Skip to content

Commit

Permalink
Merge pull request #1203 from czkz/add-escapes
Browse files Browse the repository at this point in the history
Add C escape sequences
  • Loading branch information
bakpakin authored Jun 29, 2023
2 parents 3f7a2c2 + d63379e commit b125cbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ static int checkescape(uint8_t c) {
return '\f';
case 'v':
return '\v';
case 'a':
return '\a';
case 'b':
return '\b';
case '\'':
return '\'';
case '?':
return '?';
case 'e':
return 27;
case '"':
Expand Down
6 changes: 6 additions & 0 deletions src/core/pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ static void janet_escape_string_impl(JanetBuffer *buffer, const uint8_t *str, in
case '\v':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\v", 2);
break;
case '\a':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\a", 2);
break;
case '\b':
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\b", 2);
break;
case 27:
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\e", 2);
break;
Expand Down

0 comments on commit b125cbe

Please sign in to comment.