guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Windows file name separators


From: Ludovic Courtès
Subject: Re: Windows file name separators
Date: Wed, 02 Jul 2014 22:56:03 +0200
User-agent: Gnus/5.130009 (Ma Gnus v0.9) Emacs/24.3 (gnu/linux)

Eli Zaretskii <address@hidden> skribis:

>> From: address@hidden (Ludovic Courtès)
>> Cc: address@hidden
>> Date: Tue, 01 Jul 2014 17:38:04 +0200
>> 
>> Eli Zaretskii <address@hidden> skribis:
>> 
>> >> From: address@hidden (Ludovic Courtès)
>> >> Cc: address@hidden
>> >> Date: Tue, 01 Jul 2014 11:36:32 +0200
>> >> 
>> >> Eli Zaretskii <address@hidden> skribis:
>> >> 
>> >> > In Emacs, some of the file and directory names recorded during the
>> >> > build and startup come from argv[0] and from prefix-relative directory
>> >> > names computed by configure.  Is there something similar in Guile, and
>> >> > if so, where do I find that?
>> >> 
>> >> The default %load-path uses absolute directory names based on what
>> >> ./configure computed.
>> >
>> > Thanks.  Where do I find the code which does that?  I'd like to review
>> > it with the issue at hand in mind.
>> 
>> You can look at load.c, and in particular scm_init_load_path.
>
> OK, thanks for the pointer.

Looks good.

> I've reviewed the related code, and below is what I suggest to push.
> (This supersedes what I sent in
> http://lists.gnu.org/archive/html/guile-devel/2014-06/msg00066.html.)

Overall looks good.  Some comments:

> --- libguile/load.c~0 2014-02-28 23:01:27 +0200
> +++ libguile/load.c   2014-07-02 19:00:50 +0300
> @@ -277,6 +277,37 @@ SCM_DEFINE (scm_parse_path_with_ellipsis
>  }
>  #undef FUNC_NAME
>  
> +static char *
> +getenv_path (const char *name)

What about making it ‘canonicalize_file_name_separators’, and change
callers to do:

  thing = canonicalize_file_name_separators (getenv ("PATH"))

Also please add a “docstring” above the function.

[...]

> --- libguile/filesys.c~0      2014-02-28 23:01:27 +0200
> +++ libguile/filesys.c        2014-06-29 18:13:30 +0300
> @@ -1235,6 +1235,19 @@ SCM_DEFINE (scm_getcwd, "getcwd", 0, 0,
>        errno = save_errno;
>        SCM_SYSERROR;
>      }
> +#ifdef __MINGW32__
> +  if (rv)
> +    {
> +      char *p = wd;
> +
> +      while (*p)
> +     {
> +       if (*p == '\\')
> +         *p = '/';
> +       p++;
> +     }
> +    }
> +#endif

Maybe this could be replaced by an unconditional call to
canonicalize_file_name_separators?

In that case, that function actually needs to be called
scm_i_canonicalize_file_name_separators and declared SCM_INTERNAL.

> --- libguile/init.c~0 2014-02-28 23:01:27 +0200
> +++ libguile/init.c   2014-07-02 18:51:04 +0300
> @@ -310,6 +310,17 @@ scm_boot_guile (int argc, char ** argv,
>  {
>    void *res;
>    struct main_func_closure c;
> +#ifdef __MINGW32__
> +  /* Convert backslashes in argv[0] to forward slashes.  */
> +  char *p = argv[0];
> +
> +  while (*p)
> +    {
> +      if (*p == '\\')
> +     *p = '/';
> +      p++;
> +    }
> +#endif

Ditto.

Thanks,
Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]