Signed-off-by: Alejandro Colomar <[email protected]> --- src/devices/grodvi/dvi.cpp | 6 +- src/devices/grohtml/html-text.cpp | 2 +- src/devices/grohtml/post-html.cpp | 118 +++++++++++++++--------------- src/devices/grolbp/lbp.cpp | 4 +- src/devices/grolj4/lj4.cpp | 4 +- src/devices/grops/ps.cpp | 8 +- src/devices/grotty/tty.cpp | 4 +- src/devices/xditview/Dvi.c | 2 +- src/devices/xditview/device.c | 26 +++---- src/devices/xditview/font.c | 7 +- src/devices/xditview/xditview.c | 16 ++-- src/include/nonposix.h | 2 +- src/include/ptable.h | 8 +- src/libs/libbib/search.cpp | 4 +- src/libs/libdriver/input.cpp | 8 +- src/libs/libdriver/printer.cpp | 4 +- src/libs/libgroff/change_lf.cpp | 2 +- src/libs/libgroff/error.cpp | 2 +- src/libs/libgroff/font.cpp | 84 ++++++++++----------- src/libs/libgroff/localcharset.c | 7 +- src/libs/libgroff/searchpath.cpp | 2 +- src/libs/libgroff/symbol.cpp | 4 +- src/libs/libgroff/tmpname.cpp | 2 +- src/libs/libxutil/DviChar.c | 6 +- src/libs/libxutil/XFontName.c | 2 +- src/preproc/eqn/box.cpp | 6 +- src/preproc/eqn/main.cpp | 8 +- src/preproc/eqn/text.cpp | 6 +- src/preproc/grn/hdb.cpp | 6 +- src/preproc/grn/main.cpp | 10 +-- src/preproc/html/pre-html.cpp | 17 ++--- src/preproc/html/pushback.cpp | 2 +- src/preproc/pic/lex.cpp | 2 +- src/preproc/pic/main.cpp | 4 +- src/preproc/pic/pic.ypp | 10 +-- src/preproc/pic/troff.cpp | 2 +- src/preproc/preconv/preconv.cpp | 6 +- src/preproc/refer/command.cpp | 4 +- src/preproc/refer/refer.cpp | 10 +-- src/preproc/refer/token.cpp | 2 +- src/preproc/soelim/soelim.cpp | 2 +- src/preproc/tbl/table.cpp | 2 +- src/roff/groff/groff.cpp | 19 +++-- src/roff/troff/input.cpp | 62 ++++++++-------- src/utils/addftinfo/addftinfo.cpp | 6 +- src/utils/hpftodit/hpftodit.cpp | 21 +++--- src/utils/indxbib/indxbib.cpp | 6 +- src/utils/tfmtodit/tfmtodit.cpp | 4 +- src/utils/xtotroff/xtotroff.c | 4 +- 49 files changed, 274 insertions(+), 281 deletions(-)
diff --git a/src/devices/grodvi/dvi.cpp b/src/devices/grodvi/dvi.cpp index 399663bf35f4..0fd018f1563d 100644 --- a/src/devices/grodvi/dvi.cpp +++ b/src/devices/grodvi/dvi.cpp @@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> // EOF, FILE, fprintf(), printf(), putc(), setbuf(), // sprintf(), stderr, stdout #include <stdlib.h> // exit(), EXIT_SUCCESS, strtol() -#include <string.h> // strcmp(), strlen() +#include <string.h> // strlen() #include <getopt.h> // getopt_long() @@ -99,7 +99,7 @@ void dvi_font::handle_unknown_font_command(const char *command, int lineno) { char *ptr; - if (strcmp(command, "checksum") == 0) { + if (streq(command, "checksum")) { if (arg == 0) fatal_with_file_and_line(fn, lineno, "'checksum' command requires an argument"); @@ -108,7 +108,7 @@ void dvi_font::handle_unknown_font_command(const char *command, fatal_with_file_and_line(fn, lineno, "bad checksum"); } } - else if (strcmp(command, "designsize") == 0) { + else if (streq(command, "designsize")) { if (arg == 0) fatal_with_file_and_line(fn, lineno, "'designsize' command requires an argument"); diff --git a/src/devices/grohtml/html-text.cpp b/src/devices/grohtml/html-text.cpp index 449c6b7e7dc8..9362dda7b569 100644 --- a/src/devices/grohtml/html-text.cpp +++ b/src/devices/grohtml/html-text.cpp @@ -690,7 +690,7 @@ void html_text::do_para (const char *arg, html_indent *in, int space) if (is_present(PRE_TAG)) { html_indent *i = remove_indent(PRE_TAG); done_pre(); - if ((arg == NULL || (strcmp(arg, "") == 0)) && + if ((arg == NULL || streq(arg, "")) && (i == in || in == NULL)) in = i; else diff --git a/src/devices/grohtml/post-html.cpp b/src/devices/grohtml/post-html.cpp index 3d567d1b48e8..8422d12f806c 100644 --- a/src/devices/grohtml/post-html.cpp +++ b/src/devices/grohtml/post-html.cpp @@ -30,7 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> // EOF, FILE, fclose(), fflush(), fopen(), freopen(), // fseek(), SEEK_SET, setbuf(), stderr, stdout #include <stdlib.h> // abs(), atoi(), EXIT_SUCCESS, exit() -#include <string.h> // strcasecmp(), strcmp(), strerror(), strlen(), +#include <string.h> // strcasecmp(), strerror(), strlen(), // strncmp() #include <time.h> // asctime(), tm @@ -750,7 +750,7 @@ int text_glob::is_a_tag (void) // TODO: boolify int text_glob::is_eol (void) { - return is_tag && (strcmp(text_string, "devtag:.eol") == 0); + return is_tag && streq(text_string, "devtag:.eol"); } /* @@ -760,7 +760,7 @@ int text_glob::is_eol (void) // TODO: boolify int text_glob::is_eol_ce (void) { - return is_tag && (strcmp(text_string, "devtag:eol.ce") == 0); + return is_tag && streq(text_string, "devtag:eol.ce"); } /* @@ -770,7 +770,7 @@ int text_glob::is_eol_ce (void) // TODO: boolify int text_glob::is_tl (void) { - return is_tag && (strcmp(text_string, "devtag:.tl") == 0); + return is_tag && streq(text_string, "devtag:.tl"); } /* @@ -780,7 +780,7 @@ int text_glob::is_tl (void) // TODO: boolify int text_glob::is_eo_tl (void) { - return is_tag && (strcmp(text_string, "devtag:.eo.tl") == 0); + return is_tag && streq(text_string, "devtag:.eo.tl"); } /* @@ -816,7 +816,7 @@ int text_glob::is_fi (void) // TODO: boolify int text_glob::is_eo_h (void) { - return is_tag && (strcmp(text_string, "devtag:.eo.h") == 0); + return is_tag && streq(text_string, "devtag:.eo.h"); } /* @@ -892,7 +892,7 @@ int text_glob::is_col (void) // TODO: boolify int text_glob::is_tab_ts (void) { - return is_tag && (strcmp(text_string, "devtag:.tab-ts") == 0); + return is_tag && streq(text_string, "devtag:.tab-ts"); } /* @@ -902,7 +902,7 @@ int text_glob::is_tab_ts (void) // TODO: boolify int text_glob::is_tab_te (void) { - return is_tag && (strcmp(text_string, "devtag:.tab-te") == 0); + return is_tag && streq(text_string, "devtag:.tab-te"); } /* @@ -959,7 +959,7 @@ int text_glob::is_auto_img (void) // TODO: boolify int text_glob::is_br (void) { - return is_a_tag() && ((strcmp ("devtag:.br", text_string) == 0) + return is_a_tag() && (streq("devtag:.br", text_string) || (strncmp("devtag:.sp", text_string, strlen("devtag:.sp")) == 0)); } @@ -1913,7 +1913,7 @@ void assert_state::add (assert_pos **h, assert_pos *t = *h; while (t != 0 /* nullptr */) { - if (strcmp(t->id, i) == 0) + if (streq(t->id, i)) break; t = t->next; } @@ -1968,7 +1968,7 @@ void assert_state::compare(assert_pos *t, while ((*s) == '=') s++; - if (strcmp(v, s) != 0) { + if (!streq(v, s)) { if (0 /* nullptr */ == f) f = "stdin"; if (0 /* nullptr */ == l) @@ -1982,15 +1982,15 @@ void assert_state::compare(assert_pos *t, void assert_state::close (const char *c) { assert(c != 0 /* nullptr */); - if (strcmp(c, "sp") == 0) + if (streq(c, "sp")) check_sp_flag = 0; - else if (strcmp(c, "br") == 0) + else if (streq(c, "br")) check_br_flag = 0; - else if (strcmp(c, "fi") == 0) + else if (streq(c, "fi")) check_fi_flag = 0; - else if (strcmp(c, "nf") == 0) + else if (streq(c, "nf")) check_fi_flag = 0; - else if (strcmp(c, "ce") == 0) + else if (streq(c, "ce")) check_ce_flag = 0; else fprintf(stderr, "%s: ignoring unrecognized tag '%s'\n", @@ -2039,27 +2039,27 @@ void assert_state::set (const char *c, const char *v, f = "stdin"; // fprintf(stderr, "%s:%s:setting %s to %s\n", f, l, c, v); - if (strcmp(c, "sp") == 0) { + if (streq(c, "sp")) { check_sp_flag = 1; val_sp = replace_str(val_sp, strsave(v)); file_sp = replace_str(file_sp, strsave(f)); line_sp = replace_str(line_sp, strsave(l)); - } else if (strcmp(c, "br") == 0) { + } else if (streq(c, "br")) { check_br_flag = 1; val_br = replace_str(val_br, strsave(v)); file_br = replace_str(file_br, strsave(f)); line_br = replace_str(line_br, strsave(l)); - } else if (strcmp(c, "fi") == 0) { + } else if (streq(c, "fi")) { check_fi_flag = 1; val_fi = replace_str(val_fi, strsave(v)); file_fi = replace_str(file_fi, strsave(f)); line_fi = replace_str(line_fi, strsave(l)); - } else if (strcmp(c, "nf") == 0) { + } else if (streq(c, "nf")) { check_fi_flag = 1; val_fi = replace_negate_str(val_fi, strsave(v)); file_fi = replace_str(file_fi, strsave(f)); line_fi = replace_str(line_fi, strsave(l)); - } else if (strcmp(c, "ce") == 0) { + } else if (streq(c, "ce")) { check_ce_flag = 1; val_ce = replace_str(val_ce, strsave(v)); file_ce = replace_str(file_ce, strsave(f)); @@ -2397,7 +2397,7 @@ int html_printer::is_bold (font *f) // XXX: This property should be inferred from font description data, // not the file name. const char *fontname = f->get_filename(); - return (strcmp(fontname, "B") == 0) || (strcmp(fontname, "BI") == 0); + return streq(fontname, "B") || streq(fontname, "BI"); } /* @@ -2411,11 +2411,11 @@ font *html_printer::make_bold (font *f) // scheme. const char *fontname = f->get_filename(); - if (strcmp(fontname, "B") == 0) + if (streq(fontname, "B")) return f; - if (strcmp(fontname, "I") == 0) + if (streq(fontname, "I")) return font::load_font("BI"); - if (strcmp(fontname, "BI") == 0) + if (streq(fontname, "BI")) return f; return 0 /* nullptr */; } @@ -3188,10 +3188,8 @@ void html_printer::do_check_center(void) else current_paragraph->do_para("class=\"center\"", space); } else - if ((strcmp("align=\"center\"", - current_paragraph->get_alignment()) != 0) - && (strcmp("class=\"center\"", - current_paragraph->get_alignment()) != 0)) { + if (!streq("align=\"center\"", current_paragraph->get_alignment()) + && !streq("class=\"center\"", current_paragraph->get_alignment())) { /* * different alignment, so shutdown paragraph and open * a new one. @@ -3511,11 +3509,11 @@ void html_printer::troff_tag (text_glob *g) seen_break = 1; as.check_br(1); do_break(); - } else if (strcmp(t, ".centered-image") == 0) { + } else if (streq(t, ".centered-image")) { do_centered_image(); - } else if (strcmp(t, ".right-image") == 0) { + } else if (streq(t, ".right-image")) { do_right_image(); - } else if (strcmp(t, ".left-image") == 0) { + } else if (streq(t, ".left-image")) { do_left_image(); } else if (strncmp(t, ".auto-image", 11) == 0) { char *a = t+11; @@ -3557,7 +3555,7 @@ void html_printer::troff_tag (text_glob *g) } else if (strncmp(t, ".ps", 3) == 0) { char *a = t+3; do_pointsize(a); - } else if (strcmp(t, ".links") == 0) { + } else if (streq(t, ".links")) { do_links(); } else if (strncmp(t, ".job-name", 9) == 0) { char *a = t+9; @@ -3565,11 +3563,11 @@ void html_printer::troff_tag (text_glob *g) } else if (strncmp(t, ".head", 5) == 0) { char *a = t+5; do_head(a); - } else if (strcmp(t, ".no-auto-rule") == 0) { + } else if (streq(t, ".no-auto-rule")) { auto_rule = FALSE; - } else if (strcmp(t, ".tab-ts") == 0) { + } else if (streq(t, ".tab-ts")) { do_tab_ts(g); - } else if (strcmp(t, ".tab-te") == 0) { + } else if (streq(t, ".tab-te")) { do_tab_te(); } else if (strncmp(t, ".col ", 5) == 0) { char *a = t+4; @@ -3628,7 +3626,7 @@ void html_printer::flush_globs (void) handle_state_assertion(g); - if (strcmp(g->text_string, "XXXXXXX") == 0) + if (streq(g->text_string, "XXXXXXX")) stop(); if (g->is_a_tag()) @@ -3985,7 +3983,7 @@ void html_printer::lookahead_for_tables (void) fprintf(stderr, g->text_string) ; fprintf(stderr, "] ") ; fflush(stderr); - if (strcmp(g->text_string, "XXXXXXX") == 0) + if (streq(g->text_string, "XXXXXXX")) stop(); #endif @@ -4235,22 +4233,22 @@ int html_printer::is_font_courier (font *f) void html_printer::end_font (const char *fontname) { assert(fontname != 0 /* nullptr */); - if (strcmp(fontname, "B") == 0) { + if (streq(fontname, "B")) { current_paragraph->done_bold(); - } else if (strcmp(fontname, "I") == 0) { + } else if (streq(fontname, "I")) { current_paragraph->done_italic(); - } else if (strcmp(fontname, "BI") == 0) { + } else if (streq(fontname, "BI")) { current_paragraph->done_bold(); current_paragraph->done_italic(); - } else if (strcmp(fontname, "CR") == 0) { + } else if (streq(fontname, "CR")) { current_paragraph->done_tt(); - } else if (strcmp(fontname, "CI") == 0) { + } else if (streq(fontname, "CI")) { current_paragraph->done_italic(); current_paragraph->done_tt(); - } else if (strcmp(fontname, "CB") == 0) { + } else if (streq(fontname, "CB")) { current_paragraph->done_bold(); current_paragraph->done_tt(); - } else if (strcmp(fontname, "CBI") == 0) { + } else if (streq(fontname, "CBI")) { current_paragraph->done_bold(); current_paragraph->done_italic(); current_paragraph->done_tt(); @@ -4264,25 +4262,25 @@ void html_printer::end_font (const char *fontname) void html_printer::start_font (const char *fontname) { assert(fontname != 0 /* nullptr */); - if (strcmp(fontname, "R") == 0) { + if (streq(fontname, "R")) { current_paragraph->done_bold(); current_paragraph->done_italic(); current_paragraph->done_tt(); - } else if (strcmp(fontname, "B") == 0) { + } else if (streq(fontname, "B")) { current_paragraph->do_bold(); - } else if (strcmp(fontname, "I") == 0) { + } else if (streq(fontname, "I")) { current_paragraph->do_italic(); - } else if (strcmp(fontname, "BI") == 0) { + } else if (streq(fontname, "BI")) { current_paragraph->do_bold(); current_paragraph->do_italic(); - } else if (strcmp(fontname, "CR") == 0) { + } else if (streq(fontname, "CR")) { if ((! fill_on) && is_courier_until_eol() && is_line_start(! fill_on)) { current_paragraph->do_pre(); } current_paragraph->do_tt(); - } else if (strcmp(fontname, "CI") == 0) { + } else if (streq(fontname, "CI")) { if ((! fill_on) && is_courier_until_eol() && is_line_start(! fill_on)) { @@ -4290,7 +4288,7 @@ void html_printer::start_font (const char *fontname) } current_paragraph->do_tt(); current_paragraph->do_italic(); - } else if (strcmp(fontname, "CB") == 0) { + } else if (streq(fontname, "CB")) { if ((! fill_on) && is_courier_until_eol() && is_line_start(! fill_on)) { @@ -4298,7 +4296,7 @@ void html_printer::start_font (const char *fontname) } current_paragraph->do_tt(); current_paragraph->do_bold(); - } else if (strcmp(fontname, "CBI") == 0) { + } else if (streq(fontname, "CBI")) { if ((! fill_on) && is_courier_until_eol() && is_line_start(! fill_on)) { @@ -5306,13 +5304,13 @@ void html_printer::write_navigation (const string &top, "<tr><td class=\"left\">", stdout); handle_valid_flag(FALSE); fputs("[ ", stdout); - if ((strcmp(prev.contents(), "") != 0) + if (!streq(prev.contents(), "") && prev != top && prev != current) { emit_link(prev, "prev"); need_bar = TRUE; } - if ((strcmp(next.contents(), "") != 0) + if (!streq(next.contents(), "") && next != top && next != current) { if (need_bar) @@ -5321,7 +5319,7 @@ void html_printer::write_navigation (const string &top, need_bar = TRUE; } if (top != "<standard input>" - && (strcmp(top.contents(), "") != 0) + && !streq(top.contents(), "") && top != current) { if (need_bar) fputs(" | ", stdout); @@ -5655,9 +5653,9 @@ void html_printer::handle_assertion (int minv, int minh, char *file= get_str(n, &n); char *line= get_str(n, &n); - if (strcmp(cmd, "assertion:[x") == 0) + if (streq(cmd, "assertion:[x")) as.addx(cmd, id, make_val(val, minh, id, file, line), file, line); - else if (strcmp(cmd, "assertion:[y") == 0) + else if (streq(cmd, "assertion:[y")) as.addy(cmd, id, make_val(val, minv, id, file, line), file, line); else if (strncmp(cmd, "assertion:[", strlen("assertion:[")) == 0) @@ -5955,10 +5953,10 @@ int main(int argc, char **argv) valid_flag = TRUE; break; case 'x': - if (strcmp(optarg, "x") == 0) { + if (streq(optarg, "x")) { dialect = xhtml; simple_anchors = TRUE; - } else if (strcmp(optarg, "4") == 0) + } else if (streq(optarg, "4")) dialect = html4; else warning("unsupported HTML dialect: '%1'", optarg); diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp index 7b4d85695454..a33ed0791b3a 100644 --- a/src/devices/grolbp/lbp.cpp +++ b/src/devices/grolbp/lbp.cpp @@ -33,7 +33,7 @@ TODO #include <math.h> // fabs(), sqrt() #include <stdcountof.h> #include <stdlib.h> // abs(), EXIT_SUCCESS, exit(), strtol() -#include <string.h> // strcmp(), strcpy(), strlen(), strncpy() +#include <string.h> // strcpy(), strlen(), strncpy() #include <strings.h> // strcasecmp() #include <getopt.h> // getopt_long() @@ -140,7 +140,7 @@ void lbp_font::handle_unknown_font_command(const char *command, const char *arg, const char *fn, int lineno) { - if (strcmp(command, "lbpname") == 0) { + if (streq(command, "lbpname")) { if (arg == 0) fatal_with_file_and_line(fn, lineno, "'%1' command requires an argument", diff --git a/src/devices/grolj4/lj4.cpp b/src/devices/grolj4/lj4.cpp index d0b9ef54c32d..ef4b74aa2d1b 100644 --- a/src/devices/grolj4/lj4.cpp +++ b/src/devices/grolj4/lj4.cpp @@ -41,7 +41,7 @@ X command to include bitmap graphics #include <stdio.h> // EOF, FILE, fflush(), fprintf(), printf(), // setbuf(), stderr, stdout #include <stdlib.h> // exit(), EXIT_SUCCESS, strtol() -#include <string.h> // strcmp() +#include <string.h> #include <strings.h> // strcasecmp() #include <getopt.h> // getopt_long() @@ -146,7 +146,7 @@ void lj4_font::handle_unknown_font_command(const char *command, int lineno) { for (size_t i = 0; i < countof(command_table); i++) { - if (strcmp(command, command_table[i].s) == 0) { + if (streq(command, command_table[i].s)) { if (0 /* nullptr */ == arg) fatal_with_file_and_line(fn, lineno, "'%1' command requires an argument", diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp index 7f8145902376..9eb2e5178772 100644 --- a/src/devices/grops/ps.cpp +++ b/src/devices/grops/ps.cpp @@ -35,7 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> // EOF, FILE, fclose(), fgets(), fileno(), fseek(), // getc(), SEEK_SET, setbuf(), stderr, stdout #include <stdlib.h> // exit(), EXIT_SUCCESS, putenv(), strtol() -#include <string.h> // strchr(), strcmp(), strcpy(), strerror(), +#include <string.h> // strchr(), strcpy(), strerror(), // strlen(), strncmp(), strstr(), strtok() #include <time.h> // asctime() @@ -466,7 +466,7 @@ ps_font::~ps_font() void ps_font::handle_unknown_font_command(const char *command, const char *arg, const char *fn, int lineno) { - if (strcmp(command, "encoding") == 0) { + if (streq(command, "encoding")) { if (arg == 0) error_with_file_and_line(fn, lineno, "'encoding' command requires an argument"); @@ -478,7 +478,7 @@ void ps_font::handle_unknown_font_command(const char *command, const char *arg, static void handle_unknown_desc_command(const char *command, const char *arg, const char *fn, int lineno) { - if (strcmp(command, "broken") == 0) { + if (streq(command, "broken")) { if (arg == 0) error_with_file_and_line(fn, lineno, "'broken' command requires an argument"); @@ -690,7 +690,7 @@ int ps_printer::set_encoding_index(ps_font *f) int encoding_index = (static_cast<ps_font *>(p->p))->encoding_index; if ((encoding != 0 /* nullptr */) && encoding_index >= 0 - && strcmp(f->encoding, encoding) == 0) { + && streq(f->encoding, encoding)) { return f->encoding_index = encoding_index; } } diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp index 8e69a3b59940..182cc60ba815 100644 --- a/src/devices/grotty/tty.cpp +++ b/src/devices/grotty/tty.cpp @@ -155,9 +155,9 @@ tty_font::~tty_font() #if 0 void tty_font::handle_x_command(int argc, const char **argv) { - if (argc >= 1 && strcmp(argv[0], "bold") == 0) + if (argc >= 1 && streq(argv[0], "bold")) mode |= BOLD_MODE; - else if (argc >= 1 && strcmp(argv[0], "underline") == 0) + else if (argc >= 1 && streq(argv[0], "underline")) mode |= UNDERLINE_MODE; } #endif diff --git a/src/devices/xditview/Dvi.c b/src/devices/xditview/Dvi.c index 26f0ee6bf349..49531e1bd37a 100644 --- a/src/devices/xditview/Dvi.c +++ b/src/devices/xditview/Dvi.c @@ -402,7 +402,7 @@ SetValuesHook (Widget wdw, ArgList args, Cardinal *num_argsp) DviWidget dw = (DviWidget)wdw; for (i = 0; i < *num_argsp; i++) { - if (!strcmp (args[i].name, XtNfile)) { + if (streq(args[i].name, XtNfile)) { CloseFile (dw); OpenFile (dw); return TRUE; diff --git a/src/devices/xditview/device.c b/src/devices/xditview/device.c index 1eaafbefccb2..f53e4cfcc940 100644 --- a/src/devices/xditview/device.c +++ b/src/devices/xditview/device.c @@ -119,19 +119,19 @@ Device *device_load(const char *name) int *np = 0; char *q; - if (strcmp(p, "charset") == 0) + if (streq(p, "charset")) break; - if (strcmp(p, "X11") == 0) + if (streq(p, "X11")) dev->X11 = 1; - else if (strcmp(p, "sizescale") == 0) + else if (streq(p, "sizescale")) np = &dev->sizescale; - else if (strcmp(p, "res") == 0) + else if (streq(p, "res")) np = &dev->res; - else if (strcmp(p, "unitwidth") == 0) + else if (streq(p, "unitwidth")) np = &dev->unitwidth; - else if (strcmp(p, "paperwidth") == 0) + else if (streq(p, "paperwidth")) np = &dev->paperwidth; - else if (strcmp(p, "paperlength") == 0) + else if (streq(p, "paperlength")) np = &dev->paperlength; if (np) { @@ -177,7 +177,7 @@ DeviceFont *device_find_font(Device *dev, const char *name) if (!dev) return 0; for (f = dev->fonts; f; f = f->next) - if (strcmp(f->name, name) == 0) + if (streq(f->name, name)) return f; return load_font(dev, name); } @@ -204,9 +204,9 @@ DeviceFont *load_font(Device *dev, const char *name) current_lineno++; p = strtok(buf, WS); /* charset must be on a line by itself */ - if (p && strcmp(p, "charset") == 0 && strtok((char *)0, WS) == 0) + if (p && streq(p, "charset") && strtok((char *)0, WS) == 0) break; - if (p && strcmp(p, "special") == 0) + if (p && streq(p, "special")) special = 1; } f = new_font(name, dev); @@ -325,7 +325,7 @@ int device_char_width(DeviceFont *f, int ps, const char *name, int *widthp) for (p = f->char_table[hash_name(name) % CHAR_TABLE_SIZE];; p = p->next) { if (!p) return 0; - if (strcmp(p->name, name) == 0) + if (streq(p->name, name)) break; } *widthp = scale_round(p->width, ps, f->dev->unitwidth); @@ -372,7 +372,7 @@ struct charinfo *add_char(DeviceFont *f, const char *name, int width, int code) struct charinfo *ci; name = canonicalize_name(name); - if (strcmp(name, "---") == 0) + if (streq(name, "---")) name = ""; ci = (struct charinfo *)XtMalloc(XtOffsetOf(struct charinfo, name[0]) @@ -414,7 +414,7 @@ int read_charset_section(DeviceFont *f, FILE *fp) p = strtok((char *)0, WS); if (!p) /* end of charset section */ break; - if (strcmp(p, "\"") == 0) { + if (streq(p, "\"")) { if (!last_charinfo) { error("first line of charset section cannot use '\"'"); return 0; diff --git a/src/devices/xditview/font.c b/src/devices/xditview/font.c index 419de4bf359e..3bed82524a76 100644 --- a/src/devices/xditview/font.c +++ b/src/devices/xditview/font.c @@ -215,8 +215,7 @@ InstallFont (DviWidget dw, int position, /* * ignore gratuitous font loading */ - if (!strcmp (f->dvi_name, dvi_name) && - !strcmp (f->x_name, x_name)) + if (streq(f->dvi_name, dvi_name) && streq(f->x_name, x_name)) return f; DisposeFontSizes (dw, f->sizes); @@ -291,7 +290,7 @@ MapDviNameToXName (DviWidget dw, const char *dvi_name) DviFontMap *fm; for (fm = dw->dvi.font_map; fm; fm=fm->next) - if (!strcmp (fm->dvi_name, dvi_name)) + if (streq(fm->dvi_name, dvi_name)) return fm->x_name; return 0; } @@ -303,7 +302,7 @@ MapXNameToDviName (DviWidget dw, const char *x_name) DviFontMap *fm; for (fm = dw->dvi.font_map; fm; fm=fm->next) - if (!strcmp (fm->x_name, x_name)) + if (streq(fm->x_name, x_name)) return fm->dvi_name; return 0; } diff --git a/src/devices/xditview/xditview.c b/src/devices/xditview/xditview.c index f39eedc098f5..b48d2d9a449e 100644 --- a/src/devices/xditview/xditview.c +++ b/src/devices/xditview/xditview.c @@ -57,7 +57,7 @@ static char rcsid[] = "$XConsortium: xditview.c,v 1.17 89/12/10 17:05:08 rws Exp // pclose(), popen(), printf(), sprintf(), stderr, // stdin, stdout #include <stdlib.h> // exit(), EXIT_FAILURE, EXIT_SUCCESS -#include <string.h> // strcmp(), strcpy(), strncpy() +#include <string.h> // strcpy(), strncpy() #include "Dvi.h" #include "groff_version.h" @@ -234,12 +234,12 @@ int main(int argc, char **argv) * XXX: This is not as flexible as GNU getopt, but good enough to * work when called by groff. */ - if ((strcmp(argv[1], "-help") == 0) - || (strcmp(argv[1], "--help") == 0)) + if (streq(argv[1], "-help") + || streq(argv[1], "--help")) Syntax(argv[0], false /* did not have error */); - else if ((strcmp(argv[1], "-v") == 0) - || (strcmp(argv[1], "-version") == 0) - || (strcmp(argv[1], "--version") == 0)) { + else if (streq(argv[1], "-v") + || streq(argv[1], "-version") + || streq(argv[1], "--version")) { (void) printf("GNU gxditview (groff) version %s\n", Version_string); exit(EXIT_SUCCESS); @@ -342,14 +342,14 @@ NewFile (const char *name) Boolean seek = 0; if (current_file) { - if (!strcmp (current_file_name, "-")) + if (streq(current_file_name, "-")) ; else if (current_file_name[0] == '|') pclose (current_file); else fclose (current_file); } - if (!strcmp (name, "-")) + if (streq(name, "-")) new_file = stdin; else if (name[0] == '|') new_file = popen (name+1, "r"); diff --git a/src/include/nonposix.h b/src/include/nonposix.h index a250e4f0b015..2fb28f9eb390 100644 --- a/src/include/nonposix.h +++ b/src/include/nonposix.h @@ -197,7 +197,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ # define BSHELL_DASH_C "-c" #endif #ifndef IS_BSHELL -# define IS_BSHELL(s) ((s) && strcmp(s,BSHELL) == 0) +# define IS_BSHELL(s) ((s) && streq(s,BSHELL)) #endif #ifndef PATH_SEP # define PATH_SEP ":" diff --git a/src/include/ptable.h b/src/include/ptable.h index 0bf90a8a2c78..1a60433cd6b2 100644 --- a/src/include/ptable.h +++ b/src/include/ptable.h @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> #include <stdlib.h> // free(), malloc() -#include <string.h> // strcmp(), strcpy(), strlen() +#include <string.h> // strcpy(), strlen() // This groffism can be replaced with // std::unordered_map<const char *, T> if/when we migrate to C++11. @@ -144,7 +144,7 @@ const char *PTABLE(T)::define(const char *key, T *val) \ for (n = unsigned(h % size); \ v[n].key != 0; \ n = (n == 0 ? size - 1 : n - 1)) \ - if (strcmp(v[n].key, key) == 0) { \ + if (streq(v[n].key, key)) { \ /* XXX leak, because we don't know whether */ \ /* 'free', 'delete', or 'delete[]' should be used */ \ /* delete[] v[n].val; */ \ @@ -192,7 +192,7 @@ T *PTABLE(T)::lookup(const char *key) \ for (unsigned n = unsigned(hash_string(key) % size); \ v[n].key != 0; \ n = (n == 0 ? size - 1 : n - 1)) \ - if (strcmp(v[n].key, key) == 0) \ + if (streq(v[n].key, key)) \ return v[n].val; \ return 0; \ } \ @@ -204,7 +204,7 @@ T *PTABLE(T)::lookupassoc(const char **keyptr) \ for (unsigned n = unsigned(hash_string(key) % size); \ v[n].key != 0; \ n = (n == 0 ? size - 1 : n - 1)) \ - if (strcmp(v[n].key, key) == 0) { \ + if (streq(v[n].key, key)) { \ *keyptr = v[n].key; \ return v[n].val; \ } \ diff --git a/src/libs/libbib/search.cpp b/src/libs/libbib/search.cpp index a8e5f0b1cef9..f4f893d30c82 100644 --- a/src/libs/libbib/search.cpp +++ b/src/libs/libbib/search.cpp @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> #include <errno.h> -#include <string.h> // strchr(), strcmp(), strerror(), strlen() +#include <string.h> // strchr(), strerror(), strlen() #include "lib.h" @@ -121,7 +121,7 @@ search_item::~search_item() int search_item::is_named(const char *nm) const { - return strcmp(name, nm) == 0; + return streq(name, nm); } int search_item::next_filename_id() const diff --git a/src/libs/libdriver/input.cpp b/src/libs/libdriver/input.cpp index 9df863ee5e47..4213ba1755de 100644 --- a/src/libs/libdriver/input.cpp +++ b/src/libs/libdriver/input.cpp @@ -241,7 +241,7 @@ #include <stdio.h> // EOF, FILE, fclose(), fopen(), getc(), stdin, // ungetc() #include <stdlib.h> // strtol() -#include <string.h> // strcmp(), strlen(), strncmp(), strncpy() +#include <string.h> // strlen(), strncmp(), strncpy() #include "driver.h" #include "device.h" @@ -1031,7 +1031,7 @@ void remember_filename(const char *filename) { char *fname; - if (strcmp(filename, "-") == 0) + if (streq(filename, "-")) fname = (char *)"<standard input>"; else fname = (char *)filename; @@ -1057,7 +1057,7 @@ void remember_source_filename(const char *filename) { char *fname; - if (strcmp(filename, "-") == 0) + if (streq(filename, "-")) fname = (char *)"<standard input>"; else fname = (char *)filename; @@ -1607,7 +1607,7 @@ do_file(const char *filename) fatal("cannot load description of '%1' device", tmp_dev); } else { - if (device == 0 || strcmp(device, tmp_dev) != 0) + if (device == 0 || !streq(device, tmp_dev)) fatal("all files must use the same device"); delete[] tmp_dev; } diff --git a/src/libs/libdriver/printer.cpp b/src/libs/libdriver/printer.cpp index 40fa8dc6ef55..2c121d2ca804 100644 --- a/src/libs/libdriver/printer.cpp +++ b/src/libs/libdriver/printer.cpp @@ -24,7 +24,7 @@ #include <assert.h> #include <errno.h> // EINVAL, errno #include <stdio.h> // clearerr(), ferror(), fflush(), stdout -#include <string.h> // strcmp() +#include <string.h> #include "driver.h" @@ -135,7 +135,7 @@ void printer::load_font(int n, const char *nm) font *printer::find_font(const char *nm) { for (font_pointer_list *p = font_list; p; p = p->next) - if (strcmp(p->p->get_filename(), nm) == 0) + if (streq(p->p->get_filename(), nm)) return p->p; font *f = make_font(nm); if (0 /* nullptr */ == f) diff --git a/src/libs/libgroff/change_lf.cpp b/src/libs/libgroff/change_lf.cpp index 140329de72cd..fa2b96912be3 100644 --- a/src/libs/libgroff/change_lf.cpp +++ b/src/libs/libgroff/change_lf.cpp @@ -29,7 +29,7 @@ extern int current_lineno; void change_filename(const char *f) { - if (current_filename != 0 && strcmp(current_filename, f) == 0) + if (current_filename != 0 && streq(current_filename, f)) return; current_filename = strsave(f); } diff --git a/src/libs/libgroff/error.cpp b/src/libs/libgroff/error.cpp index d92dae1a61b7..84bda569f2f8 100644 --- a/src/libs/libgroff/error.cpp +++ b/src/libs/libgroff/error.cpp @@ -46,7 +46,7 @@ static void do_error_with_file_and_line(const char *filename, need_space = true; } if (filename != 0 /* nullptr */) { - if (strcmp(filename, "-") == 0) + if (streq(filename, "-")) filename = "<standard input>"; fputs(filename, stderr); if (source_filename != 0 /* nullptr */) { diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp index b3c99dc08600..827ba06b193b 100644 --- a/src/libs/libgroff/font.cpp +++ b/src/libs/libgroff/font.cpp @@ -906,20 +906,20 @@ bool font::load(bool load_header_only) bool saw_name_directive = false; while (t.next_line()) { p = strtok(t.buf, WS); - if (strcmp(p, "name") == 0) { + if (streq(p, "name")) { p = strtok(0 /* nullptr */, WS); if (0 /* nullptr */ == p) { t.error("'name' directive requires an argument"); return false; } - if (strcmp(p, filename) != 0) { + if (!streq(p, filename)) { t.error("font description file name '%1' does not match 'name'" " argument '%2'", filename, p); return false; } saw_name_directive = true; } - else if (strcmp(p, "spacewidth") == 0) { + else if (streq(p, "spacewidth")) { p = strtok(0 /* nullptr */, WS); int n; if (0 /* nullptr */ == p) { @@ -936,7 +936,7 @@ bool font::load(bool load_header_only) } space_width = n; } - else if (strcmp(p, "slant") == 0) { + else if (streq(p, "slant")) { p = strtok(0 /* nullptr */, WS); double n; if (0 /* nullptr */ == p) { @@ -953,20 +953,20 @@ bool font::load(bool load_header_only) } slant = n; } - else if (strcmp(p, "ligatures") == 0) { + else if (streq(p, "ligatures")) { for (;;) { p = strtok(0 /* nullptr */, WS); - if (0 /* nullptr */ == p || strcmp(p, "0") == 0) + if (0 /* nullptr */ == p || streq(p, "0")) break; - if (strcmp(p, "ff") == 0) + if (streq(p, "ff")) ligatures |= LIG_ff; - else if (strcmp(p, "fi") == 0) + else if (streq(p, "fi")) ligatures |= LIG_fi; - else if (strcmp(p, "fl") == 0) + else if (streq(p, "fl")) ligatures |= LIG_fl; - else if (strcmp(p, "ffi") == 0) + else if (streq(p, "ffi")) ligatures |= LIG_ffi; - else if (strcmp(p, "ffl") == 0) + else if (streq(p, "ffl")) ligatures |= LIG_ffl; else { t.error("unrecognized ligature '%1'", p); @@ -974,7 +974,7 @@ bool font::load(bool load_header_only) } } } - else if (strcmp(p, "internalname") == 0) { + else if (streq(p, "internalname")) { p = strtok(0 /* nullptr */, WS); if (0 /* nullptr */ == p) { t.error("missing argument to 'internalname' directive"); @@ -983,11 +983,11 @@ bool font::load(bool load_header_only) internalname = new char[strlen(p) + 1]; strcpy(internalname, p); } - else if (strcmp(p, "special") == 0) { + else if (streq(p, "special")) { special = true; } - else if (strcmp(p, "kernpairs") != 0 && strcmp(p, "charset") != 0 && - strcmp(p, "charset-range") != 0) { + else if (!streq(p, "kernpairs") && !streq(p, "charset") && + !streq(p, "charset-range")) { char *directive = p; p = strtok(0 /* nullptr */, "\n"); handle_unknown_font_command(directive, trim_arg(p), t.path, @@ -1000,7 +1000,7 @@ bool font::load(bool load_header_only) char *directive = p; t.recognize_comments = false; while (directive) { - if (strcmp(directive, "kernpairs") == 0) { + if (streq(directive, "kernpairs")) { if (load_header_only) return true; for (;;) { @@ -1034,7 +1034,7 @@ bool font::load(bool load_header_only) } } // TODO: Rename this directive to "ranged-charset". - else if (strcmp(directive, "charset-range") == 0) { + else if (streq(directive, "charset-range")) { if (load_header_only) return true; saw_charset_directive = true; @@ -1093,7 +1093,7 @@ bool font::load(bool load_header_only) wcp->type = type; p = strtok(0 /* nullptr */, WS); - if ((0 /* nullptr */ == p) || (strcmp(p, "--") == 0)) { + if ((0 /* nullptr */ == p) || streq(p, "--")) { wcp->special_device_coding = 0 /* nullptr */; } else { @@ -1111,7 +1111,7 @@ bool font::load(bool load_header_only) return false; } } - else if (strcmp(directive, "charset") == 0) { + else if (streq(directive, "charset")) { if (load_header_only) return true; saw_charset_directive = true; @@ -1134,7 +1134,7 @@ bool font::load(bool load_header_only) " cannot be an alias", nm); return false; } - if (strcmp(nm, "---") == 0) { + if (streq(nm, "---")) { t.error("an unnamed character ('---') cannot be an alias"); return false; } @@ -1205,7 +1205,7 @@ bool font::load(bool load_header_only) } metric.code = static_cast<int>(index); p = strtok(0 /* nullptr */, WS); - if ((0 /* nullptr */ == p) || (strcmp(p, "--") == 0)) { + if ((0 /* nullptr */ == p) || streq(p, "--")) { metric.special_device_coding = 0; } else { @@ -1213,7 +1213,7 @@ bool font::load(bool load_header_only) strcpy(nam, p); metric.special_device_coding = nam; } - if (strcmp(nm, "---") == 0) { + if (streq(nm, "---")) { last_glyph = number_to_glyph(metric.code); add_entry(last_glyph, metric); } @@ -1291,7 +1291,7 @@ const char *font::load_desc() for (idx = 0; !numeric_directive_found && (idx < countof(numeric_directive_table)); idx++) - if (strcmp(numeric_directive_table[idx].name, p) == 0) + if (streq(numeric_directive_table[idx].name, p)) numeric_directive_found = true; if (numeric_directive_found) { char *q = strtok(0 /* nullptr */, WS); @@ -1304,13 +1304,13 @@ const char *font::load_desc() t.error("'%1' directive given invalid number '%2'", p, q); return 0 /* nullptr */; } - if ((strcmp(p, "res") == 0 - || strcmp(p, "hor") == 0 - || strcmp(p, "vert") == 0 - || strcmp(p, "unitwidth") == 0 - || strcmp(p, "paperwidth") == 0 - || strcmp(p, "paperlength") == 0 - || strcmp(p, "sizescale") == 0) + if ((streq(p, "res") + || streq(p, "hor") + || streq(p, "vert") + || streq(p, "unitwidth") + || streq(p, "paperwidth") + || streq(p, "paperlength") + || streq(p, "sizescale")) && val < 1) { t.error("expected argument to '%1' directive to be a" " positive number, got '%2'", p, val); @@ -1318,7 +1318,7 @@ const char *font::load_desc() } *(numeric_directive_table[idx - 1].ptr) = val; } - else if (strcmp("family", p) == 0) { + else if (streq("family", p)) { p = strtok(0 /* nullptr */, WS); if (0 /* nullptr */ == p) { t.error("'family' directive requires an argument"); @@ -1328,7 +1328,7 @@ const char *font::load_desc() strcpy(tem, p); family = tem; } - else if (strcmp("fonts", p) == 0) { + else if (streq("fonts", p)) { p = strtok(0 /* nullptr */, WS); if (0 /* nullptr */ == p) { t.error("'fonts' directive requires arguments"); @@ -1361,7 +1361,7 @@ const char *font::load_desc() } font_name_table[nfonts] = 0 /* nullptr */; } - else if (strcmp("papersize", p) == 0) { + else if (streq("papersize", p)) { if (0 /* nullptr */ == res) { t.error("'res' directive must precede 'papersize' in device" " description file"); @@ -1396,11 +1396,11 @@ const char *font::load_desc() } free(savedp); } - else if (strcmp("unscaled_charwidths", p) == 0) + else if (streq("unscaled_charwidths", p)) use_unscaled_charwidths = true; - else if (strcmp("pass_filenames", p) == 0) + else if (streq("pass_filenames", p)) pass_filenames = true; - else if (strcmp("sizes", p) == 0) { + else if (streq("sizes", p)) { int n = 16; sizes = new int[n]; int i = 0; @@ -1443,7 +1443,7 @@ const char *font::load_desc() return 0 /* nullptr */; } } - else if (strcmp("styles", p) == 0) { + else if (streq("styles", p)) { int style_table_size = 5; style_table = (const char **)new char *[style_table_size]; int j; @@ -1470,13 +1470,13 @@ const char *font::load_desc() style_table[i++] = tem; } } - else if (strcmp("tcommand", p) == 0) + else if (streq("tcommand", p)) has_tcommand = true; - else if (strcmp("use_charnames_in_special", p) == 0) + else if (streq("use_charnames_in_special", p)) use_charnames_in_special = true; - else if (strcmp("unicode", p) == 0) + else if (streq("unicode", p)) is_unicode = true; - else if (strcmp("image_generator", p) == 0) { + else if (streq("image_generator", p)) { p = strtok(0 /* nullptr */, WS); if (0 /* nullptr */ == p) { t.error("'image_generator' directive requires an argument"); @@ -1484,7 +1484,7 @@ const char *font::load_desc() } image_generator = strsave(p); } - else if (strcmp("charset", p) == 0) + else if (streq("charset", p)) break; else if (unknown_desc_command_handler) { char *directive = p; diff --git a/src/libs/libgroff/localcharset.c b/src/libs/libgroff/localcharset.c index 344599f99d6a..720ad46e0fd0 100644 --- a/src/libs/libgroff/localcharset.c +++ b/src/libs/libgroff/localcharset.c @@ -380,7 +380,7 @@ locale_charset (void) /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always returns "US-ASCII". Return the suffix of the locale name from the environment variables (if present) or the codepage as a number. */ - if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) + if (codeset != NULL && streq(codeset, "US-ASCII")) { const char *locale; static char buf[2 + 10 + 1]; @@ -559,8 +559,7 @@ locale_charset (void) for (aliases = get_charset_aliases (); *aliases != '\0'; aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) - if (strcmp (codeset, aliases) == 0 - || (aliases[0] == '*' && aliases[1] == '\0')) + if (streq(codeset, aliases) || (aliases[0] == '*' && aliases[1] == '\0')) { codeset = aliases + strlen (aliases) + 1; break; @@ -575,7 +574,7 @@ locale_charset (void) #ifdef DARWIN7 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" (the default codeset) does not work when MB_CUR_MAX is 1. */ - if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1) + if (streq(codeset, "UTF-8") && MB_CUR_MAX_L (uselocale (NULL)) <= 1) codeset = "ASCII"; #endif diff --git a/src/libs/libgroff/searchpath.cpp b/src/libs/libgroff/searchpath.cpp index 2d5e599d2bc0..13343753884a 100644 --- a/src/libs/libgroff/searchpath.cpp +++ b/src/libs/libgroff/searchpath.cpp @@ -178,7 +178,7 @@ FILE *search_path::open_file_cautiously(const char *name, char **pathp, if (0 /* nullptr */ == mode) mode = "r"; bool reading = (strchr(mode, 'r') != 0 /* nullptr */); - if (0 /* nullptr */ == name || strcmp(name, "-") == 0) { + if (0 /* nullptr */ == name || streq(name, "-")) { if (pathp != 0) *pathp = strsave(reading ? "stdin" : "stdout"); return (reading ? stdin : stdout); diff --git a/src/libs/libgroff/symbol.cpp b/src/libs/libgroff/symbol.cpp index 42659a2460af..5cd0304a033b 100644 --- a/src/libs/libgroff/symbol.cpp +++ b/src/libs/libgroff/symbol.cpp @@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #endif #include <assert.h> -#include <string.h> // strcat(), strcmp(), strcpy(), strlen() +#include <string.h> // strcat(), strcpy(), strlen() #include <stdlib.h> // calloc() #include "cset.h" // csprint() @@ -105,7 +105,7 @@ symbol::symbol(const char *p, int how) for (pp = table + hc % table_size; *pp != 0 /* nullptr */; (pp == table ? pp = table + table_size - 1 : --pp)) - if (strcmp(p, *pp) == 0) { + if (streq(p, *pp)) { s = *pp; return; } diff --git a/src/libs/libgroff/tmpname.cpp b/src/libs/libgroff/tmpname.cpp index 021d33f2758e..c162cca45728 100644 --- a/src/libs/libgroff/tmpname.cpp +++ b/src/libs/libgroff/tmpname.cpp @@ -71,7 +71,7 @@ int gen_tempname(char *tmpl, int dir) static uint64_t value; size_t len = strlen(tmpl); - if (len < 6 || strcmp(&tmpl[len - 6], "XXXXXX")) + if (len < 6 || !streq(&tmpl[len - 6], "XXXXXX")) return -1; /* EINVAL */ /* This is where the Xs start. */ diff --git a/src/libs/libxutil/DviChar.c b/src/libs/libxutil/DviChar.c index 1d751a194c13..66dfb00e49c1 100644 --- a/src/libs/libxutil/DviChar.c +++ b/src/libs/libxutil/DviChar.c @@ -55,7 +55,7 @@ DviFindMap (char *encoding) if (!standard_maps_loaded) load_standard_maps (); for (m = world; m; m=m->next) - if (!strcmp (m->map->encoding, encoding)) + if (streq(m->map->encoding, encoding)) return m->map; return 0; } @@ -68,7 +68,7 @@ DviRegisterMap (DviCharNameMap *map) if (!standard_maps_loaded) load_standard_maps (); for (m = world; m; m = m->next) - if (!strcmp (m->map->encoding, map->encoding)) + if (streq(m->map->encoding, map->encoding)) break; if (!m) { m = (struct map_list *) xmalloc (sizeof *m); @@ -140,7 +140,7 @@ DviCharIndex (DviCharNameMap *map, const char *name) i = hash_name (name) % DVI_HASH_SIZE; for (h = map->buckets[i]; h; h=h->next) - if (!strcmp (h->name, name)) + if (streq(h->name, name)) return h->position; return -1; } diff --git a/src/libs/libxutil/XFontName.c b/src/libs/libxutil/XFontName.c index d6d0fc13a1c8..112c95c53a41 100644 --- a/src/libs/libxutil/XFontName.c +++ b/src/libs/libxutil/XFontName.c @@ -205,7 +205,7 @@ XCompareFontName (XFontName *name1, XFontName *name2, { #define CompareString(field,bit) \ if (fontNameAttributes & bit) \ - if (strcmp (name1->field, name2->field)) \ + if (!streq(name1->field, name2->field)) \ return False; #define CompareUnsigned(field,bit) \ diff --git a/src/preproc/eqn/box.cpp b/src/preproc/eqn/box.cpp index a58762d31344..a55d823acadb 100644 --- a/src/preproc/eqn/box.cpp +++ b/src/preproc/eqn/box.cpp @@ -142,7 +142,7 @@ struct param *param_table = 0 /* nullptr */; void set_param(const char *name, int value) { for (size_t i = 0; i <= countof(default_param_table); i++) - if (strcmp(param_table[i].name, name) == 0) { + if (streq(param_table[i].name, name)) { *(param_table[i].ptr) = value; return; } @@ -152,7 +152,7 @@ void set_param(const char *name, int value) void reset_param(const char *name) { for (size_t i = 0; i < countof(default_param_table); i++) - if (strcmp(param_table[i].name, name) == 0) { + if (streq(param_table[i].name, name)) { *param_table[i].ptr = *(default_param_table[i].ptr); return; } @@ -163,7 +163,7 @@ void reset_param(const char *name) int get_param(const char *name) { for (size_t i = 0; i < countof(default_param_table); i++) - if (strcmp(param_table[i].name, name) == 0) + if (streq(param_table[i].name, name)) return *(param_table[i].ptr); assert(0 == "attempted to access parameter not in table"); fatal("internal error: unrecognized parameter name '%1'", name); diff --git a/src/preproc/eqn/main.cpp b/src/preproc/eqn/main.cpp index 371101ceaeb4..9f26a5f591fd 100644 --- a/src/preproc/eqn/main.cpp +++ b/src/preproc/eqn/main.cpp @@ -376,15 +376,15 @@ int main(int argc, char **argv) break; case 'T': device = optarg; - if (strcmp(device, "ps:html") == 0) { + if (streq(device, "ps:html")) { device = "ps"; html = 1; } - else if (strcmp(device, "MathML") == 0) { + else if (streq(device, "MathML")) { output_format = mathml; want_startup_file = false; } - else if (strcmp(device, "mathml:xhtml") == 0) { + else if (streq(device, "mathml:xhtml")) { device = "MathML"; output_format = mathml; want_startup_file = false; @@ -482,7 +482,7 @@ int main(int argc, char **argv) do_file(stdin, "-"); else for (int i = optind; i < argc; i++) - if (strcmp(argv[i], "-") == 0) + if (streq(argv[i], "-")) do_file(stdin, "-"); else { errno = 0; diff --git a/src/preproc/eqn/text.cpp b/src/preproc/eqn/text.cpp index 4d6a33513462..b8cdbf747922 100644 --- a/src/preproc/eqn/text.cpp +++ b/src/preproc/eqn/text.cpp @@ -399,7 +399,7 @@ const char *special_to_entity(const char *sp) { struct map *mp; for (mp = entity_table; mp < entity_table + countof(entity_table); mp++) { - if (strcmp(mp->from, sp) == 0) + if (streq(mp->from, sp)) return mp->to; } return NULL; @@ -536,7 +536,7 @@ void init_char_table() static int lookup_spacing_type(const char *type) { for (int i = 0; spacing_type_table[i] != 0; i++) - if (strcmp(spacing_type_table[i], type) == 0) + if (streq(spacing_type_table[i], type)) return i; return -1; } @@ -544,7 +544,7 @@ static int lookup_spacing_type(const char *type) static int lookup_font_type(const char *type) { for (int i = 0; font_type_table[i] != 0; i++) - if (strcmp(font_type_table[i], type) == 0) + if (streq(font_type_table[i], type)) return i; return -1; } diff --git a/src/preproc/grn/hdb.cpp b/src/preproc/grn/hdb.cpp index 708389de4d8c..ba00282c548d 100644 --- a/src/preproc/grn/hdb.cpp +++ b/src/preproc/grn/hdb.cpp @@ -17,7 +17,7 @@ #include <ctype.h> // isdigit() #include <stdio.h> // FILE, feof(), fgets(), getc() #include <stdlib.h> // atoi() -#include <string.h> // strcmp() +#include <string.h> #include "errarg.h" #include "error.h" @@ -109,8 +109,8 @@ DBRead(FILE *file) return (elist); } lineno++; - if (strcmp(string, "gremlinfile")) { - if (strcmp(string, "sungremlinfile")) { + if (!streq(string, "gremlinfile")) { + if (!streq(string, "sungremlinfile")) { error_with_file_and_line(gremlinfile, lineno, "not a gremlin file; giving up on this" " picture"); diff --git a/src/preproc/grn/main.cpp b/src/preproc/grn/main.cpp index 18c0cc0bdc87..910a3ccec320 100644 --- a/src/preproc/grn/main.cpp +++ b/src/preproc/grn/main.cpp @@ -86,7 +86,7 @@ #include <stdio.h> // FILE, fclose(), fgets(), fopen(), fprintf(), // fputs(), printf(), stderr, stdin, stdout #include <stdlib.h> // exit(), EXIT_SUCCESS, free(), malloc() -#include <string.h> // strchr(), strcmp(), strcpy(), strerror(), +#include <string.h> // strchr(), strcpy(), strerror(), // strlen() #include "device.h" @@ -358,13 +358,13 @@ main(int argc, break; case '-': - if (strcmp(*argv,"--version")==0) { + if (streq(*argv,"--version")) { case 'v': printf("GNU grn (groff) version %s\n", Version_string); exit(EXIT_SUCCESS); break; } - if (strcmp(*argv,"--help")==0) { + if (streq(*argv,"--help")) { case '?': usage(stdout); exit(EXIT_SUCCESS); @@ -882,7 +882,7 @@ interpret(char *line) stipple = (char *) grnmalloc(strlen(str2) + 1, "stipple command"); strcpy(stipple, str2); /* if it's a 'known' font (currently only 'cf'), set indices */ - if (strcmp(stipple, "cf") == 0) + if (streq(stipple, "cf")) defstipple_index = cf_stipple_index; else defstipple_index = other_stipple_index; @@ -954,7 +954,7 @@ interpret(char *line) break; case 'p': /* pointscale */ - if (strcmp("off", str2)) + if (!streq("off", str2)) pointscale = 1; else pointscale = 0; diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp index 7b58903d8193..13778f9320b5 100644 --- a/src/preproc/html/pre-html.cpp +++ b/src/preproc/html/pre-html.cpp @@ -30,7 +30,7 @@ // stderr, stdin, stdout, ungetc() #include <stdlib.h> // atexit(), atoi(), exit(), free(), getenv(), // malloc(), system() -#include <string.h> // memcpy(), strchr(), strcmp(), strcpy(), +#include <string.h> // memcpy(), strchr(), strcpy(), // strerror(), strlen(), strncmp(), strsignal() #include <getopt.h> // getopt_long() @@ -637,7 +637,7 @@ static void setupAntiAlias(void) static void checkImageDir(void) { - if (image_dir != 0 /* nullptr */ && strcmp(image_dir, "") != 0) + if (image_dir != 0 /* nullptr */ && !streq(image_dir, "")) if (!(mkdir(image_dir, 0777) == 0 || errno == EEXIST)) fatal("cannot create directory '%1': %2", image_dir, strerror(errno)); @@ -1229,8 +1229,7 @@ static void alterDeviceTo(int argc, char *argv[], int toImage) if (toImage) { while (i < argc) { - if ((strcmp(argv[i], "-Thtml") == 0) || - (strcmp(argv[i], "-Txhtml") == 0)) + if (streq(argv[i], "-Thtml") || streq(argv[i], "-Txhtml")) argv[i] = (char *)IMAGE_DEVICE; i++; } @@ -1238,7 +1237,7 @@ static void alterDeviceTo(int argc, char *argv[], int toImage) } else { while (i < argc) { - if (strcmp(argv[i], IMAGE_DEVICE) == 0) { + if (streq(argv[i], IMAGE_DEVICE)) { if (dialect == xhtml) argv[i] = (char *)"-Txhtml"; else @@ -1697,9 +1696,9 @@ static int scanArguments(int argc, char **argv) break; case 'x': // html dialect - if (strcmp(optarg, "x") == 0) + if (streq(optarg, "x")) dialect = xhtml; - else if (strcmp(optarg, "4") == 0) + else if (streq(optarg, "4")) dialect = html4; else warning("unsupported HTML dialect: '%1'", optarg); @@ -1732,7 +1731,7 @@ static int scanArguments(int argc, char **argv) i = optind; while (i < argc) { - if (strcmp(argv[i], troff_name) == 0) + if (streq(argv[i], troff_name)) troff_arg = i; else if (argv[i][0] != '-') return i; @@ -1789,7 +1788,7 @@ static bool do_file(const char *filename) FILE *fp; current_filename = filename; - if (strcmp(filename, "-") == 0) + if (streq(filename, "-")) fp = stdin; else { fp = fopen(filename, "r"); diff --git a/src/preproc/html/pushback.cpp b/src/preproc/html/pushback.cpp index 9ecd4363ed13..8fb95436dc6f 100644 --- a/src/preproc/html/pushback.cpp +++ b/src/preproc/html/pushback.cpp @@ -66,7 +66,7 @@ pushBackBuffer::pushBackBuffer (const char *filename) verbose = 0; eofFound = FALSE; lineNo = 1; - if (strcmp(filename, "") != 0) { + if (!streq(filename, "")) { stdIn = dup(0); if (stdIn < 0) { sys_fatal("dup stdin"); diff --git a/src/preproc/pic/lex.cpp b/src/preproc/pic/lex.cpp index 247ec67e6177..56384064755e 100644 --- a/src/preproc/pic/lex.cpp +++ b/src/preproc/pic/lex.cpp @@ -1712,7 +1712,7 @@ int copy_thru_input::get_line() } while (c != ' ' && c != '\n'); line += '\0'; } - if (until != 0 && argc > 0 && strcmp(&line[argv[0]], until) == 0) { + if (until != 0 && argc > 0 && streq(&line[argv[0]], until)) { done = 1; return 0; } diff --git a/src/preproc/pic/main.cpp b/src/preproc/pic/main.cpp index 7bfb6d80440c..25a1a669221c 100644 --- a/src/preproc/pic/main.cpp +++ b/src/preproc/pic/main.cpp @@ -308,7 +308,7 @@ void do_picture(FILE *fp) void do_file(const char *filename) { FILE *fp; - if (strcmp(filename, "-") == 0) + if (streq(filename, "-")) fp = stdin; else { errno = 0; @@ -466,7 +466,7 @@ void do_whole_file(const char *filename) { // Do not set current_filename. FILE *fp; - if (strcmp(filename, "-") == 0) + if (streq(filename, "-")) fp = stdin; else { errno = 0; diff --git a/src/preproc/pic/pic.ypp b/src/preproc/pic/pic.ypp index a97751095afd..e0ce78bc9fad 100644 --- a/src/preproc/pic/pic.ypp +++ b/src/preproc/pic/pic.ypp @@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdcountof.h> #include <stdio.h> // fflush(), fprintf(), snprintf(), sprintf(), stderr #include <stdlib.h> // rand(), srand(), system() -#include <string.h> // strcat(), strchr(), strcmp(), strcpy(), strlen() +#include <string.h> // strcat(), strchr(), strcpy(), strlen() #ifdef NEED_DECLARATION_RAND #undef rand @@ -564,13 +564,13 @@ any_expr: text_expr: text EQUALEQUAL text { - $$ = strcmp($1.str, $3.str) == 0; + $$ = streq($1.str, $3.str); delete[] $1.str; delete[] $3.str; } | text NOTEQUAL text { - $$ = strcmp($1.str, $3.str) != 0; + $$ = !streq($1.str, $3.str); delete[] $1.str; delete[] $3.str; } @@ -1847,7 +1847,7 @@ void define_variable(const char *name, double val) p->x = val; p->y = 0.0; current_table->define(name, p); - if (strcmp(name, "scale") == 0) { + if (streq(name, "scale")) { // When the scale changes, reset all scaled predefined variables to // their default values. for (size_t i = 0; i < countof(defaults_table); i++) @@ -1871,7 +1871,7 @@ void parse_init() void reset(const char *nm) { for (size_t i = 0; i < countof(defaults_table); i++) - if (strcmp(nm, defaults_table[i].name) == 0) { + if (streq(nm, defaults_table[i].name)) { double val = defaults_table[i].val; if (defaults_table[i].scaled) { double scale; diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp index 478a83cc07e0..2fb1fa989212 100644 --- a/src/preproc/pic/troff.cpp +++ b/src/preproc/pic/troff.cpp @@ -593,7 +593,7 @@ bool strsame(const char *s, const char *t) { if ((s == 0 /* nullptr */) || (t == 0 /* nullptr */)) return false; - return (strcmp(s, t) == 0); + return streq(s, t); } void troff_output::set_location(const char *s, int n) diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp index 6fe23074e8b7..b35257f7d460 100644 --- a/src/preproc/preconv/preconv.cpp +++ b/src/preproc/preconv/preconv.cpp @@ -1116,7 +1116,7 @@ do_file(const char *filename) // TODO: Consider moving some of this into a `quoted_file_name` // function in libgroff. - if (strcmp(filename, "-") == 0) { + if (streq(filename, "-")) { fp = stdin; reported_filename = string("<standard input>"); } @@ -1152,7 +1152,7 @@ do_file(const char *filename) fprintf(stderr, " user-specified encoding '%s', " "no search for coding tag\n", user_encoding); - if (BOM_encoding && strcmp(BOM_encoding, user_encoding)) + if (BOM_encoding && !streq(BOM_encoding, user_encoding)) fprintf(stderr, " but BOM in data stream implies encoding" " '%s'!\n", BOM_encoding); } @@ -1261,7 +1261,7 @@ main(int argc, char **argv) // encoding. setlocale(LC_ALL, ""); char *locale = getlocale(LC_CTYPE); - if (!locale || !strcmp(locale, "C") || !strcmp(locale, "POSIX")) + if (!locale || streq(locale, "C") || streq(locale, "POSIX")) strcpy(fallback_encoding, "latin1"); else { strncpy(fallback_encoding, locale_charset(), MAX_VAR_LEN - 1); diff --git a/src/preproc/refer/command.cpp b/src/preproc/refer/command.cpp index 4ae2901bdbff..20e85bd14ed3 100644 --- a/src/preproc/refer/command.cpp +++ b/src/preproc/refer/command.cpp @@ -153,7 +153,7 @@ int input_stack::peek_char() void input_stack::push_file(const char *fn) { FILE *fp; - if (strcmp(fn, "-") == 0) { + if (streq(fn, "-")) { fp = stdin; fn = "<standard input>"; } @@ -761,7 +761,7 @@ static int check_args(const char *types, const char *name, static void execute_command(const char *name, int argc, argument *argv) { for (unsigned int i = 0; i < countof(command_table); i++) - if (strcmp(name, command_table[i].name) == 0) { + if (streq(name, command_table[i].name)) { if (check_args(command_table[i].arg_types, name, argc, argv)) (*command_table[i].func)(argc, argv); return; diff --git a/src/preproc/refer/refer.cpp b/src/preproc/refer/refer.cpp index e696323c2e1c..f7a8346e61e4 100644 --- a/src/preproc/refer/refer.cpp +++ b/src/preproc/refer/refer.cpp @@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ // setbuf(), sprintf(), stderr, stdin, stdout, // ungetc() #include <stdlib.h> // getenv(), qsort(), strtol() -#include <string.h> // strcat(), strchr(), strcmp(), strcpy(), +#include <string.h> // strcat(), strchr(), strcpy(), // strerror() #include "refer.h" // includes cset.h @@ -370,13 +370,13 @@ int main(int argc, char **argv) opt++; break; } - if (strcmp(opt, "-version") == 0) { + if (streq(opt, "-version")) { case 'v': printf("GNU refer (groff) version %s\n", Version_string); exit(EXIT_SUCCESS); break; } - if (strcmp(opt, "-help") == 0) { + if (streq(opt, "-help")) { usage(stdout); exit(EXIT_SUCCESS); break; @@ -459,7 +459,7 @@ static bool is_list(const string &str) static void do_file(const char *filename) { FILE *fp; - if (strcmp(filename, "-") == 0) { + if (streq(filename, "-")) { fp = stdin; } else { @@ -1158,7 +1158,7 @@ static void trim_blanks(string &str) void do_bib(const char *filename) { FILE *fp; - if (strcmp(filename, "-") == 0) + if (streq(filename, "-")) fp = stdin; else { errno = 0; diff --git a/src/preproc/refer/token.cpp b/src/preproc/refer/token.cpp index 35ec4394536b..8cc697c6f244 100644 --- a/src/preproc/refer/token.cpp +++ b/src/preproc/refer/token.cpp @@ -164,7 +164,7 @@ static void store_token(const char *tok, token_type typ, token_table[n].tok = tok; break; } - if (strcmp(tok, token_table[n].tok) == 0) + if (streq(tok, token_table[n].tok)) break; if (n == 0) n = TOKEN_TABLE_SIZE - 1; diff --git a/src/preproc/soelim/soelim.cpp b/src/preproc/soelim/soelim.cpp index e49c879a1987..fea770d847ac 100644 --- a/src/preproc/soelim/soelim.cpp +++ b/src/preproc/soelim/soelim.cpp @@ -199,7 +199,7 @@ static bool do_file(const char *filename) &file_name_in_path); int err = errno; string whole_filename(filename); - if (strcmp(filename, "-") && file_name_in_path != 0 /* nullptr */) + if (!streq(filename, "-") && file_name_in_path != 0 /* nullptr */) whole_filename = file_name_in_path; whole_filename += '\0'; free(file_name_in_path); diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp index fdceaa5b459e..6a66354f4228 100644 --- a/src/preproc/tbl/table.cpp +++ b/src/preproc/tbl/table.cpp @@ -3212,7 +3212,7 @@ const char *last_filename = 0; void set_troff_location(const char *fn, int ln) { if (!location_force_filename && last_filename != 0 - && strcmp(fn, last_filename) == 0) + && streq(fn, last_filename)) printfs(".lf %1\n", as_string(ln)); else { string filename(fn); diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp index ff2f0825f297..54defc34c33f 100644 --- a/src/roff/groff/groff.cpp +++ b/src/roff/groff/groff.cpp @@ -317,7 +317,7 @@ int main(int argc, char **argv) want_unsafe_mode = true; break; case 'T': - if (strcmp(optarg, "xhtml") == 0) { + if (streq(optarg, "xhtml")) { // force soelim to aid the html preprocessor commands[SOELIM_INDEX].set_name(command_prefix, "soelim"); Pargs += "-x"; @@ -328,10 +328,10 @@ int main(int argc, char **argv) device = "html"; break; } - if (strcmp(optarg, "html") == 0) + if (streq(optarg, "html")) // force soelim to aid the html preprocessor commands[SOELIM_INDEX].set_name(command_prefix, "soelim"); - if (strcmp(optarg, "Xps") == 0) { + if (streq(optarg, "Xps")) { warning("-TXps option is obsolete: use -X -Tps instead"); device = "ps"; Xflag++; @@ -439,8 +439,7 @@ int main(int argc, char **argv) } if (postdriver) commands[POST_INDEX].set_name(postdriver); - int gxditview_flag = postdriver - && strcmp(xbasename(postdriver), GXDITVIEW) == 0; + int gxditview_flag = postdriver && streq(xbasename(postdriver), GXDITVIEW); if (gxditview_flag && argc - optind == 1) { commands[POST_INDEX].append_arg("-title"); commands[POST_INDEX].append_arg(argv[optind]); @@ -486,7 +485,7 @@ int main(int argc, char **argv) commands[SPOOL_INDEX].set_name(0 /* nullptr */); } commands[TROFF_INDEX].append_arg("-T", device); - if (strcmp(device, "html") == 0) { + if (streq(device, "html")) { if (is_xhtml) { if (oflag) fatal("'-o' option is invalid with device 'xhtml'"); @@ -593,7 +592,7 @@ const char *xbasename(const char *s) void handle_unknown_desc_command(const char *command, const char *arg, const char *filename, int lineno) { - if (strcmp(command, "print") == 0) { + if (streq(command, "print")) { if (arg == 0 /* nullptr */) error_with_file_and_line(filename, lineno, "'print' directive" " requires an argument"); @@ -601,7 +600,7 @@ void handle_unknown_desc_command(const char *command, const char *arg, spooler = xstrdup(arg); return; } - if (strcmp(command, "prepro") == 0) { + if (streq(command, "prepro")) { if (arg == 0 /* nullptr */) error("'prepro' directive requires an argument"); else { @@ -615,7 +614,7 @@ void handle_unknown_desc_command(const char *command, const char *arg, } return; } - if (strcmp(command, "postpro") == 0) { + if (streq(command, "postpro")) { if (arg == 0 /* nullptr */) error_with_file_and_line(filename, lineno, "'postpro' directive" " requires an argument"); @@ -765,7 +764,7 @@ void possible_command::print(int is_last, FILE *fp) build_argv(); if (IS_BSHELL(argv[0]) && argv[1] != 0 /* nullptr */ - && strcmp(argv[1], BSHELL_DASH_C) == 0 + && streq(argv[1], BSHELL_DASH_C) && argv[2] != 0 /* nullptr */ && argv[3] == 0 /* nullptr */) fputs(argv[2], fp); else { diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index 1fe5b163181b..9f08a88da0f6 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -532,7 +532,7 @@ bool file_iterator::get_location(bool /*allow_macro*/, assert(filename != 0 /* nullptr */); if (0 /* nullptr */ == filename) return false; - if (strcmp(filename, "-") == 0) + if (streq(filename, "-")) *filenamep = "<standard input>"; else *filenamep = filename; @@ -1608,15 +1608,15 @@ static void define_color() return; } color *col; - if (strcmp(color_space.contents(), "rgb") == 0) + if (streq(color_space.contents(), "rgb")) col = read_rgb(); - else if (strcmp(color_space.contents(), "cmyk") == 0) + else if (streq(color_space.contents(), "cmyk")) col = read_cmyk(); - else if (strcmp(color_space.contents(), "gray") == 0) + else if (streq(color_space.contents(), "gray")) col = read_gray(); - else if (strcmp(color_space.contents(), "grey") == 0) + else if (streq(color_space.contents(), "grey")) col = read_gray(); - else if (strcmp(color_space.contents(), "cmy") == 0) + else if (streq(color_space.contents(), "cmy")) col = read_cmy(); else { warning(WARN_COLOR, "unknown color space '%1';" @@ -3524,12 +3524,12 @@ void process_input_stack() #if defined(DEBUGGING) if (want_html_debugging) { if (!nm.is_null()) { - if (strcmp(nm.contents(), "test") == 0) { + if (streq(nm.contents(), "test")) { fprintf(stderr, "found it!\n"); fflush(stderr); } fprintf(stderr, "interpreting [%s]", nm.contents()); - if (strcmp(nm.contents(), "di") == 0 && topdiv != curdiv) + if (streq(nm.contents(), "di") && topdiv != curdiv) fprintf(stderr, " currently in diversion: %s", curdiv->get_diversion_name()); fprintf(stderr, "\n"); @@ -4832,7 +4832,7 @@ static void map_composite_character() const char *to_decomposed = decompose_unicode(to_gn); if (to_decomposed != 0 /* nullptr */) to_gn = &to_decomposed[1]; - if (strcmp(from_gn, to_gn) == 0) + if (streq(from_gn, to_gn)) composite_dictionary.remove(symbol(from_gn)); else (void) composite_dictionary.lookup(symbol(from_gn), (void *) to_gn); @@ -6613,37 +6613,37 @@ static node *do_non_interpreted() // \? static void map_special_character_for_device_output(macro *mac, const char *sc) { - if (strcmp("-", sc) == 0) + if (streq("-", sc)) mac->append('-'); - else if (strcmp("dq", sc) == 0) + else if (streq("dq", sc)) mac->append('"'); - else if (strcmp("sh", sc) == 0) + else if (streq("sh", sc)) mac->append('#'); - else if (strcmp("Do", sc) == 0) + else if (streq("Do", sc)) mac->append('$'); - else if (strcmp("aq", sc) == 0) + else if (streq("aq", sc)) mac->append('\''); - else if (strcmp("sl", sc) == 0) + else if (streq("sl", sc)) mac->append('/'); - else if (strcmp("at", sc) == 0) + else if (streq("at", sc)) mac->append('@'); - else if (strcmp("lB", sc) == 0) + else if (streq("lB", sc)) mac->append('['); - else if (strcmp("rs", sc) == 0) + else if (streq("rs", sc)) mac->append('\\'); - else if (strcmp("rB", sc) == 0) + else if (streq("rB", sc)) mac->append(']'); - else if (strcmp("ha", sc) == 0) + else if (streq("ha", sc)) mac->append('^'); - else if (strcmp("lC", sc) == 0) + else if (streq("lC", sc)) mac->append('{'); - else if (strcmp("ba", sc) == 0) + else if (streq("ba", sc)) mac->append('|'); - else if (strcmp("or", sc) == 0) + else if (streq("or", sc)) mac->append('|'); - else if (strcmp("rC", sc) == 0) + else if (streq("rC", sc)) mac->append('}'); - else if (strcmp("ti", sc) == 0) + else if (streq("ti", sc)) mac->append('~'); else { if (font::use_charnames_in_special) { @@ -9729,7 +9729,7 @@ void macro_source_quietly_request() // .msoquiet static void process_input_file(const char *name) { FILE *fp; - if (strcmp(name, "-") == 0) { + if (streq(name, "-")) { clearerr(stdin); fp = stdin; } @@ -9917,7 +9917,7 @@ int main(int argc, char **argv) case 'T': device = optarg; have_explicit_device_argument = true; - is_writing_html = (strcmp(device, "html") == 0); + is_writing_html = streq(device, "html"); break; case 'C': want_att_compat = true; @@ -10037,7 +10037,7 @@ int main(int argc, char **argv) mac_path = ¯o_path; set_string(".T", device); // TODO: Kill this off in groff 1.24.0 release + 2 years. See env.cpp. - if ((strcmp("pdf", device) == 0) || strcmp("ps", device) == 0) + if (streq("pdf", device) || streq("ps", device)) is_device_ps_or_pdf = true; init_charset_table(); init_hpf_code_table(); @@ -10069,7 +10069,7 @@ int main(int argc, char **argv) for (i = 0; font::font_name_table[i] != 0 /* nullptr */; i++, j++) // In the DESC file, a font name of 0 (zero) means "leave this // position empty". - if (strcmp(font::font_name_table[i], "0") != 0) + if (!streq(font::font_name_table[i], "0")) if (!mount_font(j, symbol(font::font_name_table[i]))) warning(WARN_FONT, "cannot mount font '%1' directed by 'DESC'" " file for device '%2'", font::font_name_table[i], @@ -10609,7 +10609,7 @@ static struct warning_category { static unsigned int lookup_warning(const char *name) { for (unsigned int i = 0U; i < countof(warning_table); i++) - if (strcmp(name, warning_table[i].name) == 0) + if (streq(name, warning_table[i].name)) return warning_table[i].mask; return 0U; } @@ -11192,7 +11192,7 @@ void charinfo::dump() errprint(" is%1 translatable as input\n", translatable_as_input ? "" : " not"); const char *modestr = character_mode_description(mode); - if (strcmp(modestr, "") == 0) + if (streq(modestr, "")) modestr =" normal"; errprint(" mode:%1\n", modestr); } diff --git a/src/utils/addftinfo/addftinfo.cpp b/src/utils/addftinfo/addftinfo.cpp index c19d18b07275..a50d257a13d0 100644 --- a/src/utils/addftinfo/addftinfo.cpp +++ b/src/utils/addftinfo/addftinfo.cpp @@ -73,9 +73,9 @@ int main(int argc, char **argv) program_name = argv[0]; int i; for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-v") || !strcmp(argv[i],"--version")) + if (streq(argv[i], "-v") || streq(argv[i],"--version")) version(); - if (!strcmp(argv[i],"--help")) { + if (streq(argv[i],"--help")) { usage(stdout); exit(EXIT_SUCCESS); } @@ -118,7 +118,7 @@ int main(int argc, char **argv) for (j = 0;; j++) { if (j >= countof(param_table)) fatal("parameter '%1' not recognized", argv[i] + 1); - if (strcmp(param_table[j].name, argv[i] + 1) == 0) + if (streq(param_table[j].name, argv[i] + 1)) break; } if (sscanf(argv[i+1], "%d", &(param.*(param_table[j].par))) != 1) diff --git a/src/utils/hpftodit/hpftodit.cpp b/src/utils/hpftodit/hpftodit.cpp index ba6556ee0e15..b4d859bbae9f 100644 --- a/src/utils/hpftodit/hpftodit.cpp +++ b/src/utils/hpftodit/hpftodit.cpp @@ -35,7 +35,7 @@ put filename in error messages (or fix lib) // freopen(), printf(), sprintf() #include <stdlib.h> // atoi(), exit(), EXIT_FAILURE, EXIT_SUCCESS, // strtol() -#include <string.h> // strchr(), strcmp(), strerror(), strlen(), +#include <string.h> // strchr(), strerror(), strlen(), // strrchr(), strtok() #include <getopt.h> // getopt_long() @@ -52,7 +52,6 @@ put filename in error messages (or fix lib) extern "C" const char *Version_string; extern const char *hp_msl_to_unicode_code(const char *); -#define equal(a, b) (strcmp(a, b) == 0) // only valid if is_uname(c) has returned true #define is_decomposed(c) strchr(c, '_') @@ -362,7 +361,7 @@ main(int argc, char **argv) read_map(argv[optind + 1], tfm_type); current_filename = NULL; current_lineno = -1; // no line numbers - if (!debug_flag && !equal(argv[optind + 2], "-")) + if (!debug_flag && !streq(argv[optind + 2], "-")) if (freopen(argv[optind + 2], "w", stdout) == NULL) fatal("cannot open '%1': %2", argv[optind + 2], strerror(errno)); current_filename = argv[optind]; @@ -830,7 +829,7 @@ output_ligatures() && char_table[i].symbol_set != NO_SYMBOL_SET) { for (name_list *p = charcode_name_table[charcode]; p; p = p->next) for (unsigned int j = 0; j < countof(ligature_chars); j++) - if (strcmp(p->name, ligature_chars[j]) == 0) { + if (streq(p->name, ligature_chars[j])) { ligature_mask |= 1 << j; break; } @@ -866,7 +865,7 @@ read_and_output_kernpairs(File &f) for (name_list *q = charcode_name_table[char_table[i2].charcode]; q; q = q->next) - if (!equal(p->name, UNNAMED) && !equal(q->name, UNNAMED)) + if (!streq(p->name, UNNAMED) && !streq(q->name, UNNAMED)) printf("%s %s %d\n", p->name, q->name, scale(val)); } } @@ -968,7 +967,7 @@ output_charset(const int tfm_type) char *name = charcode_name_table[charcode]->name; // don't warn about Unicode or unnamed glyphs // that aren't in the TFM file - if (tfm_type == UNICODE && !quiet_flag && !equal(name, UNNAMED) + if (tfm_type == UNICODE && !quiet_flag && !streq(name, UNNAMED) && !is_uname(name)) { fprintf(stderr, "%s: warning: symbol U+%04X (%s", program_name, charcode, name); @@ -977,7 +976,7 @@ output_charset(const int tfm_type) fprintf(stderr, ", %s", p->name); fprintf(stderr, ") not in any searched symbol set\n"); } - else if (!quiet_flag && !equal(name, UNNAMED) && !is_uname(name)) { + else if (!quiet_flag && !streq(name, UNNAMED) && !is_uname(name)) { fprintf(stderr, "%s: warning: symbol MSL %d (%s", program_name, charcode, name); for (name_list *p = charcode_name_table[charcode]->next; @@ -1309,14 +1308,14 @@ hp_msl_to_ucode_name(int msl) if (ucode >= 0xE000 && ucode <= 0xF8FF) ustr = UNNAMED; } - if (!equal(ustr, UNNAMED)) { + if (!streq(ustr, UNNAMED)) { const char *uname_decomposed = decompose_unicode(ustr); if (uname_decomposed) // 1st char is the number of components ustr = uname_decomposed + 1; } char *value = new char[strlen(ustr) + 1]; - sprintf(value, equal(ustr, UNNAMED) ? UNNAMED : "u%s", ustr); + sprintf(value, streq(ustr, UNNAMED) ? UNNAMED : "u%s", ustr); return value; } @@ -1335,14 +1334,14 @@ unicode_to_ucode_name(int ucode) sprintf(codestr, "%04X", ucode); ustr = codestr; } - if (!equal(ustr, UNNAMED)) { + if (!streq(ustr, UNNAMED)) { const char *uname_decomposed = decompose_unicode(ustr); if (uname_decomposed) // 1st char is the number of components ustr = uname_decomposed + 1; } char *value = new char[strlen(ustr) + 1]; - sprintf(value, equal(ustr, UNNAMED) ? UNNAMED : "u%s", ustr); + sprintf(value, streq(ustr, UNNAMED) ? UNNAMED : "u%s", ustr); return value; } diff --git a/src/utils/indxbib/indxbib.cpp b/src/utils/indxbib/indxbib.cpp index 36df77915d8a..498ecd03479d 100644 --- a/src/utils/indxbib/indxbib.cpp +++ b/src/utils/indxbib/indxbib.cpp @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> // EOF, FILE, fclose(), fdopen(), fopen(), fprintf(), // fseek(), getc(), printf(), rename(), setbuf(), // stderr, stdin, stdout, ungetc() -#include <string.h> // strcat(), strchr(), strcmp(), strcpy(), +#include <string.h> // strcat(), strchr(), strcpy(), // strerror(), strlen(), strrchr() #include <getopt.h> // getopt_long() @@ -274,7 +274,7 @@ int main(int argc, char **argv) int failed = 0; if (foption) { FILE *fp = stdin; - if (strcmp(foption, "-") != 0) { + if (!streq(foption, "-")) { errno = 0; fp = fopen(foption, "r"); if (!fp) @@ -328,7 +328,7 @@ int main(int argc, char **argv) // Replace the dot with an underscore and try again. if (fname && (dot = strchr(fname, '.')) != 0 - && strcmp(dot, INDEX_SUFFIX) != 0) + && !streq(dot, INDEX_SUFFIX)) *dot = '_'; if (rename(temp_index_file, index_file) < 0) #endif diff --git a/src/utils/tfmtodit/tfmtodit.cpp b/src/utils/tfmtodit/tfmtodit.cpp index 25aa5d3e61ee..40255006a7a8 100644 --- a/src/utils/tfmtodit/tfmtodit.cpp +++ b/src/utils/tfmtodit/tfmtodit.cpp @@ -784,7 +784,7 @@ int main(int argc, char **argv) fputs("special\n", stdout); char *internal_name = strsave(argv[optind]); size_t len = strlen(internal_name); - if (len > 4 && strcmp(internal_name + len - 4, ".tfm") == 0) + if (len > 4 && streq(internal_name + len - 4, ".tfm")) internal_name[len - 4] = '\0'; // DIR_SEPS[] are possible directory separator characters, see // nonposix.h. We want the rightmost separator of all possible ones. @@ -818,7 +818,7 @@ int main(int argc, char **argv) for (i = 0; i < 256; i++) for (unsigned int j = 0; j < lig_char_entries; j++) for (char_list *p = table[i]; p; p = p->next) - if (strcmp(lig_chars[j].ch, p->ch) == 0) + if (streq(lig_chars[j].ch, p->ch)) lig_chars[j].i = i; // For each possible ligature, if its participants all exist, // and it appears as a ligature in the tfm file, include in diff --git a/src/utils/xtotroff/xtotroff.c b/src/utils/xtotroff/xtotroff.c index aa1ab8af1afa..ca34b8399a5c 100644 --- a/src/utils/xtotroff/xtotroff.c +++ b/src/utils/xtotroff/xtotroff.c @@ -111,7 +111,7 @@ FontNamesAmbiguous(const char *font_name, char **names, int count) program_name, names[i]); return true; } - if (i > 0 && strcmp(name1, name2) != 0) { + if (i > 0 && !streq(name1, name2)) { (void) fprintf(stderr, "%s: ambiguous font name: \"%s\"", program_name, font_name); (void) fprintf(stderr, " matches \"%s\"", names[0]); @@ -225,7 +225,7 @@ static bool MapFont(char *font_name, const char *troff_name) return false; } (void) fprintf(out, "name %s\n", troff_name); - if (!strcmp(char_map->encoding, "adobe-fontspecific")) + if (streq(char_map->encoding, "adobe-fontspecific")) (void) fprintf(out, "special\n"); if (charExists(fi, ' ')) { int w = charWidth(fi, ' '); -- 2.51.0
