+2005-05-01 Bruno Haible <bruno@clisp.org>
+
+ * 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 <qboosh@pld-linux.org>.
+
2005-05-01 Bruno Haible <bruno@clisp.org>
Improved error message.
/* xgettext sh backend.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
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. */
if (open_doublequote || open_singlequote)
abort ();
open_singlequote = true;
+ open_singlequote_terminator = '\'';
}
static inline void
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;
return '\\';
}
else
- return (open_doublequote ? QUOTED (c) : c);
+ return ((open_doublequote
+ || (open_singlequote && open_singlequote_terminator != c))
+ ? QUOTED (c)
+ : c);
}
else if (c == '"')
{
return '\\';
}
else
- return QUOTED (c);
+ return (open_singlequote_terminator != c ? QUOTED (c) : c);
}
else
{
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);
break;
if (c == '"')
{
- saw_closing_doublequote ();
+ saw_closing_singlequote ();
break;
}
grow_token (&string);
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 ();