changed the tre parser to treat a backslash as an escaper inside []

This commit is contained in:
hyung-hwan 2020-03-09 15:29:31 +00:00
parent fd56a19a79
commit 75ef3a949a
3 changed files with 12 additions and 4 deletions

View File

@ -8821,5 +8821,5 @@ hawk_oow_t hawk_rtx_fmttobcstr_ (hawk_rtx_t* rtx, hawk_bch_t* buf, hawk_oow_t bu
int hawk_rtx_buildrex (hawk_rtx_t* rtx, const hawk_ooch_t* ptn, hawk_oow_t len, hawk_tre_t** code, hawk_tre_t** icode) int hawk_rtx_buildrex (hawk_rtx_t* rtx, const hawk_ooch_t* ptn, hawk_oow_t len, hawk_tre_t** code, hawk_tre_t** icode)
{ {
return hawk_gem_buildrex(hawk_rtx_getgem(rtx), ptn, len, !(hawk_rtx_gethawk(rtx)->opt.trait & HAWK_REXBOUND), code, icode); return hawk_gem_buildrex(hawk_rtx_getgem(rtx), ptn, len, !(rtx->hawk->opt.trait & HAWK_REXBOUND), code, icode);
} }

View File

@ -277,6 +277,14 @@ tre_parse_bracket_items(tre_parse_ctx_t *ctx, int negate,
if (min > max) if (min > max)
status = REG_ERANGE; status = REG_ERANGE;
} }
/* BACON */
else if (re + 1 < ctx->re_end && *re == CHAR_BACKSLASH)
{
/* escaped character inside [] */
min = max = *(re + 1);
re += 2;
}
/* END BACON */
else if (re + 1 < ctx->re_end else if (re + 1 < ctx->re_end
&& *re == CHAR_LBRACKET && *(re + 1) == CHAR_PERIOD) && *re == CHAR_LBRACKET && *(re + 1) == CHAR_PERIOD)
status = REG_ECOLLATE; status = REG_ECOLLATE;