diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 60 | ||||
-rw-r--r-- | src/FILES | 67 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/dir-list.c | 10 | ||||
-rw-r--r-- | src/dir-list.h | 13 | ||||
-rw-r--r-- | src/domain.h | 35 | ||||
-rw-r--r-- | src/gettextp.c | 23 | ||||
-rw-r--r-- | src/message.c | 212 | ||||
-rw-r--r-- | src/message.h | 32 | ||||
-rw-r--r-- | src/msgcmp.c | 16 | ||||
-rw-r--r-- | src/msgcomm.c | 6 | ||||
-rw-r--r-- | src/msgfmt.c | 19 | ||||
-rw-r--r-- | src/msgmerge.c | 18 | ||||
-rw-r--r-- | src/msgunfmt.c | 1 | ||||
-rw-r--r-- | src/open-po.c | 67 | ||||
-rw-r--r-- | src/open-po.h | 28 | ||||
-rw-r--r-- | src/po-gram-gen.y | 4 | ||||
-rw-r--r-- | src/po-lex.c | 16 | ||||
-rw-r--r-- | src/po-lex.h | 82 | ||||
-rw-r--r-- | src/po.c | 2 | ||||
-rw-r--r-- | src/po.h | 32 | ||||
-rw-r--r-- | src/pos.h | 30 | ||||
-rw-r--r-- | src/str-list.c | 12 | ||||
-rw-r--r-- | src/str-list.h | 36 | ||||
-rw-r--r-- | src/xgettext.c | 11 | ||||
-rwxr-xr-x | src/ylwrap | 28 |
26 files changed, 578 insertions, 286 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index cc8cca7..481f2d9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,63 @@ +2000-12-31 Bruno Haible <haible@clisp.cons.org> + + * str-list.h: Fix typo. Add comments. + * str-list.c: Add comments. + + * dir-list.h: Add comments. + * dir-list.c: Likewise. + + * domain.h: Remove file. + * msgfmt.c: Incorporate it here. Don't include "domain.h". + * msgunfmt.c: Don't include "domain.h". + * xgettext.c: Likewise. + * Makefile.am (noinst_HEADERS): Remove domain.h. + + * open-po.h: New file. + * open-po.c: Include it. + * po-lex.c: Likewise. + * Makefile.am (noinst_HEADERS): Add open-po.h. + + * open-po.c (open_po_file): Merge duplicated code. + + * po-lex.h: Add comments. + (gram_max_allowed_errors): Change type to 'unsigned int'. + (po_gram_error_at_line): Renamed from gram_error_at_line. + (po_gram_error, po_gram_error_at_line): Use ISO C 99 macro vararg + syntax if possible. + * po-lex.c: Add comments. Don't include "po-gram.h". + (po_gram_error_at_line): Renamed from gram_error_at_line. + * msgmerge.c (main): Initialize gram_max_allowed_errors to UINT_MAX. + + * message.h: Add comments. + (enum is_wrap): New type. + (parse_c_width_description_string): Change return type. + (message_ty): Change type of do_wrap field. + * message.c (wrap): Change type of do_wrap argument. + * msgfmt.c (msgfmt_class_ty): Change type of do_wrap field. + * msgmerge.c (merge_class_ty): Change type of do_wrap field. + * msgcomm.c (extract_class_ty): Change types of is_c_format, do_wrap + fields. + * xgettext.c (extract_class_ty): Likewise. + (remember_a_message): Change type of do_wrap. + + * pos.h: New file. + * po-lex.h: Include it. + (struct lex_pos_ty): Remove type, now in pos.h. + * message,h: Include pos.h instead of po-lex.h. + * Makefile.am (noinst_HEADERS): Add pos.h. + + * po.h: Add comments. + + * gettextp.c (main): Use bindtextdomain instead of bindtextdomain__, + and dgettext instead of dgettext__. There is no need to use the + included libintl when GNU gettext or an X/Open gettext or a catgets + has been found in the system's C library. + + * ylwrap: Update from automake-1.4. + + * FILES: New file. + * Makefile.am (EXTRA_DIST): New variable. + 2000-12-30 Bruno Haible <haible@clisp.cons.org> * xgettext.c (scanner_c, scanner_cxx): Remove declarations. diff --git a/src/FILES b/src/FILES new file mode 100644 index 0000000..320bb9b --- /dev/null +++ b/src/FILES @@ -0,0 +1,67 @@ + Short description of the source files + ===================================== + +1) +gettextp.c Source for the 'gettext' program. + +2) The msgfmt, msgunfmt, msgcmp, msgcomm, msgmerge, xgettext programs. + +Bottom-up structure: + +str-list.h +str-list.c + A list-of-immutable-strings type. + +dir-list.h +dir-list.c + Management of the list of directories where PO files are + searched. + +pos.h + Source file positions. + +message.h +message.c + The message type, with many utility routines. + A list-of-messages type. + A list-of-lists-of-messages type. + +msgunfmt.c Main source for the 'msgunfmt' program. + +open-po.h +open-po.c + Opening PO files for reading. + +po-lex.h +po-lex.c + Lexical analysis of PO files. + +po.h +po-hash.h +po-hash-gen.y +po-gram.h +po-gram-gen.y +po.c + Parsing of PO files. + po.h + General parser structure. + po-hash.h + po-hash-gen.y + Lexical analysis and parsing of pseudo-comments in + PO files, introduced by "#:" and "#". + po-gram.h + po-gram-gen.y + Parsing of PO files, based on po-lex.{h,c}. + po.c + Top-level parser functions and callbacks. + +msgfmt.c Main source for the 'msgfmt' program. +msgcmp.c Main source for the 'msgcmp' program. +msgcomm.c Main source for the 'msgcomm' program. +msgmerge.c Main source for the 'msgmerge' program. + +xget-lex.h +xget-lex.c + Lexical analysis of C/C++ files. + +xgettext.c Main source for the 'xgettext' program. diff --git a/src/Makefile.am b/src/Makefile.am index 2e6ffb9..2cdf093 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,9 +21,11 @@ AUTOMAKE_OPTIONS = 1.2 gnits bin_PROGRAMS = gettext msgcmp msgfmt msgmerge msgunfmt xgettext msgcomm -noinst_HEADERS = domain.h message.h po-gram.h po-hash.h po-lex.h po.h \ +noinst_HEADERS = pos.h message.h po-gram.h po-hash.h po-lex.h po.h open-po.h \ str-list.h xget-lex.h dir-list.h po-gram-gen.h po-hash-gen.h +EXTRA_DIST = FILES + datadir = $(prefix)/@DATADIRNAME@ localedir = $(datadir)/locale diff --git a/src/dir-list.c b/src/dir-list.c index e02d708..9173bb5 100644 --- a/src/dir-list.c +++ b/src/dir-list.c @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" #endif -#ifdef STDC_HEADERS +#ifdef HAVE_STDLIB_H # include <stdlib.h> #endif @@ -30,9 +30,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "dir-list.h" #include "str-list.h" -static string_list_ty *directory; +static string_list_ty *directory /* = NULL */; +/* Append a directory to the end of the list of directories. */ void dir_list_append (s) const char *s; @@ -43,12 +44,15 @@ dir_list_append (s) } +/* Return the nth directory, or NULL of n is out of range. */ const char * dir_list_nth (n) int n; { + /* The default value of the list consists of the single directory ".". */ if (directory == NULL) dir_list_append ("."); + if (n < 0 || n >= directory->nitems) return NULL; return directory->item[n]; diff --git a/src/dir-list.h b/src/dir-list.h index fd6bae7..d3378c2 100644 --- a/src/dir-list.h +++ b/src/dir-list.h @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> @@ -20,7 +20,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef SRC_DIR_LIST_H #define SRC_DIR_LIST_H -void dir_list_append PARAMS ((const char *__directory)); -const char *dir_list_nth PARAMS ((int __n)); +/* Management of the list of directories where PO files are searched. + It is an ordered list, without duplicates. The default value of the + list consists of the single directory ".". */ + +/* Append a directory to the end of the list of directories. */ +extern void dir_list_append PARAMS ((const char *__directory)); + +/* Return the nth directory, or NULL of n is out of range. */ +extern const char *dir_list_nth PARAMS ((int __n)); #endif /* SRC_DIR_LIST_H */ diff --git a/src/domain.h b/src/domain.h deleted file mode 100644 index c3d4284..0000000 --- a/src/domain.h +++ /dev/null @@ -1,35 +0,0 @@ - -/* Copyright (C) 1995 Free Software Foundation, Inc. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library 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 -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#ifndef _DOMAIN_H -#define _DOMAIN_H 1 - -#include <stdio.h> -#include "hash.h" - -struct msg_domain -{ - /* Table for mapping message IDs to message strings. */ - hash_table symbol_tab; - /* Name domain these ID/String pairs are part of. */ - const char *domain_name; - /* Link to the next domain. */ - struct msg_domain *next; -}; - -#endif /* domain.h */ diff --git a/src/gettextp.c b/src/gettextp.c index 911577e..6b6d107 100644 --- a/src/gettextp.c +++ b/src/gettextp.c @@ -1,5 +1,5 @@ /* gettext - retrieve text string from message catalog and print it. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, May 1995. This program is free software; you can redistribute it and/or modify @@ -23,7 +23,7 @@ #include <getopt.h> #include <stdio.h> -#ifdef STDC_HEADERS +#ifdef HAVE_STDLIB_H # include <stdlib.h> #else char *getenv (); @@ -74,17 +74,19 @@ main (argc, argv) char *argv[]; { int optchar; + const char *msgid; + + /* Default values for command line options. */ int do_help = 0; int do_shell = 0; int do_version = 0; - const char *msgid; const char *domain = getenv ("TEXTDOMAIN"); const char *domaindir = getenv ("TEXTDOMAINDIR"); + add_newline = 1; + do_expand = 0; /* Set program name for message texts. */ program_name = argv[0]; - add_newline = 1; - do_expand = 0; #ifdef HAVE_SETLOCALE /* Set locale via LC_ALL. */ @@ -95,6 +97,7 @@ main (argc, argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); + /* Parse command line options. */ while ((optchar = getopt_long (argc, argv, "+d:eEhnsV", long_options, NULL)) != EOF) switch (optchar) @@ -173,14 +176,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ /* Bind domain to appropriate directory. */ if (domaindir != NULL && domaindir[0] != '\0') - bindtextdomain__ (domain, domaindir); + bindtextdomain (domain, domaindir); /* Expand escape sequences is enabled. */ if (do_expand) msgid = expand_escape (msgid); /* Write out the result. */ - fputs (dgettext__ (domain, msgid), stdout); + fputs (dgettext (domain, msgid), stdout); } else { @@ -191,7 +194,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ else /* Bind domain to appropriate directory. */ if (domaindir != NULL && domaindir[0] != '\0') - bindtextdomain__ (domain, domaindir); + bindtextdomain (domain, domaindir); /* We have to simulate `echo'. All arguments are strings. */ while (optind < argc) @@ -203,14 +206,14 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ msgid = expand_escape (msgid); /* Write out the result. */ - fputs (domain == NULL ? msgid : dgettext__ (domain, msgid), stdout); + fputs (domain == NULL ? msgid : dgettext (domain, msgid), stdout); /* We separate the arguments by a single ' '. */ if (optind < argc) fputc (' ', stdout); } - /* If not otherwise told add trailing newline. */ + /* If not otherwise told: add trailing newline. */ if (add_newline) fputc ('\n', stdout); } diff --git a/src/message.c b/src/message.c index 2ff1156..26c21eb 100644 --- a/src/message.c +++ b/src/message.c @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> @@ -63,7 +63,7 @@ static size_t page_width = PAGE_WIDTH; /* Prototypes for local functions. */ static void wrap PARAMS ((FILE *__fp, const char *__line_prefix, const char *__name, const char *__value, - int do_wrap)); + enum is_wrap do_wrap)); static void print_blank_line PARAMS ((FILE *__fp)); static void message_print PARAMS ((const message_ty *__mp, FILE *__fp, const char *__domain, int blank_line, @@ -78,11 +78,113 @@ static const char *make_c_format_description_string PARAMS ((enum is_c_format, static const char *make_c_width_description_string PARAMS ((enum is_c_format)); static int significant_c_format_p PARAMS ((enum is_c_format __is_c_format)); - static message_ty *message_list_search_fuzzy_inner PARAMS (( +static message_ty *message_list_search_fuzzy_inner PARAMS (( message_list_ty *__mlp, const char *__msgid, double *__best_weight_p)); +enum is_c_format +parse_c_format_description_string (s) + const char *s; +{ + if (strstr (s, "no-c-format") != NULL) + return no; + else if (strstr (s, "impossible-c-format") != NULL) + return impossible; + else if (strstr (s, "possible-c-format") != NULL) + return possible; + else if (strstr (s, "c-format") != NULL) + return yes; + return undecided; +} + + +static const char * +make_c_format_description_string (is_c_format, debug) + enum is_c_format is_c_format; + int debug; +{ + const char *result = NULL; + + switch (is_c_format) + { + case possible: + if (debug) + { + result = " possible-c-format"; + break; + } + /* FALLTHROUGH */ + case yes: + result = " c-format"; + break; + case impossible: + result = " impossible-c-format"; + break; + case no: + result = " no-c-format"; + break; + case undecided: + result = " undecided"; + break; + default: + abort (); + } + + return result; +} + + +int +possible_c_format_p (is_c_format) + enum is_c_format is_c_format; +{ + return is_c_format == possible || is_c_format == yes; +} + + +static int +significant_c_format_p (is_c_format) + enum is_c_format is_c_format; +{ + return is_c_format != undecided && is_c_format != impossible; +} + + +enum is_c_format +parse_c_width_description_string (s) + const char *s; +{ + if (strstr (s, "no-wrap") != NULL) + return no; + else if (strstr (s, "wrap") != NULL) + return yes; + return undecided; +} + + +static const char * +make_c_width_description_string (do_wrap) + enum is_wrap do_wrap; +{ + const char *result = NULL; + + switch (do_wrap) + { + case yes: + result = " wrap"; + break; + case no: + result = " no-wrap"; + break; + default: + abort (); + } + + return result; +} + + message_ty * message_alloc (msgid) char *msgid; @@ -751,7 +853,7 @@ wrap (fp, line_prefix, name, value, do_wrap) const char *line_prefix; const char *name; const char *value; - int do_wrap; + enum is_wrap do_wrap; { const char *s; int first_line; @@ -1401,108 +1503,6 @@ message_list_sort_by_filepos (mlp) } -enum is_c_format -parse_c_format_description_string (s) - const char *s; -{ - if (strstr (s, "no-c-format") != NULL) - return no; - else if (strstr (s, "impossible-c-format") != NULL) - return impossible; - else if (strstr (s, "possible-c-format") != NULL) - return possible; - else if (strstr (s, "c-format") != NULL) - return yes; - return undecided; -} - - -enum is_c_format -parse_c_width_description_string (s) - const char *s; -{ - if (strstr (s, "no-wrap") != NULL) - return no; - else if (strstr (s, "wrap") != NULL) - return yes; - return undecided; -} - - -static const char * -make_c_format_description_string (is_c_format, debug) - enum is_c_format is_c_format; - int debug; -{ - const char *result = NULL; - - switch (is_c_format) - { - case possible: - if (debug) - { - result = " possible-c-format"; - break; - } - /* FALLTHROUGH */ - case yes: - result = " c-format"; - break; - case impossible: - result = " impossible-c-format"; - break; - case no: - result = " no-c-format"; - break; - case undecided: - result = " undecided"; - break; - default: - abort (); - } - - return result; -} - - -static const char * -make_c_width_description_string (do_wrap) - enum is_c_format do_wrap; -{ - const char *result = NULL; - - switch (do_wrap) - { - case yes: - result = " wrap"; - break; - case no: - result = " no-wrap"; - break; - default: - abort (); - } - - return result; -} - - -int -possible_c_format_p (is_c_format) - enum is_c_format is_c_format; -{ - return is_c_format == possible || is_c_format == yes; -} - - -static int -significant_c_format_p (is_c_format) - enum is_c_format is_c_format; -{ - return is_c_format != undecided && is_c_format != impossible; -} - - void message_page_width_set (n) size_t n; diff --git a/src/message.h b/src/message.h index aa60005..ed9e8f8 100644 --- a/src/message.h +++ b/src/message.h @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> @@ -20,8 +20,8 @@ #ifndef _MESSAGE_H #define _MESSAGE_H -#include "po-lex.h" #include "str-list.h" +#include "pos.h" /* According to Sun's Uniforum proposal the default message domain is named `messages'. */ @@ -38,6 +38,27 @@ enum is_c_format impossible }; +extern enum is_c_format + parse_c_format_description_string PARAMS ((const char *s)); +extern int possible_c_format_p PARAMS ((enum is_c_format)); + + +/* Is current msgid wrappable? */ +#if 0 +enum is_wrap +{ + undecided, + yes, + no +}; +#else /* HACK - C's enum concept is so stupid */ +#define is_wrap is_c_format +#endif + +extern enum is_wrap parse_c_width_description_string PARAMS ((const char *s)); +extern void message_page_width_set PARAMS ((size_t width)); + + typedef struct message_variant_ty message_variant_ty; struct message_variant_ty { @@ -66,7 +87,7 @@ struct message_ty enum is_c_format is_c_format; /* Do we want the string to be wrapped in the emitted PO file? */ - enum is_c_format do_wrap; + enum is_wrap do_wrap; /* The msgid string. */ const char *msgid; @@ -141,9 +162,4 @@ message_ty *message_list_list_search PARAMS ((message_list_list_ty *, message_ty *message_list_list_search_fuzzy PARAMS ((message_list_list_ty *, const char *)); -enum is_c_format parse_c_format_description_string PARAMS ((const char *s)); -enum is_c_format parse_c_width_description_string PARAMS ((const char *s)); -int possible_c_format_p PARAMS ((enum is_c_format)); -void message_page_width_set PARAMS ((size_t width)); - #endif /* message.h */ diff --git a/src/msgcmp.c b/src/msgcmp.c index af689a2..7851628 100644 --- a/src/msgcmp.c +++ b/src/msgcmp.c @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> This program is free software; you can redistribute it and/or modify @@ -256,15 +256,15 @@ compare (fn1, fn2) mp1 = message_list_search_fuzzy (list1, mp2->msgid); if (mp1) { - gram_error_at_line (&mp2->variant[0].pos, _("\ + po_gram_error_at_line (&mp2->variant[0].pos, _("\ this message is used but not defined...")); - gram_error_at_line (&mp1->variant[0].pos, _("\ + po_gram_error_at_line (&mp1->variant[0].pos, _("\ ...but this definition is similar")); mp1->used = 1; } else { - gram_error_at_line (&mp2->variant[0].pos, _("\ + po_gram_error_at_line (&mp2->variant[0].pos, _("\ this message is used but not defined in %s"), fn1); } } @@ -277,7 +277,7 @@ this message is used but not defined in %s"), fn1); mp1 = list1->item[k]; if (mp1->used) continue; - gram_error_at_line (&mp1->variant[0].pos, + po_gram_error_at_line (&mp1->variant[0].pos, _("warning: this message is not used")); } @@ -352,8 +352,8 @@ compare_directive_message (that, msgid, msgid_pos, msgstr, msgstr_pos) mvp = message_variant_search (mp, this->domain); if (mvp) { - gram_error_at_line (msgid_pos, _("duplicate message definition")); - gram_error_at_line (&mvp->pos, _("\ + po_gram_error_at_line (msgid_pos, _("duplicate message definition")); + po_gram_error_at_line (&mvp->pos, _("\ ...this is the location of the first definition")); free (msgstr); } @@ -393,7 +393,7 @@ compare_parse_debrief (that) break; } if (m >= mp->variant_count) - gram_error_at_line (&mp->variant[0].pos, _("\ + po_gram_error_at_line (&mp->variant[0].pos, _("\ this message has no definition in the \"%s\" domain"), domain_name); } } diff --git a/src/msgcomm.c b/src/msgcomm.c index 082639a..e78da18 100644 --- a/src/msgcomm.c +++ b/src/msgcomm.c @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> @@ -524,8 +524,8 @@ struct extract_class_ty string_list_ty *comment_dot; int is_fuzzy; - int is_c_format; - int do_wrap; + enum is_c_format is_c_format; + enum is_wrap do_wrap; int filepos_count; lex_pos_ty *filepos; diff --git a/src/msgfmt.c b/src/msgfmt.c index d535ed5..931fd22 100644 --- a/src/msgfmt.c +++ b/src/msgfmt.c @@ -1,5 +1,5 @@ /* Converts Uniforum style .po files to binary .mo files - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995. This program is free software; you can redistribute it and/or modify @@ -44,7 +44,6 @@ #include <system.h> #include "gettext.h" -#include "domain.h" #include "hash-string.h" #include <libintl.h> #include "message.h" @@ -81,7 +80,7 @@ struct msgfmt_class_ty int is_fuzzy; enum is_c_format is_c_format; - enum is_c_format do_wrap; + enum is_wrap do_wrap; int has_header_entry; }; @@ -107,6 +106,15 @@ const char *program_name; /* We may have more than one input file. Domains with same names in different files have to merged. So we need a list of tables for each output file. */ +struct msg_domain +{ + /* Table for mapping message IDs to message strings. */ + hash_table symbol_tab; + /* Name of domain these ID/String pairs are part of. */ + const char *domain_name; + /* Link to the next domain. */ + struct msg_domain *next; +}; static struct msg_domain *domain; static struct msg_domain *current_domain; @@ -630,8 +638,9 @@ some header fields still have the initial default value")); strlen (msgid_string), (void **) &entry); if (0 != strcmp(msgstr_string, entry->msgstr)) { - gram_error_at_line (msgid_pos, _("duplicate message definition")); - gram_error_at_line (&entry->pos, _("\ + po_gram_error_at_line (msgid_pos, _("\ +duplicate message definition")); + po_gram_error_at_line (&entry->pos, _("\ ...this is the location of the first definition")); /* FIXME Should this be always a reason for an exit status != 0? */ diff --git a/src/msgmerge.c b/src/msgmerge.c index 27481d9..78b7cde 100644 --- a/src/msgmerge.c +++ b/src/msgmerge.c @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> This program is free software; you can redistribute it and/or modify @@ -72,7 +72,7 @@ struct merge_class_ty /* Flags transported in special comments. */ int is_fuzzy; enum is_c_format is_c_format; - enum is_c_format do_wrap; + enum is_wrap do_wrap; /* Accumulate filepos comments for the next message directive. */ size_t filepos_count; @@ -164,7 +164,7 @@ main (argc, argv) verbosity_level = 0; quiet = 0; error_print_progname = error_print; - gram_max_allowed_errors = INT_MAX; + gram_max_allowed_errors = UINT_MAX; #ifdef HAVE_SETLOCALE /* Set locale via LC_ALL. */ @@ -514,8 +514,8 @@ merge_directive_message (that, msgid, msgid_pos, msgstr, msgstr_pos) mvp = message_variant_search (mp, this->domain); if (mvp) { - gram_error_at_line (msgid_pos, _("duplicate message definition")); - gram_error_at_line (&mvp->pos, _("\ + po_gram_error_at_line (msgid_pos, _("duplicate message definition")); + po_gram_error_at_line (&mvp->pos, _("\ ...this is the location of the first definition")); free (msgstr); } @@ -563,7 +563,7 @@ merge_parse_debrief (that) break; } if (m >= mp->variant_count) - gram_error_at_line (&mp->variant[0].pos, _("\ + po_gram_error_at_line (&mp->variant[0].pos, _("\ this message has no definition in the \"%s\" domain"), domain_name); } } @@ -743,9 +743,9 @@ merge (fn1, fn2) if (verbosity_level > 1) { - gram_error_at_line (&refmsg->variant[0].pos, _("\ + po_gram_error_at_line (&refmsg->variant[0].pos, _("\ this message is used but not defined...")); - gram_error_at_line (&defmsg->variant[0].pos, _("\ + po_gram_error_at_line (&defmsg->variant[0].pos, _("\ ...but this definition is similar")); } @@ -772,7 +772,7 @@ this message is used but not defined...")); message_ty *mp; if (verbosity_level > 1) - gram_error_at_line (&refmsg->variant[0].pos, _("\ + po_gram_error_at_line (&refmsg->variant[0].pos, _("\ this message is used but not defined in %s"), fn1); mp = message_copy (refmsg); diff --git a/src/msgunfmt.c b/src/msgunfmt.c index 920d82f..6c5b6b7 100644 --- a/src/msgunfmt.c +++ b/src/msgunfmt.c @@ -43,7 +43,6 @@ #include <system.h> #include "gettext.h" -#include "domain.h" #include "hash-string.h" #include <libintl.h> #include "message.h" diff --git a/src/open-po.c b/src/open-po.c index aad7e61..1954b02 100644 --- a/src/open-po.c +++ b/src/open-po.c @@ -1,5 +1,5 @@ /* open-po - search for .po file along search path list and open for reading - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc. Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995. This program is free software; you can redistribute it and/or modify @@ -28,12 +28,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ # include <stdlib.h> #endif -#if defined STDC_HEADERS || HAVE_STRING_H +#ifdef HAVE_STRING_H # include <string.h> #else # include <strings.h> #endif +#include "open-po.h" #include "dir-list.h" #include "error.h" #include "system.h" @@ -54,7 +55,8 @@ extern char *xstrdup PARAMS ((const char *string)); /* Open the input file with the name INPUT_NAME. The ending .po is added if necessary. If INPUT_NAME is not an absolute file name and the file is - not found, the list of directories in INPUT_PATH_LIST is searched. */ + not found, the list of directories in "dir-list.h" is searched. The + file's pathname is returned in *FILE_NAME, for error message purposes. */ FILE * open_po_file (input_name, file_name) const char *input_name; @@ -89,40 +91,37 @@ open_po_file (input_name, file_name) free (*file_name); } - - /* File does not exist. */ - *file_name = xstrdup (input_name); - errno = ENOENT; - return NULL; } - - /* For relative file names, look through the directory search list, - trying the various extensions. If no directory search list is - specified, the current directory is used. */ - for (j = 0; (dir = dir_list_nth (j)) != NULL; ++j) - for (k = 0; k < SIZEOF (extension); ++k) - { - ext = extension[k]; - if (dir[0] == '.' && dir[1] == '\0') - { - *file_name = xmalloc (strlen(input_name) + strlen(ext) + 1); - stpcpy (stpcpy (*file_name, input_name), ext); - } - else + else + { + /* For relative file names, look through the directory search list, + trying the various extensions. If no directory search list is + specified, the current directory is used. */ + for (j = 0; (dir = dir_list_nth (j)) != NULL; ++j) + for (k = 0; k < SIZEOF (extension); ++k) { - *file_name = xmalloc (strlen (dir) + strlen (input_name) - + strlen (ext) + 2); - stpcpy (stpcpy (stpcpy (stpcpy (*file_name, dir), "/"), - input_name), - ext); + ext = extension[k]; + if (dir[0] == '.' && dir[1] == '\0') + { + *file_name = xmalloc (strlen(input_name) + strlen(ext) + 1); + stpcpy (stpcpy (*file_name, input_name), ext); + } + else + { + *file_name = xmalloc (strlen (dir) + strlen (input_name) + + strlen (ext) + 2); + stpcpy (stpcpy (stpcpy (stpcpy (*file_name, dir), "/"), + input_name), + ext); + } + + ret_val = fopen (*file_name, "r"); + if (ret_val != NULL || errno != ENOENT) + return ret_val; + + free (*file_name); } - - ret_val = fopen (*file_name, "r"); - if (ret_val != NULL || errno != ENOENT) - return ret_val; - - free (*file_name); - } + } /* File does not exist. */ *file_name = xstrdup (input_name); diff --git a/src/open-po.h b/src/open-po.h new file mode 100644 index 0000000..0bf9cb3 --- /dev/null +++ b/src/open-po.h @@ -0,0 +1,28 @@ +/* Opening PO files. + Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. + + 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 SRC_OPEN_PO_H +#define SRC_OPEN_PO_H + +/* Open the input file with the name INPUT_NAME. The ending .po is added + if necessary. If INPUT_NAME is not an absolute file name and the file is + not found, the list of directories in "dir-list.h" is searched. The + file's pathname is returned in *FILE_NAME, for error message purposes. */ +extern FILE *open_po_file PARAMS ((const char *__input_name, + char **__file_name)); + +#endif diff --git a/src/po-gram-gen.y b/src/po-gram-gen.y index 4d5023f..9153139 100644 --- a/src/po-gram-gen.y +++ b/src/po-gram-gen.y @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <pmiller@agso.gov.au> @@ -126,7 +126,7 @@ message } | msgid string_list { - gram_error_at_line (&$1, _("missing `msgstr' section")); + po_gram_error_at_line (&$1, _("missing `msgstr' section")); free ($2); } ; diff --git a/src/po-lex.c b/src/po-lex.c index 248ddc3..5e97946 100644 --- a/src/po-lex.c +++ b/src/po-lex.c @@ -44,9 +44,9 @@ #endif #include "po-lex.h" -#include "po-gram.h" #include "system.h" #include "error.h" +#include "open-po.h" #include "po-gram-gen2.h" #if HAVE_C_BACKSLASH_A @@ -70,6 +70,7 @@ static int keyword_p PARAMS ((char *__s)); static int control_sequence PARAMS ((void)); +/* Open the PO file FNAME and prepare its lexical analysis. */ void lex_open (fname) const char *fname; @@ -83,6 +84,7 @@ lex_open (fname) } +/* Terminate lexical analysis and close the current PO file. */ void lex_close () { @@ -99,7 +101,7 @@ lex_close () /* CAUTION: If you change this function, you must also make identical - changes to the macro of the same name in src/po-lex.h */ + changes to the macros of the same name in src/po-lex.h */ #if !__STDC__ || !defined __GNUC__ || __GNUC__ == 1 /* VARARGS1 */ @@ -142,9 +144,9 @@ po_gram_error (fmt, va_alist) /* VARARGS2 */ void # if defined VA_START && __STDC__ -gram_error_at_line (const lex_pos_ty *pp, const char *fmt, ...) +po_gram_error_at_line (const lex_pos_ty *pp, const char *fmt, ...) # else -gram_error_at_line (pp, fmt, va_alist) +po_gram_error_at_line (pp, fmt, va_alist) const lex_pos_ty *pp; const char *fmt; va_dcl @@ -176,6 +178,7 @@ gram_error_at_line (pp, fmt, va_alist) #endif +/* Read a single character, dealing with backslash-newline. */ static int lex_getc () { @@ -352,6 +355,8 @@ control_sequence () } +/* Return the next token in the PO file. The return codes are defined + in "po-gram-gen2.h". Associated data is put in 'po_gram_lval. */ int po_gram_lex () { @@ -549,6 +554,7 @@ po_gram_lex () } +/* po_gram_lex() can return comments as COMMENT. Switch this on or off. */ void po_lex_pass_comments (flag) int flag; @@ -557,6 +563,8 @@ po_lex_pass_comments (flag) } +/* po_gram_lex() can return obsolete entries as if they were normal entries. + Switch this on or off. */ void po_lex_pass_obsolete_entries (flag) int flag; diff --git a/src/po-lex.h b/src/po-lex.h index fd95d97..82ae7e8 100644 --- a/src/po-lex.h +++ b/src/po-lex.h @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> @@ -22,31 +22,72 @@ #include <sys/types.h> #include "error.h" +#include "pos.h" -typedef struct lex_pos_ty lex_pos_ty; -struct lex_pos_ty -{ - char *file_name; - size_t line_number; -}; +/* Lexical analyzer for reading PO files. */ /* Global variables from po-lex.c. */ + +/* Current position within the PO file. */ extern lex_pos_ty gram_pos; -extern size_t gram_max_allowed_errors; +/* Number of parse errors within a PO file that cause the program to + terminate. Cf. error_message_count, declared in <error.h>. */ +extern unsigned int gram_max_allowed_errors; + + +/* Open the PO file FNAME and prepare its lexical analysis. */ +extern void lex_open PARAMS ((const char *__fname)); + +/* Terminate lexical analysis and close the current PO file. */ +extern void lex_close PARAMS ((void)); -void lex_open PARAMS ((const char *__fname)); -void lex_close PARAMS ((void)); -int po_gram_lex PARAMS ((void)); -void po_lex_pass_comments PARAMS ((int __flag)); -void po_lex_pass_obsolete_entries PARAMS ((int __flag)); +/* Return the next token in the PO file. The return codes are defined + in "po-gram-gen2.h". Associated data is put in 'po_gram_lval. */ +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)); -/* GCC is smart enough to allow optimizations like this. */ -#if __STDC__ && defined __GNUC__ && __GNUC__ >= 2 +/* 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)); +/* ISO C 99 is smart enough to allow optimizations like this. */ +#if __STDC__ && (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) + +/* CAUTION: If you change this macro, you must also make identical + changes to the function of the same name in src/po-lex.c */ + +# define po_gram_error(fmt, ...) \ + do { \ + error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number, \ + fmt, __VA_ARGS__); \ + if (*fmt == '.') \ + --error_message_count; \ + else if (error_message_count >= gram_max_allowed_errors) \ + error (1, 0, _("too many errors, aborting")); \ + } while (0) + + +/* CAUTION: If you change this macro, you must also make identical + changes to the function of the same name in src/po-lex.c */ + +# define po_gram_error_at_line(pos, fmt, ...) \ + do { \ + error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \ + fmt, __VA_ARGS__); \ + if (*fmt == '.') \ + --error_message_count; \ + else if (error_message_count >= gram_max_allowed_errors) \ + error (1, 0, _("too many errors, aborting")); \ + } while (0) + +/* GCC is also smart enough to allow optimizations like this. */ +#elif __STDC__ && defined __GNUC__ && __GNUC__ >= 2 + /* CAUTION: If you change this macro, you must also make identical changes to the function of the same name in src/po-lex.c */ @@ -56,7 +97,7 @@ void po_lex_pass_obsolete_entries PARAMS ((int __flag)); fmt, ## args); \ if (*fmt == '.') \ --error_message_count; \ - else if (error_message_count >= gram_max_allowed_errors) \ + else if (error_message_count >= gram_max_allowed_errors) \ error (1, 0, _("too many errors, aborting")); \ } while (0) @@ -64,7 +105,7 @@ void po_lex_pass_obsolete_entries PARAMS ((int __flag)); /* CAUTION: If you change this macro, you must also make identical changes to the function of the same name in src/po-lex.c */ -# define gram_error_at_line(pos, fmt, args...) \ +# define po_gram_error_at_line(pos, fmt, args...) \ do { \ error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \ fmt, ## args); \ @@ -73,10 +114,11 @@ void po_lex_pass_obsolete_entries PARAMS ((int __flag)); else if (error_message_count >= gram_max_allowed_errors) \ error (1, 0, _("too many errors, aborting")); \ } while (0) + #else -void po_gram_error PARAMS ((const char *__fmt, ...)); -void gram_error_at_line PARAMS ((const lex_pos_ty *__pos, const char *__fmt, - ...)); +extern void po_gram_error PARAMS ((const char *__fmt, ...)); +extern void po_gram_error_at_line PARAMS ((const lex_pos_ty *__pos, + const char *__fmt, ...)); #endif @@ -96,7 +96,7 @@ po_scan (pop, filename) po_gram_parse (); po_parse_debrief (pop); lex_close (); - callback_arg = 0; + callback_arg = NULL; } @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "po-lex.h" /* Note: the _t suffix is reserved by ANSI C, so the _ty suffix is - used to indicate a type name */ + used to indicate a type name. */ /* The following pair of structures cooperate to create an "Object" in the OO sense, we are simply doing it manually, rather than with the @@ -96,7 +96,7 @@ struct po_method_ty /* This next structure defines the base class passed to the methods. Derived methods will often need to cast their first argument before - using it (this correponds to the implicit ``this'' argument of many + using it (this corresponds to the implicit ``this'' argument of many C++ implementations). When declaring derived classes, use the PO_BASE_TY define at the @@ -113,17 +113,27 @@ struct po_ty }; -po_ty *po_alloc PARAMS ((po_method_ty *__jtable)); -void po_scan PARAMS ((po_ty *__pop, const char *__filename)); -void po_free PARAMS ((po_ty *__pop)); +/* Allocate a fresh po_ty (or derived class) instance and call its + constructor. */ +extern po_ty *po_alloc PARAMS ((po_method_ty *__jtable)); + +/* Read a PO file, and dispatch to the various po_method_ty methods. */ +extern void po_scan PARAMS ((po_ty *__pop, const char *__filename)); + +/* Call the destructor and deallocate a po_ty (or derived class) + instance. */ +extern void po_free PARAMS ((po_ty *__pop)); + /* Callbacks used by po-gram.y or po-hash.y or po-lex.c, indirectly from po_scan. */ -void po_callback_domain PARAMS ((char *__name)); -void po_callback_message PARAMS ((char *__msgid, lex_pos_ty *__msgid_pos, - char *__msgstr, lex_pos_ty *__msgstr_pos)); -void po_callback_comment PARAMS ((const char *__s)); -void po_callback_comment_dot PARAMS ((const char *__s)); -void po_callback_comment_filepos PARAMS ((const char *__s, int __line)); +extern void po_callback_domain PARAMS ((char *__name)); +extern void po_callback_message PARAMS ((char *__msgid, + lex_pos_ty *__msgid_pos, + char *__msgstr, + lex_pos_ty *__msgstr_pos)); +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)); #endif diff --git a/src/pos.h b/src/pos.h new file mode 100644 index 0000000..5626cbc --- /dev/null +++ b/src/pos.h @@ -0,0 +1,30 @@ +/* Source file positions. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. + + 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 SRC_POS_H +#define SRC_POS_H + +/* Position of a message within a source file. + Used for error reporting purposes. */ +typedef struct lex_pos_ty lex_pos_ty; +struct lex_pos_ty +{ + char *file_name; + size_t line_number; +}; + +#endif diff --git a/src/str-list.c b/src/str-list.c index 4000745..7d27020 100644 --- a/src/str-list.c +++ b/src/str-list.c @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "str-list.h" +/* Return a fresh, empty list of strings. */ string_list_ty * string_list_alloc () { @@ -41,6 +42,7 @@ string_list_alloc () } +/* Append a single string to the end of a list of strings. */ void string_list_append (slp, s) string_list_ty *slp; @@ -61,6 +63,8 @@ string_list_append (slp, s) } +/* Append a single string to the end of a list of strings, unless it is + already contained in the list. */ void string_list_append_unique (slp, s) string_list_ty *slp; @@ -87,6 +91,7 @@ string_list_append_unique (slp, s) } +/* Free a list of strings. */ void string_list_free (slp) string_list_ty *slp; @@ -101,6 +106,8 @@ string_list_free (slp) } +/* Return a freshly allocated string obtained by concatenating all the + strings in the list, separated by spaces. */ char * string_list_join (slp) const string_list_ty *slp; @@ -127,11 +134,12 @@ string_list_join (slp) memcpy (result + pos, slp->item[j], len); pos += len; } - result[pos] = 0; + result[pos] = '\0'; return result; } +/* Return 1 if s is contained in the list of strings, 0 otherwise. */ int string_list_member (slp, s) const string_list_ty *slp; diff --git a/src/str-list.h b/src/str-list.h index 9e2b998..cecee48 100644 --- a/src/str-list.h +++ b/src/str-list.h @@ -1,5 +1,5 @@ /* GNU gettext - internationalization aids - Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation, Inc. This file was written by Peter Miller <millerp@canb.auug.org.au> @@ -20,16 +20,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef SRC_STR_LIST_H #define SRC_STR_LIST_H 1 -#ifdef STC_HEADERS -# define __need_size_t -# define __need_NULL +/* Get size_t and NULL. */ +#ifdef HAVE_STDDEF_H # include <stddef.h> #else # include <sys/types.h> # include <stdio.h> #endif -/* Type describing list of strings implemented using a dynamic array. */ +/* Type describing list of immutable strings, + implemented using a dynamic array. */ typedef struct string_list_ty string_list_ty; struct string_list_ty { @@ -38,13 +38,27 @@ struct string_list_ty size_t nitems_max; }; +/* Return a fresh, empty list of strings. */ +extern string_list_ty *string_list_alloc PARAMS ((void)); -string_list_ty *string_list_alloc PARAMS ((void)); -void string_list_append PARAMS ((string_list_ty *__slp, const char *__s)); -void string_list_append_unique PARAMS ((string_list_ty *__slp, +/* Append a single string to the end of a list of strings. */ +extern void string_list_append PARAMS ((string_list_ty *__slp, const char *__s)); -void string_list_free PARAMS ((string_list_ty *__slp)); -char *string_list_join PARAMS ((const string_list_ty *__slp)); -int string_list_member PARAMS ((const string_list_ty *__slp, const char *__s)); + +/* Append a single string to the end of a list of strings, unless it is + already contained in the list. */ +extern void string_list_append_unique PARAMS ((string_list_ty *__slp, + const char *__s)); + +/* Free a list of strings. */ +extern void string_list_free PARAMS ((string_list_ty *__slp)); + +/* Return a freshly allocated string obtained by concatenating all the + strings in the list, separated by spaces. */ +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)); #endif diff --git a/src/xgettext.c b/src/xgettext.c index 0ac43da..884ecb7 100644 --- a/src/xgettext.c +++ b/src/xgettext.c @@ -56,7 +56,6 @@ extern int errno; #include "printf-parse.h" #include "gettext.h" -#include "domain.h" #include <libintl.h> #ifndef _POSIX_VERSION @@ -735,7 +734,7 @@ remember_a_message (mlp, tp) xgettext_token_ty *tp; { enum is_c_format is_c_format = undecided; - enum is_c_format do_wrap = undecided; + enum is_wrap do_wrap = undecided; char *msgid; message_ty *mp; char *msgstr; @@ -960,8 +959,8 @@ struct extract_class_ty string_list_ty *comment_dot; int is_fuzzy; - int is_c_format; - int do_wrap; + enum is_c_format is_c_format; + enum is_wrap do_wrap; int filepos_count; lex_pos_ty *filepos; @@ -1083,8 +1082,8 @@ extract_directive_message (that, msgid, msgid_pos, msgstr, msgstr_pos) mvp = message_variant_search (mp, MESSAGE_DOMAIN_DEFAULT); if (mvp != NULL && strcmp (msgstr, mvp->msgstr) != 0) { - gram_error_at_line (msgid_pos, _("duplicate message definition")); - gram_error_at_line (&mvp->pos, _("\ + po_gram_error_at_line (msgid_pos, _("duplicate message definition")); + po_gram_error_at_line (&mvp->pos, _("\ ...this is the location of the first definition")); free (msgstr); } @@ -1,6 +1,6 @@ #! /bin/sh # ylwrap - wrapper for lex/yacc invocations. -# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. # Written by Tom Tromey <tromey@cygnus.com>. # # This program is free software; you can redistribute it and/or modify @@ -29,12 +29,17 @@ # The program to run. prog="$1" shift +# Make any relative path in $prog absolute. +case "$prog" in + /* | [A-Za-z]:\\*) ;; + */*) prog="`pwd`/$prog" ;; +esac # The input. input="$1" shift case "$input" in - /*) + /* | [A-Za-z]:\\*) # Absolute path; do nothing. ;; *) @@ -45,9 +50,17 @@ case "$input" in ;; esac +# We don't want to use the absolute path if the input in the current +# directory like when making a tar ball. +input_base=`echo $input | sed -e 's|.*/||'` +if test -f $input_base && cmp $input_base $input >/dev/null 2>&1; then + input=$input_base +fi + pairlist= while test "$#" -ne 0; do if test "$1" = "--"; then + shift break fi pairlist="$pairlist $1" @@ -61,6 +74,15 @@ trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 mkdir $dirname || exit 1 cd $dirname +case "$input" in + /* | [A-Za-z]:\\*) + # Absolute path; do nothing. + ;; + *) + # Make a symbolic link, hard link or hardcopy. + ln -s ../"$input" . > /dev/null 2>&1 || ln ../"$input" . > /dev/null 2>&1 || cp ../"$input" . + ;; +esac $prog ${1+"$@"} "$input" status=$? @@ -73,7 +95,7 @@ if test $status -eq 0; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in - /*) target="$2";; + /* | [A-Za-z]:\\*) target="$2";; *) target="../$2";; esac mv "$1" "$target" || status=$? |