X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fparser.c;h=9cb5add1d17ed7834a679eddfeda1ec9b3804ffd;hp=aa9b5399c2d347786ba40ff714c97a8727c9329f;hb=HEAD;hpb=ef4e043826e92afd32000b7d945cdf86a6e9a223 diff --git a/src/parser.c b/src/parser.c index aa9b539..9cb5add 100644 --- a/src/parser.c +++ b/src/parser.c @@ -102,7 +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_mtim.tv_sec; + fb->lmod = sb.st_mtime; fb->length = sb.st_size; fb->file = psi_string_init_interned(filename, strlen(filename), 1); @@ -149,26 +149,6 @@ bool psi_parser_process(struct psi_parser *P, struct psi_plist *tokens, return true; } -#if PSI_THREADED_PARSER -static void psi_smart_str_printf(smart_str *ss, const char *fmt, ...) -{ - va_list argv; - char *buf; - int len; - - va_start(argv, fmt); - len = vasprintf(&buf, fmt, argv); - va_end(argv); - - if (len != -1) { - smart_str_appendl_ex(ss, buf, len, 1); - free(buf); - } -} -#else -# define psi_smart_str_printf smart_str_append_printf -#endif - static inline zend_string *macro_to_constant(struct psi_parser *parser, zend_string *name, struct psi_validate_scope *scope) { @@ -235,6 +215,13 @@ void psi_parser_postprocess(struct psi_parser *P) } } else if (!psi_num_exp_validate(PSI_DATA(P), scope.macro->exp, &scope)) { continue; + } else if (psi_plist_count(scope.macro->tokens) == 1) { + struct psi_token *tok; + if (!psi_plist_get(scope.macro->tokens, 0, &tok)) { + continue; + } else if (zend_string_equals(name, tok->text)) { + continue; + } } cnst = macro_to_constant(P, name, &scope);