diff options
36 files changed, 69 insertions, 66 deletions
diff --git a/applets/individual.c b/applets/individual.c index 4c468df..e94f26c 100644 --- a/applets/individual.c +++ b/applets/individual.c @@ -19,6 +19,6 @@ int main(int argc, char **argv) void bb_show_usage(void) { - fputs(APPLET_full_usage "\n", stdout); + fputs_stdout(APPLET_full_usage "\n"); exit(EXIT_FAILURE); } diff --git a/coreutils/cat.c b/coreutils/cat.c index dae6089..4b34149 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c @@ -152,7 +152,7 @@ static int catv(unsigned opts, char **argv) eol_seen = (c == eol_char); #endif visible(c, buf, opts); - fputs(buf, stdout); + fputs_stdout(buf); } } if (ENABLE_FEATURE_CLEAN_UP && fd) diff --git a/coreutils/cut.c b/coreutils/cut.c index 1acbb51..16418ff 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -167,7 +167,7 @@ static void cut_file(FILE *file, char delim, const struct cut_list *cut_lists, u * printed */ if (nfields_printed > 0) putchar(delim); - fputs(field, stdout); + fputs_stdout(field); printed[ndelim] = 'X'; nfields_printed++; /* shouldn't overflow.. */ } diff --git a/coreutils/expand.c b/coreutils/expand.c index 5f59939..c5e1de6 100644 --- a/coreutils/expand.c +++ b/coreutils/expand.c @@ -123,7 +123,7 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt) } ptr++; } - fputs(ptr_strbeg, stdout); + fputs_stdout(ptr_strbeg); free(line); } } diff --git a/coreutils/head.c b/coreutils/head.c index 1219dfe..b6efabb 100644 --- a/coreutils/head.c +++ b/coreutils/head.c @@ -117,7 +117,7 @@ print_except_N_last_lines(FILE *fp, unsigned count) char *c; if (head == count) head = 0; - fputs(circle[head], stdout); + fputs_stdout(circle[head]); c = xmalloc_fgets(fp); if (!c) goto ret; diff --git a/coreutils/id.c b/coreutils/id.c index 78d5f2a..f453a87 100644 --- a/coreutils/id.c +++ b/coreutils/id.c @@ -258,7 +258,7 @@ int id_main(int argc UNUSED_PARAM, char **argv) bb_error_msg_and_die("can't get process context%s", username ? " for a different user" : ""); } - fputs(scontext, stdout); + fputs_stdout(scontext); } /* freecon(NULL) seems to be harmless */ if (ENABLE_FEATURE_CLEAN_UP) diff --git a/coreutils/ls.c b/coreutils/ls.c index e5375a6..80ef920 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -453,7 +453,7 @@ static unsigned print_name(const char *name) name = printable_string2(&uni_stat, name); if (!(option_mask32 & OPT_Q)) { - fputs(name, stdout); + fputs_stdout(name); return uni_stat.unicode_width; } diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index d5bd7bf..5b5e56a 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c @@ -422,19 +422,19 @@ print_named_ascii(size_t n_bytes, const char *block, masked_c &= 0x7f; if (masked_c == 0x7f) { - fputs(" del", stdout); + fputs_stdout(" del"); continue; } if (masked_c > ' ') { buf[3] = masked_c; - fputs(buf, stdout); + fputs_stdout(buf); continue; } /* Why? Because printf(" %3.3s") is much slower... */ buf[6] = charname[masked_c][0]; buf[7] = charname[masked_c][1]; buf[8] = charname[masked_c][2]; - fputs(buf+5, stdout); + fputs_stdout(buf+5); } } @@ -451,7 +451,7 @@ print_ascii(size_t n_bytes, const char *block, if (ISPRINT(c)) { buf[3] = c; - fputs(buf, stdout); + fputs_stdout(buf); continue; } switch (c) { @@ -485,7 +485,7 @@ print_ascii(size_t n_bytes, const char *block, buf[8] = (c & 7) + '0'; s = buf + 5; } - fputs(s, stdout); + fputs_stdout(s); } } @@ -881,7 +881,7 @@ format_address_label(off_t address, char c) static void dump_hexl_mode_trailer(size_t n_bytes, const char *block) { - fputs(" >", stdout); + fputs_stdout(" >"); while (n_bytes--) { unsigned c = *(unsigned char *) block++; c = (ISPRINT(c) ? c : '.'); @@ -1121,13 +1121,13 @@ dump_strings(off_t address, off_t end_offset) for (i = 0; (c = buf[i]); i++) { switch (c) { - case '\007': fputs("\\a", stdout); break; - case '\b': fputs("\\b", stdout); break; - case '\f': fputs("\\f", stdout); break; - case '\n': fputs("\\n", stdout); break; - case '\r': fputs("\\r", stdout); break; - case '\t': fputs("\\t", stdout); break; - case '\v': fputs("\\v", stdout); break; + case '\007': fputs_stdout("\\a"); break; + case '\b': fputs_stdout("\\b"); break; + case '\f': fputs_stdout("\\f"); break; + case '\n': fputs_stdout("\\n"); break; + case '\r': fputs_stdout("\\r"); break; + case '\t': fputs_stdout("\\t"); break; + case '\v': fputs_stdout("\\v"); break; default: putchar(c); } } diff --git a/coreutils/paste.c b/coreutils/paste.c index fd2aa50..7def4de 100644 --- a/coreutils/paste.c +++ b/coreutils/paste.c @@ -53,7 +53,7 @@ static void paste_files(FILE** files, int file_cnt, char* delims, int del_cnt) --active_files; continue; } - fputs(line, stdout); + fputs_stdout(line); free(line); delim = '\n'; if (i != file_cnt - 1) { @@ -79,7 +79,7 @@ static void paste_files_separate(FILE** files, char* delims, int del_cnt) line = NULL; while ((next_line = xmalloc_fgetline(files[i])) != NULL) { if (line) { - fputs(line, stdout); + fputs_stdout(line); free(line); delim = delims[del_idx++]; if (del_idx == del_cnt) diff --git a/coreutils/stat.c b/coreutils/stat.c index 073b2c6..a839346 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c @@ -439,7 +439,7 @@ static void print_it(const char *masterformat, /* print preceding string */ *p = '\0'; - fputs(b, stdout); + fputs_stdout(b); p += len; b = p + 1; diff --git a/coreutils/stty.c b/coreutils/stty.c index 1925396..ba2b783 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c @@ -855,7 +855,7 @@ static void wrapf(const char *message, ...) } } } - fputs(buf, stdout); + fputs_stdout(buf); G.current_col += buflen; if (buf[buflen-1] == '\n') G.current_col = 0; diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 164b208..02b0372 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c @@ -319,7 +319,7 @@ int baseNUM_main(int argc UNUSED_PARAM, char **argv) } if (col == 0) { - fputs(dst_buf, stdout); + fputs_stdout(dst_buf); } else { char *result = dst_buf; if (rem == 0) diff --git a/coreutils/yes.c b/coreutils/yes.c index 9a435a7..0ad2592 100644 --- a/coreutils/yes.c +++ b/coreutils/yes.c @@ -43,7 +43,7 @@ int yes_main(int argc UNUSED_PARAM, char **argv) do { pp = argv; while (1) { - fputs(*pp, stdout); + fputs_stdout(*pp); if (!*++pp) break; putchar(' '); diff --git a/editors/ed.c b/editors/ed.c index d3ae8da..c50faee 100644 --- a/editors/ed.c +++ b/editors/ed.c @@ -553,7 +553,7 @@ static int printLines(int num1, int num2, int expandFlag) fputc_printable(ch | PRINTABLE_META, stdout); } - fputs("$\n", stdout); + fputs_stdout("$\n"); setCurNum(num1++); lp = lp->next; diff --git a/editors/vi.c b/editors/vi.c index adfb2b8..458ca62 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -522,7 +522,7 @@ static void show_help(void) static void write1(const char *out) { - fputs(out, stdout); + fputs_stdout(out); } #if ENABLE_FEATURE_VI_WIN_RESIZE diff --git a/include/libbb.h b/include/libbb.h index cb63364..135d911 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -874,6 +874,7 @@ char *xmalloc_substitute_string(const char *src, int count, const char *sub, con int bb_putchar(int ch) FAST_FUNC; /* Note: does not use stdio, writes to fd 2 directly */ int bb_putchar_stderr(char ch) FAST_FUNC; +int fputs_stdout(const char *s) FAST_FUNC; char *xasprintf(const char *format, ...) __attribute__ ((format(printf, 1, 2))) FAST_FUNC RETURNS_MALLOC; char *auto_string(char *str) FAST_FUNC; // gcc-4.1.1 still isn't good enough at optimizing it diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c index 2dcead3..66d6a47 100644 --- a/libbb/bb_askpass.c +++ b/libbb/bb_askpass.c @@ -25,7 +25,7 @@ char* FAST_FUNC bb_ask_noecho(int fd, int timeout, const char *prompt) /* Was buggy: was printing prompt *before* flushing input, * which was upsetting "expect" based scripts of some users. */ - fputs(prompt, stdout); + fputs_stdout(prompt); fflush_all(); tcgetattr(fd, &oldtio); diff --git a/libbb/dump.c b/libbb/dump.c index 1ba1132..fb7849e 100644 --- a/libbb/dump.c +++ b/libbb/dump.c @@ -560,7 +560,7 @@ static void display(priv_dumper_t* dumper) ) { if (dumper->pub.eofstring) { /* xxd support: requested to not pad incomplete blocks */ - fputs(dumper->pub.eofstring, stdout); + fputs_stdout(dumper->pub.eofstring); return; } if (!(pr->flags & (F_TEXT | F_BPAD))) diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 75de88e..367396b 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -312,7 +312,7 @@ static void BB_PUTCHAR(wchar_t c) ssize_t len = wcrtomb(buf, c, &mbst); if (len > 0) { buf[len] = '\0'; - fputs(buf, stdout); + fputs_stdout(buf); } } else { /* In this case, c is always one byte */ @@ -460,7 +460,7 @@ static void beep(void) */ static void put_prompt_custom(bool is_full) { - fputs((is_full ? cmdedit_prompt : prompt_last_line), stdout); + fputs_stdout((is_full ? cmdedit_prompt : prompt_last_line)); cursor = 0; cmdedit_y = cmdedit_prmt_len / cmdedit_termw; /* new quasireal y */ cmdedit_x = cmdedit_prmt_len % cmdedit_termw; @@ -1851,7 +1851,7 @@ static void ask_terminal(void) pfd.events = POLLIN; if (safe_poll(&pfd, 1, 0) == 0) { S.sent_ESC_br6n = 1; - fputs(ESC"[6n", stdout); + fputs_stdout(ESC"[6n"); fflush_all(); /* make terminal see it ASAP! */ } } @@ -2957,7 +2957,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman #undef read_line_input int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize) { - fputs(prompt, stdout); + fputs_stdout(prompt); fflush_all(); if (!fgets(command, maxsize, stdin)) return -1; diff --git a/libbb/login.c b/libbb/login.c index 7f593d8..af860c2 100644 --- a/libbb/login.c +++ b/libbb/login.c @@ -120,7 +120,7 @@ void FAST_FUNC print_login_issue(const char *issue_file, const char *tty) buf[0] = c; } } - fputs(outbuf, stdout); + fputs_stdout(outbuf); } fclose(fp); fflush_all(); @@ -130,8 +130,8 @@ void FAST_FUNC print_login_prompt(void) { char *hostname = safe_gethostname(); - fputs(hostname, stdout); - fputs(LOGIN, stdout); + fputs_stdout(hostname); + fputs_stdout(LOGIN); fflush_all(); free(hostname); } diff --git a/libbb/print_numbered_lines.c b/libbb/print_numbered_lines.c index 4758068..b64f855 100644 --- a/libbb/print_numbered_lines.c +++ b/libbb/print_numbered_lines.c @@ -25,7 +25,7 @@ int FAST_FUNC print_numbered_lines(struct number_state *ns, const char *filename printf("%*u%s", ns->width, N, ns->sep); N += ns->inc; } else if (ns->empty_str) - fputs(ns->empty_str, stdout); + fputs_stdout(ns->empty_str); puts(line); free(line); } diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 99596b9..f0399ca 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -318,6 +318,11 @@ int FAST_FUNC bb_putchar(int ch) return putchar(ch); } +int FAST_FUNC fputs_stdout(const char *s) +{ + return fputs(s, stdout); +} + /* Die with an error message if we can't copy an entire FILE* to stdout, * then close that file. */ void FAST_FUNC xprint_and_close_file(FILE *file) diff --git a/miscutils/bc.c b/miscutils/bc.c index 53eb5c7..02a61ac 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -6448,7 +6448,7 @@ static BC_STATUS zdc_program_printStream(void) char *str; idx = (r->t == XC_RESULT_STR) ? r->d.id.idx : n->rdx; str = *xc_program_str(idx); - fputs(str, stdout); + fputs_stdout(str); } RETURN_STATUS(s); diff --git a/miscutils/conspy.c b/miscutils/conspy.c index fac11d3..21a498d 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c @@ -107,8 +107,8 @@ enum { static void putcsi(const char *s) { - fputs(ESC"[", stdout); - fputs(s, stdout); + fputs_stdout(ESC"["); + fputs_stdout(s); } static void clrscr(void) diff --git a/miscutils/strings.c b/miscutils/strings.c index 51412f4..e4a6822 100644 --- a/miscutils/strings.c +++ b/miscutils/strings.c @@ -92,7 +92,7 @@ int strings_main(int argc UNUSED_PARAM, char **argv) if (option_mask32 & (PRINT_OFFSET | PRINT_RADIX)) { printf(radix_fmt, offset - n); } - fputs(string, stdout); + fputs_stdout(string); } count++; } diff --git a/networking/brctl.c b/networking/brctl.c index f057f9b..e1f3e64 100644 --- a/networking/brctl.c +++ b/networking/brctl.c @@ -156,7 +156,7 @@ static int show_bridge(const char *name, int need_hdr) else if (LONE_CHAR(filedata, '1')) strcpy(filedata, "yes"); - fputs(filedata, stdout); + fputs_stdout(filedata); /* sfx points past "BR/bridge/", turn it into "BR/brif": */ sfx[-4] = 'f'; sfx[-3] = '\0'; diff --git a/networking/httpd.c b/networking/httpd.c index 3cad289..e6757d9 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -2788,12 +2788,12 @@ int httpd_main(int argc UNUSED_PARAM, char **argv) , &verbose ); if (opt & OPT_DECODE_URL) { - fputs(percent_decode_in_place(url_for_decode, /*strict:*/ 0), stdout); + fputs_stdout(percent_decode_in_place(url_for_decode, /*strict:*/ 0)); return 0; } #if ENABLE_FEATURE_HTTPD_ENCODE_URL_STR if (opt & OPT_ENCODE_URL) { - fputs(encodeString(url_for_encode), stdout); + fputs_stdout(encodeString(url_for_encode)); return 0; } #endif diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index dfd84c0..17a8384 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -192,20 +192,20 @@ static NOINLINE int print_linkinfo(const struct nlmsghdr *n) printf("%c link/%s ", _SL_, ll_type_n2a(ifi->ifi_type, b1)); if (tb[IFLA_ADDRESS]) { - fputs(ll_addr_n2a(RTA_DATA(tb[IFLA_ADDRESS]), + fputs_stdout(ll_addr_n2a(RTA_DATA(tb[IFLA_ADDRESS]), RTA_PAYLOAD(tb[IFLA_ADDRESS]), ifi->ifi_type, - b1, sizeof(b1)), stdout); + b1, sizeof(b1))); } if (tb[IFLA_BROADCAST]) { if (ifi->ifi_flags & IFF_POINTOPOINT) printf(" peer "); else printf(" brd "); - fputs(ll_addr_n2a(RTA_DATA(tb[IFLA_BROADCAST]), + fputs_stdout(ll_addr_n2a(RTA_DATA(tb[IFLA_BROADCAST]), RTA_PAYLOAD(tb[IFLA_BROADCAST]), ifi->ifi_type, - b1, sizeof(b1)), stdout); + b1, sizeof(b1))); } } bb_putchar('\n'); @@ -307,9 +307,7 @@ static int FAST_FUNC print_addrinfo(const struct sockaddr_nl *who UNUSED_PARAM, printf(" family %d ", ifa->ifa_family); if (rta_tb[IFA_LOCAL]) { - fputs(rt_addr_n2a(ifa->ifa_family, RTA_DATA(rta_tb[IFA_LOCAL])), - stdout - ); + fputs_stdout(rt_addr_n2a(ifa->ifa_family, RTA_DATA(rta_tb[IFA_LOCAL]))); if (rta_tb[IFA_ADDRESS] == NULL || memcmp(RTA_DATA(rta_tb[IFA_ADDRESS]), RTA_DATA(rta_tb[IFA_LOCAL]), 4) == 0 @@ -363,7 +361,7 @@ static int FAST_FUNC print_addrinfo(const struct sockaddr_nl *who UNUSED_PARAM, if (ifa_flags) printf("flags %02x ", ifa_flags); if (rta_tb[IFA_LABEL]) - fputs((char*)RTA_DATA(rta_tb[IFA_LABEL]), stdout); + fputs_stdout((char*)RTA_DATA(rta_tb[IFA_LABEL])); if (rta_tb[IFA_CACHEINFO]) { struct ifa_cacheinfo *ci = RTA_DATA(rta_tb[IFA_CACHEINFO]); char buf[128]; diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index 50acfe4..a23a00d 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c @@ -88,10 +88,9 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, r->rtm_src_len ); } else { - fputs(format_host(r->rtm_family, + fputs_stdout(format_host(r->rtm_family, RTA_PAYLOAD(tb[RTA_SRC]), - RTA_DATA(tb[RTA_SRC])), - stdout + RTA_DATA(tb[RTA_SRC])) ); } } else if (r->rtm_src_len) { @@ -178,7 +177,7 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, } else printf("masquerade"); } else if (r->rtm_type != RTN_UNICAST) - fputs(rtnl_rtntype_n2a(r->rtm_type), stdout); + fputs_stdout(rtnl_rtntype_n2a(r->rtm_type)); bb_putchar('\n'); /*fflush_all();*/ diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index 1e94052..19606c5 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c @@ -112,7 +112,7 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv) printf("%02u:%02u:%02u\n", h, m, (unsigned)expires); } else { /* -a */ time_t t = expires_abs; - fputs(ctime(&t), stdout); + fputs_stdout(ctime(&t)); } } /* close(fd); */ diff --git a/procps/powertop.c b/procps/powertop.c index d508b5f..fc6018b 100644 --- a/procps/powertop.c +++ b/procps/powertop.c @@ -818,7 +818,7 @@ int powertop_main(int argc UNUSED_PARAM, char UNUSED_PARAM **argv) for (i = 0; i < MAX_CSTATE_COUNT + 2; i++) if (cstate_lines[i][0]) - fputs(cstate_lines[i], stdout); + fputs_stdout(cstate_lines[i]); i = process_timer_stats(); #if ENABLE_FEATURE_POWERTOP_PROCIRQ diff --git a/procps/top.c b/procps/top.c index 8d39526..cadc4ec 100644 --- a/procps/top.c +++ b/procps/top.c @@ -712,7 +712,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) ); if ((int)(scr_width - col) > 1) read_cmdline(line_buf + col, scr_width - col, s->pid, s->comm); - fputs(line_buf, stdout); + fputs_stdout(line_buf); /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu, cur_jif.busy - prev_jif.busy, cur_jif.total - prev_jif.total); */ s++; diff --git a/shell/hush.c b/shell/hush.c index 77f90f8..5eb6fa3 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2692,7 +2692,7 @@ static int get_user_input(struct in_str *i) * Without check_and_run_traps, handler never runs. */ check_and_run_traps(); - fputs(prompt_str, stdout); + fputs_stdout(prompt_str); fflush_all(); } r = hfgetc(i->file); diff --git a/sysklogd/logread.c b/sysklogd/logread.c index b52dc9c..d5f8ca0 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c @@ -205,7 +205,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv) cur = shbuf_tail; #else while (cur != shbuf_tail) { - fputs(shbuf_data + cur, stdout); + fputs_stdout(shbuf_data + cur); cur += strlen(shbuf_data + cur) + 1; if (cur >= shbuf_size) cur = 0; @@ -217,7 +217,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv) #if ENABLE_FEATURE_LOGREAD_REDUCED_LOCKING for (i = 0; i < len_total; i += strlen(copy + i) + 1) { - fputs(copy + i, stdout); + fputs_stdout(copy + i); } free(copy); #endif diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c index e884e3d..4c30f31 100644 --- a/util-linux/fdisk_gpt.c +++ b/util-linux/fdisk_gpt.c @@ -87,7 +87,7 @@ gpt_print_wide36(uint16_t *s) } wc[i] = 0; if (wcstombs(buf, wc, sizeof(buf)) <= sizeof(buf)-1) - fputs(printable_string(buf), stdout); + fputs_stdout(printable_string(buf)); #else char buf[37]; int i = 0; @@ -98,7 +98,7 @@ gpt_print_wide36(uint16_t *s) i++; } buf[i] = '\0'; - fputs(buf, stdout); + fputs_stdout(buf); #endif } diff --git a/util-linux/rev.c b/util-linux/rev.c index ede4fbc..d439b4d 100644 --- a/util-linux/rev.c +++ b/util-linux/rev.c @@ -108,7 +108,7 @@ int rev_main(int argc UNUSED_PARAM, char **argv) #else strrev(buf, strlen(buf)); #endif - fputs(buf, stdout); + fputs_stdout(buf); } fclose(fp); } while (*argv); |