]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Use bool where appropriate.
authorBruno Haible <bruno@clisp.org>
Wed, 24 Sep 2003 10:34:30 +0000 (10:34 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:01 +0000 (12:11 +0200)
gettext-runtime/src/ChangeLog
gettext-runtime/src/envsubst.c
gettext-runtime/src/gettext.c
gettext-runtime/src/ngettext.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/tstgettext.c
gettext-tools/tests/tstngettext.c

index 6580a5346e598b9b9318e20010932279a864cf16..c49c4fa062076739d775ae8709e51c6c7833607b 100644 (file)
@@ -1,3 +1,15 @@
+2003-09-16  Bruno Haible  <bruno@clisp.org>
+
+       * 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  <bruno@clisp.org>
 
        * envsubst.c (main): Remove stdout write error check, now done in
index 9396fe7a79e0ade6094e2444931514c7ff6e6ae6..1fb16342f3812f0e176571118be20d4fcd8da853 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <errno.h>
 #include <getopt.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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)
index 7a6fa516d1d67709de105b1740e8f74570b687a5..088a4f6dc815284c9f6cbe2dec9666fd3719bd96 100644 (file)
@@ -21,6 +21,7 @@
 #endif
 
 #include <getopt.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #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 */
index 8e6b03f77f38ac2e53284d475f25cda908a23f58..f0dbd96085216c389f06ced5516a51a77fb9465f 100644 (file)
@@ -20,6 +20,7 @@
 #endif
 
 #include <getopt.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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);
index 548b6f0b4a3b724685ef339f752b17a450a8c03f..6b258b9a723588cac6f3b286a7897a545c98c5f3 100644 (file)
@@ -1,3 +1,10 @@
+2003-09-16  Bruno Haible  <bruno@clisp.org>
+
+       * 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  <bruno@clisp.org>
 
        * lang-sh: Source gettext.sh.
index 3b2d9d2278c9a549091ddcbcc70c45fffeb2616d..fefe6fd31d787e6061f045a223bfa267aa110882 100644 (file)
 
 #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 */
index 0060ae0d0b48d0df9715aedcc6c054c48857e47a..b29474d8b9c01a667edff5eb9f09de40a5c0e379 100644 (file)
@@ -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 '=':
       {