annotate m4/stat.m4 @ 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 97fc9a21a8fb
children 93a1703f75df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14393
9f47f8c334f2 dirname: move m4/dos.m4 functionality into lib/dosname.h
Paul Eggert <eggert@cs.ucla.edu>
parents: 14079
diff changeset
1 # serial 7
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
2
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 13918
diff changeset
3 # Copyright (C) 2009-2011 Free Software Foundation, Inc.
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
4 #
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
5 # This file is free software; the Free Software Foundation
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
6 # gives unlimited permission to copy and/or distribute it,
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
7 # with or without modifications, as long as this notice is preserved.
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
8
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
9 AC_DEFUN([gl_FUNC_STAT],
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
10 [
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
13 AC_CHECK_FUNCS_ONCE([lstat])
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
14 dnl mingw is the only known platform where stat(".") and stat("./") differ
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
15 AC_CACHE_CHECK([whether stat handles trailing slashes on directories],
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
16 [gl_cv_func_stat_dir_slash],
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
17 [AC_RUN_IFELSE(
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
18 [AC_LANG_PROGRAM(
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
19 [[#include <sys/stat.h>
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
20 ]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])],
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
21 [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no],
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
22 [case $host_os in
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
23 mingw*) gl_cv_func_stat_dir_slash="guessing no";;
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
24 *) gl_cv_func_stat_dir_slash="guessing yes";;
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
25 esac])])
13499
af9512fc5d24 stat: Update regarding AIX.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
26 dnl AIX 7.1, Solaris 9 mistakenly succeed on stat("file/")
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
27 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/")
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
28 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
29 [gl_cv_func_stat_file_slash],
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
30 [touch conftest.tmp
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
31 # Assume that if we have lstat, we can also check symlinks.
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
32 if test $ac_cv_func_lstat = yes; then
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
33 ln -s conftest.tmp conftest.lnk
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
34 fi
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
35 AC_RUN_IFELSE(
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
36 [AC_LANG_PROGRAM(
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
37 [[#include <sys/stat.h>
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13499
diff changeset
38 ]], [[int result = 0;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13499
diff changeset
39 struct stat st;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13499
diff changeset
40 if (!stat ("conftest.tmp/", &st))
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13499
diff changeset
41 result |= 1;
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
42 #if HAVE_LSTAT
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13499
diff changeset
43 if (!stat ("conftest.lnk/", &st))
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13499
diff changeset
44 result |= 2;
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
45 #endif
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13499
diff changeset
46 return result;
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
47 ]])],
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
48 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
49 [gl_cv_func_stat_file_slash="guessing no"])
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
50 rm -f conftest.tmp conftest.lnk])
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
51 case $gl_cv_func_stat_dir_slash in
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
52 *no) REPLACE_STAT=1
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
53 AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
54 help when passed a directory name with a trailing slash]);;
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
55 esac
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
56 case $gl_cv_func_stat_file_slash in
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
57 *no) REPLACE_STAT=1
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
58 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
59 help when passed a file name with a trailing slash]);;
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
60 esac
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
61 if test $REPLACE_STAT = 1; then
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
62 AC_LIBOBJ([stat])
12542
ea823743f290 Use AC_C_INLINE where necessary.
Bruno Haible <bruno@clisp.org>
parents: 12258
diff changeset
63 dnl Prerequisites of lib/stat.c.
ea823743f290 Use AC_C_INLINE where necessary.
Bruno Haible <bruno@clisp.org>
parents: 12258
diff changeset
64 AC_REQUIRE([AC_C_INLINE])
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
65 fi
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
66 ])