1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0011758: TCollection strings are not memory safe as reported by Purify

Custom string handling code enabled by OptJr macro removed from implementation of strings in TCollection and elsewhere.
Functions from string.h are used instead of macros from Standard_String.hxx
File Standard_String.hxx and methods ISSIMILAR and HASHCODE of TCollection*String classes are removed (to be replaced by strcasecmp).
Functions HashCode for strings reimplemented using DJB2 algorithm for C strings and SDBM algorithm for extended strings.
Adding test cases and draw-command for issue CR11758
Fix misprint added with previous integration
Fix misprint in the test command.
Remove compilation warnings (Linux).
Avoid compiler warning "dereferencing type-punned pointer will break strict-aliasing rules" on Linux
This commit is contained in:
vsr
2013-08-22 11:21:09 +04:00
committed by bugmaster
parent 80cd454f1d
commit 29cb310ae9
18 changed files with 744 additions and 2414 deletions

View File

@@ -50,7 +50,6 @@ Standard_ShallowDump.cxx
Standard_ShortReal.cxx
Standard_ShortReal.hxx
Standard_Stream.hxx
Standard_String.hxx
Standard_Time.cxx
Standard_Time.hxx
Standard_Transient.hxx

View File

@@ -25,31 +25,10 @@
#define _Standard_CString_SourceFile
#define OptJr 1
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Standard_CLocaleSentry.hxx>
#include <Standard_CString.hxx>
#include <Standard_Type.hxx>
#include <Standard_OStream.hxx>
#if OptJr
# if defined(WORDS_BIGENDIAN)
static const Standard_Integer static_MaskEndIntegerString[4] = { 0x00000000 ,
0xff000000 ,
0xffff0000 ,
0xffffff00 } ;
# else
static const Standard_Integer static_MaskEndIntegerString[4] = { 0x00000000 ,
0x000000ff ,
0x0000ffff ,
0x00ffffff } ;
# endif
#endif
#include <Standard_String.hxx>
#include <string.h>
#include <stdarg.h>
@@ -76,186 +55,32 @@ Standard_EXPORT void ShallowDump (const Standard_CString Value, Standard_OStream
Standard_Integer HashCode (const Standard_CString Value,
const Standard_Integer Upper )
{
Standard_Integer aLen ;
//#if OptJr
//STRINGLEN( Value , aLen ) ;
//#else
aLen = (Standard_Integer)strlen(Value);
//#endif
return HashCode ( HashCodes( Value , aLen ) , Upper ) ;
Standard_Integer aLen = (Standard_Integer)strlen(Value);
return HashCode (HashCodes (Value, aLen), Upper);
}
#if OptJr
# if defined(WORDS_BIGENDIAN)
static Standard_Integer Standard_Mask_String_Left[4] =
{ 0 , 0x00ffffff , 0x0000ffff , 0x000000ff } ;
static Standard_Integer Standard_Mask_String_Right[4] =
{ 0 , 0xff000000 , 0xffff0000 , 0xffffff00 } ;
# else
static Standard_Integer Standard_Mask_String_Left[4] =
{ 0 , 0xffffff00 , 0xffff0000 , 0xff000000 } ;
static Standard_Integer Standard_Mask_String_Right[4] =
{ 0 , 0x000000ff , 0x0000ffff , 0x00ffffff } ;
# endif
#endif
//============================================================================
//==== HashCode of a CString
//============================================================================
Standard_Integer HashCodes (const Standard_CString Value ,
const Standard_Integer Len )
Standard_Integer HashCodes (const Standard_CString Value,
const Standard_Integer Len)
{
Standard_Integer aHashCode = 0 ;
Standard_Integer i ;
#if !OptJr
char *charPtr = (char *)Value;
Standard_Integer pos = 0,
count,
*tmphash;
char tabchar[20];
#endif
// compute DJB2 hash of a string
Standard_Integer hash = 0;
const Standard_Character *c = Value;
for (Standard_Integer i = 0; i < Len; i++, c++)
{
/* hash = hash * 33 ^ c */
hash = ((hash << 5) + hash) ^ (*c);
}
if (Value != NULL) {
#if !OptJr
i = 0 ;
while (i < Len) {
for (count = 0,pos = i;count < sizeof(Standard_Integer); count++) {
if (pos + count >= Len) tabchar[count] = '\0';
else tabchar[count] = charPtr[pos + count];
i++;
}
tmphash = (Standard_Integer *)tabchar;
aHashCode = aHashCode ^ *tmphash;
}
}
#else
Standard_Integer *value = (Standard_Integer *)(ptrdiff_t(Value) & ~0x3) ;
Standard_Integer len = Len ;
unsigned int aResidue = (unsigned int)(ptrdiff_t(Value) & 0x3);
if (aResidue) {
aHashCode = *value & Standard_Mask_String_Left[aResidue] ;
value += 1 ;
len -= (4 - aResidue);
}
for ( i = 1 ; i <= len >> 2 ; i++ ) {
aHashCode = aHashCode ^ value[ i - 1 ] ;
}
aHashCode = aHashCode ^ ( value[ i - 1 ] &
Standard_Mask_String_Right[ len & 3 ] ) ;
if ( len != Len ) {
# if defined(WORDS_BIGENDIAN)
aHashCode = aHashCode << 8*aResidue |
aHashCode >> 8*(4 - aResidue) ;
# else
aHashCode = aHashCode << 8*(4 - aResidue) |
aHashCode >> 8*aResidue ;
# endif
}
}
#endif
return aHashCode ;
return hash;
}
# if defined(WORDS_BIGENDIAN)
static Standard_Integer Standard_Mask_Upper_Lower[5] =
{ 0 , 0xdf000000 , 0xdfdf0000 , 0xdfdfdf00 , 0xdfdfdfdf } ;
#else
static Standard_Integer Standard_Mask_Upper_Lower[5] =
{ 0 , 0xdf , 0xdfdf , 0xdfdfdf , 0xdfdfdfdf } ;
#endif
//============================================================================
//==== HashCode of a CString with discard of bit 5 (UpperCase<-->LowerCase)
// Efficient for Types and MethodNames (without copy of characters)
// Valid if we have only alphanumeric characters and "_" (unicity)
// Valid if the Strings address is aligned for Integers
//============================================================================
Standard_Integer HASHCODES (const Standard_CString Value ,
const Standard_Integer Len )
{
Standard_Integer aHashCode = 0 ;
Standard_Integer i = 0 ;
if (Value != NULL) {
#ifdef ALIGNMENT_BUG
for ( i = 1 ; i <= Len >> 2 ; i++ ) {
aHashCode = aHashCode ^
( ((Standard_Integer *) Value ) [ i - 1 ] &
Standard_Mask_Upper_Lower[4] ) ;
}
aHashCode = aHashCode ^
( ((Standard_Integer *) Value ) [ i - 1 ] &
Standard_Mask_Upper_Lower[ Len & 3 ] ) ;
#else
Standard_Integer itmp = 0 ;
for ( i = 0 ; i <= Len-4 ; i+=4 ) {
memcpy(&itmp,(const void *)&Value[i],4);
aHashCode=aHashCode^(itmp&Standard_Mask_Upper_Lower[4]);
}
if (Len&3) {
memcpy(&itmp,(const void *)&Value[i],Len&3);
aHashCode=aHashCode^(itmp&Standard_Mask_Upper_Lower[Len&3]);
}
#endif
}
return aHashCode ;
}
//============================================================================
// IsEqual : Returns Standard_True if two CString have the same value
// Comparison is done with discard of bit 5 (UpperCase<-->LowerCase)
// Efficient for Types and MethodNames (without copy of characters)
// Valid if we have only alphanumeric characters and "_" (unicity)
// Valid if the Strings address are aligned for Integers
//============================================================================
Standard_Boolean ISSIMILAR(const Standard_CString One ,
const Standard_Integer LenOne ,
const Standard_CString Two )
{
Standard_Integer i ;
#ifdef ALIGNMENT_BUG
for ( i = 1 ; i <= LenOne >> 2 ; i++ ) {
if ( (((Standard_Integer *) One ) [ i - 1 ] &
Standard_Mask_Upper_Lower[ 4 ] ) !=
(((Standard_Integer *) Two ) [ i - 1 ] &
Standard_Mask_Upper_Lower[ 4 ] ) )
return Standard_False ;
}
if ( (((Standard_Integer *) One ) [ i - 1 ] &
Standard_Mask_Upper_Lower[ LenOne & 3 ] ) !=
(((Standard_Integer *) Two ) [ i - 1 ] &
Standard_Mask_Upper_Lower[ LenOne & 3 ] ) )
return Standard_False ;
#else
Standard_Integer iOne, iTwo ;
for ( i = 0; i <= LenOne-4; i+=4 ) {
memcpy(&iOne,(const void *)&One[i],4);
memcpy(&iTwo,(const void *)&Two[i],4);
if ((iOne&Standard_Mask_Upper_Lower[4] ) !=
(iTwo&Standard_Mask_Upper_Lower[4]))
return Standard_False;
}
if(LenOne&3) {
memcpy(&iOne,(const void *)&One[i],4);
memcpy(&iTwo,(const void *)&Two[i],4);
if ( (iOne&Standard_Mask_Upper_Lower[LenOne&3]) !=
(iTwo&Standard_Mask_Upper_Lower[LenOne&3]))
return Standard_False;
}
#endif
return Standard_True ;
}
//======================================================================
// Locale-independent equivalents of C functions dealing with conversion
// of string to real and vice-versa
//======================================================================
#ifdef __APPLE__
// There are a lot of *_l functions availalbe on Mac OS X - we use them

View File

@@ -63,22 +63,6 @@ inline Standard_Integer HashCode (const Standard_CString,
Standard_Integer& );
Standard_Integer HashCodes (const Standard_CString ,
const Standard_Integer );
inline Standard_Boolean ISEQUAL(const Standard_CString One ,
const Standard_Integer LenOne ,
const Standard_CString Two,
const Standard_Integer LenTwo );
__Standard_API Standard_Boolean ISSIMILAR(const Standard_CString One ,
const Standard_Integer Len ,
const Standard_CString Two );
inline Standard_Integer HASHCODE (const Standard_CString,
const Standard_Integer,
const Standard_Integer);
inline Standard_Integer HASHCODE (const Standard_CString,
const Standard_Integer,
const Standard_Integer ,
Standard_Integer& );
__Standard_API Standard_Integer HASHCODES (const Standard_CString,
const Standard_Integer);
//! Equivalents of functions from standard C library that use always C locale
__Standard_API double Atof (const char* theStr);
@@ -130,52 +114,4 @@ inline Standard_Integer HashCode (const Standard_CString Value,
return HashCode( (Standard_Integer) HashCodes( Value , Len ) , Upper ) ;
}
//============================================================================
//==== HashCode of CString converted to uppercase. Returns the HashCode itself
//==== and the HashCode % Upper
//============================================================================
inline Standard_Integer HASHCODE (const Standard_CString Value,
const Standard_Integer Len ,
const Standard_Integer Upper ,
Standard_Integer& aHashCode )
{
aHashCode = HASHCODES( Value , Len );
// return (Abs( aHashCode ) % Upper ) + 1 ;
return HashCode( (Standard_Integer) aHashCode , Upper ) ;
}
//============================================================================
//==== HashCode of a CString converted to uppercase
//============================================================================
inline Standard_Integer HASHCODE (const Standard_CString Value,
const Standard_Integer Len ,
const Standard_Integer Upper)
{
// return (Abs( HASHCODES( Value , Len ) ) % Upper ) + 1 ;
return HashCode( (Standard_Integer) HASHCODES( Value , Len ) , Upper ) ;
}
//============================================================================
// IsEqual : Returns Standard_True if two CString have the same value
// Comparison is done with discard of bit 5 (UpperCase<-->LowerCase)
// Efficient for Types and MethodNames (without copy of characters)
// Valid if we have only alphanumeric characters and "_" (unicity)
// Valid if the Strings address are aligned for Integers
//============================================================================
inline Standard_Boolean ISEQUAL(const Standard_CString One ,
const Standard_Integer LenOne ,
const Standard_CString Two,
const Standard_Integer LenTwo )
{
if ( One == Two )
return Standard_True ;
if ( LenOne != LenTwo )
return Standard_False ;
return ISSIMILAR( One , LenOne , Two ) ;
}
#endif

View File

@@ -20,11 +20,8 @@
# include <config.h>
#endif
#define OptJr 1
#include <Standard_ExtString.hxx>
#include <Standard_Type.hxx>
#include <Standard_String.hxx>
#ifndef _Standard_OStream_HeaderFile
#include <Standard_OStream.hxx>
#endif
@@ -48,78 +45,13 @@ const Handle_Standard_Type& Standard_ExtString_Type_()
Standard_Integer HashCode (const Standard_ExtString Value,
const Standard_Integer Upper)
{
Standard_Integer aHashCode ;
Standard_Integer i = 0 ;
#if OptJr
Standard_ExtString aValue ;
// cout << "HashCode " << hex << Value << dec << endl ;
if ((ptrdiff_t(Value) & 3 ) == 2) {
aHashCode = Value[ 0 ] ;
#if defined(WNT) || defined(DECOSF1) || defined(LININTEL) || defined(__FreeBSD__)
aHashCode = aHashCode << 16 ;
#endif
aValue = &Value[1] ;
}
else {
aHashCode = 0 ;
aValue = Value ;
// compute SDBM hash of an ext string
Standard_Integer hash = 0;
for (const Standard_ExtCharacter *c = Value; *c; c++)
{
/* hash = hash * 33 ^ c */
hash = (*c) + (hash << 6) + (hash << 16) - hash;
}
while ( ExtStringTestOfZero(((Standard_Integer *) aValue ) [ i ] ) ) {
// cout << i << " " << hex << aHashCode << " " << ((Standard_Integer *) aValue )[i]
// << dec << endl ;
aHashCode = aHashCode ^ ((Standard_Integer *) aValue ) [ i++ ] ;
}
while ( aValue[ i << 1 ] != 0 && aValue[( i << 1 ) + 1 ] != 0 ) {
// cout << i << " " << hex << aHashCode << " " << ((Standard_Integer *) aValue )[i]
// << dec << endl ;
aHashCode = aHashCode ^ ((Standard_Integer *) aValue ) [ i++ ] ;
}
if ( aValue[ i << 1 ] != 0 ) {
// cout << i << " " << hex << aHashCode << dec << endl ;
aHashCode = aHashCode ^ ((Standard_Integer *) aValue ) [ i ] ;
}
if ((ptrdiff_t(Value ) & 3) == 2) {
// cout << hex << aHashCode << dec << endl ;
aHashCode = (( aHashCode >> 16 ) & 0x0000ffff ) |
(( aHashCode << 16 ) & 0xffff0000 ) ;
}
// cout << i << " " << hex << aHashCode << dec << endl ;
#else
char* charPtr = (char *)Value;
Standard_Integer pos = 0,
count,
*tmphash,
isend = 0;
char tabchar[20];
aHashCode = 0 ;
if (Value != NULL) {
while(charPtr[i] != 0 || charPtr[i + 1] != 0) {
for (count = 0,pos = i; count < sizeof(Standard_Integer); count += 2) {
if (charPtr[pos + count] == 0 && charPtr[pos + count + 1] == 0 || isend == 1) {
isend = 1;
tabchar[count] = '\0';
tabchar[count + 1] = '\0';
}
else {
tabchar[count] = charPtr[pos + count];
tabchar[count + 1] = charPtr[pos + count + 1];
}
i += 2;
}
tmphash = (Standard_Integer *)tabchar;
aHashCode = aHashCode ^ *tmphash;
}
}
#endif
aHashCode = HashCode(aHashCode , Upper) ;
return aHashCode ;
return HashCode (hash, Upper);
}

View File

@@ -1,906 +0,0 @@
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#ifndef _Standard_String_HeaderFile
# define _Standard_String_HeaderFile
# ifndef _Standard_TypeDef_HeaderFile
# include <Standard_TypeDef.hxx>
# endif
#define INF(X,Y) (((X)<(Y))?(X):(Y))
# if OptJr
#define STRLEN(s,i) {(i) = 0;while((s)[(i)++] != '\0');(i)--;}
#define EXTSTRLEN(s,i) {(i) = 0;while((s)[(i)++] != 0);(i)--;}
#define STRCPY(s1,s2,i) {for(LoopIndex=0; LoopIndex<(i); LoopIndex++)(s1)[LoopIndex] = (s2)[LoopIndex];}
#define STRCAT(s1,i,s2,j) {for(LoopIndex=0; LoopIndex<(j); LoopIndex++) (s1)[(i)+LoopIndex] = (s2)[LoopIndex];}
//# ifdef __Standard_DLL
# ifdef _Standard_CString_SourceFile
__Standard_API const Standard_Integer *MaskEndIntegerString = static_MaskEndIntegerString ;
# else
__Standard_APIEXTERN const Standard_Integer *MaskEndIntegerString ;
# endif
//# else
//Standard_IMPORT const Standard_Integer *MaskEndIntegerString ;
//# endif
// JR 16-jul-1998
// Algorithme utilise pour le calcul des longueurs de strings
// Je suppose que les octets sont de l'ascii 7 bits.
// Si un des octets d'un mot est a zero et si on soustrait 0x01010101 a ce
// mot, l'octet a zero change de signe.
// Reciproquement si (( Word - 0x01010101 ) & 0x80808080 ) != 0
// alors Word a un octet a zero.
// Si on a des octets negatifs et si on applique le resultat ci-dessus a
// ( Word & 0x7f7f7f7f ), cela sera vrai sauf si un des octets vaut 0x80
// auquel cas on trouvera un octet a zero a tort.
// Conclusion : il suffit de controler la presence d'un octet a zero a partir
// du debut du mot ou l'on croira en avoir trouve un pour traiter
// correctement les octets qui valent 0x80.
// La meme chose est vraie pour les extendedstrings.
// D'autre part afin d'accelerer les traitements, on teste si les chaines
// sont alignees sur des mots de 32 bits ( AND de l'adresse avec 3 ) ou
// sont alignees sur des shorts de 16 bits ( AND de l'adresse avec 1 ).
inline Standard_Boolean CStringTestOfZero(const Standard_Integer aString )
{
return ( ((( aString & 0x7f7f7f7f ) - \
0x01010101 ) & 0x80808080 ) == 0 ) ;
}
inline Standard_Boolean HalfCStringTestOfZero(const Standard_ExtCharacter anExtCharacter )
{
return ( ((( anExtCharacter & 0x7f7f ) - 0x0101 ) & 0x8080 ) == 0 ) ;
}
inline Standard_Boolean ExtStringTestOfZero(const Standard_Integer anExtString )
{
return ( ((( anExtString & 0x7fff7fff ) - \
0x00010001 ) & 0x80008000 ) == 0 ) ;
}
#define STRINGLEN( aString , LoopIndex ) { \
if ((ptrdiff_t(aString) & 1) == 0) { \
LoopIndex = 0 ; \
if ((ptrdiff_t(aString) & 3) == 0) { \
while (CStringTestOfZero(((Standard_Integer *)aString)[LoopIndex++])); \
LoopIndex = ( LoopIndex << 2 ) - 4 ; \
} \
else { \
while (HalfCStringTestOfZero(((Standard_ExtCharacter *)aString)[LoopIndex++])); \
LoopIndex = ( LoopIndex << 1 ) - 2 ; \
} \
while (aString[LoopIndex++] != '\0'); \
LoopIndex -= 1 ; \
} \
else \
STRLEN( aString , LoopIndex ) ; \
}
#define EXTSTRINGLEN( anExtString , LoopIndex ) { \
if ((ptrdiff_t(anExtString) & 3) == 0) { \
LoopIndex = 0 ; \
while (ExtStringTestOfZero(((Standard_Integer *)anExtString)[LoopIndex++]));\
LoopIndex = ( LoopIndex << 1 ) - 2 ; \
if ( anExtString[ LoopIndex ] != 0 ) \
LoopIndex += 1 ; \
} \
else \
EXTSTRLEN( anExtString , LoopIndex ) ; \
}
// aStringOut is an AsciiString and is word aligned
// aStringIn is a CString and may be not word aligned
#define CSTRINGCOPY( aStringOut , aStringIn , aStringLen ) { \
Standard_Integer LoopIndex = (Standard_Integer)(ptrdiff_t(aStringIn) & 3) ; \
if ( ( LoopIndex & 1 ) == 0 ) { \
if ( LoopIndex == 0 ) { \
for (; LoopIndex <= ( aStringLen >> 2 ) ; LoopIndex++ ) { \
((Standard_Integer *) aStringOut )[ LoopIndex ] = \
((Standard_Integer *) aStringIn )[ LoopIndex ] ; \
} \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex <= ( aStringLen >> 1) ; LoopIndex++ ) { \
((Standard_ExtCharacter *) aStringOut )[ LoopIndex ] = \
((Standard_ExtCharacter *) aStringIn )[ LoopIndex ] ; \
} \
} \
} \
else \
STRCPY( aStringOut , aStringIn , aStringLen + 1 ) ; \
}
// aStringOut is an AsciiString and is word aligned
// aStringIn is an AsciiString and is word aligned
#define ASCIISTRINGCOPY( aStringOut , aStringIn , aStringLen ) { \
Standard_Integer LoopIndex ; \
LoopIndex = 0 ; \
for(; LoopIndex <= ( aStringLen >> 2 ) ; LoopIndex++ ) { \
((Standard_Integer *) aStringOut )[ LoopIndex ] = \
((Standard_Integer *) aStringIn )[ LoopIndex ] ; \
} \
}
#define STRINGCAT( aStringOut , aStringOutLen , aStringIn , aStringInLen ) { \
Standard_Integer LoopIndex ; \
if ((ptrdiff_t(&aStringOut[ aStringOutLen ]) & 1) == 0 && \
(ptrdiff_t(aStringIn) & 1 ) == 0 ) { \
LoopIndex = 0 ; \
if ((ptrdiff_t(&aStringOut[ aStringOutLen ]) & 3 ) == 0 && \
(ptrdiff_t(aStringIn) & 3 ) == 0 ) { \
for (; LoopIndex <= ( aStringInLen >> 2 ) ; LoopIndex++ ) { \
((Standard_Integer *) aStringOut )[ ( aStringOutLen >> 2 ) + \
LoopIndex ] = ((Standard_Integer *) aStringIn )[ LoopIndex ] ; \
} \
} \
else { \
for (; LoopIndex <= ( aStringInLen >> 1 ) ; LoopIndex++ ) { \
((Standard_ExtCharacter *) aStringOut )[ ( aStringOutLen >> 1 ) + \
LoopIndex ] = ((Standard_ExtCharacter *) aStringIn )[ LoopIndex ] ; \
} \
} \
} \
else \
STRCPY( &aStringOut[ aStringOutLen ] , aStringIn , aStringInLen + 1 ) ; \
}
// aString is an AsciiString and is word aligned
// anOtherString is aCString and may be not word aligned
// aStringLen is the length of aString and anOtherString
#define CSTRINGEQUAL( aString , anOtherString , aStringLen , KEqual ) { \
KEqual = Standard_True ; \
Standard_Integer LoopIndex = Standard_Integer(ptrdiff_t(anOtherString) & 3); \
if ( ( LoopIndex & 1 ) == 0 ) { \
if ( LoopIndex == 0 ) { \
for (; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
if (((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
if ( KEqual == Standard_True && \
(((Standard_Integer *) aString )[ LoopIndex ] & \
MaskEndIntegerString[ aStringLen & 3 ]) != \
(((Standard_Integer *) anOtherString )[ LoopIndex ] & \
MaskEndIntegerString[ aStringLen & 3 ] ) ) \
KEqual = Standard_False ; \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex < (( aStringLen + 1) >> 1) ; LoopIndex++ ) { \
if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
} \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
} \
}
// aString is an AsciiString and is word aligned
// anOtherString is aCString and may be not word aligned
// aStringLen is the length of aString.
// The length of anOtherString is unknown
#define LCSTRINGEQUAL( aString , aStringLen , anOtherString , KEqual ) { \
KEqual = Standard_True ; \
Standard_Integer LoopIndex = Standard_Integer(ptrdiff_t(anOtherString) & 3); \
if ( ( LoopIndex & 1 ) == 0 ) { \
if ( LoopIndex == 0 ) { \
for (; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
if (((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex << 2) ; \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex < (( aStringLen + 1) >> 1) ; LoopIndex++ ) { \
if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex << 1) ; \
} \
if ( KEqual ) { \
for (; LoopIndex <= aStringLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
} \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex <= aStringLen ; LoopIndex++ ) { \
if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
} \
}
// aString is an AsciiString and is word aligned
// anOtherString is an AsciiString and is word aligned
#define ASCIISTRINGEQUAL( aString , anOtherString , aStringLen , KEqual ) { \
Standard_Integer LoopIndex ; \
KEqual = Standard_True ; \
LoopIndex = 0 ; \
for(; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
if ( KEqual == Standard_True && \
(((Standard_Integer *) aString )[ LoopIndex ] & \
MaskEndIntegerString[ aStringLen & 3 ]) != \
(((Standard_Integer *) anOtherString )[ LoopIndex ] & \
MaskEndIntegerString[ aStringLen & 3 ] ) ) \
KEqual = Standard_False ; \
}
// aString is an AsciiString and is word aligned
// anOtherString is aCString and may be not word aligned
#define CSTRINGLESS( aString , aStringLen , anOtherString , \
anOtherStringLen , MinLen , KLess ) { \
Standard_Integer LoopIndex ; \
KLess = Standard_True ; \
LoopIndex = ptrdiff_t(anOtherString) & 3 ; \
if ( ( LoopIndex & 1 ) == 0 && MinLen > 3 ) { \
if ( LoopIndex == 0 ) { \
for (; LoopIndex < ( MinLen >> 2 ) ; LoopIndex++ ) { \
if (((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 2 ; \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex < ( MinLen >> 1 ) ; LoopIndex++ ) { \
if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
} \
else \
LoopIndex = 0 ; \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
KLess = Standard_False ; \
} \
else if ( aStringLen >= anOtherStringLen ) \
KLess = Standard_False ; \
}
// aString is an AsciiString and is word aligned
// anOtherString is aCString and may be not word aligned
// aStringLen is the length of aString
// The length of anOtherString is unknown
#define LCSTRINGLESS( aString , aStringLen , anOtherString , KLess ) { \
KLess = Standard_True ; \
Standard_Integer LoopIndex = Standard_Integer(ptrdiff_t(anOtherString) & 3); \
if ( ( LoopIndex & 1 ) == 0 && aStringLen > 3 ) { \
if ( LoopIndex == 0 ) { \
for (; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
if (((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 2 ; \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
} \
else \
LoopIndex = 0 ; \
for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != aStringLen ) { \
if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
KLess = Standard_False ; \
} \
else if ( anOtherString[ LoopIndex ] == '\0' ) \
KLess = Standard_False ; \
}
// aString is an AsciiString and is word aligned
// anOtherString is an AsciiString and is word aligned
#define ASCIISTRINGLESS( aString , aStringLen , anOtherString , \
anOtherStringLen , MinLen , KLess ) { \
Standard_Integer LoopIndex ; \
KLess = Standard_True ; \
LoopIndex = 0 ; \
if ( MinLen > 3 ) { \
for(; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 2 ; \
} \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
KLess = Standard_False ; \
} \
else if ( aStringLen >= anOtherStringLen ) \
KLess = Standard_False ; \
}
// aString is an AsciiString and is word aligned
// anOtherString is aCString and may be not word aligned
#define CSTRINGGREATER( aString , aStringLen , anOtherString , \
anOtherStringLen , MinLen , KGreater ) { \
KGreater = Standard_True ; \
Standard_Integer LoopIndex = Standard_Integer(ptrdiff_t(anOtherString) & 3); \
if ( ( LoopIndex & 1 ) == 0 && MinLen > 3 ) { \
if ( LoopIndex == 0 ) { \
for (; LoopIndex < ( MinLen >> 2 ) ; LoopIndex++ ) { \
if (((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 2 ; \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex < ( MinLen >> 1 ) ; LoopIndex++ ) { \
if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
} \
else \
LoopIndex = 0 ; \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
KGreater = Standard_False ; \
} \
else if ( aStringLen <= anOtherStringLen ) \
KGreater = Standard_False ; \
}
// aString is an AsciiString and is word aligned
// anOtherString is aCString and may be not word aligned
// aStringLen is the length of aString
// The length of anOtherString is unknown
#define LCSTRINGGREATER( aString , aStringLen , anOtherString , KGreater ) { \
Standard_Integer LoopIndex ; \
KGreater = Standard_True ; \
LoopIndex = (Standard_Integer)(ptrdiff_t(anOtherString) & 3) ; \
if ( ( LoopIndex & 1 ) == 0 && aStringLen > 3 ) { \
if ( LoopIndex == 0 ) { \
for (; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
if (((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 2 ; \
} \
else { \
for ( LoopIndex = 0 ; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
if (((Standard_ExtCharacter *) aString )[ LoopIndex ] != \
((Standard_ExtCharacter *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
} \
else \
LoopIndex = 0 ; \
for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != aStringLen ) { \
if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
KGreater = Standard_False ; \
} \
else \
KGreater = Standard_False ; \
}
// aString is an AsciiString and is word aligned
// anOtherString is an AsciiString and is word aligned
#define ASCIISTRINGGREATER( aString , aStringLen , anOtherString , \
anOtherStringLen , MinLen , KGreater ) { \
Standard_Integer LoopIndex ; \
KGreater = Standard_True ; \
LoopIndex = 0 ; \
if ( MinLen > 3 ) { \
for(; LoopIndex < ( aStringLen >> 2 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 2 ; \
} \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
KGreater = Standard_False ; \
} \
else if ( aStringLen <= anOtherStringLen ) \
KGreater = Standard_False ; \
}
// anExtStringOut is an ExtendedString and is word aligned
// anExtStringIn is an ExtString and may be not word aligned
#define EXTSTRINGCOPY( anExtStringOut , anExtStringIn , anExtStringLen ) { \
Standard_Integer LoopIndex ; \
LoopIndex = (Standard_Integer)(ptrdiff_t(anExtStringIn) & 3) ; \
if ( LoopIndex == 0 ) { \
for (; LoopIndex <= ( anExtStringLen >> 1 ) ; LoopIndex++ ) { \
((Standard_Integer *) anExtStringOut )[ LoopIndex ] = \
((Standard_Integer *) anExtStringIn )[ LoopIndex ] ; \
} \
} \
else \
STRCPY( anExtStringOut , anExtStringIn , anExtStringLen + 1 ) ; \
}
// anExtStringOut is an ExtendedString and is word aligned
// anExtStringIn is an ExtendedString and is word aligned
// We copy the ending zero and possibly the ExtCharacter folowing
#define EXTENDEDSTRINGCOPY( anExtStringOut , anExtStringIn , anExtStringLen ) {\
Standard_Integer LoopIndex ; \
for (LoopIndex = 0 ; LoopIndex <= ( anExtStringLen >> 1 ) ; LoopIndex++ ) { \
((Standard_Integer *) anExtStringOut )[ LoopIndex ] = \
((Standard_Integer *) anExtStringIn )[ LoopIndex ] ; \
} \
}
// anExtStringOut is an ExtendedString and is word aligned
// anExtStringIn is an ExtendedString and is word aligned
// We copy the ending zero and possibly the ExtCharacter folowing
#define EXTENDEDSTRINGCAT( anExtStringOut , anExtStringOutLen , anExtStringIn , anExtStringInLen ) {\
Standard_Integer LoopIndex ; \
if ( ( anExtStringOutLen & 1 ) == 0 ) { \
for (LoopIndex = 0 ; LoopIndex <= ( anExtStringInLen >> 1 ) ; LoopIndex++ ) { \
((Standard_Integer *) anExtStringOut )[ ( anExtStringOutLen >> 1 ) + LoopIndex ] = \
((Standard_Integer *) anExtStringIn )[ LoopIndex ] ; \
} \
} \
else { \
STRCAT( anExtStringOut , anExtStringOutLen , anExtStringIn , anExtStringInLen + 1 ) ; \
} \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtString and may be not word aligned
// We compare the last two ExtCharacters or the last ExtCharacter and the
// ending zero if it's word aligned
// aStringLen is the length of aString and anOtherString
#define EXTSTRINGEQUAL( aString , anOtherString , aStringLen , KEqual ) { \
Standard_Integer LoopIndex ; \
KEqual = Standard_True ; \
LoopIndex = 0 ; \
if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
for(; LoopIndex < (( aStringLen + 1) >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
} \
else { \
for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
} \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtString and may be not word aligned
// We compare the last two ExtCharacters or the last ExtCharacter and the
// ending zero if it's word aligned
// aStringLen is the length of aString.
// The length of anOtherString is unknown
#define LEXTSTRINGEQUAL( aString , aStringLen , anOtherString , KEqual ) { \
Standard_Integer LoopIndex ; \
KEqual = Standard_True ; \
LoopIndex = 0 ; \
if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
for(; LoopIndex < (( aStringLen + 1) >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
if ( KEqual && aString [ aStringLen ] != anOtherString [ aStringLen ] ) \
KEqual = Standard_False ; \
} \
else { \
for(; LoopIndex <= aStringLen ; LoopIndex++ ) { \
if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
} \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtendedString and is word aligned
// We compare the last two ExtCharacters or the last ExtCharacter and the
// ending zero
#define EXTENDEDSTRINGEQUAL( aString , anOtherString , aStringLen , KEqual ) { \
Standard_Integer LoopIndex ; \
KEqual = Standard_True ; \
LoopIndex = 0 ; \
for(; LoopIndex < (( aStringLen + 1) >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
KEqual = Standard_False ; \
break ; \
} \
} \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtendedString and may be not word aligned
#define EXTSTRINGLESS( aString , aStringLen , anOtherString , \
anOtherStringLen , MinLen , KLess ) { \
Standard_Integer LoopIndex ; \
KLess = Standard_True ; \
LoopIndex = 0 ; \
if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
if ( MinLen > 1 ) { \
for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
KLess = Standard_False ; \
} \
else if ( aStringLen >= anOtherStringLen ) \
KLess = Standard_False ; \
} \
else { \
if ( MinLen > 1 ) { \
for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = LoopIndex - 1 ; \
} \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
KLess = Standard_False ; \
} \
else if ( aStringLen >= anOtherStringLen ) \
KLess = Standard_False ; \
} \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtendedString and may be not word aligned
// aStringLen is the length of aString
// The length of anOtherString is unknown
#define LEXTSTRINGLESS( aString , aStringLen , anOtherString , KLess ) { \
Standard_Integer LoopIndex ; \
KLess = Standard_True ; \
LoopIndex = 0 ; \
if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
if ( aStringLen > 1 ) { \
for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != aStringLen ) { \
if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
KLess = Standard_False ; \
} \
else if ( anOtherString[ LoopIndex ] == 0 ) \
KLess = Standard_False ; \
} \
else { \
if ( aStringLen > 1 ) { \
for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = LoopIndex - 1 ; \
} \
for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != aStringLen ) { \
if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
KLess = Standard_False ; \
} \
else if ( anOtherString[ LoopIndex ] == 0 ) \
KLess = Standard_False ; \
} \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtendedString and is word aligned
#define EXTENDEDSTRINGLESS( aString , aStringLen , anOtherString , \
anOtherStringLen , MinLen , KLess ) { \
Standard_Integer LoopIndex ; \
KLess = Standard_True ; \
LoopIndex = 0 ; \
if ( MinLen > 1 ) { \
for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] > anOtherString[ LoopIndex ] ) \
KLess = Standard_False ; \
} \
else if ( aStringLen >= anOtherStringLen ) \
KLess = Standard_False ; \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtendedString and may be not word aligned
#define EXTSTRINGGREATER( aString , aStringLen , anOtherString , \
anOtherStringLen , MinLen , KGreater ) { \
Standard_Integer LoopIndex ; \
KGreater = Standard_True ; \
LoopIndex = 0 ; \
if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
if ( MinLen > 1 ) { \
for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
KGreater = Standard_False ; \
} \
else if ( aStringLen <= anOtherStringLen ) \
KGreater = Standard_False ; \
} \
else { \
if ( MinLen > 1 ) { \
for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = LoopIndex - 1 ; \
} \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
KGreater = Standard_False ; \
} \
else if ( aStringLen <= anOtherStringLen ) \
KGreater = Standard_False ; \
} \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtendedString and may be not word aligned
// aStringLen is the length of aString
// The length of anOtherString is unknown
#define LEXTSTRINGGREATER( aString , aStringLen , anOtherString , KGreater ) { \
Standard_Integer LoopIndex ; \
KGreater = Standard_True ; \
LoopIndex = 0 ; \
if ((ptrdiff_t(anOtherString) & 3 ) == 0 ) { \
if ( aStringLen > 1 ) { \
for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != aStringLen ) { \
if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
KGreater = Standard_False ; \
} \
else \
KGreater = Standard_False ; \
} \
else { \
if ( aStringLen > 1 ) { \
for(; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString [ LoopIndex ] != anOtherString [ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = LoopIndex - 1 ; \
} \
for (; LoopIndex < aStringLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != aStringLen ) { \
if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
KGreater = Standard_False ; \
} \
else \
KGreater = Standard_False ; \
} \
}
// aString is an ExtendedString and is word aligned
// anOtherString is an ExtendedString and is word aligned
#define EXTENDEDSTRINGGREATER( aString , aStringLen , anOtherString , \
anOtherStringLen , MinLen , KGreater ) { \
Standard_Integer LoopIndex ; \
KGreater = Standard_True ; \
LoopIndex = 0 ; \
if ( MinLen > 1 ) { \
for(; LoopIndex < ( aStringLen >> 1 ) ; LoopIndex++ ) { \
if ( ((Standard_Integer *) aString )[ LoopIndex ] != \
((Standard_Integer *) anOtherString )[ LoopIndex ] ) { \
LoopIndex++ ; \
break ; \
} \
} \
LoopIndex = ( LoopIndex - 1 ) << 1 ; \
} \
for (; LoopIndex < MinLen ; LoopIndex++ ) { \
if ( aString[ LoopIndex ] != anOtherString[ LoopIndex ] ) \
break ; \
} \
if ( LoopIndex != MinLen ) { \
if ( aString[ LoopIndex ] < anOtherString[ LoopIndex ] ) \
KGreater = Standard_False ; \
} \
else if ( aStringLen <= anOtherStringLen ) \
KGreater = Standard_False ; \
}
# else
#define STRLEN(s,i) {(i) = 0;while((s)[(i)++] != '\0');(i)--;}
#define EXTSTRLEN(s,i) {(i) = 0;while((s)[(i)++] != 0);(i)--;}
#define STRCPY(s1,s2,i) {for(int j=0; j<(i); j++)(s1)[j] = (s2)[j];}
#define STRCAT(s1,i,s2,j) {for(int k=0; k<(j); k++) (s1)[(i)+k] = (s2)[k];}
# endif
#endif