Convert K&R definitions to ANSI C

This commit is contained in:
Nishi 2026-06-18 14:01:01 +09:00
commit a2161ba1b0
45 changed files with 521 additions and 1073 deletions

View file

@ -54,35 +54,27 @@
#endif
extern int current_locale;
int sj3_iswcntrl16(wc)
wchar16_t wc;
int sj3_iswcntrl16(wchar16_t wc)
{
if((wc < 0x20) || (wc == 0x7f)) return TRUE;
return FALSE;
}
int sj3_iswupper16(wc)
wchar16_t wc;
int sj3_iswupper16(wchar16_t wc)
{
if(((0x40 < wc) && (wc < 0x5b)) ||
((0xa3c0 < wc) && (wc < 0xa3db))) return TRUE;
return FALSE;
}
int sj3_iswdigit16(wc)
wchar16_t wc;
int sj3_iswdigit16(wchar16_t wc)
{
if(((0x29 < wc) && (wc < 0x3a)) ||
((0xa3af < wc) && (wc < 0xa3ba))) return TRUE;
return FALSE;
}
int sj3_iswxdigit16(wc)
wchar16_t wc;
int sj3_iswxdigit16(wchar16_t wc)
{
if(((0x29 < wc) && (wc < 0x3a)) ||
((0xa3af < wc) && (wc < 0xa3ba))) return TRUE;
@ -95,9 +87,7 @@ wchar16_t wc;
return FALSE;
}
int sj3_wslen16(ws)
wchar16_t* ws;
int sj3_wslen16(wchar16_t * ws)
{
int i = 0;
@ -106,9 +96,7 @@ wchar16_t* ws;
while(*ws++) i++;
return i;
}
int sj3_wscmp16(ws1, ws2)
wchar16_t *ws1, *ws2;
int sj3_wscmp16(wchar16_t * ws1, wchar16_t * ws2)
{
while((*ws1 && *ws2) && (*ws1 == *ws2)) {
ws1++;
@ -120,10 +108,7 @@ wchar16_t *ws1, *ws2;
if(*ws1 < *ws2) return -1;
return 1;
}
int sj3_wsncmp16(ws1, ws2, n)
wchar16_t *ws1, *ws2;
int n;
int sj3_wsncmp16(wchar16_t * ws1, wchar16_t * ws2, int n)
{
int i = 0;
@ -140,9 +125,7 @@ int n;
return 1;
}
wchar16_t*
sj3_wscpy16(ws1, ws2)
wchar16_t *ws1, *ws2;
wchar16_t* sj3_wscpy16(wchar16_t * ws1, wchar16_t * ws2)
{
wchar16_t* ws;
@ -156,10 +139,7 @@ wchar16_t *ws1, *ws2;
return ws1;
}
wchar16_t*
sj3_wsncpy16(ws1, ws2, n)
wchar16_t *ws1, *ws2;
int n;
wchar16_t* sj3_wsncpy16(wchar16_t * ws1, wchar16_t * ws2, int n)
{
wchar16_t* ws;
int i = 0;
@ -175,9 +155,7 @@ int n;
return ws1;
}
wchar16_t*
sj3_wscat16(ws1, ws2)
wchar16_t *ws1, *ws2;
wchar16_t* sj3_wscat16(wchar16_t * ws1, wchar16_t * ws2)
{
wchar16_t* ws;
@ -195,9 +173,7 @@ wchar16_t *ws1, *ws2;
return ws1;
}
wchar16_t
sj3_euc2wc16(code)
unsigned int code;
wchar16_t sj3_euc2wc16(unsigned int code)
{
wchar16_t wc = 0;
@ -212,9 +188,7 @@ unsigned int code;
return wc;
}
wchar16_t
sj3_sjis2wc16(code)
unsigned int code;
wchar16_t sj3_sjis2wc16(unsigned int code)
{
unsigned short ch;
@ -228,9 +202,7 @@ unsigned int code;
return (sj3_euc2wc16(ch));
}
unsigned int
sj3_wc2euc16(wc)
wchar16_t wc;
unsigned int sj3_wc2euc16(wchar16_t wc)
{
unsigned int code = 0;
unsigned char tmp;
@ -253,9 +225,7 @@ wchar16_t wc;
return code;
}
unsigned int
sj3_wc2sjis16(wc)
wchar16_t wc;
unsigned int sj3_wc2sjis16(wchar16_t wc)
{
unsigned int ch;
@ -270,11 +240,7 @@ wchar16_t wc;
return wc;
}
}
int sj3_wcs2eucs16(mb, ws, n)
unsigned char* mb;
wchar16_t* ws;
int n;
int sj3_wcs2eucs16(unsigned char * mb, wchar16_t * ws, int n)
{
int i = 0;
unsigned int code;
@ -314,11 +280,7 @@ int n;
return i;
}
int sj3_wcs2sjiss16(mb, ws, n)
unsigned char* mb;
wchar16_t* ws;
int n;
int sj3_wcs2sjiss16(unsigned char * mb, wchar16_t * ws, int n)
{
int i = 0;
unsigned int code;
@ -348,11 +310,7 @@ int n;
return i;
}
int sj3_eucs2wcs16(ws, mb, n)
wchar16_t* ws;
unsigned char* mb;
int n;
int sj3_eucs2wcs16(wchar16_t * ws, unsigned char * mb, int n)
{
int i = 0;
unsigned int code;
@ -379,11 +337,7 @@ int n;
return i;
}
int sj3_sjiss2wcs16(ws, mb, n)
wchar16_t* ws;
unsigned char* mb;
int n;
int sj3_sjiss2wcs16(wchar16_t * ws, unsigned char * mb, int n)
{
int i = 0;
unsigned int code;
@ -406,22 +360,14 @@ int n;
return i;
}
int sj3_mbstowcs16(ws, mb, n)
wchar16_t* ws;
unsigned char* mb;
int n;
int sj3_mbstowcs16(wchar16_t * ws, unsigned char * mb, int n)
{
if(current_locale == LC_CTYPE_EUC)
return sj3_eucs2wcs16(ws, mb, n);
else
return sj3_sjiss2wcs16(ws, mb, n);
}
int sj3_wcstombs16(mb, ws, n)
unsigned char* mb;
wchar16_t* ws;
int n;
int sj3_wcstombs16(unsigned char * mb, wchar16_t * ws, int n)
{
if(current_locale == LC_CTYPE_EUC)
return sj3_wcs2eucs16(mb, ws, n);