Revert "Remove leading underscores from identifiers directly in lexer"
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 1 Feb 2012 21:42:21 +0000 (16:42 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 1 Feb 2012 21:42:21 +0000 (16:42 -0500)
This reverts commit f071e095a2a8f76dd78becfa103b952af68e148d.

The reason why the underscores are needed in the first place is because
we want to make sure sequences and variants to not have clash between
fields called e.g. "stream" and the dynamic scope
"stream.event.header.". Therefore, we need to keep the leading
underscores as part of the internal identifier representation.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf-text/types/array.c
formats/ctf-text/types/enum.c
formats/ctf-text/types/float.c
formats/ctf-text/types/integer.c
formats/ctf-text/types/sequence.c
formats/ctf-text/types/string.c
formats/ctf-text/types/struct.c
formats/ctf-text/types/variant.c
formats/ctf/metadata/ctf-lexer.l
include/babeltrace/ctf-text/types.h

index 6dc84480c67e49eff8b0837ca81a040d13f9b4f7..3aaa633143ef48ee997d9239e26eb5e699353120 100644 (file)
@@ -41,7 +41,7 @@ int ctf_text_array_write(struct stream_pos *ppos, struct definition *definition)
                fprintf(pos->fp, " ");
                if (pos->print_names)
                        fprintf(pos->fp, "%s = ",
-                               g_quark_to_string(definition->name));
+                               rem_(g_quark_to_string(definition->name)));
        }
 
        if (elem->id == CTF_TYPE_INTEGER) {
index 12031c242fef048c6de3687636fd211790456405..b973d494b195dcd67d65931979b3d28dc06996a7 100644 (file)
@@ -44,7 +44,7 @@ int ctf_text_enum_write(struct stream_pos *ppos, struct definition *definition)
        fprintf(pos->fp, " ");
        if (pos->print_names)
                fprintf(pos->fp, "%s = ",
-                       g_quark_to_string(definition->name));
+                       rem_(g_quark_to_string(definition->name)));
 
        field_nr_saved = pos->field_nr;
        pos->field_nr = 0;
index 5897ce9d74ff84fffabfb8396fa4dc34e814fe95..77651124d000e2bb41942efc7b3ec0385802b5c6 100644 (file)
@@ -40,7 +40,7 @@ int ctf_text_float_write(struct stream_pos *ppos, struct definition *definition)
        fprintf(pos->fp, " ");
        if (pos->print_names)
                fprintf(pos->fp, "%s = ",
-                       g_quark_to_string(definition->name));
+                       rem_(g_quark_to_string(definition->name)));
 
        fprintf(pos->fp, "%g", float_definition->value);
        return 0;
index 46803f640c3376ed662883a1a4876ae5a052e3d5..f56a753bbb47177b0ab2811600f3669a2b935ce7 100644 (file)
@@ -43,7 +43,7 @@ int ctf_text_integer_write(struct stream_pos *ppos, struct definition *definitio
        fprintf(pos->fp, " ");
        if (pos->print_names)
                fprintf(pos->fp, "%s = ",
-                       g_quark_to_string(definition->name));
+                       rem_(g_quark_to_string(definition->name)));
 
        if (pos->string
            && (integer_declaration->encoding == CTF_STRING_ASCII
index 6a0472f87c5d797b3276caf8b22e24714e838a1d..3fe5ff170c381e43f7276f9cf063a5588f50e604 100644 (file)
@@ -41,7 +41,7 @@ int ctf_text_sequence_write(struct stream_pos *ppos, struct definition *definiti
                fprintf(pos->fp, " ");
                if (pos->print_names)
                        fprintf(pos->fp, "%s = ",
-                               g_quark_to_string(definition->name));
+                               rem_(g_quark_to_string(definition->name)));
        }
 
        if (elem->id == CTF_TYPE_INTEGER) {
index 82bc361f2b96931cbe1f79be93a777f5b0940fd8..1ac38c46ff86da5e6f9b282fb73a08aba41104d2 100644 (file)
@@ -43,7 +43,7 @@ int ctf_text_string_write(struct stream_pos *ppos,
        fprintf(pos->fp, " ");
        if (pos->print_names)
                fprintf(pos->fp, "%s = ",
-                       g_quark_to_string(definition->name));
+                       rem_(g_quark_to_string(definition->name)));
 
        fprintf(pos->fp, "\"%s\"", string_definition->value);
        return 0;
index b1395351d9ff7498663992915399b33cd3dc48de..a10e4da1d9c6b0ee5735112c6cd118762c5374d0 100644 (file)
@@ -42,7 +42,7 @@ int ctf_text_struct_write(struct stream_pos *ppos, struct definition *definition
                                fprintf(pos->fp, " ");
                        if (pos->print_names && definition->name != 0)
                                fprintf(pos->fp, "%s = ",
-                                       g_quark_to_string(definition->name));
+                                       rem_(g_quark_to_string(definition->name)));
                        if (pos->print_names || len > 1)
                                fprintf(pos->fp, "{");
                }
index 871b8d58a8435af3badad90cface116bbae73a93..da069c8ac3e9395b9e7ad6b4b612c2447d602daf 100644 (file)
@@ -37,7 +37,7 @@ int ctf_text_variant_write(struct stream_pos *ppos, struct definition *definitio
                        fprintf(pos->fp, " ");
                        if (pos->print_names)
                                fprintf(pos->fp, "%s = ",
-                                       g_quark_to_string(definition->name));
+                                       rem_(g_quark_to_string(definition->name)));
                        fprintf(pos->fp, "{");
                }
                pos->depth++;
index 322832bedc91ccdcde55af8caba7cdac43d17a2f..f5ff02f1aa17084b9b1c1e920d6317e7194b3252 100644 (file)
@@ -30,15 +30,6 @@ static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
        __attribute__((unused));
 static int input (yyscan_t yyscanner) __attribute__((unused));
 
-static inline
-const char *rem_(const char *str)
-{
-       if (str[0] == '_')
-               return &str[1];
-       else
-               return str;
-}
-
 %}
 
 %x comment_ml comment_sl string_lit char_const
@@ -131,7 +122,7 @@ _Imaginary                  setstring(yyextra, yylval, yytext); return _IMAGINARY;
 [1-9]{DIGIT}*{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return DECIMAL_CONSTANT;
 0{OCTALDIGIT}*{INTEGER_SUFFIX}?        setstring(yyextra, yylval, yytext); return OCTAL_CONSTANT;
 0[xX]{HEXDIGIT}+{INTEGER_SUFFIX}?      setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT;
-{IDENTIFIER}                   printf_debug("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, rem_(yytext)); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER;
+{IDENTIFIER}                   printf_debug("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER;
 [ \t\n]+                       ; /* ignore */
 .                              return ERROR;
 %%
index 3db8a1069ef97625a667cf28eb5dd26bfc243ae5..101873a9d5af801bff4508bef1183728ff75e329 100644 (file)
@@ -75,4 +75,13 @@ void print_pos_tabs(struct ctf_text_stream_pos *pos)
  */
 int print_field(struct definition *definition);
 
+static inline
+const char *rem_(const char *str)
+{
+       if (str[0] == '_')
+               return &str[1];
+       else
+               return str;
+}
+
 #endif /* _BABELTRACE_CTF_TEXT_TYPES_H */
This page took 0.039845 seconds and 4 git commands to generate.