mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-03 21:30:29 +02:00
* 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.
This commit is contained in:
parent
00c34e457c
commit
fed9c9a2d4
3 changed files with 83 additions and 43 deletions
|
@ -1,5 +1,14 @@
|
||||||
Sat Mar 8 00:27:05 1997 Gary Houston <ghouston@actrix.gen.nz>
|
Sat Mar 8 00:27:05 1997 Gary Houston <ghouston@actrix.gen.nz>
|
||||||
|
|
||||||
|
* 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.
|
* strports.c (scm_read_0str, scm_eval_0str): update scm_read usage.
|
||||||
|
|
||||||
* gdbint.c (gdb_read): update scm_lreadr usage.
|
* gdbint.c (gdb_read): update scm_lreadr usage.
|
||||||
|
|
|
@ -37,21 +37,21 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||||
INSTALL_DATA = @INSTALL_DATA@
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||||
transform = @program_transform_name@
|
transform = @program_transform_name@
|
||||||
host_alias = @host_alias@
|
|
||||||
host_triplet = @host@
|
host_triplet = @host@
|
||||||
RANLIB = @RANLIB@
|
host_alias = @host_alias@
|
||||||
LIBTOOL = @LIBTOOL@
|
|
||||||
AWK = @AWK@
|
|
||||||
module = @module@
|
|
||||||
LIBLOBJS = @LIBLOBJS@
|
|
||||||
CC = @CC@
|
|
||||||
PACKAGE = @PACKAGE@
|
|
||||||
ERRNO_EXTRACT = @ERRNO_EXTRACT@
|
ERRNO_EXTRACT = @ERRNO_EXTRACT@
|
||||||
FD_SETTER = @FD_SETTER@
|
FD_SETTER = @FD_SETTER@
|
||||||
|
LIBLOBJS = @LIBLOBJS@
|
||||||
|
AWK = @AWK@
|
||||||
|
LIBTOOL = @LIBTOOL@
|
||||||
VERSION = @VERSION@
|
VERSION = @VERSION@
|
||||||
|
module = @module@
|
||||||
|
CC = @CC@
|
||||||
|
RANLIB = @RANLIB@
|
||||||
|
MAINT = @MAINT@
|
||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||||
xtra_PLUGIN_guile_libs = @xtra_PLUGIN_guile_libs@
|
xtra_PLUGIN_guile_libs = @xtra_PLUGIN_guile_libs@
|
||||||
MAINT = @MAINT@
|
PACKAGE = @PACKAGE@
|
||||||
|
|
||||||
AUTOMAKE_OPTIONS = foreign
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||||
LINK = $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@
|
LINK = $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@
|
||||||
DATA = $(modinclude_DATA)
|
DATA = $(modinclude_DATA)
|
||||||
|
|
||||||
HEADERS = $(modinclude_HEADERS) $(include_HEADERS)
|
HEADERS = $(include_HEADERS) $(modinclude_HEADERS)
|
||||||
|
|
||||||
DIST_COMMON = COPYING ChangeLog Makefile.am Makefile.in acconfig.h \
|
DIST_COMMON = COPYING ChangeLog Makefile.am Makefile.in acconfig.h \
|
||||||
acinclude.m4 aclocal.m4 configure configure.in fd.h.in guile-snarf.in \
|
acinclude.m4 aclocal.m4 configure configure.in fd.h.in guile-snarf.in \
|
||||||
|
@ -297,19 +297,6 @@ uninstall-modincludeDATA:
|
||||||
rm -f $(modincludedir)/$$p; \
|
rm -f $(modincludedir)/$$p; \
|
||||||
done
|
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)
|
install-includeHEADERS: $(include_HEADERS)
|
||||||
$(NORMAL_INSTALL)
|
$(NORMAL_INSTALL)
|
||||||
$(mkinstalldirs) $(includedir)
|
$(mkinstalldirs) $(includedir)
|
||||||
|
@ -323,6 +310,19 @@ uninstall-includeHEADERS:
|
||||||
rm -f $(includedir)/$$p; \
|
rm -f $(includedir)/$$p; \
|
||||||
done
|
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
|
tags: TAGS
|
||||||
|
|
||||||
ID: $(HEADERS) $(SOURCES)
|
ID: $(HEADERS) $(SOURCES)
|
||||||
|
@ -419,21 +419,21 @@ installcheck:
|
||||||
install-exec: install-libPROGRAMS install-binSCRIPTS
|
install-exec: install-libPROGRAMS install-binSCRIPTS
|
||||||
$(NORMAL_INSTALL)
|
$(NORMAL_INSTALL)
|
||||||
|
|
||||||
install-data: install-modincludeDATA install-modincludeHEADERS install-includeHEADERS
|
install-data: install-modincludeDATA install-includeHEADERS install-modincludeHEADERS
|
||||||
$(NORMAL_INSTALL)
|
$(NORMAL_INSTALL)
|
||||||
|
|
||||||
install: install-exec install-data all
|
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
|
all: $(PROGRAMS) $(SCRIPTS) $(DATA) $(HEADERS) Makefile scmconfig.h
|
||||||
|
|
||||||
install-strip:
|
install-strip:
|
||||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||||
installdirs:
|
installdirs:
|
||||||
$(mkinstalldirs) $(libdir) $(bindir) $(modincludedir) $(modincludedir) \
|
$(mkinstalldirs) $(libdir) $(bindir) $(modincludedir) $(includedir) \
|
||||||
$(includedir)
|
$(modincludedir)
|
||||||
|
|
||||||
|
|
||||||
mostlyclean-generic:
|
mostlyclean-generic:
|
||||||
|
@ -478,10 +478,10 @@ install-libPROGRAMS mostlyclean-compile distclean-compile clean-compile \
|
||||||
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
|
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
|
||||||
clean-libtool maintainer-clean-libtool uninstall-binSCRIPTS \
|
clean-libtool maintainer-clean-libtool uninstall-binSCRIPTS \
|
||||||
install-binSCRIPTS uninstall-modincludeDATA install-modincludeDATA \
|
install-binSCRIPTS uninstall-modincludeDATA install-modincludeDATA \
|
||||||
uninstall-modincludeHEADERS install-modincludeHEADERS \
|
uninstall-includeHEADERS install-includeHEADERS \
|
||||||
uninstall-includeHEADERS install-includeHEADERS tags mostlyclean-tags \
|
uninstall-modincludeHEADERS install-modincludeHEADERS tags \
|
||||||
distclean-tags clean-tags maintainer-clean-tags distdir \
|
mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
|
||||||
mostlyclean-depend distclean-depend clean-depend \
|
distdir mostlyclean-depend distclean-depend clean-depend \
|
||||||
maintainer-clean-depend info dvi installcheck install-exec install-data \
|
maintainer-clean-depend info dvi installcheck install-exec install-data \
|
||||||
install uninstall all installdirs mostlyclean-generic distclean-generic \
|
install uninstall all installdirs mostlyclean-generic distclean-generic \
|
||||||
clean-generic maintainer-clean-generic clean mostlyclean distclean \
|
clean-generic maintainer-clean-generic clean mostlyclean distclean \
|
||||||
|
|
|
@ -82,8 +82,9 @@ scm_read_options (setting)
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Association list mapping extra hash characters to procedures. */
|
/* CDR contains an association list mapping extra hash characters to
|
||||||
static SCM scm_read_hash_procedures = SCM_EOL;
|
procedures. */
|
||||||
|
static SCM scm_read_hash_procedures;
|
||||||
|
|
||||||
SCM_PROC (s_read, "read", 0, 1, 0, scm_read);
|
SCM_PROC (s_read, "read", 0, 1, 0, scm_read);
|
||||||
|
|
||||||
|
@ -762,16 +763,42 @@ scm_read_hash_extend (chr, proc)
|
||||||
SCM chr;
|
SCM chr;
|
||||||
SCM proc;
|
SCM proc;
|
||||||
{
|
{
|
||||||
SCM_ASSERT (SCM_ICHRP(chr), chr, SCM_ARG1, s_read_hash_extend);
|
SCM this;
|
||||||
SCM_ASSERT (SCM_NIMP(proc), proc, SCM_ARG2, s_read_hash_extend);
|
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;
|
return SCM_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,7 +807,8 @@ static SCM
|
||||||
scm_get_hash_procedure (c)
|
scm_get_hash_procedure (c)
|
||||||
int c;
|
int c;
|
||||||
{
|
{
|
||||||
SCM rest = scm_read_hash_procedures;
|
SCM rest = SCM_CDR (scm_read_hash_procedures);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (SCM_NULLP (rest))
|
if (SCM_NULLP (rest))
|
||||||
|
@ -796,6 +824,9 @@ scm_get_hash_procedure (c)
|
||||||
void
|
void
|
||||||
scm_init_read ()
|
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);
|
scm_init_opts (scm_read_options, scm_read_opts, SCM_N_READ_OPTIONS);
|
||||||
#include "read.x"
|
#include "read.x"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue