m4-commit
[Top][All Lists]
Advanced

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

Changes to m4/src/Attic/path.c,v [branch-1_4]


From: Eric Blake
Subject: Changes to m4/src/Attic/path.c,v [branch-1_4]
Date: Sun, 30 Jul 2006 03:18:14 +0000

CVSROOT:        /sources/m4
Module name:    m4
Branch:         branch-1_4
Changes by:     Eric Blake <ericb>      06/07/30 03:18:12

Index: src/path.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/path.c,v
retrieving revision 1.1.1.1.2.5
retrieving revision 1.1.1.1.2.6
diff -u -b -r1.1.1.1.2.5 -r1.1.1.1.2.6
--- src/path.c  10 Jul 2006 01:44:10 -0000      1.1.1.1.2.5
+++ src/path.c  30 Jul 2006 03:18:12 -0000      1.1.1.1.2.6
@@ -100,14 +100,22 @@
 #endif
 }
 
+/* Search for FILE, first in `.', then according to -I options.  If
+   successful, return the open file, and if RESULT is not NULL, set
+   *RESULT to a malloc'd string that represents the file found with
+   respect to the current working directory.  */
+
 FILE *
-path_search (const char *file)
+path_search (const char *file, const char **result)
 {
   FILE *fp;
   includes *incl;
   char *name;                  /* buffer for constructed name */
   int e;
 
+  if (result)
+    *result = NULL;
+
   /* Reject empty file.  */
   if (!*file)
     {
@@ -118,7 +126,11 @@
   /* Look in current working directory first.  */
   fp = fopen (file, "r");
   if (fp != NULL)
+    {
+      if (result)
+       *result = strdup (file);
     return fp;
+    }
 
   /* If file not found, and filename absolute, fail.  */
   if (*file == '/' || no_gnu_extensions)
@@ -142,7 +154,12 @@
        {
          if (debug_level & DEBUG_TRACE_PATH)
            DEBUG_MESSAGE2 ("path search for `%s' found `%s'", file, name);
-         break;
+         if (result)
+           *result = name;
+         else
+           free (name);
+         errno = e;
+         return fp;
        }
     }
   xfree (name);




reply via email to

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