From: Mathieu Desnoyers Date: Wed, 1 Feb 2012 20:43:51 +0000 (-0500) Subject: Remove leading underscores from identifiers directly in lexer X-Git-Tag: v0.9~7 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=f071e095a2a8f76dd78becfa103b952af68e148d Remove leading underscores from identifiers directly in lexer Signed-off-by: Mathieu Desnoyers --- diff --git a/formats/ctf-text/types/array.c b/formats/ctf-text/types/array.c index 3aaa6331..6dc84480 100644 --- a/formats/ctf-text/types/array.c +++ b/formats/ctf-text/types/array.c @@ -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 = ", - rem_(g_quark_to_string(definition->name))); + g_quark_to_string(definition->name)); } if (elem->id == CTF_TYPE_INTEGER) { diff --git a/formats/ctf-text/types/enum.c b/formats/ctf-text/types/enum.c index b973d494..12031c24 100644 --- a/formats/ctf-text/types/enum.c +++ b/formats/ctf-text/types/enum.c @@ -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 = ", - rem_(g_quark_to_string(definition->name))); + g_quark_to_string(definition->name)); field_nr_saved = pos->field_nr; pos->field_nr = 0; diff --git a/formats/ctf-text/types/float.c b/formats/ctf-text/types/float.c index 77651124..5897ce9d 100644 --- a/formats/ctf-text/types/float.c +++ b/formats/ctf-text/types/float.c @@ -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 = ", - rem_(g_quark_to_string(definition->name))); + g_quark_to_string(definition->name)); fprintf(pos->fp, "%g", float_definition->value); return 0; diff --git a/formats/ctf-text/types/integer.c b/formats/ctf-text/types/integer.c index f56a753b..46803f64 100644 --- a/formats/ctf-text/types/integer.c +++ b/formats/ctf-text/types/integer.c @@ -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 = ", - rem_(g_quark_to_string(definition->name))); + g_quark_to_string(definition->name)); if (pos->string && (integer_declaration->encoding == CTF_STRING_ASCII diff --git a/formats/ctf-text/types/sequence.c b/formats/ctf-text/types/sequence.c index 3fe5ff17..6a0472f8 100644 --- a/formats/ctf-text/types/sequence.c +++ b/formats/ctf-text/types/sequence.c @@ -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 = ", - rem_(g_quark_to_string(definition->name))); + g_quark_to_string(definition->name)); } if (elem->id == CTF_TYPE_INTEGER) { diff --git a/formats/ctf-text/types/string.c b/formats/ctf-text/types/string.c index 1ac38c46..82bc361f 100644 --- a/formats/ctf-text/types/string.c +++ b/formats/ctf-text/types/string.c @@ -43,7 +43,7 @@ int ctf_text_string_write(struct stream_pos *ppos, fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", - rem_(g_quark_to_string(definition->name))); + g_quark_to_string(definition->name)); fprintf(pos->fp, "\"%s\"", string_definition->value); return 0; diff --git a/formats/ctf-text/types/struct.c b/formats/ctf-text/types/struct.c index a10e4da1..b1395351 100644 --- a/formats/ctf-text/types/struct.c +++ b/formats/ctf-text/types/struct.c @@ -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 = ", - rem_(g_quark_to_string(definition->name))); + g_quark_to_string(definition->name)); if (pos->print_names || len > 1) fprintf(pos->fp, "{"); } diff --git a/formats/ctf-text/types/variant.c b/formats/ctf-text/types/variant.c index da069c8a..871b8d58 100644 --- a/formats/ctf-text/types/variant.c +++ b/formats/ctf-text/types/variant.c @@ -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 = ", - rem_(g_quark_to_string(definition->name))); + g_quark_to_string(definition->name)); fprintf(pos->fp, "{"); } pos->depth++; diff --git a/formats/ctf/metadata/ctf-lexer.l b/formats/ctf/metadata/ctf-lexer.l index f5ff02f1..322832be 100644 --- a/formats/ctf/metadata/ctf-lexer.l +++ b/formats/ctf/metadata/ctf-lexer.l @@ -30,6 +30,15 @@ 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 @@ -122,7 +131,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("\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER; +{IDENTIFIER} printf_debug("\n", yytext); setstring(yyextra, yylval, rem_(yytext)); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER; [ \t\n]+ ; /* ignore */ . return ERROR; %% diff --git a/include/babeltrace/ctf-text/types.h b/include/babeltrace/ctf-text/types.h index 101873a9..3db8a106 100644 --- a/include/babeltrace/ctf-text/types.h +++ b/include/babeltrace/ctf-text/types.h @@ -75,13 +75,4 @@ 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 */