From: Bruno Haible Date: Wed, 23 Aug 2000 21:06:21 +0000 (+0000) Subject: Tweak string control sequence parser. X-Git-Tag: v0.10.36~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21f5a0899526957efb6e162e3fcd98db7d56a9f9;p=thirdparty%2Fgettext.git Tweak string control sequence parser. --- diff --git a/src/ChangeLog b/src/ChangeLog index 6bd700bbc..a956ef4d3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2000-08-23 Bruno Haible + + * po-lex.c (ALERT_CHAR): New constant macro. + (control_sequence): Accept \a. Don't accept \X. + 2000-08-23 Ulrich Drepper * po-lex.c (control_sequence): Unget character which ended \x.. diff --git a/src/po-lex.c b/src/po-lex.c index 549aa4971..248ddc3a6 100644 --- a/src/po-lex.c +++ b/src/po-lex.c @@ -49,6 +49,12 @@ #include "error.h" #include "po-gram-gen2.h" +#if HAVE_C_BACKSLASH_A +# define ALERT_CHAR '\a' +#else +# define ALERT_CHAR '\7' +#endif + static FILE *fp; lex_pos_ty gram_pos; @@ -271,6 +277,9 @@ control_sequence () case 'v': return '\v'; + case 'a': + return ALERT_CHAR; + case '\\': case '"': return c; @@ -278,10 +287,13 @@ control_sequence () case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': val = 0; - for (max = 0; max < 3; ++max) + max = 0; + for (;;) { /* Warning: not portable, can't depend on '0'..'7' ordering. */ - val = val * 8 + c - '0'; + val = val * 8 + (c - '0'); + if (++max == 3) + break; c = lex_getc (); switch (c) { @@ -292,12 +304,12 @@ control_sequence () default: break; } + lex_ungetc (c); break; } - lex_ungetc (c); return val; - case 'x': case 'X': + case 'x': c = lex_getc (); if (c == EOF || !isxdigit (c)) break; @@ -328,10 +340,12 @@ control_sequence () default: break; } + lex_ungetc (c); break; } - lex_ungetc (c); return val; + + /* FIXME: \u and \U are not handled. */ } po_gram_error (_("invalid control sequence")); return ' '; @@ -435,6 +449,7 @@ po_gram_lex () } buf[bufpos] = 0; + /* FIXME: Treatment of embedded \000 chars is incorrect. */ po_gram_lval.string = xstrdup (buf); return STRING;