#include "gl/c-ctype.h"
#include "gl/c-strcase.h"
+#include "gl/verify.h"
enum segmenter_state
{
S_TITLE_2
};
+/* S_SHBANG is the start state that SEGMENTER_INIT refers to as just 0. */
+verify (S_SHBANG == 0);
+
#define SS_START_OF_LINE (1u << 0)
#define SS_START_OF_COMMAND (1u << 1)
{
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
void
segmenter_init (struct segmenter *s, enum segmenter_mode mode)
{
- s->state = S_SHBANG;
- s->substate = 0;
- s->mode = mode;
+ *s = (struct segmenter) SEGMENTER_INIT (mode);
}
/* Returns the mode passed to segmenter_init() for S. */