diff options
Diffstat (limited to 'gettext-tools/src/xgettext.h')
-rw-r--r-- | gettext-tools/src/xgettext.h | 92 |
1 files changed, 86 insertions, 6 deletions
diff --git a/gettext-tools/src/xgettext.h b/gettext-tools/src/xgettext.h index c2fe3d1..619a785 100644 --- a/gettext-tools/src/xgettext.h +++ b/gettext-tools/src/xgettext.h @@ -1,5 +1,5 @@ /* xgettext common functions. - Copyright (C) 2001-2003 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc. Written by Peter Miller <millerp@canb.auug.org.au> and Bruno Haible <haible@clisp.cons.org>, 2001. @@ -20,6 +20,7 @@ #ifndef _XGETTEXT_H #define _XGETTEXT_H +#include <stdbool.h> #include <stddef.h> #include <stdlib.h> @@ -47,9 +48,32 @@ extern int xgettext_omit_header; extern bool substring_match; -/* Split keyword spec into keyword, argnum1, argnum2. */ +/* Calling convention for a given keyword. */ +struct callshape +{ + int argnum1; /* argument number to use for msgid */ + int argnum2; /* argument number to use for msgid_plural */ + int argnumc; /* argument number to use for msgctxt */ +}; + +/* Split keyword spec into keyword, argnum1, argnum2, argnumc. */ extern void split_keywordspec (const char *spec, const char **endp, - int *argnum1p, int *argnum2p); + struct callshape *shapep); + +/* Set of alternative calling conventions for a given keyword. */ +struct callshapes +{ + const char *keyword; /* the keyword, not NUL terminated */ + size_t keyword_len; /* the keyword's length */ + size_t nshapes; + struct callshape shapes[1]; /* actually nshapes elements */ +}; + +/* Insert a (keyword, callshape) pair into a hash table mapping keyword to + 'struct callshapes *'. */ +extern void insert_keyword_callshape (hash_table *table, + const char *keyword, size_t keyword_len, + const struct callshape *shape); /* Context representing some flags. */ @@ -192,19 +216,22 @@ extern void savable_comment_reset (void); /* Add a message to the list of extracted messages. - STRING must be malloc()ed string; its ownership is passed to the callee. + msgctxt must be either NULL or a malloc()ed string; its ownership is passed + to the callee. + MSGID must be a malloc()ed string; its ownership is passed to the callee. POS->file_name must be allocated with indefinite extent. COMMENT may be savable_comment, or it may be a saved copy of savable_comment (then add_reference must be used when saving it, and drop_reference while dropping it). Clear savable_comment. */ extern message_ty *remember_a_message (message_list_ty *mlp, - char *string, + char *msgctxt, + char *msgid, flag_context_ty context, lex_pos_ty *pos, refcounted_string_list_ty *comment); /* Add an msgid_plural to a message previously returned by remember_a_message. - STRING must be malloc()ed string; its ownership is passed to the callee. + STRING must be a malloc()ed string; its ownership is passed to the callee. POS->file_name must be allocated with indefinite extent. COMMENT may be savable_comment, or it may be a saved copy of savable_comment (then add_reference must be used when saving it, and drop_reference while @@ -216,6 +243,59 @@ extern void remember_a_message_plural (message_ty *mp, refcounted_string_list_ty *comment); +/* Represents the progressive parsing of an argument list w.r.t. a single + 'struct callshape'. */ +struct partial_call +{ + int argnumc; /* number of context argument, 0 when seen */ + int argnum1; /* number of singular argument, 0 when seen */ + int argnum2; /* number of plural argument, 0 when seen */ + char *msgctxt; /* context - owned string, or NULL */ + lex_pos_ty msgctxt_pos; + char *msgid; /* msgid - owned string, or NULL */ + flag_context_ty msgid_context; + lex_pos_ty msgid_pos; + refcounted_string_list_ty *msgid_comment; + char *msgid_plural; /* msgid_plural - owned string, or NULL */ + flag_context_ty msgid_plural_context; + lex_pos_ty msgid_plural_pos; +}; + +/* Represents the progressive parsing of an argument list w.r.t. an entire + 'struct callshapes'. */ +struct arglist_parser +{ + message_list_ty *mlp; /* list where the message shall be added */ + const char *keyword; /* the keyword, not NUL terminated */ + size_t keyword_len; /* the keyword's length */ + size_t nalternatives; /* number of partial_call alternatives */ + struct partial_call alternative[1]; /* partial_call alternatives */ +}; + +/* Creates a fresh arglist_parser recognizing calls. + You can pass shapes = NULL for a parser not recognizing any calls. */ +extern struct arglist_parser * arglist_parser_alloc (message_list_ty *mlp, + const struct callshapes *shapes); +/* Clones an arglist_parser. */ +extern struct arglist_parser * arglist_parser_clone (struct arglist_parser *ap); +/* Adds a string argument to an arglist_parser. ARGNUM must be > 0. + STRING must be malloc()ed string; its ownership is passed to the callee. + FILE_NAME must be allocated with indefinite extent. + COMMENT may be savable_comment, or it may be a saved copy of savable_comment + (then add_reference must be used when saving it, and drop_reference while + dropping it). Clear savable_comment. */ +extern void arglist_parser_remember (struct arglist_parser *ap, + int argnum, char *string, + flag_context_ty context, + char *file_name, size_t line_number, + refcounted_string_list_ty *comment); +/* Tests whether an arglist_parser has is not waiting for more arguments after + argument ARGNUM. */ +extern bool arglist_parser_decidedp (struct arglist_parser *ap, int argnum); +/* Terminates the processing of an arglist_parser and deletes it. */ +extern void arglist_parser_done (struct arglist_parser *ap); + + #ifdef __cplusplus } #endif |