From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Add parse-path-with-ellipsis, and use it for GUILE_LOAD_PATH et al Date: Wed, 28 Nov 2012 18:12:41 -0500 Message-ID: <87624pxqxi.fsf_-_@tines.lan> References: <87sj8o20v0.fsf@googlemail.com> <87liecucrz.fsf@delenn.home.rotty.xx.vu> <87k3tpkyeg.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1354144395 25727 80.91.229.3 (28 Nov 2012 23:13:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Nov 2012 23:13:15 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Nov 29 00:13:25 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tdqol-0006h2-Pf for guile-devel@m.gmane.org; Thu, 29 Nov 2012 00:13:24 +0100 Original-Received: from localhost ([::1]:46217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tdqoa-0007Cj-5c for guile-devel@m.gmane.org; Wed, 28 Nov 2012 18:13:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdqoW-0007Bt-AC for guile-devel@gnu.org; Wed, 28 Nov 2012 18:13:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdqoU-0003Yk-U4 for guile-devel@gnu.org; Wed, 28 Nov 2012 18:13:08 -0500 Original-Received: from world.peace.net ([96.39.62.75]:59332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdqoU-0003XZ-OE; Wed, 28 Nov 2012 18:13:06 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1TdqoC-0006Be-2j; Wed, 28 Nov 2012 18:12:48 -0500 In-Reply-To: <87k3tpkyeg.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 13 Nov 2012 22:04:23 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15270 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ludovic, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > I pretty much like Mark=E2=80=99s suggestion of using =E2=80=98...=E2=80= =99 as a special marker, > even though that=E2=80=99s a valid file name. Here's a patch to implement the "..." special marker. It would be good to have this in 2.0.7. What do you think? Mark --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-parse-path-with-ellipsis-and-use-it-for-GUILE_LO.patch Content-Description: [PATCH] Add parse-path-with-ellipsis, and use it for GUILE_LOAD_PATH et al >From 4a78f4a638334a5bd8eb08308891b541bbde9b1e Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Wed, 28 Nov 2012 18:01:35 -0500 Subject: [PATCH] Add parse-path-with-ellipsis, and use it for GUILE_LOAD_PATH et al. * libguile/load.c (scm_parse_path_with_ellipsis): New procedure. (scm_init_load_path): Use 'scm_parse_path_with_ellipsis' to handle GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH. * libguile/load.h (scm_parse_path_with_ellipsis): Add prototype. * doc/ref/api-evaluation.texi (Load Paths): Add docs. --- doc/ref/api-evaluation.texi | 9 +++++++++ libguile/load.c | 31 +++++++++++++++++++++++++++++-- libguile/load.h | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi index 37e41e1..6a442c7 100644 --- a/doc/ref/api-evaluation.texi +++ b/doc/ref/api-evaluation.texi @@ -943,6 +943,15 @@ a list and return the resulting list with @var{tail} appended. If @var{path} is @code{#f}, @var{tail} is returned. @end deffn +@deffn {Scheme Procedure} parse-path-with-ellipsis path base +@deffnx {C Function} scm_parse_path_with_ellipsis (path, base) +Parse @var{path}, which is expected to be a colon-separated string, into +a list and return the resulting list with @var{base} (a list) spliced in +place of the @code{...} path component, if present, or else @var{base} +is added to the end. If @var{path} is @code{#f}, @var{base} is +returned. +@end deffn + @deffn {Scheme Procedure} search-path path filename [extensions [require-exts?]] @deffnx {C Function} scm_search_path (path, filename, rest) Search @var{path} for a directory containing a file named diff --git a/libguile/load.c b/libguile/load.c index af2ca45..76bbd83 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -243,6 +243,33 @@ SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_parse_path_with_ellipsis, "parse-path-with-ellipsis", 2, 0, 0, + (SCM path, SCM base), + "Parse @var{path}, which is expected to be a colon-separated\n" + "string, into a list and return the resulting list with\n" + "@var{base} (a list) spliced in place of the @code{...} path\n" + "component, if present, or else @var{base} is added to the end.\n" + "If @var{path} is @code{#f}, @var{base} is returned.") +#define FUNC_NAME s_scm_parse_path_with_ellipsis +{ + SCM ellipsis = scm_from_latin1_string ("..."); + SCM lst = scm_parse_path (path, SCM_EOL); + SCM walk = lst; + SCM *prev = &lst; + + while (!scm_is_null (walk) && + scm_is_false (scm_equal_p (scm_car (walk), ellipsis))) + { + prev = SCM_CDRLOC (walk); + walk = *prev; + } + *prev = scm_is_null (walk) + ? base + : scm_append (scm_list_2 (base, scm_cdr (walk))); + return lst; +} +#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 @@ -316,11 +343,11 @@ scm_init_load_path () env = getenv ("GUILE_LOAD_PATH"); if (env) - path = scm_parse_path (scm_from_locale_string (env), path); + path = scm_parse_path_with_ellipsis (scm_from_locale_string (env), path); env = getenv ("GUILE_LOAD_COMPILED_PATH"); if (env) - cpath = scm_parse_path (scm_from_locale_string (env), cpath); + cpath = scm_parse_path_with_ellipsis (scm_from_locale_string (env), cpath); *scm_loc_load_path = path; *scm_loc_load_compiled_path = cpath; diff --git a/libguile/load.h b/libguile/load.h index 0bddac2..698bbaf 100644 --- a/libguile/load.h +++ b/libguile/load.h @@ -27,6 +27,7 @@ SCM_API SCM scm_parse_path (SCM path, SCM tail); +SCM_API SCM scm_parse_path_with_ellipsis (SCM path, SCM base); SCM_API SCM scm_primitive_load (SCM filename); SCM_API SCM scm_c_primitive_load (const char *filename); SCM_API SCM scm_sys_package_data_dir (void); -- 1.7.10.4 --=-=-=--