~ubuntu-branches/ubuntu/oneiric/imagemagick/oneiric-updates

« back to all changes in this revision

Viewing changes to magick/token-private.h

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-06-15 11:05:28 UTC
  • mfrom: (6.2.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110615110528-08jgo07a4846xh8d
Tags: 8:6.6.0.4-3ubuntu1
* Resynchronise with Debian (LP: #797595).  Remaining changes:
  - Make ufraw-batch (universe) a suggestion instead of a recommendation.
  - Make debian/rules install target depend on check; they cannot reliably
    be run in parallel.
  - Don't set MAKEFLAGS in debian/rules; just pass it to the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
typedef struct
32
32
{
33
 
  int
 
33
  long
34
34
    code_mask,
35
35
    code_value,
36
36
    utf_mask,
48
48
    { 0xFE, 0xFC, 0x7ffffff, 0x4000000 },  /* 6 byte sequence */
49
49
  };
50
50
 
51
 
static inline unsigned char *ConvertLatin1ToUTF8(const unsigned char *content)
52
 
{
53
 
  register const unsigned char
54
 
    *p;
55
 
 
56
 
  register unsigned char
57
 
    *q;
58
 
 
59
 
  size_t
60
 
    length;
61
 
 
62
 
  unsigned char
63
 
    *utf8;
64
 
 
65
 
  unsigned int
66
 
    c;
67
 
 
68
 
  length=0;
69
 
  for (p=content; *p != '\0'; p++)
70
 
    length+=(*p & 0x80) != 0 ? 2 : 1;
71
 
  utf8=(unsigned char *) NULL;
72
 
  if (~length >= 1)
73
 
    utf8=(unsigned char *) AcquireQuantumMemory(length+1UL,sizeof(*utf8));
74
 
  if (utf8 == (unsigned char *) NULL)
75
 
    return((unsigned char *) NULL);
76
 
  q=utf8;
77
 
  for (p=content; *p != '\0'; p++)
78
 
  {
79
 
    c=(*p);
80
 
    if ((c & 0x80) == 0)
81
 
      *q++=c;
82
 
    else
83
 
      {
84
 
        *q++=0xc0 | ((c >> 6) & 0x3f);
85
 
        *q++=0x80 | (c & 0x3f);
86
 
      }
87
 
  }
88
 
  *q='\0';
89
 
  return(utf8);
90
 
}
91
 
 
92
 
static inline int GetNextUTFCode(const char *text,unsigned int *octets)
93
 
{
94
 
  int
 
51
static inline long GetNextUTFCode(const char *text,size_t *octets)
 
52
{
 
53
  long
95
54
    code;
96
55
 
97
 
  register ssize_t
 
56
  register long
98
57
    i;
99
58
 
100
 
  register int
 
59
  register long
101
60
    c,
102
61
    unicode;
103
62
 
104
 
  *octets=1;
 
63
  *octets=0;
105
64
  if (text == (const char *) NULL)
106
65
    {
107
66
      errno=EINVAL;
108
67
      return(-1);
109
68
    }
110
 
  code=(int) (*text++) & 0xff;
 
69
  code=(long) (*text++) & 0xff;
111
70
  unicode=code;
112
71
  for (i=0; i < MaxMultibyteCodes; i++)
113
72
  {
119
78
            errno=EILSEQ;
120
79
            return(-1);
121
80
          }
122
 
        *octets=(unsigned int) (i+1);
 
81
        *octets=(size_t) (i+1);
123
82
        return(unicode);
124
83
      }
125
 
    c=(int) (*text++ ^ 0x80) & 0xff;
 
84
    c=(long) (*text++ ^ 0x80) & 0xff;
126
85
    if ((c & 0xc0) != 0)
127
86
      {
128
87
        errno=EILSEQ;
134
93
  return(-1);
135
94
}
136
95
 
137
 
static inline int GetUTFCode(const char *text)
 
96
static long GetUTFCode(const char *text)
138
97
{
139
 
  unsigned int
 
98
  size_t
140
99
    octets;
141
100
 
142
101
  return(GetNextUTFCode(text,&octets));
143
102
}
144
103
 
145
 
static inline unsigned int GetUTFOctets(const char *text)
 
104
static size_t GetUTFOctets(const char *text)
146
105
{
147
 
  unsigned int
 
106
  size_t
148
107
    octets;
149
108
 
150
109
  (void) GetNextUTFCode(text,&octets);
151
110
  return(octets);
152
111
}
153
112
 
154
 
static inline MagickBooleanType IsUTFSpace(int code)
 
113
static inline MagickBooleanType IsUTFSpace(long code)
155
114
{
156
115
  if (((code >= 0x0009) && (code <= 0x000d)) || (code == 0x0020) ||
157
116
      (code == 0x0085) || (code == 0x00a0) || (code == 0x1680) ||
162
121
  return(MagickFalse);
163
122
}
164
123
 
165
 
static inline MagickBooleanType IsUTFValid(int code)
 
124
static inline MagickBooleanType IsUTFValid(long code)
166
125
{
167
 
  int
 
126
  long
168
127
    mask;
169
128
 
170
 
  mask=(int) 0x7fffffff;
 
129
  mask=(long) 0x7fffffff;
171
130
  if (((code & ~mask) != 0) && ((code < 0xd800) || (code > 0xdfff)) &&
172
131
      (code != 0xfffe) && (code != 0xffff))
173
132
    return(MagickFalse);
174
133
  return(MagickTrue);
175
134
}
176
135
 
177
 
static inline MagickBooleanType IsUTFAscii(int code)
 
136
static inline MagickBooleanType IsUTFAscii(long code)
178
137
{
179
 
  int
 
138
  long
180
139
    mask;
181
140
 
182
 
  mask=(int) 0x7f;
 
141
  mask=(long) 0x7f;
183
142
  if ((code & ~mask) != 0)
184
143
    return(MagickFalse);
185
144
  return(MagickTrue);