+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
#include <errno.h>
#include <getopt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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[] =
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;
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);
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 ();
{
const char *variable_start;
const char *variable_end;
- int valid;
+ bool valid;
char c;
if (*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);
/* 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;
{
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);
}
/* Test whether the variable shall be substituted. */
if (!all_variables
&& !sorted_string_list_member (&variables_set, buffer))
- valid = 0;
+ valid = false;
}
if (valid)
#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[] =
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]);
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);
/* 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. */
++cp;
break;
case 'c': /* suppress trailing newline */
- add_newline = 0;
+ add_newline = false;
++cp;
break;
case 'f': /* form feed */
#endif
#include <getopt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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[] =
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]);
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);
+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.
#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[] =
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]);
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 '=':
{
/* 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. */
++cp;
break;
case 'c': /* suppress trailing newline */
- add_newline = 0;
+ add_newline = false;
++cp;
break;
case 'f': /* form feed */
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");
domain = optarg;
break;
case 'h':
- do_help = 1;
+ do_help = true;
break;
case 'V':
- do_version = 1;
+ do_version = true;
break;
case '=':
{