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 /src | |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/copyin.c | 60 | ||||
-rw-r--r-- | src/extern.h | 3 |
2 files changed, 5 insertions, 58 deletions
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); |