From: Bruno Haible Date: Tue, 3 May 2005 10:49:47 +0000 (+0000) Subject: Fix interpretation of backslashes in $"..." strings. X-Git-Tag: v0.15~534 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a548d13f2b9126fbce2b64b981570a29d2da7314;p=thirdparty%2Fgettext.git Fix interpretation of backslashes in $"..." strings. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 0036cab67..9b3c88191 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,12 @@ +2005-05-01 Bruno Haible + + * x-sh.c (open_singlequote_terminator): New variable. + (saw_opening_singlequote): Set it. + (phase2_getc): Handle the case of open_singlequote_terminator == '"'. + (read_word): Likewise. Treat i18n quotes like single quotes with + terminator '"'. + Reported by Jakub Bogusz . + 2005-05-01 Bruno Haible Improved error message. diff --git a/gettext-tools/src/x-sh.c b/gettext-tools/src/x-sh.c index 66faadd78..cd66eac33 100644 --- a/gettext-tools/src/x-sh.c +++ b/gettext-tools/src/x-sh.c @@ -1,5 +1,5 @@ /* xgettext sh backend. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2005 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify @@ -362,6 +362,10 @@ static bool open_doublequote; innermost backquotes nesting. */ static bool open_singlequote; +/* The expected terminator of the currently open single-quote. + Usually '\'', but can be '"' for i18n-quotes. */ +static char open_singlequote_terminator; + /* Functions to update the state. */ @@ -407,6 +411,7 @@ saw_opening_singlequote () if (open_doublequote || open_singlequote) abort (); open_singlequote = true; + open_singlequote_terminator = '\''; } static inline void @@ -529,8 +534,16 @@ phase2_getc () if (c == EOF) return c; if (c == '\'') - return (open_doublequote ? QUOTED (c) : c); - if (!open_singlequote) + return ((open_doublequote + || (open_singlequote && open_singlequote_terminator != c)) + ? QUOTED (c) + : c); + if (open_singlequote) + { + if (c == open_singlequote_terminator) + return c; + } + else { if (c == '"' || c == '$') return c; @@ -573,7 +586,10 @@ phase2_getc () return '\\'; } else - return (open_doublequote ? QUOTED (c) : c); + return ((open_doublequote + || (open_singlequote && open_singlequote_terminator != c)) + ? QUOTED (c) + : c); } else if (c == '"') { @@ -590,7 +606,7 @@ phase2_getc () return '\\'; } else - return QUOTED (c); + return (open_singlequote_terminator != c ? QUOTED (c) : c); } else { @@ -990,7 +1006,8 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) lex_pos_ty pos; struct token string; - saw_opening_doublequote (); + saw_opening_singlequote (); + open_singlequote_terminator = '"'; pos.file_name = logical_file_name; pos.line_number = line_number; init_token (&string); @@ -1001,7 +1018,7 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) break; if (c == '"') { - saw_closing_doublequote (); + saw_closing_singlequote (); break; } grow_token (&string); @@ -1042,7 +1059,12 @@ read_word (struct word *wp, int looking_for, flag_context_ty context) if (c == '"') { - if (!open_doublequote) + if (open_singlequote && open_singlequote_terminator == '"') + { + /* Handle a closing i18n quote. */ + saw_closing_singlequote (); + } + else if (!open_doublequote) { /* Handle an opening double quote. */ saw_opening_doublequote (); diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 7b45ca8e5..2d6200da0 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,8 @@ +2005-05-01 Bruno Haible + + * xgettext-sh-4: New file. + * Makefile.am (TESTS): Add it. + 2005-03-20 Bruno Haible * gettext-6: New file. diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 542270175..2ac99534d 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -78,7 +78,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \ xgettext-properties-1 \ xgettext-python-1 xgettext-python-2 \ xgettext-scheme-1 \ - xgettext-sh-1 xgettext-sh-2 xgettext-sh-3 \ + xgettext-sh-1 xgettext-sh-2 xgettext-sh-3 xgettext-sh-4 \ xgettext-smalltalk-1 \ xgettext-stringtable-1 \ xgettext-tcl-1 xgettext-tcl-2 \