aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-11-10 15:17:11 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-11-10 15:24:38 +0200
commitcb76d31808b47783cb0bdac694db5643d1a23b4e (patch)
treedd5e932946529a4189ab9aaac9d590fdf83cc1a2
parent65b51a8d17b2e382dc8c6d0fa5a83da83a34fd36 (diff)
downloadcpio-cb76d31808b47783cb0bdac694db5643d1a23b4e.tar.gz
cpio-cb76d31808b47783cb0bdac694db5643d1a23b4e.tar.bz2
Fix the output of UTF8 file names in verbose mode.
* am/quoting.m4: New file. * configure.ac: Set default quoting style. * src/copyin.c (long_format): Use quotearg. (print_name_with_quoting): Remove. * src/extern.h (print_name_with_quoting): Remove proto.
-rw-r--r--am/quoting.m432
-rw-r--r--configure.ac2
-rw-r--r--src/copyin.c60
-rw-r--r--src/extern.h3
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 @@
1# This file is part of GNU cpio
2# Copyright (C) 2016 Free Software Foundation
3#
4# GNU cpio is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# GNU cpio is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GNU cpio. If not, see <http://www.gnu.org/licenses/>.
16
17# CPIO_DEFAULT_QUOTING_STYLE(style) - set default style for the gnulib
18# quotearg module.
19m4_define([QUOTING_STYLES],dnl
20 [literal|shell|shell-always|c|escape|locale|clocale])
21AC_DEFUN([CPIO_DEFAULT_QUOTING_STYLE],[
22 DEFAULT_QUOTING_STYLE="$1"
23 AC_ARG_VAR([DEFAULT_QUOTING_STYLE],
24 [Set the default quoting style. Allowed values are: ] m4_bpatsubst(QU
25OTING_STYLES,[|], [[, ]]) [. Default is "escape".])
26 case $DEFAULT_QUOTING_STYLE in
27QUOTING_STYLES) ;;
28*) AC_MSG_ERROR(Invalid quoting style);;
29esac
30 DEFAULT_QUOTING_STYLE=`echo ${DEFAULT_QUOTING_STYLE}|sed 's/-/_/g'`_quoting_style
31 AC_DEFINE_UNQUOTED(DEFAULT_QUOTING_STYLE, $DEFAULT_QUOTING_STYLE,
32 [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
59CPIO_SYSDEP 59CPIO_SYSDEP
60CPIO_PACKED_STRUCTS 60CPIO_PACKED_STRUCTS
61 61
62CPIO_DEFAULT_QUOTING_STYLE(escape)
63
62AC_ARG_ENABLE(mt, 64AC_ARG_ENABLE(mt,
63 AC_HELP_STRING([--enable-mt], [Enable building of mt program])) 65 AC_HELP_STRING([--enable-mt], [Enable building of mt program]))
64 66
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)
173 } 173 }
174 else 174 else
175 { 175 {
176 /* Debian hack: Modified to print a list of filenames 176 /* Print out the name as it is. The name_end delimiter is normally
177 terminiated by a null character when the -t and -0 177 '\n', but can be reset to '\0' by the -0 option. */
178 flags are used. This has been submitted as a
179 suggestion to "bug-gnu-utils@prep.ai.mit.edu". -BEM */
180 printf ("%s%c", file_hdr->c_name, name_end); 178 printf ("%s%c", file_hdr->c_name, name_end);
181 } 179 }
182 180
@@ -788,65 +786,15 @@ long_format (struct cpio_file_stat *file_hdr, char *link_name)
788 786
789 printf ("%s ", tbuf + 4); 787 printf ("%s ", tbuf + 4);
790 788
791 print_name_with_quoting (file_hdr->c_name); 789 printf ("%s", quotearg (file_hdr->c_name));
792 if (link_name) 790 if (link_name)
793 { 791 {
794 printf (" -> "); 792 printf (" -> ");
795 print_name_with_quoting (link_name); 793 printf ("%s", quotearg (link_name));
796 } 794 }
797 putc ('\n', stdout); 795 putc ('\n', stdout);
798} 796}
799 797
800void
801print_name_with_quoting (register char *p)
802{
803 register unsigned char c;
804
805 while ( (c = *p++) )
806 {
807 switch (c)
808 {
809 case '\\':
810 printf ("\\\\");
811 break;
812
813 case '\n':
814 printf ("\\n");
815 break;
816
817 case '\b':
818 printf ("\\b");
819 break;
820
821 case '\r':
822 printf ("\\r");
823 break;
824
825 case '\t':
826 printf ("\\t");
827 break;
828
829 case '\f':
830 printf ("\\f");
831 break;
832
833 case ' ':
834 printf ("\\ ");
835 break;
836
837 case '"':
838 printf ("\\\"");
839 break;
840
841 default:
842 if (c > 040 && c < 0177)
843 putchar (c);
844 else
845 printf ("\\%03o", (unsigned int) c);
846 }
847 }
848}
849
850/* Read a pattern file (for the -E option). Put a list of 798/* Read a pattern file (for the -E option). Put a list of
851 `num_patterns' elements in `save_patterns'. Any patterns that were 799 `num_patterns' elements in `save_patterns'. Any patterns that were
852 already in `save_patterns' (from the command line) are preserved. */ 800 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 @@
1/* extern.h - External declarations for cpio. Requires system.h. 1/* extern.h - External declarations for cpio. Requires system.h.
2 Copyright (C) 1990-1992, 2001, 2006-2007, 2009-2010, 2014-2015 Free 2 Copyright (C) 1990-1992, 2001, 2006-2007, 2009-2010, 2014-2016 Free
3 Software Foundation, Inc. 3 Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 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,
112void swab_array (char *arg, int count); 112void swab_array (char *arg, int count);
113void process_copy_in (void); 113void process_copy_in (void);
114void long_format (struct cpio_file_stat *file_hdr, char *link_name); 114void long_format (struct cpio_file_stat *file_hdr, char *link_name);
115void print_name_with_quoting (char *p);
116 115
117/* copyout.c */ 116/* copyout.c */
118int write_out_header (struct cpio_file_stat *file_hdr, int out_des); 117int write_out_header (struct cpio_file_stat *file_hdr, int out_des);

Return to:

Send suggestions and report system problems to the System administrator.