diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 6c2e8b8ef..4d70625d2 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,5 +1,14 @@ Sat Mar 8 00:27:05 1997 Gary Houston + * read.c (scm_init_read): intitialise scm_read_hash_procedures + (idea from Mikael: make it a pair so scm_permanent object only + called once.) + (scm_read_hash_extend): don't call scm_permanent_object. + (ideas from Mikael): if chr is already in the list, replace its + procedure instead of appending it again. If chr is #f, remove + it from the list. + (scm_get_hash_procedure): take CDR of scm_read_hash_procedures. + * strports.c (scm_read_0str, scm_eval_0str): update scm_read usage. * gdbint.c (gdb_read): update scm_lreadr usage. diff --git a/libguile/Makefile.in b/libguile/Makefile.in index f18033012..b71382d17 100644 --- a/libguile/Makefile.in +++ b/libguile/Makefile.in @@ -37,21 +37,21 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ -host_alias = @host_alias@ host_triplet = @host@ -RANLIB = @RANLIB@ -LIBTOOL = @LIBTOOL@ -AWK = @AWK@ -module = @module@ -LIBLOBJS = @LIBLOBJS@ -CC = @CC@ -PACKAGE = @PACKAGE@ +host_alias = @host_alias@ ERRNO_EXTRACT = @ERRNO_EXTRACT@ FD_SETTER = @FD_SETTER@ +LIBLOBJS = @LIBLOBJS@ +AWK = @AWK@ +LIBTOOL = @LIBTOOL@ VERSION = @VERSION@ +module = @module@ +CC = @CC@ +RANLIB = @RANLIB@ +MAINT = @MAINT@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ xtra_PLUGIN_guile_libs = @xtra_PLUGIN_guile_libs@ -MAINT = @MAINT@ +PACKAGE = @PACKAGE@ AUTOMAKE_OPTIONS = foreign @@ -133,7 +133,7 @@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) LINK = $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ DATA = $(modinclude_DATA) -HEADERS = $(modinclude_HEADERS) $(include_HEADERS) +HEADERS = $(include_HEADERS) $(modinclude_HEADERS) DIST_COMMON = COPYING ChangeLog Makefile.am Makefile.in acconfig.h \ acinclude.m4 aclocal.m4 configure configure.in fd.h.in guile-snarf.in \ @@ -297,19 +297,6 @@ uninstall-modincludeDATA: rm -f $(modincludedir)/$$p; \ done -install-modincludeHEADERS: $(modinclude_HEADERS) - $(NORMAL_INSTALL) - $(mkinstalldirs) $(modincludedir) - @list="$(modinclude_HEADERS)"; for p in $$list; do \ - echo "$(INSTALL_DATA) $(srcdir)/$$p $(modincludedir)/$$p"; \ - $(INSTALL_DATA) $(srcdir)/$$p $(modincludedir)/$$p; \ - done - -uninstall-modincludeHEADERS: - list="$(modinclude_HEADERS)"; for p in $$list; do \ - rm -f $(modincludedir)/$$p; \ - done - install-includeHEADERS: $(include_HEADERS) $(NORMAL_INSTALL) $(mkinstalldirs) $(includedir) @@ -323,6 +310,19 @@ uninstall-includeHEADERS: rm -f $(includedir)/$$p; \ done +install-modincludeHEADERS: $(modinclude_HEADERS) + $(NORMAL_INSTALL) + $(mkinstalldirs) $(modincludedir) + @list="$(modinclude_HEADERS)"; for p in $$list; do \ + echo "$(INSTALL_DATA) $(srcdir)/$$p $(modincludedir)/$$p"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(modincludedir)/$$p; \ + done + +uninstall-modincludeHEADERS: + list="$(modinclude_HEADERS)"; for p in $$list; do \ + rm -f $(modincludedir)/$$p; \ + done + tags: TAGS ID: $(HEADERS) $(SOURCES) @@ -419,21 +419,21 @@ installcheck: install-exec: install-libPROGRAMS install-binSCRIPTS $(NORMAL_INSTALL) -install-data: install-modincludeDATA install-modincludeHEADERS install-includeHEADERS +install-data: install-modincludeDATA install-includeHEADERS install-modincludeHEADERS $(NORMAL_INSTALL) install: install-exec install-data all @: -uninstall: uninstall-libPROGRAMS uninstall-binSCRIPTS uninstall-modincludeDATA uninstall-modincludeHEADERS uninstall-includeHEADERS +uninstall: uninstall-libPROGRAMS uninstall-binSCRIPTS uninstall-modincludeDATA uninstall-includeHEADERS uninstall-modincludeHEADERS all: $(PROGRAMS) $(SCRIPTS) $(DATA) $(HEADERS) Makefile scmconfig.h install-strip: $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install installdirs: - $(mkinstalldirs) $(libdir) $(bindir) $(modincludedir) $(modincludedir) \ - $(includedir) + $(mkinstalldirs) $(libdir) $(bindir) $(modincludedir) $(includedir) \ + $(modincludedir) mostlyclean-generic: @@ -478,10 +478,10 @@ install-libPROGRAMS mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile mostlyclean-libtool distclean-libtool \ clean-libtool maintainer-clean-libtool uninstall-binSCRIPTS \ install-binSCRIPTS uninstall-modincludeDATA install-modincludeDATA \ -uninstall-modincludeHEADERS install-modincludeHEADERS \ -uninstall-includeHEADERS install-includeHEADERS tags mostlyclean-tags \ -distclean-tags clean-tags maintainer-clean-tags distdir \ -mostlyclean-depend distclean-depend clean-depend \ +uninstall-includeHEADERS install-includeHEADERS \ +uninstall-modincludeHEADERS install-modincludeHEADERS tags \ +mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir mostlyclean-depend distclean-depend clean-depend \ maintainer-clean-depend info dvi installcheck install-exec install-data \ install uninstall all installdirs mostlyclean-generic distclean-generic \ clean-generic maintainer-clean-generic clean mostlyclean distclean \ diff --git a/libguile/read.c b/libguile/read.c index ca7614df0..c71cf77fc 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -82,8 +82,9 @@ scm_read_options (setting) return ans; } -/* Association list mapping extra hash characters to procedures. */ -static SCM scm_read_hash_procedures = SCM_EOL; +/* CDR contains an association list mapping extra hash characters to + procedures. */ +static SCM scm_read_hash_procedures; SCM_PROC (s_read, "read", 0, 1, 0, scm_read); @@ -762,16 +763,42 @@ scm_read_hash_extend (chr, proc) SCM chr; SCM proc; { - SCM_ASSERT (SCM_ICHRP(chr), chr, SCM_ARG1, s_read_hash_extend); - SCM_ASSERT (SCM_NIMP(proc), proc, SCM_ARG2, s_read_hash_extend); + SCM this; + SCM prev; + + SCM_ASSERT (SCM_ICHRP(chr), chr, SCM_ARG1, s_read_hash_extend); + SCM_ASSERT (SCM_FALSEP (proc) || SCM_NIMP(proc), proc, SCM_ARG2, + s_read_hash_extend); + + /* See it this chr is already in the alist. */ + this = SCM_CDR (scm_read_hash_procedures); + prev = scm_read_hash_procedures; + while (1) + { + if (SCM_NULLP (this)) + { + /* not found, so add it to the beginning. */ + if (SCM_NFALSEP (proc)) + { + scm_set_cdr_x (scm_read_hash_procedures, + scm_cons (scm_cons (chr, proc), + SCM_CDR (scm_read_hash_procedures))); + } + break; + } + if (chr == SCM_CAAR (this)) + { + /* already in the alist. */ + if (SCM_FALSEP (proc)) + scm_set_cdr_x (prev, SCM_CDR (this)); /* remove it. */ + else + scm_set_cdr_x (SCM_CAR (this), proc); /* replace it. */ + break; + } + prev = this; + this = SCM_CDR (this); + } - /* We are making every member of this list a permanent object. - Is that bad? */ - SCM_DEFER_INTS; - scm_read_hash_procedures = scm_cons (scm_cons (chr, proc), - scm_read_hash_procedures); - scm_permanent_object (scm_read_hash_procedures); - SCM_ALLOW_INTS; return SCM_UNSPECIFIED; } @@ -780,7 +807,8 @@ static SCM scm_get_hash_procedure (c) int c; { - SCM rest = scm_read_hash_procedures; + SCM rest = SCM_CDR (scm_read_hash_procedures); + while (1) { if (SCM_NULLP (rest)) @@ -796,6 +824,9 @@ scm_get_hash_procedure (c) void scm_init_read () { + scm_read_hash_procedures = scm_cons (SCM_BOOL_F, SCM_EOL); + scm_permanent_object (scm_read_hash_procedures); + scm_init_opts (scm_read_options, scm_read_opts, SCM_N_READ_OPTIONS); #include "read.x" }