adding support for R6RS-style \<space><newline><space> string escapes

This commit is contained in:
Alex Shinn 2011-08-19 22:51:38 +09:00
parent 32b17bf43e
commit 66482788ec
2 changed files with 24 additions and 3 deletions

View file

@ -249,6 +249,10 @@
#define SEXP_USE_NO_FEATURES 0 #define SEXP_USE_NO_FEATURES 0
#endif #endif
#ifndef SEXP_USE_PEDANTIC
#define SEXP_USE_PEDANTIC 0
#endif
#ifndef SEXP_USE_GREEN_THREADS #ifndef SEXP_USE_GREEN_THREADS
#define SEXP_USE_GREEN_THREADS ! SEXP_USE_NO_FEATURES #define SEXP_USE_GREEN_THREADS ! SEXP_USE_NO_FEATURES
#endif #endif
@ -405,6 +409,14 @@
#define SEXP_USE_MATH SEXP_USE_FLONUMS && ! SEXP_USE_NO_FEATURES #define SEXP_USE_MATH SEXP_USE_FLONUMS && ! SEXP_USE_NO_FEATURES
#endif #endif
#ifndef SEXP_USE_ESCAPE_NEWLINE
#define SEXP_USE_ESCAPE_NEWLINE ! SEXP_USE_NO_FEATURES
#endif
#ifndef SEXP_USE_ESCAPE_REQUIRES_TRAILING_SEMI_COLON
#define SEXP_USE_ESCAPE_REQUIRES_TRAILING_SEMI_COLON SEXP_USE_PEDANTIC
#endif
#ifndef SEXP_USE_SELF_PARAMETER #ifndef SEXP_USE_SELF_PARAMETER
#define SEXP_USE_SELF_PARAMETER 1 #define SEXP_USE_SELF_PARAMETER 1
#endif #endif

15
sexp.c
View file

@ -1542,11 +1542,20 @@ sexp sexp_read_string (sexp ctx, sexp in) {
res = sexp_read_number(ctx, in, 16); res = sexp_read_number(ctx, in, 16);
if (sexp_fixnump(res)) { if (sexp_fixnump(res)) {
c = sexp_read_char(ctx, in); c = sexp_read_char(ctx, in);
if (c == ';') if (c != ';') {
c = sexp_unbox_fixnum(res); #if SEXP_USE_ESCAPE_REQUIRES_TRAILING_SEMI_COLON
else
res = sexp_read_error(ctx, "missing ; in \\x escape", SEXP_NULL, in); res = sexp_read_error(ctx, "missing ; in \\x escape", SEXP_NULL, in);
#else
sexp_push_char(ctx, c, in);
#endif
}
c = sexp_unbox_fixnum(res);
} }
break;
#if SEXP_USE_ESCAPE_NEWLINE
default:
if (isspace(c)) while (isspace(c) && c!=EOF) c=sexp_read_char(ctx, in);
#endif
} }
if (sexp_exceptionp(res)) break; if (sexp_exceptionp(res)) break;
} else if (c == '\n') { } else if (c == '\n') {