guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.7-118-g7a179


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.7-118-g7a17979
Date: Sun, 24 Feb 2013 13:21:49 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=7a17979ea4ae769c60ca4ca291cca877701c08e1

The branch, stable-2.0 has been updated
       via  7a17979ea4ae769c60ca4ca291cca877701c08e1 (commit)
       via  c21939bc247e2e36a5d698c60ba4a03cd3bbaf38 (commit)
       via  4bab7f01be8a1ce321f1e30235e1077f1ea0804c (commit)
      from  65fa3923060dd66b166fd858bcd6f462f37ee8c0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7a17979ea4ae769c60ca4ca291cca877701c08e1
Author: Andy Wingo <address@hidden>
Date:   Sun Feb 24 14:15:06 2013 +0100

    cleanup to filesys.c's handling of file name separators
    
    * libguile/filesys.c (is_file_name_separator): New helper, as in
      load.c.
      (scm_dirname, scm_basename, scm_i_relativize_path): Use
      is_file_name_separator.

commit c21939bc247e2e36a5d698c60ba4a03cd3bbaf38
Author: Andy Wingo <address@hidden>
Date:   Sun Feb 24 14:07:13 2013 +0100

    simplify scm_stat on mingw
    
    * libguile/filesys.c (scm_stat): Don't munge the filename on MinGW;
      gnulib does that for us.

commit 4bab7f01be8a1ce321f1e30235e1077f1ea0804c
Author: Andy Wingo <address@hidden>
Date:   Sun Feb 24 13:48:02 2013 +0100

    load.c uses same logic as boot-9 for file names
    
    * libguile/load.c (is_file_name_separator, is_drive_letter):
      (is_absolute_file_name): New helpers, like the ones in boot-9.
      Perhaps we should just define them in C.
      (search_path, scm_try_auto_compile, canonical_suffix): Rewrite using
      the new helpers.

-----------------------------------------------------------------------

Summary of changes:
 libguile/filesys.c |   77 ++++++++++-------------------------
 libguile/load.c    |  112 +++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 102 insertions(+), 87 deletions(-)

diff --git a/libguile/filesys.c b/libguile/filesys.c
index 2c4168e..f7c83e0 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -460,6 +460,18 @@ static int fstat_Win32 (int fdes, struct stat *buf)
 }
 #endif /* __MINGW32__ */
 
+static int
+is_file_name_separator (SCM c)
+{
+  if (c == SCM_MAKE_CHAR ('/'))
+    return 1;
+#ifdef __MINGW32__
+  if (c == SCM_MAKE_CHAR ('\\'))
+    return 1;
+#endif
+  return 0;
+}
+
 SCM_DEFINE (scm_stat, "stat", 1, 1, 0, 
             (SCM object, SCM exception_on_error),
            "Return an object containing various information about the file\n"
@@ -541,12 +553,6 @@ SCM_DEFINE (scm_stat, "stat", 1, 1, 0,
   else if (scm_is_string (object))
     {
       char *file = scm_to_locale_string (object);
-#ifdef __MINGW32__
-      char *p;
-      p = file + strlen (file) - 1;
-      while (p > file && (*p == '/' || *p == '\\'))
-       *p-- = '\0';
-#endif
       SCM_SYSCALL (rv = stat_or_stat64 (file, &stat_temp));
       free (file);
     }
@@ -1467,32 +1473,17 @@ SCM_DEFINE (scm_dirname, "dirname", 1, 0, 0,
   len = scm_i_string_length (filename);
 
   i = len - 1;
-#ifdef __MINGW32__
-  while (i >= 0 && (scm_i_string_ref (filename, i) == '/'
-                   || scm_i_string_ref (filename, i) == '\\')) 
-    --i;
-  while (i >= 0 && (scm_i_string_ref (filename, i) != '/'
-                   && scm_i_string_ref (filename, i) != '\\')) 
-    --i;
-  while (i >= 0 && (scm_i_string_ref (filename, i) == '/'
-                   || scm_i_string_ref (filename, i) == '\\')) 
-    --i;
-#else
-  while (i >= 0 && scm_i_string_ref (filename, i) == '/') 
+
+  while (i >= 0 && is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-  while (i >= 0 && scm_i_string_ref (filename, i) != '/') 
+  while (i >= 0 && !is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-  while (i >= 0 && scm_i_string_ref (filename, i) == '/') 
+  while (i >= 0 && is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-#endif /* ndef __MINGW32__ */
+
   if (i < 0)
     {
-#ifdef __MINGW32__
-      if (len > 0 && (scm_i_string_ref (filename, 0) == '/'
-                     || scm_i_string_ref (filename, 0) == '\\'))
-#else
-      if (len > 0 && scm_i_string_ref (filename, 0) == '/')
-#endif /* ndef __MINGW32__ */
+      if (len > 0 && is_file_name_separator (scm_c_string_ref (filename, 0)))
        return scm_c_substring (filename, 0, 1);
       else
        return scm_dot_string;
@@ -1523,14 +1514,8 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
       j = scm_i_string_length (suffix) - 1;
     }
   i = len - 1;
-#ifdef __MINGW32__
-  while (i >= 0 && (scm_i_string_ref (filename, i) == '/'
-                   || scm_i_string_ref (filename, i) ==  '\\'))
+  while (i >= 0 && is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-#else
-  while (i >= 0 && scm_i_string_ref (filename, i) == '/')
-    --i;
-#endif /* ndef __MINGW32__ */
   end = i;
   while (i >= 0 && j >= 0 
         && (scm_i_string_ref (filename, i)
@@ -1541,22 +1526,11 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
     }
   if (j == -1)
     end = i;
-#ifdef __MINGW32__
-  while (i >= 0 && (scm_i_string_ref (filename, i) != '/'
-                   && scm_i_string_ref (filename, i) != '\\'))
+  while (i >= 0 && !is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-#else
-  while (i >= 0 && scm_i_string_ref (filename, i) != '/')
-    --i;
-#endif /* ndef __MINGW32__ */
   if (i == end)
     {
-#ifdef __MINGW32__
-      if (len > 0 && (scm_i_string_ref (filename, 0) ==  '/'
-                     || scm_i_string_ref (filename, 0) ==  '\\'))
-#else
-      if (len > 0 && scm_i_string_ref (filename, 0) == '/')
-#endif /* ndef __MINGW32__ */
+      if (len > 0 && is_file_name_separator (scm_c_string_ref (filename, 0)))
         return scm_c_substring (filename, 0, 1);
       else
        return scm_dot_string;
@@ -1623,14 +1597,7 @@ scm_i_relativize_path (SCM path, SCM in_path)
             will be delimited by single delimiters.  When DIR does not
             have a trailing delimiter, add one to the length to strip
             off the delimiter within SCANON.  */
-         if (
-#ifdef __MINGW32__
-             (scm_i_string_ref (dir, len - 1) != '/'
-              && scm_i_string_ref (dir, len - 1) != '\\')
-#else
-             scm_i_string_ref (dir, len - 1) != '/'
-#endif
-             )
+         if (!is_file_name_separator (scm_c_string_ref (dir, len - 1)))
            len++;
 
          if (scm_c_string_length (scanon) > len)
diff --git a/libguile/load.c b/libguile/load.c
index 84b6705..f2af6c8 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -447,6 +447,58 @@ scm_c_string_has_an_ext (char *str, size_t len, SCM 
extensions)
   return 0;
 }
 
+#ifdef __MINGW32__
+#define FILE_NAME_SEPARATOR_STRING "\\"
+#else
+#define FILE_NAME_SEPARATOR_STRING "/"
+#endif
+
+static int
+is_file_name_separator (SCM c)
+{
+  if (c == SCM_MAKE_CHAR ('/'))
+    return 1;
+#ifdef __MINGW32__
+  if (c == SCM_MAKE_CHAR ('\\'))
+    return 1;
+#endif
+  return 0;
+}
+
+static int
+is_drive_letter (SCM c)
+{
+#ifdef __MINGW32__
+  if (SCM_CHAR (c) >= 'a' && SCM_CHAR (c) <= 'z')
+    return 1;
+  else if (SCM_CHAR (c) >= 'A' && SCM_CHAR (c) <= 'Z')
+    return 1;
+#endif
+  return 0;
+}
+
+static int
+is_absolute_file_name (const char *filename_chars, size_t filename_len)
+{
+  if (filename_len >= 1
+      && is_file_name_separator (SCM_MAKE_CHAR (filename_chars[0]))
+#ifdef __MINGW32__
+      /* On Windows, one initial separator indicates a drive-relative
+         path.  Two separators indicate a Universal Naming Convention
+         (UNC) path.  UNC paths are always absolute.  */
+      && filename_len >= 2
+      && is_file_name_separator (SCM_MAKE_CHAR (filename_chars[1]))
+#endif
+      )
+    return 1;
+  if (filename_len >= 3
+      && is_drive_letter (SCM_MAKE_CHAR (filename_chars[0]))
+      && filename_chars[1] == ':'
+      && is_file_name_separator (SCM_MAKE_CHAR (filename_chars[2])))
+    return 1;
+  return 0;
+}
+
 /* 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 pathname; otherwise, return #f.
@@ -477,16 +529,7 @@ search_path (SCM path, SCM filename, SCM extensions, SCM 
require_exts,
   scm_dynwind_free (filename_chars);
 
   /* If FILENAME is absolute and is still valid, 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
+  if (is_absolute_file_name (filename_chars, filename_len))
     {
       if ((scm_is_false (require_exts) ||
            scm_c_string_has_an_ext (filename_chars, filename_len,
@@ -520,11 +563,7 @@ search_path (SCM path, SCM filename, SCM extensions, SCM 
require_exts,
            extensions = SCM_EOL;
            break;
          }
-#ifdef __MINGW32__
-       else if (*endp == '/' || *endp == '\\')
-#else
-       else if (*endp == '/')
-#endif
+       else if (is_file_name_separator (SCM_MAKE_CHAR (*endp)))
          /* This filename has no extension, so keep the current list
              of extensions.  */
          break;
@@ -553,12 +592,9 @@ search_path (SCM path, SCM filename, SCM extensions, SCM 
require_exts,
        
       /* 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, "/");
+      if (buf.ptr > buf.buf
+          && !is_file_name_separator (SCM_MAKE_CHAR (buf.ptr[-1])))
+       stringbuf_cat (&buf, FILE_NAME_SEPARATOR_STRING);
 
       stringbuf_cat (&buf, filename_chars);
       sans_ext_len = buf.ptr - buf.buf;
@@ -823,24 +859,36 @@ scm_try_auto_compile (SCM source)
                       NULL, NULL);
 }
 
-/* See also (system base compile):compiled-file-name. */
+/* The auto-compilation code will residualize a .go file in the cache
+   dir: by default, $HOME/.cache/guile/2.0/ccache/PATH.go.  This
+   function determines the PATH to use as a key into the compilation
+   cache.  See also (system base compile):compiled-file-name. */
 static SCM
 canonical_suffix (SCM fname)
 {
   SCM canon;
-  size_t len;
 
+  /* CANON should be absolute.  */
   canon = scm_canonicalize_path (fname);
-  len = scm_c_string_length (canon);
   
-  if (len > 1 && scm_is_eq (scm_c_string_ref (canon, 0), SCM_MAKE_CHAR ('/')))
-    return canon;
-  else if (len > 2 && scm_is_eq (scm_c_string_ref (canon, 1), SCM_MAKE_CHAR 
(':')))
-    return scm_string_append (scm_list_3 (scm_from_latin1_string ("/"),
-                                          scm_c_substring (canon, 0, 1),
-                                          scm_c_substring (canon, 2, len)));
-  else
-    return canon;
+#ifdef __MINGW32__
+  {
+    size_t len = scm_c_string_length (canon);
+
+    /* On Windows, an absolute file name that doesn't start with a
+       separator starts with a drive component.  Transform the drive
+       component to a file name element: c:\foo -> \c\foo. */
+    if (len >= 2
+        && is_absolute_file_name (canon)
+        && !is_file_name_separator (scm_c_string_ref (canon, 0)))
+      return scm_string_append
+        (scm_list_3 (scm_from_latin1_string (FILE_NAME_SEPARATOR_STRING),
+                     scm_c_substring (canon, 0, 1),
+                     scm_c_substring (canon, 2, len)));
+  }
+#endif
+
+  return canon;
 }
 
 SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,


hooks/post-receive
-- 
GNU Guile



reply via email to

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