diff options
| author | Karl Heuer | 1994-10-06 21:29:49 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-10-06 21:29:49 +0000 |
| commit | 6428369f3365257dbfa3df1abe290dc0ae4c6666 (patch) | |
| tree | faad09174640ba0ce23a12a9bd447010bd20d8f1 /src | |
| parent | df1955fcf9ec0f223ccca768670da40fedf0b7b2 (diff) | |
| download | emacs-6428369f3365257dbfa3df1abe290dc0ae4c6666.tar.gz emacs-6428369f3365257dbfa3df1abe290dc0ae4c6666.zip | |
(read1): New argument for returning out-of-band data, obviating the need for
Lisp_Internal datatype.
(read0, read1, read_list): Use that new calling sequence.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/src/lread.c b/src/lread.c index dce5912d03d..23885cc8ad3 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -929,8 +929,8 @@ START and END optionally delimit a substring of STRING from which to read;\n\ | |||
| 929 | return Fcons (tem, make_number (read_from_string_index)); | 929 | return Fcons (tem, make_number (read_from_string_index)); |
| 930 | } | 930 | } |
| 931 | 931 | ||
| 932 | /* Use this for recursive reads, in contexts where internal tokens are not allowed. */ | 932 | /* Use this for recursive reads, in contexts where internal tokens |
| 933 | 933 | are not allowed. */ | |
| 934 | static Lisp_Object | 934 | static Lisp_Object |
| 935 | read0 (readcharfun) | 935 | read0 (readcharfun) |
| 936 | Lisp_Object readcharfun; | 936 | Lisp_Object readcharfun; |
| @@ -938,12 +938,9 @@ read0 (readcharfun) | |||
| 938 | register Lisp_Object val; | 938 | register Lisp_Object val; |
| 939 | char c; | 939 | char c; |
| 940 | 940 | ||
| 941 | val = read1 (readcharfun); | 941 | val = read1 (readcharfun, &c); |
| 942 | if (INTERNALP (val)) | 942 | if (c) |
| 943 | { | 943 | Fsignal (Qinvalid_read_syntax, Fcons (make_string (&c, 1), Qnil)); |
| 944 | c = XINT (val); | ||
| 945 | return Fsignal (Qinvalid_read_syntax, Fcons (make_string (&c, 1), Qnil)); | ||
| 946 | } | ||
| 947 | 944 | ||
| 948 | return val; | 945 | return val; |
| 949 | } | 946 | } |
| @@ -1106,11 +1103,16 @@ read_escape (readcharfun) | |||
| 1106 | } | 1103 | } |
| 1107 | } | 1104 | } |
| 1108 | 1105 | ||
| 1106 | /* If the next token is ')' or ']' or '.', we store that character | ||
| 1107 | in *PCH and the return value is not interesting. Else, we store | ||
| 1108 | zero in *PCH and we read and return one lisp object. */ | ||
| 1109 | static Lisp_Object | 1109 | static Lisp_Object |
| 1110 | read1 (readcharfun) | 1110 | read1 (readcharfun, pch) |
| 1111 | register Lisp_Object readcharfun; | 1111 | register Lisp_Object readcharfun; |
| 1112 | char *pch; | ||
| 1112 | { | 1113 | { |
| 1113 | register int c; | 1114 | register int c; |
| 1115 | *pch = 0; | ||
| 1114 | 1116 | ||
| 1115 | retry: | 1117 | retry: |
| 1116 | 1118 | ||
| @@ -1128,9 +1130,8 @@ read1 (readcharfun) | |||
| 1128 | case ')': | 1130 | case ')': |
| 1129 | case ']': | 1131 | case ']': |
| 1130 | { | 1132 | { |
| 1131 | register Lisp_Object val; | 1133 | *pch = c; |
| 1132 | XSETINTERNAL (val, c); | 1134 | return Qnil; |
| 1133 | return val; | ||
| 1134 | } | 1135 | } |
| 1135 | 1136 | ||
| 1136 | case '#': | 1137 | case '#': |
| @@ -1149,10 +1150,11 @@ read1 (readcharfun) | |||
| 1149 | { | 1150 | { |
| 1150 | Lisp_Object tmp; | 1151 | Lisp_Object tmp; |
| 1151 | struct gcpro gcpro1; | 1152 | struct gcpro gcpro1; |
| 1153 | char ch; | ||
| 1152 | 1154 | ||
| 1153 | /* Read the string itself. */ | 1155 | /* Read the string itself. */ |
| 1154 | tmp = read1 (readcharfun); | 1156 | tmp = read1 (readcharfun, &ch); |
| 1155 | if (!STRINGP (tmp)) | 1157 | if (ch != 0 || !STRINGP (tmp)) |
| 1156 | Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); | 1158 | Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); |
| 1157 | GCPRO1 (tmp); | 1159 | GCPRO1 (tmp); |
| 1158 | /* Read the intervals and their properties. */ | 1160 | /* Read the intervals and their properties. */ |
| @@ -1160,22 +1162,17 @@ read1 (readcharfun) | |||
| 1160 | { | 1162 | { |
| 1161 | Lisp_Object beg, end, plist; | 1163 | Lisp_Object beg, end, plist; |
| 1162 | 1164 | ||
| 1163 | beg = read1 (readcharfun); | 1165 | beg = read1 (readcharfun, &ch); |
| 1164 | if (INTERNALP (beg)) | 1166 | if (ch == ')') |
| 1165 | { | 1167 | break; |
| 1166 | if (XINT (beg) == ')') | 1168 | if (ch == 0) |
| 1167 | break; | 1169 | end = read1 (readcharfun, &ch); |
| 1168 | Fsignal (Qinvalid_read_syntax, Fcons (make_string ("invalid string property list", 28), Qnil)); | 1170 | if (ch == 0) |
| 1169 | } | 1171 | plist = read1 (readcharfun, &ch); |
| 1170 | end = read1 (readcharfun); | 1172 | if (ch) |
| 1171 | if (INTERNALP (end)) | ||
| 1172 | Fsignal (Qinvalid_read_syntax, | ||
| 1173 | Fcons (make_string ("invalid string property list", 28), Qnil)); | ||
| 1174 | |||
| 1175 | plist = read1 (readcharfun); | ||
| 1176 | if (INTERNALP (plist)) | ||
| 1177 | Fsignal (Qinvalid_read_syntax, | 1173 | Fsignal (Qinvalid_read_syntax, |
| 1178 | Fcons (make_string ("invalid string property list", 28), Qnil)); | 1174 | Fcons (build_string ("invalid string property list"), |
| 1175 | Qnil)); | ||
| 1179 | Fset_text_properties (beg, end, plist, tmp); | 1176 | Fset_text_properties (beg, end, plist, tmp); |
| 1180 | } | 1177 | } |
| 1181 | UNGCPRO; | 1178 | UNGCPRO; |
| @@ -1276,9 +1273,8 @@ read1 (readcharfun) | |||
| 1276 | if (! isdigit (next_char)) | 1273 | if (! isdigit (next_char)) |
| 1277 | #endif | 1274 | #endif |
| 1278 | { | 1275 | { |
| 1279 | register Lisp_Object val; | 1276 | *pch = c; |
| 1280 | XSETINTERNAL (val, c); | 1277 | return Qnil; |
| 1281 | return val; | ||
| 1282 | } | 1278 | } |
| 1283 | 1279 | ||
| 1284 | /* Otherwise, we fall through! Note that the atom-reading loop | 1280 | /* Otherwise, we fall through! Note that the atom-reading loop |
| @@ -1477,29 +1473,30 @@ read_list (flag, readcharfun) | |||
| 1477 | 1473 | ||
| 1478 | while (1) | 1474 | while (1) |
| 1479 | { | 1475 | { |
| 1476 | char ch; | ||
| 1480 | GCPRO2 (val, tail); | 1477 | GCPRO2 (val, tail); |
| 1481 | elt = read1 (readcharfun); | 1478 | elt = read1 (readcharfun, &ch); |
| 1482 | UNGCPRO; | 1479 | UNGCPRO; |
| 1483 | if (INTERNALP (elt)) | 1480 | if (ch) |
| 1484 | { | 1481 | { |
| 1485 | if (flag > 0) | 1482 | if (flag > 0) |
| 1486 | { | 1483 | { |
| 1487 | if (XINT (elt) == ']') | 1484 | if (ch == ']') |
| 1488 | return val; | 1485 | return val; |
| 1489 | return Fsignal (Qinvalid_read_syntax, Fcons (make_string (") or . in a vector", 18), Qnil)); | 1486 | Fsignal (Qinvalid_read_syntax, Fcons (make_string (") or . in a vector", 18), Qnil)); |
| 1490 | } | 1487 | } |
| 1491 | if (XINT (elt) == ')') | 1488 | if (ch == ')') |
| 1492 | return val; | 1489 | return val; |
| 1493 | if (XINT (elt) == '.') | 1490 | if (ch == '.') |
| 1494 | { | 1491 | { |
| 1495 | GCPRO2 (val, tail); | 1492 | GCPRO2 (val, tail); |
| 1496 | if (!NILP (tail)) | 1493 | if (!NILP (tail)) |
| 1497 | XCONS (tail)->cdr = read0 (readcharfun); | 1494 | XCONS (tail)->cdr = read0 (readcharfun); |
| 1498 | else | 1495 | else |
| 1499 | val = read0 (readcharfun); | 1496 | val = read0 (readcharfun); |
| 1500 | elt = read1 (readcharfun); | 1497 | read1 (readcharfun, &ch); |
| 1501 | UNGCPRO; | 1498 | UNGCPRO; |
| 1502 | if (INTERNALP (elt) && XINT (elt) == ')') | 1499 | if (ch == ')') |
| 1503 | return val; | 1500 | return val; |
| 1504 | return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil)); | 1501 | return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil)); |
| 1505 | } | 1502 | } |