@@ -1148,17 +1148,27 @@ sub parse {
11481148
11491149 next PARAGRAPH unless @{ $pxs -> {line } };
11501150
1151- # This will die on something like
1151+ # die if the next line is indented: all file-scoped things (CPP,
1152+ # keywords, XSUB starts) are supposed to start on column 1
1153+ # (although see the comment below about multiple parse_keywords()
1154+ # iterations sneaking in indented keywords).
11521155 #
1156+ # The text of the error message is based around a common reason
1157+ # for an indented line to appear in file scope: this is due to an
1158+ # XSUB being prematurely truncated by fetch_para(). For example in
1159+ # the code below, the coder wants the foo and bar lines to both be
1160+ # part of the same CODE block. But the XS parser sees the blank
1161+ # line followed by the '#ifdef' on column 1 as terminating the
1162+ # current XSUB. So the bar() line is treated as being in file
1163+ # scope and dies because it is indented.
1164+ #
1165+ # |int f()
11531166 # | CODE:
11541167 # | foo();
11551168 # |
1156- # |#define X
1169+ # |#ifdef USE_BAR
11571170 # | bar();
1158- #
1159- # due to the define starting at column 1 and being preceded by a blank
1160- # line: so the define and bar() aren't parsed as part of the CODE
1161- # block.
1171+ # |#endif
11621172
11631173 $pxs -> death(
11641174 " Code is not inside a function"
@@ -1184,12 +1194,15 @@ sub parse {
11841194 # Process file-scoped keywords
11851195 # ----------------------------------------------------------------
11861196
1187- # Note that MODULE and TYPEMAP will already have been processed by
1188- # fetch_para().
11891197 #
11901198 # This loop repeatedly: skips any blank lines and then calls
11911199 # the relevant Node::FOO::parse() method if it finds any of the
11921200 # file-scoped keywords in the passed pattern.
1201+ #
1202+ # Note due to the looping within parse_keywords() rather than
1203+ # looping here, only the first keyword in a contiguous block
1204+ # gets the 'start at column 1' check above enforced. This is
1205+ # a bug, maintained for backwards compatibility.
11931206
11941207 $self -> parse_keywords(
11951208 $pxs ,
0 commit comments