From: Bruno Haible Date: Mon, 2 Jul 2001 12:58:44 +0000 (+0000) Subject: Use 'bool' where appropriate. X-Git-Tag: v0.11~635 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d9da1d5b82fd0fb061986a4fec6daf78f0ee788;p=thirdparty%2Fgettext.git Use 'bool' where appropriate. --- diff --git a/ChangeLog b/ChangeLog index 3225a37bd..bf4292198 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-06-30 Bruno Haible + + * configure.in: Call gt_STDBOOL_H. + 2001-06-25 Bruno Haible * configure.in (ACLOCAL_VERSION): Remove. diff --git a/configure.in b/configure.in index 4db37e377..f57c9085a 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.13) -AC_REVISION($Revision: 1.34 $) +AC_REVISION($Revision: 1.35 $) AC_INIT(src/msgfmt.c) AM_INIT_AUTOMAKE(gettext, 0.11) RELEASE_DATE=2001-05-23 dnl in "date +%Y-%m-%d" format @@ -34,6 +34,7 @@ dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(limits.h malloc.h string.h unistd.h values.h) +gt_STDBOOL_H dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/lib/ChangeLog b/lib/ChangeLog index e945f249a..5c9987906 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,14 @@ +2001-06-30 Bruno Haible + + * stdbool.h.in: New file. + * Makefile.am (EXTRA_DIST): Add stdbool.h.in. + (all-local): Depend on @STDBOOL_H@. + (stdbool.h): New rule. + (MOSTLYCLEANFILES): New variable. + * progname.h: Include stdbool.h. + (error_with_progname): Change type to bool. + * progname.c (error_with_progname): Likewise. + 2001-06-25 Bruno Haible * mbswidth.c (mbsinit): Define to 1 if not defined. For SCO 3.2v5.0.2. diff --git a/lib/Makefile.am b/lib/Makefile.am index 84ac17f57..abaae75a1 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -24,6 +24,7 @@ noinst_LIBRARIES = libnlsut.a EXTRA_DIST = alloca.c config.charset error.c getline.c memset.c memmove.c \ printf-prs.c ref-add.sin ref-del.sin stpcpy.c stpncpy.c strcasecmp.c \ strcspn.c strncasecmp.c strstr.c strtol.c strtoul.c vasprintf.c \ +stdbool.h.in \ gen-lbrkprop.c 3level.h libnlsut_a_SOURCES = basename.c c-ctype.c concatpath.c findprog.c fstrcmp.c \ @@ -42,6 +43,12 @@ DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@ INCLUDES = -I. -I$(srcdir) -I.. -I../intl +all-local: @STDBOOL_H@ +stdbool.h: stdbool.h.in + cp $(srcdir)/stdbool.h.in stdbool.h +MOSTLYCLEANFILES = @STDBOOL_H@ + + # The following is needed in order to install a simple file in $(libdir) # which is shared with other installed packages. We use a list of referencing # packages so that "make uninstall" will remove the file if and only if it diff --git a/lib/progname.c b/lib/progname.c index 7bf9ff466..9d3b93d07 100644 --- a/lib/progname.c +++ b/lib/progname.c @@ -45,7 +45,7 @@ set_program_name (argv0) /* Indicates whether errors and warnings get prefixed with program_name. Default is true. */ -int error_with_progname = 1; +bool error_with_progname = true; /* Print program_name prefix on stderr if and only if error_with_progname is true. */ diff --git a/lib/progname.h b/lib/progname.h index aaddd88fa..b6883115e 100644 --- a/lib/progname.h +++ b/lib/progname.h @@ -19,6 +19,8 @@ #ifndef _PROGNAME_H #define _PROGNAME_H +#include + /* This file supports selectively prefixing or nor prefixing error messages with the program name. @@ -37,7 +39,7 @@ extern void set_program_name PARAMS ((const char *argv0)); Default is true. A reason to omit the prefix is for better interoperability with Emacs' compile.el. */ -extern int error_with_progname; +extern bool error_with_progname; /* Print program_name prefix on stderr if and only if error_with_progname is true. */ diff --git a/lib/stdbool.h.in b/lib/stdbool.h.in new file mode 100644 index 000000000..705f93e42 --- /dev/null +++ b/lib/stdbool.h.in @@ -0,0 +1,34 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _STDBOOL_H +#define _STDBOOL_H + +/* ISO C 99 for platforms that lack it. */ + +/* 7.16. Boolean type and values */ + +/* For the sake of symbolic names in gdb, define _Bool as an enum type. */ +typedef enum { false = 0, true = 1 } _Bool; +#define bool _Bool + +/* The other macros must be usable in preprocessor directives. */ +#define false 0 +#define true 1 +#define __bool_true_false_are_defined 1 + +#endif /* _STDBOOL_H */ diff --git a/m4/ChangeLog b/m4/ChangeLog index 86a89d951..170f6962a 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,8 @@ +2001-06-30 Bruno Haible + + * stdbool.m4: New file. + * Makefile.am (EXTRA_DIST): Add it. + 2001-06-25 Bruno Haible * mbswidth.m4: Also check for mbsinit. Needed for SCO 3.2v5.0.2. diff --git a/m4/Makefile.am b/m4/Makefile.am index ed70d6097..aec67a2e0 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -9,5 +9,5 @@ aclocal_DATA = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage. EXTRA_DIST = README \ c-bs-a.m4 codeset.m4 getline.m4 gettext.m4 glibc21.m4 iconv.m4 \ inttypes_h.m4 isc-posix.m4 lcmessage.m4 libtool.m4 mbrtowc.m4 mbstate_t.m4 \ -mbswidth.m4 progtest.m4 setlocale.m4 signed.m4 ssize_t.m4 uintmax_t.m4 \ -ulonglong.m4 unionwait.m4 +mbswidth.m4 progtest.m4 setlocale.m4 signed.m4 ssize_t.m4 stdbool.m4 \ +uintmax_t.m4 ulonglong.m4 unionwait.m4 diff --git a/m4/stdbool.m4 b/m4/stdbool.m4 new file mode 100644 index 000000000..281e8dc0c --- /dev/null +++ b/m4/stdbool.m4 @@ -0,0 +1,31 @@ +dnl serial 1 + +dnl From Bruno Haible. +dnl Test whether is supported or must be substituted. + +AC_DEFUN([gt_STDBOOL_H], +[dnl gcc 2.95.2 has an for which both 'true' and 'false' evaluate +dnl to 0 in preprocessor expressions. +AC_MSG_CHECKING([for stdbool.h]) +AC_CACHE_VAL(gt_cv_header_stdbool_h, [ + AC_TRY_COMPILE([#include +#if false +int A[-1]; +#endif +#define b -1 +#if true +#undef b +#define b 1 +#endif +int B[b]; +], [], gt_cv_header_stdbool_h=yes, gt_cv_header_stdbool_h=no)]) +AC_MSG_RESULT([$gt_cv_header_stdbool_h]) +if test $gt_cv_header_stdbool_h = yes; then + AC_DEFINE(HAVE_STDBOOL_H, 1, + [Define if you have a working header file.]) + STDBOOL_H='' +else + STDBOOL_H='stdbool.h' +fi +AC_SUBST(STDBOOL_H) +]) diff --git a/src/ChangeLog b/src/ChangeLog index fb2cc07fc..7738401b0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,122 @@ +2001-06-30 Bruno Haible + + * message.h: Include stdbool.h. + (message_ty): Change type of fields 'is_fuzzy', 'obsolete' to bool. + (message_predicate_ty): Change return type to bool. + * message.c (message_alloc): Update. + * msgcat.c (is_message_selected): Change return type to bool. + (is_message_needed): Likewise. + (is_message_first_needed): Likewise. + (main): Use bool. + (catenate_msgdomain_list): Update. Use yes/no for is_c_format and + do_wrap. + * msgcmp.c (multi_domain_mode): Change type to bool. + (compare_directive_message): Change 'obsolete' argument type to bool. + (main): Use bool. + * msgcomm.c (is_message_selected): Change return type to bool. + (extract_directive_message): Change 'obsolete' argument type to bool. + (main): Use bool. + (struct extract_class_ty): Change type of field 'is_fuzzy' to bool. + Change type of field 'filepos_count' to size_t. + (extract_constructor): Update. + (extract_parse_brief): Update. + (extract_comment_special): Update. + (read_po_file): Update. + * msgconv.c (main): Use bool. + * msgen.c (main): Use bool. + * msgfmt.c (struct msgfmt_class_ty): Change type of fields 'is_fuzzy', + 'has_header_entry' to bool. + (include_all): Change type to bool. + (do_check): Likewise. + (long_options): Update. + (format_directive_message): Change 'obsolete' argument type to bool. + (main): Use bool. + (format_constructor): Update. + (format_debrief): Update. + (format_comment_special): Update. + (check_pair): Update. + * msggrep.c (is_string_selected): Change return type to bool. + (is_message_selected): Likewise. + (main): Use bool. + * msgl-charset.c (compare_po_locale_charsets): Use bool. + * msgl-iconv.c (iconv_message_list): Update. + * msgmerge.c (quiet): Change type to bool. + (multi_domain_mode): Likewise. + (main): Use bool. + (match_domain): Update. + (merge): Update. + * msgsed.c (main): Use bool. + * msgunfmt.c (main): Use bool. + * po-gram-gen.y (string, stringlist, number, pos, rhs): Change type of + 'obsolete' field to bool. + * po-lex.h: Include stdbool.h. + (pass_obsolete_entries): Change type to bool. + (po_lex_pass_comments): Change argument type to bool. + (po_lex_pass_obsolete_entries): Likewise. + (po_gram_error): Update. + (po_gram_error_at_line): Update. + * po-lex.c (po_lex_obsolete): Change type to bool. + (pass_comments): Likewise. + (pass_obsolete_entries): Likewise. + (lex_open): Update. + (lex_close): Update. + (po_gram_error): Update. + (po_gram_error_at_line): Update. + (po_gram_lex): Update. + (po_lex_pass_comments): Change argument type to bool. + (po_lex_pass_obsolete_entries): Likewise. + * po.h (struct po_method_ty): Change 'obsolete' argument type of + directive_message to bool. + (po_callback_message): Change 'obsolete' argument type to bool. + * po.c (po_directive_message): Change 'obsolete' argument type to bool. + (po_callback_message): Likewise. + * read-po.c (struct readall_class_ty): Change type of field 'is_fuzzy' + to bool. + (readall_directive_message): Change 'obsolete' argument type to bool. + (readall_constructor): Update. + (readall_parse_brief): Update. + (readall_comment_special): Update. + (read_po_file): Update. + * str-list.h: Include stdbool.h. + (string_list_member): Change return type to bool. + * str-list.c (string_list_member): Change return type to bool. + * write-po.h (message_print_style_escape, msgdomain_list_print): Change + argument type to bool. + * write-po.c (make_c_format_description_string) Change argument type + to bool. + (message_print): Likewise. + (message_print_obsolete): Likewise. + (indent): Change type to bool. + (uniforum): Likewise. + (escape): Likewise. + (message_print_style_indent): Update. + (message_print_style_uniforum): Update. + (message_print_style_escape): Change argument type to bool. + (wrap): Update. + (msgdomain_list_print): Change argument type to bool. + * xget-lex.h (xgettext_any_keywords): Change return type to bool. + * xget-lex.c (trigraphs): Change type to bool. + (default_keywords): Likewise. + (phase5_get): Use NULL not 0. Update. + (phaseX_get): Use bool. + (xgettext_lex): Update. + (xgettext_lex_keyword): Update. + (xgettext_any_keywords): Change return type to bool. + (xgettext_lex_trigraphs): Update. + * xgettext.c (add_all_comments): Change type to bool. + (extract_all): Likewise. + (long_options): Update. + (exclude_directive_message): Change 'obsolete' argument type to bool. + (extract_directive_message): Likewise. + (main): Use bool. + (scan_c_file): Update. + (struct extract_class_ty): Change type of field 'is_fuzzy' to bool. + Change type of field 'filepos_count' to size_t. + (extract_constructor): Update. + (extract_parse_brief): Update. + (extract_comment_special): Update. + (construct_header): Update. + 2001-06-25 Bruno Haible * msggrep.c (usage): Explain the pattern syntax. diff --git a/src/message.c b/src/message.c index ff8d07126..96c08f6e1 100644 --- a/src/message.c +++ b/src/message.c @@ -91,11 +91,11 @@ message_alloc (msgid, msgid_plural, msgstr, msgstr_len, pp) mp->comment_dot = NULL; mp->filepos_count = 0; mp->filepos = NULL; - mp->is_fuzzy = 0; + mp->is_fuzzy = false; mp->is_c_format = undecided; mp->do_wrap = undecided; mp->used = 0; - mp->obsolete = 0; + mp->obsolete = false; return mp; } diff --git a/src/message.h b/src/message.h index bee267a9e..c864951dc 100644 --- a/src/message.h +++ b/src/message.h @@ -23,6 +23,8 @@ #include "str-list.h" #include "pos.h" +#include + /* According to Sun's Uniforum proposal the default message domain is named 'messages'. */ #define MESSAGE_DOMAIN_DEFAULT "messages" @@ -90,7 +92,7 @@ struct message_ty lex_pos_ty *filepos; /* Informations from special comments (e.g. generated by msgmerge). */ - int is_fuzzy; + bool is_fuzzy; enum is_c_format is_c_format; /* Do we want the string to be wrapped in the emitted PO file? */ @@ -98,7 +100,7 @@ struct message_ty /* If set the message is obsolete and while writing out it should be commented out. */ - int obsolete; + bool obsolete; /* Used for checking that messages have been used, in the msgcmp, msgmerge, msgcomm and msgcat programs. */ @@ -146,7 +148,7 @@ extern void message_list_prepend PARAMS ((message_list_ty *mlp, message_ty *mp)); extern void message_list_delete_nth PARAMS ((message_list_ty *mlp, size_t n)); -typedef int message_predicate_ty PARAMS ((const message_ty *mp)); +typedef bool message_predicate_ty PARAMS ((const message_ty *mp)); extern void message_list_remove_if_not PARAMS ((message_list_ty *mlp, message_predicate_ty *predicate)); diff --git a/src/msgcat.c b/src/msgcat.c index 260f59844..5f8d235dd 100644 --- a/src/msgcat.c +++ b/src/msgcat.c @@ -87,9 +87,9 @@ static const struct option long_options[] = /* Prototypes for local functions. */ static void usage PARAMS ((int status)); static string_list_ty *read_name_from_file PARAMS ((const char *file_name)); -static int is_message_selected PARAMS ((const message_ty *tmp)); -static int is_message_needed PARAMS ((const message_ty *tmp)); -static int is_message_first_needed PARAMS ((const message_ty *tmp)); +static bool is_message_selected PARAMS ((const message_ty *tmp)); +static bool is_message_needed PARAMS ((const message_ty *tmp)); +static bool is_message_first_needed PARAMS ((const message_ty *tmp)); static msgdomain_list_ty * catenate_msgdomain_list PARAMS ((string_list_ty *file_list, const char *to_code)); @@ -102,14 +102,14 @@ main (argc, argv) { int cnt; int optchar; - int do_help; - int do_version; + bool do_help; + bool do_version; char *output_file; const char *files_from; string_list_ty *file_list; msgdomain_list_ty *result; - int sort_by_msgid = 0; - int sort_by_filepos = 0; + bool sort_by_msgid = false; + bool sort_by_filepos = false; /* Set program name for messages. */ program_name = argv[0]; @@ -125,8 +125,8 @@ main (argc, argv) textdomain (PACKAGE); /* Set default values for variables. */ - do_help = 0; - do_version = 0; + do_help = false; + do_version = false; output_file = NULL; files_from = NULL; @@ -162,11 +162,11 @@ main (argc, argv) break; case 'e': - message_print_style_escape (0); + message_print_style_escape (false); break; case 'E': - message_print_style_escape (1); + message_print_style_escape (true); break; case 'f': @@ -174,11 +174,11 @@ main (argc, argv) break; case 'F': - sort_by_filepos = 1; + sort_by_filepos = true; break; case 'h': - do_help = 1; + do_help = true; break; case 'i': @@ -194,7 +194,7 @@ main (argc, argv) break; case 's': - sort_by_msgid = 1; + sort_by_msgid = true; break; case 'S': @@ -210,7 +210,7 @@ main (argc, argv) break; case 'V': - do_version = 1; + do_version = true; break; case 'w': @@ -282,7 +282,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgdomain_list_sort_by_msgid (result); /* Write the PO file. */ - msgdomain_list_print (result, output_file, force_po, 0); + msgdomain_list_print (result, output_file, force_po, false); exit (EXIT_SUCCESS); } @@ -442,7 +442,7 @@ read_name_from_file (file_name) } -static int +static bool is_message_selected (tmp) const message_ty *tmp; { @@ -453,7 +453,7 @@ is_message_selected (tmp) } -static int +static bool is_message_needed (mp) const message_ty *mp; { @@ -467,17 +467,17 @@ is_message_needed (mp) /* The use_first logic. */ -static int +static bool is_message_first_needed (mp) const message_ty *mp; { if (mp->tmp->obsolete && is_message_needed (mp)) { - mp->tmp->obsolete = 0; - return 1; + mp->tmp->obsolete = false; + return true; } else - return 0; + return false; } @@ -518,7 +518,7 @@ catenate_msgdomain_list (file_list, to_code) if (mlp->nitems > 0) { for (j = 0; j < mlp->nitems; j++) - if (mlp->item[j]->msgid[0] == '\0' && mlp->item[j]->obsolete == 0) + if (mlp->item[j]->msgid[0] == '\0' && !mlp->item[j]->obsolete) { const char *header = mlp->item[j]->msgstr; @@ -588,7 +588,7 @@ domain \"%s\" in input file `%s' doesn't contain a header entry with a charset s char *project_id = NULL; for (j = 0; j < mlp->nitems; j++) - if (mlp->item[j]->msgid[0] == '\0' && mlp->item[j]->obsolete == 0) + if (mlp->item[j]->msgid[0] == '\0' && !mlp->item[j]->obsolete) { const char *header = mlp->item[j]->msgstr; @@ -658,9 +658,9 @@ domain \"%s\" in input file `%s' doesn't contain a header entry with a charset s { tmp = message_alloc (mp->msgid, mp->msgid_plural, NULL, 0, &mp->pos); - tmp->is_c_format = 0; /* may be set to 1 later */ - tmp->do_wrap = 1; /* may be set to 0 later */ - tmp->obsolete = 1; /* may be set to 0 later */ + tmp->is_c_format = no; /* may be set to yes later */ + tmp->do_wrap = yes; /* may be set to no later */ + tmp->obsolete = true; /* may be set to false later */ message_list_append (total_mlp, tmp); } @@ -725,7 +725,7 @@ domain \"%s\" in input file `%s' doesn't contain a header entry with a charset s all in a single encoding. If so, conversion is not needed. */ const char *first = NULL; const char *second = NULL; - int with_UTF8 = 0; + bool with_UTF8 = false; for (n = 0; n < nfiles; n++) { @@ -740,7 +740,7 @@ domain \"%s\" in input file `%s' doesn't contain a header entry with a charset s second = canon_charsets[n][k]; if (strcmp (canon_charsets[n][k], "UTF-8") == 0) - with_UTF8 = 1; + with_UTF8 = true; } } @@ -888,13 +888,13 @@ To select a different output encoding, use the --to-code option.\n\ for (i = 0; i < mp->filepos_count; i++) message_comment_filepos (tmp, mp->filepos[i].file_name, mp->filepos[i].line_number); - tmp->is_fuzzy = 1; - if (mp->is_c_format) - tmp->is_c_format = 1; - if (!mp->do_wrap) - tmp->do_wrap = 0; + tmp->is_fuzzy = true; + if (mp->is_c_format == yes) + tmp->is_c_format = yes; + if (mp->do_wrap == no) + tmp->do_wrap = no; if (!mp->obsolete) - tmp->obsolete = 0; + tmp->obsolete = false; } } } diff --git a/src/msgcmp.c b/src/msgcmp.c index 673c17020..5f2faeb45 100644 --- a/src/msgcmp.c +++ b/src/msgcmp.c @@ -39,7 +39,7 @@ /* Apply the .pot file to each of the domains in the PO file. */ -static int multi_domain_mode; +static bool multi_domain_mode = false; /* Long options. */ static const struct option long_options[] = @@ -68,7 +68,7 @@ static void compare_directive_message PARAMS ((po_ty *that, char *msgid, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); int @@ -77,8 +77,8 @@ main (argc, argv) char *argv[]; { int optchar; - int do_help; - int do_version; + bool do_help; + bool do_version; /* Set program name for messages. */ set_program_name (argv[0]); @@ -94,8 +94,8 @@ main (argc, argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - do_help = 0; - do_version = 0; + do_help = false; + do_version = false; while ((optchar = getopt_long (argc, argv, "D:hmV", long_options, NULL)) != EOF) switch (optchar) @@ -108,15 +108,15 @@ main (argc, argv) break; case 'h': - do_help = 1; + do_help = true; break; case 'm': - multi_domain_mode = 1; + multi_domain_mode = true; break; case 'V': - do_version = 1; + do_version = true; break; default: @@ -403,7 +403,7 @@ compare_directive_message (that, msgid, msgid_pos, msgid_plural, char *msgstr; size_t msgstr_len; lex_pos_ty *msgstr_pos; - int obsolete; + bool obsolete; { compare_class_ty *this = (compare_class_ty *) that; message_ty *mp; diff --git a/src/msgcomm.c b/src/msgcomm.c index 89d2d8aba..3c8733665 100644 --- a/src/msgcomm.c +++ b/src/msgcomm.c @@ -100,7 +100,7 @@ static void usage PARAMS ((int status)) #endif ; static string_list_ty *read_name_from_file PARAMS ((const char *file_name)); -static int is_message_selected PARAMS ((const message_ty *mp)); +static bool is_message_selected PARAMS ((const message_ty *mp)); static void extract_constructor PARAMS ((po_ty *that)); static void extract_directive_domain PARAMS ((po_ty *that, char *name)); static void extract_directive_message PARAMS ((po_ty *that, char *msgid, @@ -108,7 +108,7 @@ static void extract_directive_message PARAMS ((po_ty *that, char *msgid, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); static void extract_parse_brief PARAMS ((po_ty *that)); static void extract_comment PARAMS ((po_ty *that, const char *s)); static void extract_comment_dot PARAMS ((po_ty *that, const char *s)); @@ -126,12 +126,12 @@ main (argc, argv) { int cnt; int optchar; - int do_help = 0; - int do_version = 0; + bool do_help = false; + bool do_version = false; message_list_ty *mlp; msgdomain_list_ty *result; - int sort_by_msgid = 0; - int sort_by_filepos = 0; + bool sort_by_msgid = false; + bool sort_by_filepos = false; const char *files_from = NULL; string_list_ty *file_list; char *output_file = NULL; @@ -177,19 +177,19 @@ main (argc, argv) dir_list_append (optarg); break; case 'e': - message_print_style_escape (0); + message_print_style_escape (false); break; case 'E': - message_print_style_escape (1); + message_print_style_escape (true); break; case 'f': files_from = optarg; break; case 'F': - sort_by_filepos = 1; + sort_by_filepos = true; break; case 'h': - do_help = 1; + do_help = true; break; case 'i': message_print_style_indent (); @@ -201,7 +201,7 @@ main (argc, argv) output_file = optarg; break; case 's': - sort_by_msgid = 1; + sort_by_msgid = true; break; case 'S': message_print_style_uniforum (); @@ -210,7 +210,7 @@ main (argc, argv) less_than = 2; break; case 'V': - do_version = 1; + do_version = true; break; case 'w': { @@ -298,7 +298,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgdomain_list_sort_by_msgid (result); /* Write the PO file. */ - msgdomain_list_print (result, output_file, force_po, 0); + msgdomain_list_print (result, output_file, force_po, false); exit (EXIT_SUCCESS); } @@ -455,7 +455,7 @@ read_name_from_file (file_name) } -static int +static bool is_message_selected (mp) const message_ty *mp; { @@ -477,11 +477,11 @@ struct extract_class_ty string_list_ty *comment; string_list_ty *comment_dot; - int is_fuzzy; + bool is_fuzzy; enum is_c_format is_c_format; enum is_wrap do_wrap; - int filepos_count; + size_t filepos_count; lex_pos_ty *filepos; }; @@ -495,7 +495,7 @@ extract_constructor (that) this->mlp = NULL; /* actually set in read_po_file, below */ this->comment = NULL; this->comment_dot = NULL; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; this->filepos_count = 0; @@ -522,7 +522,7 @@ extract_directive_message (that, msgid, msgid_pos, msgid_plural, char *msgstr; size_t msgstr_len; lex_pos_ty *msgstr_pos; - int obsolete; + bool obsolete; { extract_class_ty *this = (extract_class_ty *)that; message_ty *mp; @@ -544,7 +544,7 @@ extract_directive_message (that, msgid, msgid_pos, msgid_plural, this->comment_dot = NULL; this->filepos_count = 0; this->filepos = NULL; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; return; @@ -566,9 +566,9 @@ extract_directive_message (that, msgid, msgid_pos, msgid_plural, /* The ``obsolete'' flag is cleared before reading each PO file. If thisflag is clear, set it, and increment the ``used'' counter. This allows us to count how many of the PO files use the message. */ - if (mp->obsolete == 0) + if (!mp->obsolete) { - mp->obsolete = 1; + mp->obsolete = true; mp->used++; } @@ -607,7 +607,7 @@ extract_directive_message (that, msgid, msgid_pos, msgid_plural, free (this->filepos); this->filepos_count = 0; this->filepos = NULL; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; } @@ -617,7 +617,7 @@ static void extract_parse_brief (that) po_ty *that; { - po_lex_pass_comments (1); + po_lex_pass_comments (true); } @@ -677,7 +677,7 @@ extract_comment_special (that, s) extract_class_ty *this = (extract_class_ty *) that; if (strstr (s, "fuzzy") != NULL) - this->is_fuzzy = 1; + this->is_fuzzy = true; if (strstr (s, "c-format") != NULL) this->is_c_format = yes; if (strstr (s, "no-c-format") != NULL) @@ -730,5 +730,5 @@ read_po_file (file_name, mlp) is clear, it is set, and increment the ``used'' counter. This allows us to count how many of the PO files use each message. */ for (j = 0; j < mlp->nitems; ++j) - mlp->item[j]->obsolete = 0; + mlp->item[j]->obsolete = false; } diff --git a/src/msgconv.c b/src/msgconv.c index 4dfb316d3..a13def596 100644 --- a/src/msgconv.c +++ b/src/msgconv.c @@ -79,13 +79,13 @@ main (argc, argv) char **argv; { int opt; - int do_help; - int do_version; + bool do_help; + bool do_version; char *output_file; const char *input_file; msgdomain_list_ty *result; - int sort_by_filepos = 0; - int sort_by_msgid = 0; + bool sort_by_filepos = false; + bool sort_by_msgid = false; /* Set program name for messages. */ program_name = argv[0]; @@ -101,8 +101,8 @@ main (argc, argv) textdomain (PACKAGE); /* Set default values for variables. */ - do_help = 0; - do_version = 0; + do_help = false; + do_version = false; output_file = NULL; input_file = NULL; @@ -118,19 +118,19 @@ main (argc, argv) break; case 'e': - message_print_style_escape (0); + message_print_style_escape (false); break; case 'E': - message_print_style_escape (1); + message_print_style_escape (true); break; case 'F': - sort_by_filepos = 1; + sort_by_filepos = true; break; case 'h': - do_help = 1; + do_help = true; break; case 'i': @@ -142,7 +142,7 @@ main (argc, argv) break; case 's': - sort_by_msgid = 1; + sort_by_msgid = true; break; case 'S': @@ -154,7 +154,7 @@ main (argc, argv) break; case 'V': - do_version = 1; + do_version = true; break; case 'w': @@ -219,7 +219,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgdomain_list_sort_by_msgid (result); /* Write the merged message list out. */ - msgdomain_list_print (result, output_file, force_po, 0); + msgdomain_list_print (result, output_file, force_po, false); exit (EXIT_SUCCESS); } diff --git a/src/msgen.c b/src/msgen.c index 75670b778..a555a45c7 100644 --- a/src/msgen.c +++ b/src/msgen.c @@ -73,12 +73,12 @@ main (argc, argv) char **argv; { int opt; - int do_help; - int do_version; + bool do_help; + bool do_version; char *output_file; msgdomain_list_ty *result; - int sort_by_filepos = 0; - int sort_by_msgid = 0; + bool sort_by_filepos = false; + bool sort_by_msgid = false; /* Set program name for messages. */ program_name = argv[0]; @@ -94,8 +94,8 @@ main (argc, argv) textdomain (PACKAGE); /* Set default values for variables. */ - do_help = 0; - do_version = 0; + do_help = false; + do_version = false; output_file = NULL; while ((opt = getopt_long (argc, argv, "D:eEFhio:sVw:", long_options, NULL)) @@ -110,19 +110,19 @@ main (argc, argv) break; case 'e': - message_print_style_escape (0); + message_print_style_escape (false); break; case 'E': - message_print_style_escape (1); + message_print_style_escape (true); break; case 'F': - sort_by_filepos = 1; + sort_by_filepos = true; break; case 'h': - do_help = 1; + do_help = true; break; case 'i': @@ -134,7 +134,7 @@ main (argc, argv) break; case 's': - sort_by_msgid = 1; + sort_by_msgid = true; break; case 'S': @@ -142,7 +142,7 @@ main (argc, argv) break; case 'V': - do_version = 1; + do_version = true; break; case 'w': @@ -204,7 +204,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgdomain_list_sort_by_msgid (result); /* Write the merged message list out. */ - msgdomain_list_print (result, output_file, force_po, 0); + msgdomain_list_print (result, output_file, force_po, false); exit (EXIT_SUCCESS); } diff --git a/src/msgfmt.c b/src/msgfmt.c index e44bf4165..edd7864c8 100644 --- a/src/msgfmt.c +++ b/src/msgfmt.c @@ -81,11 +81,11 @@ struct msgfmt_class_ty /* inherited instance variables, etc */ PO_BASE_TY - int is_fuzzy; + bool is_fuzzy; enum is_c_format is_c_format; enum is_wrap do_wrap; - int has_header_entry; + bool has_header_entry; }; /* Alignment of strings in resulting .mo file. */ @@ -94,8 +94,8 @@ static size_t alignment; /* Contains exit status for case in which no premature exit occurs. */ static int exit_status; -/* If nonzero include even fuzzy translations in output file. */ -static int include_all; +/* If true include even fuzzy translations in output file. */ +static bool include_all = false; /* Nonzero if no hash table in .mo is wanted. */ static int no_hash_table; @@ -123,9 +123,9 @@ static struct msg_domain *current_domain; /* If not zero list duplicate message identifiers. */ static int verbose_level; -/* If not zero check strings according to format string rules for the +/* If true check strings according to format string rules for the language. */ -static int do_check; +static bool do_check = false; /* Counters for statistics on translations for the processed files. */ static int msgs_translated; @@ -139,7 +139,7 @@ static int do_statistics; static const struct option long_options[] = { { "alignment", required_argument, NULL, 'a' }, - { "check", no_argument, &do_check, 1 }, + { "check", no_argument, NULL, 'c' }, { "directory", required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' }, { "no-hash", no_argument, &no_hash_table, 1 }, @@ -177,7 +177,7 @@ static void format_directive_message PARAMS ((po_ty *pop, char *msgid, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); static void format_comment_special PARAMS ((po_ty *pop, const char *s)); static void format_debrief PARAMS ((po_ty *)); static struct msg_domain *new_domain PARAMS ((const char *name, @@ -197,9 +197,9 @@ main (argc, argv) char *argv[]; { int opt; - int do_help = 0; - int do_version = 0; - int strict_uniforum = 0; + bool do_help = false; + bool do_version = false; + bool strict_uniforum = false; struct msg_domain *domain; /* Set default value for global variables. */ @@ -236,28 +236,28 @@ main (argc, argv) } break; case 'c': - do_check = 1; + do_check = true; break; case 'D': dir_list_append (optarg); break; case 'f': - include_all = 1; + include_all = true; break; case 'h': - do_help = 1; + do_help = true; break; case 'o': output_file_name = optarg; break; case 'S': - strict_uniforum = 1; + strict_uniforum = true; break; case 'v': ++verbose_level; break; case 'V': - do_version = 1; + do_version = true; break; default: usage (EXIT_FAILURE); @@ -299,7 +299,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ /* Prepare PO file reader. We need to see the comments because inexact translations must be reported. */ - po_lex_pass_comments (1); + po_lex_pass_comments (true); /* Now write out all domains. */ /* Process all given .po files. */ @@ -481,10 +481,10 @@ format_constructor (that) { msgfmt_class_ty *this = (msgfmt_class_ty *) that; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; - this->has_header_entry = 0; + this->has_header_entry = false; } @@ -498,7 +498,7 @@ format_debrief (that) /* Test whether header entry was found. FIXME: Should do this even if not in verbose mode, because the consequences are not harmless. But it breaks the test suite. */ - if (verbose_level > 0 && this->has_header_entry == 0) + if (verbose_level > 0 && !this->has_header_entry) { multiline_error (xasprintf ("%s: ", gram_pos.file_name), xasprintf (_("\ @@ -565,7 +565,7 @@ format_directive_message (that, msgid_string, msgid_pos, msgid_plural, char *msgstr_string; size_t msgstr_len; lex_pos_ty *msgstr_pos; - int obsolete; + bool obsolete; { msgfmt_class_ty *this = (msgfmt_class_ty *) that; struct hashtable_entry *entry; @@ -579,12 +579,12 @@ format_directive_message (that, msgid_string, msgid_pos, msgid_plural, { /* We don't change the exit status here because this is really only an information. */ - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgstr_pos->file_name, msgstr_pos->line_number, (msgstr_string[0] == '\0' ? _("empty `msgstr' entry ignored") : _("fuzzy `msgstr' entry ignored"))); - error_with_progname = 1; + error_with_progname = true; } /* Increment counter for fuzzy/untranslated messages. */ @@ -601,7 +601,7 @@ format_directive_message (that, msgid_string, msgid_pos, msgid_plural, /* Test for header entry. */ if (msgid_string[0] == '\0') { - this->has_header_entry = 1; + this->has_header_entry = true; /* Do some more tests on test contents of the header entry. */ if (verbose_level > 0) @@ -721,7 +721,7 @@ duplicate message definition")); free (msgid_string); /* Prepare for next message. */ - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; } @@ -737,17 +737,17 @@ format_comment_special (that, s) if (strstr (s, "fuzzy") != NULL) { - static int warned = 0; + static bool warned = false; - if (!include_all && verbose_level > 1 && warned == 0) + if (!include_all && verbose_level > 1 && !warned) { - warned = 1; + warned = true; error (0, 0, _("\ %s: warning: source file contains fuzzy translation"), gram_pos.file_name); } - this->is_fuzzy = 1; + this->is_fuzzy = true; } this->is_c_format = parse_c_format_description_string (s); this->do_wrap = parse_c_width_description_string (s); @@ -963,21 +963,21 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos, { if (TEST_NEWLINE(msgid_plural) != has_newline) { - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number, _("\ `msgid' and `msgid_plural' entries do not both begin with '\\n'")); - error_with_progname = 1; + error_with_progname = true; exit_status = EXIT_FAILURE; } for (p = msgstr, i = 0; p < msgstr + msgstr_len; p += strlen (p) + 1, i++) if (TEST_NEWLINE(p) != has_newline) { - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number, _("\ `msgid' and `msgstr[%u]' entries do not both begin with '\\n'"), i); - error_with_progname = 1; + error_with_progname = true; exit_status = EXIT_FAILURE; } } @@ -985,11 +985,11 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos, { if (TEST_NEWLINE(msgstr) != has_newline) { - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number, _("\ `msgid' and `msgstr' entries do not both begin with '\\n'")); - error_with_progname = 1; + error_with_progname = true; exit_status = EXIT_FAILURE; } } @@ -1002,21 +1002,21 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos, { if (TEST_NEWLINE(msgid_plural) != has_newline) { - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number, _("\ `msgid' and `msgid_plural' entries do not both end with '\\n'")); - error_with_progname = 1; + error_with_progname = true; exit_status = EXIT_FAILURE; } for (p = msgstr, i = 0; p < msgstr + msgstr_len; p += strlen (p) + 1, i++) if (TEST_NEWLINE(p) != has_newline) { - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number, _("\ `msgid' and `msgstr[%u]' entries do not both end with '\\n'"), i); - error_with_progname = 1; + error_with_progname = true; exit_status = EXIT_FAILURE; } } @@ -1024,11 +1024,11 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos, { if (TEST_NEWLINE(msgstr) != has_newline) { - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number, _("\ `msgid' and `msgstr' entries do not both end with '\\n'")); - error_with_progname = 1; + error_with_progname = true; exit_status = EXIT_FAILURE; } } @@ -1042,11 +1042,11 @@ check_pair (msgid, msgid_pos, msgid_plural, msgstr, msgstr_len, msgstr_pos, nstrfmts = parse_printf_format (msgstr, 0, NULL); if (nidfmts != nstrfmts) { - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number, _("\ number of format specifications in `msgid' and `msgstr' does not match")); - error_with_progname = 1; + error_with_progname = true; exit_status = EXIT_FAILURE; } else @@ -1061,12 +1061,12 @@ number of format specifications in `msgid' and `msgstr' does not match")); for (cnt = 0; cnt < nidfmts; ++cnt) if (id_args[cnt] != str_args[cnt]) { - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, msgid_pos->file_name, msgid_pos->line_number, _("\ format specifications for argument %lu are not the same"), (unsigned long) (cnt + 1)); - error_with_progname = 1; + error_with_progname = true; exit_status = EXIT_FAILURE; } } diff --git a/src/msggrep.c b/src/msggrep.c index 47b0eefec..0ed0eee21 100644 --- a/src/msggrep.c +++ b/src/msggrep.c @@ -108,9 +108,9 @@ static void usage PARAMS ((int status)); #ifdef EINTR static inline int nonintr_close PARAMS ((int fd)); #endif -static int is_string_selected PARAMS ((int grep_pass, const char *str, - size_t len)); -static int is_message_selected PARAMS ((const message_ty *mp)); +static bool is_string_selected PARAMS ((int grep_pass, const char *str, + size_t len)); +static bool is_message_selected PARAMS ((const message_ty *mp)); static void process_message_list PARAMS ((const char *domain, message_list_ty *mlp)); static msgdomain_list_ty * @@ -123,14 +123,14 @@ main (argc, argv) char **argv; { int opt; - int do_help; - int do_version; + bool do_help; + bool do_version; char *output_file; const char *input_file; int grep_pass; msgdomain_list_ty *result; - int sort_by_filepos = 0; - int sort_by_msgid = 0; + bool sort_by_filepos = false; + bool sort_by_msgid = false; size_t i; /* Set program name for messages. */ @@ -147,8 +147,8 @@ main (argc, argv) textdomain (PACKAGE); /* Set default values for variables. */ - do_help = 0; - do_version = 0; + do_help = false; + do_version = false; output_file = NULL; input_file = NULL; grep_pass = -1; @@ -196,7 +196,7 @@ main (argc, argv) break; case 'h': - do_help = 1; + do_help = true; break; case 'i': @@ -230,7 +230,7 @@ main (argc, argv) break; case 'V': - do_version = 1; + do_version = true; break; case 'w': @@ -244,7 +244,7 @@ main (argc, argv) break; case CHAR_MAX + 1: - message_print_style_escape (1); + message_print_style_escape (true); break; case CHAR_MAX + 2: @@ -252,15 +252,15 @@ main (argc, argv) break; case CHAR_MAX + 3: - message_print_style_escape (0); + message_print_style_escape (false); break; case CHAR_MAX + 4: - sort_by_filepos = 1; + sort_by_filepos = true; break; case CHAR_MAX + 5: - sort_by_msgid = 1; + sort_by_msgid = true; break; default: @@ -340,7 +340,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgdomain_list_sort_by_msgid (result); /* Write the merged message list out. */ - msgdomain_list_print (result, output_file, force_po, 0); + msgdomain_list_print (result, output_file, force_po, false); exit (EXIT_SUCCESS); } @@ -480,9 +480,9 @@ nonintr_close (fd) #endif -/* Process a string STR of size LEN bytes through grep, and return nonzero +/* Process a string STR of size LEN bytes through grep, and return true if it matches. */ -static int +static bool is_string_selected (grep_pass, str, len) int grep_pass; const char *str; @@ -515,8 +515,8 @@ is_string_selected (grep_pass, str, len) } -/* Return nonzero if a message matches. */ -static int +/* Return true if a message matches. */ +static bool is_message_selected (mp) const message_ty *mp; { @@ -527,19 +527,19 @@ is_message_selected (mp) /* Always keep the header entry. */ if (mp->msgid[0] == '\0') - return 1; + return true; /* Test whether one of mp->filepos[] is selected. */ for (i = 0; i < mp->filepos_count; i++) if (string_list_member (location_files, mp->filepos[i].file_name)) - return 1; + return true; /* Test msgid and msgid_plural using the --msgid arguments. */ if (is_string_selected (0, mp->msgid, strlen (mp->msgid))) - return 1; + return true; if (mp->msgid_plural != NULL && is_string_selected (0, mp->msgid_plural, strlen (mp->msgid_plural))) - return 1; + return true; /* Test msgstr using the --msgstr arguments. */ msgstr = mp->msgstr; @@ -550,12 +550,12 @@ is_message_selected (mp) size_t length = strlen (p); if (is_string_selected (1, p, length)) - return 1; + return true; p += length + 1; } - return 0; + return false; } diff --git a/src/msgl-charset.c b/src/msgl-charset.c index ccc7c840e..f7db13cfe 100644 --- a/src/msgl-charset.c +++ b/src/msgl-charset.c @@ -43,20 +43,20 @@ compare_po_locale_charsets (mdlp) { const char *locale_code; const char *canon_locale_code; - int warned; + bool warned; size_t j, k; /* Check whether the locale encoding and the PO file's encoding are the same. Otherwise emit a warning. */ locale_code = locale_charset (); canon_locale_code = po_charset_canonicalize (locale_code); - warned = 0; + warned = false; for (k = 0; k < mdlp->nitems; k++) { const message_list_ty *mlp = mdlp->item[k]->messages; for (j = 0; j < mlp->nitems; j++) - if (mlp->item[j]->msgid[0] == '\0' && mlp->item[j]->obsolete == 0) + if (mlp->item[j]->msgid[0] == '\0' && !mlp->item[j]->obsolete) { const char *header = mlp->item[j]->msgstr; @@ -112,7 +112,7 @@ Possible workarounds are:\n\ then apply '%s',\n\ then convert back to %s using 'msgconv'.\n\ "), "UTF-8", "UTF-8", basename (program_name), canon_charset)); - warned = 1; + warned = true; } } } diff --git a/src/msgl-iconv.c b/src/msgl-iconv.c index 4ac759e6c..1d1ec462f 100644 --- a/src/msgl-iconv.c +++ b/src/msgl-iconv.c @@ -264,7 +264,7 @@ iconv_message_list (mlp, canon_to_code) /* Search the header entry, and extract and replace the charset name. */ canon_from_code = NULL; for (j = 0; j < mlp->nitems; j++) - if (mlp->item[j]->msgid[0] == '\0' && mlp->item[j]->obsolete == 0) + if (mlp->item[j]->msgid[0] == '\0' && !mlp->item[j]->obsolete) { const char *header = mlp->item[j]->msgstr; diff --git a/src/msgmerge.c b/src/msgmerge.c index 58a1d9427..79d618d02 100644 --- a/src/msgmerge.c +++ b/src/msgmerge.c @@ -39,8 +39,8 @@ #define _(str) gettext (str) -/* If non-zero do not print unneeded messages. */ -static int quiet; +/* If true do not print unneeded messages. */ +static bool quiet; /* Verbosity level. */ static int verbosity_level; @@ -49,7 +49,7 @@ static int verbosity_level; static int force_po; /* Apply the .pot file to each of the domains in the PO file. */ -static int multi_domain_mode; +static bool multi_domain_mode = false; /* List of user-specified compendiums. */ static message_list_list_ty *compendiums; @@ -107,18 +107,18 @@ main (argc, argv) char **argv; { int opt; - int do_help; - int do_version; + bool do_help; + bool do_version; char *output_file; msgdomain_list_ty *result; - int sort_by_filepos = 0; - int sort_by_msgid = 0; + bool sort_by_filepos = false; + bool sort_by_msgid = false; /* Set program name for messages. */ set_program_name (argv[0]); error_print_progname = maybe_print_progname; verbosity_level = 0; - quiet = 0; + quiet = false; gram_max_allowed_errors = UINT_MAX; #ifdef HAVE_SETLOCALE @@ -131,8 +131,8 @@ main (argc, argv) textdomain (PACKAGE); /* Set default values for variables. */ - do_help = 0; - do_version = 0; + do_help = false; + do_version = false; output_file = NULL; while ((opt @@ -152,19 +152,19 @@ main (argc, argv) break; case 'e': - message_print_style_escape (0); + message_print_style_escape (false); break; case 'E': - message_print_style_escape (1); + message_print_style_escape (true); break; case 'F': - sort_by_filepos = 1; + sort_by_filepos = true; break; case 'h': - do_help = 1; + do_help = true; break; case 'i': @@ -172,7 +172,7 @@ main (argc, argv) break; case 'm': - multi_domain_mode = 1; + multi_domain_mode = true; break; case 'o': @@ -180,11 +180,11 @@ main (argc, argv) break; case 'q': - quiet = 1; + quiet = true; break; case 's': - sort_by_msgid = 1; + sort_by_msgid = true; break; case 'S': @@ -196,7 +196,7 @@ main (argc, argv) break; case 'V': - do_version = 1; + do_version = true; break; case 'w': @@ -258,7 +258,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgdomain_list_sort_by_msgid (result); /* Write the merged message list out. */ - msgdomain_list_print (result, output_file, force_po, 0); + msgdomain_list_print (result, output_file, force_po, false); exit (EXIT_SUCCESS); } @@ -435,7 +435,7 @@ this message is used but not defined...")); this merged entry to the output message list. */ mp = message_merge (defmsg, refmsg); - mp->is_fuzzy = 1; + mp->is_fuzzy = true; message_list_append (resultmlp, mp); @@ -564,7 +564,7 @@ merge (fn1, fn2) { /* Remember the old translation although it is not used anymore. But we mark it as obsolete. */ - defmsg->obsolete = 1; + defmsg->obsolete = true; message_list_append (msgdomain_list_sublist (result, domain, 1), defmsg); diff --git a/src/msgsed.c b/src/msgsed.c index fd612f8bf..1d41c255f 100644 --- a/src/msgsed.c +++ b/src/msgsed.c @@ -128,13 +128,13 @@ main (argc, argv) char **argv; { int opt; - int do_help; - int do_version; + bool do_help; + bool do_version; char *output_file; const char *input_file; msgdomain_list_ty *result; - int sort_by_filepos = 0; - int sort_by_msgid = 0; + bool sort_by_filepos = false; + bool sort_by_msgid = false; size_t i; /* Set program name for messages. */ @@ -151,8 +151,8 @@ main (argc, argv) textdomain (PACKAGE); /* Set default values for variables. */ - do_help = 0; - do_version = 0; + do_help = false; + do_version = false; output_file = NULL; input_file = NULL; sed_args = string_list_alloc (); @@ -175,7 +175,7 @@ main (argc, argv) break; case 'E': - message_print_style_escape (1); + message_print_style_escape (true); break; case 'f': @@ -184,11 +184,11 @@ main (argc, argv) break; case 'F': - sort_by_filepos = 1; + sort_by_filepos = true; break; case 'h': - do_help = 1; + do_help = true; break; case 'i': @@ -204,7 +204,7 @@ main (argc, argv) break; case 's': - sort_by_msgid = 1; + sort_by_msgid = true; break; case 'S': @@ -212,7 +212,7 @@ main (argc, argv) break; case 'V': - do_version = 1; + do_version = true; break; case 'w': @@ -226,7 +226,7 @@ main (argc, argv) break; case CHAR_MAX + 1: - message_print_style_escape (0); + message_print_style_escape (false); break; default: @@ -298,7 +298,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgdomain_list_sort_by_msgid (result); /* Write the merged message list out. */ - msgdomain_list_print (result, output_file, force_po, 0); + msgdomain_list_print (result, output_file, force_po, false); exit (EXIT_SUCCESS); } diff --git a/src/msgunfmt.c b/src/msgunfmt.c index cd52c85aa..25de802bb 100644 --- a/src/msgunfmt.c +++ b/src/msgunfmt.c @@ -91,12 +91,12 @@ main (argc, argv) char **argv; { int optchar; - int do_help = 0; - int do_version = 0; + bool do_help = false; + bool do_version = false; const char *output_file = "-"; message_list_ty *mlp; msgdomain_list_ty *result; - int sort_by_msgid = 0; + bool sort_by_msgid = false; /* Set program name for messages. */ set_program_name (argv[0]); @@ -120,15 +120,15 @@ main (argc, argv) break; case 'e': - message_print_style_escape (0); + message_print_style_escape (false); break; case 'E': - message_print_style_escape (1); + message_print_style_escape (true); break; case 'h': - do_help = 1; + do_help = true; break; case 'i': @@ -140,7 +140,7 @@ main (argc, argv) break; case 's': - sort_by_msgid = 1; + sort_by_msgid = true; break; case 'S': @@ -148,7 +148,7 @@ main (argc, argv) break; case 'V': - do_version = 1; + do_version = true; break; case 'w': @@ -203,7 +203,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgdomain_list_sort_by_msgid (result); /* Write the resulting message list to the given .po file. */ - msgdomain_list_print (result, output_file, force_po, 0); + msgdomain_list_print (result, output_file, force_po, false); /* No problems. */ exit (EXIT_SUCCESS); diff --git a/src/po-gram-gen.c b/src/po-gram-gen.c index 66613ec2f..d9ba0876a 100644 --- a/src/po-gram-gen.c +++ b/src/po-gram-gen.c @@ -89,11 +89,11 @@ static long plural_counter; #line 103 "po-gram-gen.y" typedef union { - struct { char *string; lex_pos_ty pos; int obsolete; } string; - struct { string_list_ty stringlist; lex_pos_ty pos; int obsolete; } stringlist; - struct { long number; lex_pos_ty pos; int obsolete; } number; - struct { lex_pos_ty pos; int obsolete; } pos; - struct { struct msgstr_def rhs; lex_pos_ty pos; int obsolete; } rhs; + struct { char *string; lex_pos_ty pos; bool obsolete; } string; + struct { string_list_ty stringlist; lex_pos_ty pos; bool obsolete; } stringlist; + struct { long number; lex_pos_ty pos; bool obsolete; } number; + struct { lex_pos_ty pos; bool obsolete; } pos; + struct { struct msgstr_def rhs; lex_pos_ty pos; bool obsolete; } rhs; } YYSTYPE; #include diff --git a/src/po-gram-gen.h b/src/po-gram-gen.h index 13c74814c..dd0c6c9c6 100644 --- a/src/po-gram-gen.h +++ b/src/po-gram-gen.h @@ -1,10 +1,10 @@ typedef union { - struct { char *string; lex_pos_ty pos; int obsolete; } string; - struct { string_list_ty stringlist; lex_pos_ty pos; int obsolete; } stringlist; - struct { long number; lex_pos_ty pos; int obsolete; } number; - struct { lex_pos_ty pos; int obsolete; } pos; - struct { struct msgstr_def rhs; lex_pos_ty pos; int obsolete; } rhs; + struct { char *string; lex_pos_ty pos; bool obsolete; } string; + struct { string_list_ty stringlist; lex_pos_ty pos; bool obsolete; } stringlist; + struct { long number; lex_pos_ty pos; bool obsolete; } number; + struct { lex_pos_ty pos; bool obsolete; } pos; + struct { struct msgstr_def rhs; lex_pos_ty pos; bool obsolete; } rhs; } YYSTYPE; #define COMMENT 257 #define DOMAIN 258 diff --git a/src/po-gram-gen.y b/src/po-gram-gen.y index b539b56b6..510cd37a3 100644 --- a/src/po-gram-gen.y +++ b/src/po-gram-gen.y @@ -102,11 +102,11 @@ static long plural_counter; %union { - struct { char *string; lex_pos_ty pos; int obsolete; } string; - struct { string_list_ty stringlist; lex_pos_ty pos; int obsolete; } stringlist; - struct { long number; lex_pos_ty pos; int obsolete; } number; - struct { lex_pos_ty pos; int obsolete; } pos; - struct { struct msgstr_def rhs; lex_pos_ty pos; int obsolete; } rhs; + struct { char *string; lex_pos_ty pos; bool obsolete; } string; + struct { string_list_ty stringlist; lex_pos_ty pos; bool obsolete; } stringlist; + struct { long number; lex_pos_ty pos; bool obsolete; } number; + struct { lex_pos_ty pos; bool obsolete; } pos; + struct { struct msgstr_def rhs; lex_pos_ty pos; bool obsolete; } rhs; } %type STRING COMMENT NAME msgid_pluralform diff --git a/src/po-lex.c b/src/po-lex.c index f94e81b74..25060ecb5 100644 --- a/src/po-lex.c +++ b/src/po-lex.c @@ -61,9 +61,9 @@ static FILE *fp; lex_pos_ty gram_pos; unsigned int gram_max_allowed_errors = 20; -static int po_lex_obsolete; -static int pass_comments = 0; -int pass_obsolete_entries = 0; +static bool po_lex_obsolete; +static bool pass_comments = false; +bool pass_obsolete_entries = false; /* Prototypes for local functions. Needed to ensure compiler checking of @@ -85,7 +85,7 @@ lex_open (fname) _("error while opening \"%s\" for reading"), fname); gram_pos.line_number = 1; - po_lex_obsolete = 0; + po_lex_obsolete = false; po_lex_charset_init (); } @@ -103,10 +103,10 @@ lex_close () if (fp != stdin) fclose (fp); fp = NULL; - gram_pos.file_name = 0; + gram_pos.file_name = NULL; gram_pos.line_number = 0; error_message_count = 0; - po_lex_obsolete = 0; + po_lex_obsolete = false; po_lex_charset_close (); } @@ -133,14 +133,14 @@ po_gram_error (fmt, va_alist) vasprintf (&buffer, fmt, ap); va_end (ap); - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number, "%s", buffer); - error_with_progname = 1; + error_with_progname = true; # else - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number, fmt, a1, a2, a3, a4, a5, a6, a7, a8); - error_with_progname = 1; + error_with_progname = true; # endif /* Some messages need more than one line. Continuation lines are @@ -175,14 +175,14 @@ po_gram_error_at_line (pp, fmt, va_alist) vasprintf (&buffer, fmt, ap); va_end (ap); - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, pp->file_name, pp->line_number, "%s", buffer); - error_with_progname = 1; + error_with_progname = true; # else - error_with_progname = 0; + error_with_progname = false; error_at_line (0, 0, pp->file_name, pp->line_number, fmt, a1, a2, a3, a4, a5, a6, a7, a8); - error_with_progname = 1; + error_with_progname = true; # endif /* Some messages need more than one line, or more than one location. @@ -396,7 +396,7 @@ po_gram_lex () return 0; case '\n': - po_lex_obsolete = 0; + po_lex_obsolete = false; break; case ' ': @@ -414,7 +414,7 @@ po_gram_lex () We simply discard the "#~" prefix. The following characters are expected to be well formed. */ { - po_lex_obsolete = 1; + po_lex_obsolete = true; break; } @@ -442,7 +442,7 @@ po_gram_lex () po_gram_lval.string.string = buf; po_gram_lval.string.pos = gram_pos; po_gram_lval.string.obsolete = po_lex_obsolete; - po_lex_obsolete = 0; + po_lex_obsolete = false; return COMMENT; } else @@ -452,7 +452,7 @@ po_gram_lex () is not very effective. */ while (c != EOF && c != '\n') c = lex_getc (); - po_lex_obsolete = 0; + po_lex_obsolete = false; } break; @@ -658,9 +658,9 @@ po_gram_lex () /* po_gram_lex() can return comments as COMMENT. Switch this on or off. */ void po_lex_pass_comments (flag) - int flag; + bool flag; { - pass_comments = (flag != 0); + pass_comments = flag; } @@ -668,7 +668,7 @@ po_lex_pass_comments (flag) Switch this on or off. */ void po_lex_pass_obsolete_entries (flag) - int flag; + bool flag; { - pass_obsolete_entries = (flag != 0); + pass_obsolete_entries = flag; } diff --git a/src/po-lex.h b/src/po-lex.h index 03332ce17..bd1eb48de 100644 --- a/src/po-lex.h +++ b/src/po-lex.h @@ -21,6 +21,7 @@ #define _PO_LEX_H #include +#include #include "error.h" #include "progname.h" #include "pos.h" @@ -37,8 +38,8 @@ extern lex_pos_ty gram_pos; terminate. Cf. error_message_count, declared in . */ extern unsigned int gram_max_allowed_errors; -/* Nonzero if obsolete entries shall be considered as valid. */ -extern int pass_obsolete_entries; +/* True if obsolete entries shall be considered as valid. */ +extern bool pass_obsolete_entries; /* Open the PO file FNAME and prepare its lexical analysis. */ @@ -52,11 +53,11 @@ extern void lex_close PARAMS ((void)); extern int po_gram_lex PARAMS ((void)); /* po_gram_lex() can return comments as COMMENT. Switch this on or off. */ -extern void po_lex_pass_comments PARAMS ((int flag)); +extern void po_lex_pass_comments PARAMS ((bool flag)); /* po_gram_lex() can return obsolete entries as if they were normal entries. Switch this on or off. */ -extern void po_lex_pass_obsolete_entries PARAMS ((int flag)); +extern void po_lex_pass_obsolete_entries PARAMS ((bool flag)); /* ISO C 99 is smart enough to allow optimizations like this. */ @@ -67,10 +68,10 @@ extern void po_lex_pass_obsolete_entries PARAMS ((int flag)); # define po_gram_error(fmt, ...) \ do { \ - error_with_progname = 0; \ + error_with_progname = false; \ error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number, \ fmt, __VA_ARGS__); \ - error_with_progname = 1; \ + error_with_progname = true; \ if (*fmt == '.') \ --error_message_count; \ else if (error_message_count >= gram_max_allowed_errors) \ @@ -83,10 +84,10 @@ extern void po_lex_pass_obsolete_entries PARAMS ((int flag)); # define po_gram_error_at_line(pos, fmt, ...) \ do { \ - error_with_progname = 0; \ + error_with_progname = false; \ error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \ fmt, __VA_ARGS__); \ - error_with_progname = 1; \ + error_with_progname = true; \ if (*fmt == '.') \ --error_message_count; \ else if (error_message_count >= gram_max_allowed_errors) \ @@ -101,10 +102,10 @@ extern void po_lex_pass_obsolete_entries PARAMS ((int flag)); # define po_gram_error(fmt, args...) \ do { \ - error_with_progname = 0; \ + error_with_progname = false; \ error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number, \ fmt, ## args); \ - error_with_progname = 1; \ + error_with_progname = true; \ if (*fmt == '.') \ --error_message_count; \ else if (error_message_count >= gram_max_allowed_errors) \ @@ -117,10 +118,10 @@ extern void po_lex_pass_obsolete_entries PARAMS ((int flag)); # define po_gram_error_at_line(pos, fmt, args...) \ do { \ - error_with_progname = 0; \ + error_with_progname = false; \ error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \ fmt, ## args); \ - error_with_progname = 1; \ + error_with_progname = true; \ if (*fmt == '.') \ --error_message_count; \ else if (error_message_count >= gram_max_allowed_errors) \ diff --git a/src/po.c b/src/po.c index 0fac31500..90ac988a0 100644 --- a/src/po.c +++ b/src/po.c @@ -41,7 +41,7 @@ static void po_directive_message PARAMS ((po_ty *pop, char *msgid, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); static void po_comment PARAMS ((po_ty *pop, const char *s)); static void po_comment_dot PARAMS ((po_ty *pop, const char *s)); static void po_comment_filepos PARAMS ((po_ty *pop, const char *name, @@ -146,7 +146,7 @@ po_directive_message (pop, msgid, msgid_pos, msgid_plural, char *msgstr; size_t msgstr_len; lex_pos_ty *msgstr_pos; - int obsolete; + bool obsolete; { if (pop->method->directive_message) pop->method->directive_message (pop, msgid, msgid_pos, msgid_plural, @@ -164,7 +164,7 @@ po_callback_message (msgid, msgid_pos, msgid_plural, char *msgstr; size_t msgstr_len; lex_pos_ty *msgstr_pos; - int obsolete; + bool obsolete; { /* assert(callback_arg); */ diff --git a/src/po.h b/src/po.h index aaa77d345..d3b712ac4 100644 --- a/src/po.h +++ b/src/po.h @@ -60,7 +60,7 @@ struct po_method_ty char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); /* This method is invoked before the parse, but after the file is opened by the lexer. */ @@ -135,7 +135,7 @@ extern void po_callback_message PARAMS ((char *msgid, lex_pos_ty *msgid_pos, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); extern void po_callback_comment PARAMS ((const char *s)); extern void po_callback_comment_dot PARAMS ((const char *s)); extern void po_callback_comment_filepos PARAMS ((const char *s, int line)); diff --git a/src/read-po.c b/src/read-po.c index 4ccd08393..505d47ab9 100644 --- a/src/read-po.c +++ b/src/read-po.c @@ -58,7 +58,7 @@ struct readall_class_ty string_list_ty *comment_dot; /* Flags transported in special comments. */ - int is_fuzzy; + bool is_fuzzy; enum is_c_format is_c_format; enum is_wrap do_wrap; @@ -78,7 +78,7 @@ static void readall_directive_message PARAMS ((po_ty *that, char *msgid, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); static void readall_parse_brief PARAMS ((po_ty *that)); static void readall_comment PARAMS ((po_ty *that, const char *s)); static void readall_comment_dot PARAMS ((po_ty *that, const char *s)); @@ -100,7 +100,7 @@ readall_constructor (that) this->comment_dot = NULL; this->filepos_count = 0; this->filepos = NULL; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; } @@ -168,7 +168,7 @@ readall_directive_message (that, msgid, msgid_pos, msgid_plural, char *msgstr; size_t msgstr_len; lex_pos_ty *msgstr_pos; - int obsolete; + bool obsolete; { readall_class_ty *this = (readall_class_ty *) that; message_ty *mp; @@ -226,7 +226,7 @@ readall_directive_message (that, msgid, msgid_pos, msgid_plural, free (this->filepos); this->filepos_count = 0; this->filepos = NULL; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; } @@ -236,7 +236,7 @@ static void readall_parse_brief (that) po_ty *that; { - po_lex_pass_comments (1); + po_lex_pass_comments (true); } @@ -274,7 +274,7 @@ readall_comment_special (that, s) readall_class_ty *this = (readall_class_ty *) that; if (strstr (s, "fuzzy") != NULL) - this->is_fuzzy = 1; + this->is_fuzzy = true; this->is_c_format = parse_c_format_description_string (s); this->do_wrap = parse_c_width_description_string (s); @@ -331,7 +331,7 @@ read_po_file (filename) msgdomain_list_ty *mdlp; pop = po_alloc (&readall_methods); - po_lex_pass_obsolete_entries (1); + po_lex_pass_obsolete_entries (true); po_scan (pop, filename); mdlp = ((readall_class_ty *) pop)->mdlp; po_free (pop); diff --git a/src/str-list.c b/src/str-list.c index a8ab49d54..a961ef3f1 100644 --- a/src/str-list.c +++ b/src/str-list.c @@ -215,7 +215,7 @@ string_list_join (slp) /* Return 1 if s is contained in the list of strings, 0 otherwise. */ -int +bool string_list_member (slp, s) const string_list_ty *slp; const char *s; @@ -224,6 +224,6 @@ string_list_member (slp, s) for (j = 0; j < slp->nitems; ++j) if (strcmp (slp->item[j], s) == 0) - return 1; - return 0; + return true; + return false; } diff --git a/src/str-list.h b/src/str-list.h index e31a62429..03b31d24d 100644 --- a/src/str-list.h +++ b/src/str-list.h @@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Get size_t and NULL. */ #include +/* Get bool. */ +#include + /* Type describing list of immutable strings, implemented using a dynamic array. */ typedef struct string_list_ty string_list_ty; @@ -66,7 +69,7 @@ extern char *string_list_concat_destroy PARAMS ((string_list_ty *slp)); extern char *string_list_join PARAMS ((const string_list_ty *slp)); /* Return 1 if s is contained in the list of strings, 0 otherwise. */ -extern int string_list_member PARAMS ((const string_list_ty *slp, - const char *s)); +extern bool string_list_member PARAMS ((const string_list_ty *slp, + const char *s)); #endif /* _STR_LIST_H */ diff --git a/src/write-po.c b/src/write-po.c index 89f10fdc1..0f9af6c32 100644 --- a/src/write-po.c +++ b/src/write-po.c @@ -49,7 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Prototypes for local functions. Needed to ensure compiler checking of function argument counts despite of K&R C function definition syntax. */ static const char *make_c_format_description_string PARAMS ((enum is_c_format, - int debug)); + bool debug)); static int significant_c_format_p PARAMS ((enum is_c_format is_c_format)); static const char *make_c_width_description_string PARAMS ((enum is_c_format)); static void wrap PARAMS ((FILE *fp, const char *line_prefix, const char *name, @@ -57,11 +57,11 @@ static void wrap PARAMS ((FILE *fp, const char *line_prefix, const char *name, const char *charset)); static void print_blank_line PARAMS ((FILE *fp)); static void message_print PARAMS ((const message_ty *mp, FILE *fp, - const char *charset, int blank_line, - int debug)); + const char *charset, bool blank_line, + bool debug)); static void message_print_obsolete PARAMS ((const message_ty *mp, FILE *fp, const char *charset, - int blank_line)); + bool blank_line)); static int msgid_cmp PARAMS ((const void *va, const void *vb)); static int filepos_cmp PARAMS ((const void *va, const void *vb)); @@ -90,27 +90,27 @@ message_page_width_set (n) /* These three variables control the output style of the message_print function. Interface functions for them are to be used. */ -static int indent; -static int uniforum; -static int escape; +static bool indent = false; +static bool uniforum = false; +static bool escape = false; void message_print_style_indent () { - indent = 1; + indent = true; } void message_print_style_uniforum () { - uniforum = 1; + uniforum = true; } void message_print_style_escape (flag) - int flag; + bool flag; { - escape = (flag != 0); + escape = flag; } @@ -120,7 +120,7 @@ message_print_style_escape (flag) static const char * make_c_format_description_string (is_c_format, debug) enum is_c_format is_c_format; - int debug; + bool debug; { const char *result = NULL; @@ -193,7 +193,7 @@ wrap (fp, line_prefix, name, value, do_wrap, charset) const char *charset; { const char *s; - int first_line; + bool first_line; #if HAVE_ICONV const char *envval; iconv_t conv; @@ -223,7 +223,7 @@ wrap (fp, line_prefix, name, value, do_wrap, charset) /* Loop over the '\n' delimited portions of value. */ s = value; - first_line = 1; + first_line = true; do { /* The \a and \v escapes were added by the ANSI C Standard. @@ -449,7 +449,7 @@ internationalized messages should not contain the `\\%c' escape sequence"), fputs (line_prefix, fp); fputs (name, fp); fputs (" \"\"\n", fp); - first_line = 0; + first_line = false; /* Recompute startcol and linebreaks. */ goto recompute; } @@ -463,7 +463,7 @@ internationalized messages should not contain the `\\%c' escape sequence"), { fputs (name, fp); putc (indent ? '\t' : ' ', fp); - first_line = 0; + first_line = false; } else { @@ -520,8 +520,8 @@ message_print (mp, fp, charset, blank_line, debug) const message_ty *mp; FILE *fp; const char *charset; - int blank_line; - int debug; + bool blank_line; + bool debug; { size_t j; @@ -625,7 +625,7 @@ message_print (mp, fp, charset, blank_line, debug) || significant_c_format_p (mp->is_c_format) || mp->do_wrap == no) { - int first_flag = 1; + bool first_flag = true; putc ('#', fp); putc (',', fp); @@ -636,7 +636,7 @@ message_print (mp, fp, charset, blank_line, debug) if (mp->is_fuzzy && mp->msgstr[0] != '\0') { fputs (" fuzzy", fp); - first_flag = 0; + first_flag = false; } if (significant_c_format_p (mp->is_c_format)) @@ -646,7 +646,7 @@ message_print (mp, fp, charset, blank_line, debug) fputs (make_c_format_description_string (mp->is_c_format, debug), fp); - first_flag = 0; + first_flag = false; } if (mp->do_wrap == no) @@ -655,7 +655,7 @@ message_print (mp, fp, charset, blank_line, debug) putc (',', fp); fputs (make_c_width_description_string (mp->do_wrap), fp); - first_flag = 0; + first_flag = false; } putc ('\n', fp); @@ -692,7 +692,7 @@ message_print_obsolete (mp, fp, charset, blank_line) const message_ty *mp; FILE *fp; const char *charset; - int blank_line; + bool blank_line; { size_t j; @@ -735,7 +735,7 @@ message_print_obsolete (mp, fp, charset, blank_line) /* Print flag information in special comment. */ if (mp->is_fuzzy) { - int first = 1; + bool first = true; putc ('#', fp); putc (',', fp); @@ -743,7 +743,7 @@ message_print_obsolete (mp, fp, charset, blank_line) if (mp->is_fuzzy) { fputs (" fuzzy", fp); - first = 0; + first = false; } putc ('\n', fp); @@ -778,18 +778,18 @@ void msgdomain_list_print (mdlp, filename, force, debug) msgdomain_list_ty *mdlp; const char *filename; - int force; - int debug; + bool force; + bool debug; { FILE *fp; size_t j, k; - int blank_line; + bool blank_line; /* We will not write anything if, for every domain, we have no message or only the header entry. */ if (!force) { - int found_nonempty = 0; + bool found_nonempty = false; for (k = 0; k < mdlp->nitems; k++) { @@ -798,7 +798,7 @@ msgdomain_list_print (mdlp, filename, force, debug) if (!(mlp->nitems == 0 || (mlp->nitems == 1 && mlp->item[0]->msgid[0] == '\0'))) { - found_nonempty = 1; + found_nonempty = true; break; } } @@ -824,7 +824,7 @@ msgdomain_list_print (mdlp, filename, force, debug) } /* Write out the messages for each domain. */ - blank_line = 0; + blank_line = false; for (k = 0; k < mdlp->nitems; k++) { message_list_ty *mlp; @@ -839,7 +839,7 @@ msgdomain_list_print (mdlp, filename, force, debug) if (blank_line) print_blank_line (fp); fprintf (fp, "domain \"%s\"\n", mdlp->item[k]->domain); - blank_line = 1; + blank_line = true; } mlp = mdlp->item[k]->messages; @@ -847,7 +847,7 @@ msgdomain_list_print (mdlp, filename, force, debug) /* Search the header entry. */ header = NULL; for (j = 0; j < mlp->nitems; ++j) - if (mlp->item[j]->msgid[0] == '\0' && mlp->item[j]->obsolete == 0) + if (mlp->item[j]->msgid[0] == '\0' && !mlp->item[j]->obsolete) { header = mlp->item[j]->msgstr; break; @@ -873,18 +873,18 @@ msgdomain_list_print (mdlp, filename, force, debug) /* Write out each of the messages for this domain. */ for (j = 0; j < mlp->nitems; ++j) - if (mlp->item[j]->obsolete == 0) + if (!mlp->item[j]->obsolete) { message_print (mlp->item[j], fp, charset, blank_line, debug); - blank_line = 1; + blank_line = true; } /* Write out each of the obsolete messages for this domain. */ for (j = 0; j < mlp->nitems; ++j) - if (mlp->item[j]->obsolete != 0) + if (mlp->item[j]->obsolete) { message_print_obsolete (mlp->item[j], fp, charset, blank_line); - blank_line = 1; + blank_line = true; } } diff --git a/src/write-po.h b/src/write-po.h index 1523c4410..55ef969eb 100644 --- a/src/write-po.h +++ b/src/write-po.h @@ -30,12 +30,12 @@ extern void extern void message_print_style_uniforum PARAMS ((void)); extern void - message_print_style_escape PARAMS ((int flag)); + message_print_style_escape PARAMS ((bool flag)); extern void msgdomain_list_print PARAMS ((msgdomain_list_ty *mdlp, const char *filename, - int force, int debug)); + bool force, bool debug)); extern void msgdomain_list_sort_by_msgid PARAMS ((msgdomain_list_ty *mdlp)); extern void diff --git a/src/xget-lex.c b/src/xget-lex.c index c69e23027..516b9f48d 100644 --- a/src/xget-lex.c +++ b/src/xget-lex.c @@ -106,10 +106,10 @@ static const char *file_name; static char *logical_file_name; static int line_number; static FILE *fp; -static int trigraphs; +static bool trigraphs = false; static string_list_ty *comment; static hash_table keywords; -static int default_keywords = 1; +static bool default_keywords = true; /* These are for tracking whether comments count as immediately before keyword. */ @@ -697,7 +697,7 @@ phase5_get (tp) *tp = phase5_pushback[--phase5_pushback_length]; return; } - tp->string = 0; + tp->string = NULL; tp->number = 0; tp->line_number = line_number; c = phase4_getc (); @@ -875,10 +875,10 @@ phase5_get (tp) c = phase7_getc (); if (c == P7_NEWLINE) { - error_with_progname = 0; + error_with_progname = false; error (0, 0, _("%s:%d: warning: unterminated character constant"), logical_file_name, line_number - 1); - error_with_progname = 1; + error_with_progname = true; phase7_ungetc ('\n'); break; } @@ -899,10 +899,10 @@ phase5_get (tp) c = phase7_getc (); if (c == P7_NEWLINE) { - error_with_progname = 0; + error_with_progname = false; error (0, 0, _("%s:%d: warning: unterminated string literal"), logical_file_name, line_number - 1); - error_with_progname = 1; + error_with_progname = true; phase7_ungetc ('\n'); break; } @@ -970,12 +970,12 @@ static void phaseX_get (tp) token_ty *tp; { - static int middle; /* 0 at the beginning of a line, 1 otherwise. */ + static bool middle; /* false at the beginning of a line, true otherwise. */ phase5_get (tp); if (tp->type == token_type_eoln || tp->type == token_type_eof) - middle = 0; + middle = false; else { if (middle) @@ -999,7 +999,7 @@ phaseX_get (tp) else phase5_unget (&next); } - middle = 1; + middle = true; } } } @@ -1202,7 +1202,7 @@ xgettext_lex (tp) xgettext_lex_keyword ("dngettext:2,3"); xgettext_lex_keyword ("dcngettext:2,3"); xgettext_lex_keyword ("gettext_noop"); - default_keywords = 0; + default_keywords = false; } if (find_entry (&keywords, token.string, strlen (token.string) + 1, @@ -1262,7 +1262,7 @@ xgettext_lex_keyword (name) const char *name; { if (name == NULL) - default_keywords = 0; + default_keywords = false; else { int argnum1; @@ -1310,7 +1310,7 @@ xgettext_lex_keyword (name) } -int +bool xgettext_any_keywords () { return (keywords.filled > 0) || default_keywords; @@ -1341,5 +1341,5 @@ xgettext_lex_comment_reset () void xgettext_lex_trigraphs () { - trigraphs = 1; + trigraphs = true; } diff --git a/src/xget-lex.h b/src/xget-lex.h index 1fe4edd8c..f0e39ec78 100644 --- a/src/xget-lex.h +++ b/src/xget-lex.h @@ -59,7 +59,7 @@ const char *xgettext_lex_comment PARAMS ((size_t n)); void xgettext_lex_comment_reset PARAMS ((void)); /* void xgettext_lex_filepos PARAMS ((char **, int *)); FIXME needed? */ void xgettext_lex_keyword PARAMS ((const char *name)); -int xgettext_any_keywords PARAMS ((void)); +bool xgettext_any_keywords PARAMS ((void)); void xgettext_lex_trigraphs PARAMS ((void)); #endif /* _XGET_LEX_H */ diff --git a/src/xgettext.c b/src/xgettext.c index 89619f855..712570aa1 100644 --- a/src/xgettext.c +++ b/src/xgettext.c @@ -63,7 +63,7 @@ struct passwd *getpwuid (); /* If nonzero add all comments immediately preceding one of the keywords. */ -static int add_all_comments; +static bool add_all_comments = false; /* If nonzero add comments for file name and line number for each msgid. */ static int line_comment; @@ -81,8 +81,8 @@ static int do_debug; /* Content of .po files with symbols to be excluded. */ static message_list_ty *exclude; -/* If nonzero extract all strings. */ -static int extract_all; +/* If true extract all strings. */ +static bool extract_all = false; /* Force output of PO file even if empty. */ static int force_po; @@ -114,7 +114,7 @@ static const struct option long_options[] = { "directory", required_argument, NULL, 'D' }, { "escape", no_argument, NULL, 'E' }, { "exclude-file", required_argument, NULL, 'x' }, - { "extract-all", no_argument, &extract_all, 1 }, + { "extract-all", no_argument, NULL, 'a' }, { "files-from", required_argument, NULL, 'f' }, { "force-po", no_argument, &force_po, 1 }, { "foreign-user", no_argument, &foreign_user, 1 }, @@ -155,7 +155,7 @@ static void exclude_directive_message PARAMS ((po_ty *pop, char *msgid, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); static void read_exclusion_file PARAMS ((char *file_name)); static message_ty *remember_a_message PARAMS ((message_list_ty *mlp, xgettext_token_ty *tp)); @@ -170,7 +170,7 @@ static void extract_directive_message PARAMS ((po_ty *that, char *msgid, char *msgid_plural, char *msgstr, size_t msgstr_len, lex_pos_ty *msgstr_pos, - int obsolete)); + bool obsolete)); static void extract_parse_brief PARAMS ((po_ty *that)); static void extract_comment PARAMS ((po_ty *that, const char *s)); static void extract_comment_dot PARAMS ((po_ty *that, const char *s)); @@ -199,12 +199,12 @@ main (argc, argv) { int cnt; int optchar; - int do_help = 0; - int do_version = 0; + bool do_help = false; + bool do_version = false; msgdomain_list_ty *mdlp; - int join_existing = 0; - int sort_by_msgid = 0; - int sort_by_filepos = 0; + bool join_existing = false; + bool sort_by_msgid = false; + bool sort_by_filepos = false; const char *file_name; const char *files_from = NULL; string_list_ty *file_list; @@ -236,17 +236,17 @@ main (argc, argv) case '\0': /* Long option. */ break; case 'a': - extract_all = 1; + extract_all = true; break; case 'c': if (optarg == NULL) { - add_all_comments = 1; + add_all_comments = true; comment_tag = NULL; } else { - add_all_comments = 0; + add_all_comments = false; comment_tag = optarg; /* We ignore leading white space. */ while (isspace (*comment_tag)) @@ -263,25 +263,25 @@ main (argc, argv) dir_list_append (optarg); break; case 'e': - message_print_style_escape (0); + message_print_style_escape (false); break; case 'E': - message_print_style_escape (1); + message_print_style_escape (true); break; case 'f': files_from = optarg; break; case 'F': - sort_by_filepos = 1; + sort_by_filepos = true; break; case 'h': - do_help = 1; + do_help = true; break; case 'i': message_print_style_indent (); break; case 'j': - join_existing = 1; + join_existing = true; break; case 'k': if (optarg == NULL || *optarg != '\0') @@ -327,7 +327,7 @@ main (argc, argv) } break; case 's': - sort_by_msgid = 1; + sort_by_msgid = true; break; case 'S': message_print_style_uniforum (); @@ -336,7 +336,7 @@ main (argc, argv) xgettext_lex_trigraphs (); break; case 'V': - do_version = 1; + do_version = true; break; case 'w': { @@ -687,7 +687,7 @@ exclude_directive_message (pop, msgid, msgid_pos, msgid_plural, char *msgstr; size_t msgstr_len; lex_pos_ty *msgstr_pos; - int obsolete; + bool obsolete; { message_ty *mp; @@ -940,11 +940,11 @@ scan_c_file (filename, mdlp) { if (commas_to_skip == 0) { - error_with_progname = 0; + error_with_progname = false; error (0, 0, _("%s:%d: warning: keyword nested in keyword arg"), token.file_name, token.line_number); - error_with_progname = 1; + error_with_progname = true; continue; } @@ -952,11 +952,11 @@ scan_c_file (filename, mdlp) potentially unbounded stack. We haven't run across an example that needs this functionality yet. For now, we punt and forget the outer keyword. */ - error_with_progname = 0; + error_with_progname = false; error (0, 0, _("%s:%d: warning: keyword between outer keyword and its arg"), token.file_name, token.line_number); - error_with_progname = 1; + error_with_progname = true; } commas_to_skip = token.argnum1 - 1; plural_commas = (token.argnum2 > token.argnum1 @@ -1059,11 +1059,11 @@ struct extract_class_ty string_list_ty *comment; string_list_ty *comment_dot; - int is_fuzzy; + bool is_fuzzy; enum is_c_format is_c_format; enum is_wrap do_wrap; - int filepos_count; + size_t filepos_count; lex_pos_ty *filepos; }; @@ -1077,7 +1077,7 @@ extract_constructor (that) this->mlp = NULL; /* actually set in read_po_file, below */ this->comment = NULL; this->comment_dot = NULL; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; this->filepos_count = 0; @@ -1104,7 +1104,7 @@ extract_directive_message (that, msgid, msgid_pos, msgid_plural, char *msgstr; size_t msgstr_len; lex_pos_ty *msgstr_pos; - int obsolete; + bool obsolete; { extract_class_ty *this = (extract_class_ty *)that; message_ty *mp; @@ -1131,7 +1131,7 @@ extract_directive_message (that, msgid, msgid_pos, msgid_plural, this->comment_dot = NULL; this->filepos_count = 0; this->filepos = NULL; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; return; @@ -1188,7 +1188,7 @@ extract_directive_message (that, msgid, msgid_pos, msgid_plural, free (this->filepos); this->filepos_count = 0; this->filepos = NULL; - this->is_fuzzy = 0; + this->is_fuzzy = false; this->is_c_format = undecided; this->do_wrap = undecided; } @@ -1198,7 +1198,7 @@ static void extract_parse_brief (that) po_ty *that; { - po_lex_pass_comments (1); + po_lex_pass_comments (true); } @@ -1258,7 +1258,7 @@ extract_comment_special (that, s) extract_class_ty *this = (extract_class_ty *) that; if (strstr (s, "fuzzy") != NULL) - this->is_fuzzy = 1; + this->is_fuzzy = true; this->is_c_format = parse_c_format_description_string (s); this->do_wrap = parse_c_width_description_string (s); } @@ -1379,7 +1379,7 @@ SOME DESCRIPTIVE TITLE.\n\ Copyright (C) YEAR Free Software Foundation, Inc.\n\ FIRST AUTHOR , YEAR.\n"); - mp->is_fuzzy = 1; + mp->is_fuzzy = true; return mp; }