autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Be nice with file systems that don't handle unusual characters.


From: Ralf Wildenhues
Subject: [PATCH] Be nice with file systems that don't handle unusual characters.
Date: Sun, 2 Mar 2008 13:08:44 +0100
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

        * 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 <address@hidden>
Signed-off-by: Ralf Wildenhues <address@hidden>
---

Changes in this patch over the previous version:
- unsupported_fs_chars gets \\ added instead of \ if that is problematic
  (this escaping is needed for tr).
- superfluous backslashes in the tr command arguments dropped


 ChangeLog        |    9 +++++++++
 tests/atlocal.in |   26 ++++++++++++++++++++++++++
 tests/tools.at   |    9 ++++-----
 tests/torture.at |   42 +++++++++++++++++++++++++-----------------
 4 files changed, 64 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c480adf..b247fd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-03-01  Benoit Sigoure  <address@hidden>
 
+       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)
diff --git a/tests/atlocal.in b/tests/atlocal.in
index dad0ea8..bc7a914 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -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
diff --git a/tests/tools.at b/tests/tools.at
index e5f9ae8..1b3dca5 100644
--- a/tests/tools.at
+++ b/tests/tools.at
@@ -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
 
diff --git a/tests/torture.at b/tests/torture.at
index c052c04..0eaea17 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -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
 
 
-- 
1.5.4.rc5.2.g3ed9a




reply via email to

[Prev in Thread] Current Thread [Next in Thread]