]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Be nice with file systems that don't handle unusual characters.
authorBenoit Sigoure <tsuna@lrde.epita.fr>
Tue, 18 Dec 2007 12:54:08 +0000 (13:54 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 2 Mar 2008 12:03:10 +0000 (13:03 +0100)
* tests/atlocal.in (func_sanitize_file_name)
(func_sanitize_dir_name): New shell functions.
* tests/tools.at (autom4te and whitespace in file names)
(autotools and whitespace in file names): Use them.
* tests/torture.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS):
Cover more potentially problemtic file names.  Use the new
functions.

Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr>
Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
tests/atlocal.in
tests/tools.at
tests/torture.at

index c480adff12e6de90d78df47b31cdfade3cc0b0ee..b247fd41a9fe30c0f04691c74c0951b4b8ca5824 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-03-01  Benoit Sigoure  <tsuna@lrde.epita.fr>
 
+       Be nice with file systems that don't handle unusual characters.
+       * tests/atlocal.in (func_sanitize_file_name)
+       (func_sanitize_dir_name): New shell functions.
+       * tests/tools.at (autom4te and whitespace in file names)
+       (autotools and whitespace in file names): Use them.
+       * tests/torture.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS):
+       Cover more potentially problemtic file names.  Use the new
+       functions.
+
        Properly handle funny file names for headers in config.status.
        The test suite did not cover this bug because the code was not
        quoting properly the arguments of `rm -f' (which "fails" silently)
index dad0ea8538125e8606812c86a74acf2ad0f91548..bc7a914b002097baa7c249221ef18659f65665c4 100644 (file)
@@ -24,3 +24,29 @@ SED='@SED@'
 
 # We need to know if sh -n is ok.
 ac_cv_sh_n_works='@ac_cv_sh_n_works@'
+
+# Check whether the underlying system can manage some unusual
+# symbols in file names.
+unsupported_fs_chars=
+for c in '\\' '"' '<' '>' '*' '?' '|'
+do
+  touch "t$c" 2>/dev/null
+  test -f "t$c" && rm -f "t$c" && continue
+  # $c cannot be used in a file name.
+  unsupported_fs_chars=$unsupported_fs_chars$c
+done
+if test -z "$unsupported_fs_chars"; then
+  func_sanitize_file_name () { echo "$@"; }
+else
+  func_sanitize_file_name () { echo "$@" | tr -d "$unsupported_fs_chars"; }
+fi
+
+# Can we create directories with trailing whitespaces in their name?
+rm -rf 'tdir /'
+mkdir 'tdir ' && touch 'tdir /tfile' 2>/dev/null
+if test -f 'tdir /tfile'; then
+  func_sanitize_dir_name () { echo "$@"; }
+  rm -rf 'tdir /'
+else
+  func_sanitize_dir_name () { echo "$@" | sed 's/  *$//'; }
+fi
index e5f9ae8faee5b0c3175373501824adc98ca710d5..1b3dca59e6861cb1eb60de44b0b568a0c47ab61e 100644 (file)
@@ -146,15 +146,14 @@ AT_SETUP([autom4te and whitespace in file names])
 x=
 export x
 rm -f a b
-# the first one omits special characters and trailing spaces,
-# which are not w32 safe.
 for funny in \
   'with  funny '\'' $x & #! name' \
   'with  funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock
 do
+  funny=`func_sanitize_file_name "$funny"`
   file=" file $funny"
   outfile="$file out "
-  dir=" dir $funny"
+  dir=`func_sanitize_dir_name " dir $funny"`
   cachedir=" cache$dir"
   TMPDIR=" tmp$dir"
   export TMPDIR
@@ -988,13 +987,13 @@ AT_SETUP([autotools and whitespace in file names])
 x=
 export x
 rm -f a b
-# the first one omits special characters that are not w32 safe.
 for funny in \
   'with  funny '\'' $x & #! name ' \
   'with  funny \ '\'' \'\'' " <a >b * ? name '
 do
+  funny=`func_sanitize_file_name "$funny"`
   file=" file $funny"
-  dir=" dir $funny"
+  dir=`func_sanitize_dir_name " dir $funny"`
   TMPDIR=" tmp$dir"
   export TMPDIR
 
index c052c049775ea03d628f2c9f08dd192baad9dbd3..0eaea17755d701f3b99184fb8c537982a352d87a 100644 (file)
@@ -262,29 +262,37 @@ AT_CHECK_CONFIG_CREATION_NOWRITE(link)
 AT_CHECK([grep ac_write_fail config.status], [1])
 
 # Check that --file and --header accept funny file names
-file='file with  funny \ '\'' \'\'' $ & #!*? name'
-cat >"$file.in" <<'END'
+
+x=
+export x
+for file in \
+  'with  funny '\'' $x & #! name' \
+  'file with  funny \ '\'' \'\'' $ & #!*? name' \
+  'with  funny \ '\'' \'\'' " <a >b & * ? name ' # "restore font-lock
+do
+  # The function func_sanitize_file_name comes from tools.at
+  file=`func_sanitize_file_name "$file"`
+  cat >"$file.in" <<'END'
 OK
 END
-# skip if we cannot create such a file
-AT_CHECK([test -f "$file.in" || exit 77])
-AT_CHECK([./config.status "--file=$file:$file.in"],
-        [0], [ignore])
-AT_CHECK([grep OK "$file"], [], [OK
+  AT_CHECK([./config.status "--file=$file:$file.in"],
+          [0], [ignore])
+  AT_CHECK([grep OK "$file"], [], [OK
 ])
-AT_CHECK([./config.status "--header=$file:$file.in"],
-        [0], [ignore])
-# Run the same test a 2nd time to see that config.status does not recreate
-# the header (regression test)
-AT_CHECK([./config.status "--header=$file:$file.in"],
-        [0], [config.status: creating file with  funny \ ' \' $ & #!*? name
-config.status: file with  funny \ ' \' $ & #!*? name is unchanged
+  AT_CHECK([./config.status "--header=$file:$file.in"],
+          [0], [ignore])
+  # Run the same test a 2nd time to see that config.status does not recreate
+  # the header (regression test)
+  AT_CHECK_NOESCAPE([./config.status "--header=$file:$file.in"],
+                   [0], [config.status: creating $file
+config.status: $file is unchanged
 ])
-AT_CHECK([grep ' & ' "$file"], [],
-[/* file with  funny \ ' \' $ & #!*? name.  Generated from file with  funny \ ' \' $ & #!*? name.in by configure.  */
+  AT_CHECK_NOESCAPE([grep ' & ' "$file"], [],
+[/* $file.  Generated from $file.in by configure.  */
 ])
-AT_CHECK([grep OK "$file"], [], [OK
+  AT_CHECK([grep OK "$file"], [], [OK
 ])
+done
 AT_CLEANUP