Added line-reader example. Changed behaviour of eof on regex to parse either eof or a newline followed be eof (better matchers other regex engines).

This commit is contained in:
Daniel Holden
2018-10-13 18:27:42 -04:00
parent 65060137b1
commit fbc5d8f9ae
4 changed files with 112 additions and 3 deletions

7
mpc.c
View File

@@ -2200,7 +2200,12 @@ static mpc_val_t *mpcf_re_escape(mpc_val_t *x) {
/* Regex Special Characters */
if (s[0] == '.') { free(s); return mpc_any(); }
if (s[0] == '^') { free(s); return mpc_and(2, mpcf_snd, mpc_soi(), mpc_lift(mpcf_ctor_str), free); }
if (s[0] == '$') { free(s); return mpc_and(2, mpcf_snd, mpc_eoi(), mpc_lift(mpcf_ctor_str), free); }
if (s[0] == '$') {
free(s);
return mpc_or(2,
mpc_and(2, mpcf_fst, mpc_newline(), mpc_eoi(), free),
mpc_and(2, mpcf_snd, mpc_eoi(), mpc_lift(mpcf_ctor_str), free));
}
/* Regex Escape */
if (s[0] == '\\') {