Copies from gettext-0.10.35.

CVS patchset: 2331
CVS date: 1998/09/20 17:49:35
This commit is contained in:
jbj 1998-09-20 17:49:35 +00:00
parent 0ba3a6c926
commit 33e58c54f5
5 changed files with 469 additions and 0 deletions

25
misc/fstrcmp.h Normal file
View File

@ -0,0 +1,25 @@
/* GNU gettext - internationalization aids
Copyright (C) 1995 Free Software Foundation, Inc.
This file was written by Peter Miller <pmiller@agso.gov.au>
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 _FSTRCMP_H
#define _FSTRCMP_H
double fstrcmp PARAMS ((const char *__s1, const char *__s2));
#endif

182
misc/libgettext.h Normal file
View File

@ -0,0 +1,182 @@
/* Message catalogs for internationalization.
Copyright (C) 1995, 1996, 1997, 1998 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. */
/* Because on some systems (e.g. Solaris) we sometimes have to include
the systems libintl.h as well as this file we have more complex
include protection above. But the systems header might perhaps also
define _LIBINTL_H and therefore we have to protect the definition here. */
#if !defined _LIBINTL_H || !defined _LIBGETTEXT_H
#ifndef _LIBINTL_H
# define _LIBINTL_H 1
#endif
#define _LIBGETTEXT_H 1
/* We define an additional symbol to signal that we use the GNU
implementation of gettext. */
#define __USE_GNU_GETTEXT 1
#include <sys/types.h>
#if HAVE_LOCALE_H
# include <locale.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* @@ end of prolog @@ */
#ifndef PARAMS
# if __STDC__ || defined __cplusplus
# define PARAMS(args) args
# else
# define PARAMS(args) ()
# endif
#endif
#ifndef NULL
# if !defined __cplusplus || defined __GNUC__
# define NULL ((void *) 0)
# else
# define NULL (0)
# endif
#endif
#if !HAVE_LC_MESSAGES
/* This value determines the behaviour of the gettext() and dgettext()
function. But some system does not have this defined. Define it
to a default value. */
# define LC_MESSAGES (-1)
#endif
/* Declarations for gettext-using-catgets interface. Derived from
Jim Meyering's libintl.h. */
struct _msg_ent
{
const char *_msg;
int _msg_number;
};
#if HAVE_CATGETS
/* These two variables are defined in the automatically by po-to-tbl.sed
generated file `cat-id-tbl.c'. */
extern const struct _msg_ent _msg_tbl[];
extern int _msg_tbl_length;
#endif
/* For automatical extraction of messages sometimes no real
translation is needed. Instead the string itself is the result. */
#define gettext_noop(Str) (Str)
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
extern char *gettext PARAMS ((const char *__msgid));
extern char *gettext__ PARAMS ((const char *__msgid));
/* Look up MSGID in the DOMAINNAME message catalog for the current
LC_MESSAGES locale. */
extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid));
extern char *dgettext__ PARAMS ((const char *__domainname,
const char *__msgid));
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid,
int __category));
extern char *dcgettext__ PARAMS ((const char *__domainname,
const char *__msgid, int __category));
/* Set the current default message catalog to DOMAINNAME.
If DOMAINNAME is null, return the current default.
If DOMAINNAME is "", reset to the default of "messages". */
extern char *textdomain PARAMS ((const char *__domainname));
extern char *textdomain__ PARAMS ((const char *__domainname));
/* Specify that the DOMAINNAME message catalog will be found
in DIRNAME rather than in the system locale data base. */
extern char *bindtextdomain PARAMS ((const char *__domainname,
const char *__dirname));
extern char *bindtextdomain__ PARAMS ((const char *__domainname,
const char *__dirname));
#if ENABLE_NLS
/* Solaris 2.3 has the gettext function but dcgettext is missing.
So we omit this optimization for Solaris 2.3. BTW, Solaris 2.4
has dcgettext. */
# if !HAVE_CATGETS && (!HAVE_GETTEXT || HAVE_DCGETTEXT)
# define gettext(Msgid) \
dgettext (NULL, Msgid)
# define dgettext(Domainname, Msgid) \
dcgettext (Domainname, Msgid, LC_MESSAGES)
# if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7
/* This global variable is defined in loadmsgcat.c. We need a sign,
whether a new catalog was loaded, which can be associated with all
translations. */
extern int _nl_msg_cat_cntr;
# define dcgettext(Domainname, Msgid, Category) \
(__extension__ \
({ \
char *__result; \
if (__builtin_constant_p (Msgid)) \
{ \
static char *__translation__; \
static int __catalog_counter__; \
if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \
{ \
__translation__ = \
dcgettext__ (Domainname, Msgid, Category); \
__catalog_counter__ = _nl_msg_cat_cntr; \
} \
__result = __translation__; \
} \
else \
__result = dcgettext__ (Domainname, Msgid, Category); \
__result; \
}))
# endif
# endif
#else
# define gettext(Msgid) (Msgid)
# define dgettext(Domainname, Msgid) (Msgid)
# define dcgettext(Domainname, Msgid, Category) (Msgid)
# define textdomain(Domainname) ((char *) Domainname)
# define bindtextdomain(Domainname, Dirname) ((char *) Dirname)
#endif
/* @@ begin of epilog @@ */
#ifdef __cplusplus
}
#endif
#endif

129
misc/message.h Normal file
View File

@ -0,0 +1,129 @@
/* GNU gettext - internationalization aids
Copyright (C) 1995, 1996, 1997, 1998 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
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 SoftwareFoundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MESSAGE_H
#define _MESSAGE_H
#include "po-lex.h"
#include "str-list.h"
/* According to Sun's Uniforum proposal the default message domain is
named `messages'. */
#define MESSAGE_DOMAIN_DEFAULT "messages"
/* Is current msgid a format string? */
enum is_c_format
{
undecided,
yes,
no,
possible,
impossible
};
typedef struct message_variant_ty message_variant_ty;
struct message_variant_ty
{
const char *domain;
lex_pos_ty pos;
const char *msgstr;
};
typedef struct message_ty message_ty;
struct message_ty
{
/* Plain comments (#) appearing before the message. */
string_list_ty *comment;
/* Extracted comments (#.) appearing before the message. */
string_list_ty *comment_dot;
/* File position comments (#:) appearing before the message, one for
each unique file position instance, sorted by file name and then
by line. */
size_t filepos_count;
lex_pos_ty *filepos;
/* Informations from special comments (e.g. generated by msgmerge). */
int is_fuzzy;
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;
/* The msgid string. */
const char *msgid;
/* The msgstr strings, one for each observed domain in the file. */
size_t variant_count;
message_variant_ty *variant;
/* Used for checking that messages have been used, in the msgcmp and
msgmerge programs. */
int used;
/* If set the message is obsolete and while writing out it should be
commented out. */
int obsolete;
};
message_ty *message_alloc PARAMS ((char *msgid));
void message_free PARAMS ((message_ty *));
message_variant_ty *message_variant_search PARAMS ((message_ty *mp,
const char *domain));
void message_variant_append PARAMS ((message_ty *mp, const char *domain,
const char *msgstr,
const lex_pos_ty *pp));
void message_comment_append PARAMS ((message_ty *, const char *));
void message_comment_dot_append PARAMS ((message_ty *, const char *));
message_ty *message_copy PARAMS ((message_ty *));
message_ty *message_merge PARAMS ((message_ty *def, message_ty *ref));
void message_comment_filepos PARAMS ((message_ty *, const char *, size_t));
void message_print_style_indent PARAMS ((void));
void message_print_style_uniforum PARAMS ((void));
void message_print_style_escape PARAMS ((int));
typedef struct message_list_ty message_list_ty;
struct message_list_ty
{
message_ty **item;
size_t nitems;
size_t nitems_max;
};
message_list_ty *message_list_alloc PARAMS ((void));
void message_list_free PARAMS ((message_list_ty *));
void message_list_append PARAMS ((message_list_ty *, message_ty *));
void message_list_delete_nth PARAMS ((message_list_ty *, size_t));
message_ty *message_list_search PARAMS ((message_list_ty *, const char *));
message_ty *message_list_search_fuzzy PARAMS ((message_list_ty *,
const char *));
void message_list_print PARAMS ((message_list_ty *, const char *, int, int));
void message_list_sort_by_msgid PARAMS ((message_list_ty *));
void message_list_sort_by_filepos PARAMS ((message_list_ty *));
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 */

83
misc/po-lex.h Normal file
View File

@ -0,0 +1,83 @@
/* GNU gettext - internationalization aids
Copyright (C) 1995, 1996, 1997, 1998 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
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 _PO_LEX_H
#define _PO_LEX_H
#include <sys/types.h>
#include "error.h"
typedef struct lex_pos_ty lex_pos_ty;
struct lex_pos_ty
{
char *file_name;
size_t line_number;
};
/* Global variables from po-lex.c. */
extern lex_pos_ty gram_pos;
extern size_t gram_max_allowed_errors;
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));
/* GCC is smart enough to allow optimizations like this. */
#if __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 */
# define po_gram_error(fmt, args...) \
do { \
error_at_line (0, 0, gram_pos.file_name, gram_pos.line_number, \
fmt, ## 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 gram_error_at_line(pos, fmt, args...) \
do { \
error_at_line (0, 0, (pos)->file_name, (pos)->line_number, \
fmt, ## args); \
if (*fmt == '.') \
--error_message_count; \
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,
...));
#endif
#endif

50
misc/str-list.h Normal file
View File

@ -0,0 +1,50 @@
/* GNU gettext - internationalization aids
Copyright (C) 1995, 1996, 1998 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
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_STR_LIST_H
#define SRC_STR_LIST_H 1
#ifdef STC_HEADERS
# define __need_size_t
# define __need_NULL
# include <stddef.h>
#else
# include <sys/types.h>
# include <stdio.h>
#endif
/* Type describing list of strings implemented using a dynamic array. */
typedef struct string_list_ty string_list_ty;
struct string_list_ty
{
const char **item;
size_t nitems;
size_t nitems_max;
};
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,
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));
#endif