No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / src / msgl-ascii.c
blobda7494153ca0acf444b013be9ca78ae6dcc65b1e
1 /* Message list test for ASCII character set.
2 Copyright (C) 2001-2002, 2005 Free Software Foundation, Inc.
3 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 #endif
24 /* Specification. */
25 #include "msgl-ascii.h"
27 #include "c-ctype.h"
30 /* This file's structure parallels msgl-iconv.c. */
33 bool
34 is_ascii_string (const char *string)
36 for (; *string; string++)
37 if (!c_isascii ((unsigned char) *string))
38 return false;
39 return true;
42 bool
43 is_ascii_string_list (string_list_ty *slp)
45 size_t i;
47 if (slp != NULL)
48 for (i = 0; i < slp->nitems; i++)
49 if (!is_ascii_string (slp->item[i]))
50 return false;
51 return true;
54 bool
55 is_ascii_message (message_ty *mp)
57 const char *p = mp->msgstr;
58 const char *p_end = p + mp->msgstr_len;
60 for (; p < p_end; p++)
61 if (!c_isascii ((unsigned char) *p))
62 return false;
64 if (!is_ascii_string_list (mp->comment))
65 return false;
66 if (!is_ascii_string_list (mp->comment_dot))
67 return false;
69 /* msgid and msgid_plural are normally ASCII, so why checking?
70 Because in complete UTF-8 environments they can be UTF-8, not ASCII. */
71 if (!is_ascii_string (mp->msgid))
72 return false;
73 if (mp->msgid_plural != NULL && !is_ascii_string (mp->msgid_plural))
74 return false;
76 return true;
79 bool
80 is_ascii_message_list (message_list_ty *mlp)
82 size_t j;
84 for (j = 0; j < mlp->nitems; j++)
85 if (!is_ascii_message (mlp->item[j]))
86 return false;
88 return true;
91 bool
92 is_ascii_msgdomain_list (msgdomain_list_ty *mdlp)
94 size_t k;
96 for (k = 0; k < mdlp->nitems; k++)
97 if (!is_ascii_message_list (mdlp->item[k]->messages))
98 return false;
100 return true;