Previously, if the first line of the macro body (the same line as the
closing parenthesis in the DEFINE) was blank, we reported it as a blank
line to the lexer. The parser for DEFINE could check for that (by seeing
whether the first line of macro body was empty or all-spaces) but it seems
more elegant to do it in the segmenter. This implements that.
{
s->nest--;
if (!s->nest)
- s->state = S_DEFINE_3;
+ {
+ s->state = S_DEFINE_3;
+ s->substate = 0;
+ }
return ofs;
}
The line might be blank, whether completely empty or just spaces and
comments. That's OK: we need to report blank lines because they can
- have significance. */
- *type = SEG_MACRO_BODY;
+ have significance.
+
+ However, if the first line of the macro body (the same line as the
+ closing parenthesis in the argument definition) is blank, we just
+ report it as spaces because it's not significant. */
+ *type = (s->substate == 0 && is_all_spaces (input, ofs)
+ ? SEG_SPACES : SEG_MACRO_BODY);
s->state = S_DEFINE_4;
+ s->substate = 1;
return ofs;
}
else
MACRO_ID "!macro1"
LPAREN
RPAREN
-STRING ""
+SKIP
SKIP
STRING "var1 var2 var3"
SKIP
MACRO_ID "!macro1"
LPAREN
RPAREN
-STRING ""
+SKIP
SKIP
STRING "var1 var2 var3"
MACRO_ID "!enddefine"
MACRO_ID "!macro1"
LPAREN
RPAREN
+SKIP
+SKIP
+MACRO_ID "!enddefine"
+ENDCMD
+-SKIP
+STOP
+])
+PSPP_CHECK_SCAN([-i])
+AT_CLEANUP
+\f
+AT_SETUP([DEFINE command - blank lines])
+AT_KEYWORDS([scan])
+AT_DATA([input], [dnl
+define !macro1()
+
+
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+ID "define"
+SKIP
+MACRO_ID "!macro1"
+LPAREN
+RPAREN
+SKIP
+SKIP
+STRING ""
+SKIP
STRING ""
SKIP
MACRO_ID "!enddefine"
LPAREN
RPAREN
RPAREN
-STRING ""
+SKIP
SKIP
MACRO_ID "!enddefine"
ENDCMD
RPAREN
SKIP
RPAREN
-STRING ""
+SKIP
SKIP
MACRO_ID "!enddefine"
ENDCMD
ID "z"
SKIP
RPAREN
-STRING ""
+SKIP
SKIP
STRING "content 1"
SKIP
MACRO_ID "!macro1"
LPAREN
RPAREN
-STRING ""
+SKIP
SKIP
STRING "content line 1"
SKIP
macro_id !macro1
punct (
punct )
-macro_body
+spaces
newline \n (DEFINE)
macro_body var1_var2_var3
macro_id !macro1
punct (
punct )
-macro_body
+spaces
newline \n (DEFINE)
macro_body var1_var2_var3
macro_id !macro1
punct (
punct )
-macro_body
+spaces
newline \n (DEFINE)
macro_id !enddefine
macro_id !macro1
punct (
punct )
-macro_body
+spaces
newline \n (DEFINE)
macro_body
punct (
punct )
punct )
-macro_body
+spaces
newline \n (DEFINE)
macro_id !enddefine
newline \n (later)
punct )
-macro_body
+spaces
newline \n (DEFINE)
macro_id !enddefine
newline \n (later)
punct )
-macro_body
+spaces
newline \n (DEFINE)
macro_body content_1
macro_id !macro1
punct (
punct )
-macro_body
+spaces
newline \n (DEFINE)
macro_body content_line_1