summaryrefslogtreecommitdiff
path: root/gettext-tools/src/format-python-brace.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-06-11 13:13:21 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-06-11 13:13:21 +0000
commit500500ec9b7b0d0cef90b48c9b4ddc8866b5f19c (patch)
tree1d7b3e6fab5c199fdbbaab53ee9532de6a4c8cf7 /gettext-tools/src/format-python-brace.c
parent6eb5949dd99d174393465069c2fd0bab32deddcc (diff)
downloadgettext-tarball-500500ec9b7b0d0cef90b48c9b4ddc8866b5f19c.tar.gz
Diffstat (limited to 'gettext-tools/src/format-python-brace.c')
-rw-r--r--gettext-tools/src/format-python-brace.c69
1 files changed, 38 insertions, 31 deletions
diff --git a/gettext-tools/src/format-python-brace.c b/gettext-tools/src/format-python-brace.c
index 4323230..c76088c 100644
--- a/gettext-tools/src/format-python-brace.c
+++ b/gettext-tools/src/format-python-brace.c
@@ -1,5 +1,5 @@
/* Python brace format strings.
- Copyright (C) 2004, 2006-2007, 2013, 2015 Free Software Foundation,
+ Copyright (C) 2004, 2006-2007, 2013, 2015-2016 Free Software Foundation,
Inc.
Written by Daiki Ueno <ueno@gnu.org>, 2013.
@@ -140,42 +140,49 @@ parse_directive (struct spec *spec,
return false;
}
- c = *format;
- if (c == '.')
+ /* Parse '.' (getattr) or '[..]' (getitem) operators followed by a
+ name. If must not recurse, but can be specifed in a chain, such
+ as "foo.bar.baz[0]". */
+ for (;;)
{
- format++;
- if (!parse_named_field (spec, &format, translated, fdi,
- invalid_reason))
- {
- *invalid_reason =
- xasprintf (_("In the directive number %u, '%c' cannot start a getattr argument."), spec->directives, *format);
- FDI_SET (format, FMTDIR_ERROR);
- return false;
- }
c = *format;
- }
- else if (c == '[')
- {
- format++;
- if (!parse_named_field (spec, &format, translated, fdi,
- invalid_reason)
- && !parse_numeric_field (spec, &format, translated, fdi,
- invalid_reason))
+
+ if (c == '.')
{
- *invalid_reason =
- xasprintf (_("In the directive number %u, '%c' cannot start a getitem argument."), spec->directives, *format);
- FDI_SET (format, FMTDIR_ERROR);
- return false;
+ format++;
+ if (!parse_named_field (spec, &format, translated, fdi,
+ invalid_reason))
+ {
+ *invalid_reason =
+ xasprintf (_("In the directive number %u, '%c' cannot start a getattr argument."), spec->directives, *format);
+ FDI_SET (format, FMTDIR_ERROR);
+ return false;
+ }
}
-
- c = *format++;
- if (c != ']')
+ else if (c == '[')
{
- *invalid_reason = INVALID_UNTERMINATED_DIRECTIVE ();
- FDI_SET (format, FMTDIR_ERROR);
- return false;
+ format++;
+ if (!parse_named_field (spec, &format, translated, fdi,
+ invalid_reason)
+ && !parse_numeric_field (spec, &format, translated, fdi,
+ invalid_reason))
+ {
+ *invalid_reason =
+ xasprintf (_("In the directive number %u, '%c' cannot start a getitem argument."), spec->directives, *format);
+ FDI_SET (format, FMTDIR_ERROR);
+ return false;
+ }
+
+ c = *format++;
+ if (c != ']')
+ {
+ *invalid_reason = INVALID_UNTERMINATED_DIRECTIVE ();
+ FDI_SET (format, FMTDIR_ERROR);
+ return false;
+ }
}
- c = *format;
+ else
+ break;
}
if (c == ':')