fix typo (?) in extractfuncs tool to fix segfault when run w/o any args.

fix some warnings.

Submitted by: Ozkan Sezer
This commit is contained in:
Yamagi Burmeister 2015-08-31 18:57:16 +02:00
parent 264ca3d89e
commit faa5144244
4 changed files with 178 additions and 173 deletions

View file

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
gcc -g -o extractfuncts -DSCREWUP extractfuncs.c l_log.c l_memory.c l_precomp.c l_script.c clang -o extractfuncs -Wall -DSCREWUP extractfuncs.c l_log.c l_memory.c l_precomp.c l_script.c

View file

@ -196,7 +196,7 @@ void DumpReplaceFunctions (char *typeName)
fclose( f ); fclose( f );
strcpy( path, func_listfile ); strcpy( path, func_listfile );
if ( f = fopen( path, "rb" ) ) if ((f = fopen( path, "rb" )) != NULL)
{ {
fseek( f, 0, SEEK_END ); fseek( f, 0, SEEK_END );
newlen = ftell( f ); newlen = ftell( f );
@ -264,7 +264,7 @@ void DumpReplaceFunctions (char *typeName)
fclose( f ); fclose( f );
strcpy( path, func_decsfile ); strcpy( path, func_decsfile );
if ( f = fopen( path, "rb" ) ) if ((f = fopen( path, "rb" )) != NULL)
{ {
fseek( f, 0, SEEK_END ); fseek( f, 0, SEEK_END );
newlen = ftell( f ); newlen = ftell( f );
@ -734,7 +734,7 @@ void main (int argc, char *argv[])
} }
} }
if (argc < 1 || (firstParmSet && firstParm < 1)) if (argc < 2 || (firstParmSet && firstParm < 1))
Usage (); Usage ();
// end Knightmare // end Knightmare
@ -756,6 +756,8 @@ void main (int argc, char *argv[])
DumpReplaceFunctions (typeName); DumpReplaceFunctions (typeName);
else else
DumpReplaceFunctions (NULL); DumpReplaceFunctions (NULL);
return 0;
} }
#else #else
/* /*
@ -818,7 +820,7 @@ int main (int argc, char *argv[])
} }
} }
if (argc < 1 || (firstParmSet && firstParm < 1)) if (argc < 2 || (firstParmSet && firstParm < 1))
Usage (); Usage ();
// end Knightmare // end Knightmare
@ -835,6 +837,8 @@ int main (int argc, char *argv[])
DumpReplaceFunctions (typeName); DumpReplaceFunctions (typeName);
else else
DumpReplaceFunctions (NULL); DumpReplaceFunctions (NULL);
return 0;
} }
#endif #endif

View file

@ -49,6 +49,7 @@ you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, R
#include <stdarg.h> #include <stdarg.h>
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <ctype.h>
#include "l_memory.h" #include "l_memory.h"
#include "l_script.h" #include "l_script.h"
#include "l_precomp.h" #include "l_precomp.h"
@ -789,12 +790,12 @@ void PC_AddBuiltinDefines( source_t *source ) {
char *string; char *string;
int builtin; int builtin;
} builtin[] = { } builtin[] = {
"__LINE__", BUILTIN_LINE, { "__LINE__", BUILTIN_LINE },
"__FILE__", BUILTIN_FILE, { "__FILE__", BUILTIN_FILE },
"__DATE__", BUILTIN_DATE, { "__DATE__", BUILTIN_DATE },
"__TIME__", BUILTIN_TIME, { "__TIME__", BUILTIN_TIME },
// "__STDC__", BUILTIN_STDC, // { "__STDC__", BUILTIN_STDC },
NULL, 0 { NULL, 0 }
}; };
for ( i = 0; builtin[i].string; i++ ) for ( i = 0; builtin[i].string; i++ )
@ -811,7 +812,7 @@ void PC_AddBuiltinDefines( source_t *source ) {
#else #else
define->next = source->defines; define->next = source->defines;
source->defines = define; source->defines = define;
#endif //DEFINEHASHING #endif /* DEFINEHASHING */
} //end for } //end for
} //end of the function PC_AddBuiltinDefines } //end of the function PC_AddBuiltinDefines
//============================================================================ //============================================================================
@ -823,7 +824,7 @@ void PC_AddBuiltinDefines( source_t *source ) {
int PC_ExpandBuiltinDefine( source_t *source, define_t *define, int PC_ExpandBuiltinDefine( source_t *source, define_t *define,
token_t **firsttoken, token_t **lasttoken ) { token_t **firsttoken, token_t **lasttoken ) {
token_t token; token_t token;
unsigned long t; // time_t t; //to prevent LCC warning time_t t;
char *curtime; char *curtime;
memcpy( &token, &source->token, sizeof( token_t ) ); memcpy( &token, &source->token, sizeof( token_t ) );

View file

@ -721,13 +721,13 @@ int PS_ReadNumber( script_t *script, token_t *token ) {
{ {
c = *script->script_p; c = *script->script_p;
//check for a LONG number //check for a LONG number
if ( c == 'l' || c == 'L' && if ( (c == 'l' || c == 'L') &&
!( token->subtype & TT_LONG ) ) { !( token->subtype & TT_LONG ) ) {
script->script_p++; script->script_p++;
token->subtype |= TT_LONG; token->subtype |= TT_LONG;
} //end if } //end if
//check for an UNSIGNED number //check for an UNSIGNED number
else if ( c == 'u' || c == 'U' && else if ( (c == 'u' || c == 'U') &&
!( token->subtype & ( TT_UNSIGNED | TT_FLOAT ) ) ) { !( token->subtype & ( TT_UNSIGNED | TT_FLOAT ) ) ) {
script->script_p++; script->script_p++;
token->subtype |= TT_UNSIGNED; token->subtype |= TT_UNSIGNED;
@ -736,7 +736,7 @@ int PS_ReadNumber( script_t *script, token_t *token ) {
token->string[len] = '\0'; token->string[len] = '\0';
#ifdef NUMBERVALUE #ifdef NUMBERVALUE
NumberValue( token->string, token->subtype, &token->intvalue, &token->floatvalue ); NumberValue( token->string, token->subtype, &token->intvalue, &token->floatvalue );
#endif //NUMBERVALUE #endif /* NUMBERVALUE */
if ( !( token->subtype & TT_FLOAT ) ) { if ( !( token->subtype & TT_FLOAT ) ) {
token->subtype |= TT_INTEGER; token->subtype |= TT_INTEGER;
} }