projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
* threaded parser
[m6w6/ext-psi]
/
src
/
parser.c
diff --git
a/src/parser.c
b/src/parser.c
index 24028166df0c3eb310bb7185e12a6b4cc8b09d1a..cf06f6af7694c2ddfc1f26342cee51cb9114d550 100644
(file)
--- a/
src/parser.c
+++ b/
src/parser.c
@@
-98,7
+98,7
@@
struct psi_parser_input *psi_parser_open_file(struct psi_parser *P,
memset(fb->buffer + sb.st_size, 0, psi_parser_maxfill());
fb->length = sb.st_size;
memset(fb->buffer + sb.st_size, 0, psi_parser_maxfill());
fb->length = sb.st_size;
- fb->file =
zend
_string_init_interned(filename, strlen(filename), 1);
+ fb->file =
psi
_string_init_interned(filename, strlen(filename), 1);
return fb;
}
return fb;
}
@@
-119,7
+119,7
@@
struct psi_parser_input *psi_parser_open_string(struct psi_parser *P,
memset(sb->buffer + length, 0, psi_parser_maxfill());
sb->length = length;
memset(sb->buffer + length, 0, psi_parser_maxfill());
sb->length = length;
- sb->file =
zend
_string_init_interned("<stdin>", strlen("<stdin>"), 1);
+ sb->file =
psi
_string_init_interned("<stdin>", strlen("<stdin>"), 1);
return sb;
}
return sb;
}
@@
-150,23
+150,44
@@
static inline zend_string *macro_to_constant(struct psi_parser *parser,
size_t i = 0;
struct psi_token *tok;
size_t i = 0;
struct psi_token *tok;
+#if HAVE_ASPRINTF
+ int persistent = 1;
+
+ smart_str_appendl_ex(&str, ZEND_STRL("const psi\\"), 1);
+ smart_str_append_ex(&str, name, 1);
+ smart_str_appendl_ex(&str, ZEND_STRL(" = "), 1);
+#else
+ int persistent = 0;
+
smart_str_append_printf(&str, "const psi\\%s = ", name->val);
smart_str_append_printf(&str, "const psi\\%s = ", name->val);
+#endif
if (scope->macro->exp) {
if (scope->macro->exp) {
+#if HAVE_ASPRINTF
+ char *astr = NULL;
+ struct psi_dump dump = {{.hn = &astr},
+ .fun = (psi_dump_cb) asprintf};
+#else
struct psi_dump dump = {{.hn = &str},
.fun = (psi_dump_cb) smart_str_append_printf};
struct psi_dump dump = {{.hn = &str},
.fun = (psi_dump_cb) smart_str_append_printf};
+#endif
psi_num_exp_dump(&dump, scope->macro->exp);
psi_num_exp_dump(&dump, scope->macro->exp);
+
+#if HAVE_ASPRINTF
+ smart_str_appends_ex(&str, astr, 1);
+ free(astr);
+#endif
} else while (psi_plist_get(scope->macro->tokens, i++, &tok)) {
if (tok->type == PSI_T_QUOTED_STRING) {
} else while (psi_plist_get(scope->macro->tokens, i++, &tok)) {
if (tok->type == PSI_T_QUOTED_STRING) {
- smart_str_appendc
(&str, '"'
);
+ smart_str_appendc
_ex(&str, '"', persistent
);
}
}
- smart_str_append
(&str, tok->tex
t);
+ smart_str_append
_ex(&str, tok->text, persisten
t);
if (tok->type == PSI_T_QUOTED_STRING) {
if (tok->type == PSI_T_QUOTED_STRING) {
- smart_str_appendc
(&str, '"'
);
+ smart_str_appendc
_ex(&str, '"', persistent
);
}
}
- smart_str_appendc
(&str, ' '
);
+ smart_str_appendc
_ex(&str, ' ', persistent
);
}
}
- smart_str_appendl
(&str, ";\n", 2
);
+ smart_str_appendl
_ex(&str, ";\n", 2, persistent
);
return smart_str_extract(&str);
}
return smart_str_extract(&str);
}