aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/unzip.c57
-rw-r--r--coreutils/ls.c4
-rw-r--r--include/libbb.h3
-rw-r--r--libbb/lineedit.c2
-rw-r--r--libbb/printable_string.c7
-rw-r--r--libbb/unicode.c2
-rw-r--r--util-linux/fdisk_gpt.c2
7 files changed, 50 insertions, 27 deletions
diff --git a/archival/unzip.c b/archival/unzip.c
index 96b7ab69b..c406d53c4 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -153,15 +153,15 @@ typedef union {
153#define FIX_ENDIANNESS_CDF(cdf) \ 153#define FIX_ENDIANNESS_CDF(cdf) \
154do { if (BB_BIG_ENDIAN) { \ 154do { if (BB_BIG_ENDIAN) { \
155 (cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \ 155 (cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \
156 (cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed); \ 156 (cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed ); \
157 (cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \ 157 (cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \
158 (cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \ 158 (cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \
159 (cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \ 159 (cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \
160 (cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \ 160 (cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \
161 (cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \ 161 (cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \
162 (cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \ 162 (cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \
163 (cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len); \ 163 (cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len ); \
164 (cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \ 164 (cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \
165 (cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \ 165 (cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \
166 (cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \ 166 (cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \
167}} while (0) 167}} while (0)
@@ -456,7 +456,9 @@ static int get_lstat_mode(const char *dst_fn)
456 struct stat stat_buf; 456 struct stat stat_buf;
457 if (lstat(dst_fn, &stat_buf) == -1) { 457 if (lstat(dst_fn, &stat_buf) == -1) {
458 if (errno != ENOENT) { 458 if (errno != ENOENT) {
459 bb_perror_msg_and_die("can't stat '%s'", dst_fn); 459 bb_perror_msg_and_die("can't stat '%s'",
460 dst_fn
461 );
460 } 462 }
461 /* File does not exist */ 463 /* File does not exist */
462 return -1; 464 return -1;
@@ -634,7 +636,9 @@ int unzip_main(int argc, char **argv)
634 break; 636 break;
635 if (++i > 2) { 637 if (++i > 2) {
636 *ext = '\0'; 638 *ext = '\0';
637 bb_error_msg_and_die("can't open %s[.zip]", src_fn); 639 bb_error_msg_and_die("can't open %s[.zip]",
640 src_fn
641 );
638 } 642 }
639 strcpy(ext, extn[i - 1]); 643 strcpy(ext, extn[i - 1]);
640 } 644 }
@@ -646,8 +650,11 @@ int unzip_main(int argc, char **argv)
646 xchdir(base_dir); 650 xchdir(base_dir);
647 651
648 if (quiet <= 1) { /* not -qq */ 652 if (quiet <= 1) { /* not -qq */
649 if (quiet == 0) 653 if (quiet == 0) {
650 printf("Archive: %s\n", src_fn); 654 printf("Archive: %s\n",
655 printable_string(src_fn)
656 );
657 }
651 if (opts & OPT_l) { 658 if (opts & OPT_l) {
652 puts(verbose ? 659 puts(verbose ?
653 " Length Method Size Cmpr Date Time CRC-32 Name\n" 660 " Length Method Size Cmpr Date Time CRC-32 Name\n"
@@ -831,7 +838,8 @@ int unzip_main(int argc, char **argv)
831 printf( "%9u " "%s " "%s\n", 838 printf( "%9u " "%s " "%s\n",
832 (unsigned)zip.fmt.ucmpsize, 839 (unsigned)zip.fmt.ucmpsize,
833 dtbuf, 840 dtbuf,
834 dst_fn); 841 printable_string(dst_fn)
842 );
835 } else { 843 } else {
836 char method6[7]; 844 char method6[7];
837 unsigned long percents; 845 unsigned long percents;
@@ -860,7 +868,8 @@ int unzip_main(int argc, char **argv)
860 (unsigned)percents, 868 (unsigned)percents,
861 dtbuf, 869 dtbuf,
862 zip.fmt.crc32, 870 zip.fmt.crc32,
863 dst_fn); 871 printable_string(dst_fn)
872 );
864 total_size += zip.fmt.cmpsize; 873 total_size += zip.fmt.cmpsize;
865 } 874 }
866 total_usize += zip.fmt.ucmpsize; 875 total_usize += zip.fmt.ucmpsize;
@@ -886,7 +895,7 @@ int unzip_main(int argc, char **argv)
886 mode = get_lstat_mode(dst_fn); 895 mode = get_lstat_mode(dst_fn);
887 if (mode == -1) { /* ENOENT */ 896 if (mode == -1) { /* ENOENT */
888 if (!quiet) { 897 if (!quiet) {
889 printf(" creating: %s\n", dst_fn); 898 printf(" creating: %s\n", printable_string(dst_fn));
890 } 899 }
891 unzip_create_leading_dirs(dst_fn); 900 unzip_create_leading_dirs(dst_fn);
892 if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) { 901 if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) {
@@ -895,7 +904,9 @@ int unzip_main(int argc, char **argv)
895 } else { 904 } else {
896 if (!S_ISDIR(mode)) { 905 if (!S_ISDIR(mode)) {
897 bb_error_msg_and_die("'%s' exists but is not a %s", 906 bb_error_msg_and_die("'%s' exists but is not a %s",
898 dst_fn, "directory"); 907 printable_string(dst_fn),
908 "directory"
909 );
899 } 910 }
900 } 911 }
901 goto skip_cmpsize; 912 goto skip_cmpsize;
@@ -914,12 +925,16 @@ int unzip_main(int argc, char **argv)
914 if (!S_ISREG(mode)) { 925 if (!S_ISREG(mode)) {
915 fishy: 926 fishy:
916 bb_error_msg_and_die("'%s' exists but is not a %s", 927 bb_error_msg_and_die("'%s' exists but is not a %s",
917 dst_fn, "regular file"); 928 printable_string(dst_fn),
929 "regular file"
930 );
918 } 931 }
919 if (overwrite == O_ALWAYS) { 932 if (overwrite == O_ALWAYS) {
920 goto do_open_and_extract; 933 goto do_open_and_extract;
921 } 934 }
922 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); 935 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ",
936 printable_string(dst_fn)
937 );
923 my_fgets80(key_buf); 938 my_fgets80(key_buf);
924 /* User input could take a long time. Is it still a regular file? */ 939 /* User input could take a long time. Is it still a regular file? */
925 mode = get_lstat_mode(dst_fn); 940 mode = get_lstat_mode(dst_fn);
@@ -949,7 +964,9 @@ int unzip_main(int argc, char **argv)
949 if (!quiet) { 964 if (!quiet) {
950 printf(/* zip.fmt.method == 0 965 printf(/* zip.fmt.method == 0
951 ? " extracting: %s\n" 966 ? " extracting: %s\n"
952 : */ " inflating: %s\n", dst_fn); 967 : */ " inflating: %s\n",
968 printable_string(dst_fn)
969 );
953 } 970 }
954#if ENABLE_FEATURE_UNZIP_CDF 971#if ENABLE_FEATURE_UNZIP_CDF
955 if (S_ISLNK(file_mode)) { 972 if (S_ISLNK(file_mode)) {
diff --git a/coreutils/ls.c b/coreutils/ls.c
index b1c306809..db3ddb944 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -421,7 +421,7 @@ static unsigned calc_name_len(const char *name)
421 uni_stat_t uni_stat; 421 uni_stat_t uni_stat;
422 422
423 // TODO: quote tab as \t, etc, if -Q 423 // TODO: quote tab as \t, etc, if -Q
424 name = printable_string(&uni_stat, name); 424 name = printable_string2(&uni_stat, name);
425 425
426 if (!(option_mask32 & OPT_Q)) { 426 if (!(option_mask32 & OPT_Q)) {
427 return uni_stat.unicode_width; 427 return uni_stat.unicode_width;
@@ -450,7 +450,7 @@ static unsigned print_name(const char *name)
450 uni_stat_t uni_stat; 450 uni_stat_t uni_stat;
451 451
452 // TODO: quote tab as \t, etc, if -Q 452 // TODO: quote tab as \t, etc, if -Q
453 name = printable_string(&uni_stat, name); 453 name = printable_string2(&uni_stat, name);
454 454
455 if (!(option_mask32 & OPT_Q)) { 455 if (!(option_mask32 & OPT_Q)) {
456 fputs(name, stdout); 456 fputs(name, stdout);
diff --git a/include/libbb.h b/include/libbb.h
index 61fa1e03e..140404ff5 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -833,7 +833,8 @@ typedef struct uni_stat_t {
833} uni_stat_t; 833} uni_stat_t;
834/* Returns a string with unprintable chars replaced by '?' or 834/* Returns a string with unprintable chars replaced by '?' or
835 * SUBST_WCHAR. This function is unicode-aware. */ 835 * SUBST_WCHAR. This function is unicode-aware. */
836const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str); 836const char* FAST_FUNC printable_string(const char *str);
837const char* FAST_FUNC printable_string2(uni_stat_t *stats, const char *str);
837/* Prints unprintable char ch as ^C or M-c to file 838/* Prints unprintable char ch as ^C or M-c to file
838 * (M-c is used only if ch is ORed with PRINTABLE_META), 839 * (M-c is used only if ch is ORed with PRINTABLE_META),
839 * else it is printed as-is (except for ch = 0x9b) */ 840 * else it is printed as-is (except for ch = 0x9b) */
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index d5e92e84c..b1e971f88 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1086,7 +1086,7 @@ static void showfiles(void)
1086 ); 1086 );
1087 } 1087 }
1088 if (ENABLE_UNICODE_SUPPORT) 1088 if (ENABLE_UNICODE_SUPPORT)
1089 puts(printable_string(NULL, matches[n])); 1089 puts(printable_string(matches[n]));
1090 else 1090 else
1091 puts(matches[n]); 1091 puts(matches[n]);
1092 } 1092 }
diff --git a/libbb/printable_string.c b/libbb/printable_string.c
index 077d58d32..a814fd03c 100644
--- a/libbb/printable_string.c
+++ b/libbb/printable_string.c
@@ -9,7 +9,7 @@
9#include "libbb.h" 9#include "libbb.h"
10#include "unicode.h" 10#include "unicode.h"
11 11
12const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str) 12const char* FAST_FUNC printable_string2(uni_stat_t *stats, const char *str)
13{ 13{
14 char *dst; 14 char *dst;
15 const char *s; 15 const char *s;
@@ -55,3 +55,8 @@ const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str)
55#endif 55#endif
56 return auto_string(dst); 56 return auto_string(dst);
57} 57}
58
59const char* FAST_FUNC printable_string(const char *str)
60{
61 return printable_string2(NULL, str);
62}
diff --git a/libbb/unicode.c b/libbb/unicode.c
index d378175a4..89d42179b 100644
--- a/libbb/unicode.c
+++ b/libbb/unicode.c
@@ -996,7 +996,7 @@ size_t FAST_FUNC unicode_strlen(const char *string)
996size_t FAST_FUNC unicode_strwidth(const char *string) 996size_t FAST_FUNC unicode_strwidth(const char *string)
997{ 997{
998 uni_stat_t uni_stat; 998 uni_stat_t uni_stat;
999 printable_string(&uni_stat, string); 999 printable_string2(&uni_stat, string);
1000 return uni_stat.unicode_width; 1000 return uni_stat.unicode_width;
1001} 1001}
1002 1002
diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c
index cdb90627d..dbe889f7c 100644
--- a/util-linux/fdisk_gpt.c
+++ b/util-linux/fdisk_gpt.c
@@ -87,7 +87,7 @@ gpt_print_wide36(uint16_t *s)
87 } 87 }
88 wc[i] = 0; 88 wc[i] = 0;
89 if (wcstombs(buf, wc, sizeof(buf)) <= sizeof(buf)-1) 89 if (wcstombs(buf, wc, sizeof(buf)) <= sizeof(buf)-1)
90 fputs(printable_string(NULL, buf), stdout); 90 fputs(printable_string(buf), stdout);
91#else 91#else
92 char buf[37]; 92 char buf[37];
93 int i = 0; 93 int i = 0;