mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +02:00
Restore signature of `scm_search_path ()' as found in 1.8.
The incompatibly was introduced by
22f4ee4882
("make primitive-load-path load
compiled files if available").
* doc/ref/api-options.texi (Build Config): Update `search-path'
documentation.
* libguile/load.c (scm_search_path): Change C prototype to expect only 3
arguments. Parse the rest argument accordingly. Update callers.
* libguile/load.h (scm_search_path): Update accordingly.
This commit is contained in:
parent
731dd0ce19
commit
88cbb42189
3 changed files with 54 additions and 12 deletions
|
@ -113,15 +113,21 @@ string, into a list and return the resulting list with
|
||||||
is returned.
|
is returned.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Scheme Procedure} search-path path filename [extensions]
|
@deffn {Scheme Procedure} search-path path filename [extensions [require-exts?]]
|
||||||
@deffnx {C Function} scm_search_path (path, filename, extensions)
|
@deffnx {C Function} scm_search_path (path, filename, rest)
|
||||||
Search @var{path} for a directory containing a file named
|
Search @var{path} for a directory containing a file named
|
||||||
@var{filename}. The file must be readable, and not a directory.
|
@var{filename}. The file must be readable, and not a directory.
|
||||||
If we find one, return its full filename; otherwise, return
|
If we find one, return its full filename; otherwise, return
|
||||||
@code{#f}. If @var{filename} is absolute, return it unchanged.
|
@code{#f}. If @var{filename} is absolute, return it unchanged.
|
||||||
If given, @var{extensions} is a list of strings; for each
|
If given, @var{extensions} is a list of strings; for each
|
||||||
directory in @var{path}, we search for @var{filename}
|
directory in @var{path}, we search for @var{filename}
|
||||||
concatenated with each @var{extension}.
|
concatenated with each @var{extension}. If @var{require-exts?}
|
||||||
|
is true, require that the returned file name have one of the
|
||||||
|
given extensions; if @var{require-exts?} is not given, it
|
||||||
|
defaults to @code{#f}.
|
||||||
|
|
||||||
|
For compatibility with Guile 1.8 and earlier, the C function takes only
|
||||||
|
three arguments
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@defvar %guile-build-info
|
@defvar %guile-build-info
|
||||||
|
|
|
@ -391,8 +391,8 @@ scm_c_string_has_an_ext (char *str, size_t len, SCM extensions)
|
||||||
If FILENAME is absolute, return it unchanged.
|
If FILENAME is absolute, return it unchanged.
|
||||||
If given, EXTENSIONS is a list of strings; for each directory
|
If given, EXTENSIONS is a list of strings; for each directory
|
||||||
in PATH, we search for FILENAME concatenated with each EXTENSION. */
|
in PATH, we search for FILENAME concatenated with each EXTENSION. */
|
||||||
SCM_DEFINE (scm_search_path, "search-path", 2, 2, 0,
|
SCM_DEFINE (scm_search_path, "search-path", 2, 0, 1,
|
||||||
(SCM path, SCM filename, SCM extensions, SCM require_exts),
|
(SCM path, SCM filename, SCM rest),
|
||||||
"Search @var{path} for a directory containing a file named\n"
|
"Search @var{path} for a directory containing a file named\n"
|
||||||
"@var{filename}. The file must be readable, and not a directory.\n"
|
"@var{filename}. The file must be readable, and not a directory.\n"
|
||||||
"If we find one, return its full filename; otherwise, return\n"
|
"If we find one, return its full filename; otherwise, return\n"
|
||||||
|
@ -405,11 +405,46 @@ SCM_DEFINE (scm_search_path, "search-path", 2, 2, 0,
|
||||||
struct stringbuf buf;
|
struct stringbuf buf;
|
||||||
char *filename_chars;
|
char *filename_chars;
|
||||||
size_t filename_len;
|
size_t filename_len;
|
||||||
|
SCM extensions, require_exts;
|
||||||
SCM result = SCM_BOOL_F;
|
SCM result = SCM_BOOL_F;
|
||||||
|
|
||||||
|
if (scm_is_null (rest))
|
||||||
|
{
|
||||||
|
/* Called either by Scheme code that didn't provide the optional
|
||||||
|
arguments, or C code that used the Guile 1.8 signature (2 required,
|
||||||
|
1 optional arg) and passed '() as the EXTENSIONS argument. */
|
||||||
|
extensions = SCM_EOL;
|
||||||
|
require_exts = SCM_UNDEFINED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (scm_is_null (SCM_CAR (rest)) || scm_is_pair (SCM_CAR (rest)))
|
||||||
|
{
|
||||||
|
/* Called by Scheme code written for 1.9. */
|
||||||
|
extensions = SCM_CAR (rest);
|
||||||
|
if (scm_is_null (SCM_CDR (rest)))
|
||||||
|
require_exts = SCM_UNDEFINED;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
require_exts = SCM_CADR (rest);
|
||||||
|
if (SCM_UNLIKELY (!scm_is_null (SCM_CDDR (rest))))
|
||||||
|
scm_wrong_num_args (scm_from_locale_string (FUNC_NAME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Called by C code that uses the 1.8 signature, i.e., which
|
||||||
|
expects the 3rd argument to be EXTENSIONS. */
|
||||||
|
extensions = rest;
|
||||||
|
require_exts = SCM_UNDEFINED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SCM_UNBNDP (extensions))
|
if (SCM_UNBNDP (extensions))
|
||||||
extensions = SCM_EOL;
|
extensions = SCM_EOL;
|
||||||
|
|
||||||
|
SCM_VALIDATE_LIST (3, extensions);
|
||||||
|
|
||||||
if (SCM_UNBNDP (require_exts))
|
if (SCM_UNBNDP (require_exts))
|
||||||
require_exts = SCM_BOOL_F;
|
require_exts = SCM_BOOL_F;
|
||||||
|
|
||||||
|
@ -565,7 +600,7 @@ SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0,
|
||||||
SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL);
|
SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL);
|
||||||
if (scm_ilength (exts) < 0)
|
if (scm_ilength (exts) < 0)
|
||||||
SCM_MISC_ERROR ("%load-extension list is not a proper list", SCM_EOL);
|
SCM_MISC_ERROR ("%load-extension list is not a proper list", SCM_EOL);
|
||||||
return scm_search_path (path, filename, exts, SCM_UNDEFINED);
|
return scm_search_path (path, filename, exts);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -726,11 +761,12 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
|
||||||
exception_on_not_found = SCM_BOOL_T;
|
exception_on_not_found = SCM_BOOL_T;
|
||||||
|
|
||||||
full_filename = scm_sys_search_load_path (filename);
|
full_filename = scm_sys_search_load_path (filename);
|
||||||
compiled_filename = scm_search_path (*scm_loc_load_compiled_path,
|
compiled_filename =
|
||||||
filename,
|
scm_search_path (*scm_loc_load_compiled_path,
|
||||||
*scm_loc_load_compiled_extensions,
|
filename,
|
||||||
SCM_BOOL_T);
|
scm_list_2 (*scm_loc_load_compiled_extensions,
|
||||||
|
SCM_BOOL_T));
|
||||||
|
|
||||||
if (scm_is_false (compiled_filename)
|
if (scm_is_false (compiled_filename)
|
||||||
&& scm_is_true (full_filename)
|
&& scm_is_true (full_filename)
|
||||||
&& scm_is_true (*scm_loc_compile_fallback_path)
|
&& scm_is_true (*scm_loc_compile_fallback_path)
|
||||||
|
|
|
@ -32,7 +32,7 @@ SCM_API SCM scm_c_primitive_load (const char *filename);
|
||||||
SCM_API SCM scm_sys_package_data_dir (void);
|
SCM_API SCM scm_sys_package_data_dir (void);
|
||||||
SCM_API SCM scm_sys_library_dir (void);
|
SCM_API SCM scm_sys_library_dir (void);
|
||||||
SCM_API SCM scm_sys_site_dir (void);
|
SCM_API SCM scm_sys_site_dir (void);
|
||||||
SCM_API SCM scm_search_path (SCM path, SCM filename, SCM exts, SCM require_exts);
|
SCM_API SCM scm_search_path (SCM path, SCM filename, SCM rest);
|
||||||
SCM_API SCM scm_sys_search_load_path (SCM filename);
|
SCM_API SCM scm_sys_search_load_path (SCM filename);
|
||||||
SCM_API SCM scm_primitive_load_path (SCM filename_and_exception_on_not_found);
|
SCM_API SCM scm_primitive_load_path (SCM filename_and_exception_on_not_found);
|
||||||
SCM_API SCM scm_c_primitive_load_path (const char *filename);
|
SCM_API SCM scm_c_primitive_load_path (const char *filename);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue