1 /* GNU gettext - internationalization aids
2 Copyright (C) 1995-1998, 2000-2004 Free Software Foundation, Inc.
4 This file was written by Peter Miller <millerp@canb.auug.org.au>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #include <sys/types.h>
27 #include "error-progname.h"
38 /* Lexical analyzer for reading PO files. */
41 /* Global variables from po-lex.c. */
43 /* Current position within the PO file. */
44 extern DLL_VARIABLE lex_pos_ty gram_pos
;
45 extern DLL_VARIABLE
int gram_pos_column
;
47 /* Number of parse errors within a PO file that cause the program to
48 terminate. Cf. error_message_count, declared in <error.h>. */
49 extern DLL_VARIABLE
unsigned int gram_max_allowed_errors
;
51 /* True if obsolete entries shall be considered as valid. */
52 extern DLL_VARIABLE
bool pass_obsolete_entries
;
55 /* Prepare lexical analysis. */
56 extern void lex_start (FILE *fp
, const char *real_filename
,
57 const char *logical_filename
);
59 /* Terminate lexical analysis. */
60 extern void lex_end (void);
62 /* Return the next token in the PO file. The return codes are defined
63 in "po-gram-gen2.h". Associated data is put in 'po_gram_lval. */
64 extern int po_gram_lex (void);
66 /* po_gram_lex() can return comments as COMMENT. Switch this on or off. */
67 extern void po_lex_pass_comments (bool flag
);
69 /* po_gram_lex() can return obsolete entries as if they were normal entries.
70 Switch this on or off. */
71 extern void po_lex_pass_obsolete_entries (bool flag
);
74 /* ISO C 99 is smart enough to allow optimizations like this.
75 Note: OpenVMS 7.3 cc pretends to support ISO C 99 but chokes on '...'. */
76 #if __STDC__ && (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __DECC)
78 /* CAUTION: If you change this macro, you must also make identical
79 changes to the function of the same name in src/po-lex.c */
81 # define po_gram_error(fmt, ...) \
83 char *totalfmt = xasprintf ("%s%s", "%s:%lu:%d: ", fmt); \
84 error_with_progname = false; \
85 po_error (0, 0, totalfmt, gram_pos.file_name, \
86 (unsigned long) gram_pos.line_number, gram_pos_column + 1, \
88 error_with_progname = true; \
91 --error_message_count; \
92 else if (error_message_count >= gram_max_allowed_errors) \
93 po_error (1, 0, _("too many errors, aborting")); \
96 /* CAUTION: If you change this macro, you must also make identical
97 changes to the function of the same name in src/po-lex.c */
99 # define po_gram_error_at_line(pos, fmt, ...) \
101 error_with_progname = false; \
102 po_error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \
103 fmt, __VA_ARGS__ + 0); \
104 error_with_progname = true; \
106 --error_message_count; \
107 else if (error_message_count >= gram_max_allowed_errors) \
108 po_error (1, 0, _("too many errors, aborting")); \
111 /* GCC is also smart enough to allow optimizations like this. */
112 #elif __STDC__ && defined __GNUC__ && __GNUC__ >= 2 && !defined __APPLE_CC__
114 /* CAUTION: If you change this macro, you must also make identical
115 changes to the function of the same name in src/po-lex.c */
117 # define po_gram_error(fmt, args...) \
119 char *totalfmt = xasprintf ("%s%s", "%s:%d:%d: ", fmt); \
120 error_with_progname = false; \
121 po_error (0, 0, totalfmt, gram_pos.file_name, gram_pos.line_number, \
122 gram_pos_column + 1 , ## args); \
123 error_with_progname = true; \
126 --error_message_count; \
127 else if (error_message_count >= gram_max_allowed_errors) \
128 po_error (1, 0, _("too many errors, aborting")); \
131 /* CAUTION: If you change this macro, you must also make identical
132 changes to the function of the same name in src/po-lex.c */
134 # define po_gram_error_at_line(pos, fmt, args...) \
136 error_with_progname = false; \
137 po_error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \
139 error_with_progname = true; \
141 --error_message_count; \
142 else if (error_message_count >= gram_max_allowed_errors) \
143 po_error (1, 0, _("too many errors, aborting")); \
147 extern void po_gram_error (const char *fmt
, ...);
148 extern void po_gram_error_at_line (const lex_pos_ty
*pos
, const char *fmt
, ...);
152 /* Contains information about the definition of one translation. */