#ifndef _PO_LEX_H
#define _PO_LEX_H
#include <sys/types.h>
#include <stdio.h>
#include <stdbool.h>
#include "error.h"
#include "error-progname.h"
#include "pos.h"
#include "xerror.h"
#ifdef __cplusplus
extern "C" {
#endif
extern DLL_VARIABLE lex_pos_ty gram_pos;
extern DLL_VARIABLE int gram_pos_column;
extern DLL_VARIABLE unsigned int gram_max_allowed_errors;
extern DLL_VARIABLE bool pass_obsolete_entries;
extern void lex_start (FILE *fp, const char *real_filename,
const char *logical_filename);
extern void lex_end (void);
extern int po_gram_lex (void);
extern void po_lex_pass_comments (bool flag);
extern void po_lex_pass_obsolete_entries (bool flag);
#if __STDC__ && (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __DECC)
# define po_gram_error(fmt, ...) \
do { \
char *totalfmt = xasprintf ("%s%s", "%s:%lu:%d: ", fmt); \
error_with_progname = false; \
error (0, 0, totalfmt, gram_pos.file_name, \
(unsigned long) gram_pos.line_number, gram_pos_column + 1, \
__VA_ARGS__ + 0); \
error_with_progname = true; \
free (totalfmt); \
if (*fmt == '.') \
--error_message_count; \
else if (error_message_count >= gram_max_allowed_errors) \
error (1, 0, _("too many errors, aborting")); \
} while (0)
# define po_gram_error_at_line(pos, fmt, ...) \
do { \
error_with_progname = false; \
error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \
fmt, __VA_ARGS__ + 0); \
error_with_progname = true; \
if (*fmt == '.') \
--error_message_count; \
else if (error_message_count >= gram_max_allowed_errors) \
error (1, 0, _("too many errors, aborting")); \
} while (0)
#elif __STDC__ && defined __GNUC__ && __GNUC__ >= 2 && !defined __APPLE_CC__
# define po_gram_error(fmt, args...) \
do { \
char *totalfmt = xasprintf ("%s%s", "%s:%d:%d: ", fmt); \
error_with_progname = false; \
error (0, 0, totalfmt, gram_pos.file_name, gram_pos.line_number, \
gram_pos_column + 1 , ## args); \
error_with_progname = true; \
free (totalfmt); \
if (*fmt == '.') \
--error_message_count; \
else if (error_message_count >= gram_max_allowed_errors) \
error (1, 0, _("too many errors, aborting")); \
} while (0)
# define po_gram_error_at_line(pos, fmt, args...) \
do { \
error_with_progname = false; \
error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \
fmt , ## args); \
error_with_progname = true; \
if (*fmt == '.') \
--error_message_count; \
else if (error_message_count >= gram_max_allowed_errors) \
error (1, 0, _("too many errors, aborting")); \
} while (0)
#else
extern void po_gram_error (const char *fmt, ...);
extern void po_gram_error_at_line (const lex_pos_ty *pos, const char *fmt, ...);
#endif
struct msgstr_def
{
char *msgstr;
size_t msgstr_len;
};
#ifdef __cplusplus
}
#endif
#endif