{
size_t n = input.length;
const struct substring enddefine = ss_cstr ("!ENDDEFINE");
- for (size_t i = 0; i + enddefine.length <= n; i++)
- if (input.string[i] == '!'
- && ss_equals_case (ss_substr (input, i, enddefine.length), enddefine))
- return i;
- return SIZE_MAX;
+ for (int ofs = 0;;)
+ {
+ /* Skip !ENDDEFINE in comment. */
+ ofs = skip_spaces_and_comments (input.string, n, true, ofs);
+ if (ofs + enddefine.length > n)
+ return SIZE_MAX;
+
+ char c = input.string[ofs];
+ if (c == '!'
+ && ss_equals_case (ss_substr (input, ofs, enddefine.length),
+ enddefine))
+ return ofs;
+ else if (c == '\'' || c == '"')
+ {
+ /* Skip quoted !ENDDEFINE. */
+ ofs++;
+ for (;;)
+ {
+ if (ofs >= n)
+ return SIZE_MAX;
+ else if (input.string[ofs++] == c)
+ break;
+ }
+ }
+ else
+ ofs++;
+ }
}
/* We are in the body of a macro definition, looking for additional lines of
AT_KEYWORDS([segment])
AT_DATA([input], [dnl
define !macro1()
-var1 var2 var3
+var1 var2 var3 "!enddefine"
!enddefine.
])
AT_DATA([expout-base], [dnl
spaces
newline \n (DEFINE)
-macro_body var1_var2_var3
+macro_body var1_var2_var3_"!enddefine"
newline \n (DEFINE)
macro_id !enddefine
AT_SETUP([DEFINE command - no newline after parentheses])
AT_KEYWORDS([segment])
AT_DATA([input], [dnl
-define !macro1() var1 var2 var3
+define !macro1() var1 var2 var3 /* !enddefine
!enddefine.
])
AT_DATA([expout-base], [dnl
macro_id !macro1
punct (
punct )
-macro_body _var1_var2_var3
+macro_body _var1_var2_var3_/*_!enddefine
newline \n (DEFINE)
macro_id !enddefine