aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-02-20 06:52:14 +0000
committerKarl Heuer1997-02-20 06:52:14 +0000
commitfe0e03f37052772428635909a4ece3deb0d846f1 (patch)
treea5bc591488b4f9e9fef88494716a99326acf18fb
parent6b768554054e8ab90d359bf6dd167813d3cb7fed (diff)
downloademacs-fe0e03f37052772428635909a4ece3deb0d846f1.tar.gz
emacs-fe0e03f37052772428635909a4ece3deb0d846f1.zip
Include charset.h.
(Vload_source_file_function): New variable. (Fload): Call Vload_source_file_function if defined while loading an Emacs Lisp source file. */ (read_multibyte): New function. (read_escape): Handle multibyte characters. (read1): Correct the value of size_in_chars of a bool vector. Handle the case `?' is followed by a multibyte character. (Vload_source_file_function): New variable.
-rw-r--r--src/lread.c61
1 files changed, 57 insertions, 4 deletions
diff --git a/src/lread.c b/src/lread.c
index 322cb1e1c8d..4e2ed5ccd2a 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -30,6 +30,7 @@ Boston, MA 02111-1307, USA. */
30 30
31#ifndef standalone 31#ifndef standalone
32#include "buffer.h" 32#include "buffer.h"
33#include "charset.h"
33#include <paths.h> 34#include <paths.h>
34#include "commands.h" 35#include "commands.h"
35#include "keyboard.h" 36#include "keyboard.h"
@@ -109,6 +110,10 @@ Lisp_Object read_objects;
109/* Nonzero means load should forcibly load all dynamic doc strings. */ 110/* Nonzero means load should forcibly load all dynamic doc strings. */
110static int load_force_doc_strings; 111static int load_force_doc_strings;
111 112
113/* Function to use for loading an Emacs lisp source file (not
114 compiled) instead of readevalloop. */
115Lisp_Object Vload_source_file_function;
116
112/* List of descriptors now open for Fload. */ 117/* List of descriptors now open for Fload. */
113static Lisp_Object load_descriptor_list; 118static Lisp_Object load_descriptor_list;
114 119
@@ -139,7 +144,11 @@ static int new_backquote_flag;
139 144
140/* Handle unreading and rereading of characters. 145/* Handle unreading and rereading of characters.
141 Write READCHAR to read a character, 146 Write READCHAR to read a character,
142 UNREAD(c) to unread c to be read again. */ 147 UNREAD(c) to unread c to be read again.
148
149 These macros actually read/unread a byte code, multibyte characters
150 are not handled here. The caller should manage them if necessary.
151 */
143 152
144#define READCHAR readchar (readcharfun) 153#define READCHAR readchar (readcharfun)
145#define UNREAD(c) unreadchar (readcharfun, c) 154#define UNREAD(c) unreadchar (readcharfun, c)
@@ -468,6 +477,17 @@ Return t if file exists.")
468 } 477 }
469 XSTRING (found)->data[XSTRING (found)->size - 1] = 'c'; 478 XSTRING (found)->data[XSTRING (found)->size - 1] = 'c';
470 } 479 }
480 else
481 {
482 /* We are loading a source file (*.el). */
483 if (!NILP (Vload_source_file_function))
484 {
485 close (fd);
486 return call3 (Vload_source_file_function, found, file,
487 NILP (noerror) ? Qnil : Qt,
488 NILP (nomessage) ? Qnil : Qt);
489 }
490 }
471 491
472#ifdef DOS_NT 492#ifdef DOS_NT
473 close (fd); 493 close (fd);
@@ -1085,6 +1105,27 @@ read0 (readcharfun)
1085static int read_buffer_size; 1105static int read_buffer_size;
1086static char *read_buffer; 1106static char *read_buffer;
1087 1107
1108/* Read multibyte form and return it as a character. C is a first
1109 byte of multibyte form, and rest of them are read from
1110 READCHARFUN. */
1111static int
1112read_multibyte (c, readcharfun)
1113 register int c;
1114 Lisp_Object readcharfun;
1115{
1116 /* We need the actual character code of this multibyte
1117 characters. */
1118 unsigned char str[MAX_LENGTH_OF_MULTI_BYTE_FORM];
1119 int len = 0;
1120
1121 str[len++] = c;
1122 while ((c = READCHAR) >= 0xA0
1123 && len < MAX_LENGTH_OF_MULTI_BYTE_FORM)
1124 str[len++] = c;
1125 UNREAD (c);
1126 return STRING_CHAR (str, len);
1127}
1128
1088static int 1129static int
1089read_escape (readcharfun) 1130read_escape (readcharfun)
1090 Lisp_Object readcharfun; 1131 Lisp_Object readcharfun;
@@ -1239,6 +1280,8 @@ read_escape (readcharfun)
1239 } 1280 }
1240 1281
1241 default: 1282 default:
1283 if (BASE_LEADING_CODE_P (c))
1284 c = read_multibyte (c, readcharfun);
1242 return c; 1285 return c;
1243 } 1286 }
1244} 1287}
@@ -1523,9 +1566,10 @@ read1 (readcharfun, pch, first_in_list)
1523 if (c < 0) return Fsignal (Qend_of_file, Qnil); 1566 if (c < 0) return Fsignal (Qend_of_file, Qnil);
1524 1567
1525 if (c == '\\') 1568 if (c == '\\')
1526 XSETINT (val, read_escape (readcharfun)); 1569 c = read_escape (readcharfun);
1527 else 1570 else if (BASE_LEADING_CODE_P (c))
1528 XSETINT (val, c); 1571 c = read_multibyte (c, readcharfun);
1572 XSETINT (val, c);
1529 1573
1530 return val; 1574 return val;
1531 } 1575 }
@@ -2596,6 +2640,15 @@ or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
2596The default is nil, which means use the function `read'."); 2640The default is nil, which means use the function `read'.");
2597 Vload_read_function = Qnil; 2641 Vload_read_function = Qnil;
2598 2642
2643 DEFVAR_LISP ("load-source-file-function", &Vload_source_file_function,
2644 "Function called in `load' for loading an Emacs lisp source file.\n\
2645This function is for doing code conversion before reading the source file.\n\
2646If nil, loading is done without any code conversion.\n\
2647Arguments are FULLNAME, FILE, NOERROR, NOMESSAGE, where\n\
2648 FULLNAME is the full name of FILE.\n\
2649See `load' for the meaning of the remaining arguments.");
2650 Vload_source_file_function = Qnil;
2651
2599 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings, 2652 DEFVAR_BOOL ("load-force-doc-strings", &load_force_doc_strings,
2600 "Non-nil means `load' should force-load all dynamic doc strings.\n\ 2653 "Non-nil means `load' should force-load all dynamic doc strings.\n\
2601This is useful when the file being loaded is a temporary copy."); 2654This is useful when the file being loaded is a temporary copy.");