fix enum dump; fix float formats; fix dumps
authorMichael Wallner <mike@php.net>
Thu, 22 Nov 2018 07:38:06 +0000 (08:38 +0100)
committerMichael Wallner <mike@php.net>
Tue, 4 Dec 2018 11:13:49 +0000 (12:13 +0100)
src/types/decl_enum.c
src/types/decl_type.c

index df353398d2acface6ebaf3d0291292ff7af371c7..674dd03e83e2a64b8ce6bf8f306e68062353a5f7 100644 (file)
@@ -51,13 +51,15 @@ void psi_decl_enum_free(struct psi_decl_enum **e_ptr)
 
 void psi_decl_enum_dump(struct psi_dump *dump, struct psi_decl_enum *e, unsigned level)
 {
-       bool is_anon = psi_decl_type_is_anon(e->name, "enum");
-       PSI_DUMP(dump, "enum %s%s%s {\n",
-                       is_anon ? "/* ":"", e->name->val, is_anon ? " */":"");
-       if (e->items) {
-               size_t i = 0;
-               struct psi_decl_enum_item *item;
+       size_t i = 0;
+       struct psi_decl_enum_item *item;
 
+       PSI_DUMP(dump, "enum ");
+       if (!psi_decl_type_is_anon(e->name, "enum")) {
+               PSI_DUMP(dump, "%s ", e->name->val);
+       }
+       if (e->items) {
+               PSI_DUMP(dump, "{\n");
                while (psi_plist_get(e->items, i++, &item)) {
                        if (i > 1) {
                                PSI_DUMP(dump, ",\n");
@@ -65,8 +67,8 @@ void psi_decl_enum_dump(struct psi_dump *dump, struct psi_decl_enum *e, unsigned
                        PSI_DUMP(dump, "%s", psi_t_indent(level + 1));
                        psi_decl_enum_item_dump(dump, item);
                }
+               PSI_DUMP(dump, "%s\n} ", psi_t_indent(level));
        }
-       PSI_DUMP(dump, "\n}");
 }
 
 bool psi_decl_enum_validate(struct psi_data *data, struct psi_decl_enum *e)
index 9db6de14a3c87c1e34f1e7f692884ade87a45f0d..1445c353ebe2ec8fa719498d9616114473bc836f 100644 (file)
@@ -326,24 +326,11 @@ void psi_decl_type_dump(struct psi_dump *dump, struct psi_decl_type *t, unsigned
                return;
 
        case PSI_T_ENUM:
-               PSI_DUMP(dump, "enum ");
                if (psi_decl_type_is_anon(t->name, "enum")) {
-                       size_t i = 0, c = psi_plist_count(t->real.enm->items);
-                       struct psi_decl_enum_item *item;
-
-                       PSI_DUMP(dump, "{\n");
-                       ++level;
-                       while (psi_plist_get(t->real.enm->items, i++, &item)) {
-                               PSI_DUMP(dump, "%s", psi_t_indent(level));
-                               psi_decl_enum_item_dump(dump, item);
-                               if (i < c) {
-                                       PSI_DUMP(dump, "%s\n", i < c ? "," : "");
-                               }
-                       }
-                       --level;
-                       PSI_DUMP(dump, "%s\n} ", psi_t_indent(level));
+                       psi_decl_enum_dump(dump, t->real.enm, level);
                        return;
                }
+               PSI_DUMP(dump, "enum ");
                break;
 
        case PSI_T_STRUCT: