Mercurial > hg > xemacs-beta
comparison src/lread.c @ 444:576fb035e263 r21-2-37
Import from CVS: tag r21-2-37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:36:19 +0200 |
parents | abe6d1db359e |
children | e7ef97881643 |
comparison
equal
deleted
inserted
replaced
443:a8296e22da4e | 444:576fb035e263 |
---|---|
256 else if (LSTREAMP (readcharfun)) | 256 else if (LSTREAMP (readcharfun)) |
257 { | 257 { |
258 Emchar c = Lstream_get_emchar (XLSTREAM (readcharfun)); | 258 Emchar c = Lstream_get_emchar (XLSTREAM (readcharfun)); |
259 #ifdef DEBUG_XEMACS /* testing Mule */ | 259 #ifdef DEBUG_XEMACS /* testing Mule */ |
260 static int testing_mule = 0; /* Change via debugger */ | 260 static int testing_mule = 0; /* Change via debugger */ |
261 if (testing_mule) { | 261 if (testing_mule) |
262 if (c >= 0x20 && c <= 0x7E) stderr_out ("%c", c); | 262 { |
263 else if (c == '\n') stderr_out ("\\n\n"); | 263 if (c >= 0x20 && c <= 0x7E) stderr_out ("%c", c); |
264 else stderr_out ("\\%o ", c); | 264 else if (c == '\n') stderr_out ("\\n\n"); |
265 } | 265 else stderr_out ("\\%o ", c); |
266 #endif | 266 } |
267 #endif /* testing Mule */ | |
267 return c; | 268 return c; |
268 } | 269 } |
269 else if (MARKERP (readcharfun)) | 270 else if (MARKERP (readcharfun)) |
270 { | 271 { |
271 Emchar c; | 272 Emchar c; |
534 USED-CODESYS is non-nil, it should be a symbol, and the actual coding | 535 USED-CODESYS is non-nil, it should be a symbol, and the actual coding |
535 system that was used for the decoding is stored into it. It will in | 536 system that was used for the decoding is stored into it. It will in |
536 general be different from CODESYS if CODESYS specifies automatic | 537 general be different from CODESYS if CODESYS specifies automatic |
537 encoding detection or end-of-line detection. | 538 encoding detection or end-of-line detection. |
538 */ | 539 */ |
539 (file, no_error, nomessage, nosuffix, codesys, used_codesys)) | 540 (file, noerror, nomessage, nosuffix, codesys, used_codesys)) |
540 { | 541 { |
541 /* This function can GC */ | 542 /* This function can GC */ |
542 int fd = -1; | 543 int fd = -1; |
543 int speccount = specpdl_depth (); | 544 int speccount = specpdl_depth (); |
544 int source_only = 0; | 545 int source_only = 0; |
565 /*#endif / * DEBUG_XEMACS */ | 566 /*#endif / * DEBUG_XEMACS */ |
566 | 567 |
567 /* If file name is magic, call the handler. */ | 568 /* If file name is magic, call the handler. */ |
568 handler = Ffind_file_name_handler (file, Qload); | 569 handler = Ffind_file_name_handler (file, Qload); |
569 if (!NILP (handler)) | 570 if (!NILP (handler)) |
570 RETURN_UNGCPRO (call5 (handler, Qload, file, no_error, | 571 RETURN_UNGCPRO (call5 (handler, Qload, file, noerror, |
571 nomessage, nosuffix)); | 572 nomessage, nosuffix)); |
572 | 573 |
573 /* Do this after the handler to avoid | 574 /* Do this after the handler to avoid |
574 the need to gcpro noerror, nomessage and nosuffix. | 575 the need to gcpro noerror, nomessage and nosuffix. |
575 (Below here, we care only whether they are nil or not.) */ | 576 (Below here, we care only whether they are nil or not.) */ |
594 &found, | 595 &found, |
595 -1); | 596 -1); |
596 | 597 |
597 if (fd < 0) | 598 if (fd < 0) |
598 { | 599 { |
599 if (NILP (no_error)) | 600 if (NILP (noerror)) |
600 signal_file_error ("Cannot open load file", file); | 601 signal_file_error ("Cannot open load file", file); |
601 else | 602 else |
602 { | 603 { |
603 UNGCPRO; | 604 UNGCPRO; |
604 return Qnil; | 605 return Qnil; |
1468 DEFUN ("eval-buffer", Feval_buffer, 0, 2, "bBuffer: ", /* | 1469 DEFUN ("eval-buffer", Feval_buffer, 0, 2, "bBuffer: ", /* |
1469 Execute BUFFER as Lisp code. | 1470 Execute BUFFER as Lisp code. |
1470 Programs can pass two arguments, BUFFER and PRINTFLAG. | 1471 Programs can pass two arguments, BUFFER and PRINTFLAG. |
1471 BUFFER is the buffer to evaluate (nil means use current buffer). | 1472 BUFFER is the buffer to evaluate (nil means use current buffer). |
1472 PRINTFLAG controls printing of output: | 1473 PRINTFLAG controls printing of output: |
1473 nil means discard it; anything else is stream for print. | 1474 nil means discard it; anything else is a stream for printing. |
1474 | 1475 |
1475 If there is no error, point does not move. If there is an error, | 1476 If there is no error, point does not move. If there is an error, |
1476 point remains at the end of the last character read from the buffer. | 1477 point remains at the end of the last character read from the buffer. |
1477 Execute BUFFER as Lisp code. | |
1478 */ | 1478 */ |
1479 (bufname, printflag)) | 1479 (buffer, printflag)) |
1480 { | 1480 { |
1481 /* This function can GC */ | 1481 /* This function can GC */ |
1482 int speccount = specpdl_depth (); | 1482 int speccount = specpdl_depth (); |
1483 Lisp_Object tem, buf; | 1483 Lisp_Object tem, buf; |
1484 | 1484 |
1485 if (NILP (bufname)) | 1485 if (NILP (buffer)) |
1486 buf = Fcurrent_buffer (); | 1486 buf = Fcurrent_buffer (); |
1487 else | 1487 else |
1488 buf = Fget_buffer (bufname); | 1488 buf = Fget_buffer (buffer); |
1489 if (NILP (buf)) | 1489 if (NILP (buf)) |
1490 error ("No such buffer."); | 1490 error ("No such buffer."); |
1491 | 1491 |
1492 if (NILP (printflag)) | 1492 if (NILP (printflag)) |
1493 tem = Qsymbolp; /* #### #@[]*&$#*[& SI:NULL-STREAM */ | 1493 tem = Qsymbolp; /* #### #@[]*&$#*[& SI:NULL-STREAM */ |
1517 } | 1517 } |
1518 #endif /* 0 */ | 1518 #endif /* 0 */ |
1519 | 1519 |
1520 DEFUN ("eval-region", Feval_region, 2, 3, "r", /* | 1520 DEFUN ("eval-region", Feval_region, 2, 3, "r", /* |
1521 Execute the region as Lisp code. | 1521 Execute the region as Lisp code. |
1522 When called from programs, expects two arguments, | 1522 When called from programs, expects two arguments START and END |
1523 giving starting and ending indices in the current buffer | 1523 giving starting and ending indices in the current buffer |
1524 of the text to be executed. | 1524 of the text to be executed. |
1525 Programs can pass third argument PRINTFLAG which controls output: | 1525 Programs can pass third optional argument STREAM which controls output: |
1526 nil means discard it; anything else is stream for printing it. | 1526 nil means discard it; anything else is stream for printing it. |
1527 | 1527 |
1528 If there is no error, point does not move. If there is an error, | 1528 If there is no error, point does not move. If there is an error, |
1529 point remains at the end of the last character read from the buffer. | 1529 point remains at the end of the last character read from the buffer. |
1530 | 1530 |
1531 Note: Before evaling the region, this function narrows the buffer to it. | 1531 Note: Before evaling the region, this function narrows the buffer to it. |
1532 If the code being eval'd should happen to trigger a redisplay you may | 1532 If the code being eval'd should happen to trigger a redisplay you may |
1533 see some text temporarily disappear because of this. | 1533 see some text temporarily disappear because of this. |
1534 */ | 1534 */ |
1535 (b, e, printflag)) | 1535 (start, end, stream)) |
1536 { | 1536 { |
1537 /* This function can GC */ | 1537 /* This function can GC */ |
1538 int speccount = specpdl_depth (); | 1538 int speccount = specpdl_depth (); |
1539 Lisp_Object tem; | 1539 Lisp_Object tem; |
1540 Lisp_Object cbuf = Fcurrent_buffer (); | 1540 Lisp_Object cbuf = Fcurrent_buffer (); |
1541 | 1541 |
1542 if (NILP (printflag)) | 1542 if (NILP (stream)) |
1543 tem = Qsymbolp; /* #### #@[]*&$#*[& SI:NULL-STREAM */ | 1543 tem = Qsymbolp; /* #### #@[]*&$#*[& SI:NULL-STREAM */ |
1544 else | 1544 else |
1545 tem = printflag; | 1545 tem = stream; |
1546 specbind (Qstandard_output, tem); | 1546 specbind (Qstandard_output, tem); |
1547 | 1547 |
1548 if (NILP (printflag)) | 1548 if (NILP (stream)) |
1549 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 1549 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
1550 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | 1550 record_unwind_protect (save_restriction_restore, save_restriction_save ()); |
1551 | 1551 |
1552 /* This both uses b and checks its type. */ | 1552 /* This both uses start and checks its type. */ |
1553 Fgoto_char (b, cbuf); | 1553 Fgoto_char (start, cbuf); |
1554 Fnarrow_to_region (make_int (BUF_BEGV (current_buffer)), e, cbuf); | 1554 Fnarrow_to_region (make_int (BUF_BEGV (current_buffer)), end, cbuf); |
1555 readevalloop (cbuf, XBUFFER (cbuf)->filename, Feval, | 1555 readevalloop (cbuf, XBUFFER (cbuf)->filename, Feval, |
1556 !NILP (printflag)); | 1556 !NILP (stream)); |
1557 | 1557 |
1558 return unbind_to (speccount, Qnil); | 1558 return unbind_to (speccount, Qnil); |
1559 } | 1559 } |
1560 | 1560 |
1561 DEFUN ("read", Fread, 0, 1, 0, /* | 1561 DEFUN ("read", Fread, 0, 1, 0, /* |
2033 | 2033 |
2034 static Lisp_Object | 2034 static Lisp_Object |
2035 read_bit_vector (Lisp_Object readcharfun) | 2035 read_bit_vector (Lisp_Object readcharfun) |
2036 { | 2036 { |
2037 unsigned_char_dynarr *dyn = Dynarr_new (unsigned_char); | 2037 unsigned_char_dynarr *dyn = Dynarr_new (unsigned_char); |
2038 Emchar c; | |
2039 Lisp_Object val; | 2038 Lisp_Object val; |
2040 | 2039 |
2041 while (1) | 2040 while (1) |
2042 { | 2041 { |
2043 c = readchar (readcharfun); | 2042 unsigned char bit; |
2044 if (c != '0' && c != '1') | 2043 Emchar c = readchar (readcharfun); |
2045 break; | 2044 if (c == '0') |
2046 Dynarr_add (dyn, (unsigned char) (c - '0')); | 2045 bit = 0; |
2047 } | 2046 else if (c == '1') |
2048 | 2047 bit = 1; |
2049 if (c >= 0) | 2048 else |
2050 unreadchar (readcharfun, c); | 2049 { |
2050 if (c >= 0) | |
2051 unreadchar (readcharfun, c); | |
2052 break; | |
2053 } | |
2054 Dynarr_add (dyn, bit); | |
2055 } | |
2051 | 2056 |
2052 val = make_bit_vector_from_byte_vector (Dynarr_atp (dyn, 0), | 2057 val = make_bit_vector_from_byte_vector (Dynarr_atp (dyn, 0), |
2053 Dynarr_length (dyn)); | 2058 Dynarr_length (dyn)); |
2054 | |
2055 Dynarr_free (dyn); | 2059 Dynarr_free (dyn); |
2056 | 2060 |
2057 return val; | 2061 return val; |
2058 } | 2062 } |
2059 | 2063 |