Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/packcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,6 @@ static bool_t unescape_string(char *str, size_t *len, bool_t cls) { /* cls: TRUE
switch (str[i]) {
case '\'': str[j++] = '\''; break;
case '\"': str[j++] = '\"'; break;
case '0': str[j++] = '\x00'; break;
case 'a': str[j++] = '\x07'; break;
case 'b': str[j++] = '\x08'; break;
case 'f': str[j++] = '\x0c'; break;
Expand Down Expand Up @@ -917,6 +916,29 @@ static bool_t unescape_string(char *str, size_t *len, bool_t cls) { /* cls: TRUE
i += t ? 10 : 4;
}
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
{
char s = 0;
size_t k;
for (k = 0; k < 3; k++) {
char c;
c = str[i + k];
if (c < '0' || c > '7') break;
c -= '0';
s = s * 8 + c;
}
// k can never be less than 1
i += k - 1;
str[j++] = s;
}
break;
case '\n': break;
case '\r': if (str[i + 1] == '\n') i++; break;
case '\\':
Expand Down
5 changes: 2 additions & 3 deletions tests/character_classes_1.d/input.peg
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ FILE <- (LOWER_LETTER / UPPER_LETTER / DIGIT / UNICODE / ESCAPED / CARET / SPACE

# simple character class
LOWER_LETTER <- [a-z] { print_esc("LOWER", $0); }
# octal escapes (FIXME: octals do not work)
# UPPER_LETTER <- [\101-\132] { print_esc("UPPER", $0); }
UPPER_LETTER <- [A-Z] { print_esc("UPPER", $0); }
UPPER_LETTER <- [\101-\132] { print_esc("UPPER", $0); }
# UPPER_LETTER <- [A-Z] { print_esc("UPPER", $0); }
# hexadecimal escapes
DIGIT <- [\x30-\x39] { print_esc("DIGIT", $0); }
# some unicode chars
Expand Down
Loading