This patch adds a module 'findprog-lgpl'. The GPLed and the LGPLed variant of find_in_path have the same specification; therefore they can share the same function name. In a gnulib build where both are requested, we need to ensure the LGPLed variant is compiled and the GPLed variant is omitted. (Just like we did for the canonicalize_file_name function.)
For this reason, the naming of the modules is not 'findprog' vs. 'xfindprog', but 'findprog-lgpl' vs. 'findprog'. 2008-09-01 Bruno Haible <[EMAIL PROTECTED]> 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. ============================== modules/findprog-lgpl ========================= 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 =============================== lib/findprog-lgpl.c ========================== /* Locating a program in PATH. Copyright (C) 2001-2004, 2006-2008 Free Software Foundation, Inc. Written by Bruno Haible <[EMAIL PROTECTED]>, 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" ============================================================================== *** lib/findprog.c.orig 2008-09-02 02:04:33.000000000 +0200 --- lib/findprog.c 2008-09-02 01:57:09.000000000 +0200 *************** *** 26,32 **** #include <string.h> #include <unistd.h> ! #include "xalloc.h" #include "concat-filename.h" --- 26,37 ---- #include <string.h> #include <unistd.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,62 **** --- 61,74 ---- 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,81 **** --- 87,103 ---- 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,114 **** --- 134,138 ---- return progname; #endif } + + #endif