if (cpp->skip) {
if (!cpp->do_cpp) {
#if PSI_CPP_DEBUG
- psi_debug_lock(PSI_DATA(cpp->parser));
- PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP skip ");
- PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, current);
- psi_debug_unlock(PSI_DATA(cpp->parser));
+ PSI_DEBUG_LOCK(cpp->parser,
+ PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP skip ");
+ PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, current);
+ );
#endif
psi_cpp_tokiter_del_cur(cpp, true);
continue;
/* leave EOLs in the input stream, else we might end up
* with a hash not preceded with a new line after include */
+ psi_cpp_tokiter_add(cpp, current);
psi_plist_pop(cpp->tokens.exec, NULL);
psi_plist_clean(cpp->tokens.exec);
}
psi_plist_free(cpp->tokens.exec);
+ cpp->tokens.exec = NULL;
return true;
}
zend_hash_del(&cpp->expanding, expanding->text);
}
- if (cpp->tokens.next) {
- free(cpp->tokens.iter);
- cpp->tokens.iter = cpp->tokens.next;
- cpp->tokens.next = NULL;
+ *tokens = cpp->tokens.next;
+ psi_plist_free(cpp->tokens.iter);
+ if (cpp->tokens.exec) {
+ assert(!psi_plist_count(cpp->tokens.exec));
+ psi_plist_free(cpp->tokens.exec);
}
- *tokens = cpp->tokens.iter;
-
- if (temp.tokens.iter) {
- cpp->tokens.iter = temp.tokens.iter;
- cpp->tokens.next = temp.tokens.next;
- cpp->tokens.exec = temp.tokens.exec;
- }
+ cpp->tokens = temp.tokens;
cpp->index = temp.index;
cpp->skip = temp.skip;
cpp->level = temp.level;
if (psi_builtin_exists(tok->text)) {
defined = true;
} else if (!zend_hash_exists(&cpp->expanding, tok->text)) {
- struct psi_macro_decl *macro = zend_hash_find_ptr(&cpp->defs, tok->text);
-
- if (macro) {
- defined = true;
- }
+ defined = zend_hash_exists(&cpp->defs, tok->text);
}
#if PSI_CPP_DEBUG
- psi_debug_lock(PSI_DATA(cpp->parser));
- PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP defined -> %s ", defined ? "true" : "false");
- if (defined) {
- struct psi_cpp_macro_decl *macro = zend_hash_find_ptr(&cpp->defs, tok->text);
- if (macro) {
- PSI_DEBUG_PRINT(cpp->parser, " @ %s:%u ", macro->token->file->val, macro->token->line);
- }
- } else {
- zend_string *key;
+ PSI_DEBUG_LOCK(cpp->parser,
+ PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP defined -> %s ", defined ? "true" : "false");
+ if (defined) {
+ struct psi_cpp_macro_decl *macro = zend_hash_find_ptr(&cpp->defs, tok->text);
+ if (macro) {
+ PSI_DEBUG_PRINT(cpp->parser, " @ %s:%u ", macro->token->file->val, macro->token->line);
+ }
+ } else {
+ zend_string *key;
- PSI_DEBUG_PRINT(cpp->parser, " expanding=");
- ZEND_HASH_FOREACH_STR_KEY(&cpp->expanding, key)
- {
- PSI_DEBUG_PRINT(cpp->parser, "%s,", key->val);
- }
- ZEND_HASH_FOREACH_END();
- PSI_DEBUG_PRINT(cpp->parser, "\t");
- }
- PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, tok);
- psi_debug_unlock(PSI_DATA(cpp->parser));
+ PSI_DEBUG_PRINT(cpp->parser, " expanding=");
+ ZEND_HASH_FOREACH_STR_KEY(&cpp->expanding, key)
+ {
+ PSI_DEBUG_PRINT(cpp->parser, "%s,", key->val);
+ }
+ ZEND_HASH_FOREACH_END();
+ PSI_DEBUG_PRINT(cpp->parser, "\t");
+ }
+ PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, tok);
+ );
#endif
}
"'%s' previously defined", old->token->text->val);
}
#if PSI_CPP_DEBUG
- psi_debug_lock(PSI_DATA(cpp->parser));
- if (decl->exp) {
- PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP MACRO num_exp -> ");
- } else {
- PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP MACRO decl -> ");
- }
- PSI_DEBUG_DUMP(cpp->parser, psi_cpp_macro_decl_dump, decl);
- PSI_DEBUG_PRINT(cpp->parser, "\n");
- psi_debug_unlock(PSI_DATA(cpp->parser));
+ PSI_DEBUG_LOCK(cpp->parser,
+ if (decl->exp) {
+ PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP MACRO num_exp -> ");
+ } else {
+ PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP MACRO decl -> ");
+ }
+ PSI_DEBUG_DUMP(cpp->parser, psi_cpp_macro_decl_dump, decl);
+ PSI_DEBUG_PRINT(cpp->parser, "\n");
+ );
#endif
zend_hash_update_ptr(&cpp->defs, decl->token->text, decl);
}