Remove usage of long type from idlib/

Apart from some minor stuff, this changes the signature of some methods
of Parser and Token classes and of the (unused) Random2 class.
That no problem though, because the calling code uses normal ints
anyway.
This commit is contained in:
Daniel Gibson 2012-06-23 01:42:47 +02:00
parent ce87a8904c
commit a9a6042a04
7 changed files with 36 additions and 36 deletions

View file

@ -44,7 +44,7 @@ static const char sixtet_to_base64[] =
void idBase64::Encode( const byte *from, int size ) { void idBase64::Encode( const byte *from, int size ) {
int i, j; int i, j;
unsigned long w; unsigned int w;
byte *to; byte *to;
EnsureAlloced( 4*(size+3)/3 + 2 ); // ratio and padding + trailing \0 EnsureAlloced( 4*(size+3)/3 + 2 ); // ratio and padding + trailing \0
@ -94,7 +94,7 @@ idBase64::Decode
============ ============
*/ */
int idBase64::Decode( byte *to ) const { int idBase64::Decode( byte *to ) const {
unsigned long w; unsigned int w;
int i, j; int i, j;
size_t n; size_t n;
static char base64_to_sixtet[256]; static char base64_to_sixtet[256];

View file

@ -1297,7 +1297,7 @@ typedef struct operator_s
typedef struct value_s typedef struct value_s
{ {
signed long int intvalue; int intvalue;
double floatvalue; double floatvalue;
int parentheses; int parentheses;
struct value_s *prev, *next; struct value_s *prev, *next;
@ -1368,7 +1368,7 @@ int PC_OperatorPriority(int op) {
#define FreeOperator(op) #define FreeOperator(op)
int idParser::EvaluateTokens( idToken *tokens, signed long int *intvalue, double *floatvalue, int integer ) { int idParser::EvaluateTokens( idToken *tokens, int *intvalue, double *floatvalue, int integer ) {
operator_t *o, *firstoperator, *lastoperator; operator_t *o, *firstoperator, *lastoperator;
value_t *v, *firstvalue, *lastvalue, *v1, *v2; value_t *v, *firstvalue, *lastvalue, *v1, *v2;
idToken *t; idToken *t;
@ -1791,7 +1791,7 @@ int idParser::EvaluateTokens( idToken *tokens, signed long int *intvalue, double
idParser::Evaluate idParser::Evaluate
================ ================
*/ */
int idParser::Evaluate( signed long int *intvalue, double *floatvalue, int integer ) { int idParser::Evaluate( int *intvalue, double *floatvalue, int integer ) {
idToken token, *firsttoken, *lasttoken; idToken token, *firsttoken, *lasttoken;
idToken *t, *nexttoken; idToken *t, *nexttoken;
define_t *define; define_t *define;
@ -1882,7 +1882,7 @@ int idParser::Evaluate( signed long int *intvalue, double *floatvalue, int integ
idParser::DollarEvaluate idParser::DollarEvaluate
================ ================
*/ */
int idParser::DollarEvaluate( signed long int *intvalue, double *floatvalue, int integer) { int idParser::DollarEvaluate( int *intvalue, double *floatvalue, int integer) {
int indent, defined = false; int indent, defined = false;
idToken token, *firsttoken, *lasttoken; idToken token, *firsttoken, *lasttoken;
idToken *t, *nexttoken; idToken *t, *nexttoken;
@ -1984,7 +1984,7 @@ idParser::Directive_elif
================ ================
*/ */
int idParser::Directive_elif( void ) { int idParser::Directive_elif( void ) {
signed long int value; int value;
int type, skip; int type, skip;
idParser::PopIndent( &type, &skip ); idParser::PopIndent( &type, &skip );
@ -2006,7 +2006,7 @@ idParser::Directive_if
================ ================
*/ */
int idParser::Directive_if( void ) { int idParser::Directive_if( void ) {
signed long int value; int value;
int skip; int skip;
if ( !idParser::Evaluate( &value, NULL, true ) ) { if ( !idParser::Evaluate( &value, NULL, true ) ) {
@ -2102,7 +2102,7 @@ idParser::Directive_eval
================ ================
*/ */
int idParser::Directive_eval( void ) { int idParser::Directive_eval( void ) {
signed long int value; int value;
idToken token; idToken token;
char buf[128]; char buf[128];
@ -2241,7 +2241,7 @@ idParser::DollarDirective_evalint
================ ================
*/ */
int idParser::DollarDirective_evalint( void ) { int idParser::DollarDirective_evalint( void ) {
signed long int value; int value;
idToken token; idToken token;
char buf[128]; char buf[128];
@ -2290,7 +2290,7 @@ int idParser::DollarDirective_evalfloat( void ) {
token = buf; token = buf;
token.type = TT_NUMBER; token.type = TT_NUMBER;
token.subtype = TT_FLOAT | TT_LONG | TT_DECIMAL | TT_VALUESVALID; token.subtype = TT_FLOAT | TT_LONG | TT_DECIMAL | TT_VALUESVALID;
token.intvalue = (unsigned long) fabs( value ); token.intvalue = (unsigned int) fabs( value );
token.floatvalue = fabs( value ); token.floatvalue = fabs( value );
idParser::UnreadSourceToken( &token ); idParser::UnreadSourceToken( &token );
if ( value < 0 ) { if ( value < 0 ) {

View file

@ -228,9 +228,9 @@ private:
int Directive_ifndef( void ); int Directive_ifndef( void );
int Directive_else( void ); int Directive_else( void );
int Directive_endif( void ); int Directive_endif( void );
int EvaluateTokens( idToken *tokens, signed long int *intvalue, double *floatvalue, int integer ); int EvaluateTokens( idToken *tokens, int *intvalue, double *floatvalue, int integer );
int Evaluate( signed long int *intvalue, double *floatvalue, int integer ); int Evaluate( int *intvalue, double *floatvalue, int integer );
int DollarEvaluate( signed long int *intvalue, double *floatvalue, int integer); int DollarEvaluate( int *intvalue, double *floatvalue, int integer);
int Directive_define( void ); int Directive_define( void );
int Directive_elif( void ); int Directive_elif( void );
int Directive_if( void ); int Directive_if( void );

View file

@ -703,7 +703,7 @@ idStr::FileNameHash
*/ */
int idStr::FileNameHash( void ) const { int idStr::FileNameHash( void ) const {
int i; int i;
long hash; int hash;
char letter; char letter;
hash = 0; hash = 0;
@ -716,7 +716,7 @@ int idStr::FileNameHash( void ) const {
if ( letter =='\\' ) { if ( letter =='\\' ) {
letter = '/'; letter = '/';
} }
hash += (long)(letter)*(i+119); hash += (int)(letter)*(i+119);
i++; i++;
} }
hash &= (FILE_HASH_SIZE-1); hash &= (FILE_HASH_SIZE-1);

View file

@ -92,7 +92,7 @@ public:
double GetDoubleValue( void ); // double value of TT_NUMBER double GetDoubleValue( void ); // double value of TT_NUMBER
float GetFloatValue( void ); // float value of TT_NUMBER float GetFloatValue( void ); // float value of TT_NUMBER
unsigned long GetUnsignedLongValue( void ); // unsigned long value of TT_NUMBER unsigned int GetUnsignedIntValue( void ); // unsigned int value of TT_NUMBER
int GetIntValue( void ); // int value of TT_NUMBER int GetIntValue( void ); // int value of TT_NUMBER
int WhiteSpaceBeforeToken( void ) const;// returns length of whitespace before token int WhiteSpaceBeforeToken( void ) const;// returns length of whitespace before token
void ClearTokenWhiteSpace( void ); // forget whitespace before token void ClearTokenWhiteSpace( void ); // forget whitespace before token
@ -100,7 +100,7 @@ public:
void NumberValue( void ); // calculate values for a TT_NUMBER void NumberValue( void ); // calculate values for a TT_NUMBER
private: private:
unsigned long intvalue; // integer value unsigned int intvalue; // integer value
double floatvalue; // floating point value double floatvalue; // floating point value
const char * whiteSpaceStart_p; // start of white space before token, only used by idLexer const char * whiteSpaceStart_p; // start of white space before token, only used by idLexer
const char * whiteSpaceEnd_p; // end of white space before token, only used by idLexer const char * whiteSpaceEnd_p; // end of white space before token, only used by idLexer
@ -141,7 +141,7 @@ ID_INLINE float idToken::GetFloatValue( void ) {
return (float) GetDoubleValue(); return (float) GetDoubleValue();
} }
ID_INLINE unsigned long idToken::GetUnsignedLongValue( void ) { ID_INLINE unsigned int idToken::GetUnsignedIntValue( void ) {
if ( type != TT_NUMBER ) { if ( type != TT_NUMBER ) {
return 0; return 0;
} }
@ -152,7 +152,7 @@ ID_INLINE unsigned long idToken::GetUnsignedLongValue( void ) {
} }
ID_INLINE int idToken::GetIntValue( void ) { ID_INLINE int idToken::GetIntValue( void ) {
return (int) GetUnsignedLongValue(); return (int) GetUnsignedIntValue();
} }
ID_INLINE int idToken::WhiteSpaceBeforeToken( void ) const { ID_INLINE int idToken::WhiteSpaceBeforeToken( void ) const {

View file

@ -100,10 +100,10 @@ ID_INLINE float idRandom::CRandomFloat( void ) {
class idRandom2 { class idRandom2 {
public: public:
idRandom2( unsigned long seed = 0 ); idRandom2( unsigned int seed = 0 );
void SetSeed( unsigned long seed ); void SetSeed( unsigned int seed );
unsigned long GetSeed( void ) const; unsigned int GetSeed( void ) const;
int RandomInt( void ); // random integer in the range [0, MAX_RAND] int RandomInt( void ); // random integer in the range [0, MAX_RAND]
int RandomInt( int max ); // random integer in the range [0, max] int RandomInt( int max ); // random integer in the range [0, max]
@ -113,26 +113,26 @@ public:
static const int MAX_RAND = 0x7fff; static const int MAX_RAND = 0x7fff;
private: private:
unsigned long seed; unsigned int seed;
static const unsigned long IEEE_ONE = 0x3f800000; static const unsigned int IEEE_ONE = 0x3f800000;
static const unsigned long IEEE_MASK = 0x007fffff; static const unsigned int IEEE_MASK = 0x007fffff;
}; };
ID_INLINE idRandom2::idRandom2( unsigned long seed ) { ID_INLINE idRandom2::idRandom2( unsigned int seed ) {
this->seed = seed; this->seed = seed;
} }
ID_INLINE void idRandom2::SetSeed( unsigned long seed ) { ID_INLINE void idRandom2::SetSeed( unsigned int seed ) {
this->seed = seed; this->seed = seed;
} }
ID_INLINE unsigned long idRandom2::GetSeed( void ) const { ID_INLINE unsigned int idRandom2::GetSeed( void ) const {
return seed; return seed;
} }
ID_INLINE int idRandom2::RandomInt( void ) { ID_INLINE int idRandom2::RandomInt( void ) {
seed = 1664525L * seed + 1013904223L; seed = 1664525 * seed + 1013904223;
return ( (int) seed & idRandom2::MAX_RAND ); return ( (int) seed & idRandom2::MAX_RAND );
} }
@ -144,15 +144,15 @@ ID_INLINE int idRandom2::RandomInt( int max ) {
} }
ID_INLINE float idRandom2::RandomFloat( void ) { ID_INLINE float idRandom2::RandomFloat( void ) {
unsigned long i; unsigned int i;
seed = 1664525L * seed + 1013904223L; seed = 1664525 * seed + 1013904223;
i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK ); i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK );
return ( ( *(float *)&i ) - 1.0f ); return ( ( *(float *)&i ) - 1.0f );
} }
ID_INLINE float idRandom2::CRandomFloat( void ) { ID_INLINE float idRandom2::CRandomFloat( void ) {
unsigned long i; unsigned int i;
seed = 1664525L * seed + 1013904223L; seed = 1664525 * seed + 1013904223;
i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK ); i = idRandom2::IEEE_ONE | ( seed & idRandom2::IEEE_MASK );
return ( 2.0f * ( *(float *)&i ) - 3.0f ); return ( 2.0f * ( *(float *)&i ) - 3.0f );
} }

View file

@ -147,7 +147,7 @@ void idSIMD::Shutdown( void ) {
idSIMDProcessor *p_simd; idSIMDProcessor *p_simd;
idSIMDProcessor *p_generic; idSIMDProcessor *p_generic;
long baseClocks = 0; int baseClocks = 0;
#ifdef _MSC_VER #ifdef _MSC_VER
@ -155,7 +155,7 @@ long baseClocks = 0;
#pragma warning(disable : 4731) // frame pointer register 'ebx' modified by inline assembly code #pragma warning(disable : 4731) // frame pointer register 'ebx' modified by inline assembly code
long saved_ebx = 0; int saved_ebx = 0;
#define StartRecordTime( start ) \ #define StartRecordTime( start ) \
__asm mov saved_ebx, ebx \ __asm mov saved_ebx, ebx \