@@ -44,14 +44,14 @@ FILE_RCSID("@(#)$File: encoding.c,v 1.20 2019/04/15 16:48:41 christos Exp $")
44
44
#include <stdlib.h>
45
45
46
46
47
- private int looks_ascii (const unsigned char * , size_t , unichar * , size_t * );
48
- private int looks_utf8_with_BOM (const unsigned char * , size_t , unichar * ,
47
+ private int looks_ascii (const unsigned char * , size_t , unicodechar * , size_t * );
48
+ private int looks_utf8_with_BOM (const unsigned char * , size_t , unicodechar * ,
49
49
size_t * );
50
- private int looks_utf7 (const unsigned char * , size_t , unichar * , size_t * );
51
- private int looks_ucs16 (const unsigned char * , size_t , unichar * , size_t * );
52
- private int looks_ucs32 (const unsigned char * , size_t , unichar * , size_t * );
53
- private int looks_latin1 (const unsigned char * , size_t , unichar * , size_t * );
54
- private int looks_extended (const unsigned char * , size_t , unichar * , size_t * );
50
+ private int looks_utf7 (const unsigned char * , size_t , unicodechar * , size_t * );
51
+ private int looks_ucs16 (const unsigned char * , size_t , unicodechar * , size_t * );
52
+ private int looks_ucs32 (const unsigned char * , size_t , unicodechar * , size_t * );
53
+ private int looks_latin1 (const unsigned char * , size_t , unicodechar * , size_t * );
54
+ private int looks_extended (const unsigned char * , size_t , unicodechar * , size_t * );
55
55
private void from_ebcdic (const unsigned char * , size_t , unsigned char * );
56
56
57
57
#ifdef DEBUG_ENCODING
@@ -63,19 +63,19 @@ private void from_ebcdic(const unsigned char *, size_t, unsigned char *);
63
63
/*
64
64
* Try to determine whether text is in some character code we can
65
65
* identify. Each of these tests, if it succeeds, will leave
66
- * the text converted into one-unichar -per-character Unicode in
66
+ * the text converted into one-unicodechar -per-character Unicode in
67
67
* ubuf, and the number of characters converted in ulen.
68
68
*/
69
69
protected int
70
- file_encoding (struct magic_set * ms , const struct buffer * b , unichar * * ubuf ,
70
+ file_encoding (struct magic_set * ms , const struct buffer * b , unicodechar * * ubuf ,
71
71
size_t * ulen , const char * * code , const char * * code_mime , const char * * type )
72
72
{
73
73
const unsigned char * buf = CAST (const unsigned char * , b -> fbuf );
74
74
size_t nbytes = b -> flen ;
75
75
size_t mlen ;
76
76
int rv = 1 , ucs_type ;
77
77
unsigned char * nbuf = NULL ;
78
- unichar * udefbuf ;
78
+ unicodechar * udefbuf ;
79
79
size_t udeflen ;
80
80
81
81
if (ubuf == NULL )
@@ -89,7 +89,7 @@ file_encoding(struct magic_set *ms, const struct buffer *b, unichar **ubuf,
89
89
* code_mime = "binary" ;
90
90
91
91
mlen = (nbytes + 1 ) * sizeof ((* ubuf )[0 ]);
92
- if ((* ubuf = CAST (unichar * , ecalloc (CAST (size_t , 1 ), mlen ))) == NULL ) {
92
+ if ((* ubuf = CAST (unicodechar * , ecalloc (CAST (size_t , 1 ), mlen ))) == NULL ) {
93
93
file_oomem (ms , mlen );
94
94
goto done ;
95
95
}
@@ -251,7 +251,7 @@ private char text_chars[256] = {
251
251
};
252
252
253
253
private int
254
- looks_ascii (const unsigned char * buf , size_t nbytes , unichar * ubuf ,
254
+ looks_ascii (const unsigned char * buf , size_t nbytes , unicodechar * ubuf ,
255
255
size_t * ulen )
256
256
{
257
257
size_t i ;
@@ -271,7 +271,7 @@ looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf,
271
271
}
272
272
273
273
private int
274
- looks_latin1 (const unsigned char * buf , size_t nbytes , unichar * ubuf , size_t * ulen )
274
+ looks_latin1 (const unsigned char * buf , size_t nbytes , unicodechar * ubuf , size_t * ulen )
275
275
{
276
276
size_t i ;
277
277
@@ -290,7 +290,7 @@ looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ule
290
290
}
291
291
292
292
private int
293
- looks_extended (const unsigned char * buf , size_t nbytes , unichar * ubuf ,
293
+ looks_extended (const unsigned char * buf , size_t nbytes , unicodechar * ubuf ,
294
294
size_t * ulen )
295
295
{
296
296
size_t i ;
@@ -321,11 +321,11 @@ looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf,
321
321
* ubuf must be big enough!
322
322
*/
323
323
protected int
324
- file_looks_utf8 (const unsigned char * buf , size_t nbytes , unichar * ubuf , size_t * ulen )
324
+ file_looks_utf8 (const unsigned char * buf , size_t nbytes , unicodechar * ubuf , size_t * ulen )
325
325
{
326
326
size_t i ;
327
327
int n ;
328
- unichar c ;
328
+ unicodechar c ;
329
329
int gotone = 0 , ctrl = 0 ;
330
330
331
331
if (ubuf )
@@ -392,7 +392,7 @@ file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *
392
392
* rest of the text.
393
393
*/
394
394
private int
395
- looks_utf8_with_BOM (const unsigned char * buf , size_t nbytes , unichar * ubuf ,
395
+ looks_utf8_with_BOM (const unsigned char * buf , size_t nbytes , unicodechar * ubuf ,
396
396
size_t * ulen )
397
397
{
398
398
if (nbytes > 3 && buf [0 ] == 0xef && buf [1 ] == 0xbb && buf [2 ] == 0xbf )
@@ -402,7 +402,7 @@ looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf,
402
402
}
403
403
404
404
private int
405
- looks_utf7 (const unsigned char * buf , size_t nbytes , unichar * ubuf , size_t * ulen )
405
+ looks_utf7 (const unsigned char * buf , size_t nbytes , unicodechar * ubuf , size_t * ulen )
406
406
{
407
407
if (nbytes > 4 && buf [0 ] == '+' && buf [1 ] == '/' && buf [2 ] == 'v' )
408
408
switch (buf [3 ]) {
@@ -421,7 +421,7 @@ looks_utf7(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
421
421
}
422
422
423
423
private int
424
- looks_ucs16 (const unsigned char * bf , size_t nbytes , unichar * ubf ,
424
+ looks_ucs16 (const unsigned char * bf , size_t nbytes , unicodechar * ubf ,
425
425
size_t * ulen )
426
426
{
427
427
int bigend ;
@@ -444,10 +444,10 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf,
444
444
445
445
if (bigend )
446
446
ubf [(* ulen )++ ] = bf [i + 1 ]
447
- | (CAST (unichar , bf [i ]) << 8 );
447
+ | (CAST (unicodechar , bf [i ]) << 8 );
448
448
else
449
449
ubf [(* ulen )++ ] = bf [i ]
450
- | (CAST (unichar , bf [i + 1 ]) << 8 );
450
+ | (CAST (unicodechar , bf [i + 1 ]) << 8 );
451
451
452
452
if (ubf [* ulen - 1 ] == 0xfffe )
453
453
return 0 ;
@@ -460,7 +460,7 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, unichar *ubf,
460
460
}
461
461
462
462
private int
463
- looks_ucs32 (const unsigned char * bf , size_t nbytes , unichar * ubf ,
463
+ looks_ucs32 (const unsigned char * bf , size_t nbytes , unicodechar * ubf ,
464
464
size_t * ulen )
465
465
{
466
466
int bigend ;
@@ -482,15 +482,15 @@ looks_ucs32(const unsigned char *bf, size_t nbytes, unichar *ubf,
482
482
/* XXX fix to properly handle chars > 65536 */
483
483
484
484
if (bigend )
485
- ubf [(* ulen )++ ] = CAST (unichar , bf [i + 3 ])
486
- | (CAST (unichar , bf [i + 2 ]) << 8 )
487
- | (CAST (unichar , bf [i + 1 ]) << 16 )
488
- | (CAST (unichar , bf [i ]) << 24 );
485
+ ubf [(* ulen )++ ] = CAST (unicodechar , bf [i + 3 ])
486
+ | (CAST (unicodechar , bf [i + 2 ]) << 8 )
487
+ | (CAST (unicodechar , bf [i + 1 ]) << 16 )
488
+ | (CAST (unicodechar , bf [i ]) << 24 );
489
489
else
490
- ubf [(* ulen )++ ] = CAST (unichar , bf [i + 0 ])
491
- | (CAST (unichar , bf [i + 1 ]) << 8 )
492
- | (CAST (unichar , bf [i + 2 ]) << 16 )
493
- | (CAST (unichar , bf [i + 3 ]) << 24 );
490
+ ubf [(* ulen )++ ] = CAST (unicodechar , bf [i + 0 ])
491
+ | (CAST (unicodechar , bf [i + 1 ]) << 8 )
492
+ | (CAST (unicodechar , bf [i + 2 ]) << 16 )
493
+ | (CAST (unicodechar , bf [i + 3 ]) << 24 );
494
494
495
495
if (ubf [* ulen - 1 ] == 0xfffe )
496
496
return 0 ;
0 commit comments