From d50fc04ded36255465184a16c70eb4c50acdb199 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 26 Apr 2009 12:42:11 +0300 Subject: Introduce formats in preprocessor variables. * configure.ac: Version 1.9.90 * NEWS: Likewise. * etc/Makefile.am (EXTRA_DIST): Add logfilter.awk uptmpl.sed * etc/logfilter.awk: New file * etc/uptmpl.sed: New file * etc/tagr.tmpl: Update * etc/upgrade.awk: Add copyleft header * gnulib.modules: Add fprintftime. * src/graph.c (rate_unit): Change to "Bytes per Second". (number_suffix, number_suffix_count): Move to grid.c * src/html.gram.y: Work with formats. * src/html.lex.l: Likewise. * src/output.c (update_output): Store NOW as a number and provide a formatting function for it. * src/tagr.h (union value, value_format_fn): New types. (pp_value_t): New members: fmt, format (add_numeric_value, add_string_value): Change return type. (init_value): New proto. --- src/html.lex.l | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/html.lex.l') diff --git a/src/html.lex.l b/src/html.lex.l index 9f323dd..931bfc1 100644 --- a/src/html.lex.l +++ b/src/html.lex.l @@ -44,7 +44,7 @@ N [0-9]+ if (find_value (yytext+1, &yylval.value)) { yyerror ("unknown identifier"); - yylval.value.type = unspecified_value; + init_value (&yylval.value, unspecified_value, NULL); } return IDENT; } @@ -53,7 +53,7 @@ N [0-9]+ if (find_value (yytext+2, &yylval.value)) { yyerror ("unknown identifier"); - yylval.value.type = unspecified_value; + init_value (&yylval.value, unspecified_value, NULL); } return IDENT; } @@ -63,7 +63,7 @@ N [0-9]+ if (find_value (yytext+2, &yylval.value)) { yyerror ("unknown identifier"); - yylval.value.type = unspecified_value; + init_value (&yylval.value, unspecified_value, NULL); } else { @@ -71,6 +71,27 @@ N [0-9]+ } return IDENT; } +\$\({NAME}:[^)]+\) { + pp_value_t val; + char *p = strchr (yytext, ':'); + *p++ = 0; + if (find_value (yytext+2, &val)) + { + yyerror ("unknown identifier"); + init_value (&yylval.value, unspecified_value, NULL); + } + else + { + size_t len = strlen (p) - 1; + init_value (&yylval.value, val.type, &val.v); + yylval.value.prec = val.prec; + yylval.value.format = val.format; + yylval.value.fmt = xmalloc (len + 1); + memcpy (yylval.value.fmt, p, len); + yylval.value.fmt[len] = 0; + } + return IDENT; +} \$\{ return OBRACE; \$\} return CBRACE; [ \t]+ ; -- cgit v1.2.1