aboutsummaryrefslogtreecommitdiff
path: root/jimregexp.c
diff options
context:
space:
mode:
Diffstat (limited to 'jimregexp.c')
-rw-r--r--jimregexp.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/jimregexp.c b/jimregexp.c
index 136b0c0..38db210 100644
--- a/jimregexp.c
+++ b/jimregexp.c
@@ -948,6 +948,27 @@ cc_switch:
ret = regnode(preg, EXACTLY);
+ if (preg->cflags & REG_EXPANDED) {
+ /* Skip leading white space */
+ while ((ch = *preg->regparse) != 0) {
+ if (strchr(" \t\r\n\f\v", ch)) {
+ preg->regparse++;
+ continue;
+ }
+ break;
+ }
+ if (ch == '#') {
+ /* And skip comments to end of line */
+ preg->regparse++;
+ while ((ch = *preg->regparse) != 0) {
+ preg->regparse++;
+ if (ch == '\n') {
+ break;
+ }
+ }
+ }
+ }
+
/* Note that a META operator such as ? or * consumes the
* preceding char.
* Thus we must be careful to look ahead by 2 and add the
@@ -993,6 +1014,12 @@ cc_switch:
break;
}
+ /* For REG_EXPANDED, if we hit white space, stop */
+ if ((preg->cflags & REG_EXPANDED) && n == 1 && strchr(" \t\r\n\f\v", ch)) {
+ preg->regparse += n;
+ break;
+ }
+
/* No, so just add this char normally */
regc(preg, ch);
added++;