[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: conflicts between pathname.h and dirname.h
From: |
Bruno Haible |
Subject: |
Re: conflicts between pathname.h and dirname.h |
Date: |
Sun, 25 Feb 2007 17:02:00 +0100 |
User-agent: |
KMail/1.5.4 |
Paul Eggert wrote:
> > Well, if you want my biased opinion, pathname should go. :-)
> >
> > The GNU Coding Standards say that one shouldn't use the word
> > "pathname" to describe file names.
If that is your only argument, I can rename this module to 'filename'.
Ben Pfaff wrote:
> Here is my attempt at a minimally invasive resolution of the
> differences
This is backwards. You introduce a dependency from a simple module to a
complicated module. The purpose of 'filename' (ex-'pathname') is to do
the most simple filename manipulations: analysis and concatenation. Why
should it depend on a module that defines functions base_name(), dir_name(),
last_component(), strip_trailing_slashes() ?
> which should be good enough to let both headers be included at once.
The conflicts between the headers arise because of the macros. Questions:
- Do the conflicting macros actually the same thing?
(Answer: yes, except that that filename.h treats DJGPP correctly, while
dirname.h doesn't.)
- Does one of the header have macros that the other doesn't?
(Answer: filename.h also has HAS_DEVICE, which may be useful in some cases.)
- Are there differences in the code structure?
(Answer: filename.h is simpler, since it does a #ifdef at compile time,
rather than at configure time. Also dirname.h is harder to understand
because half of the code is contained in dos.m4.)
- Are the macros optimized to the same extent?
(Answer: Those in dirname.h are better optimized than those in filename.h.)
Bruno
2007-02-25 Bruno Haible <address@hidden>
* modules/filename: Renamed from modules/pathname.
(Files): Replace lib/pathname.h with lib/filename.h. Replace
lib/concatpath.c with lib/concat-filename.c.
(Makefile.am): Update.
(Include): Replace pathname.h with filename.h.
* lib/filename.h: Renamed from lib/pathname.h.
(concatenated_filename): Renamed from concatenated_pathname.
* lib/concat-filename.c: Renamed from lib/concatpath.c.
(concatenated_filename): Renamed from concatenated_pathname.
* lib/findprog.c: Include filename.h instead of pathname.h.
(find_in_path): Update.
* lib/javacomp.c: Include filename.h instead of pathname.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): Update.
* lib/javaexec.c: Include filename.h instead of pathname.h.
(execute_java_class): Update.
* modules/findprog: Update.
* modules/javacomp: Update.
* modules/javaexec: Update.
* MODULES.html.sh (File system functions): Add 'filename', remove
'pathname'.
--- MODULES.html.sh 21 Feb 2007 02:18:10 -0000 1.199
+++ MODULES.html.sh 25 Feb 2007 15:25:12 -0000
@@ -2050,6 +2050,7 @@
func_module file-type
func_module fileblocks
func_module filemode
+ func_module filename
func_module filenamecat
func_module fts
func_module fts-lgpl
@@ -2061,7 +2062,6 @@
func_module modechange
func_module mountlist
func_module openat
- func_module pathname
func_module pathmax
func_module same
func_module save-cwd
--- lib/concat-filename.c 25 Feb 2007 15:06:41 -0000 1.1
+++ lib/concat-filename.c 25 Feb 2007 15:25:12 -0000
@@ -1,5 +1,5 @@
/* Construct a full pathname from a directory and a filename.
- Copyright (C) 2001-2004, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2006-2007 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
@@ -21,18 +21,18 @@
#include <config.h>
/* Specification. */
-#include "pathname.h"
+#include "filename.h"
#include <string.h>
#include "xalloc.h"
-/* Concatenate a directory pathname, a relative pathname and an optional
+/* 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 pathname. */
+ Return a freshly allocated filename. */
char *
-concatenated_pathname (const char *directory, const char *filename,
+concatenated_filename (const char *directory, const char *filename,
const char *suffix)
{
char *result;
--- lib/filename.h 25 Feb 2007 15:05:21 -0000 1.1
+++ lib/filename.h 25 Feb 2007 15:25:12 -0000
@@ -1,5 +1,5 @@
/* Pathname support.
- Copyright (C) 2001-2004 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2007 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
@@ -15,8 +15,8 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-#ifndef _PATHNAME_H
-#define _PATHNAME_H
+#ifndef _FILENAME_H
+#define _FILENAME_H
#ifdef __cplusplus
extern "C" {
@@ -47,13 +47,13 @@
# define FILE_SYSTEM_PREFIX_LEN(P) 0
#endif
-/* Concatenate a directory pathname, a relative pathname and an optional
- suffix. Return a freshly allocated pathname. */
-extern char *concatenated_pathname (const char *directory,
+/* Concatenate a directory filename, a relative filename and an optional
+ suffix. Return a freshly allocated filename. */
+extern char *concatenated_filename (const char *directory,
const char *filename, const char *suffix);
#ifdef __cplusplus
}
#endif
-#endif /* _PATHNAME_H */
+#endif /* _FILENAME_H */
--- lib/findprog.c 6 Nov 2006 13:03:10 -0000 1.9
+++ lib/findprog.c 25 Feb 2007 15:25:12 -0000
@@ -1,5 +1,5 @@
/* Locating a program in PATH.
- Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2006-2007 Free Software Foundation, Inc.
Written by Bruno Haible <address@hidden>, 2001.
This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@
#include <unistd.h>
#include "xalloc.h"
-#include "pathname.h"
+#include "filename.h"
const char *
@@ -76,7 +76,7 @@
dir = ".";
/* Concatenate dir and progname. */
- progpathname = concatenated_pathname (dir, progname, NULL);
+ progpathname = concatenated_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
@@ -89,7 +89,7 @@
{
free (progpathname);
- /* Add the "./" prefix for real, that concatenated_pathname()
+ /* Add the "./" prefix for real, that concatenated_filename()
optimized away. This avoids a second PATH search when the
caller uses execlp/execvp. */
progpathname = XNMALLOC (2 + strlen (progname) + 1, char);
--- lib/javacomp.c 4 Feb 2007 16:28:01 -0000 1.12
+++ lib/javacomp.c 25 Feb 2007 15:25:13 -0000
@@ -43,7 +43,7 @@
#include "xalloc.h"
#include "xallocsa.h"
#include "getline.h"
-#include "pathname.h"
+#include "filename.h"
#include "fwriteerror.h"
#include "clean-temp.h"
#include "error.h"
@@ -741,7 +741,7 @@
return true;
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.class", NULL);
+ concatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
register_temp_file (tmpdir, compiled_file_name);
java_sources[0] = conftest_file_name;
@@ -785,7 +785,7 @@
free (conftest_file_name);
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.java",
NULL);
if (write_temp_file (tmpdir, conftest_file_name, failcode))
@@ -797,7 +797,7 @@
}
compiled_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.class",
NULL);
register_temp_file (tmpdir, compiled_file_name);
@@ -890,7 +890,7 @@
return true;
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.class", NULL);
+ concatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
register_temp_file (tmpdir, compiled_file_name);
java_sources[0] = conftest_file_name;
@@ -927,7 +927,7 @@
Return a failure indicator (true upon error). */
static bool
is_envjavac_oldgcj_14_13_usable (const char *javac,
- bool *usablep, bool *need_no_assert_option_p)
+ bool *usablep, bool *need_no_assert_option_p)
{
static bool envjavac_tested;
static bool envjavac_usable;
@@ -951,7 +951,7 @@
return true;
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.class", NULL);
+ concatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
register_temp_file (tmpdir, compiled_file_name);
java_sources[0] = conftest_file_name;
@@ -994,7 +994,7 @@
if (javac_works && javac_noassert_works)
{
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftestfail.java",
+ concatenated_filename (tmpdir->dir_name, "conftestfail.java",
NULL);
if (write_temp_file (tmpdir, conftest_file_name,
get_failcode_snippet ("1.3")))
@@ -1006,7 +1006,7 @@
}
compiled_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftestfail.class",
+ concatenated_filename (tmpdir->dir_name, "conftestfail.class",
NULL);
register_temp_file (tmpdir, compiled_file_name);
@@ -1091,7 +1091,7 @@
return true;
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.class", NULL);
+ concatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
register_temp_file (tmpdir, compiled_file_name);
java_sources[0] = conftest_file_name;
@@ -1135,7 +1135,7 @@
free (conftest_file_name);
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.java",
NULL);
if (write_temp_file (tmpdir, conftest_file_name, failcode))
@@ -1147,7 +1147,7 @@
}
compiled_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.class",
NULL);
register_temp_file (tmpdir, compiled_file_name);
@@ -1219,7 +1219,7 @@
free (conftest_file_name);
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.java",
NULL);
if (write_temp_file (tmpdir, conftest_file_name,
@@ -1233,7 +1233,7 @@
}
compiled_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.class",
NULL);
register_temp_file (tmpdir, compiled_file_name);
@@ -1387,7 +1387,7 @@
char *conftest_file_name;
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftestlib.java",
+ concatenated_filename (tmpdir->dir_name, "conftestlib.java",
NULL);
if (write_temp_file (tmpdir, conftest_file_name,
"public class conftestlib {\n"
@@ -1401,7 +1401,7 @@
const char *java_sources[1];
compiled_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestlib.class",
NULL);
register_temp_file (tmpdir, compiled_file_name);
@@ -1531,7 +1531,7 @@
return true;
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.class", NULL);
+ concatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
register_temp_file (tmpdir, compiled_file_name);
java_sources[0] = conftest_file_name;
@@ -1571,7 +1571,7 @@
free (conftest_file_name);
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.java",
NULL);
if (write_temp_file (tmpdir, conftest_file_name, failcode))
@@ -1582,7 +1582,7 @@
}
compiled_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.class",
NULL);
register_temp_file (tmpdir, compiled_file_name);
@@ -1670,7 +1670,7 @@
return true;
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name, "conftest.java", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.class", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.java", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.class", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.java", NULL);
+ concatenated_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_pathname (tmpdir->dir_name, "conftest.class", NULL);
+ concatenated_filename (tmpdir->dir_name, "conftest.class", NULL);
register_temp_file (tmpdir, compiled_file_name);
java_sources[0] = conftest_file_name;
@@ -1878,7 +1878,7 @@
free (conftest_file_name);
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.java",
NULL);
if (write_temp_file (tmpdir, conftest_file_name, failcode))
@@ -1889,7 +1889,7 @@
}
compiled_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.class",
NULL);
register_temp_file (tmpdir, compiled_file_name);
@@ -1959,7 +1959,7 @@
free (conftest_file_name);
conftest_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.java",
NULL);
if (write_temp_file (tmpdir, conftest_file_name,
@@ -1971,7 +1971,7 @@
}
compiled_file_name =
- concatenated_pathname (tmpdir->dir_name,
+ concatenated_filename (tmpdir->dir_name,
"conftestfail.class",
NULL);
register_temp_file (tmpdir, compiled_file_name);
--- lib/javaexec.c 14 Sep 2006 14:18:36 -0000 1.4
+++ lib/javaexec.c 25 Feb 2007 15:25:13 -0000
@@ -1,5 +1,5 @@
/* Execute a Java program.
- Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2006-2007 Free Software Foundation, Inc.
Written by Bruno Haible <address@hidden>, 2001.
This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,7 @@
#include "classpath.h"
#include "xsetenv.h"
#include "sh-quote.h"
-#include "pathname.h"
+#include "filename.h"
#include "xalloc.h"
#include "xallocsa.h"
#include "error.h"
@@ -95,7 +95,7 @@
/* First, try a class compiled to a native code executable. */
if (exe_dir != NULL)
{
- char *exe_pathname = concatenated_pathname (exe_dir, class_name, EXEEXT);
+ char *exe_pathname = concatenated_filename (exe_dir, class_name, EXEEXT);
char *old_classpath;
char **argv = (char **) xallocsa ((1 + nargs + 1) * sizeof (char *));
unsigned int i;
--- modules/filename 25 Feb 2007 15:04:50 -0000 1.1
+++ modules/filename 25 Feb 2007 15:25:13 -0000
@@ -1,10 +1,10 @@
Description:
-Construct a full pathname by concatenating a directory name, a relative
+Construct a full filename by concatenating a directory name, a relative
filename, and a suffix.
Files:
-lib/pathname.h
-lib/concatpath.c
+lib/filename.h
+lib/concat-filename.c
Depends-on:
xalloc
@@ -13,10 +13,10 @@
configure.ac:
Makefile.am:
-lib_SOURCES += pathname.h concatpath.c
+lib_SOURCES += concat-filename.c
Include:
-"pathname.h"
+"filename.h"
License:
GPL
--- modules/findprog 24 Apr 2006 11:38:06 -0000 1.3
+++ modules/findprog 25 Feb 2007 15:25:13 -0000
@@ -10,7 +10,7 @@
Depends-on:
stdbool
xalloc
-pathname
+filename
unistd
configure.ac:
--- modules/javacomp 27 Jan 2007 02:21:21 -0000 1.5
+++ modules/javacomp 25 Feb 2007 15:25:13 -0000
@@ -20,7 +20,7 @@
xalloc
xallocsa
getline
-pathname
+filename
fwriteerror
clean-temp
error
--- modules/javaexec 16 Jan 2007 12:43:13 -0000 1.5
+++ modules/javaexec 25 Feb 2007 15:25:13 -0000
@@ -11,7 +11,7 @@
classpath
xsetenv
sh-quote
-pathname
+filename
xalloc
xallocsa
error