glide2x: remove dependency on ctype.h functionality

This commit is contained in:
sezero
2018-08-20 14:32:24 +03:00
parent 103dec9ab9
commit 61ebabbc40
5 changed files with 38 additions and 21 deletions

View File

@@ -62,14 +62,12 @@
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <3dfx.h>
#define FX_DLL_DEFINITION
#include <fxdll.h>
#include <glide.h>
#include "fxglide.h"
#include <ctype.h>
extern const int _grMipMapHostWH[GR_ASPECT_1x8 + 1][GR_LOD_1 + 1][2];
extern FxU32 _gr_aspect_index_table[];
@@ -305,7 +303,8 @@ GR_DIENTRY(gu3dfGetInfo, FxBool,
{
char *tempStr = (char*)color_format;
while (*tempStr != '\0') {
*tempStr = toupper(*tempStr);
if (*tempStr >= 'a' && *tempStr <= 'z')
*tempStr -= ('a'-'A');
tempStr++;
}
}

View File

@@ -27,7 +27,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#if __WIN32__
#include <windows.h>
@@ -455,6 +454,16 @@ static int sst1InitFgets(char *string, FILE *stream)
return(validChars);
}
static __inline int sst1_isspace (int c)
{
switch(c) {
case ' ': case '\t':
case '\n': case '\r':
case '\f': case '\v': return 1;
}
return 0;
}
static int sst1InitFgetc(FILE *stream)
{
static int column = 0;
@@ -489,11 +498,13 @@ static int sst1InitFgetc(FILE *stream)
} else
continue;
} else {
if(isspace(charRead))
if(sst1_isspace(charRead))
continue;
validChars++;
column++;
charReadL = (islower(charRead)) ? toupper(charRead) : charRead;
charReadL = charRead;
if (charReadL >= 'a' && charReadL <= 'z')
charReadL -= ('a'-'A');
return(charReadL);
}
}
@@ -967,7 +978,8 @@ static void sst1InitToLower(char *string)
char *ptr = string;
while(*ptr) {
*ptr = (isupper(*ptr)) ? tolower(*ptr) : *ptr;
if (*ptr >= 'A' && *ptr <= 'Z')
*ptr += ('a'-'A');
ptr++;
}
}

View File

@@ -68,7 +68,6 @@
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <3dfx.h>
@@ -306,7 +305,8 @@ GR_DIENTRY(gu3dfGetInfo, FxBool,
{
char *tempStr = (char*)color_format;
while (*tempStr != '\0') {
*tempStr = toupper(*tempStr);
if (*tempStr >= 'a' && *tempStr <= 'z')
*tempStr -= ('a'-'A');
tempStr++;
}
}
@@ -562,6 +562,3 @@ static FxU32 ReadDataLong(FILE *fp)
return data;
}

View File

@@ -36,7 +36,6 @@
#include <fxdll.h>
#include <glide.h>
#include "fxglide.h"
#include <ctype.h>
extern const int _grMipMapHostWH[GR_ASPECT_1x8+1][GR_LOD_1+1][2];
extern FxU32 _gr_aspect_index_table[];
@@ -250,7 +249,8 @@ GR_DIENTRY(gu3dfGetInfo, FxBool,
{
char *tempStr = (char*)color_format;
while (*tempStr != '\0') {
*tempStr = toupper(*tempStr);
if (*tempStr >= 'a' && *tempStr <= 'z')
*tempStr -= ('a'-'A');
tempStr++;
}
}
@@ -517,6 +517,3 @@ static FxU32 ReadDataLong( FILE *fp )
return data;
}

View File

@@ -27,7 +27,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <malloc.h>
#include <3dfx.h>
#define FX_DLL_DEFINITION
@@ -336,6 +335,16 @@ static int sst1InitFgets(char *string, FILE *stream)
return(validChars);
}
static __inline int sst1_isspace (int c)
{
switch(c) {
case ' ': case '\t':
case '\n': case '\r':
case '\f': case '\v': return 1;
}
return 0;
}
static int sst1InitFgetc(FILE *stream)
{
static int column = 0;
@@ -370,11 +379,13 @@ static int sst1InitFgetc(FILE *stream)
} else
continue;
} else {
if(isspace(charRead))
if(sst1_isspace(charRead))
continue;
validChars++;
column++;
charReadL = (islower(charRead)) ? toupper(charRead) : charRead;
charReadL = charRead;
if (charReadL >= 'a' && charReadL <= 'z')
charReadL -= ('a'-'A');
return(charReadL);
}
}
@@ -843,7 +854,8 @@ static void sst1InitToLower(char *string)
char *ptr = string;
while(*ptr) {
*ptr = (isupper(*ptr)) ? tolower(*ptr) : *ptr;
if (*ptr >= 'A' && *ptr <= 'Z')
*ptr += ('a'-'A');
ptr++;
}
}