diff options
-rw-r--r-- | am/quoting.m4 | 32 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/copyin.c | 60 | ||||
-rw-r--r-- | src/extern.h | 3 |
4 files changed, 39 insertions, 58 deletions
diff --git a/am/quoting.m4 b/am/quoting.m4 new file mode 100644 index 0000000..1378efb --- /dev/null +++ b/am/quoting.m4 @@ -0,0 +1,32 @@ +# This file is part of GNU cpio +# Copyright (C) 2016 Free Software Foundation +# +# GNU cpio 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, or (at your option) +# any later version. +# +# GNU cpio 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 GNU cpio. If not, see <http://www.gnu.org/licenses/>. + +# CPIO_DEFAULT_QUOTING_STYLE(style) - set default style for the gnulib +# quotearg module. +m4_define([QUOTING_STYLES],dnl + [literal|shell|shell-always|c|escape|locale|clocale]) +AC_DEFUN([CPIO_DEFAULT_QUOTING_STYLE],[ + DEFAULT_QUOTING_STYLE="$1" + AC_ARG_VAR([DEFAULT_QUOTING_STYLE], + [Set the default quoting style. Allowed values are: ] m4_bpatsubst(QU +OTING_STYLES,[|], [[, ]]) [. Default is "escape".]) + case $DEFAULT_QUOTING_STYLE in +QUOTING_STYLES) ;; +*) AC_MSG_ERROR(Invalid quoting style);; +esac + DEFAULT_QUOTING_STYLE=`echo ${DEFAULT_QUOTING_STYLE}|sed 's/-/_/g'`_quoting_style + AC_DEFINE_UNQUOTED(DEFAULT_QUOTING_STYLE, $DEFAULT_QUOTING_STYLE, + [Define to a default quoting style (see lib/quoteargs.c for the list)])]) diff --git a/configure.ac b/configure.ac index 73a5e2b..9bde963 100644 --- a/configure.ac +++ b/configure.ac @@ -59,6 +59,8 @@ cpio_PAXUTILS CPIO_SYSDEP CPIO_PACKED_STRUCTS +CPIO_DEFAULT_QUOTING_STYLE(escape) + AC_ARG_ENABLE(mt, AC_HELP_STRING([--enable-mt], [Enable building of mt program])) diff --git a/src/copyin.c b/src/copyin.c index 05279d2..99d9cdb 100644 --- a/src/copyin.c +++ b/src/copyin.c @@ -173,10 +173,8 @@ list_file (struct cpio_file_stat* file_hdr, int in_file_des) } else { - /* Debian hack: Modified to print a list of filenames - terminiated by a null character when the -t and -0 - flags are used. This has been submitted as a - suggestion to "bug-gnu-utils@prep.ai.mit.edu". -BEM */ + /* Print out the name as it is. The name_end delimiter is normally + '\n', but can be reset to '\0' by the -0 option. */ printf ("%s%c", file_hdr->c_name, name_end); } @@ -788,65 +786,15 @@ long_format (struct cpio_file_stat *file_hdr, char *link_name) printf ("%s ", tbuf + 4); - print_name_with_quoting (file_hdr->c_name); + printf ("%s", quotearg (file_hdr->c_name)); if (link_name) { printf (" -> "); - print_name_with_quoting (link_name); + printf ("%s", quotearg (link_name)); } putc ('\n', stdout); } -void -print_name_with_quoting (register char *p) -{ - register unsigned char c; - - while ( (c = *p++) ) - { - switch (c) - { - case '\\': - printf ("\\\\"); - break; - - case '\n': - printf ("\\n"); - break; - - case '\b': - printf ("\\b"); - break; - - case '\r': - printf ("\\r"); - break; - - case '\t': - printf ("\\t"); - break; - - case '\f': - printf ("\\f"); - break; - - case ' ': - printf ("\\ "); - break; - - case '"': - printf ("\\\""); - break; - - default: - if (c > 040 && c < 0177) - putchar (c); - else - printf ("\\%03o", (unsigned int) c); - } - } -} - /* Read a pattern file (for the -E option). Put a list of `num_patterns' elements in `save_patterns'. Any patterns that were already in `save_patterns' (from the command line) are preserved. */ diff --git a/src/extern.h b/src/extern.h index e27d662..8339050 100644 --- a/src/extern.h +++ b/src/extern.h @@ -1,5 +1,5 @@ /* extern.h - External declarations for cpio. Requires system.h. - Copyright (C) 1990-1992, 2001, 2006-2007, 2009-2010, 2014-2015 Free + Copyright (C) 1990-1992, 2001, 2006-2007, 2009-2010, 2014-2016 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -112,7 +112,6 @@ void read_in_binary (struct cpio_file_stat *file_hdr, void swab_array (char *arg, int count); void process_copy_in (void); void long_format (struct cpio_file_stat *file_hdr, char *link_name); -void print_name_with_quoting (char *p); /* copyout.c */ int write_out_header (struct cpio_file_stat *file_hdr, int out_des); |