diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-11-10 15:17:11 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-11-10 15:24:38 +0200 |
commit | cb76d31808b47783cb0bdac694db5643d1a23b4e (patch) | |
tree | dd5e932946529a4189ab9aaac9d590fdf83cc1a2 | |
parent | 65b51a8d17b2e382dc8c6d0fa5a83da83a34fd36 (diff) | |
download | cpio-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.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 @@ | |||
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. | ||
19 | m4_define([QUOTING_STYLES],dnl | ||
20 | [literal|shell|shell-always|c|escape|locale|clocale]) | ||
21 | AC_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 | ||
25 | OTING_STYLES,[|], [[, ]]) [. Default is "escape".]) | ||
26 | case $DEFAULT_QUOTING_STYLE in | ||
27 | QUOTING_STYLES) ;; | ||
28 | *) AC_MSG_ERROR(Invalid quoting style);; | ||
29 | esac | ||
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 | |||
@@ -56,12 +56,14 @@ gl_INIT | |||
56 | # paxutils modules | 56 | # paxutils modules |
57 | cpio_PAXUTILS | 57 | cpio_PAXUTILS |
58 | # Additional system dependencies (for mingw) | 58 | # Additional system dependencies (for mingw) |
59 | CPIO_SYSDEP | 59 | CPIO_SYSDEP |
60 | CPIO_PACKED_STRUCTS | 60 | CPIO_PACKED_STRUCTS |
61 | 61 | ||
62 | CPIO_DEFAULT_QUOTING_STYLE(escape) | ||
63 | |||
62 | AC_ARG_ENABLE(mt, | 64 | AC_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 | ||
65 | AM_CONDITIONAL([CPIO_MT_COND], [test "$enable_mt" = yes]) | 67 | AM_CONDITIONAL([CPIO_MT_COND], [test "$enable_mt" = yes]) |
66 | 68 | ||
67 | AC_CHECK_HEADERS([unistd.h stdlib.h string.h fcntl.h pwd.h grp.h sys/io/trioctl.h utmp.h getopt.h locale.h libintl.h sys/wait.h utime.h locale.h process.h sys/ioctl.h]) | 69 | AC_CHECK_HEADERS([unistd.h stdlib.h string.h fcntl.h pwd.h grp.h sys/io/trioctl.h utmp.h getopt.h locale.h libintl.h sys/wait.h utime.h locale.h process.h sys/ioctl.h]) |
diff --git a/src/copyin.c b/src/copyin.c index 05279d2..99d9cdb 100644 --- a/src/copyin.c +++ b/src/copyin.c | |||
@@ -170,16 +170,14 @@ list_file (struct cpio_file_stat* file_hdr, int in_file_des) | |||
170 | else | 170 | else |
171 | #endif | 171 | #endif |
172 | long_format (file_hdr, (char *) 0); | 172 | long_format (file_hdr, (char *) 0); |
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 | ||
183 | crc = 0; | 181 | crc = 0; |
184 | tape_toss_input (in_file_des, file_hdr->c_filesize); | 182 | tape_toss_input (in_file_des, file_hdr->c_filesize); |
185 | tape_skip_padding (in_file_des, file_hdr->c_filesize); | 183 | tape_skip_padding (in_file_des, file_hdr->c_filesize); |
@@ -785,71 +783,21 @@ long_format (struct cpio_file_stat *file_hdr, char *link_name) | |||
785 | file_hdr->c_rdev_min); | 783 | file_hdr->c_rdev_min); |
786 | else | 784 | else |
787 | printf ("%8"PRIuMAX" ", (uintmax_t) file_hdr->c_filesize); | 785 | printf ("%8"PRIuMAX" ", (uintmax_t) file_hdr->c_filesize); |
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 | ||
800 | void | ||
801 | print_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. */ |
853 | 801 | ||
854 | static void | 802 | static void |
855 | read_pattern_file () | 803 | read_pattern_file () |
diff --git a/src/extern.h b/src/extern.h index e27d662..8339050 100644 --- a/src/extern.h +++ b/src/extern.h | |||
@@ -1,8 +1,8 @@ | |||
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 |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 3, or (at your option) | 7 | the Free Software Foundation; either version 3, or (at your option) |
8 | any later version. | 8 | any later version. |
@@ -109,13 +109,12 @@ void read_in_old_ascii (struct cpio_file_stat *file_hdr, int in_des); | |||
109 | void read_in_new_ascii (struct cpio_file_stat *file_hdr, int in_des); | 109 | void read_in_new_ascii (struct cpio_file_stat *file_hdr, int in_des); |
110 | void read_in_binary (struct cpio_file_stat *file_hdr, | 110 | void read_in_binary (struct cpio_file_stat *file_hdr, |
111 | struct old_cpio_header *short_hdr, int in_des); | 111 | struct old_cpio_header *short_hdr, int in_des); |
112 | void swab_array (char *arg, int count); | 112 | void swab_array (char *arg, int count); |
113 | void process_copy_in (void); | 113 | void process_copy_in (void); |
114 | void long_format (struct cpio_file_stat *file_hdr, char *link_name); | 114 | void long_format (struct cpio_file_stat *file_hdr, char *link_name); |
115 | void print_name_with_quoting (char *p); | ||
116 | 115 | ||
117 | /* copyout.c */ | 116 | /* copyout.c */ |
118 | int write_out_header (struct cpio_file_stat *file_hdr, int out_des); | 117 | int write_out_header (struct cpio_file_stat *file_hdr, int out_des); |
119 | void process_copy_out (void); | 118 | void process_copy_out (void); |
120 | 119 | ||
121 | /* copypass.c */ | 120 | /* copypass.c */ |