X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Flread.c;h=03a4f546a43cb4e9336e03aeb6bd7135c653e6a3;hb=557a8105b1bfe98e9a52f16fc2d4b10107f66b19;hp=481f6647c6cbb6b0b51939ea0df9477f61aafe19;hpb=976b002b16336930724ae22476014583ad022e7d;p=chise%2Fxemacs-chise.git diff --git a/src/lread.c b/src/lread.c index 481f664..03a4f54 100644 --- a/src/lread.c +++ b/src/lread.c @@ -218,14 +218,14 @@ EXFUN (Fread_from_string, 3); static DOESNT_RETURN -syntax_error (CONST char *string) +read_syntax_error (const char *string) { signal_error (Qinvalid_read_syntax, list1 (build_translated_string (string))); } static Lisp_Object -continuable_syntax_error (CONST char *string) +continuable_read_syntax_error (const char *string) { return Fsignal (Qinvalid_read_syntax, list1 (build_translated_string (string))); @@ -259,9 +259,9 @@ readchar (Lisp_Object readcharfun) #ifdef DEBUG_XEMACS /* testing Mule */ static int testing_mule = 0; /* Change via debugger */ if (testing_mule) { - if (c >= 0x20 && c <= 0x7E) fprintf (stderr, "%c", c); - else if (c == '\n') fprintf (stderr, "\\n\n"); - else fprintf (stderr, "\\%o ", c); + if (c >= 0x20 && c <= 0x7E) stderr_out ("%c", c); + else if (c == '\n') stderr_out ("\\n\n"); + else stderr_out ("\\%o ", c); } #endif return c; @@ -443,12 +443,6 @@ load_force_doc_string_unwind (Lisp_Object oldlist) Lisp_Object list = Vload_force_doc_string_list; Lisp_Object tail; int fd = XINT (XCAR (Vload_descriptor_list)); - /* NOTE: If purify_flag is true, we're in-place modifying objects that - may be in purespace (and if not, they will be). Therefore, we have - to be VERY careful to make sure that all objects that we create - are purecopied -- objects in purespace are not marked for GC, and - if we leave any impure objects inside of pure ones, we're really - screwed. */ GCPRO1 (list); /* restore the old value first just in case an error occurs. */ @@ -479,13 +473,12 @@ load_force_doc_string_unwind (Lisp_Object oldlist) ivan = Fread (juan); if (!CONSP (ivan)) signal_simple_error ("invalid lazy-loaded byte code", ivan); - /* Remember to purecopy; see above. */ - XCOMPILED_FUNCTION (john)->instructions = Fpurecopy (XCAR (ivan)); + XCOMPILED_FUNCTION (john)->instructions = XCAR (ivan); /* v18 or v19 bytecode file. Need to Ebolify. */ if (XCOMPILED_FUNCTION (john)->flags.ebolified && VECTORP (XCDR (ivan))) ebolify_bytecode_constants (XCDR (ivan)); - XCOMPILED_FUNCTION (john)->constants = Fpurecopy (XCDR (ivan)); + XCOMPILED_FUNCTION (john)->constants = XCDR (ivan); NUNGCPRO; } doc = compiled_function_documentation (XCOMPILED_FUNCTION (john)); @@ -630,7 +623,7 @@ encoding detection or end-of-line detection. int result; /* temporarily hack the 'c' off the end of the filename */ foundstr[foundlen - 1] = '\0'; - result = stat (foundstr, &s2); + result = xemacs_stat (foundstr, &s2); if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) { @@ -683,7 +676,7 @@ encoding detection or end-of-line detection. { /* Lisp_Object's must be malloc'ed, not stack-allocated */ Lisp_Object lispstream = Qnil; - CONST int block_size = 8192; + const int block_size = 8192; struct gcpro ngcpro1; NGCPRO1 (lispstream); @@ -910,22 +903,23 @@ locate_file_find_directory_hash_table (Lisp_Object directory) nil, a list, or a string (for backward compatibility), with the following semantics: - a) nil - no suffix, just search for file name intact (semantically - different from "empty suffix list") + a) nil - no suffix, just search for file name intact + (semantically different from "empty suffix list", which + would be meaningless.) b) list - list of suffixes to append to file name. Each of these must be a string. c) string - colon-separated suffixes to append to file name (backward compatibility). - All of this got hairy, so I decided to use write a mapper. Calling - a function for each suffix shouldn't slow things down, since - locate_file is rarely call with enough suffixes for it to make a - difference. */ + All of this got hairy, so I decided to use a mapper. Calling a + function for each suffix shouldn't slow things down, since + locate_file is rarely called with enough suffixes for funcalls to + make any difference. */ /* Map FUN over SUFFIXES, as described above. FUN will be called with a char * containing the current file name, and ARG. Mapping stops when FUN returns non-zero. */ -void +static void locate_file_map_suffixes (Lisp_Object filename, Lisp_Object suffixes, int (*fun) (char *, void *), void *arg) @@ -984,12 +978,12 @@ locate_file_map_suffixes (Lisp_Object filename, Lisp_Object suffixes, else { /* Case c) */ - CONST char *nsuffix = XSTRING_DATA (suffixes); + const char *nsuffix = (const char *) XSTRING_DATA (suffixes); while (1) { char *esuffix = (char *) strchr (nsuffix, ':'); - int lsuffix = ((esuffix) ? (esuffix - nsuffix) : strlen (nsuffix)); + int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix); /* Concatenate path element/specified name with the suffix. */ strncpy (fn + fn_len, nsuffix, lsuffix); @@ -1020,7 +1014,7 @@ locate_file_in_directory_mapper (char *fn, void *arg) struct stat st; /* Ignore file if it's a directory. */ - if (stat (fn, &st) >= 0 + if (xemacs_stat (fn, &st) >= 0 && (st.st_mode & S_IFMT) != S_IFDIR) { /* Check that we can access or open it. */ @@ -1035,7 +1029,7 @@ locate_file_in_directory_mapper (char *fn, void *arg) if (closure->storeptr) *closure->storeptr = build_string (fn); -#ifndef WINDOWSNT +#ifndef WIN32_NATIVE /* If we actually opened the file, set close-on-exec flag on the new descriptor so that subprocesses can't whack at it. */ @@ -1236,7 +1230,7 @@ locate_file (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, int found = 0; /* If this path element is relative, we have to look by hand. */ - if (NILP (Ffile_name_absolute_p (pathel))) + if (NILP (pathel) || NILP (Ffile_name_absolute_p (pathel))) { val = locate_file_in_directory (pathel, str, suffixes, storeptr, mode); @@ -1876,7 +1870,7 @@ read_atom_0 (Lisp_Object readcharfun, Emchar firstchar, int *saw_a_backslash) return Lstream_byte_count (XLSTREAM (Vread_buffer_stream)) - 1; } -static Lisp_Object parse_integer (CONST Bufbyte *buf, Bytecount len, int base); +static Lisp_Object parse_integer (const Bufbyte *buf, Bytecount len, int base); static Lisp_Object read_atom (Lisp_Object readcharfun, @@ -1947,7 +1941,6 @@ read_atom (Lisp_Object readcharfun, sym = Fmake_symbol ( make_string ((Bufbyte *) read_ptr, len)); else { - /* intern will purecopy pname if necessary */ Lisp_Object name = make_string ((Bufbyte *) read_ptr, len); sym = Fintern (name, Qnil); } @@ -1957,10 +1950,10 @@ read_atom (Lisp_Object readcharfun, static Lisp_Object -parse_integer (CONST Bufbyte *buf, Bytecount len, int base) +parse_integer (const Bufbyte *buf, Bytecount len, int base) { - CONST Bufbyte *lim = buf + len; - CONST Bufbyte *p = buf; + const Bufbyte *lim = buf + len; + const Bufbyte *p = buf; EMACS_UINT num = 0; int negativland = 0; @@ -2043,6 +2036,7 @@ read_bit_vector (Lisp_Object readcharfun) { unsigned_char_dynarr *dyn = Dynarr_new (unsigned_char); Emchar c; + Lisp_Object val; while (1) { @@ -2055,8 +2049,12 @@ read_bit_vector (Lisp_Object readcharfun) if (c >= 0) unreadchar (readcharfun, c); - return make_bit_vector_from_byte_vector (Dynarr_atp (dyn, 0), - Dynarr_length (dyn)); + val = make_bit_vector_from_byte_vector (Dynarr_atp (dyn, 0), + Dynarr_length (dyn)); + + Dynarr_free (dyn); + + return val; } @@ -2122,17 +2120,17 @@ read_structure (Lisp_Object readcharfun) GCPRO2 (orig_list, already_seen); if (c != '(') - RETURN_UNGCPRO (continuable_syntax_error ("#s not followed by paren")); + RETURN_UNGCPRO (continuable_read_syntax_error ("#s not followed by paren")); list = read_list (readcharfun, ')', 0, 0); orig_list = list; { int len = XINT (Flength (list)); if (len == 0) - RETURN_UNGCPRO (continuable_syntax_error + RETURN_UNGCPRO (continuable_read_syntax_error ("structure type not specified")); if (!(len & 1)) RETURN_UNGCPRO - (continuable_syntax_error + (continuable_read_syntax_error ("structures must have alternating keyword/value pairs")); } @@ -2698,10 +2696,10 @@ retry: #define EXP_INT 16 int -isfloat_string (CONST char *cp) +isfloat_string (const char *cp) { int state = 0; - CONST Bufbyte *ucp = (CONST Bufbyte *) cp; + const Bufbyte *ucp = (const Bufbyte *) cp; if (*ucp == '+' || *ucp == '-') ucp++; @@ -2769,9 +2767,9 @@ sequence_reader (Lisp_Object readcharfun, unreadchar (readcharfun, ch); #ifdef FEATUREP_SYNTAX if (ch == ']') - syntax_error ("\"]\" in a list"); + read_syntax_error ("\"]\" in a list"); else if (ch == ')') - syntax_error ("\")\" in a vector"); + read_syntax_error ("\")\" in a vector"); #endif state = ((conser) (readcharfun, state, len)); } @@ -2811,15 +2809,15 @@ read_list_conser (Lisp_Object readcharfun, void *state, Charcount len) goto done; } else if (ch == ']') - syntax_error ("']' in a list"); + read_syntax_error ("']' in a list"); else if (ch == ')') - syntax_error ("')' in a vector"); + read_syntax_error ("')' in a vector"); else #endif if (ch != '.') signal_simple_error ("BUG! Internal reader error", elt); else if (!s->allow_dotted_lists) - syntax_error ("\".\" in a vector"); + read_syntax_error ("\".\" in a vector"); else { if (!NILP (s->tail)) @@ -2837,7 +2835,7 @@ read_list_conser (Lisp_Object readcharfun, void *state, Charcount len) goto done; } } - syntax_error (". in wrong context"); + read_syntax_error (". in wrong context"); } } @@ -3004,13 +3002,8 @@ read_vector (Lisp_Object readcharfun, i < len; i++, p++) { - struct Lisp_Cons *otem = XCONS (tem); -#if 0 /* FSFmacs defun hack */ - if (read_pure) - tem = Fpurecopy (Fcar (tem)); - else -#endif - tem = Fcar (tem); + Lisp_Cons *otem = XCONS (tem); + tem = Fcar (tem); *p = tem; tem = otem->cdr; free_cons (otem); @@ -3037,11 +3030,11 @@ read_compiled_function (Lisp_Object readcharfun, Emchar terminator) len = XINT (Flength (stuff)); if (len < COMPILED_STACK_DEPTH + 1 || len > COMPILED_DOMAIN + 1) return - continuable_syntax_error ("#[...] used with wrong number of elements"); + continuable_read_syntax_error ("#[...] used with wrong number of elements"); for (iii = 0; CONSP (stuff); iii++) { - struct Lisp_Cons *victim = XCONS (stuff); + Lisp_Cons *victim = XCONS (stuff); make_byte_code_args[iii] = Fcar (stuff); if ((purify_flag || load_force_doc_strings) && CONSP (make_byte_code_args[iii]) @@ -3149,8 +3142,17 @@ structure_type_create (void) } void +reinit_vars_of_lread (void) +{ + Vread_buffer_stream = Qnil; + staticpro_nodump (&Vread_buffer_stream); +} + +void vars_of_lread (void) { + reinit_vars_of_lread (); + DEFVAR_LISP ("values", &Vvalues /* List of values of all expressions which were read, evaluated and printed. Order is reverse chronological. @@ -3268,9 +3270,6 @@ character escape syntaxes or just read them incorrectly. with values saved when the image is dumped. */ staticpro (&Vload_descriptor_list); - Vread_buffer_stream = Qnil; - staticpro (&Vread_buffer_stream); - /* Initialized in init_lread. */ staticpro (&Vload_force_doc_string_list);