projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
fix enum dump; fix float formats; fix dumps
[m6w6/ext-psi]
/
src
/
types
/
cpp_exp.c
diff --git
a/src/types/cpp_exp.c
b/src/types/cpp_exp.c
index ded4db5b614ea86a548d3aa0a3f7dfb6f5f7154c..aa70c639df763955c5cea756c618dc150490218c 100644
(file)
--- a/
src/types/cpp_exp.c
+++ b/
src/types/cpp_exp.c
@@
-32,7
+32,7
@@
struct psi_cpp_exp *psi_cpp_exp_init(token_t type, void *data)
{
struct psi_cpp_exp *psi_cpp_exp_init(token_t type, void *data)
{
- struct psi_cpp_exp *exp =
calloc(1, sizeof(*exp)
);
+ struct psi_cpp_exp *exp =
pecalloc(1, sizeof(*exp), 1
);
switch ((exp->type = type)) {
case PSI_T_WARNING:
switch ((exp->type = type)) {
case PSI_T_WARNING:
@@
-101,9
+101,9
@@
void psi_cpp_exp_free(struct psi_cpp_exp **exp_ptr)
}
}
}
}
-void psi_cpp_exp_dump(
int fd
, struct psi_cpp_exp *exp)
+void psi_cpp_exp_dump(
struct psi_dump *dump
, struct psi_cpp_exp *exp)
{
{
-
dprintf(fd
, "#%s ", exp->token->text->val);
+
PSI_DUMP(dump
, "#%s ", exp->token->text->val);
switch (exp->type) {
case PSI_T_WARNING:
case PSI_T_ERROR:
switch (exp->type) {
case PSI_T_WARNING:
case PSI_T_ERROR:
@@
-114,23
+114,23
@@
void psi_cpp_exp_dump(int fd, struct psi_cpp_exp *exp)
case PSI_T_UNDEF:
case PSI_T_IFDEF:
case PSI_T_IFNDEF:
case PSI_T_UNDEF:
case PSI_T_IFDEF:
case PSI_T_IFNDEF:
-
dprintf(fd
, "%s", exp->data.tok->text->val);
+
PSI_DUMP(dump
, "%s", exp->data.tok->text->val);
break;
case PSI_T_IMPORT:
case PSI_T_INCLUDE:
case PSI_T_INCLUDE_NEXT:
if (exp->data.tok->type == PSI_T_CPP_HEADER) {
break;
case PSI_T_IMPORT:
case PSI_T_INCLUDE:
case PSI_T_INCLUDE_NEXT:
if (exp->data.tok->type == PSI_T_CPP_HEADER) {
-
dprintf(fd
, "<%s>", exp->data.tok->text->val);
+
PSI_DUMP(dump
, "<%s>", exp->data.tok->text->val);
} else {
} else {
-
dprintf(fd
, "\"%s\"", exp->data.tok->text->val);
+
PSI_DUMP(dump
, "\"%s\"", exp->data.tok->text->val);
}
break;
case PSI_T_DEFINE:
}
break;
case PSI_T_DEFINE:
- psi_cpp_macro_decl_dump(
fd
, exp->data.decl);
+ psi_cpp_macro_decl_dump(
dump
, exp->data.decl);
break;
case PSI_T_IF:
case PSI_T_ELIF:
break;
case PSI_T_IF:
case PSI_T_ELIF:
- psi_num_exp_dump(
fd
, exp->data.num);
+ psi_num_exp_dump(
dump
, exp->data.num);
break;
case PSI_T_ENDIF:
case PSI_T_ELSE:
break;
case PSI_T_ENDIF:
case PSI_T_ELSE:
@@
-140,7
+140,7
@@
void psi_cpp_exp_dump(int fd, struct psi_cpp_exp *exp)
assert(0);
break;
}
assert(0);
break;
}
-
dprintf(fd
, "\n");
+
PSI_DUMP(dump
, "\n");
}
}
@@
-184,7
+184,8
@@
void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d
exp->token->text->val, cpp->level, cpp->skip);
#if PSI_CPP_DEBUG
exp->token->text->val, cpp->level, cpp->skip);
#if PSI_CPP_DEBUG
- psi_cpp_exp_dump(2, exp);
+ PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP exec -> ");
+ PSI_DEBUG_DUMP(cpp->parser, psi_cpp_exp_dump, exp);
#endif
switch (exp->type) {
#endif
switch (exp->type) {
@@
-296,21
+297,24
@@
void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_d
case PSI_T_INCLUDE:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE)) {
case PSI_T_INCLUDE:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE)) {
- D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
+ D->error(D, exp->token, PSI_WARNING, "Failed to include %s: %s",
+ exp->data.tok->text->val, strerror(errno));
}
}
break;
case PSI_T_INCLUDE_NEXT:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE_NEXT)) {
}
}
break;
case PSI_T_INCLUDE_NEXT:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE_NEXT)) {
- D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
+ D->error(D, exp->token, PSI_WARNING, "Failed to include next %s: %s",
+ exp->data.tok->text->val, strerror(errno));
}
}
break;
case PSI_T_IMPORT:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE_ONCE)) {
}
}
break;
case PSI_T_IMPORT:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE_ONCE)) {
- D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
+ D->error(D, exp->token, PSI_WARNING, "Failed to include once %s: %s",
+ exp->data.tok->text->val, strerror(errno));
}
}
break;
}
}
break;