Mercurial > hg > octave-lyh > gnulib-hg
changeset 10391:f0a681493fa6
New module 'xconcat-filename', split off from module 'concat-filename'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 02 Sep 2008 01:34:21 +0200 |
parents | 247990850251 |
children | dd1c6e77ee94 |
files | ChangeLog NEWS lib/concat-filename.c lib/concat-filename.h lib/findprog.c lib/javacomp.c lib/javaexec.c lib/xconcat-filename.c modules/concat-filename modules/findprog modules/javacomp modules/javaexec modules/xconcat-filename |
diffstat | 13 files changed, 196 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +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. + (License): Change to LGPLv2+. + * modules/xconcat-filename: New file. + * lib/concat-filename.h (concatenated_filename): Change specification. + (xconcatenated_filename): New declaration. + * lib/concat-filename.c: Include errno.h, stdlib.h, not xalloc.h. + (concatenated_filename): Use malloc instead of xalloc. Handle out-of- + memory situations. + * lib/xconcat-filename.c: New file. + * NEWS: Mention the change. + * lib/findprog.c: Include concat-filename.h, not filename.h. + (find_in_path): Use xconcatenated_filename instead of + concatenated_filename. + * lib/javacomp.c: Include concat-filename.h, not filename.h. + (is_envjavac_gcj43_usable, is_envjavac_oldgcj_14_14_usable, + is_envjavac_oldgcj_14_13_usable, is_envjavac_nongcj_usable, + is_gcj_present, is_gcj43_usable, is_oldgcj_14_14_usable, + is_oldgcj_14_13_usable, is_javac_usable): Use xconcatenated_filename + instead of concatenated_filename. + * lib/javaexec.c: Include concat-filename.h, not filename.h. + (execute_java_class): Use xconcatenated_filename instead of + concatenated_filename. + * modules/findprog (Depends-on): Add xconcat-filename, remove filename. + * modules/javacomp (Depends-on): Likewise. + * modules/javaexec (Depends-on): Likewise. + 2008-09-01 Bruno Haible <bruno@clisp.org> Split module 'filename' into 'filename' and 'concat-filename'.
--- a/NEWS +++ b/NEWS @@ -7,9 +7,10 @@ Date Modules Changes 2008-09-01 filename The module does not define the function - concatenated_filename any more. To get this - function, use module 'concat-filename' and the - include file "concat-filename.h". + concatenated_filename any more. To get an + equivalent function, use function + xconcatenated_filename from module + 'xconcat-filename'. 2008-08-31 havelib On Solaris, when searching for 64-bit mode libraries the directory $prefix/lib is now ignored.
--- a/lib/concat-filename.c +++ b/lib/concat-filename.c @@ -21,15 +21,17 @@ /* Specification. */ #include "concat-filename.h" +#include <errno.h> +#include <stdlib.h> #include <string.h> #include "filename.h" -#include "xalloc.h" /* Concatenate a directory filename, a relative filename and an optional suffix. The directory may end with the directory separator. The second argument may not start with the directory separator (it is relative). - Return a freshly allocated filename. */ + Return a freshly allocated filename. Return NULL and set errno + upon memory allocation failure. */ char * concatenated_filename (const char *directory, const char *filename, const char *suffix) @@ -40,10 +42,11 @@ if (strcmp (directory, ".") == 0) { /* No need to prepend the directory. */ - result = XNMALLOC (strlen (filename) - + (suffix != NULL ? strlen (suffix) : 0) - + 1, - char); + result = (char *) malloc (strlen (filename) + + (suffix != NULL ? strlen (suffix) : 0) + + 1); + if (result == NULL) + return NULL; /* errno is set here */ p = result; } else @@ -52,11 +55,12 @@ int need_slash = (directory_len > FILE_SYSTEM_PREFIX_LEN (directory) && !ISSLASH (directory[directory_len - 1])); - result = XNMALLOC (directory_len + need_slash - + strlen (filename) - + (suffix != NULL ? strlen (suffix) : 0) - + 1, - char); + result = (char *) malloc (directory_len + need_slash + + strlen (filename) + + (suffix != NULL ? strlen (suffix) : 0) + + 1); + if (result == NULL) + return NULL; /* errno is set here */ memcpy (result, directory, directory_len); p = result + directory_len; if (need_slash)
--- a/lib/concat-filename.h +++ b/lib/concat-filename.h @@ -23,10 +23,16 @@ /* Concatenate a directory filename, a relative filename and an optional - suffix. Return a freshly allocated filename. */ + suffix. Return a freshly allocated filename. Return NULL and set errno + upon memory allocation failure. */ extern char *concatenated_filename (const char *directory, const char *filename, const char *suffix); +/* Concatenate a directory filename, a relative filename and an optional + suffix. Return a freshly allocated filename. */ +extern char *xconcatenated_filename (const char *directory, + const char *filename, const char *suffix); + #ifdef __cplusplus }
--- a/lib/findprog.c +++ b/lib/findprog.c @@ -1,5 +1,5 @@ /* Locating a program in PATH. - Copyright (C) 2001-2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2008 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -27,7 +27,7 @@ #include <unistd.h> #include "xalloc.h" -#include "filename.h" +#include "concat-filename.h" const char * @@ -75,7 +75,7 @@ dir = "."; /* Concatenate dir and progname. */ - progpathname = concatenated_filename (dir, progname, NULL); + progpathname = xconcatenated_filename (dir, progname, NULL); /* On systems which have the eaccess() system call, let's use it. On other systems, let's hope that this program is not installed @@ -88,7 +88,7 @@ { free (progpathname); - /* Add the "./" prefix for real, that concatenated_filename() + /* Add the "./" prefix for real, that xconcatenated_filename() optimized away. This avoids a second PATH search when the caller uses execlp/execvp. */ progpathname = XNMALLOC (2 + strlen (progname) + 1, char);
--- a/lib/javacomp.c +++ b/lib/javacomp.c @@ -41,7 +41,7 @@ #include "safe-read.h" #include "xalloc.h" #include "xmalloca.h" -#include "filename.h" +#include "concat-filename.h" #include "fwriteerror.h" #include "clean-temp.h" #include "error.h" @@ -741,7 +741,7 @@ return true; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.java", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL); if (write_temp_file (tmpdir, conftest_file_name, get_goodcode_snippet (source_version))) { @@ -751,7 +751,7 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.class", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -785,9 +785,9 @@ free (conftest_file_name); conftest_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.java", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.java", + NULL); if (write_temp_file (tmpdir, conftest_file_name, failcode)) { free (conftest_file_name); @@ -797,9 +797,9 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.class", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.class", + NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -890,7 +890,7 @@ return true; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.java", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL); if (write_temp_file (tmpdir, conftest_file_name, get_goodcode_snippet ("1.4"))) { @@ -900,7 +900,7 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.class", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -951,7 +951,7 @@ return true; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.java", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL); if (write_temp_file (tmpdir, conftest_file_name, get_goodcode_snippet ("1.3"))) { @@ -961,7 +961,7 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.class", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -994,8 +994,8 @@ if (javac_works && javac_noassert_works) { conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftestfail.java", - NULL); + xconcatenated_filename (tmpdir->dir_name, "conftestfail.java", + NULL); if (write_temp_file (tmpdir, conftest_file_name, get_failcode_snippet ("1.3"))) { @@ -1006,8 +1006,8 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftestfail.class", - NULL); + xconcatenated_filename (tmpdir->dir_name, "conftestfail.class", + NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1091,7 +1091,7 @@ return true; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.java", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL); if (write_temp_file (tmpdir, conftest_file_name, get_goodcode_snippet (source_version))) { @@ -1101,7 +1101,7 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.class", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1135,9 +1135,9 @@ free (conftest_file_name); conftest_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.java", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.java", + NULL); if (write_temp_file (tmpdir, conftest_file_name, failcode)) { free (conftest_file_name); @@ -1147,9 +1147,9 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.class", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.class", + NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1219,9 +1219,9 @@ free (conftest_file_name); conftest_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.java", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.java", + NULL); if (write_temp_file (tmpdir, conftest_file_name, failcode)) { @@ -1233,9 +1233,9 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.class", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.class", + NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1387,8 +1387,8 @@ char *conftest_file_name; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftestlib.java", - NULL); + xconcatenated_filename (tmpdir->dir_name, "conftestlib.java", + NULL); if (write_temp_file (tmpdir, conftest_file_name, "public class conftestlib {\n" " public static void main (String[] args) {\n" @@ -1401,9 +1401,9 @@ const char *java_sources[1]; compiled_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestlib.class", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestlib.class", + NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1531,7 +1531,7 @@ return true; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.java", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL); if (write_temp_file (tmpdir, conftest_file_name, get_goodcode_snippet (source_version))) { @@ -1541,7 +1541,7 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.class", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1571,9 +1571,9 @@ free (conftest_file_name); conftest_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.java", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.java", + NULL); if (write_temp_file (tmpdir, conftest_file_name, failcode)) { free (conftest_file_name); @@ -1582,9 +1582,9 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.class", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.class", + NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1670,7 +1670,7 @@ return true; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.java", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL); if (write_temp_file (tmpdir, conftest_file_name, get_goodcode_snippet ("1.4"))) { @@ -1680,7 +1680,7 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.class", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1727,7 +1727,7 @@ return true; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.java", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL); if (write_temp_file (tmpdir, conftest_file_name, get_goodcode_snippet ("1.3"))) { @@ -1737,7 +1737,7 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.class", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1835,7 +1835,7 @@ return true; conftest_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.java", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.java", NULL); if (write_temp_file (tmpdir, conftest_file_name, get_goodcode_snippet (source_version))) { @@ -1845,7 +1845,7 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, "conftest.class", NULL); + xconcatenated_filename (tmpdir->dir_name, "conftest.class", NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1878,9 +1878,9 @@ free (conftest_file_name); conftest_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.java", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.java", + NULL); if (write_temp_file (tmpdir, conftest_file_name, failcode)) { free (conftest_file_name); @@ -1889,9 +1889,9 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.class", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.class", + NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name; @@ -1959,9 +1959,9 @@ free (conftest_file_name); conftest_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.java", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.java", + NULL); if (write_temp_file (tmpdir, conftest_file_name, failcode)) { @@ -1971,9 +1971,9 @@ } compiled_file_name = - concatenated_filename (tmpdir->dir_name, - "conftestfail.class", - NULL); + xconcatenated_filename (tmpdir->dir_name, + "conftestfail.class", + NULL); register_temp_file (tmpdir, compiled_file_name); java_sources[0] = conftest_file_name;
--- a/lib/javaexec.c +++ b/lib/javaexec.c @@ -29,7 +29,7 @@ #include "classpath.h" #include "xsetenv.h" #include "sh-quote.h" -#include "filename.h" +#include "concat-filename.h" #include "xalloc.h" #include "xmalloca.h" #include "error.h" @@ -94,7 +94,7 @@ /* First, try a class compiled to a native code executable. */ if (exe_dir != NULL) { - char *exe_pathname = concatenated_filename (exe_dir, class_name, EXEEXT); + char *exe_pathname = xconcatenated_filename (exe_dir, class_name, EXEEXT); char *old_classpath; char **argv = (char **) xmalloca ((1 + nargs + 1) * sizeof (char *)); unsigned int i;
new file mode 100644 --- /dev/null +++ b/lib/xconcat-filename.c @@ -0,0 +1,41 @@ +/* Construct a full filename from a directory and a relative filename. + Copyright (C) 2001-2004, 2006-2008 Free Software Foundation, Inc. + + 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 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/>. */ + +/* Written by Bruno Haible <haible@clisp.cons.org>. */ + +#include <config.h> + +/* Specification. */ +#include "concat-filename.h" + +#include "xalloc.h" + +/* Concatenate a directory filename, a relative filename and an optional + suffix. The directory may end with the directory separator. The second + argument may not start with the directory separator (it is relative). + Return a freshly allocated filename. */ +char * +xconcatenated_filename (const char *directory, const char *filename, + const char *suffix) +{ + char *result; + + result = concatenated_filename (directory, filename, suffix); + if (result == NULL) + xalloc_die (); + + return result; +}
--- a/modules/concat-filename +++ b/modules/concat-filename @@ -8,7 +8,7 @@ Depends-on: filename -xalloc +malloc-posix stpcpy configure.ac: @@ -20,7 +20,7 @@ "concat-filename.h" License: -GPL +LGPLv2+ Maintainer: Bruno Haible
--- a/modules/findprog +++ b/modules/findprog @@ -10,7 +10,7 @@ Depends-on: stdbool xalloc -filename +xconcat-filename unistd configure.ac:
--- a/modules/javacomp +++ b/modules/javacomp @@ -20,7 +20,7 @@ xalloc xmalloca getline -filename +xconcat-filename fwriteerror clean-temp error
--- a/modules/javaexec +++ b/modules/javaexec @@ -11,7 +11,7 @@ classpath xsetenv sh-quote -filename +xconcat-filename xalloc xmalloca error
new file mode 100644 --- /dev/null +++ b/modules/xconcat-filename @@ -0,0 +1,26 @@ +Description: +Construct a full filename by concatenating a directory name, a relative +filename, and a suffix, with out-of-memory checking. + +Files: +lib/concat-filename.h +lib/xconcat-filename.c + +Depends-on: +concat-filename +xalloc-die + +configure.ac: + +Makefile.am: +lib_SOURCES += xconcat-filename.c + +Include: +"concat-filename.h" + +License: +GPL + +Maintainer: +Bruno Haible +