Mercurial > hg > octave-lojdl > gnulib-hg
changeset 14393:9f47f8c334f2
dirname: move m4/dos.m4 functionality into lib/dosname.h
m4/dos.m4 needs to go. It laboriously invokes the C compiler, and
extracts symbols from it, puts them into config.h; but it's much
easier to use the symbols directly. filename.h already does this,
but it disagrees with dos.m4 in some respects. This patch
introduces a different include file dosname.h that packages up
dos.m4, and then later we can work on merging filename.h and
dosname.h. Applications that need only the easy-to-configure
symbols should consider including dosname.h rather than dirname.h.
* NEWS: Mention incompatible changes.
* m4/dos.m4: Remove.
* lib/dosname.h, modules/dosname: New files.
* lib/dirname.h (ISSLASH, FILE_SYSTEM_PREFIX_LEN):
(FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE):
(IS_ABSOLUTE_FILE_NAME, IS_RELATIVE_FILE_NAME): Move to lib/dosname.h.
* lib/at-func.c, lib/at-func2.c, lib/openat.c, lib/savewd.c:
Include dosname.h, not dirname.h.
* lib/rmdir.c, lib/stat.c, lib/unlink.c, lib/unlinkat.c:
Include dosname.h, for definitions of symbols like ISSLASH
that used to be in config.h.
* m4/dirname.m4 (gl_DIRNAME_LGPL): Do not require gl_AC_DOS.
* m4/rmdir.m4 (gl_FUNC_RMDIR): Likewise.
* m4/stat.m4 (gl_FUNC_STAT): Likewise.
* m4/unlink.m4 (gl_FUNC_UNLINK): Likewise.
* modules/dirname-lgpl (Files): Omit m4/dos.m4.
* modules/rmdir (Files): Likewise.
* modules/stat (Files): Likewise.
* modules/unlink (Files): Likewise.
* modules/dirname-lgpl (Depends-on): Add dosname.
* modules/lstat (Depends-on): Likewise.
* modules/openat (Depends-on): Likewise.
* modules/rmdir (Depends-on): Likewise.
* modules/savewd (Depends-on): Likewise.
* modules/stat (Depends-on): Likewise.
* modules/unlink (Depends-on): Likewise.
* modules/openat (Depends-on): Remove dirname-lgpl.
* modules/savewd (Depends-on): Likewise.
* tests/test-dirname.c: Do not use removed symbols like
FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR. Instead, use
the remaining symbols, e.g., ISSLASH ('\\').
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 25 Feb 2011 10:52:37 -0800 |
parents | 8e3cbca9a7f4 |
children | 74d1558ae43f |
files | ChangeLog NEWS lib/at-func.c lib/at-func2.c lib/dirname.h lib/dosname.h lib/openat.c lib/rmdir.c lib/savewd.c lib/stat.c lib/unlink.c lib/unlinkat.c m4/dirname.m4 m4/dos.m4 m4/rmdir.m4 m4/stat.m4 m4/unlink.m4 modules/dirname-lgpl modules/dosname modules/lstat modules/openat modules/rmdir modules/savewd modules/stat modules/unlink tests/test-dirname.c |
diffstat | 26 files changed, 153 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,47 @@ +2011-02-25 Paul Eggert <eggert@cs.ucla.edu> + + dirname: move m4/dos.m4 functionality into lib/dosname.h + + m4/dos.m4 needs to go. It laboriously invokes the C compiler, and + extracts symbols from it, puts them into config.h; but it's much + easier to use the symbols directly. filename.h already does this, + but it disagrees with dos.m4 in some respects. This patch + introduces a different include file dosname.h that packages up + dos.m4, and then later we can work on merging filename.h and + dosname.h. Applications that need only the easy-to-configure + symbols should consider including dosname.h rather than dirname.h. + * NEWS: Mention incompatible changes. + * m4/dos.m4: Remove. + * lib/dosname.h, modules/dosname: New files. + * lib/dirname.h (ISSLASH, FILE_SYSTEM_PREFIX_LEN): + (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE): + (IS_ABSOLUTE_FILE_NAME, IS_RELATIVE_FILE_NAME): Move to lib/dosname.h. + * lib/at-func.c, lib/at-func2.c, lib/openat.c, lib/savewd.c: + Include dosname.h, not dirname.h. + * lib/rmdir.c, lib/stat.c, lib/unlink.c, lib/unlinkat.c: + Include dosname.h, for definitions of symbols like ISSLASH + that used to be in config.h. + * m4/dirname.m4 (gl_DIRNAME_LGPL): Do not require gl_AC_DOS. + * m4/rmdir.m4 (gl_FUNC_RMDIR): Likewise. + * m4/stat.m4 (gl_FUNC_STAT): Likewise. + * m4/unlink.m4 (gl_FUNC_UNLINK): Likewise. + * modules/dirname-lgpl (Files): Omit m4/dos.m4. + * modules/rmdir (Files): Likewise. + * modules/stat (Files): Likewise. + * modules/unlink (Files): Likewise. + * modules/dirname-lgpl (Depends-on): Add dosname. + * modules/lstat (Depends-on): Likewise. + * modules/openat (Depends-on): Likewise. + * modules/rmdir (Depends-on): Likewise. + * modules/savewd (Depends-on): Likewise. + * modules/stat (Depends-on): Likewise. + * modules/unlink (Depends-on): Likewise. + * modules/openat (Depends-on): Remove dirname-lgpl. + * modules/savewd (Depends-on): Likewise. + * tests/test-dirname.c: Do not use removed symbols like + FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR. Instead, use + the remaining symbols, e.g., ISSLASH ('\\'). + 2011-02-25 Eric Blake <eblake@redhat.com> strstr: revert patches that introduced bug and pessimization
--- a/NEWS +++ b/NEWS @@ -12,6 +12,17 @@ Date Modules Changes +2011-02-25 dirname These modules no longer put #defines for the + dirname-lgpl following symbols into <config.h>: ISSLASH, + backupfile FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX, + lstat FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR, + openat FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE. + remove Applications that need ISSLASH can include the new + rmdir header dosname.h. + savewd + stat + unlink + 2011-02-14 getloadavg This module no longer #defines C_GETLOADAVG or HAVE_GETLOADAVG, as the application no longer needs to worry about how getloadavg is defined. It no
--- a/lib/at-func.c +++ b/lib/at-func.c @@ -16,7 +16,7 @@ /* written by Jim Meyering */ -#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ #include "openat.h" #include "openat-priv.h" #include "save-cwd.h"
--- a/lib/at-func2.c +++ b/lib/at-func2.c @@ -25,7 +25,7 @@ #include <string.h> #include <unistd.h> -#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ #include "filenamecat.h" #include "openat.h" #include "same-inode.h"
--- a/lib/dirname.h +++ b/lib/dirname.h @@ -21,44 +21,16 @@ # include <stdbool.h> # include <stddef.h> +# include "dosname.h" # ifndef DIRECTORY_SEPARATOR # define DIRECTORY_SEPARATOR '/' # endif -# ifndef ISSLASH -# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) -# endif - -# ifndef FILE_SYSTEM_PREFIX_LEN -# if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX - /* This internal macro assumes ASCII, but all hosts that support drive - letters use ASCII. */ -# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \ - <= 'z' - 'a') -# define FILE_SYSTEM_PREFIX_LEN(Filename) \ - (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) -# else -# define FILE_SYSTEM_PREFIX_LEN(Filename) 0 -# endif -# endif - -# ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE -# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 -# endif - # ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT # define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 # endif -# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE -# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) -# else -# define IS_ABSOLUTE_FILE_NAME(F) \ - (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F)) -# endif -# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) - # if GNULIB_DIRNAME char *base_name (char const *file); char *dir_name (char const *file);
new file mode 100644 --- /dev/null +++ b/lib/dosname.h @@ -0,0 +1,53 @@ +/* File names on MS-DOS/Windows systems. + + Copyright (C) 2000-2001, 2004-2006, 2009-2011 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 + (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/>. + + From Paul Eggert and Jim Meyering. */ + +#ifndef _DOSNAME_H +#define _DOSNAME_H + +#if (defined _WIN32 || defined __WIN32__ || \ + defined __MSDOS__ || defined __CYGWIN__ || \ + defined __EMX__ || defined __DJGPP__) + /* This internal macro assumes ASCII, but all hosts that support drive + letters use ASCII. */ +# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \ + <= 'z' - 'a') +# define FILE_SYSTEM_PREFIX_LEN(Filename) \ + (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) +# ifndef __CYGWIN__ +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1 +# endif +# define ISSLASH(C) ((C) == '/' || (C) == '\\') +#else +# define FILE_SYSTEM_PREFIX_LEN(Filename) 0 +# define ISSLASH(C) ((C) == '/') +#endif + +#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0 +#endif + +#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE +# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) +# else +# define IS_ABSOLUTE_FILE_NAME(F) \ + (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0) +#endif +#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) + +#endif /* DOSNAME_H_ */
--- a/lib/openat.c +++ b/lib/openat.c @@ -25,7 +25,7 @@ #include <string.h> #include <sys/stat.h> -#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ #include "openat-priv.h" #include "save-cwd.h"
--- a/lib/rmdir.c +++ b/lib/rmdir.c @@ -23,6 +23,8 @@ #include <errno.h> #include <string.h> +#include "dosname.h" + #undef rmdir /* Remove directory DIR.
--- a/lib/savewd.c +++ b/lib/savewd.c @@ -31,7 +31,7 @@ #include <sys/wait.h> #include <unistd.h> -#include "dirname.h" +#include "dosname.h" #include "fcntl-safer.h" /* Save the working directory into *WD, if it hasn't been saved
--- a/lib/stat.c +++ b/lib/stat.c @@ -37,6 +37,7 @@ #include <limits.h> #include <stdbool.h> #include <string.h> +#include "dosname.h" /* Store information about NAME into ST. Work around bugs with trailing slashes. Mingw has other bugs (such as st_ino always
--- a/lib/unlink.c +++ b/lib/unlink.c @@ -24,6 +24,8 @@ #include <string.h> #include <sys/stat.h> +#include "dosname.h" + #undef unlink /* Remove file NAME.
--- a/lib/unlinkat.c +++ b/lib/unlinkat.c @@ -26,6 +26,7 @@ #include <string.h> #include <sys/stat.h> +#include "dosname.h" #include "openat.h" #if HAVE_UNLINKAT
--- a/m4/dirname.m4 +++ b/m4/dirname.m4 @@ -1,4 +1,4 @@ -#serial 8 -*- autoconf -*- +#serial 9 -*- autoconf -*- dnl Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,7 +18,6 @@ AC_LIBOBJ([stripslash]) dnl Prerequisites of lib/dirname.h. - AC_REQUIRE([gl_AC_DOS]) AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
deleted file mode 100644 --- a/m4/dos.m4 +++ /dev/null @@ -1,71 +0,0 @@ -#serial 11 -*- autoconf -*- - -# Define some macros required for proper operation of code in lib/*.c -# on MSDOS/Windows systems. - -# Copyright (C) 2000-2001, 2004-2006, 2009-2011 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# From Jim Meyering. - -AC_DEFUN([gl_AC_DOS], - [ - AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos], - [ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ -#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__ -neither MSDOS nor Windows -#endif]])], - [ac_cv_win_or_dos=yes], - [ac_cv_win_or_dos=no]) - ]) - - if test x"$ac_cv_win_or_dos" = xyes; then - ac_fs_accepts_drive_letter_prefix=1 - ac_fs_backslash_is_file_name_separator=1 - AC_CACHE_CHECK([whether drive letter can start relative path], - [ac_cv_drive_letter_can_be_relative], - [ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ -#if defined __CYGWIN__ -drive letters are always absolute -#endif]])], - [ac_cv_drive_letter_can_be_relative=yes], - [ac_cv_drive_letter_can_be_relative=no]) - ]) - if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then - ac_fs_drive_letter_can_be_relative=1 - else - ac_fs_drive_letter_can_be_relative=0 - fi - else - ac_fs_accepts_drive_letter_prefix=0 - ac_fs_backslash_is_file_name_separator=0 - ac_fs_drive_letter_can_be_relative=0 - fi - - AC_DEFINE_UNQUOTED([FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX], - $ac_fs_accepts_drive_letter_prefix, - [Define on systems for which file names may have a so-called - `drive letter' prefix, define this to compute the length of that - prefix, including the colon.]) - - AH_VERBATIM(ISSLASH, - [#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR -# define ISSLASH(C) ((C) == '/' || (C) == '\\') -#else -# define ISSLASH(C) ((C) == '/') -#endif]) - - AC_DEFINE_UNQUOTED([FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR], - $ac_fs_backslash_is_file_name_separator, - [Define if the backslash character may also serve as a file name - component separator.]) - - AC_DEFINE_UNQUOTED([FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE], - $ac_fs_drive_letter_can_be_relative, - [Define if a drive letter prefix denotes a relative path if it is - not followed by a file name component separator.]) - ])
--- a/m4/rmdir.m4 +++ b/m4/rmdir.m4 @@ -1,4 +1,4 @@ -# rmdir.m4 serial 9 +# rmdir.m4 serial 10 dnl Copyright (C) 2002, 2005, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_RMDIR], [ - AC_REQUIRE([gl_AC_DOS]) AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl Detect cygwin 1.5.x bug. AC_CACHE_CHECK([whether rmdir works], [gl_cv_func_rmdir_works],
--- a/m4/stat.m4 +++ b/m4/stat.m4 @@ -1,4 +1,4 @@ -# serial 6 +# serial 7 # Copyright (C) 2009-2011 Free Software Foundation, Inc. # @@ -9,7 +9,6 @@ AC_DEFUN([gl_FUNC_STAT], [ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_REQUIRE([gl_AC_DOS]) AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) AC_CHECK_FUNCS_ONCE([lstat]) dnl mingw is the only known platform where stat(".") and stat("./") differ
--- a/m4/unlink.m4 +++ b/m4/unlink.m4 @@ -1,4 +1,4 @@ -# unlink.m4 serial 6 +# unlink.m4 serial 7 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,6 @@ AC_DEFUN([gl_FUNC_UNLINK], [ - AC_REQUIRE([gl_AC_DOS]) AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl Detect FreeBSD 7.2, AIX 7.1, Solaris 9 bug.
--- a/modules/dirname-lgpl +++ b/modules/dirname-lgpl @@ -7,9 +7,9 @@ lib/basename-lgpl.c lib/stripslash.c m4/dirname.m4 -m4/dos.m4 Depends-on: +dosname double-slash-root malloc-posix stdbool
new file mode 100644 --- /dev/null +++ b/modules/dosname @@ -0,0 +1,20 @@ +Description: +Macros for porting to systems with DOS-style file names. + +Files: +lib/dosname.h + +Depends-on: + +configure.ac: + +Makefile.am: + +Include: +"dosname.h" + +License: +LGPLv2+ + +Maintainer: +Eric Blake, Paul Eggert, Jim Meyering
--- a/modules/lstat +++ b/modules/lstat @@ -6,6 +6,7 @@ m4/lstat.m4 Depends-on: +dosname stat sys_stat
--- a/modules/openat +++ b/modules/openat @@ -16,7 +16,7 @@ m4/mode_t.m4 Depends-on: -dirname-lgpl +dosname errno extensions fchdir
--- a/modules/rmdir +++ b/modules/rmdir @@ -3,10 +3,10 @@ Files: lib/rmdir.c -m4/dos.m4 m4/rmdir.m4 Depends-on: +dosname sys_stat unistd
--- a/modules/savewd +++ b/modules/savewd @@ -7,7 +7,7 @@ m4/savewd.m4 Depends-on: -dirname-lgpl +dosname errno exit fchdir
--- a/modules/stat +++ b/modules/stat @@ -3,10 +3,10 @@ Files: lib/stat.c -m4/dos.m4 m4/stat.m4 Depends-on: +dosname stdbool sys_stat
--- a/modules/unlink +++ b/modules/unlink @@ -3,10 +3,10 @@ Files: lib/unlink.c -m4/dos.m4 m4/unlink.m4 Depends-on: +dosname lstat unistd
--- a/tests/test-dirname.c +++ b/tests/test-dirname.c @@ -54,7 +54,7 @@ {"", ".", "", "", "", false, false}, {".", ".", ".", ".", ".", false, false}, {"..", ".", "..", "..", "..", false, false}, -#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR +#if ISSLASH ('\\') {"a\\", ".", "a\\", "a\\", "a", true, false}, {"a\\b", "a", "b", "b", "a\\b", false, false}, {"\\", "\\", "", "\\", "\\", false, true}, @@ -75,7 +75,7 @@ {"//\\", "/", "\\", "\\", "//\\", false, true}, # endif #endif -#if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX +#if ISSLASH ('\\') # if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE {"c:", "c:", "", "c:", "c:", false, false}, {"c:/", "c:/", "", "c:/", "c:/", false, true}, @@ -105,7 +105,7 @@ {"a/b:c", "a", "b:c", "./b:c","a/b:c",false, false}, {"a/b:c/", "a", "b:c/", "./b:c/","a/b:c",true, false}, # endif -#else /* ! FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX */ +#else /* ! ISSLASH ('\\') */ {"c:", ".", "c:", "c:", "c:", false, false}, {"c:/", ".", "c:/", "c:/", "c:", true, false}, {"c://", ".", "c://", "c:/", "c:", true, false},