summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--lib/findprog-lgpl.c20
-rw-r--r--lib/findprog.c26
-rw-r--r--modules/findprog-lgpl32
4 files changed, 87 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 26251f9b59..c8d71a4be1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2008-09-01 Bruno Haible <bruno@clisp.org>
+ New module 'findprog-lgpl'.
+ * modules/findprog-lgpl: New file.
+ * lib/findprog-lgpl.c: New file.
+ * lib/findprog.c: Compile nothing in findprog.c if findprog-lgpl.c is
+ also compiled. Consider the possibly defined symbol IN_FINDPROG_LGPL
+ to decide whether to use strdup or xstrdup, concatenated_filename or
+ xconcatenated_filename.
+
+2008-09-01 Bruno Haible <bruno@clisp.org>
+
Split module 'concat-filename' into 'concat-filename' (LGPL) and
'xconcat-filename' (GPL).
* modules/concat-filename (Depends-on): Add malloc-posix, remove xalloc.
diff --git a/lib/findprog-lgpl.c b/lib/findprog-lgpl.c
new file mode 100644
index 0000000000..50c7cc4123
--- /dev/null
+++ b/lib/findprog-lgpl.c
@@ -0,0 +1,20 @@
+/* Locating a program in PATH.
+ Copyright (C) 2001-2004, 2006-2008 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 2008.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#define IN_FINDPROG_LGPL 1
+
+#include "findprog.c"
diff --git a/lib/findprog.c b/lib/findprog.c
index 468b334eb9..b064245a3e 100644
--- a/lib/findprog.c
+++ b/lib/findprog.c
@@ -26,7 +26,12 @@
#include <string.h>
#include <unistd.h>
-#include "xalloc.h"
+/* Avoid collision between findprog.c and findprog-lgpl.c. */
+#if IN_FINDPROG_LGPL || ! GNULIB_FINDPROG_LGPL
+
+#if !IN_FINDPROG_LGPL
+# include "xalloc.h"
+#endif
#include "concat-filename.h"
@@ -56,7 +61,14 @@ find_in_path (const char *progname)
return progname;
/* Make a copy, to prepare for destructive modifications. */
+# if !IN_FINDPROG_LGPL
path = xstrdup (path);
+# else
+ path = strdup (path);
+ if (path == NULL)
+ /* Out of memory. */
+ return progname;
+# endif
for (path_rest = path; ; path_rest = cp + 1)
{
const char *dir;
@@ -75,7 +87,17 @@ find_in_path (const char *progname)
dir = ".";
/* Concatenate dir and progname. */
+# if !IN_FINDPROG_LGPL
progpathname = xconcatenated_filename (dir, progname, NULL);
+# else
+ progpathname = concatenated_filename (dir, progname, NULL);
+ if (progpathname == NULL)
+ {
+ /* Out of memory. */
+ free (path);
+ return progname;
+ }
+# endif
/* On systems which have the eaccess() system call, let's use it.
On other systems, let's hope that this program is not installed
@@ -112,3 +134,5 @@ find_in_path (const char *progname)
return progname;
#endif
}
+
+#endif
diff --git a/modules/findprog-lgpl b/modules/findprog-lgpl
new file mode 100644
index 0000000000..a4dc64bd19
--- /dev/null
+++ b/modules/findprog-lgpl
@@ -0,0 +1,32 @@
+Description:
+Locating a program in PATH (LGPLed version).
+
+Files:
+lib/findprog.h
+lib/findprog.c
+lib/findprog-lgpl.c
+m4/findprog.m4
+m4/eaccess.m4
+
+Depends-on:
+stdbool
+strdup
+concat-filename
+unistd
+
+configure.ac:
+gl_FINDPROG
+gl_MODULE_INDICATOR([findprog-lgpl])
+
+Makefile.am:
+lib_SOURCES += findprog.h findprog.c
+
+Include:
+"findprog.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
+