X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fparser.c;h=d133cfb475cd394bba4a3bf5953daa02ba4a57d7;hp=2a89068e74d2ca6ed65ccf2b7d35a32c4f5c2e89;hb=c57af11984f284e7e9de5bde5c189c416004638c;hpb=cd0567b4052ee24259bc6b8a9858af9d26f3de48 diff --git a/src/parser.c b/src/parser.c index 2a89068..d133cfb 100644 --- a/src/parser.c +++ b/src/parser.c @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -101,6 +102,7 @@ struct psi_parser_input *psi_parser_open_file(struct psi_parser *P, memset(fb->buffer + sb.st_size, 0, psi_parser_maxfill()); + fb->lmod = sb.st_mtime; fb->length = sb.st_size; fb->file = psi_string_init_interned(filename, strlen(filename), 1); @@ -122,6 +124,7 @@ struct psi_parser_input *psi_parser_open_string(struct psi_parser *P, memcpy(sb->buffer, string, length); memset(sb->buffer + length, 0, psi_parser_maxfill()); + sb->lmod = time(NULL); sb->length = length; sb->file = psi_string_init_interned("", strlen(""), 1); @@ -270,16 +273,21 @@ bool psi_parser_parse(struct psi_parser *P, struct psi_parser_input *I) struct psi_plist *scanned, *preproc; size_t processed = 0; + P->input = I; + if (!(scanned = psi_parser_scan(P, I))) { + P->input = NULL; return false; } if (!(preproc = psi_parser_preprocess(P, &scanned))) { + P->input = NULL; psi_plist_free(scanned); return false; } if (!psi_parser_process(P, preproc, &processed)) { + P->input = NULL; psi_plist_free(preproc); return false; } @@ -287,6 +295,7 @@ bool psi_parser_parse(struct psi_parser *P, struct psi_parser_input *I) psi_parser_postprocess(P); psi_plist_free(preproc); + P->input = NULL; return true; }