*: reuse more strings

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2013-01-22 10:13:52 +01:00
parent 6aab061d2d
commit 778794d1dd
3 changed files with 17 additions and 17 deletions

View File

@ -626,7 +626,7 @@ int unzip_main(int argc, char **argv)
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
fflush_all(); fflush_all();
if (!fgets(key_buf, sizeof(key_buf), stdin)) { if (!fgets(key_buf, sizeof(key_buf), stdin)) {
bb_perror_msg_and_die("can't read input"); bb_perror_msg_and_die("can't read standard input");
} }
i = key_buf[0]; i = key_buf[0];
} }
@ -669,7 +669,7 @@ int unzip_main(int argc, char **argv)
/* Prompt for new name */ /* Prompt for new name */
printf("new name: "); printf("new name: ");
if (!fgets(key_buf, sizeof(key_buf), stdin)) { if (!fgets(key_buf, sizeof(key_buf), stdin)) {
bb_perror_msg_and_die("can't read input"); bb_perror_msg_and_die("can't read standard input");
} }
free(dst_fn); free(dst_fn);
dst_fn = xstrdup(key_buf); dst_fn = xstrdup(key_buf);

View File

@ -1049,7 +1049,7 @@ static void colon(char *buf)
#endif #endif
// how many lines in text[]? // how many lines in text[]?
li = count_lines(text, end - 1); li = count_lines(text, end - 1);
status_line("\"%s\"%s" status_line("'%s'%s"
IF_FEATURE_VI_READONLY("%s") IF_FEATURE_VI_READONLY("%s")
" %dL, %dC", current_filename, " %dL, %dC", current_filename,
(file_size(fn) < 0 ? " [New file]" : ""), (file_size(fn) < 0 ? " [New file]" : ""),
@ -1165,7 +1165,7 @@ static void colon(char *buf)
goto ret; // nothing was inserted goto ret; // nothing was inserted
// how many lines in text[]? // how many lines in text[]?
li = count_lines(q, q + ch - 1); li = count_lines(q, q + ch - 1);
status_line("\"%s\"" status_line("'%s'"
IF_FEATURE_VI_READONLY("%s") IF_FEATURE_VI_READONLY("%s")
" %dL, %dC", fn, " %dL, %dC", fn,
IF_FEATURE_VI_READONLY((readonly_mode ? " [Readonly]" : ""),) IF_FEATURE_VI_READONLY((readonly_mode ? " [Readonly]" : ""),)
@ -1298,7 +1298,7 @@ static void colon(char *buf)
} }
#if ENABLE_FEATURE_VI_READONLY #if ENABLE_FEATURE_VI_READONLY
if (readonly_mode && !useforce) { if (readonly_mode && !useforce) {
status_line_bold("\"%s\" File is read only", fn); status_line_bold("'%s' is read only", fn);
goto ret; goto ret;
} }
#endif #endif
@ -1321,9 +1321,9 @@ static void colon(char *buf)
} }
if (l < 0) { if (l < 0) {
if (l == -1) if (l == -1)
status_line_bold("\"%s\" %s", fn, strerror(errno)); status_line_bold("'%s' %s", fn, strerror(errno));
} else { } else {
status_line("\"%s\" %dL, %dC", fn, li, l); status_line("'%s' %dL, %dC", fn, li, l);
if (q == text && r == end - 1 && l == ch) { if (q == text && r == end - 1 && l == ch) {
file_modified = 0; file_modified = 0;
last_file_modified = -1; last_file_modified = -1;
@ -1735,7 +1735,7 @@ static char *char_search(char *p, const char *pat, int dir, int range)
q = (char *)re_compile_pattern(pat, strlen(pat), (struct re_pattern_buffer *)&preg); q = (char *)re_compile_pattern(pat, strlen(pat), (struct re_pattern_buffer *)&preg);
if (q != 0) { if (q != 0) {
// The pattern was not compiled // The pattern was not compiled
status_line_bold("bad search pattern: \"%s\": %s", pat, q); status_line_bold("bad search pattern: '%s': %s", pat, q);
i = 0; // return p if pattern not compiled i = 0; // return p if pattern not compiled
goto cs1; goto cs1;
} }
@ -2503,12 +2503,12 @@ static int file_insert(const char *fn, char *p, int update_ro_status)
/* Validate file */ /* Validate file */
if (stat(fn, &statbuf) < 0) { if (stat(fn, &statbuf) < 0) {
status_line_bold("\"%s\" %s", fn, strerror(errno)); status_line_bold("'%s' %s", fn, strerror(errno));
goto fi0; goto fi0;
} }
if (!S_ISREG(statbuf.st_mode)) { if (!S_ISREG(statbuf.st_mode)) {
// This is not a regular file // This is not a regular file
status_line_bold("\"%s\" Not a regular file", fn); status_line_bold("'%s' is not a regular file", fn);
goto fi0; goto fi0;
} }
if (p < text || p > end) { if (p < text || p > end) {
@ -2519,19 +2519,19 @@ static int file_insert(const char *fn, char *p, int update_ro_status)
// read file to buffer // read file to buffer
fd = open(fn, O_RDONLY); fd = open(fn, O_RDONLY);
if (fd < 0) { if (fd < 0) {
status_line_bold("\"%s\" %s", fn, strerror(errno)); status_line_bold("'%s' %s", fn, strerror(errno));
goto fi0; goto fi0;
} }
size = statbuf.st_size; size = (statbuf.st_size < INT_MAX ? (int)statbuf.st_size : INT_MAX);
p += text_hole_make(p, size); p += text_hole_make(p, size);
cnt = safe_read(fd, p, size); cnt = safe_read(fd, p, size);
if (cnt < 0) { if (cnt < 0) {
status_line_bold("\"%s\" %s", fn, strerror(errno)); status_line_bold("'%s' %s", fn, strerror(errno));
p = text_hole_delete(p, p + size - 1); // un-do buffer insert p = text_hole_delete(p, p + size - 1); // un-do buffer insert
} else if (cnt < size) { } else if (cnt < size) {
// There was a partial read, shrink unused space text[] // There was a partial read, shrink unused space text[]
p = text_hole_delete(p + cnt, p + (size - cnt) - 1); // un-do buffer insert p = text_hole_delete(p + cnt, p + (size - cnt) - 1); // un-do buffer insert
status_line_bold("can't read all of file \"%s\"", fn); status_line_bold("can't read '%s'", fn);
} }
if (cnt >= size) if (cnt >= size)
file_modified++; file_modified++;
@ -3469,7 +3469,7 @@ static void do_cmd(int c)
} else { } else {
file_modified = 0; file_modified = 0;
last_file_modified = -1; last_file_modified = -1;
status_line("\"%s\" %dL, %dC", current_filename, count_lines(text, end - 1), cnt); status_line("'%s' %dL, %dC", current_filename, count_lines(text, end - 1), cnt);
if (p[0] == 'x' || p[1] == 'q' || p[1] == 'n' if (p[0] == 'x' || p[1] == 'q' || p[1] == 'n'
|| p[0] == 'X' || p[1] == 'Q' || p[1] == 'N' || p[0] == 'X' || p[1] == 'Q' || p[1] == 'N'
) { ) {
@ -3667,7 +3667,7 @@ static void do_cmd(int c)
} }
if (file_modified) { if (file_modified) {
if (ENABLE_FEATURE_VI_READONLY && readonly_mode) { if (ENABLE_FEATURE_VI_READONLY && readonly_mode) {
status_line_bold("\"%s\" File is read only", current_filename); status_line_bold("'%s' is read only", current_filename);
break; break;
} }
cnt = file_write(current_filename, text, end - 1); cnt = file_write(current_filename, text, end - 1);

View File

@ -294,7 +294,7 @@ static void get_jiffy_counts(void)
* they are used to calculate per process CPU% */ * they are used to calculate per process CPU% */
prev_jif = cur_jif; prev_jif = cur_jif;
if (read_cpu_jiffy(fp, &cur_jif) < 4) if (read_cpu_jiffy(fp, &cur_jif) < 4)
bb_error_msg_and_die("can't read /proc/stat"); bb_error_msg_and_die("can't read '%s'", "/proc/stat");
#if !ENABLE_FEATURE_TOP_SMP_CPU #if !ENABLE_FEATURE_TOP_SMP_CPU
fclose(fp); fclose(fp);