fix regex breakage in last commit (failure to handle empty regex, etc.)
authorRich Felker <dalias@aerifal.cx>
Mon, 7 May 2012 21:43:38 +0000 (17:43 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 7 May 2012 21:43:38 +0000 (17:43 -0400)
src/regex/regcomp.c

index fa79e2e5f47491dc39066a75364e159d68dbd7f6..5f119d172e535a5ca8d6b0289ac1391e9913d045 100644 (file)
@@ -1149,10 +1149,6 @@ tre_parse(tre_parse_ctx_t *ctx)
             an empty set of `()', a bracket expression, `.', `^', `$',
             a `\' followed by a character, or a single character. */
 
-         /* End of regexp? (empty string). */
-         if (!*ctx->re)
-           goto parse_literal;
-
          switch (*ctx->re)
            {
            case CHAR_LPAREN:  /* parenthesized subexpression */
@@ -1394,6 +1390,7 @@ tre_parse(tre_parse_ctx_t *ctx)
              if (!(ctx->cflags & REG_EXTENDED))
                goto parse_literal;
 
+           case 0:
            empty_atom:
              result = tre_ast_new_literal(ctx->mem, EMPTY, -1, -1);
              if (!result)