From 52df580ccbeab244b0f9890443d681b0accadf3b Mon Sep 17 00:00:00 2001 From: Nate Choe Date: Mon, 25 Jul 2022 05:08:33 -0500 Subject: [PATCH] Fixed tokenization --- site/sitefile | 2 +- src/sitefile.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/site/sitefile b/site/sitefile index 1044b2d..ae182ac 100644 --- a/site/sitefile +++ b/site/sitefile @@ -22,7 +22,7 @@ set type text/html # The following pages are html read / site/index.html # The path / should be read from site/index.html -read /hello site/hello.html +read /hello site/hello.html # The path /hello should be read from site/hello.html throw /blog/forbidden 403 diff --git a/src/sitefile.c b/src/sitefile.c index 92128a8..ccbf4ca 100644 --- a/src/sitefile.c +++ b/src/sitefile.c @@ -67,6 +67,9 @@ static void gettoken(FILE *file, Token *ret) { for (;;) { c = fgetc(file); switch (c) { + case '#': + while (c != '\n' && c != EOF) + c = fgetc(file); case '\n': ret->type = LINE_END; return; @@ -125,7 +128,12 @@ static CommandType getcommand(FILE *file, int *argcret, char ***argvret) { case FILE_END: if (argc == 0) return PAST_END; + goto gotcommand; case LINE_END: + if (argc == 0) + return getcommand(file, argcret, argvret); + goto gotcommand; + gotcommand: *argcret = argc; *argvret = argv; return NORMAL;