mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
pattern: fix newline, tab, and carriage return treatment
This commit is contained in:
parent
f1cff0b889
commit
d7cf3982f8
@ -304,20 +304,16 @@ init: /* using goto's to optimize tail recursion */
|
||||
s = NULL; /* match failed */
|
||||
break;
|
||||
}
|
||||
case 'n': { /* newline? */
|
||||
if (*s == '\r') {
|
||||
if (*(++s) == '\n') s++;
|
||||
} else if (*s == '\n')
|
||||
s++;
|
||||
else
|
||||
s = NULL;
|
||||
break;
|
||||
}
|
||||
case 'r': /* carriage return? */
|
||||
case 'n': /* newline? */
|
||||
case 't': { /* tab? */
|
||||
if (*s == '\t')
|
||||
s++;
|
||||
else
|
||||
s = NULL;
|
||||
char h = *(p + 1);
|
||||
p += 2;
|
||||
if ( (*s == '\r' && h == 'r')
|
||||
|| (*s == '\n' && h == 'n')
|
||||
|| (*s == '\t' && h == 't')
|
||||
) { s++; goto init; }
|
||||
else s = NULL;
|
||||
break;
|
||||
}
|
||||
case '0':
|
||||
|
@ -110,8 +110,8 @@ parseInternalPattern = do maybeAnchor <- Parsec.optionMaybe (Parsec.char '^')
|
||||
_ <- Parsec.char '\\'
|
||||
c <- Parsec.oneOf ['1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'a', 'c', 'd', 'g', 'l', 'p', 's', 'u', 'w',
|
||||
'x', 'n', 't', 'b', 'f', '[', ']', '\\', '$',
|
||||
'(', ')', '^', '"', '*', '.', '-']
|
||||
'x', 'n', 'r', 't', 'b', 'f', '[', ']', '\\',
|
||||
'$', '(', ')', '^', '"', '*', '.', '-']
|
||||
case c of
|
||||
'b' -> do c1 <- Parsec.noneOf ['"']
|
||||
c2 <- Parsec.noneOf ['"']
|
||||
|
Loading…
Reference in New Issue
Block a user