From: Bruno Haible Date: Wed, 24 Sep 2003 10:34:30 +0000 (+0000) Subject: Use bool where appropriate. X-Git-Tag: v0.13~232 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff75d3f15dec756e0596525b541b50495b75db58;p=thirdparty%2Fgettext.git Use bool where appropriate. --- diff --git a/gettext-runtime/src/ChangeLog b/gettext-runtime/src/ChangeLog index 6580a5346..c49c4fa06 100644 --- a/gettext-runtime/src/ChangeLog +++ b/gettext-runtime/src/ChangeLog @@ -1,3 +1,15 @@ +2003-09-16 Bruno Haible + + * envsubst.c: Include stdbool.h. + (all_variables): Change type to bool. + (main, find_variables, subst_from_stdin): Use bool. + * gettext.c: Include stdbool.h. + (add_newline, do_expand): Change type to bool. Make static. + (main, expand_escape): Use bool. + * ngettext.c: Include stdbool.h. + (do_expand): Change type to bool. Make static. + (main): Use bool. + 2003-09-14 Bruno Haible * envsubst.c (main): Remove stdout write error check, now done in diff --git a/gettext-runtime/src/envsubst.c b/gettext-runtime/src/envsubst.c index 9396fe7a7..1fb16342f 100644 --- a/gettext-runtime/src/envsubst.c +++ b/gettext-runtime/src/envsubst.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -38,8 +39,8 @@ #define _(str) gettext (str) -/* If nonzero, substitution shall be performed on all variables. */ -static int all_variables; +/* If true, substitution shall be performed on all variables. */ +static bool all_variables; /* Long options. */ static const struct option long_options[] = @@ -64,9 +65,9 @@ int main (int argc, char *argv[]) { /* Default values for command line options. */ - int show_variables = 0; - int do_help = 0; - int do_version = 0; + bool show_variables = false; + bool do_help = false; + bool do_version = false; int opt; @@ -92,13 +93,13 @@ main (int argc, char *argv[]) case '\0': /* Long option. */ break; case 'h': - do_help = 1; + do_help = false; break; case 'v': - show_variables = 1; + show_variables = false; break; case 'V': - do_version = 1; + do_version = false; break; default: usage (EXIT_FAILURE); @@ -146,11 +147,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ switch (argc - optind) { case 1: - all_variables = 0; + all_variables = false; note_variables (argv[optind++]); break; case 0: - all_variables = 1; + all_variables = true; break; default: abort (); @@ -236,7 +237,7 @@ find_variables (const char *string, { const char *variable_start; const char *variable_end; - int valid; + bool valid; char c; if (*string == '{') @@ -257,13 +258,13 @@ find_variables (const char *string, if (*string == '}') { string++; - valid = 1; + valid = true; } else - valid = 0; + valid = false; } else - valid = 1; + valid = true; if (valid) callback (variable_start, variable_end - variable_start); @@ -465,18 +466,18 @@ subst_from_stdin () /* Look for $VARIABLE or ${VARIABLE}. */ if (c == '$') { - int opening_brace = 0; - int closing_brace = 0; + bool opening_brace = false; + bool closing_brace = false; c = do_getc (); if (c == '{') { - opening_brace = 1; + opening_brace = true; c = do_getc (); } if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_') { - int valid; + bool valid; /* Accumulate the VARIABLE in buffer. */ buflen = 0; @@ -498,18 +499,18 @@ subst_from_stdin () { if (c == '}') { - closing_brace = 1; - valid = 1; + closing_brace = true; + valid = true; } else { - valid = 0; + valid = false; do_ungetc (c); } } else { - valid = 1; + valid = true; do_ungetc (c); } @@ -526,7 +527,7 @@ subst_from_stdin () /* Test whether the variable shall be substituted. */ if (!all_variables && !sorted_string_list_member (&variables_set, buffer)) - valid = 0; + valid = false; } if (valid) diff --git a/gettext-runtime/src/gettext.c b/gettext-runtime/src/gettext.c index 7a6fa516d..088a4f6dc 100644 --- a/gettext-runtime/src/gettext.c +++ b/gettext-runtime/src/gettext.c @@ -21,6 +21,7 @@ #endif #include +#include #include #include #include @@ -38,12 +39,13 @@ #define _(str) gettext (str) -/* If nonzero add newline after last string. This makes only sense in +/* If true, add newline after last string. This makes only sense in the `echo' emulation mode. */ -int add_newline; -/* If nonzero expand escape sequences in strings before looking in the +static bool add_newline; + +/* If true, expand escape sequences in strings before looking in the message catalog. */ -int do_expand; +static bool do_expand; /* Long options. */ static const struct option long_options[] = @@ -70,13 +72,13 @@ main (int argc, char *argv[]) const char *msgid; /* Default values for command line options. */ - int do_help = 0; - int do_shell = 0; - int do_version = 0; + bool do_help = false; + bool do_shell = false; + bool do_version = false; const char *domain = getenv ("TEXTDOMAIN"); const char *domaindir = getenv ("TEXTDOMAINDIR"); - add_newline = 1; - do_expand = 0; + add_newline = true; + do_expand = false; /* Set program name for message texts. */ set_program_name (argv[0]); @@ -104,22 +106,22 @@ main (int argc, char *argv[]) domain = optarg; break; case 'e': - do_expand = 1; + do_expand = true; break; case 'E': /* Ignore. Just for compatibility. */ break; case 'h': - do_help = 1; + do_help = true; break; case 'n': - add_newline = 0; + add_newline = false; break; case 's': - do_shell = 1; + do_shell = true; break; case 'V': - do_version = 1; + do_version = true; break; default: usage (EXIT_FAILURE); @@ -145,7 +147,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ /* We have two major modes: use following Uniforum spec and as internationalized `echo' program. */ - if (do_shell == 0) + if (!do_shell) { /* We have to write a single strings translation to stdout. */ @@ -310,7 +312,7 @@ expand_escape (const char *str) ++cp; break; case 'c': /* suppress trailing newline */ - add_newline = 0; + add_newline = false; ++cp; break; case 'f': /* form feed */ diff --git a/gettext-runtime/src/ngettext.c b/gettext-runtime/src/ngettext.c index 8e6b03f77..f0dbd9608 100644 --- a/gettext-runtime/src/ngettext.c +++ b/gettext-runtime/src/ngettext.c @@ -20,6 +20,7 @@ #endif #include +#include #include #include #include @@ -38,9 +39,9 @@ #define _(str) gettext (str) -/* If nonzero expand escape sequences in strings before looking in the +/* If true, expand escape sequences in strings before looking in the message catalog. */ -int do_expand; +static int do_expand; /* Long options. */ static const struct option long_options[] = @@ -69,11 +70,11 @@ main (int argc, char *argv[]) unsigned long n; /* Default values for command line options. */ - int do_help = 0; - int do_version = 0; + bool do_help = false; + bool do_version = false; const char *domain = getenv ("TEXTDOMAIN"); const char *domaindir = getenv ("TEXTDOMAINDIR"); - do_expand = 0; + do_expand = false; /* Set program name for message texts. */ set_program_name (argv[0]); @@ -101,16 +102,16 @@ main (int argc, char *argv[]) domain = optarg; break; case 'e': - do_expand = 1; + do_expand = true; break; case 'E': /* Ignore. Just for compatibility. */ break; case 'h': - do_help = 1; + do_help = true; break; case 'V': - do_version = 1; + do_version = true; break; default: usage (EXIT_FAILURE); diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 548b6f0b4..6b258b9a7 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,10 @@ +2003-09-16 Bruno Haible + + * tstgettext.c (add_newline, do_expand): Change type to bool. Make + static. + (main, expand_escape): Use bool. + * tstngettext.c (main): Use bool. + 2003-09-13 Bruno Haible * lang-sh: Source gettext.sh. diff --git a/gettext-tools/tests/tstgettext.c b/gettext-tools/tests/tstgettext.c index 3b2d9d227..fefe6fd31 100644 --- a/gettext-tools/tests/tstgettext.c +++ b/gettext-tools/tests/tstgettext.c @@ -43,12 +43,13 @@ #define _(str) gettext (str) -/* If nonzero add newline after last string. This makes only sense in +/* If true, add newline after last string. This makes only sense in the `echo' emulation mode. */ -int add_newline; -/* If nonzero expand escape sequences in strings before looking in the +static bool add_newline; + +/* If true, expand escape sequences in strings before looking in the message catalog. */ -int do_expand; +static bool do_expand; /* Long options. */ static const struct option long_options[] = @@ -76,14 +77,14 @@ main (int argc, char *argv[]) const char *msgid; /* Default values for command line options. */ - int do_help = 0; - int do_shell = 0; - int do_version = 0; + bool do_help = false; + bool do_shell = false; + bool do_version = false; bool environ_changed = false; const char *domain = getenv ("TEXTDOMAIN"); const char *domaindir = getenv ("TEXTDOMAINDIR"); - add_newline = 1; - do_expand = 0; + add_newline = true; + do_expand = false; /* Set program name for message texts. */ set_program_name (argv[0]); @@ -111,22 +112,22 @@ main (int argc, char *argv[]) domain = optarg; break; case 'e': - do_expand = 1; + do_expand = true; break; case 'E': /* Ignore. Just for compatibility. */ break; case 'h': - do_help = 1; + do_help = true; break; case 'n': - add_newline = 0; + add_newline = false; break; case 's': - do_shell = 1; + do_shell = true; break; case 'V': - do_version = 1; + do_version = true; break; case '=': { @@ -171,7 +172,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ /* We have two major modes: use following Uniforum spec and as internationalized `echo' program. */ - if (do_shell == 0) + if (!do_shell) { /* We have to write a single strings translation to stdout. */ @@ -336,7 +337,7 @@ expand_escape (const char *str) ++cp; break; case 'c': /* suppress trailing newline */ - add_newline = 0; + add_newline = false; ++cp; break; case 'f': /* form feed */ diff --git a/gettext-tools/tests/tstngettext.c b/gettext-tools/tests/tstngettext.c index 0060ae0d0..b29474d8b 100644 --- a/gettext-tools/tests/tstngettext.c +++ b/gettext-tools/tests/tstngettext.c @@ -68,8 +68,8 @@ main (int argc, char *argv[]) unsigned long n; /* Default values for command line options. */ - int do_help = 0; - int do_version = 0; + bool do_help = false; + bool do_version = false; bool environ_changed = false; const char *domain = getenv ("TEXTDOMAIN"); const char *domaindir = getenv ("TEXTDOMAINDIR"); @@ -100,10 +100,10 @@ main (int argc, char *argv[]) domain = optarg; break; case 'h': - do_help = 1; + do_help = true; break; case 'V': - do_version = 1; + do_version = true; break; case '=': {