From 17077b3ac9119c69d30228294f083380c22c5b9a Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sat, 27 Nov 2010 09:57:32 -0700 Subject: local copy of load.c from guile --- gr-run-waveform/xyzzy-load.c | 532 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 532 insertions(+) create mode 100644 gr-run-waveform/xyzzy-load.c (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c new file mode 100644 index 000000000..ef596c165 --- /dev/null +++ b/gr-run-waveform/xyzzy-load.c @@ -0,0 +1,532 @@ +/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2004, 2006 Free Software Foundation, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include "libguile/__scm.h" +//#include "libguile/libpath.h" +#include "libguile/fports.h" +#include "libguile/read.h" +#include "libguile/eval.h" +#include "libguile/throw.h" +#include "libguile/alist.h" +#include "libguile/dynwind.h" +#include "libguile/root.h" +#include "libguile/strings.h" +#include "libguile/modules.h" +#include "libguile/lang.h" +#include "libguile/chars.h" +#include "libguile/srfi-13.h" + +#include "libguile/validate.h" +#include "libguile/load.h" +#include "libguile/fluids.h" + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ + +#ifndef R_OK +#define R_OK 4 +#endif + + +/* Loading a file, given an absolute filename. */ + +/* Hook to run when we load a file, perhaps to announce the fact somewhere. + Applied to the full name of the file. */ +static SCM *scm_loc_load_hook; + +/* The current reader (a fluid). */ +static SCM the_reader = SCM_BOOL_F; +static size_t the_reader_fluid_num = 0; + +SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, + (SCM filename), + "Load the file named @var{filename} and evaluate its contents in\n" + "the top-level environment. The load paths are not searched;\n" + "@var{filename} must either be a full pathname or be a pathname\n" + "relative to the current directory. If the variable\n" + "@code{%load-hook} is defined, it should be bound to a procedure\n" + "that will be called before any code is loaded. See the\n" + "documentation for @code{%load-hook} later in this section.") +#define FUNC_NAME s_scm_primitive_load +{ + SCM hook = *scm_loc_load_hook; + SCM_VALIDATE_STRING (1, filename); + if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) + SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", + SCM_EOL); + + if (!scm_is_false (hook)) + scm_call_1 (hook, filename); + + { /* scope */ + SCM port = scm_open_file (filename, scm_from_locale_string ("r")); + scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE); + scm_i_dynwind_current_load_port (port); + + while (1) + { + SCM reader, form; + + /* Lookup and use the current reader to read the next + expression. */ + reader = SCM_FAST_FLUID_REF (the_reader_fluid_num); + if (reader == SCM_BOOL_F) + form = scm_read (port); + else + form = scm_call_1 (reader, port); + + if (SCM_EOF_OBJECT_P (form)) + break; + + scm_primitive_eval_x (form); + } + + scm_dynwind_end (); + scm_close_port (port); + } + return SCM_UNSPECIFIED; +} +#undef FUNC_NAME + +SCM +scm_c_primitive_load (const char *filename) +{ + return scm_primitive_load (scm_from_locale_string (filename)); +} + + +/* Builtin path to scheme library files. */ +#ifdef SCM_PKGDATA_DIR +SCM_DEFINE (scm_sys_package_data_dir, "%package-data-dir", 0, 0, 0, + (), + "Return the name of the directory where Scheme packages, modules and\n" + "libraries are kept. On most Unix systems, this will be\n" + "@samp{/usr/local/share/guile}.") +#define FUNC_NAME s_scm_sys_package_data_dir +{ + return scm_from_locale_string (SCM_PKGDATA_DIR); +} +#undef FUNC_NAME +#endif /* SCM_PKGDATA_DIR */ + +#ifdef SCM_LIBRARY_DIR +SCM_DEFINE (scm_sys_library_dir, "%library-dir", 0,0,0, + (), + "Return the directory where the Guile Scheme library files are installed.\n" + "E.g., may return \"/usr/share/guile/1.3.5\".") +#define FUNC_NAME s_scm_sys_library_dir +{ + return scm_from_locale_string (SCM_LIBRARY_DIR); +} +#undef FUNC_NAME +#endif /* SCM_LIBRARY_DIR */ + +#ifdef SCM_SITE_DIR +SCM_DEFINE (scm_sys_site_dir, "%site-dir", 0,0,0, + (), + "Return the directory where the Guile site files are installed.\n" + "E.g., may return \"/usr/share/guile/site\".") +#define FUNC_NAME s_scm_sys_site_dir +{ + return scm_from_locale_string (SCM_SITE_DIR); +} +#undef FUNC_NAME +#endif /* SCM_SITE_DIR */ + + + + +/* Initializing the load path, and searching it. */ + +/* List of names of directories we search for files to load. */ +static SCM *scm_loc_load_path; + +/* List of extensions we try adding to the filenames. */ +static SCM *scm_loc_load_extensions; + + +SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0, + (SCM path, SCM tail), + "Parse @var{path}, which is expected to be a colon-separated\n" + "string, into a list and return the resulting list with\n" + "@var{tail} appended. If @var{path} is @code{#f}, @var{tail}\n" + "is returned.") +#define FUNC_NAME s_scm_parse_path +{ +#ifdef __MINGW32__ + SCM sep = SCM_MAKE_CHAR (';'); +#else + SCM sep = SCM_MAKE_CHAR (':'); +#endif + + if (SCM_UNBNDP (tail)) + tail = SCM_EOL; + return (scm_is_false (path) + ? tail + : scm_append_x (scm_list_2 (scm_string_split (path, sep), tail))); +} +#undef FUNC_NAME + + +/* Initialize the global variable %load-path, given the value of the + SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the + GUILE_LOAD_PATH environment variable. */ +void +scm_init_load_path () +{ + char *env; + SCM path = SCM_EOL; + +#ifdef SCM_LIBRARY_DIR + path = scm_list_3 (scm_from_locale_string (SCM_SITE_DIR), + scm_from_locale_string (SCM_LIBRARY_DIR), + scm_from_locale_string (SCM_PKGDATA_DIR)); +#endif /* SCM_LIBRARY_DIR */ + + env = getenv ("GUILE_LOAD_PATH"); + if (env) + path = scm_parse_path (scm_from_locale_string (env), path); + + *scm_loc_load_path = path; +} + +SCM scm_listofnullstr; + +/* Utility functions for assembling C strings in a buffer. + */ + +struct stringbuf { + char *buf, *ptr; + size_t buf_len; +}; + +static void +stringbuf_free (void *data) +{ + struct stringbuf *buf = (struct stringbuf *)data; + free (buf->buf); +} + +static void +stringbuf_grow (struct stringbuf *buf) +{ + size_t ptroff = buf->ptr - buf->buf; + buf->buf_len *= 2; + buf->buf = scm_realloc (buf->buf, buf->buf_len); + buf->ptr = buf->buf + ptroff; +} + +static void +stringbuf_cat_locale_string (struct stringbuf *buf, SCM str) +{ + size_t max_len = buf->buf_len - (buf->ptr - buf->buf) - 1; + size_t len = scm_to_locale_stringbuf (str, buf->ptr, max_len); + if (len > max_len) + { + /* buffer is too small, double its size and try again. + */ + stringbuf_grow (buf); + stringbuf_cat_locale_string (buf, str); + } + else + { + /* string fits, terminate it and check for embedded '\0'. + */ + buf->ptr[len] = '\0'; + if (strlen (buf->ptr) != len) + scm_misc_error (NULL, + "string contains #\\nul character: ~S", + scm_list_1 (str)); + buf->ptr += len; + } +} + +static void +stringbuf_cat (struct stringbuf *buf, char *str) +{ + size_t max_len = buf->buf_len - (buf->ptr - buf->buf) - 1; + size_t len = strlen (str); + if (len > max_len) + { + /* buffer is too small, double its size and try again. + */ + stringbuf_grow (buf); + stringbuf_cat (buf, str); + } + else + { + /* string fits, copy it into buffer. + */ + strcpy (buf->ptr, str); + buf->ptr += len; + } +} + + +/* Search PATH for a directory containing a file named FILENAME. + The file must be readable, and not a directory. + If we find one, return its full filename; otherwise, return #f. + If FILENAME is absolute, return it unchanged. + If given, EXTENSIONS is a list of strings; for each directory + in PATH, we search for FILENAME concatenated with each EXTENSION. */ +SCM_DEFINE (scm_search_path, "search-path", 2, 1, 0, + (SCM path, SCM filename, SCM extensions), + "Search @var{path} for a directory containing a file named\n" + "@var{filename}. The file must be readable, and not a directory.\n" + "If we find one, return its full filename; otherwise, return\n" + "@code{#f}. If @var{filename} is absolute, return it unchanged.\n" + "If given, @var{extensions} is a list of strings; for each\n" + "directory in @var{path}, we search for @var{filename}\n" + "concatenated with each @var{extension}.") +#define FUNC_NAME s_scm_search_path +{ + struct stringbuf buf; + char *filename_chars; + size_t filename_len; + SCM result = SCM_BOOL_F; + + if (SCM_UNBNDP (extensions)) + extensions = SCM_EOL; + + scm_dynwind_begin (0); + + filename_chars = scm_to_locale_string (filename); + filename_len = strlen (filename_chars); + scm_dynwind_free (filename_chars); + + /* If FILENAME is absolute, return it unchanged. */ +#ifdef __MINGW32__ + if (((filename_len >= 1) && + (filename_chars[0] == '/' || filename_chars[0] == '\\')) || + ((filename_len >= 3) && filename_chars[1] == ':' && + ((filename_chars[0] >= 'a' && filename_chars[0] <= 'z') || + (filename_chars[0] >= 'A' && filename_chars[0] <= 'Z')) && + (filename_chars[2] == '/' || filename_chars[2] == '\\'))) +#else + if (filename_len >= 1 && filename_chars[0] == '/') +#endif + { + scm_dynwind_end (); + return filename; + } + + /* If FILENAME has an extension, don't try to add EXTENSIONS to it. */ + { + char *endp; + + for (endp = filename_chars + filename_len - 1; + endp >= filename_chars; + endp--) + { + if (*endp == '.') + { + /* This filename already has an extension, so cancel the + list of extensions. */ + extensions = SCM_EOL; + break; + } +#ifdef __MINGW32__ + else if (*endp == '/' || *endp == '\\') +#else + else if (*endp == '/') +#endif + /* This filename has no extension, so keep the current list + of extensions. */ + break; + } + } + + /* This simplifies the loop below a bit. + */ + if (scm_is_null (extensions)) + extensions = scm_listofnullstr; + + buf.buf_len = 512; + buf.buf = scm_malloc (buf.buf_len); + scm_dynwind_unwind_handler (stringbuf_free, &buf, SCM_F_WIND_EXPLICITLY); + + /* Try every path element. + */ + for (; scm_is_pair (path); path = SCM_CDR (path)) + { + SCM dir = SCM_CAR (path); + SCM exts; + size_t sans_ext_len; + + buf.ptr = buf.buf; + stringbuf_cat_locale_string (&buf, dir); + + /* Concatenate the path name and the filename. */ + +#ifdef __MINGW32__ + if ((buf.ptr > buf.buf) && (buf.ptr[-1] != '/') && (buf.ptr[-1] != '\\')) +#else + if ((buf.ptr > buf.buf) && (buf.ptr[-1] != '/')) +#endif + stringbuf_cat (&buf, "/"); + + stringbuf_cat (&buf, filename_chars); + sans_ext_len = buf.ptr - buf.buf; + + /* Try every extension. */ + for (exts = extensions; scm_is_pair (exts); exts = SCM_CDR (exts)) + { + SCM ext = SCM_CAR (exts); + struct stat mode; + + buf.ptr = buf.buf + sans_ext_len; + stringbuf_cat_locale_string (&buf, ext); + + /* If the file exists at all, we should return it. If the + file is inaccessible, then that's an error. */ + + if (stat (buf.buf, &mode) == 0 + && ! (mode.st_mode & S_IFDIR)) + { + result = scm_from_locale_string (buf.buf); + goto end; + } + } + + if (!SCM_NULL_OR_NIL_P (exts)) + scm_wrong_type_arg_msg (NULL, 0, extensions, "proper list"); + } + + if (!SCM_NULL_OR_NIL_P (path)) + scm_wrong_type_arg_msg (NULL, 0, path, "proper list"); + + end: + scm_dynwind_end (); + return result; +} +#undef FUNC_NAME + + +/* Search %load-path for a directory containing a file named FILENAME. + The file must be readable, and not a directory. + If we find one, return its full filename; otherwise, return #f. + If FILENAME is absolute, return it unchanged. */ +SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, + (SCM filename), + "Search @var{%load-path} for the file named @var{filename},\n" + "which must be readable by the current user. If @var{filename}\n" + "is found in the list of paths to search or is an absolute\n" + "pathname, return its full pathname. Otherwise, return\n" + "@code{#f}. Filenames may have any of the optional extensions\n" + "in the @code{%load-extensions} list; @code{%search-load-path}\n" + "will try each extension automatically.") +#define FUNC_NAME s_scm_sys_search_load_path +{ + SCM path = *scm_loc_load_path; + SCM exts = *scm_loc_load_extensions; + SCM_VALIDATE_STRING (1, filename); + + if (scm_ilength (path) < 0) + SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); + if (scm_ilength (exts) < 0) + SCM_MISC_ERROR ("%load-extension list is not a proper list", SCM_EOL); + return scm_search_path (path, filename, exts); +} +#undef FUNC_NAME + + +SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 1, 0, 0, + (SCM filename), + "Search @var{%load-path} for the file named @var{filename} and\n" + "load it into the top-level environment. If @var{filename} is a\n" + "relative pathname and is not found in the list of search paths,\n" + "an error is signalled.") +#define FUNC_NAME s_scm_primitive_load_path +{ + SCM full_filename; + + full_filename = scm_sys_search_load_path (filename); + + if (scm_is_false (full_filename)) + SCM_MISC_ERROR ("Unable to find file ~S in load path", + scm_list_1 (filename)); + + return scm_primitive_load (full_filename); +} +#undef FUNC_NAME + +SCM +scm_c_primitive_load_path (const char *filename) +{ + return scm_primitive_load_path (scm_from_locale_string (filename)); +} + + +/* Information about the build environment. */ + +/* Initialize the scheme variable %guile-build-info, based on data + provided by the Makefile, via libpath.h. */ +static void +init_build_info () +{ + static struct { char *name; char *value; } info[] = SCM_BUILD_INFO; + SCM *loc = SCM_VARIABLE_LOC (scm_c_define ("%guile-build-info", SCM_EOL)); + unsigned long i; + + for (i = 0; i < (sizeof (info) / sizeof (info[0])); i++) + { + SCM key = scm_from_locale_symbol (info[i].name); + SCM val = scm_from_locale_string (info[i].value); + *loc = scm_acons (key, val, *loc); + } +} + + +void +scm_init_load () +{ + scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); + scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); + scm_loc_load_extensions + = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", + scm_list_2 (scm_from_locale_string (".scm"), + scm_nullstr))); + scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_define ("%load-hook", SCM_BOOL_F)); + + the_reader = scm_make_fluid (); + the_reader_fluid_num = SCM_FLUID_NUM (the_reader); + SCM_FAST_FLUID_SET_X (the_reader_fluid_num, SCM_BOOL_F); + scm_c_define("current-reader", the_reader); + + init_build_info (); + +#include "libguile/load.x" +} + +/* + Local Variables: + c-file-style: "gnu" + End: +*/ -- cgit From b5a8b6fdf5596123ecd2e7bcfb346945247db742 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sat, 27 Nov 2010 10:25:03 -0700 Subject: add additional headers needed to compile this file outside of guile --- gr-run-waveform/xyzzy-load.c | 47 ++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index ef596c165..f8474976c 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -24,24 +24,33 @@ #include #include -#include "libguile/__scm.h" -//#include "libguile/libpath.h" -#include "libguile/fports.h" -#include "libguile/read.h" -#include "libguile/eval.h" -#include "libguile/throw.h" -#include "libguile/alist.h" -#include "libguile/dynwind.h" -#include "libguile/root.h" -#include "libguile/strings.h" -#include "libguile/modules.h" -#include "libguile/lang.h" -#include "libguile/chars.h" -#include "libguile/srfi-13.h" - -#include "libguile/validate.h" -#include "libguile/load.h" -#include "libguile/fluids.h" +/* libpath.h is generated whenever the Makefile is rebuilt */ +#include "libpath.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// these headers where not in the original version of this file. +#include +#include +#include +#include #include #include @@ -522,7 +531,7 @@ scm_init_load () init_build_info (); -#include "libguile/load.x" +#include "load.x" } /* -- cgit From b976c98fcd28b63b94f9ff7c7e32e9279eddc13b Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sat, 27 Nov 2010 15:33:26 -0700 Subject: rename some methods for xyzzy --- gr-run-waveform/xyzzy-load.c | 54 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 11 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index f8474976c..1974df252 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -63,6 +63,8 @@ #define R_OK 4 #endif +#include "xyzzy.h" + /* Loading a file, given an absolute filename. */ @@ -74,7 +76,7 @@ static SCM *scm_loc_load_hook; static SCM the_reader = SCM_BOOL_F; static size_t the_reader_fluid_num = 0; -SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, +SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, (SCM filename), "Load the file named @var{filename} and evaluate its contents in\n" "the top-level environment. The load paths are not searched;\n" @@ -83,10 +85,13 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, "@code{%load-hook} is defined, it should be bound to a procedure\n" "that will be called before any code is loaded. See the\n" "documentation for @code{%load-hook} later in this section.") -#define FUNC_NAME s_scm_primitive_load +#define FUNC_NAME s_scm_xyzzy_primitive_load { SCM hook = *scm_loc_load_hook; SCM_VALIDATE_STRING (1, filename); + + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); + if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", SCM_EOL); @@ -127,7 +132,7 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, SCM scm_c_primitive_load (const char *filename) { - return scm_primitive_load (scm_from_locale_string (filename)); + return scm_xyzzy_primitive_load (scm_from_locale_string (filename)); } @@ -305,7 +310,7 @@ stringbuf_cat (struct stringbuf *buf, char *str) If FILENAME is absolute, return it unchanged. If given, EXTENSIONS is a list of strings; for each directory in PATH, we search for FILENAME concatenated with each EXTENSION. */ -SCM_DEFINE (scm_search_path, "search-path", 2, 1, 0, +SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, (SCM path, SCM filename, SCM extensions), "Search @var{path} for a directory containing a file named\n" "@var{filename}. The file must be readable, and not a directory.\n" @@ -314,22 +319,34 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 1, 0, "If given, @var{extensions} is a list of strings; for each\n" "directory in @var{path}, we search for @var{filename}\n" "concatenated with each @var{extension}.") -#define FUNC_NAME s_scm_search_path +#define FUNC_NAME s_scm_xyzzy_search_path { struct stringbuf buf; char *filename_chars; size_t filename_len; SCM result = SCM_BOOL_F; + SCM exists; if (SCM_UNBNDP (extensions)) extensions = SCM_EOL; scm_dynwind_begin (0); - filename_chars = scm_to_locale_string (filename); filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); + + /* Look in the fake filesystem for this file */ + if (xyzzy_file_exists(filename_chars)) { + fprintf(stderr, "TRACE %s exists in filesystem.dat!\n", filename_chars); + exists = scm_from_locale_string (filename_chars); +#if 0 + scm_dynwind_end (); + return exists; +#endif + } + /* If FILENAME is absolute, return it unchanged. */ #ifdef __MINGW32__ if (((filename_len >= 1) && @@ -381,6 +398,7 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 1, 0, buf.buf = scm_malloc (buf.buf_len); scm_dynwind_unwind_handler (stringbuf_free, &buf, SCM_F_WIND_EXPLICITLY); + /* Try every path element. */ for (; scm_is_pair (path); path = SCM_CDR (path)) @@ -432,7 +450,9 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 1, 0, scm_wrong_type_arg_msg (NULL, 0, path, "proper list"); end: + scm_dynwind_end (); + return result; } #undef FUNC_NAME @@ -457,39 +477,51 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, SCM exts = *scm_loc_load_extensions; SCM_VALIDATE_STRING (1, filename); + fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + if (scm_ilength (path) < 0) SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); if (scm_ilength (exts) < 0) SCM_MISC_ERROR ("%load-extension list is not a proper list", SCM_EOL); - return scm_search_path (path, filename, exts); + + return scm_xyzzy_search_path (path, filename, exts); } #undef FUNC_NAME -SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 1, 0, 0, +SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, (SCM filename), "Search @var{%load-path} for the file named @var{filename} and\n" "load it into the top-level environment. If @var{filename} is a\n" "relative pathname and is not found in the list of search paths,\n" "an error is signalled.") -#define FUNC_NAME s_scm_primitive_load_path +#define FUNC_NAME s_scm_xyzzy_primitive_load_path { SCM full_filename; + char *filename_chars; + size_t filename_len; + + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); + filename_chars = scm_to_locale_string (filename); + filename_len = strlen (filename_chars); + scm_dynwind_free (filename_chars); + full_filename = scm_sys_search_load_path (filename); if (scm_is_false (full_filename)) SCM_MISC_ERROR ("Unable to find file ~S in load path", scm_list_1 (filename)); - return scm_primitive_load (full_filename); + return scm_xyzzy_primitive_load (full_filename); } #undef FUNC_NAME SCM scm_c_primitive_load_path (const char *filename) { - return scm_primitive_load_path (scm_from_locale_string (filename)); + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename); + return scm_xyzzy_primitive_load_path (scm_from_locale_string (filename)); } -- cgit From 8f9eb3d4c09ec67bfc5a7e45ce6aba3051be2ad1 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sat, 27 Nov 2010 15:34:37 -0700 Subject: be less verbose --- gr-run-waveform/xyzzy-load.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 1974df252..3e4ba5307 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -90,8 +90,6 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, SCM hook = *scm_loc_load_hook; SCM_VALIDATE_STRING (1, filename); - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); - if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", SCM_EOL); @@ -335,8 +333,6 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); - /* Look in the fake filesystem for this file */ if (xyzzy_file_exists(filename_chars)) { fprintf(stderr, "TRACE %s exists in filesystem.dat!\n", filename_chars); @@ -477,8 +473,6 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, SCM exts = *scm_loc_load_extensions; SCM_VALIDATE_STRING (1, filename); - fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); - if (scm_ilength (path) < 0) SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); if (scm_ilength (exts) < 0) @@ -501,8 +495,6 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, char *filename_chars; size_t filename_len; - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); - filename_chars = scm_to_locale_string (filename); filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); @@ -520,7 +512,6 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, SCM scm_c_primitive_load_path (const char *filename) { - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename); return scm_xyzzy_primitive_load_path (scm_from_locale_string (filename)); } -- cgit From 66a68e3c4710a26cab8d5d586b9e9bacd1d4761e Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sat, 27 Nov 2010 16:13:42 -0700 Subject: move the contents of load.x into the source file. --- gr-run-waveform/xyzzy-load.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 3e4ba5307..bf814fbd1 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -90,6 +90,8 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, SCM hook = *scm_loc_load_hook; SCM_VALIDATE_STRING (1, filename); + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); + if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", SCM_EOL); @@ -333,6 +335,8 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); + /* Look in the fake filesystem for this file */ if (xyzzy_file_exists(filename_chars)) { fprintf(stderr, "TRACE %s exists in filesystem.dat!\n", filename_chars); @@ -473,6 +477,8 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, SCM exts = *scm_loc_load_extensions; SCM_VALIDATE_STRING (1, filename); + fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + if (scm_ilength (path) < 0) SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); if (scm_ilength (exts) < 0) @@ -495,6 +501,8 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, char *filename_chars; size_t filename_len; + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); + filename_chars = scm_to_locale_string (filename); filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); @@ -512,6 +520,7 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, SCM scm_c_primitive_load_path (const char *filename) { + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename); return scm_xyzzy_primitive_load_path (scm_from_locale_string (filename)); } @@ -554,7 +563,17 @@ scm_init_load () init_build_info (); -#include "load.x" + /* cpp arguments: load.c -DHAVE_CONFIG_H -I.. -I.. -I.. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -Wmissing-prototypes */ + scm_c_define_gsubr (s_scm_xyzzy_primitive_load, 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load); ; + scm_c_define_gsubr (s_scm_sys_package_data_dir, 0, 0, 0, (SCM (*)()) scm_sys_package_data_dir); ; + scm_c_define_gsubr (s_scm_sys_library_dir, 0, 0, 0, (SCM (*)()) scm_sys_library_dir); ; + scm_c_define_gsubr (s_scm_sys_site_dir, 0, 0, 0, (SCM (*)()) scm_sys_site_dir); ; + scm_c_define_gsubr (s_scm_parse_path, 1, 1, 0, (SCM (*)()) scm_parse_path); ; + scm_c_define_gsubr (s_scm_xyzzy_search_path, 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); ; + scm_c_define_gsubr (s_scm_sys_search_load_path, 1, 0, 0, (SCM (*)()) scm_sys_search_load_path); ; + scm_c_define_gsubr (s_scm_xyzzy_primitive_load_path, 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load_path); ; + + /* #include "load.x" */ } /* -- cgit From 4566879af30795e27baf10ac7f8b7b8cbc64b743 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sat, 27 Nov 2010 17:05:29 -0700 Subject: override primitive-load --- gr-run-waveform/xyzzy-load.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index bf814fbd1..f96ae73ef 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -65,6 +65,9 @@ #include "xyzzy.h" +// This is the magic number used when loading files +static const char *MAGIC = "-XyZzY-"; + /* Loading a file, given an absolute filename. */ @@ -76,7 +79,7 @@ static SCM *scm_loc_load_hook; static SCM the_reader = SCM_BOOL_F; static size_t the_reader_fluid_num = 0; -SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, +SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, (SCM filename), "Load the file named @var{filename} and evaluate its contents in\n" "the top-level environment. The load paths are not searched;\n" @@ -85,7 +88,7 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, "@code{%load-hook} is defined, it should be bound to a procedure\n" "that will be called before any code is loaded. See the\n" "documentation for @code{%load-hook} later in this section.") -#define FUNC_NAME s_scm_xyzzy_primitive_load +#define FUNC_NAME s_scm_primitive_load { SCM hook = *scm_loc_load_hook; SCM_VALIDATE_STRING (1, filename); @@ -99,7 +102,14 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, if (!scm_is_false (hook)) scm_call_1 (hook, filename); + /* if (strncmp(scm_from_locale_string(filename), MAGIC, strlen(MAGIC))) { */ + /* const char *ptr = strdup(scm_from_locale_string(filename)); */ + /* /\* ptr += strlen(MAGIC); *\/ */ + /* fprintf(stderr, "FIXME: magic %s\n", ptr); */ + /* } */ + { /* scope */ + fprintf(stderr, "FIXME: magic %s\n", scm_from_locale_string(filename)); SCM port = scm_open_file (filename, scm_from_locale_string ("r")); scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE); scm_i_dynwind_current_load_port (port); @@ -132,7 +142,8 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, SCM scm_c_primitive_load (const char *filename) { - return scm_xyzzy_primitive_load (scm_from_locale_string (filename)); + fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + return scm_primitive_load (scm_from_locale_string (filename)); } @@ -218,6 +229,8 @@ scm_init_load_path () char *env; SCM path = SCM_EOL; + fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + #ifdef SCM_LIBRARY_DIR path = scm_list_3 (scm_from_locale_string (SCM_SITE_DIR), scm_from_locale_string (SCM_LIBRARY_DIR), @@ -327,6 +340,8 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, SCM result = SCM_BOOL_F; SCM exists; + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); + if (SCM_UNBNDP (extensions)) extensions = SCM_EOL; @@ -335,16 +350,17 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); - /* Look in the fake filesystem for this file */ if (xyzzy_file_exists(filename_chars)) { - fprintf(stderr, "TRACE %s exists in filesystem.dat!\n", filename_chars); - exists = scm_from_locale_string (filename_chars); -#if 0 + // fprintf(stderr, "TRACE %s exists in filesystem.dat!\n", filename_chars); + char *modpath = (char *)malloc(filename_len + strlen(MAGIC)); + memset(modpath, 0, filename_len + strlen(MAGIC)); + memcpy(modpath, MAGIC, strlen(MAGIC)); + memcpy(modpath+7, filename_chars, filename_len); + scm_dynwind_free (modpath); + exists = scm_from_locale_string (modpath); scm_dynwind_end (); return exists; -#endif } /* If FILENAME is absolute, return it unchanged. */ @@ -510,10 +526,10 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, full_filename = scm_sys_search_load_path (filename); if (scm_is_false (full_filename)) - SCM_MISC_ERROR ("Unable to find file ~S in load path", + SCM_MISC_ERROR ("Unable to find the file ~S in load path", scm_list_1 (filename)); - return scm_xyzzy_primitive_load (full_filename); + return scm_primitive_load (full_filename); } #undef FUNC_NAME @@ -564,7 +580,7 @@ scm_init_load () init_build_info (); /* cpp arguments: load.c -DHAVE_CONFIG_H -I.. -I.. -I.. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -Wmissing-prototypes */ - scm_c_define_gsubr (s_scm_xyzzy_primitive_load, 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load); ; + scm_c_define_gsubr (s_scm_primitive_load, 1, 0, 0, (SCM (*)()) scm_primitive_load); ; scm_c_define_gsubr (s_scm_sys_package_data_dir, 0, 0, 0, (SCM (*)()) scm_sys_package_data_dir); ; scm_c_define_gsubr (s_scm_sys_library_dir, 0, 0, 0, (SCM (*)()) scm_sys_library_dir); ; scm_c_define_gsubr (s_scm_sys_site_dir, 0, 0, 0, (SCM (*)()) scm_sys_site_dir); ; -- cgit From b2a39b5cbb40b85450c9b6fa07338fe048cc7892 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sat, 27 Nov 2010 17:33:04 -0700 Subject: Prepend the magic number for found paths. Override primitive-load. --- gr-run-waveform/xyzzy-load.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index f96ae73ef..73d266892 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -93,7 +93,9 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, SCM hook = *scm_loc_load_hook; SCM_VALIDATE_STRING (1, filename); - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); + size_t len = strlen(scm_to_locale_string(filename)); + char *ptr = scm_to_locale_string(filename); + /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); */ if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", @@ -102,15 +104,13 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, if (!scm_is_false (hook)) scm_call_1 (hook, filename); - /* if (strncmp(scm_from_locale_string(filename), MAGIC, strlen(MAGIC))) { */ - /* const char *ptr = strdup(scm_from_locale_string(filename)); */ - /* /\* ptr += strlen(MAGIC); *\/ */ - /* fprintf(stderr, "FIXME: magic %s\n", ptr); */ - /* } */ - { /* scope */ - fprintf(stderr, "FIXME: magic %s\n", scm_from_locale_string(filename)); - SCM port = scm_open_file (filename, scm_from_locale_string ("r")); + SCM port; + if (strncmp(ptr, MAGIC, strlen(MAGIC)) == 0) { + fprintf(stderr, "FIXME: %s is a XYZZY file system file!\n", ptr+strlen(MAGIC)); + } else { + port = scm_open_file (filename, scm_from_locale_string ("r")); + } scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE); scm_i_dynwind_current_load_port (port); @@ -142,7 +142,6 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, SCM scm_c_primitive_load (const char *filename) { - fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); return scm_primitive_load (scm_from_locale_string (filename)); } @@ -229,7 +228,7 @@ scm_init_load_path () char *env; SCM path = SCM_EOL; - fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ #ifdef SCM_LIBRARY_DIR path = scm_list_3 (scm_from_locale_string (SCM_SITE_DIR), @@ -340,7 +339,7 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, SCM result = SCM_BOOL_F; SCM exists; - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); + /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); */ if (SCM_UNBNDP (extensions)) extensions = SCM_EOL; @@ -350,11 +349,12 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); - /* Look in the fake filesystem for this file */ + /* Look in the fake filesystem for this file. If we find it, we prepend a + magic number to the front so we can identify these special files later + on when trying to read from them. */ if (xyzzy_file_exists(filename_chars)) { - // fprintf(stderr, "TRACE %s exists in filesystem.dat!\n", filename_chars); - char *modpath = (char *)malloc(filename_len + strlen(MAGIC)); - memset(modpath, 0, filename_len + strlen(MAGIC)); + char *modpath = (char *)malloc(filename_len + strlen(MAGIC) + 1); + memset(modpath, 0, filename_len + strlen(MAGIC) + 1); memcpy(modpath, MAGIC, strlen(MAGIC)); memcpy(modpath+7, filename_chars, filename_len); scm_dynwind_free (modpath); @@ -493,7 +493,7 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, SCM exts = *scm_loc_load_extensions; SCM_VALIDATE_STRING (1, filename); - fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ if (scm_ilength (path) < 0) SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); @@ -517,7 +517,7 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, char *filename_chars; size_t filename_len; - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); + /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); */ filename_chars = scm_to_locale_string (filename); filename_len = strlen (filename_chars); @@ -536,7 +536,6 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, SCM scm_c_primitive_load_path (const char *filename) { - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename); return scm_xyzzy_primitive_load_path (scm_from_locale_string (filename)); } -- cgit From 07afaeebb27aa8608275a4949aa94206a227b8f2 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sun, 28 Nov 2010 13:55:26 -0700 Subject: rename the other search functions --- gr-run-waveform/xyzzy-load.c | 55 +++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 29 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 73d266892..07e3de78c 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -79,7 +79,7 @@ static SCM *scm_loc_load_hook; static SCM the_reader = SCM_BOOL_F; static size_t the_reader_fluid_num = 0; -SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, +SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, (SCM filename), "Load the file named @var{filename} and evaluate its contents in\n" "the top-level environment. The load paths are not searched;\n" @@ -88,14 +88,14 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, "@code{%load-hook} is defined, it should be bound to a procedure\n" "that will be called before any code is loaded. See the\n" "documentation for @code{%load-hook} later in this section.") -#define FUNC_NAME s_scm_primitive_load +#define FUNC_NAME s_scm_xyzzy_primitive_load { SCM hook = *scm_loc_load_hook; SCM_VALIDATE_STRING (1, filename); size_t len = strlen(scm_to_locale_string(filename)); char *ptr = scm_to_locale_string(filename); - /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); */ + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", @@ -142,7 +142,8 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, SCM scm_c_primitive_load (const char *filename) { - return scm_primitive_load (scm_from_locale_string (filename)); + fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); + return scm_xyzzy_primitive_load (scm_from_locale_string (filename)); } @@ -228,7 +229,7 @@ scm_init_load_path () char *env; SCM path = SCM_EOL; - /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ + fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); #ifdef SCM_LIBRARY_DIR path = scm_list_3 (scm_from_locale_string (SCM_SITE_DIR), @@ -337,9 +338,8 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, char *filename_chars; size_t filename_len; SCM result = SCM_BOOL_F; - SCM exists; - /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); */ + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); if (SCM_UNBNDP (extensions)) extensions = SCM_EOL; @@ -349,20 +349,6 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); - /* Look in the fake filesystem for this file. If we find it, we prepend a - magic number to the front so we can identify these special files later - on when trying to read from them. */ - if (xyzzy_file_exists(filename_chars)) { - char *modpath = (char *)malloc(filename_len + strlen(MAGIC) + 1); - memset(modpath, 0, filename_len + strlen(MAGIC) + 1); - memcpy(modpath, MAGIC, strlen(MAGIC)); - memcpy(modpath+7, filename_chars, filename_len); - scm_dynwind_free (modpath); - exists = scm_from_locale_string (modpath); - scm_dynwind_end (); - return exists; - } - /* If FILENAME is absolute, return it unchanged. */ #ifdef __MINGW32__ if (((filename_len >= 1) && @@ -450,6 +436,14 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, /* If the file exists at all, we should return it. If the file is inaccessible, then that's an error. */ + /* Look in the fake filesystem for this file. If we find it, we prepend a + magic number to the front so we can identify these special files later + on when trying to read from them. */ + if (xyzzy_file_exists(buf.buf)) { + result = scm_from_locale_string (buf.buf); + goto end; + } + if (stat (buf.buf, &mode) == 0 && ! (mode.st_mode & S_IFDIR)) { @@ -478,7 +472,7 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, The file must be readable, and not a directory. If we find one, return its full filename; otherwise, return #f. If FILENAME is absolute, return it unchanged. */ -SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, +SCM_DEFINE (scm_xyzzy_sys_search_load_path, "%search-load-path", 1, 0, 0, (SCM filename), "Search @var{%load-path} for the file named @var{filename},\n" "which must be readable by the current user. If @var{filename}\n" @@ -487,13 +481,13 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, "@code{#f}. Filenames may have any of the optional extensions\n" "in the @code{%load-extensions} list; @code{%search-load-path}\n" "will try each extension automatically.") -#define FUNC_NAME s_scm_sys_search_load_path +#define FUNC_NAME s_scm_xyzzy_sys_search_load_path { SCM path = *scm_loc_load_path; SCM exts = *scm_loc_load_extensions; SCM_VALIDATE_STRING (1, filename); - /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ + fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); if (scm_ilength (path) < 0) SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); @@ -517,19 +511,19 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, char *filename_chars; size_t filename_len; - /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); */ + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); filename_chars = scm_to_locale_string (filename); filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); - full_filename = scm_sys_search_load_path (filename); + full_filename = scm_xyzzy_sys_search_load_path (filename); if (scm_is_false (full_filename)) SCM_MISC_ERROR ("Unable to find the file ~S in load path", scm_list_1 (filename)); - return scm_primitive_load (full_filename); + return scm_xyzzy_primitive_load (full_filename); } #undef FUNC_NAME @@ -563,8 +557,11 @@ init_build_info () void scm_init_load () { + fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); + scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); + //scm_loc_load_path = SCM_VARIABLE_LOC (scm_from_locale_string("/usr/share/guile/1.8/")); scm_loc_load_extensions = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", scm_list_2 (scm_from_locale_string (".scm"), @@ -579,13 +576,13 @@ scm_init_load () init_build_info (); /* cpp arguments: load.c -DHAVE_CONFIG_H -I.. -I.. -I.. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -Wmissing-prototypes */ - scm_c_define_gsubr (s_scm_primitive_load, 1, 0, 0, (SCM (*)()) scm_primitive_load); ; + scm_c_define_gsubr (s_scm_xyzzy_primitive_load, 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load); ; scm_c_define_gsubr (s_scm_sys_package_data_dir, 0, 0, 0, (SCM (*)()) scm_sys_package_data_dir); ; scm_c_define_gsubr (s_scm_sys_library_dir, 0, 0, 0, (SCM (*)()) scm_sys_library_dir); ; scm_c_define_gsubr (s_scm_sys_site_dir, 0, 0, 0, (SCM (*)()) scm_sys_site_dir); ; scm_c_define_gsubr (s_scm_parse_path, 1, 1, 0, (SCM (*)()) scm_parse_path); ; scm_c_define_gsubr (s_scm_xyzzy_search_path, 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); ; - scm_c_define_gsubr (s_scm_sys_search_load_path, 1, 0, 0, (SCM (*)()) scm_sys_search_load_path); ; + scm_c_define_gsubr (s_scm_xyzzy_sys_search_load_path, 1, 0, 0, (SCM (*)()) scm_xyzzy_sys_search_load_path); ; scm_c_define_gsubr (s_scm_xyzzy_primitive_load_path, 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load_path); ; /* #include "load.x" */ -- cgit From 8da224c86c228023d9ba0e5662af84cb9e00e72e Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sun, 28 Nov 2010 14:45:38 -0700 Subject: fix renaming. Overload program-lpoad, succeed till we get a scm_shell() :-) --- gr-run-waveform/xyzzy-load.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 07e3de78c..4c57251a2 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -79,7 +79,7 @@ static SCM *scm_loc_load_hook; static SCM the_reader = SCM_BOOL_F; static size_t the_reader_fluid_num = 0; -SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, +SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, (SCM filename), "Load the file named @var{filename} and evaluate its contents in\n" "the top-level environment. The load paths are not searched;\n" @@ -88,7 +88,7 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "primitive-load", 1, 0, 0, "@code{%load-hook} is defined, it should be bound to a procedure\n" "that will be called before any code is loaded. See the\n" "documentation for @code{%load-hook} later in this section.") -#define FUNC_NAME s_scm_xyzzy_primitive_load +#define FUNC_NAME s_scm_primitive_load { SCM hook = *scm_loc_load_hook; SCM_VALIDATE_STRING (1, filename); @@ -143,7 +143,7 @@ SCM scm_c_primitive_load (const char *filename) { fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); - return scm_xyzzy_primitive_load (scm_from_locale_string (filename)); + return scm_primitive_load (scm_from_locale_string (filename)); } @@ -361,6 +361,12 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, if (filename_len >= 1 && filename_chars[0] == '/') #endif { + /* Look in the fake filesystem for this file. If we find it, we prepend a + magic number to the front so we can identify these special files later + on when trying to read from them. */ + if (xyzzy_file_exists(filename_chars)) { + filename = scm_from_locale_string (filename_chars); + } scm_dynwind_end (); return filename; } @@ -436,14 +442,6 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, /* If the file exists at all, we should return it. If the file is inaccessible, then that's an error. */ - /* Look in the fake filesystem for this file. If we find it, we prepend a - magic number to the front so we can identify these special files later - on when trying to read from them. */ - if (xyzzy_file_exists(buf.buf)) { - result = scm_from_locale_string (buf.buf); - goto end; - } - if (stat (buf.buf, &mode) == 0 && ! (mode.st_mode & S_IFDIR)) { @@ -472,7 +470,7 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, The file must be readable, and not a directory. If we find one, return its full filename; otherwise, return #f. If FILENAME is absolute, return it unchanged. */ -SCM_DEFINE (scm_xyzzy_sys_search_load_path, "%search-load-path", 1, 0, 0, +SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, (SCM filename), "Search @var{%load-path} for the file named @var{filename},\n" "which must be readable by the current user. If @var{filename}\n" @@ -481,7 +479,7 @@ SCM_DEFINE (scm_xyzzy_sys_search_load_path, "%search-load-path", 1, 0, 0, "@code{#f}. Filenames may have any of the optional extensions\n" "in the @code{%load-extensions} list; @code{%search-load-path}\n" "will try each extension automatically.") -#define FUNC_NAME s_scm_xyzzy_sys_search_load_path +#define FUNC_NAME s_scm_sys_search_load_path { SCM path = *scm_loc_load_path; SCM exts = *scm_loc_load_extensions; @@ -517,19 +515,20 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); - full_filename = scm_xyzzy_sys_search_load_path (filename); + full_filename = scm_sys_search_load_path (filename); if (scm_is_false (full_filename)) SCM_MISC_ERROR ("Unable to find the file ~S in load path", scm_list_1 (filename)); - return scm_xyzzy_primitive_load (full_filename); + return scm_primitive_load (full_filename); } #undef FUNC_NAME SCM scm_c_primitive_load_path (const char *filename) { + fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); return scm_xyzzy_primitive_load_path (scm_from_locale_string (filename)); } @@ -561,7 +560,6 @@ scm_init_load () scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); - //scm_loc_load_path = SCM_VARIABLE_LOC (scm_from_locale_string("/usr/share/guile/1.8/")); scm_loc_load_extensions = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", scm_list_2 (scm_from_locale_string (".scm"), @@ -575,17 +573,15 @@ scm_init_load () init_build_info (); - /* cpp arguments: load.c -DHAVE_CONFIG_H -I.. -I.. -I.. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -Wmissing-prototypes */ - scm_c_define_gsubr (s_scm_xyzzy_primitive_load, 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load); ; scm_c_define_gsubr (s_scm_sys_package_data_dir, 0, 0, 0, (SCM (*)()) scm_sys_package_data_dir); ; scm_c_define_gsubr (s_scm_sys_library_dir, 0, 0, 0, (SCM (*)()) scm_sys_library_dir); ; scm_c_define_gsubr (s_scm_sys_site_dir, 0, 0, 0, (SCM (*)()) scm_sys_site_dir); ; scm_c_define_gsubr (s_scm_parse_path, 1, 1, 0, (SCM (*)()) scm_parse_path); ; + scm_c_define_gsubr (s_scm_sys_search_load_path, 1, 0, 0, (SCM (*)()) scm_sys_search_load_path); ; + + scm_c_define_gsubr (s_scm_primitive_load, 1, 0, 0, (SCM (*)()) scm_primitive_load); ; scm_c_define_gsubr (s_scm_xyzzy_search_path, 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); ; - scm_c_define_gsubr (s_scm_xyzzy_sys_search_load_path, 1, 0, 0, (SCM (*)()) scm_xyzzy_sys_search_load_path); ; scm_c_define_gsubr (s_scm_xyzzy_primitive_load_path, 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load_path); ; - - /* #include "load.x" */ } /* -- cgit From d520aee52daa13855adaef224c9988b58e83126c Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sun, 28 Nov 2010 14:51:30 -0700 Subject: be less verbose --- gr-run-waveform/xyzzy-load.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 4c57251a2..504115d7b 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -95,7 +95,7 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, size_t len = strlen(scm_to_locale_string(filename)); char *ptr = scm_to_locale_string(filename); - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); + /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); */ if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", @@ -142,7 +142,6 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, SCM scm_c_primitive_load (const char *filename) { - fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); return scm_primitive_load (scm_from_locale_string (filename)); } @@ -229,7 +228,7 @@ scm_init_load_path () char *env; SCM path = SCM_EOL; - fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ #ifdef SCM_LIBRARY_DIR path = scm_list_3 (scm_from_locale_string (SCM_SITE_DIR), @@ -339,7 +338,7 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, size_t filename_len; SCM result = SCM_BOOL_F; - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); + /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); */ if (SCM_UNBNDP (extensions)) extensions = SCM_EOL; @@ -485,7 +484,7 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, SCM exts = *scm_loc_load_extensions; SCM_VALIDATE_STRING (1, filename); - fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ if (scm_ilength (path) < 0) SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); @@ -509,7 +508,7 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, char *filename_chars; size_t filename_len; - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); + /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); */ filename_chars = scm_to_locale_string (filename); filename_len = strlen (filename_chars); @@ -528,7 +527,6 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, SCM scm_c_primitive_load_path (const char *filename) { - fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); return scm_xyzzy_primitive_load_path (scm_from_locale_string (filename)); } @@ -556,7 +554,7 @@ init_build_info () void scm_init_load () { - fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); + /* fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); */ scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); -- cgit From 98f42ab8cfe4fa9fd69c584aa48bdaf0215fbad0 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sun, 28 Nov 2010 17:46:43 -0700 Subject: reduce to the minimum required for one function --- gr-run-waveform/xyzzy-load.c | 330 +++---------------------------------------- 1 file changed, 16 insertions(+), 314 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 504115d7b..919b47702 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -68,181 +68,6 @@ // This is the magic number used when loading files static const char *MAGIC = "-XyZzY-"; - -/* Loading a file, given an absolute filename. */ - -/* Hook to run when we load a file, perhaps to announce the fact somewhere. - Applied to the full name of the file. */ -static SCM *scm_loc_load_hook; - -/* The current reader (a fluid). */ -static SCM the_reader = SCM_BOOL_F; -static size_t the_reader_fluid_num = 0; - -SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, - (SCM filename), - "Load the file named @var{filename} and evaluate its contents in\n" - "the top-level environment. The load paths are not searched;\n" - "@var{filename} must either be a full pathname or be a pathname\n" - "relative to the current directory. If the variable\n" - "@code{%load-hook} is defined, it should be bound to a procedure\n" - "that will be called before any code is loaded. See the\n" - "documentation for @code{%load-hook} later in this section.") -#define FUNC_NAME s_scm_primitive_load -{ - SCM hook = *scm_loc_load_hook; - SCM_VALIDATE_STRING (1, filename); - - size_t len = strlen(scm_to_locale_string(filename)); - char *ptr = scm_to_locale_string(filename); - /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); */ - - if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) - SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", - SCM_EOL); - - if (!scm_is_false (hook)) - scm_call_1 (hook, filename); - - { /* scope */ - SCM port; - if (strncmp(ptr, MAGIC, strlen(MAGIC)) == 0) { - fprintf(stderr, "FIXME: %s is a XYZZY file system file!\n", ptr+strlen(MAGIC)); - } else { - port = scm_open_file (filename, scm_from_locale_string ("r")); - } - scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE); - scm_i_dynwind_current_load_port (port); - - while (1) - { - SCM reader, form; - - /* Lookup and use the current reader to read the next - expression. */ - reader = SCM_FAST_FLUID_REF (the_reader_fluid_num); - if (reader == SCM_BOOL_F) - form = scm_read (port); - else - form = scm_call_1 (reader, port); - - if (SCM_EOF_OBJECT_P (form)) - break; - - scm_primitive_eval_x (form); - } - - scm_dynwind_end (); - scm_close_port (port); - } - return SCM_UNSPECIFIED; -} -#undef FUNC_NAME - -SCM -scm_c_primitive_load (const char *filename) -{ - return scm_primitive_load (scm_from_locale_string (filename)); -} - - -/* Builtin path to scheme library files. */ -#ifdef SCM_PKGDATA_DIR -SCM_DEFINE (scm_sys_package_data_dir, "%package-data-dir", 0, 0, 0, - (), - "Return the name of the directory where Scheme packages, modules and\n" - "libraries are kept. On most Unix systems, this will be\n" - "@samp{/usr/local/share/guile}.") -#define FUNC_NAME s_scm_sys_package_data_dir -{ - return scm_from_locale_string (SCM_PKGDATA_DIR); -} -#undef FUNC_NAME -#endif /* SCM_PKGDATA_DIR */ - -#ifdef SCM_LIBRARY_DIR -SCM_DEFINE (scm_sys_library_dir, "%library-dir", 0,0,0, - (), - "Return the directory where the Guile Scheme library files are installed.\n" - "E.g., may return \"/usr/share/guile/1.3.5\".") -#define FUNC_NAME s_scm_sys_library_dir -{ - return scm_from_locale_string (SCM_LIBRARY_DIR); -} -#undef FUNC_NAME -#endif /* SCM_LIBRARY_DIR */ - -#ifdef SCM_SITE_DIR -SCM_DEFINE (scm_sys_site_dir, "%site-dir", 0,0,0, - (), - "Return the directory where the Guile site files are installed.\n" - "E.g., may return \"/usr/share/guile/site\".") -#define FUNC_NAME s_scm_sys_site_dir -{ - return scm_from_locale_string (SCM_SITE_DIR); -} -#undef FUNC_NAME -#endif /* SCM_SITE_DIR */ - - - - -/* Initializing the load path, and searching it. */ - -/* List of names of directories we search for files to load. */ -static SCM *scm_loc_load_path; - -/* List of extensions we try adding to the filenames. */ -static SCM *scm_loc_load_extensions; - - -SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0, - (SCM path, SCM tail), - "Parse @var{path}, which is expected to be a colon-separated\n" - "string, into a list and return the resulting list with\n" - "@var{tail} appended. If @var{path} is @code{#f}, @var{tail}\n" - "is returned.") -#define FUNC_NAME s_scm_parse_path -{ -#ifdef __MINGW32__ - SCM sep = SCM_MAKE_CHAR (';'); -#else - SCM sep = SCM_MAKE_CHAR (':'); -#endif - - if (SCM_UNBNDP (tail)) - tail = SCM_EOL; - return (scm_is_false (path) - ? tail - : scm_append_x (scm_list_2 (scm_string_split (path, sep), tail))); -} -#undef FUNC_NAME - - -/* Initialize the global variable %load-path, given the value of the - SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the - GUILE_LOAD_PATH environment variable. */ -void -scm_init_load_path () -{ - char *env; - SCM path = SCM_EOL; - - /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ - -#ifdef SCM_LIBRARY_DIR - path = scm_list_3 (scm_from_locale_string (SCM_SITE_DIR), - scm_from_locale_string (SCM_LIBRARY_DIR), - scm_from_locale_string (SCM_PKGDATA_DIR)); -#endif /* SCM_LIBRARY_DIR */ - - env = getenv ("GUILE_LOAD_PATH"); - if (env) - path = scm_parse_path (scm_from_locale_string (env), path); - - *scm_loc_load_path = path; -} - SCM scm_listofnullstr; /* Utility functions for assembling C strings in a buffer. @@ -315,14 +140,13 @@ stringbuf_cat (struct stringbuf *buf, char *str) } } - /* Search PATH for a directory containing a file named FILENAME. The file must be readable, and not a directory. If we find one, return its full filename; otherwise, return #f. If FILENAME is absolute, return it unchanged. If given, EXTENSIONS is a list of strings; for each directory in PATH, we search for FILENAME concatenated with each EXTENSION. */ -SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, +SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, (SCM path, SCM filename, SCM extensions), "Search @var{path} for a directory containing a file named\n" "@var{filename}. The file must be readable, and not a directory.\n" @@ -338,7 +162,7 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, size_t filename_len; SCM result = SCM_BOOL_F; - /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); */ + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); if (SCM_UNBNDP (extensions)) extensions = SCM_EOL; @@ -360,12 +184,6 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, if (filename_len >= 1 && filename_chars[0] == '/') #endif { - /* Look in the fake filesystem for this file. If we find it, we prepend a - magic number to the front so we can identify these special files later - on when trying to read from them. */ - if (xyzzy_file_exists(filename_chars)) { - filename = scm_from_locale_string (filename_chars); - } scm_dynwind_end (); return filename; } @@ -441,12 +259,20 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, /* If the file exists at all, we should return it. If the file is inaccessible, then that's an error. */ - if (stat (buf.buf, &mode) == 0 - && ! (mode.st_mode & S_IFDIR)) - { - result = scm_from_locale_string (buf.buf); - goto end; - } + + /* Look in the fake filesystem for this file. If we find it, we prepend a + magic number to the front so we can identify these special files later + on when trying to read from them. */ + if (xyzzy_file_exists(filename_chars)) { + filename = scm_from_locale_string (filename_chars); + } else { + if (stat (buf.buf, &mode) == 0 + && ! (mode.st_mode & S_IFDIR)) + { + result = scm_from_locale_string (buf.buf); + goto end; + } + } } if (!SCM_NULL_OR_NIL_P (exts)) @@ -463,127 +289,3 @@ SCM_DEFINE (scm_xyzzy_search_path, "search-path", 2, 1, 0, return result; } #undef FUNC_NAME - - -/* Search %load-path for a directory containing a file named FILENAME. - The file must be readable, and not a directory. - If we find one, return its full filename; otherwise, return #f. - If FILENAME is absolute, return it unchanged. */ -SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, - (SCM filename), - "Search @var{%load-path} for the file named @var{filename},\n" - "which must be readable by the current user. If @var{filename}\n" - "is found in the list of paths to search or is an absolute\n" - "pathname, return its full pathname. Otherwise, return\n" - "@code{#f}. Filenames may have any of the optional extensions\n" - "in the @code{%load-extensions} list; @code{%search-load-path}\n" - "will try each extension automatically.") -#define FUNC_NAME s_scm_sys_search_load_path -{ - SCM path = *scm_loc_load_path; - SCM exts = *scm_loc_load_extensions; - SCM_VALIDATE_STRING (1, filename); - - /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ - - if (scm_ilength (path) < 0) - SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); - if (scm_ilength (exts) < 0) - SCM_MISC_ERROR ("%load-extension list is not a proper list", SCM_EOL); - - return scm_xyzzy_search_path (path, filename, exts); -} -#undef FUNC_NAME - - -SCM_DEFINE (scm_xyzzy_primitive_load_path, "primitive-load-path", 1, 0, 0, - (SCM filename), - "Search @var{%load-path} for the file named @var{filename} and\n" - "load it into the top-level environment. If @var{filename} is a\n" - "relative pathname and is not found in the list of search paths,\n" - "an error is signalled.") -#define FUNC_NAME s_scm_xyzzy_primitive_load_path -{ - SCM full_filename; - char *filename_chars; - size_t filename_len; - - /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, filename_chars); */ - - filename_chars = scm_to_locale_string (filename); - filename_len = strlen (filename_chars); - scm_dynwind_free (filename_chars); - - full_filename = scm_sys_search_load_path (filename); - - if (scm_is_false (full_filename)) - SCM_MISC_ERROR ("Unable to find the file ~S in load path", - scm_list_1 (filename)); - - return scm_primitive_load (full_filename); -} -#undef FUNC_NAME - -SCM -scm_c_primitive_load_path (const char *filename) -{ - return scm_xyzzy_primitive_load_path (scm_from_locale_string (filename)); -} - - -/* Information about the build environment. */ - -/* Initialize the scheme variable %guile-build-info, based on data - provided by the Makefile, via libpath.h. */ -static void -init_build_info () -{ - static struct { char *name; char *value; } info[] = SCM_BUILD_INFO; - SCM *loc = SCM_VARIABLE_LOC (scm_c_define ("%guile-build-info", SCM_EOL)); - unsigned long i; - - for (i = 0; i < (sizeof (info) / sizeof (info[0])); i++) - { - SCM key = scm_from_locale_symbol (info[i].name); - SCM val = scm_from_locale_string (info[i].value); - *loc = scm_acons (key, val, *loc); - } -} - - -void -scm_init_load () -{ - /* fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); */ - - scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); - scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); - scm_loc_load_extensions - = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", - scm_list_2 (scm_from_locale_string (".scm"), - scm_nullstr))); - scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_define ("%load-hook", SCM_BOOL_F)); - - the_reader = scm_make_fluid (); - the_reader_fluid_num = SCM_FLUID_NUM (the_reader); - SCM_FAST_FLUID_SET_X (the_reader_fluid_num, SCM_BOOL_F); - scm_c_define("current-reader", the_reader); - - init_build_info (); - - scm_c_define_gsubr (s_scm_sys_package_data_dir, 0, 0, 0, (SCM (*)()) scm_sys_package_data_dir); ; - scm_c_define_gsubr (s_scm_sys_library_dir, 0, 0, 0, (SCM (*)()) scm_sys_library_dir); ; - scm_c_define_gsubr (s_scm_sys_site_dir, 0, 0, 0, (SCM (*)()) scm_sys_site_dir); ; - scm_c_define_gsubr (s_scm_parse_path, 1, 1, 0, (SCM (*)()) scm_parse_path); ; - scm_c_define_gsubr (s_scm_sys_search_load_path, 1, 0, 0, (SCM (*)()) scm_sys_search_load_path); ; - - scm_c_define_gsubr (s_scm_primitive_load, 1, 0, 0, (SCM (*)()) scm_primitive_load); ; - scm_c_define_gsubr (s_scm_xyzzy_search_path, 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); ; - scm_c_define_gsubr (s_scm_xyzzy_primitive_load_path, 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load_path); ; -} - -/* - Local Variables: - c-file-style: "gnu" - End: -*/ -- cgit From 35a0021f1a77824d6b15d5efa04c28bdc1ed13a9 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sun, 28 Nov 2010 19:06:56 -0700 Subject: add an init function to initialize the scm_xyzzy_* fucntions --- gr-run-waveform/xyzzy-load.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 919b47702..695dba8f0 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -289,3 +289,10 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, return result; } #undef FUNC_NAME + +void +scm_xyzzy_init (void) +{ + scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); +} + -- cgit From 1d8fb42db7d9f49ba0cf8b92d05e9f57e6e2826a Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sun, 28 Nov 2010 19:09:46 -0800 Subject: fix for xyzzy-search-path --- gr-run-waveform/xyzzy-load.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 695dba8f0..119dcd8c7 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -259,20 +259,15 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, /* If the file exists at all, we should return it. If the file is inaccessible, then that's an error. */ - - /* Look in the fake filesystem for this file. If we find it, we prepend a - magic number to the front so we can identify these special files later - on when trying to read from them. */ - if (xyzzy_file_exists(filename_chars)) { - filename = scm_from_locale_string (filename_chars); - } else { - if (stat (buf.buf, &mode) == 0 - && ! (mode.st_mode & S_IFDIR)) - { - result = scm_from_locale_string (buf.buf); - goto end; - } - } + fprintf(stderr, "TRACE %s: %d: \"%s\"\n", __FUNCTION__, __LINE__, buf.buf); + + if (xyzzy_file_exists(buf.buf) + || (stat (buf.buf, &mode) == 0 + && ! (mode.st_mode & S_IFDIR))) + { + result = scm_from_locale_string (buf.buf); + goto end; + } } if (!SCM_NULL_OR_NIL_P (exts)) @@ -295,4 +290,3 @@ scm_xyzzy_init (void) { scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); } - -- cgit From ee712e58c0aad6672490659bfa2b440db002c93d Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sun, 28 Nov 2010 20:11:40 -0700 Subject: return the right path --- gr-run-waveform/xyzzy-load.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 695dba8f0..a29d95641 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -162,11 +162,11 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, size_t filename_len; SCM result = SCM_BOOL_F; - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(filename)); - if (SCM_UNBNDP (extensions)) extensions = SCM_EOL; + /* fprintf(stderr, "TRACE %s: %d %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(SCM_CAR(path))); */ + scm_dynwind_begin (0); filename_chars = scm_to_locale_string (filename); filename_len = strlen (filename_chars); @@ -222,7 +222,6 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, buf.buf_len = 512; buf.buf = scm_malloc (buf.buf_len); scm_dynwind_unwind_handler (stringbuf_free, &buf, SCM_F_WIND_EXPLICITLY); - /* Try every path element. */ @@ -258,13 +257,15 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, /* If the file exists at all, we should return it. If the file is inaccessible, then that's an error. */ - - - /* Look in the fake filesystem for this file. If we find it, we prepend a - magic number to the front so we can identify these special files later - on when trying to read from them. */ - if (xyzzy_file_exists(filename_chars)) { - filename = scm_from_locale_string (filename_chars); + const char *magic = "/-xyzzy-"; + if (strncmp(scm_to_locale_string(dir), magic, strlen(magic)) == 0) { + /* Look in the fake filesystem for this file. If we find it, we prepend a + magic number to the front so we can identify these special files later + on when trying to read from them. */ + if (xyzzy_file_exists(buf.buf)) { + result = scm_from_locale_string (buf.buf); + goto end; + } } else { if (stat (buf.buf, &mode) == 0 && ! (mode.st_mode & S_IFDIR)) -- cgit From 90f6ec6f292a0eca9ce8d63cb56f87ba7f1efae8 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sun, 28 Nov 2010 20:55:45 -0700 Subject: drop ifdef around exists test --- gr-run-waveform/xyzzy-load.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 810f5c51b..65e22c561 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -257,26 +257,6 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, /* If the file exists at all, we should return it. If the file is inaccessible, then that's an error. */ -#if 0 - const char *magic = "/-xyzzy-"; - if (strncmp(scm_to_locale_string(dir), magic, strlen(magic)) == 0) { - /* Look in the fake filesystem for this file. If we find it, we prepend a - magic number to the front so we can identify these special files later - on when trying to read from them. */ - if (xyzzy_file_exists(buf.buf)) { - result = scm_from_locale_string (buf.buf); - goto end; - } - } else { - if (stat (buf.buf, &mode) == 0 - && ! (mode.st_mode & S_IFDIR)) - { - result = scm_from_locale_string (buf.buf); - goto end; - } - } -#else - fprintf(stderr, "TRACE %s: %d: \"%s\"\n", __FUNCTION__, __LINE__, buf.buf); if (xyzzy_file_exists(buf.buf) @@ -286,7 +266,6 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, result = scm_from_locale_string (buf.buf); goto end; } -#endif } if (!SCM_NULL_OR_NIL_P (exts)) @@ -308,4 +287,5 @@ void scm_xyzzy_init (void) { scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); + /* scm_make_port_type("gnuradio", xyzzy_fill_input, xyzzy_write); */ } -- cgit From f3570d3fb25113d5f89bd9f258fa8cf996425b70 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 29 Nov 2010 07:57:02 -0700 Subject: move make port between files to reduce messy extern prototypes --- gr-run-waveform/xyzzy-load.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 65e22c561..1b3dd9f5c 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -283,9 +283,32 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_make_gnuradio, "make-gnuradio-port", 1, 0, 0, + (SCM port), + "Return a new port which reads from @var{port}") +#define FUNC_NAME s_scm_make_gnuradio +{ + SCM result; + unsigned long mode = 0; + + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(port)); + + SCM_VALIDATE_PORT (SCM_ARG1, port); + + if (scm_is_true (scm_output_port_p (port))) + mode |= SCM_WRTNG; + else if (scm_is_true (scm_input_port_p (port))) + mode |= SCM_RDNG; + + result = make_xyzzy (port, mode); + + return result; +} +#undef FUNC_NAME + void scm_xyzzy_init (void) { scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); - /* scm_make_port_type("gnuradio", xyzzy_fill_input, xyzzy_write); */ + scm_c_define_gsubr ("make-gnuradio-port", 1, 0, 0, (SCM (*)()) scm_make_gnuradio); } -- cgit From aa0e03921168c1cc03cd7f401edf7a7d659a40a4 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 29 Nov 2010 09:42:18 -0700 Subject: use a string port for the file contents. --- gr-run-waveform/xyzzy-load.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 1b3dd9f5c..cf3a240a5 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -288,21 +288,7 @@ SCM_DEFINE (scm_make_gnuradio, "make-gnuradio-port", 1, 0, 0, "Return a new port which reads from @var{port}") #define FUNC_NAME s_scm_make_gnuradio { - SCM result; - unsigned long mode = 0; - - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(port)); - - SCM_VALIDATE_PORT (SCM_ARG1, port); - - if (scm_is_true (scm_output_port_p (port))) - mode |= SCM_WRTNG; - else if (scm_is_true (scm_input_port_p (port))) - mode |= SCM_RDNG; - - result = make_xyzzy (port, mode); - - return result; + return make_xyzzy (port); } #undef FUNC_NAME @@ -311,4 +297,6 @@ scm_xyzzy_init (void) { scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); scm_c_define_gsubr ("make-gnuradio-port", 1, 0, 0, (SCM (*)()) scm_make_gnuradio); + + xyzzy_make_read_only_port("ice-9/boot-9.scm"); } -- cgit From 75c52385ecc1ca66caa2986cffe9105f9532895f Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 29 Nov 2010 10:02:58 -0700 Subject: drop the rest of the crufty old ports code, string ports are great! --- gr-run-waveform/xyzzy-load.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index cf3a240a5..a8ce2812c 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -297,6 +297,4 @@ scm_xyzzy_init (void) { scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); scm_c_define_gsubr ("make-gnuradio-port", 1, 0, 0, (SCM (*)()) scm_make_gnuradio); - - xyzzy_make_read_only_port("ice-9/boot-9.scm"); } -- cgit From 8c37ad1bd2811623e803aafc566ad7029a5ce744 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 29 Nov 2010 11:41:07 -0700 Subject: be less verbose --- gr-run-waveform/xyzzy-load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index a8ce2812c..3c671e91d 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -257,7 +257,7 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, /* If the file exists at all, we should return it. If the file is inaccessible, then that's an error. */ - fprintf(stderr, "TRACE %s: %d: \"%s\"\n", __FUNCTION__, __LINE__, buf.buf); + /* fprintf(stderr, "TRACE %s: %d: \"%s\"\n", __FUNCTION__, __LINE__, buf.buf); */ if (xyzzy_file_exists(buf.buf) || (stat (buf.buf, &mode) == 0 -- cgit From c41980f614ad97d84358aa7bbcd674786db0b13c Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 29 Nov 2010 16:39:34 -0700 Subject: add xyzzy-primitive-load and minimal test case --- gr-run-waveform/xyzzy-load.c | 100 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 3c671e91d..a05a7ddd0 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -69,6 +69,13 @@ static const char *MAGIC = "-XyZzY-"; SCM scm_listofnullstr; +static SCM *scm_loc_load_hook; +static SCM *scm_loc_load_path; +static SCM *scm_loc_load_extensions; + +/* The current reader (a fluid). */ +static SCM the_reader = SCM_BOOL_F; +static size_t the_reader_fluid_num = 0; /* Utility functions for assembling C strings in a buffer. */ @@ -283,6 +290,69 @@ SCM_DEFINE (scm_xyzzy_search_path, "xyyzy-search-path", 2, 1, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_xyzzy_primitive_load, "xyzzy-primitive-load", 1, 0, 0, + (SCM filename), + "Load the file named @var{filename} and evaluate its contents in\n" + "the top-level environment. The load paths are not searched;\n" + "@var{filename} must either be a full pathname or be a pathname\n" + "relative to the current directory. If the variable\n" + "@code{%load-hook} is defined, it should be bound to a procedure\n" + "that will be called before any code is loaded. See the\n" + "documentation for @code{%load-hook} later in this section.") +#define FUNC_NAME s_scm_xyzzy_primitive_load +{ + SCM hook = *scm_loc_load_hook; + SCM_VALIDATE_STRING (1, filename); + + size_t len = strlen(scm_to_locale_string(filename)); + char *ptr = scm_to_locale_string(filename); + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); + + if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) + SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", + SCM_EOL); + + if (!scm_is_false (hook)) + scm_call_1 (hook, filename); + + { /* scope */ + SCM port; + const char *magic = "/-xyzzy-"; + if (strncmp(ptr, magic, strlen(magic)) == 0) { + fprintf(stderr, "TRACE: file %s is a XYZZY file system file!\n", + ptr+strlen(magic)); + port = make_xyzzy(filename); + } else { + port = scm_open_file (filename, scm_from_locale_string ("r")); + } + scm_dynwind_begin (SCM_F_DYNWIND_REWINDABLE); + scm_i_dynwind_current_load_port (port); + + while (1) + { + SCM reader, form; + + /* Lookup and use the current reader to read the next + expression. */ + reader = SCM_FAST_FLUID_REF (the_reader_fluid_num); + if (reader == SCM_BOOL_F) + form = scm_read (port); + else + form = scm_call_1 (reader, port); + + if (SCM_EOF_OBJECT_P (form)) + break; + + scm_primitive_eval_x (form); + } + + scm_dynwind_end (); + scm_close_port (port); + } + return SCM_UNSPECIFIED; +} +#undef FUNC_NAME + SCM_DEFINE (scm_make_gnuradio, "make-gnuradio-port", 1, 0, 0, (SCM port), "Return a new port which reads from @var{port}") @@ -295,6 +365,32 @@ SCM_DEFINE (scm_make_gnuradio, "make-gnuradio-port", 1, 0, 0, void scm_xyzzy_init (void) { - scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); - scm_c_define_gsubr ("make-gnuradio-port", 1, 0, 0, (SCM (*)()) scm_make_gnuradio); + SCM path = SCM_EOL; + char *env = getenv ("GUILE_LOAD_PATH"); + fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); + if (env) { + path = scm_parse_path (scm_from_locale_string (env), path); + } + +#if 0 + scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); + scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); + scm_loc_load_extensions + = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", + scm_list_2 (scm_from_locale_string (".scm"), + scm_nullstr))); +#endif + scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_define ("%load-hook", SCM_BOOL_F)); + + /* initialize the current reader, which is needed by primitive-load */ + the_reader = scm_make_fluid (); + the_reader_fluid_num = SCM_FLUID_NUM (the_reader); + SCM_FAST_FLUID_SET_X (the_reader_fluid_num, SCM_BOOL_F); + scm_c_define("current-reader", the_reader); + + /* initialize our functions in the scheme VM */ + scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); + scm_c_define_gsubr ("make-gnuradio-port", 1, 0, 0, (SCM (*)()) scm_make_gnuradio); + scm_c_define_gsubr ("xyzzy-primitive-load", 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load); } + -- cgit From 99f4366b48d254051f68b10b2d43b83cc9fb2143 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 29 Nov 2010 17:42:11 -0700 Subject: add xyzzy-primitive-load and xyzzy-primitive-load-path along with a minimal test case --- gr-run-waveform/xyzzy-load.c | 72 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 7 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index a05a7ddd0..ae0712494 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -353,6 +353,64 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "xyzzy-primitive-load", 1, 0, 0, } #undef FUNC_NAME +/* Search %load-path for a directory containing a file named FILENAME. + The file must be readable, and not a directory. + If we find one, return its full filename; otherwise, return #f. + If FILENAME is absolute, return it unchanged. */ +SCM_DEFINE (scm_xyzzy_sys_search_load_path, "%xyzzy-search-load-path", 1, 0, 0, + (SCM filename), + "Search @var{%load-path} for the file named @var{filename},\n" + "which must be readable by the current user. If @var{filename}\n" + "is found in the list of paths to search or is an absolute\n" + "pathname, return its full pathname. Otherwise, return\n" + "@code{#f}. Filenames may have any of the optional extensions\n" + "in the @code{%load-extensions} list; @code{%search-load-path}\n" + "will try each extension automatically.") +#define FUNC_NAME s_scm_xyzzy_sys_search_load_path +{ + SCM path = SCM_EOL; //scm_c_lookup("%load-path"); + SCM exts = *scm_loc_load_extensions; + SCM_VALIDATE_STRING (1, filename); + + fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + + if (scm_ilength (path) < 0) + SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); + if (scm_ilength (exts) < 0) + SCM_MISC_ERROR ("%load-extension list is not a proper list", SCM_EOL); + + return scm_xyzzy_search_path (path, filename, exts); +} +#undef FUNC_NAME + +SCM_DEFINE (scm_xyzzy_primitive_load_path, "xyzzy-primitive-load-path", 1, 0, 0, + (SCM filename), + "Search @var{%load-path} for the file named @var{filename} and\n" + "load it into the top-level environment. If @var{filename} is a\n" + "relative pathname and is not found in the list of search paths,\n" + "an error is signalled.") +#define FUNC_NAME s_scm_xyzzy_primitive_load_path +{ + SCM full_filename; + char *filename_chars; + size_t filename_len; + + filename_chars = scm_to_locale_string (filename); + filename_len = strlen (filename_chars); + scm_dynwind_free (filename_chars); + + full_filename = scm_xyzzy_sys_search_load_path (filename); + + fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(full_filename)); + + if (scm_is_false (full_filename)) + SCM_MISC_ERROR ("Unable to find the file ~S in load path", + scm_list_1 (filename)); + + return scm_xyzzy_primitive_load (full_filename); +} +#undef FUNC_NAME + SCM_DEFINE (scm_make_gnuradio, "make-gnuradio-port", 1, 0, 0, (SCM port), "Return a new port which reads from @var{port}") @@ -371,15 +429,12 @@ scm_xyzzy_init (void) if (env) { path = scm_parse_path (scm_from_locale_string (env), path); } - -#if 0 - scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); - scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); - scm_loc_load_extensions - = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", + + scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); + scm_loc_load_extensions = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", scm_list_2 (scm_from_locale_string (".scm"), scm_nullstr))); -#endif + scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_define ("%load-hook", SCM_BOOL_F)); /* initialize the current reader, which is needed by primitive-load */ @@ -392,5 +447,8 @@ scm_xyzzy_init (void) scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); scm_c_define_gsubr ("make-gnuradio-port", 1, 0, 0, (SCM (*)()) scm_make_gnuradio); scm_c_define_gsubr ("xyzzy-primitive-load", 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load); + + scm_c_define_gsubr ("xyzzy-search-load-path", 1, 0, 0, (SCM (*)()) scm_xyzzy_sys_search_load_path); + scm_c_define_gsubr ("xyzzy-primitive-load-path", 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load_path); } -- cgit From b36c97ef1ea06ffc014f08286047ad71d4193ad3 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 29 Nov 2010 18:02:37 -0700 Subject: be less verbose --- gr-run-waveform/xyzzy-load.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index ae0712494..85b94ceee 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -306,7 +306,7 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "xyzzy-primitive-load", 1, 0, 0, size_t len = strlen(scm_to_locale_string(filename)); char *ptr = scm_to_locale_string(filename); - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); + /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); */ if (scm_is_true (hook) && scm_is_false (scm_procedure_p (hook))) SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", @@ -368,11 +368,12 @@ SCM_DEFINE (scm_xyzzy_sys_search_load_path, "%xyzzy-search-load-path", 1, 0, 0, "will try each extension automatically.") #define FUNC_NAME s_scm_xyzzy_sys_search_load_path { - SCM path = SCM_EOL; //scm_c_lookup("%load-path"); + // SCM path = scm_list_4("/usr/share/guile/1.8/", "/usr/share/guile/site", "/usr/share/guile/1.8", "/usr/share/guile"); //scm_c_lookup("%load-path")); + SCM path = SCM_EOL; SCM exts = *scm_loc_load_extensions; SCM_VALIDATE_STRING (1, filename); - fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); + /* fprintf(stderr, "TRACE %s: %d:\n", __FUNCTION__, __LINE__); */ if (scm_ilength (path) < 0) SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); @@ -401,7 +402,7 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "xyzzy-primitive-load-path", 1, 0, 0, full_filename = scm_xyzzy_sys_search_load_path (filename); - fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(full_filename)); + /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, scm_to_locale_string(full_filename)); */ if (scm_is_false (full_filename)) SCM_MISC_ERROR ("Unable to find the file ~S in load path", @@ -425,7 +426,7 @@ scm_xyzzy_init (void) { SCM path = SCM_EOL; char *env = getenv ("GUILE_LOAD_PATH"); - fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); + /* fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); */ if (env) { path = scm_parse_path (scm_from_locale_string (env), path); } -- cgit From 329c5da374781e5cd2e93e89de12bdf7fb71f979 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 29 Nov 2010 18:18:18 -0700 Subject: get the current value of %load-path --- gr-run-waveform/xyzzy-load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 85b94ceee..35a40ae3b 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -368,8 +368,8 @@ SCM_DEFINE (scm_xyzzy_sys_search_load_path, "%xyzzy-search-load-path", 1, 0, 0, "will try each extension automatically.") #define FUNC_NAME s_scm_xyzzy_sys_search_load_path { - // SCM path = scm_list_4("/usr/share/guile/1.8/", "/usr/share/guile/site", "/usr/share/guile/1.8", "/usr/share/guile"); //scm_c_lookup("%load-path")); - SCM path = SCM_EOL; + SCM loadpath = scm_c_lookup("%load-path"); + SCM path = scm_variable_ref(loadpath); SCM exts = *scm_loc_load_extensions; SCM_VALIDATE_STRING (1, filename); -- cgit From 09dc1cd6928d1c32cf06509a8b81202e11bcf3a4 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Thu, 2 Dec 2010 14:18:41 -0800 Subject: Update copyright dates --- gr-run-waveform/xyzzy-load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 35a40ae3b..145d53aee 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -1,9 +1,9 @@ -/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998,1999,2000,2001,2004,2006,2010 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From f1d2556215b72104bdfae2d389e1fdd6ef01690c Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 3 Dec 2010 12:10:57 -0800 Subject: Modify scm_xyzzy_init so that it looks up the system values of variables. --- gr-run-waveform/xyzzy-load.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 145d53aee..9051883db 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -68,14 +68,15 @@ // This is the magic number used when loading files static const char *MAGIC = "-XyZzY-"; -SCM scm_listofnullstr; +static SCM scm_listofnullstr; + static SCM *scm_loc_load_hook; static SCM *scm_loc_load_path; static SCM *scm_loc_load_extensions; /* The current reader (a fluid). */ -static SCM the_reader = SCM_BOOL_F; -static size_t the_reader_fluid_num = 0; +static SCM *scm_loc_current_reader; + /* Utility functions for assembling C strings in a buffer. */ @@ -332,9 +333,8 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "xyzzy-primitive-load", 1, 0, 0, { SCM reader, form; - /* Lookup and use the current reader to read the next - expression. */ - reader = SCM_FAST_FLUID_REF (the_reader_fluid_num); + /* Lookup and use the current reader to read the next expression. */ + reader = scm_fluid_ref(*scm_loc_current_reader); if (reader == SCM_BOOL_F) form = scm_read (port); else @@ -424,25 +424,10 @@ SCM_DEFINE (scm_make_gnuradio, "make-gnuradio-port", 1, 0, 0, void scm_xyzzy_init (void) { - SCM path = SCM_EOL; - char *env = getenv ("GUILE_LOAD_PATH"); - /* fprintf(stderr, "TRACE %s: %d\n", __FUNCTION__, __LINE__); */ - if (env) { - path = scm_parse_path (scm_from_locale_string (env), path); - } - scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); - scm_loc_load_extensions = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", - scm_list_2 (scm_from_locale_string (".scm"), - scm_nullstr))); - - scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_define ("%load-hook", SCM_BOOL_F)); - - /* initialize the current reader, which is needed by primitive-load */ - the_reader = scm_make_fluid (); - the_reader_fluid_num = SCM_FLUID_NUM (the_reader); - SCM_FAST_FLUID_SET_X (the_reader_fluid_num, SCM_BOOL_F); - scm_c_define("current-reader", the_reader); + scm_loc_load_extensions = SCM_VARIABLE_LOC(scm_c_lookup("%load-extensions")); + scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_lookup("%load-hook")); + scm_loc_current_reader = SCM_VARIABLE_LOC (scm_c_lookup("current-reader")); /* initialize our functions in the scheme VM */ scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); -- cgit From 331a74a4d9f0f983c6892ca5d01e8ef4f5308e76 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 3 Dec 2010 13:14:15 -0800 Subject: Make xyzzy_open_file work. (And a bit of renaming.) xyzzy_open_file (nee make_xyzzy) was not stripping off the magic prefix before searching, and was thus always creating a new entry in the map and returning a "" string. --- gr-run-waveform/xyzzy-load.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index 9051883db..cc0c3962c 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -305,7 +305,6 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "xyzzy-primitive-load", 1, 0, 0, SCM hook = *scm_loc_load_hook; SCM_VALIDATE_STRING (1, filename); - size_t len = strlen(scm_to_locale_string(filename)); char *ptr = scm_to_locale_string(filename); /* fprintf(stderr, "TRACE %s: %d: %s\n", __FUNCTION__, __LINE__, ptr); */ @@ -318,11 +317,10 @@ SCM_DEFINE (scm_xyzzy_primitive_load, "xyzzy-primitive-load", 1, 0, 0, { /* scope */ SCM port; - const char *magic = "/-xyzzy-"; - if (strncmp(ptr, magic, strlen(magic)) == 0) { - fprintf(stderr, "TRACE: file %s is a XYZZY file system file!\n", - ptr+strlen(magic)); - port = make_xyzzy(filename); + + if (xyzzy_file_exists(ptr)){ + /* fprintf(stderr, "TRACE: file %s is a XYZZY file system file!\n", ptr); */ + port = xyzzy_open_file(filename); } else { port = scm_open_file (filename, scm_from_locale_string ("r")); } @@ -412,12 +410,12 @@ SCM_DEFINE (scm_xyzzy_primitive_load_path, "xyzzy-primitive-load-path", 1, 0, 0, } #undef FUNC_NAME -SCM_DEFINE (scm_make_gnuradio, "make-gnuradio-port", 1, 0, 0, - (SCM port), - "Return a new port which reads from @var{port}") -#define FUNC_NAME s_scm_make_gnuradio +SCM_DEFINE (scm_xyzzy_open_file, "xyzzy-open-file", 1, 0, 0, + (SCM filename), + "Return a new port which reads from @var{filename}") +#define FUNC_NAME s_scm_xyzzy_open_file { - return make_xyzzy (port); + return xyzzy_open_file (filename); } #undef FUNC_NAME @@ -431,10 +429,8 @@ scm_xyzzy_init (void) /* initialize our functions in the scheme VM */ scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); - scm_c_define_gsubr ("make-gnuradio-port", 1, 0, 0, (SCM (*)()) scm_make_gnuradio); + scm_c_define_gsubr ("xyzzy-open-file", 1, 0, 0, (SCM (*)()) scm_xyzzy_open_file); scm_c_define_gsubr ("xyzzy-primitive-load", 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load); - scm_c_define_gsubr ("xyzzy-search-load-path", 1, 0, 0, (SCM (*)()) scm_xyzzy_sys_search_load_path); scm_c_define_gsubr ("xyzzy-primitive-load-path", 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load_path); } - -- cgit From 378bace460ed556d4e1783c9585f9417e84385eb Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 3 Dec 2010 21:33:10 -0800 Subject: xyzzy-search-load-path -> %xyzzy-search-load-path --- gr-run-waveform/xyzzy-load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gr-run-waveform/xyzzy-load.c') diff --git a/gr-run-waveform/xyzzy-load.c b/gr-run-waveform/xyzzy-load.c index cc0c3962c..46b7376da 100644 --- a/gr-run-waveform/xyzzy-load.c +++ b/gr-run-waveform/xyzzy-load.c @@ -428,9 +428,9 @@ scm_xyzzy_init (void) scm_loc_current_reader = SCM_VARIABLE_LOC (scm_c_lookup("current-reader")); /* initialize our functions in the scheme VM */ - scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); scm_c_define_gsubr ("xyzzy-open-file", 1, 0, 0, (SCM (*)()) scm_xyzzy_open_file); scm_c_define_gsubr ("xyzzy-primitive-load", 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load); - scm_c_define_gsubr ("xyzzy-search-load-path", 1, 0, 0, (SCM (*)()) scm_xyzzy_sys_search_load_path); scm_c_define_gsubr ("xyzzy-primitive-load-path", 1, 0, 0, (SCM (*)()) scm_xyzzy_primitive_load_path); + scm_c_define_gsubr ("%xyzzy-search-load-path", 1, 0, 0, (SCM (*)()) scm_xyzzy_sys_search_load_path); + scm_c_define_gsubr ("xyzzy-search-path", 2, 1, 0, (SCM (*)()) scm_xyzzy_search_path); } -- cgit