Sun Dec 17 15:56:35 1995 Miles Bader <miles@gnu.ai.mit.edu>
[glibc.git] / locale / messages.c
blob842e5ef5b278212858af8641fa70020c85f9970f
1 /* Copyright (C) 1995 Free Software Foundation, Inc.
3 The GNU C Library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public License as
5 published by the Free Software Foundation; either version 2 of the
6 License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public
14 License along with the GNU C Library; see the file COPYING.LIB. If
15 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
16 Cambridge, MA 02139, USA. */
18 #include <langinfo.h>
19 #include <libintl.h>
20 #include <locale.h>
21 #include <stdio.h>
22 #include <regex.h>
24 #include "localedef.h"
26 /* These are defined in locfile-parse.c. */
27 extern struct cat_item LC_MESSAGES_desc[];
28 extern char *LC_MESSAGES_values[];
30 void
31 messages_check(void)
33 int item_no;
35 /* First general check for existence. */
36 for (item_no = 0; item_no < category[LC_MESSAGES].number; ++item_no)
37 if (LC_MESSAGES_values[item_no] == NULL)
39 int errcode;
41 errcode = LC_MESSAGES_desc[item_no].status == std ? 5 : 0;
43 error (errcode, 0, gettext ("item `%s' of category `%s' undefined"),
44 LC_MESSAGES_desc[item_no].name, "LC_MESSAGES");
46 else
48 /* Some fields need special tests. */
49 if (LC_MESSAGES_desc[item_no].item_id == YESEXPR
50 || LC_MESSAGES_desc[item_no].item_id == NOEXPR)
51 /* The expression has to be a POSIX extended regular expression. */
53 regex_t re;
54 int result;
56 result = regcomp (&re, LC_MESSAGES_values[item_no], REG_EXTENDED);
58 if (result != 0)
60 char errbuf[BUFSIZ];
62 (void) regerror (result, &re, errbuf, BUFSIZ);
63 error (0, 0, gettext ("no correct regular expression for "
64 "item `%s' in category `%s': %s"),
65 LC_MESSAGES_desc[item_no].name, "LC_MESSAGES", errbuf);
72 * Local Variables:
73 * mode:c
74 * c-basic-offset:2
75 * End: