phase2_ungetc (c);
}
-/* Number of open '{' tokens. */
-static int brace_depth;
-
/* Number of open template literals `...${ */
static int template_literal_depth;
+/* Number of open '{' tokens, at each template literal level.
+ The "current" element is brace_depths[template_literal_depth]. */
+static int *brace_depths;
+/* Number of allocated elements in brace_depths. */
+static size_t brace_depths_alloc;
+
+/* Adds a new brace_depths level after template_literal_depth was
+ incremented. */
+static void
+new_brace_depth_level (void)
+{
+ if (template_literal_depth == brace_depths_alloc)
+ {
+ brace_depths_alloc = 2 * brace_depths_alloc + 1;
+ /* Now template_literal_depth < brace_depths_alloc. */
+ brace_depths =
+ (int *) xrealloc (brace_depths, brace_depths_alloc * sizeof (int));
+ }
+ brace_depths[template_literal_depth] = 0;
+}
+
/* Number of open XML elements. */
static int xml_element_depth;
static bool inside_embedded_js_in_xml;
mixed_string_buffer_destroy (&msb);
tp->type = last_token_type = token_type_ltemplate;
template_literal_depth++;
+ new_brace_depth_level ();
break;
}
if (xml_element_depth > 0 && !inside_embedded_js_in_xml)
inside_embedded_js_in_xml = true;
else
- brace_depth++;
+ brace_depths[template_literal_depth]++;
tp->type = last_token_type = token_type_other;
return;
case '}':
if (xml_element_depth > 0 && inside_embedded_js_in_xml)
inside_embedded_js_in_xml = false;
- else if (brace_depth > 0)
- brace_depth--;
+ else if (brace_depths[template_literal_depth] > 0)
+ brace_depths[template_literal_depth]--;
else if (template_literal_depth > 0)
{
/* Middle or right part of template literal. */
last_comment_line = -1;
last_non_comment_line = -1;
- brace_depth = 0;
template_literal_depth = 0;
+ new_brace_depth_level ();
xml_element_depth = 0;
inside_embedded_js_in_xml = false;
var s8 = `a${`b${`c`+d}`}e`;
var s9 = _("a normal string");
var s10 = `abc${foo({},_('should be extracted'))}xyz`;
+var f1 = function () {
+ return _("first normal string") + `${foo}` + _("second normal string");
+};
+var s11 = _("another normal string");
EOF
: ${XGETTEXT=xgettext}
msgid "should be extracted"
msgstr ""
+
+msgid "first normal string"
+msgstr ""
+
+msgid "second normal string"
+msgstr ""
+
+msgid "another normal string"
+msgstr ""
EOF
: ${DIFF=diff}