• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/src/
1/* Message list test for ASCII character set.
2   Copyright (C) 2001-2002, 2005-2006 Free Software Foundation, Inc.
3   Written by Bruno Haible <haible@clisp.cons.org>, 2001.
4
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 3 of the License, or
8   (at your option) any later version.
9
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.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23/* Specification.  */
24#include "msgl-ascii.h"
25
26#include "c-ctype.h"
27
28
29/* This file's structure parallels msgl-iconv.c.  */
30
31
32bool
33is_ascii_string (const char *string)
34{
35  for (; *string; string++)
36    if (!c_isascii ((unsigned char) *string))
37      return false;
38  return true;
39}
40
41bool
42is_ascii_string_list (string_list_ty *slp)
43{
44  size_t i;
45
46  if (slp != NULL)
47    for (i = 0; i < slp->nitems; i++)
48      if (!is_ascii_string (slp->item[i]))
49	return false;
50  return true;
51}
52
53bool
54is_ascii_message (message_ty *mp)
55{
56  const char *p = mp->msgstr;
57  const char *p_end = p + mp->msgstr_len;
58
59  for (; p < p_end; p++)
60    if (!c_isascii ((unsigned char) *p))
61      return false;
62
63  if (!is_ascii_string_list (mp->comment))
64    return false;
65  if (!is_ascii_string_list (mp->comment_dot))
66    return false;
67
68  /* msgid and msgid_plural are normally ASCII, so why checking?
69     Because in complete UTF-8 environments they can be UTF-8, not ASCII.  */
70  if (!is_ascii_string (mp->msgid))
71    return false;
72  if (mp->msgid_plural != NULL && !is_ascii_string (mp->msgid_plural))
73    return false;
74
75  /* Likewise for msgctxt.  */
76  if (mp->msgctxt != NULL && !is_ascii_string (mp->msgctxt))
77    return false;
78
79  /* Likewise for the prev_* fields.  */
80  if (mp->prev_msgctxt != NULL && !is_ascii_string (mp->prev_msgctxt))
81    return false;
82  if (mp->prev_msgid != NULL && !is_ascii_string (mp->prev_msgid))
83    return false;
84  if (mp->prev_msgid_plural != NULL && !is_ascii_string (mp->prev_msgid_plural))
85    return false;
86
87  return true;
88}
89
90bool
91is_ascii_message_list (message_list_ty *mlp)
92{
93  size_t j;
94
95  for (j = 0; j < mlp->nitems; j++)
96    if (!is_ascii_message (mlp->item[j]))
97      return false;
98
99  return true;
100}
101
102bool
103is_ascii_msgdomain_list (msgdomain_list_ty *mdlp)
104{
105  size_t k;
106
107  for (k = 0; k < mdlp->nitems; k++)
108    if (!is_ascii_message_list (mdlp->item[k]->messages))
109      return false;
110
111  return true;
112}
113