mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-04 05:32:56 +00:00
Bug 956995 - Stop using prtypes in unicpriv.h. r=smontagu
This commit is contained in:
parent
1db04c8244
commit
1231f90835
intl/uconv/util
@ -1,14 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef ubase_h__
|
||||
#define ubase_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define PRIVATE
|
||||
#define MODULE_PRIVATE
|
||||
|
||||
#endif
|
@ -6,166 +6,166 @@
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
typedef PRBool (*uSubGeneratorFunc) (uint16_t in, unsigned char* out);
|
||||
typedef int (*uSubGeneratorFunc) (uint16_t in, unsigned char* out);
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
|
||||
typedef PRBool (*uGeneratorFunc) (
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
typedef int (*uGeneratorFunc) (
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
MODULE_PRIVATE PRBool uGenerate(
|
||||
uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uGenerate(
|
||||
uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
#define uSubGenerator(sub,in,out) (* m_subgenerator[sub])((in),(out))
|
||||
|
||||
PRIVATE PRBool uCheckAndGenAlways1Byte(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndGenAlways2Byte(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndGenAlways2ByteShiftGR(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
MODULE_PRIVATE PRBool uGenerateShift(
|
||||
uShiftOutTable *shift,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
int uCheckAndGenAlways1Byte(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uCheckAndGenAlways2Byte(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uCheckAndGenAlways2ByteShiftGR(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uGenerateShift(
|
||||
uShiftOutTable *shift,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uCheckAndGen2ByteGRPrefix8F(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uCheckAndGen2ByteGRPrefix8EA2(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
int uCheckAndGen2ByteGRPrefix8EA3(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
int uCheckAndGen2ByteGRPrefix8EA4(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
int uCheckAndGen2ByteGRPrefix8EA5(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
int uCheckAndGen2ByteGRPrefix8EA6(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
int uCheckAndGen2ByteGRPrefix8EA7(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uCnGAlways8BytesDecomposedHangul(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8F(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA2(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA3(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uCheckAndGenJohabHangul(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA4(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA5(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA6(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA7(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
PRIVATE PRBool uCnGAlways8BytesDecomposedHangul(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndGenJohabHangul(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndGenJohabSymbol(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uCheckAndGenJohabSymbol(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
|
||||
PRIVATE PRBool uCheckAndGen4BytesGB18030(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
int uCheckAndGen4BytesGB18030(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
);
|
||||
|
||||
int uGenAlways2Byte(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
);
|
||||
int uGenAlways2ByteShiftGR(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
);
|
||||
int uGenAlways1Byte(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
);
|
||||
int uGenAlways1BytePrefix8E(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
);
|
||||
/*=================================================================================
|
||||
|
||||
PRIVATE PRBool uGenAlways2Byte(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
);
|
||||
PRIVATE PRBool uGenAlways2ByteShiftGR(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
);
|
||||
PRIVATE PRBool uGenAlways1Byte(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
);
|
||||
PRIVATE PRBool uGenAlways1BytePrefix8E(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
);
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const uGeneratorFunc m_generator[uNumOfCharsetType] =
|
||||
const uGeneratorFunc m_generator[uNumOfCharsetType] =
|
||||
{
|
||||
uCheckAndGenAlways1Byte,
|
||||
uCheckAndGenAlways2Byte,
|
||||
@ -188,152 +188,151 @@ PRIVATE const uGeneratorFunc m_generator[uNumOfCharsetType] =
|
||||
|
||||
=================================================================================*/
|
||||
|
||||
PRIVATE const uSubGeneratorFunc m_subgenerator[uNumOfCharType] =
|
||||
const uSubGeneratorFunc m_subgenerator[uNumOfCharType] =
|
||||
{
|
||||
uGenAlways1Byte,
|
||||
uGenAlways2Byte,
|
||||
uGenAlways2ByteShiftGR,
|
||||
uGenAlways1BytePrefix8E
|
||||
|
||||
};
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
MODULE_PRIVATE PRBool uGenerate(
|
||||
uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uGenerate(
|
||||
uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
return (* m_generator[scanClass]) (state,in,out,outbuflen,outlen);
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uGenAlways1Byte(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
)
|
||||
int uGenAlways1Byte(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
)
|
||||
{
|
||||
out[0] = (unsigned char)in;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uGenAlways2Byte(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
)
|
||||
int uGenAlways2Byte(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
)
|
||||
{
|
||||
out[0] = (unsigned char)((in >> 8) & 0xff);
|
||||
out[1] = (unsigned char)(in & 0xff);
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uGenAlways2ByteShiftGR(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
)
|
||||
int uGenAlways2ByteShiftGR(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
)
|
||||
{
|
||||
out[0] = (unsigned char)(((in >> 8) & 0xff) | 0x80);
|
||||
out[1] = (unsigned char)((in & 0xff) | 0x80);
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uGenAlways1BytePrefix8E(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
)
|
||||
int uGenAlways1BytePrefix8E(
|
||||
uint16_t in,
|
||||
unsigned char* out
|
||||
)
|
||||
{
|
||||
out[0] = 0x8E;
|
||||
out[1] = (unsigned char)(in & 0xff);
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGenAlways1Byte(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGenAlways1Byte(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
/* Don't check inlen. The caller should ensure it is larger than 0 */
|
||||
/* Oops, I don't agree. Code changed to check every time. [CATA] */
|
||||
if(outbuflen < 1)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 1;
|
||||
out[0] = in & 0xff;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGenAlways2Byte(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGenAlways2Byte(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 2)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 2;
|
||||
out[0] = ((in >> 8 ) & 0xff);
|
||||
out[1] = in & 0xff;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGenAlways2ByteShiftGR(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGenAlways2ByteShiftGR(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 2)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 2;
|
||||
out[0] = ((in >> 8 ) & 0xff) | 0x80;
|
||||
out[1] = (in & 0xff) | 0x80;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
MODULE_PRIVATE PRBool uGenerateShift(
|
||||
uShiftOutTable *shift,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uGenerateShift(
|
||||
uShiftOutTable *shift,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
int16_t i;
|
||||
const uShiftOutCell* cell = &(shift->shiftcell[0]);
|
||||
@ -350,7 +349,7 @@ MODULE_PRIVATE PRBool uGenerateShift(
|
||||
{
|
||||
if(outbuflen < cell[i].reserveLen)
|
||||
{
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -359,41 +358,41 @@ MODULE_PRIVATE PRBool uGenerateShift(
|
||||
}
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8F( int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGen2ByteGRPrefix8F(int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 3)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 3;
|
||||
out[0] = 0x8F;
|
||||
out[1] = ((in >> 8 ) & 0xff) | 0x80;
|
||||
out[2] = (in & 0xff) | 0x80;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA2( int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGen2ByteGRPrefix8EA2(int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 4)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 4;
|
||||
@ -401,7 +400,7 @@ PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA2( int32_t* state,
|
||||
out[1] = 0xA2;
|
||||
out[2] = ((in >> 8 ) & 0xff) | 0x80;
|
||||
out[3] = (in & 0xff) | 0x80;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,15 +408,15 @@ PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA2( int32_t* state,
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA3( int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGen2ByteGRPrefix8EA3(int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 4)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 4;
|
||||
@ -425,21 +424,21 @@ PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA3( int32_t* state,
|
||||
out[1] = 0xA3;
|
||||
out[2] = ((in >> 8 ) & 0xff) | 0x80;
|
||||
out[3] = (in & 0xff) | 0x80;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA4( int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGen2ByteGRPrefix8EA4(int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 4)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 4;
|
||||
@ -447,21 +446,21 @@ PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA4( int32_t* state,
|
||||
out[1] = 0xA4;
|
||||
out[2] = ((in >> 8 ) & 0xff) | 0x80;
|
||||
out[3] = (in & 0xff) | 0x80;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA5( int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGen2ByteGRPrefix8EA5(int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 4)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 4;
|
||||
@ -469,21 +468,21 @@ PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA5( int32_t* state,
|
||||
out[1] = 0xA5;
|
||||
out[2] = ((in >> 8 ) & 0xff) | 0x80;
|
||||
out[3] = (in & 0xff) | 0x80;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA6( int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGen2ByteGRPrefix8EA6(int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 4)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 4;
|
||||
@ -491,21 +490,21 @@ PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA6( int32_t* state,
|
||||
out[1] = 0xA6;
|
||||
out[2] = ((in >> 8 ) & 0xff) | 0x80;
|
||||
out[3] = (in & 0xff) | 0x80;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA7( int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGen2ByteGRPrefix8EA7(int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 4)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*outlen = 4;
|
||||
@ -513,7 +512,7 @@ PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA7( int32_t* state,
|
||||
out[1] = 0xA7;
|
||||
out[2] = ((in >> 8 ) & 0xff) | 0x80;
|
||||
out[3] = (in & 0xff) | 0x80;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
@ -527,13 +526,13 @@ PRIVATE PRBool uCheckAndGen2ByteGRPrefix8EA7( int32_t* state,
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCnGAlways8BytesDecomposedHangul(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCnGAlways8BytesDecomposedHangul(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
static const uint8_t lMap[LCount] = {
|
||||
0xa1, 0xa2, 0xa4, 0xa7, 0xa8, 0xa9, 0xb1, 0xb2, 0xb3, 0xb5,
|
||||
@ -549,7 +548,7 @@ PRIVATE PRBool uCnGAlways8BytesDecomposedHangul(
|
||||
uint16_t SIndex, LIndex, VIndex, TIndex;
|
||||
|
||||
if(outbuflen < 8)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
|
||||
/* the following line are copy from Unicode 2.0 page 3-13 */
|
||||
/* item 1 of Hangul Syllabel Decomposition */
|
||||
@ -575,19 +574,19 @@ PRIVATE PRBool uCnGAlways8BytesDecomposedHangul(
|
||||
out[5] = (VIndex + 0xbf);
|
||||
out[7] = tMap[TIndex];
|
||||
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRIVATE PRBool uCheckAndGenJohabHangul(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGenJohabHangul(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 2)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
/*
|
||||
@ -633,19 +632,19 @@ PRIVATE PRBool uCheckAndGenJohabHangul(
|
||||
#if 0
|
||||
printf("Johab Hangul %x %x in=%x L=%d V=%d T=%d\n", out[0], out[1], in, LIndex, VIndex, TIndex);
|
||||
#endif
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
PRIVATE PRBool uCheckAndGenJohabSymbol(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGenJohabSymbol(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 2)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
/* The following code are based on the Perl code listed under
|
||||
@ -689,19 +688,19 @@ PRIVATE PRBool uCheckAndGenJohabSymbol(
|
||||
#if 0
|
||||
printf("Johab Symbol %x %x in=%x\n", out[0], out[1], in);
|
||||
#endif
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
PRIVATE PRBool uCheckAndGen4BytesGB18030(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
int uCheckAndGen4BytesGB18030(
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen
|
||||
)
|
||||
{
|
||||
if(outbuflen < 4)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
out[0] = (in / (10*126*10)) + 0x81;
|
||||
in %= (10*126*10);
|
||||
out[1] = (in / (10*126)) + 0x30;
|
||||
@ -709,5 +708,5 @@ PRIVATE PRBool uCheckAndGen4BytesGB18030(
|
||||
out[2] = (in / (10)) + 0x81;
|
||||
out[3] = (in % 10) + 0x30;
|
||||
*outlen = 4;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
@ -7,28 +7,28 @@
|
||||
|
||||
|
||||
typedef uint16_t (* MapFormatFunc)(uint16_t in,const uTable *uT,const uMapCell *cell);
|
||||
typedef PRBool (* HitFormateFunc)(uint16_t in,const uMapCell *cell);
|
||||
typedef int (* HitFormateFunc)(uint16_t in,const uMapCell *cell);
|
||||
typedef void (* FillInfoFormateFunc)(const uTable *uT, const uMapCell *cell, uint32_t* info);
|
||||
|
||||
|
||||
PRIVATE PRBool uHitFormate0(uint16_t in,const uMapCell *cell);
|
||||
PRIVATE PRBool uHitFormate2(uint16_t in,const uMapCell *cell);
|
||||
PRIVATE uint16_t uMapFormate0(uint16_t in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE uint16_t uMapFormate1(uint16_t in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE uint16_t uMapFormate2(uint16_t in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,uint32_t* aInfo);
|
||||
PRIVATE void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,uint32_t* aInfo);
|
||||
PRIVATE void uFillInfoFormate2(const uTable *uT,const uMapCell *cell,uint32_t* aInfo);
|
||||
int uHitFormate0(uint16_t in,const uMapCell *cell);
|
||||
int uHitFormate2(uint16_t in,const uMapCell *cell);
|
||||
uint16_t uMapFormate0(uint16_t in,const uTable *uT,const uMapCell *cell);
|
||||
uint16_t uMapFormate1(uint16_t in,const uTable *uT,const uMapCell *cell);
|
||||
uint16_t uMapFormate2(uint16_t in,const uTable *uT,const uMapCell *cell);
|
||||
void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,uint32_t* aInfo);
|
||||
void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,uint32_t* aInfo);
|
||||
void uFillInfoFormate2(const uTable *uT,const uMapCell *cell,uint32_t* aInfo);
|
||||
|
||||
|
||||
PRIVATE const uMapCell *uGetMapCell(const uTable *uT, int16_t item);
|
||||
PRIVATE char uGetFormat(const uTable *uT, int16_t item);
|
||||
const uMapCell *uGetMapCell(const uTable *uT, int16_t item);
|
||||
char uGetFormat(const uTable *uT, int16_t item);
|
||||
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const MapFormatFunc m_map[uNumFormatTag] =
|
||||
const MapFormatFunc m_map[uNumFormatTag] =
|
||||
{
|
||||
uMapFormate0,
|
||||
uMapFormate1,
|
||||
@ -38,7 +38,7 @@ PRIVATE const MapFormatFunc m_map[uNumFormatTag] =
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const FillInfoFormateFunc m_fillinfo[uNumFormatTag] =
|
||||
const FillInfoFormateFunc m_fillinfo[uNumFormatTag] =
|
||||
{
|
||||
uFillInfoFormate0,
|
||||
uFillInfoFormate1,
|
||||
@ -48,7 +48,7 @@ PRIVATE const FillInfoFormateFunc m_fillinfo[uNumFormatTag] =
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const HitFormateFunc m_hit[uNumFormatTag] =
|
||||
const HitFormateFunc m_hit[uNumFormatTag] =
|
||||
{
|
||||
uHitFormate0,
|
||||
uHitFormate0,
|
||||
@ -63,9 +63,9 @@ PRIVATE const HitFormateFunc m_hit[uNumFormatTag] =
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
MODULE_PRIVATE PRBool uMapCode(const uTable *uT, uint16_t in, uint16_t* out)
|
||||
int uMapCode(const uTable *uT, uint16_t in, uint16_t* out)
|
||||
{
|
||||
PRBool done = PR_FALSE;
|
||||
int done = 0;
|
||||
uint16_t itemOfList = uT->itemOfList;
|
||||
uint16_t i;
|
||||
*out = NOMAPPING;
|
||||
@ -77,7 +77,7 @@ MODULE_PRIVATE PRBool uMapCode(const uTable *uT, uint16_t in, uint16_t* out)
|
||||
if(uHit(format, in, uCell))
|
||||
{
|
||||
*out = uMap(format, in, uT,uCell);
|
||||
done = PR_TRUE;
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ member function
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uHitFormate0(uint16_t in,const uMapCell *cell)
|
||||
int uHitFormate0(uint16_t in,const uMapCell *cell)
|
||||
{
|
||||
return ( (in >= cell->fmt.format0.srcBegin) &&
|
||||
(in <= cell->fmt.format0.srcEnd) ) ;
|
||||
@ -99,21 +99,21 @@ PRIVATE PRBool uHitFormate0(uint16_t in,const uMapCell *cell)
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uHitFormate2(uint16_t in,const uMapCell *cell)
|
||||
int uHitFormate2(uint16_t in,const uMapCell *cell)
|
||||
{
|
||||
return (in == cell->fmt.format2.srcBegin);
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE uint16_t uMapFormate0(uint16_t in,const uTable *uT,const uMapCell *cell)
|
||||
uint16_t uMapFormate0(uint16_t in,const uTable *uT,const uMapCell *cell)
|
||||
{
|
||||
return ((in - cell->fmt.format0.srcBegin) + cell->fmt.format0.destBegin);
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE uint16_t uMapFormate1(uint16_t in,const uTable *uT,const uMapCell *cell)
|
||||
uint16_t uMapFormate1(uint16_t in,const uTable *uT,const uMapCell *cell)
|
||||
{
|
||||
return (*(((uint16_t *)uT) + uT->offsetToMappingTable
|
||||
+ cell->fmt.format1.mappingOffset + in - cell->fmt.format1.srcBegin));
|
||||
@ -121,7 +121,7 @@ PRIVATE uint16_t uMapFormate1(uint16_t in,const uTable *uT,const uMapCell *cell)
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE uint16_t uMapFormate2(uint16_t in,const uTable *uT,const uMapCell *cell)
|
||||
uint16_t uMapFormate2(uint16_t in,const uTable *uT,const uMapCell *cell)
|
||||
{
|
||||
return (cell->fmt.format2.destBegin);
|
||||
}
|
||||
@ -130,7 +130,7 @@ PRIVATE uint16_t uMapFormate2(uint16_t in,const uTable *uT,const uMapCell *cell)
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,uint32_t* info)
|
||||
void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,uint32_t* info)
|
||||
{
|
||||
uint16_t begin, end, i;
|
||||
begin = cell->fmt.format0.srcBegin;
|
||||
@ -152,7 +152,7 @@ PRIVATE void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,uint32_t* i
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,uint32_t* info)
|
||||
void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,uint32_t* info)
|
||||
{
|
||||
uint16_t begin, end, i;
|
||||
uint16_t *base;
|
||||
@ -168,7 +168,7 @@ PRIVATE void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,uint32_t* i
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate2(const uTable *uT,const uMapCell *cell,uint32_t* info)
|
||||
void uFillInfoFormate2(const uTable *uT,const uMapCell *cell,uint32_t* info)
|
||||
{
|
||||
SET_REPRESENTABLE(info, cell->fmt.format2.srcBegin);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef __UNIPRIV__
|
||||
#define __UNIPRIV__
|
||||
|
||||
#include "ubase.h"
|
||||
#include <stdint.h>
|
||||
#include "umap.h"
|
||||
#include "uconvutil.h"
|
||||
|
||||
@ -13,37 +13,37 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PRBool uMapCode(const uTable *uT,
|
||||
uint16_t in,
|
||||
uint16_t* out);
|
||||
int uMapCode(const uTable *uT,
|
||||
uint16_t in,
|
||||
uint16_t* out);
|
||||
|
||||
PRBool uGenerate(uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen);
|
||||
int uGenerate(uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen);
|
||||
|
||||
PRBool uScan(uScanClassID scanClass,
|
||||
int32_t *state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen);
|
||||
int uScan(uScanClassID scanClass,
|
||||
int32_t *state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen);
|
||||
|
||||
PRBool uGenerateShift(uShiftOutTable *shift,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen);
|
||||
int uGenerateShift(uShiftOutTable *shift,
|
||||
int32_t* state,
|
||||
uint16_t in,
|
||||
unsigned char* out,
|
||||
uint32_t outbuflen,
|
||||
uint32_t* outlen);
|
||||
|
||||
PRBool uScanShift(uShiftInTable *shift,
|
||||
int32_t *state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen);
|
||||
int uScanShift(uShiftInTable *shift,
|
||||
int32_t *state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -8,166 +8,166 @@
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
typedef PRBool (*uSubScannerFunc) (unsigned char* in, uint16_t* out);
|
||||
typedef int (*uSubScannerFunc) (unsigned char* in, uint16_t* out);
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
|
||||
typedef PRBool (*uScannerFunc) (
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
typedef int (*uScannerFunc) (
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
|
||||
MODULE_PRIVATE PRBool uScan(
|
||||
uScanClassID scanClass,
|
||||
int uScan(
|
||||
uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
|
||||
#define uSubScanner(sub,in,out) (* m_subscanner[sub])((in),(out))
|
||||
|
||||
int uCheckAndScanAlways1Byte(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScanAlways2Byte(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScanAlways2ByteShiftGR(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScanAlways2ByteGR128(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uScanShift(
|
||||
uShiftInTable *shift,
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
|
||||
#define uSubScanner(sub,in,out) (* m_subscanner[sub])((in),(out))
|
||||
|
||||
PRIVATE PRBool uCheckAndScanAlways1Byte(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScanAlways2Byte(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScanAlways2ByteShiftGR(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScanAlways2ByteGR128(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
MODULE_PRIVATE PRBool uScanShift(
|
||||
uShiftInTable *shift,
|
||||
int uCheckAndScan2ByteGRPrefix8F(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScan2ByteGRPrefix8EA2(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScan2ByteGRPrefix8EA3(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScan2ByteGRPrefix8EA4(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScan2ByteGRPrefix8EA5(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScan2ByteGRPrefix8EA6(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScan2ByteGRPrefix8EA7(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCnSAlways8BytesDecomposedHangul(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScanJohabHangul(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScanJohabSymbol(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8F(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA2(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA3(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA4(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA5(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA6(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA7(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCnSAlways8BytesDecomposedHangul(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScanJohabHangul(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
PRIVATE PRBool uCheckAndScanJohabSymbol(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uCheckAndScan4BytesGB18030(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
|
||||
PRIVATE PRBool uCheckAndScan4BytesGB18030(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
);
|
||||
int uScanAlways2Byte(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
);
|
||||
int uScanAlways2ByteShiftGR(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
);
|
||||
int uScanAlways1Byte(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
);
|
||||
int uScanAlways1BytePrefix8E(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
);
|
||||
/*=================================================================================
|
||||
|
||||
PRIVATE PRBool uScanAlways2Byte(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
);
|
||||
PRIVATE PRBool uScanAlways2ByteShiftGR(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
);
|
||||
PRIVATE PRBool uScanAlways1Byte(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
);
|
||||
PRIVATE PRBool uScanAlways1BytePrefix8E(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
);
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const uScannerFunc m_scanner[uNumOfCharsetType] =
|
||||
const uScannerFunc m_scanner[uNumOfCharsetType] =
|
||||
{
|
||||
uCheckAndScanAlways1Byte,
|
||||
uCheckAndScanAlways2Byte,
|
||||
@ -190,7 +190,7 @@ PRIVATE const uScannerFunc m_scanner[uNumOfCharsetType] =
|
||||
|
||||
=================================================================================*/
|
||||
|
||||
PRIVATE const uSubScannerFunc m_subscanner[uNumOfCharType] =
|
||||
const uSubScannerFunc m_subscanner[uNumOfCharType] =
|
||||
{
|
||||
uScanAlways1Byte,
|
||||
uScanAlways2Byte,
|
||||
@ -200,111 +200,111 @@ PRIVATE const uSubScannerFunc m_subscanner[uNumOfCharType] =
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
MODULE_PRIVATE PRBool uScan(
|
||||
uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uScan(
|
||||
uScanClassID scanClass,
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
return (* m_scanner[scanClass]) (state,in,out,inbuflen,inscanlen);
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uScanAlways1Byte(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
)
|
||||
int uScanAlways1Byte(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
)
|
||||
{
|
||||
*out = (uint16_t) in[0];
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uScanAlways2Byte(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
)
|
||||
int uScanAlways2Byte(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
)
|
||||
{
|
||||
*out = (uint16_t) (( in[0] << 8) | (in[1]));
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uScanAlways2ByteShiftGR(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
)
|
||||
int uScanAlways2ByteShiftGR(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
)
|
||||
{
|
||||
*out = (uint16_t) ((( in[0] << 8) | (in[1])) & 0x7F7F);
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uScanAlways1BytePrefix8E(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
)
|
||||
int uScanAlways1BytePrefix8E(
|
||||
unsigned char* in,
|
||||
uint16_t* out
|
||||
)
|
||||
{
|
||||
*out = (uint16_t) in[1];
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScanAlways1Byte(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScanAlways1Byte(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
/* Don't check inlen. The caller should ensure it is larger than 0 */
|
||||
*inscanlen = 1;
|
||||
*out = (uint16_t) in[0];
|
||||
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScanAlways2Byte(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScanAlways2Byte(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
if(inbuflen < 2)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*inscanlen = 2;
|
||||
*out = ((in[0] << 8) | ( in[1])) ;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScanAlways2ByteShiftGR(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScanAlways2ByteShiftGR(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
/*
|
||||
* Both bytes should be in the range of [0xa1,0xfe] for 94x94 character sets
|
||||
@ -313,30 +313,30 @@ PRIVATE PRBool uCheckAndScanAlways2ByteShiftGR(
|
||||
* 1st byte is checked before calling this in nsUnicodeDecoerHelper.cpp
|
||||
*/
|
||||
if(inbuflen < 2) /* will lead to NS_OK_UDEC_MOREINPUT */
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else if (! CHK_GR94(in[1]))
|
||||
{
|
||||
*inscanlen = 2;
|
||||
*out = 0xFF; /* for 2-byte table, uMap() is guaranteed to fail for 0xFF. */
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*inscanlen = 2;
|
||||
*out = (((in[0] << 8) | ( in[1])) & 0x7F7F);
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScanAlways2ByteGR128(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScanAlways2ByteGR128(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
/*
|
||||
* The first byte should be in [0xa1,0xfe]
|
||||
@ -346,31 +346,31 @@ PRIVATE PRBool uCheckAndScanAlways2ByteGR128(
|
||||
* 1st byte is checked before calling this in nsUnicodeDecoderHelper.cpp
|
||||
*/
|
||||
if(inbuflen < 2) /* will lead to NS_OK_UDEC_MOREINPUT */
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else if (in[1] < 0x41) /* 2nd byte range check */
|
||||
{
|
||||
*inscanlen = 2;
|
||||
*out = 0xFF; /* for 2-byte table, uMap() is guaranteed to fail for 0xFF. */
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*inscanlen = 2;
|
||||
*out = (in[0] << 8) | in[1];
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uScanShift(
|
||||
uShiftInTable *shift,
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uScanShift(
|
||||
uShiftInTable *shift,
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
int16_t i;
|
||||
const uShiftInCell* cell = &(shift->shiftcell[0]);
|
||||
@ -381,7 +381,7 @@ PRIVATE PRBool uScanShift(
|
||||
( in[0] <= cell[i].shiftin_Max))
|
||||
{
|
||||
if(inbuflen < cell[i].reserveLen)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
*inscanlen = cell[i].reserveLen;
|
||||
@ -389,38 +389,38 @@ PRIVATE PRBool uScanShift(
|
||||
}
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8F(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScan2ByteGRPrefix8F(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
if((inbuflen < 3) ||(in[0] != 0x8F))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else if (! CHK_GR94(in[1])) /* 2nd byte range check */
|
||||
{
|
||||
*inscanlen = 2;
|
||||
*out = 0xFF; /* for 2-byte table, uMap() is guaranteed to fail for 0xFF. */
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
else if (! CHK_GR94(in[2])) /* 3rd byte range check */
|
||||
{
|
||||
*inscanlen = 3;
|
||||
*out = 0xFF; /* for 2-byte table, uMap() is guaranteed to fail for 0xFF. */
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*inscanlen = 3;
|
||||
*out = (((in[1] << 8) | ( in[2])) & 0x7F7F);
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
@ -432,39 +432,39 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8F(
|
||||
*/
|
||||
#define CNS_8EAX_4BYTE(PREFIX) \
|
||||
if((inbuflen < 4) || (in[0] != 0x8E)) \
|
||||
return PR_FALSE; \
|
||||
return 0; \
|
||||
else if((in[1] != (PREFIX))) \
|
||||
{ \
|
||||
*inscanlen = 2; \
|
||||
*out = 0xFF; \
|
||||
return PR_TRUE; \
|
||||
return 1; \
|
||||
} \
|
||||
else if(! CHK_GR94(in[2])) \
|
||||
{ \
|
||||
*inscanlen = 3; \
|
||||
*out = 0xFF; \
|
||||
return PR_TRUE; \
|
||||
return 1; \
|
||||
} \
|
||||
else if(! CHK_GR94(in[3])) \
|
||||
{ \
|
||||
*inscanlen = 4; \
|
||||
*out = 0xFF; \
|
||||
return PR_TRUE; \
|
||||
return 1; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
*inscanlen = 4; \
|
||||
*out = (((in[2] << 8) | ( in[3])) & 0x7F7F); \
|
||||
return PR_TRUE; \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA2(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScan2ByteGRPrefix8EA2(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
CNS_8EAX_4BYTE(0xA2)
|
||||
}
|
||||
@ -472,65 +472,65 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA2(
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA3(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScan2ByteGRPrefix8EA3(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
CNS_8EAX_4BYTE(0xA3)
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA4(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScan2ByteGRPrefix8EA4(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
CNS_8EAX_4BYTE(0xA4)
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA5(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScan2ByteGRPrefix8EA5(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
CNS_8EAX_4BYTE(0xA5)
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA6(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScan2ByteGRPrefix8EA6(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
CNS_8EAX_4BYTE(0xA6)
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA7(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScan2ByteGRPrefix8EA7(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
CNS_8EAX_4BYTE(0xA7)
|
||||
}
|
||||
@ -544,24 +544,24 @@ PRIVATE PRBool uCheckAndScan2ByteGRPrefix8EA7(
|
||||
#define TCount 28
|
||||
#define NCount (VCount * TCount)
|
||||
|
||||
PRIVATE PRBool uCnSAlways8BytesDecomposedHangul(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCnSAlways8BytesDecomposedHangul(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
|
||||
uint16_t LIndex, VIndex, TIndex;
|
||||
/* no 8 bytes, not in a4 range, or the first 2 byte are not a4d4 */
|
||||
if((inbuflen < 8) || (0xa4 != in[0]) || (0xd4 != in[1]) ||
|
||||
(0xa4 != in[2] ) || (0xa4 != in[4]) || (0xa4 != in[6]))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
|
||||
/* Compute LIndex */
|
||||
if((in[3] < 0xa1) || (in[3] > 0xbe)) { /* illegal leading consonant */
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
static const uint8_t lMap[] = {
|
||||
@ -577,12 +577,12 @@ PRIVATE PRBool uCnSAlways8BytesDecomposedHangul(
|
||||
|
||||
LIndex = lMap[in[3] - 0xa1];
|
||||
if(0xff == (0xff & LIndex))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compute VIndex */
|
||||
if((in[5] < 0xbf) || (in[5] > 0xd3)) { /* illegal medial vowel */
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
VIndex = in[5] - 0xbf;
|
||||
@ -594,7 +594,7 @@ PRIVATE PRBool uCnSAlways8BytesDecomposedHangul(
|
||||
TIndex = 0;
|
||||
}
|
||||
else if((in[7] < 0xa1) || (in[7] > 0xbe)) {/* illegal trailing consonant */
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
static const uint8_t tMap[] = {
|
||||
@ -609,31 +609,31 @@ PRIVATE PRBool uCnSAlways8BytesDecomposedHangul(
|
||||
};
|
||||
TIndex = tMap[in[7] - 0xa1];
|
||||
if(0xff == (0xff & TIndex))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*inscanlen = 8;
|
||||
/* the following line is from Unicode 2.0 page 3-13 item 5 */
|
||||
*out = ( LIndex * VCount + VIndex) * TCount + TIndex + SBase;
|
||||
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
|
||||
PRIVATE PRBool uCheckAndScanJohabHangul(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScanJohabHangul(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
/* since we don't have code to convert Johab to Unicode right now *
|
||||
* make this part of code #if 0 to save space until we fully test it */
|
||||
if(inbuflen < 2)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else {
|
||||
/*
|
||||
* See Table 4-45 Johab Encoding's Five-Bit Binary Patterns in page 183
|
||||
@ -660,30 +660,30 @@ PRIVATE PRBool uCheckAndScanJohabHangul(
|
||||
uint16_t ch = (in[0] << 8) | in[1];
|
||||
uint16_t LIndex, VIndex, TIndex;
|
||||
if(0 == (0x8000 & ch))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
LIndex=lMap[(ch>>10)& 0x1F];
|
||||
VIndex=vMap[(ch>>5) & 0x1F];
|
||||
TIndex=tMap[(ch>>0) & 0x1F];
|
||||
if((0xff==(LIndex)) ||
|
||||
(0xff==(VIndex)) ||
|
||||
(0xff==(TIndex)))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
/* the following line is from Unicode 2.0 page 3-13 item 5 */
|
||||
*out = ( LIndex * VCount + VIndex) * TCount + TIndex + SBase;
|
||||
*inscanlen = 2;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
PRIVATE PRBool uCheckAndScanJohabSymbol(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScanJohabSymbol(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
if(inbuflen < 2)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
else {
|
||||
/*
|
||||
* The following code are based on the Perl code lised under
|
||||
@ -726,34 +726,34 @@ PRIVATE PRBool uCheckAndScanJohabSymbol(
|
||||
(lo - ((lo < 161) ? ((lo > 126) ? 34 : 16) :
|
||||
128));
|
||||
*inscanlen = 2;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
PRIVATE PRBool uCheckAndScan4BytesGB18030(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
int uCheckAndScan4BytesGB18030(
|
||||
int32_t* state,
|
||||
unsigned char *in,
|
||||
uint16_t *out,
|
||||
uint32_t inbuflen,
|
||||
uint32_t* inscanlen
|
||||
)
|
||||
{
|
||||
uint32_t data;
|
||||
if(inbuflen < 4)
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
|
||||
if((in[0] < 0x81 ) || (0xfe < in[0]))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
if((in[1] < 0x30 ) || (0x39 < in[1]))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
if((in[2] < 0x81 ) || (0xfe < in[2]))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
if((in[3] < 0x30 ) || (0x39 < in[3]))
|
||||
return PR_FALSE;
|
||||
return 0;
|
||||
|
||||
data = (((((in[0] - 0x81) * 10 + (in[1] - 0x30)) * 126) +
|
||||
(in[2] - 0x81)) * 10 ) + (in[3] - 0x30);
|
||||
|
||||
*inscanlen = 4;
|
||||
*out = (data < 0x00010000) ? data : 0xFFFD;
|
||||
return PR_TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user