Fix liblunicode issues on systems where sizeof(long) > 4.

Code still lacks portability (alignment/padding, required ac_uint2/4 types)
Should resolve ITS#2632, ITS#2660, ITS#2784
This commit is contained in:
Kurt Zeilenga 2003-12-07 08:29:07 +00:00
parent 0df311ed00
commit 4383fcd566
2 changed files with 217 additions and 217 deletions

View file

@ -65,7 +65,7 @@ typedef struct {
/*
* A simple array of 32-bit masks for lookup.
*/
static unsigned long masks32[32] = {
static ac_uint4 masks32[32] = {
0x00000001UL, 0x00000002UL, 0x00000004UL, 0x00000008UL,
0x00000010UL, 0x00000020UL, 0x00000040UL, 0x00000080UL,
0x00000100UL, 0x00000200UL, 0x00000400UL, 0x00000800UL,
@ -117,9 +117,9 @@ _ucopenfile(char *paths, char *filename, char *mode)
*
**************************************************************************/
static unsigned long _ucprop_size;
static unsigned short *_ucprop_offsets;
static unsigned long *_ucprop_ranges;
static ac_uint4 _ucprop_size;
static ac_uint2 *_ucprop_offsets;
static ac_uint4 *_ucprop_ranges;
/*
* Return -1 on error, 0 if okay
@ -128,7 +128,7 @@ static int
_ucprop_load(char *paths, int reload)
{
FILE *in;
unsigned long size, i;
ac_uint4 size, i;
_ucheader_t hdr;
if (_ucprop_size > 0) {
@ -169,7 +169,7 @@ _ucprop_load(char *paths, int reload)
/*
* Allocate all the storage needed for the lookup table.
*/
_ucprop_offsets = (unsigned short *) malloc(hdr.size.bytes);
_ucprop_offsets = (ac_uint2 *) malloc(hdr.size.bytes);
/*
* Calculate the offset into the storage for the ranges. The offsets
@ -177,15 +177,15 @@ _ucprop_load(char *paths, int reload)
* the header count field. This means the offset to the ranges must be
* calculated after aligning the count to a 4-byte boundary.
*/
if ((size = ((hdr.cnt + 1) * sizeof(unsigned short))) & 3)
if ((size = ((hdr.cnt + 1) * sizeof(ac_uint2))) & 3)
size += 4 - (size & 3);
size >>= 1;
_ucprop_ranges = (unsigned long *) (_ucprop_offsets + size);
_ucprop_ranges = (ac_uint4 *) (_ucprop_offsets + size);
/*
* Load the offset array.
*/
fread((char *) _ucprop_offsets, sizeof(unsigned short), size, in);
fread((char *) _ucprop_offsets, sizeof(ac_uint2), size, in);
/*
* Do an endian swap if necessary. Don't forget there is an extra node on
@ -200,7 +200,7 @@ _ucprop_load(char *paths, int reload)
* Load the ranges. The number of elements is in the last array position
* of the offsets.
*/
fread((char *) _ucprop_ranges, sizeof(unsigned long),
fread((char *) _ucprop_ranges, sizeof(ac_uint4),
_ucprop_offsets[_ucprop_size], in);
fclose(in);
@ -230,7 +230,7 @@ _ucprop_unload(void)
}
static int
_ucprop_lookup(unsigned long code, unsigned long n)
_ucprop_lookup(ac_uint4 code, ac_uint4 n)
{
long l, r, m;
@ -272,9 +272,9 @@ _ucprop_lookup(unsigned long code, unsigned long n)
}
int
ucisprop(unsigned long code, unsigned long mask1, unsigned long mask2)
ucisprop(ac_uint4 code, ac_uint4 mask1, ac_uint4 mask2)
{
unsigned long i;
ac_uint4 i;
if (mask1 == 0 && mask2 == 0)
return 0;
@ -298,9 +298,9 @@ ucisprop(unsigned long code, unsigned long mask1, unsigned long mask2)
*
**************************************************************************/
static unsigned long _uccase_size;
static unsigned short _uccase_len[2];
static unsigned long *_uccase_map;
static ac_uint4 _uccase_size;
static ac_uint2 _uccase_len[2];
static ac_uint4 *_uccase_map;
/*
* Return -1 on error, 0 if okay
@ -309,7 +309,7 @@ static int
_uccase_load(char *paths, int reload)
{
FILE *in;
unsigned long i;
ac_uint4 i;
_ucheader_t hdr;
if (_uccase_size > 0) {
@ -345,13 +345,13 @@ _uccase_load(char *paths, int reload)
_uccase_len[0] = hdr.size.len[0] * 3;
_uccase_len[1] = hdr.size.len[1] * 3;
_uccase_map = (unsigned long *)
malloc(_uccase_size * sizeof(unsigned long));
_uccase_map = (ac_uint4 *)
malloc(_uccase_size * sizeof(ac_uint4));
/*
* Load the case mapping table.
*/
fread((char *) _uccase_map, sizeof(unsigned long), _uccase_size, in);
fread((char *) _uccase_map, sizeof(ac_uint4), _uccase_size, in);
/*
* Do an endian swap if necessary.
@ -374,8 +374,8 @@ _uccase_unload(void)
_uccase_size = 0;
}
static unsigned long
_uccase_lookup(unsigned long code, long l, long r, int field)
static ac_uint4
_uccase_lookup(ac_uint4 code, long l, long r, int field)
{
long m;
@ -400,8 +400,8 @@ _uccase_lookup(unsigned long code, long l, long r, int field)
return code;
}
unsigned long
uctoupper(unsigned long code)
ac_uint4
uctoupper(ac_uint4 code)
{
int field;
long l, r;
@ -427,8 +427,8 @@ uctoupper(unsigned long code)
return _uccase_lookup(code, l, r, field);
}
unsigned long
uctolower(unsigned long code)
ac_uint4
uctolower(ac_uint4 code)
{
int field;
long l, r;
@ -454,8 +454,8 @@ uctolower(unsigned long code)
return _uccase_lookup(code, l, r, field);
}
unsigned long
uctotitle(unsigned long code)
ac_uint4
uctotitle(ac_uint4 code)
{
int field;
long l, r;
@ -490,8 +490,8 @@ uctotitle(unsigned long code)
*
**************************************************************************/
static unsigned long _uccomp_size;
static unsigned long *_uccomp_data;
static ac_uint4 _uccomp_size;
static ac_uint4 *_uccomp_data;
/*
* Return -1 on error, 0 if okay
@ -500,7 +500,7 @@ static int
_uccomp_load(char *paths, int reload)
{
FILE *in;
unsigned long size, i;
ac_uint4 size, i;
_ucheader_t hdr;
if (_uccomp_size > 0) {
@ -528,13 +528,13 @@ _uccomp_load(char *paths, int reload)
}
_uccomp_size = hdr.cnt;
_uccomp_data = (unsigned long *) malloc(hdr.size.bytes);
_uccomp_data = (ac_uint4 *) malloc(hdr.size.bytes);
/*
* Read the composition data in.
*/
size = hdr.size.bytes / sizeof(unsigned long);
fread((char *) _uccomp_data, sizeof(unsigned long), size, in);
size = hdr.size.bytes / sizeof(ac_uint4);
fread((char *) _uccomp_data, sizeof(ac_uint4), size, in);
/*
* Do an endian swap if necessary.
@ -568,7 +568,7 @@ _uccomp_unload(void)
}
int
uccomp(unsigned long node1, unsigned long node2, unsigned long *comp)
uccomp(ac_uint4 node1, ac_uint4 node2, ac_uint4 *comp)
{
int l, r, m;
@ -595,7 +595,7 @@ uccomp(unsigned long node1, unsigned long node2, unsigned long *comp)
}
int
uccomp_hangul(unsigned long *str, int len)
uccomp_hangul(ac_uint4 *str, int len)
{
const int SBase = 0xAC00, LBase = 0x1100,
VBase = 0x1161, TBase = 0x11A7,
@ -604,7 +604,7 @@ uccomp_hangul(unsigned long *str, int len)
SCount = LCount * NCount; /* 11172 */
int i, rlen;
unsigned long ch, last, lindex, sindex;
ac_uint4 ch, last, lindex, sindex;
last = str[0];
rlen = 1;
@ -613,9 +613,9 @@ uccomp_hangul(unsigned long *str, int len)
/* check if two current characters are L and V */
lindex = last - LBase;
if (lindex < (unsigned long) LCount) {
unsigned long vindex = ch - VBase;
if (vindex < (unsigned long) VCount) {
if (lindex < (ac_uint4) LCount) {
ac_uint4 vindex = ch - VBase;
if (vindex < (ac_uint4) VCount) {
/* make syllable of form LV */
last = SBase + (lindex * VCount + vindex) * TCount;
str[rlen-1] = last; /* reset last */
@ -625,11 +625,11 @@ uccomp_hangul(unsigned long *str, int len)
/* check if two current characters are LV and T */
sindex = last - SBase;
if (sindex < (unsigned long) SCount
if (sindex < (ac_uint4) SCount
&& (sindex % TCount) == 0)
{
unsigned long tindex = ch - TBase;
if (tindex <= (unsigned long) TCount) {
ac_uint4 tindex = ch - TBase;
if (tindex <= (ac_uint4) TCount) {
/* make syllable of form LVT */
last += tindex;
str[rlen-1] = last; /* reset last */
@ -646,10 +646,10 @@ uccomp_hangul(unsigned long *str, int len)
}
int
uccanoncomp(unsigned long *str, int len)
uccanoncomp(ac_uint4 *str, int len)
{
int i, stpos, copos;
unsigned long cl, prevcl, st, ch, co;
ac_uint4 cl, prevcl, st, ch, co;
st = str[0];
stpos = 0;
@ -680,13 +680,13 @@ uccanoncomp(unsigned long *str, int len)
*
**************************************************************************/
static unsigned long _ucdcmp_size;
static unsigned long *_ucdcmp_nodes;
static unsigned long *_ucdcmp_decomp;
static ac_uint4 _ucdcmp_size;
static ac_uint4 *_ucdcmp_nodes;
static ac_uint4 *_ucdcmp_decomp;
static unsigned long _uckdcmp_size;
static unsigned long *_uckdcmp_nodes;
static unsigned long *_uckdcmp_decomp;
static ac_uint4 _uckdcmp_size;
static ac_uint4 *_uckdcmp_nodes;
static ac_uint4 *_uckdcmp_decomp;
/*
* Return -1 on error, 0 if okay
@ -695,7 +695,7 @@ static int
_ucdcmp_load(char *paths, int reload)
{
FILE *in;
unsigned long size, i;
ac_uint4 size, i;
_ucheader_t hdr;
if (_ucdcmp_size > 0) {
@ -723,14 +723,14 @@ _ucdcmp_load(char *paths, int reload)
}
_ucdcmp_size = hdr.cnt << 1;
_ucdcmp_nodes = (unsigned long *) malloc(hdr.size.bytes);
_ucdcmp_nodes = (ac_uint4 *) malloc(hdr.size.bytes);
_ucdcmp_decomp = _ucdcmp_nodes + (_ucdcmp_size + 1);
/*
* Read the decomposition data in.
*/
size = hdr.size.bytes / sizeof(unsigned long);
fread((char *) _ucdcmp_nodes, sizeof(unsigned long), size, in);
size = hdr.size.bytes / sizeof(ac_uint4);
fread((char *) _ucdcmp_nodes, sizeof(ac_uint4), size, in);
/*
* Do an endian swap if necessary.
@ -750,7 +750,7 @@ static int
_uckdcmp_load(char *paths, int reload)
{
FILE *in;
unsigned long size, i;
ac_uint4 size, i;
_ucheader_t hdr;
if (_uckdcmp_size > 0) {
@ -778,14 +778,14 @@ _uckdcmp_load(char *paths, int reload)
}
_uckdcmp_size = hdr.cnt << 1;
_uckdcmp_nodes = (unsigned long *) malloc(hdr.size.bytes);
_uckdcmp_nodes = (ac_uint4 *) malloc(hdr.size.bytes);
_uckdcmp_decomp = _uckdcmp_nodes + (_uckdcmp_size + 1);
/*
* Read the decomposition data in.
*/
size = hdr.size.bytes / sizeof(unsigned long);
fread((char *) _uckdcmp_nodes, sizeof(unsigned long), size, in);
size = hdr.size.bytes / sizeof(ac_uint4);
fread((char *) _uckdcmp_nodes, sizeof(ac_uint4), size, in);
/*
* Do an endian swap if necessary.
@ -827,7 +827,7 @@ _uckdcmp_unload(void)
}
int
ucdecomp(unsigned long code, unsigned long *num, unsigned long **decomp)
ucdecomp(ac_uint4 code, ac_uint4 *num, ac_uint4 **decomp)
{
long l, r, m;
@ -859,7 +859,7 @@ ucdecomp(unsigned long code, unsigned long *num, unsigned long **decomp)
}
int
uckdecomp(unsigned long code, unsigned long *num, unsigned long **decomp)
uckdecomp(ac_uint4 code, ac_uint4 *num, ac_uint4 **decomp)
{
long l, r, m;
@ -891,15 +891,15 @@ uckdecomp(unsigned long code, unsigned long *num, unsigned long **decomp)
}
int
ucdecomp_hangul(unsigned long code, unsigned long *num, unsigned long decomp[])
ucdecomp_hangul(ac_uint4 code, ac_uint4 *num, ac_uint4 decomp[])
{
if (!ucishangul(code))
return 0;
code -= 0xac00;
decomp[0] = 0x1100 + (unsigned long) (code / 588);
decomp[1] = 0x1161 + (unsigned long) ((code % 588) / 28);
decomp[2] = 0x11a7 + (unsigned long) (code % 28);
decomp[0] = 0x1100 + (ac_uint4) (code / 588);
decomp[1] = 0x1161 + (ac_uint4) ((code % 588) / 28);
decomp[2] = 0x11a7 + (ac_uint4) (code % 28);
*num = (decomp[2] != 0x11a7) ? 3 : 2;
return 1;
@ -907,15 +907,15 @@ ucdecomp_hangul(unsigned long code, unsigned long *num, unsigned long decomp[])
/* mode == 0 for canonical, mode == 1 for compatibility */
static int
uccanoncompatdecomp(const unsigned long *in, int inlen,
unsigned long **out, int *outlen, short mode, void *ctx)
uccanoncompatdecomp(const ac_uint4 *in, int inlen,
ac_uint4 **out, int *outlen, short mode, void *ctx)
{
int l, size;
unsigned i, j, k;
unsigned long num, class, *decomp, hangdecomp[3];
ac_uint4 num, class, *decomp, hangdecomp[3];
size = inlen * 2;
*out = (unsigned long *) ber_memalloc_x(size * sizeof(**out), ctx);
*out = (ac_uint4 *) ber_memalloc_x(size * sizeof(**out), ctx);
if (*out == NULL)
return *outlen = -1;
@ -924,7 +924,7 @@ uccanoncompatdecomp(const unsigned long *in, int inlen,
if (mode ? uckdecomp(in[j], &num, &decomp) : ucdecomp(in[j], &num, &decomp)) {
if ( size - i < num) {
size = inlen + i - j + num - 1;
*out = (unsigned long *) ber_memrealloc_x(*out, size * sizeof(**out), ctx );
*out = (ac_uint4 *) ber_memrealloc_x(*out, size * sizeof(**out), ctx );
if (*out == NULL)
return *outlen = -1;
}
@ -944,7 +944,7 @@ uccanoncompatdecomp(const unsigned long *in, int inlen,
} else if (ucdecomp_hangul(in[j], &num, hangdecomp)) {
if (size - i < num) {
size = inlen + i - j + num - 1;
*out = (unsigned long *) ber_memrealloc_x(*out, size * sizeof(**out), ctx);
*out = (ac_uint4 *) ber_memrealloc_x(*out, size * sizeof(**out), ctx);
if (*out == NULL)
return *outlen = -1;
}
@ -955,7 +955,7 @@ uccanoncompatdecomp(const unsigned long *in, int inlen,
} else {
if (size - i < 1) {
size = inlen + i - j;
*out = (unsigned long *) ber_memrealloc_x(*out, size * sizeof(**out), ctx);
*out = (ac_uint4 *) ber_memrealloc_x(*out, size * sizeof(**out), ctx);
if (*out == NULL)
return *outlen = -1;
}
@ -976,15 +976,15 @@ uccanoncompatdecomp(const unsigned long *in, int inlen,
}
int
uccanondecomp(const unsigned long *in, int inlen,
unsigned long **out, int *outlen, void *ctx)
uccanondecomp(const ac_uint4 *in, int inlen,
ac_uint4 **out, int *outlen, void *ctx)
{
return uccanoncompatdecomp(in, inlen, out, outlen, 0, ctx);
}
int
uccompatdecomp(const unsigned long *in, int inlen,
unsigned long **out, int *outlen, void *ctx)
uccompatdecomp(const ac_uint4 *in, int inlen,
ac_uint4 **out, int *outlen, void *ctx)
{
return uccanoncompatdecomp(in, inlen, out, outlen, 1, ctx);
}
@ -995,8 +995,8 @@ uccompatdecomp(const unsigned long *in, int inlen,
*
**************************************************************************/
static unsigned long _uccmcl_size;
static unsigned long *_uccmcl_nodes;
static ac_uint4 _uccmcl_size;
static ac_uint4 *_uccmcl_nodes;
/*
* Return -1 on error, 0 if okay
@ -1005,7 +1005,7 @@ static int
_uccmcl_load(char *paths, int reload)
{
FILE *in;
unsigned long i;
ac_uint4 i;
_ucheader_t hdr;
if (_uccmcl_size > 0) {
@ -1033,12 +1033,12 @@ _uccmcl_load(char *paths, int reload)
}
_uccmcl_size = hdr.cnt * 3;
_uccmcl_nodes = (unsigned long *) malloc(hdr.size.bytes);
_uccmcl_nodes = (ac_uint4 *) malloc(hdr.size.bytes);
/*
* Read the combining classes in.
*/
fread((char *) _uccmcl_nodes, sizeof(unsigned long), _uccmcl_size, in);
fread((char *) _uccmcl_nodes, sizeof(ac_uint4), _uccmcl_size, in);
/*
* Do an endian swap if necessary.
@ -1061,8 +1061,8 @@ _uccmcl_unload(void)
_uccmcl_size = 0;
}
unsigned long
uccombining_class(unsigned long code)
ac_uint4
uccombining_class(ac_uint4 code)
{
long l, r, m;
@ -1088,8 +1088,8 @@ uccombining_class(unsigned long code)
*
**************************************************************************/
static unsigned long *_ucnum_nodes;
static unsigned long _ucnum_size;
static ac_uint4 *_ucnum_nodes;
static ac_uint4 _ucnum_size;
static short *_ucnum_vals;
/*
@ -1099,7 +1099,7 @@ static int
_ucnumb_load(char *paths, int reload)
{
FILE *in;
unsigned long size, i;
ac_uint4 size, i;
_ucheader_t hdr;
if (_ucnum_size > 0) {
@ -1127,7 +1127,7 @@ _ucnumb_load(char *paths, int reload)
}
_ucnum_size = hdr.cnt;
_ucnum_nodes = (unsigned long *) malloc(hdr.size.bytes);
_ucnum_nodes = (ac_uint4 *) malloc(hdr.size.bytes);
_ucnum_vals = (short *) (_ucnum_nodes + _ucnum_size);
/*
@ -1146,7 +1146,7 @@ _ucnumb_load(char *paths, int reload)
* Determine the number of values that have to be adjusted.
*/
size = (hdr.size.bytes -
(_ucnum_size * (sizeof(unsigned long) << 1))) /
(_ucnum_size * (sizeof(ac_uint4) << 1))) /
sizeof(short);
for (i = 0; i < size; i++)
@ -1167,7 +1167,7 @@ _ucnumb_unload(void)
}
int
ucnumber_lookup(unsigned long code, struct ucnumber *num)
ucnumber_lookup(ac_uint4 code, struct ucnumber *num)
{
long l, r, m;
short *vp;
@ -1196,7 +1196,7 @@ ucnumber_lookup(unsigned long code, struct ucnumber *num)
}
int
ucdigit_lookup(unsigned long code, int *digit)
ucdigit_lookup(ac_uint4 code, int *digit)
{
long l, r, m;
short *vp;
@ -1227,7 +1227,7 @@ ucdigit_lookup(unsigned long code, int *digit)
}
struct ucnumber
ucgetnumber(unsigned long code)
ucgetnumber(ac_uint4 code)
{
struct ucnumber num;
@ -1244,7 +1244,7 @@ ucgetnumber(unsigned long code)
}
int
ucgetdigit(unsigned long code)
ucgetdigit(ac_uint4 code)
{
int dig;
@ -1343,7 +1343,7 @@ void
main(void)
{
int dig;
unsigned long i, lo, *dec;
ac_uint4 i, lo, *dec;
struct ucnumber num;
ucdata_setup(".");

View file

@ -55,7 +55,7 @@
* A header written to the output file with the byte-order-mark and the number
* of property nodes.
*/
static unsigned short hdr[2] = {0xfeff, 0};
static ac_uint2 hdr[2] = {0xfeff, 0};
#define NUMPROPS 50
#define NEEDPROPS (NUMPROPS + (4 - (NUMPROPS & 3)))
@ -92,9 +92,9 @@ static _prop_t props[NUMPROPS] = {
};
typedef struct {
unsigned long *ranges;
unsigned short used;
unsigned short size;
ac_uint4 *ranges;
ac_uint2 used;
ac_uint2 size;
} _ranges_t;
static _ranges_t proptbl[NUMPROPS];
@ -102,20 +102,20 @@ static _ranges_t proptbl[NUMPROPS];
/*
* Make sure this array is sized to be on a 4-byte boundary at compile time.
*/
static unsigned short propcnt[NEEDPROPS];
static ac_uint2 propcnt[NEEDPROPS];
/*
* Array used to collect a decomposition before adding it to the decomposition
* table.
*/
static unsigned long dectmp[64];
static unsigned long dectmp_size;
static ac_uint4 dectmp[64];
static ac_uint4 dectmp_size;
typedef struct {
unsigned long code;
unsigned short size;
unsigned short used;
unsigned long *decomp;
ac_uint4 code;
ac_uint2 size;
ac_uint2 used;
ac_uint4 *decomp;
} _decomp_t;
/*
@ -124,70 +124,70 @@ typedef struct {
* compatibility mappings.
*/
static _decomp_t *decomps;
static unsigned long decomps_used;
static unsigned long decomps_size;
static ac_uint4 decomps_used;
static ac_uint4 decomps_size;
static _decomp_t *kdecomps;
static unsigned long kdecomps_used;
static unsigned long kdecomps_size;
static ac_uint4 kdecomps_used;
static ac_uint4 kdecomps_size;
/*
* Composition exclusion table stuff.
*/
#define COMPEX_SET(c) (compexs[(c) >> 5] |= (1 << ((c) & 31)))
#define COMPEX_TEST(c) (compexs[(c) >> 5] & (1 << ((c) & 31)))
static unsigned long compexs[2048];
static ac_uint4 compexs[2048];
/*
* Struct for holding a composition pair, and array of composition pairs
*/
typedef struct {
unsigned long comp;
unsigned long count;
unsigned long code1;
unsigned long code2;
ac_uint4 comp;
ac_uint4 count;
ac_uint4 code1;
ac_uint4 code2;
} _comp_t;
static _comp_t *comps;
static unsigned long comps_used;
static ac_uint4 comps_used;
/*
* Types and lists for handling lists of case mappings.
*/
typedef struct {
unsigned long key;
unsigned long other1;
unsigned long other2;
ac_uint4 key;
ac_uint4 other1;
ac_uint4 other2;
} _case_t;
static _case_t *upper;
static _case_t *lower;
static _case_t *title;
static unsigned long upper_used;
static unsigned long upper_size;
static unsigned long lower_used;
static unsigned long lower_size;
static unsigned long title_used;
static unsigned long title_size;
static ac_uint4 upper_used;
static ac_uint4 upper_size;
static ac_uint4 lower_used;
static ac_uint4 lower_size;
static ac_uint4 title_used;
static ac_uint4 title_size;
/*
* Array used to collect case mappings before adding them to a list.
*/
static unsigned long cases[3];
static ac_uint4 cases[3];
/*
* An array to hold ranges for combining classes.
*/
static unsigned long *ccl;
static unsigned long ccl_used;
static unsigned long ccl_size;
static ac_uint4 *ccl;
static ac_uint4 ccl_used;
static ac_uint4 ccl_size;
/*
* Structures for handling numbers.
*/
typedef struct {
unsigned long code;
unsigned long idx;
ac_uint4 code;
ac_uint4 idx;
} _codeidx_t;
typedef struct {
@ -199,22 +199,22 @@ typedef struct {
* Arrays to hold the mapping of codes to numbers.
*/
static _codeidx_t *ncodes;
static unsigned long ncodes_used;
static unsigned long ncodes_size;
static ac_uint4 ncodes_used;
static ac_uint4 ncodes_size;
static _num_t *nums;
static unsigned long nums_used;
static unsigned long nums_size;
static ac_uint4 nums_used;
static ac_uint4 nums_size;
/*
* Array for holding numbers.
*/
static _num_t *nums;
static unsigned long nums_used;
static unsigned long nums_size;
static ac_uint4 nums_used;
static ac_uint4 nums_size;
static void
add_range(unsigned long start, unsigned long end, char *p1, char *p2)
add_range(ac_uint4 start, ac_uint4 end, char *p1, char *p2)
{
int i, j, k, len;
_ranges_t *rlp;
@ -247,12 +247,12 @@ add_range(unsigned long start, unsigned long end, char *p1, char *p2)
*/
if (rlp->used == rlp->size) {
if (rlp->size == 0)
rlp->ranges = (unsigned long *)
malloc(sizeof(unsigned long) << 3);
rlp->ranges = (ac_uint4 *)
malloc(sizeof(ac_uint4) << 3);
else
rlp->ranges = (unsigned long *)
rlp->ranges = (ac_uint4 *)
realloc((char *) rlp->ranges,
sizeof(unsigned long) * (rlp->size + 8));
sizeof(ac_uint4) * (rlp->size + 8));
rlp->size += 8;
}
@ -312,10 +312,10 @@ add_range(unsigned long start, unsigned long end, char *p1, char *p2)
}
static void
ordered_range_insert(unsigned long c, char *name, int len)
ordered_range_insert(ac_uint4 c, char *name, int len)
{
int i, j;
unsigned long s, e;
ac_uint4 s, e;
_ranges_t *rlp;
if (len == 0)
@ -355,12 +355,12 @@ ordered_range_insert(unsigned long c, char *name, int len)
*/
if (rlp->used == rlp->size) {
if (rlp->size == 0)
rlp->ranges = (unsigned long *)
malloc(sizeof(unsigned long) << 3);
rlp->ranges = (ac_uint4 *)
malloc(sizeof(ac_uint4) << 3);
else
rlp->ranges = (unsigned long *)
rlp->ranges = (ac_uint4 *)
realloc((char *) rlp->ranges,
sizeof(unsigned long) * (rlp->size + 8));
sizeof(ac_uint4) * (rlp->size + 8));
rlp->size += 8;
}
@ -437,12 +437,12 @@ ordered_range_insert(unsigned long c, char *name, int len)
}
static void
add_decomp(unsigned long code, short compat)
add_decomp(ac_uint4 code, short compat)
{
unsigned long i, j, size;
ac_uint4 i, j, size;
_decomp_t **pdecomps;
unsigned long *pdecomps_used;
unsigned long *pdecomps_size;
ac_uint4 *pdecomps_used;
ac_uint4 *pdecomps_size;
if (compat) {
pdecomps = &kdecomps;
@ -496,12 +496,12 @@ add_decomp(unsigned long code, short compat)
size = dectmp_size + (4 - (dectmp_size & 3));
if ((*pdecomps)[i].size < size) {
if ((*pdecomps)[i].size == 0)
(*pdecomps)[i].decomp = (unsigned long *)
malloc(sizeof(unsigned long) * size);
(*pdecomps)[i].decomp = (ac_uint4 *)
malloc(sizeof(ac_uint4) * size);
else
(*pdecomps)[i].decomp = (unsigned long *)
(*pdecomps)[i].decomp = (ac_uint4 *)
realloc((char *) (*pdecomps)[i].decomp,
sizeof(unsigned long) * size);
sizeof(ac_uint4) * size);
(*pdecomps)[i].size = size;
}
@ -511,7 +511,7 @@ add_decomp(unsigned long code, short compat)
(*pdecomps)[i].code = code;
(*pdecomps)[i].used = dectmp_size;
(void) AC_MEMCPY((char *) (*pdecomps)[i].decomp, (char *) dectmp,
sizeof(unsigned long) * dectmp_size);
sizeof(ac_uint4) * dectmp_size);
/*
* NOTICE: This needs changing later so it is more general than simply
@ -522,9 +522,9 @@ add_decomp(unsigned long code, short compat)
}
static void
add_title(unsigned long code)
add_title(ac_uint4 code)
{
unsigned long i, j;
ac_uint4 i, j;
/*
* Always map the code to itself.
@ -562,9 +562,9 @@ add_title(unsigned long code)
}
static void
add_upper(unsigned long code)
add_upper(ac_uint4 code)
{
unsigned long i, j;
ac_uint4 i, j;
/*
* Always map the code to itself.
@ -609,9 +609,9 @@ add_upper(unsigned long code)
}
static void
add_lower(unsigned long code)
add_lower(ac_uint4 code)
{
unsigned long i, j;
ac_uint4 i, j;
/*
* Always map the code to itself.
@ -656,16 +656,16 @@ add_lower(unsigned long code)
}
static void
ordered_ccl_insert(unsigned long c, unsigned long ccl_code)
ordered_ccl_insert(ac_uint4 c, ac_uint4 ccl_code)
{
unsigned long i, j;
ac_uint4 i, j;
if (ccl_used == ccl_size) {
if (ccl_size == 0)
ccl = (unsigned long *) malloc(sizeof(unsigned long) * 24);
ccl = (ac_uint4 *) malloc(sizeof(ac_uint4) * 24);
else
ccl = (unsigned long *)
realloc((char *) ccl, sizeof(unsigned long) * (ccl_size + 24));
ccl = (ac_uint4 *)
realloc((char *) ccl, sizeof(ac_uint4) * (ccl_size + 24));
ccl_size += 24;
}
@ -728,10 +728,10 @@ ordered_ccl_insert(unsigned long c, unsigned long ccl_code)
* Adds a number if it does not already exist and returns an index value
* multiplied by 2.
*/
static unsigned long
static ac_uint4
make_number(short num, short denom)
{
unsigned long n;
ac_uint4 n;
/*
* Determine if the number already exists.
@ -758,9 +758,9 @@ make_number(short num, short denom)
}
static void
add_number(unsigned long code, short num, short denom)
add_number(ac_uint4 code, short num, short denom)
{
unsigned long i, j;
ac_uint4 i, j;
/*
* Insert the code in order.
@ -811,7 +811,7 @@ add_number(unsigned long code, short num, short denom)
static void
read_cdata(FILE *in)
{
unsigned long i, lineno, skip, code, ccl_code;
ac_uint4 i, lineno, skip, code, ccl_code;
short wnum, neg, number[2], compat;
char line[512], *s, *e;
@ -1096,7 +1096,7 @@ read_cdata(FILE *in)
}
static _decomp_t *
find_decomp(unsigned long code, short compat)
find_decomp(ac_uint4 code, short compat)
{
long l, r, m;
_decomp_t *decs;
@ -1119,7 +1119,7 @@ find_decomp(unsigned long code, short compat)
static void
decomp_it(_decomp_t *d, short compat)
{
unsigned long i;
ac_uint4 i;
_decomp_t *dp;
for (i = 0; i < d->used; i++) {
@ -1137,7 +1137,7 @@ decomp_it(_decomp_t *d, short compat)
static void
expand_decomp(void)
{
unsigned long i;
ac_uint4 i;
for (i = 0; i < decomps_used; i++) {
dectmp_size = 0;
@ -1171,10 +1171,10 @@ cmpcomps(const void *v_comp1, const void *v_comp2)
static void
read_compexdata(FILE *in)
{
unsigned short i, code;
ac_uint2 i, code;
char line[512], *s;
(void) memset((char *) compexs, 0, sizeof(unsigned long) << 11);
(void) memset((char *) compexs, 0, sizeof(ac_uint4) << 11);
while (fgets(line, sizeof(line), in)) {
if( (s=strchr(line, '\n')) ) *s = '\0';
@ -1207,7 +1207,7 @@ read_compexdata(FILE *in)
static void
create_comps(void)
{
unsigned long i, cu;
ac_uint4 i, cu;
comps = (_comp_t *) malloc(comps_used * sizeof(_comp_t));
@ -1229,8 +1229,8 @@ write_cdata(char *opath)
{
FILE *out;
ac_uint4 bytes;
unsigned long i, idx, nprops;
unsigned short casecnt[2];
ac_uint4 i, idx, nprops;
ac_uint2 casecnt[2];
char path[BUFSIZ];
/*****************************************************************
@ -1273,10 +1273,10 @@ write_cdata(char *opath)
* Calculate the byte count needed and pad the property counts array to a
* 4-byte boundary.
*/
if ((bytes = sizeof(unsigned short) * (NUMPROPS + 1)) & 3)
if ((bytes = sizeof(ac_uint2) * (NUMPROPS + 1)) & 3)
bytes += 4 - (bytes & 3);
nprops = bytes / sizeof(unsigned short);
bytes += sizeof(unsigned long) * idx;
nprops = bytes / sizeof(ac_uint2);
bytes += sizeof(ac_uint4) * idx;
/*
* Write the header.
@ -1286,19 +1286,19 @@ write_cdata(char *opath)
/*
* Write the byte count.
*/
fwrite((char *) &bytes, sizeof(unsigned long), 1, out);
fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
/*
* Write the property list counts.
*/
fwrite((char *) propcnt, sizeof(unsigned short), nprops, out);
fwrite((char *) propcnt, sizeof(ac_uint2), nprops, out);
/*
* Write the property lists.
*/
for (i = 0; i < NUMPROPS; i++) {
if (proptbl[i].used > 0)
fwrite((char *) proptbl[i].ranges, sizeof(unsigned long),
fwrite((char *) proptbl[i].ranges, sizeof(ac_uint4),
proptbl[i].used, out);
}
@ -1327,12 +1327,12 @@ write_cdata(char *opath)
/*
* Write the header.
*/
fwrite((char *) hdr, sizeof(unsigned short), 2, out);
fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
/*
* Write the upper and lower case table sizes.
*/
fwrite((char *) casecnt, sizeof(unsigned short), 2, out);
fwrite((char *) casecnt, sizeof(ac_uint2), 2, out);
if (upper_used > 0)
/*
@ -1375,14 +1375,14 @@ write_cdata(char *opath)
/*
* Write the header.
*/
hdr[1] = (unsigned short) comps_used * 4;
fwrite((char *) hdr, sizeof(unsigned short), 2, out);
hdr[1] = (ac_uint2) comps_used * 4;
fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
/*
* Write out the byte count to maintain header size.
*/
bytes = comps_used * sizeof(_comp_t);
fwrite((char *) &bytes, sizeof(unsigned long), 1, out);
fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
/*
* Now, if comps exist, write them out.
@ -1415,44 +1415,44 @@ write_cdata(char *opath)
/*
* Write the header.
*/
fwrite((char *) hdr, sizeof(unsigned short), 2, out);
fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
/*
* Write a temporary byte count which will be calculated as the
* decompositions are written out.
*/
bytes = 0;
fwrite((char *) &bytes, sizeof(unsigned long), 1, out);
fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
if (decomps_used) {
/*
* Write the list of decomp nodes.
*/
for (i = idx = 0; i < decomps_used; i++) {
fwrite((char *) &decomps[i].code, sizeof(unsigned long), 1, out);
fwrite((char *) &idx, sizeof(unsigned long), 1, out);
fwrite((char *) &decomps[i].code, sizeof(ac_uint4), 1, out);
fwrite((char *) &idx, sizeof(ac_uint4), 1, out);
idx += decomps[i].used;
}
/*
* Write the sentinel index as the last decomp node.
*/
fwrite((char *) &idx, sizeof(unsigned long), 1, out);
fwrite((char *) &idx, sizeof(ac_uint4), 1, out);
/*
* Write the decompositions themselves.
*/
for (i = 0; i < decomps_used; i++)
fwrite((char *) decomps[i].decomp, sizeof(unsigned long),
fwrite((char *) decomps[i].decomp, sizeof(ac_uint4),
decomps[i].used, out);
/*
* Seek back to the beginning and write the byte count.
*/
bytes = (sizeof(unsigned long) * idx) +
(sizeof(unsigned long) * ((hdr[1] << 1) + 1));
fseek(out, sizeof(unsigned short) << 1, 0L);
fwrite((char *) &bytes, sizeof(unsigned long), 1, out);
bytes = (sizeof(ac_uint4) * idx) +
(sizeof(ac_uint4) * ((hdr[1] << 1) + 1));
fseek(out, sizeof(ac_uint2) << 1, 0L);
fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
fclose(out);
}
@ -1469,44 +1469,44 @@ write_cdata(char *opath)
/*
* Write the header.
*/
fwrite((char *) hdr, sizeof(unsigned short), 2, out);
fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
/*
* Write a temporary byte count which will be calculated as the
* decompositions are written out.
*/
bytes = 0;
fwrite((char *) &bytes, sizeof(unsigned long), 1, out);
fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
if (kdecomps_used) {
/*
* Write the list of kdecomp nodes.
*/
for (i = idx = 0; i < kdecomps_used; i++) {
fwrite((char *) &kdecomps[i].code, sizeof(unsigned long), 1, out);
fwrite((char *) &idx, sizeof(unsigned long), 1, out);
fwrite((char *) &kdecomps[i].code, sizeof(ac_uint4), 1, out);
fwrite((char *) &idx, sizeof(ac_uint4), 1, out);
idx += kdecomps[i].used;
}
/*
* Write the sentinel index as the last decomp node.
*/
fwrite((char *) &idx, sizeof(unsigned long), 1, out);
fwrite((char *) &idx, sizeof(ac_uint4), 1, out);
/*
* Write the decompositions themselves.
*/
for (i = 0; i < kdecomps_used; i++)
fwrite((char *) kdecomps[i].decomp, sizeof(unsigned long),
fwrite((char *) kdecomps[i].decomp, sizeof(ac_uint4),
kdecomps[i].used, out);
/*
* Seek back to the beginning and write the byte count.
*/
bytes = (sizeof(unsigned long) * idx) +
(sizeof(unsigned long) * ((hdr[1] << 1) + 1));
fseek(out, sizeof(unsigned short) << 1, 0L);
fwrite((char *) &bytes, sizeof(unsigned long), 1, out);
bytes = (sizeof(ac_uint4) * idx) +
(sizeof(ac_uint4) * ((hdr[1] << 1) + 1));
fseek(out, sizeof(ac_uint2) << 1, 0L);
fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
fclose(out);
}
@ -1533,19 +1533,19 @@ write_cdata(char *opath)
/*
* Write the header.
*/
fwrite((char *) hdr, sizeof(unsigned short), 2, out);
fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
/*
* Write out the byte count to maintain header size.
*/
bytes = ccl_used * sizeof(unsigned long);
fwrite((char *) &bytes, sizeof(unsigned long), 1, out);
bytes = ccl_used * sizeof(ac_uint4);
fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
if (ccl_used > 0)
/*
* Write the combining class ranges out.
*/
fwrite((char *) ccl, sizeof(unsigned long), ccl_used, out);
fwrite((char *) ccl, sizeof(ac_uint4), ccl_used, out);
fclose(out);
@ -1566,18 +1566,18 @@ write_cdata(char *opath)
* The count part of the header will be the total number of codes that
* have numbers.
*/
hdr[1] = (unsigned short) (ncodes_used << 1);
hdr[1] = (ac_uint2) (ncodes_used << 1);
bytes = (ncodes_used * sizeof(_codeidx_t)) + (nums_used * sizeof(_num_t));
/*
* Write the header.
*/
fwrite((char *) hdr, sizeof(unsigned short), 2, out);
fwrite((char *) hdr, sizeof(ac_uint2), 2, out);
/*
* Write out the byte count to maintain header size.
*/
fwrite((char *) &bytes, sizeof(unsigned long), 1, out);
fwrite((char *) &bytes, sizeof(ac_uint4), 1, out);
/*
* Now, if number mappings exist, write them out.