~ubuntu-branches/ubuntu/breezy/gettext/breezy

« back to all changes in this revision

Viewing changes to gettext-tools/src/msgl-ascii.c

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2004-03-14 17:40:02 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314174002-p1ad5ldve1hqzhye
Tags: 0.14.1-2
* Added libexpat1-dev to Build-Depends, for glade support.
* Added libc0.1-dev to Build-Depends, for GNU/kFreeBSD.
* Removed special-casing of knetbsd-gnu in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Message list test for ASCII character set.
 
2
   Copyright (C) 2001-2002 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 2, or (at your option)
 
8
   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, write to the Free Software Foundation,
 
17
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
18
 
 
19
 
 
20
#ifdef HAVE_CONFIG_H
 
21
# include "config.h"
 
22
#endif
 
23
 
 
24
/* Specification.  */
 
25
#include "msgl-ascii.h"
 
26
 
 
27
#include "c-ctype.h"
 
28
 
 
29
 
 
30
/* This file's structure parallels msgl-iconv.c.  */
 
31
 
 
32
 
 
33
bool
 
34
is_ascii_string (const char *string)
 
35
{
 
36
  for (; *string; string++)
 
37
    if (!c_isascii ((unsigned char) *string))
 
38
      return false;
 
39
  return true;
 
40
}
 
41
 
 
42
bool
 
43
is_ascii_string_list (string_list_ty *slp)
 
44
{
 
45
  size_t i;
 
46
 
 
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;
 
52
}
 
53
 
 
54
bool
 
55
is_ascii_message (message_ty *mp)
 
56
{
 
57
  const char *p = mp->msgstr;
 
58
  const char *p_end = p + mp->msgstr_len;
 
59
 
 
60
  for (; p < p_end; p++)
 
61
    if (!c_isascii ((unsigned char) *p))
 
62
      return false;
 
63
 
 
64
  if (!is_ascii_string_list (mp->comment))
 
65
    return false;
 
66
  if (!is_ascii_string_list (mp->comment_dot))
 
67
    return false;
 
68
 
 
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;
 
75
 
 
76
  return true;
 
77
}
 
78
 
 
79
bool
 
80
is_ascii_message_list (message_list_ty *mlp)
 
81
{
 
82
  size_t j;
 
83
 
 
84
  for (j = 0; j < mlp->nitems; j++)
 
85
    if (!is_ascii_message (mlp->item[j]))
 
86
      return false;
 
87
 
 
88
  return true;
 
89
}