Commit to implement all symbols initially

svn path=/trunk/; revision=483
This commit is contained in:
Boudewijn Dekker 1999-05-18 18:16:30 +00:00
parent b06daa620f
commit 55b8b93555
128 changed files with 2778 additions and 844 deletions

View file

@ -1,5 +1,5 @@
#include <crtdll/conio.h>
#include <crtdll/stdlib.h>
char *
_cgets(char *string)
@ -22,7 +22,7 @@ _cgets(char *string)
*/
while(len < maxlen_wanted-1)
{
c=getch();
c=_getch();
/*
* shold we check for backspace here?
* TURBOC does (just checked) but doesn't in cscanf (thats harder
@ -32,7 +32,7 @@ _cgets(char *string)
{
if (len > 0)
{
cputs("\b \b"); /* go back, clear char on screen with space
_cputs("\b \b"); /* go back, clear char on screen with space
and go back again */
len--;
sp[len] = '\0'; /* clear the character in the string */
@ -47,12 +47,12 @@ _cgets(char *string)
{
/* special character ends input */
sp[len] = '\0';
ungetch(c); /* keep the char for later processing */
_ungetch(c); /* keep the char for later processing */
break;
}
else
{
sp[len] = putch(c);
sp[len] = _putch(c);
len++;
}
}

View file

@ -2,7 +2,7 @@
#include <crtdll/conio.h>
int
cprintf(const char *fmt, ...)
_cprintf(const char *fmt, ...)
{
int cnt;
char buf[ 2048 ]; /* this is buggy, because buffer might be too small. */
@ -12,6 +12,6 @@ cprintf(const char *fmt, ...)
cnt = vsprintf(buf, fmt, ap);
va_end(ap);
cputs(buf);
_cputs(buf);
return cnt;
}

View file

@ -1,26 +1,21 @@
#include <crtdll/conio.h>
/*
* The next two functions are needed by cscanf
*/
static int
_scan_getche(FILE *fp)
{
return(getche());
}
static int
_scan_ungetch(int c, FILE *fp)
{
return(ungetch(c));
}
#include <stdarg.h>
int
_cscanf(const char *fmt, ...)
_cscanf(char *fmt, ...)
{
// return(_doscan_low(NULL, _scan_getche, _scan_ungetch,
// fmt, (void **) unconst( ((&fmt)+1), char ** )));
int cnt;
va_list ap;
// fixme cscanf
printf("cscanf \n");
va_start(ap, fmt);
cnt = __vscanf(fmt, ap);
va_end(ap);
return cnt;
}

View file

@ -9,19 +9,23 @@
*/
#include <windows.h>
#include <conio.h>
#include <crtdll/conio.h>
#include <crtdll/stdio.h>
// FIXME PeekCosoleInput returns more than keyboard hits
extern int char_avail;
int
_kbhit(void)
{
INPUT_RECORD InputRecord;
DWORD NumberRead;
DWORD NumberRead=0;
if (char_avail)
return(1);
else {
PeekConsoleInput(stdin->file,&InputRecord,1,&NumberRead);
printf("fixeme PeekConsoleInput might do DeviceIo \n");
//PeekConsoleInput((HANDLE)stdin->_file,&InputRecord,1,&NumberRead);
return NumberRead;
}
return 0;

View file

@ -18,7 +18,7 @@ char ungot_char = 0;
int
ungetch(int c)
_ungetch(int c)
{
if (char_avail)
return(EOF);

View file

@ -17,9 +17,9 @@
; DISCLAMED. This includes but is not limited to warrenties of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
;
; $Revision: 1.9 $
; $Author: ekohl $
; $Date: 1999/05/11 22:50:44 $
; $Revision: 1.10 $
; $Author: ariadne $
; $Date: 1999/05/18 18:16:11 $
;
; These three functions appear to be name mangled in some way, so GCC is
; probably not going to be able to use them in any case.
@ -28,7 +28,7 @@
; ??3@YAXPAX@Z
; ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z
;
; Added functionallt equivalent placeholders:
; Added functional equivalent placeholders:
;
; __builtin_new
; __builtin_delete
@ -36,274 +36,274 @@
;
;
EXPORTS
;__builtin_new
;__builtin_delete
;_set_new_handler__FPFUi_i
;_CIacos
;_CIasin
;_CIatan
;_CIatan2
;_CIcos
;_CIcosh
;_CIexp
;_CIfmod
;_CIlog
;_CIlog10
;_CIpow
;_CIsin
;_CIsinh
;_CIsqrt
;_CItan
;_CItanh
;_HUGE_dll
;_XcptFilter
__builtin_new
__builtin_delete
_set_new_handler__FPFUi_i
_CIacos
_CIasin
_CIatan
_CIatan2
_CIcos
_CIcosh
_CIexp
_CIfmod
_CIlog
_CIlog10
_CIpow
_CIsin
_CIsinh
_CIsqrt
_CItan
_CItanh
_HUGE_dll
_XcptFilter
__GetMainArgs
;__argc_dll
;__argv_dll
;__dllonexit
;__doserrno
;__fpecode
;__isascii
;__iscsym
;__iscsymf
;__mb_cur_max_dll
;__pxcptinfoptrs
;__threadhandle
;__threadid
;__toascii
;_abnormal_termination
__argc_dll
__argv_dll
__dllonexit
__doserrno
__fpecode
__isascii
__iscsym
__iscsymf
__mb_cur_max_dll
__pxcptinfoptrs
__threadhandle
__threadid
__toascii
_abnormal_termination
_access
;_acmdln_dll
;_aexit_rtn_dll
;_amsg_exit
;_assert
;_basemajor_dll
;_baseminor_dll
;_baseversion_dll
;_beep
;_beginthread
;_c_exit
;_cabs
_acmdln_dll
_aexit_rtn_dll
_amsg_exit
_assert
_basemajor_dll
_baseminor_dll
_baseversion_dll
_beep
_beginthread
_c_exit
_cabs
_cexit
;_cgets
_cgets
_chdir
;_chdrive
;_chgsign
_chdrive
_chgsign
_chmod
;_chsize
;_clearfp
_chsize
_clearfp
_close
;_commit
;_commode_dll
;_control87
;_controlfp
;_copysign
;_cprintf
;_cpumode_dll
;_cputs
;_creat
;_cscanf
;_ctype
;_cwait
;_daylight_dll
_commit
_commode_dll
_control87
_controlfp
_copysign
_cprintf
_cpumode_dll
_cputs
_creat
_cscanf
_ctype
_cwait
_daylight_dll
_dup
_dup2
;_ecvt
;_endthread
;_environ_dll
;_eof
_ecvt
_endthread
_environ_dll
_eof
_errno
;_except_handler2
_except_handler2
_execl
_execle
_execlp
_execlpe
_execv
;_execve
_execve
_execvp
_execvpe
_exit
;_expand
_expand
_fcloseall
;_fcvt
_fcvt
_fdopen
;_fgetchar
;_fgetwchar
_fgetchar
_fgetwchar
_filbuf
;_fileinfo_dll
_fileinfo_dll
_filelength
_fileno
_findclose
_findfirst
_findnext
;_finite
_finite
_flsbuf
;_flushall
_flushall
_fmode_dll
;_fpclass
;_fpieee_flt
_fpclass
_fpieee_flt
_fpreset
;_fputchar
;_fputwchar
;_fsopen
_fputchar
_fputwchar
_fsopen
_fstat
;_ftime
;_ftol
;_fullpath
;_futime
;_gcvt
_ftime
_ftol
_fullpath
_futime
_gcvt
_get_osfhandle
_getch
_getche
_getcwd
;_getdcwd
_getdcwd
_getdiskfree
;_getdllprocaddr
;_getdrive
;_getdrives
;_getpid
;_getsystime
;_getw
;_global_unwind2
;_heapchk
;_heapmin
;_heapset
;_heapwalk
;_hypot
;_initterm
_getdllprocaddr
_getdrive
_getdrives
_getpid
_getsystime
_getw
_global_unwind2
_heapchk
_heapmin
_heapset
_heapwalk
_hypot
_initterm
_iob
_isatty
_isctype
;_ismbbalnum
;_ismbbalpha
;_ismbbgraph
;_ismbbkalnum
;_ismbbkana
;_ismbbkpunct
;_ismbblead
;_ismbbprint
;_ismbbpunct
;_ismbbtrail
;_ismbcalpha
;_ismbcdigit
;_ismbchira
;_ismbckata
;_ismbcl0
;_ismbcl1
;_ismbcl2
;_ismbclegal
;_ismbclower
;_ismbcprint
;_ismbcspace
;_ismbcsymbol
;_ismbcupper
;_ismbslead
;_ismbstrail
;_isnan
;_itoa
;_j0
;_j1
;_jn
;_kbhit
;_lfind
;_loaddll
;_local_unwind2
;_locking
;_logb
;_lrotl
;_lrotr
;_lsearch
_ismbbalnum
_ismbbalpha
_ismbbgraph
_ismbbkalnum
_ismbbkana
_ismbbkpunct
_ismbblead
_ismbbprint
_ismbbpunct
_ismbbtrail
_ismbcalpha
_ismbcdigit
_ismbchira
_ismbckata
_ismbcl0
_ismbcl1
_ismbcl2
_ismbclegal
_ismbclower
_ismbcprint
_ismbcspace
_ismbcsymbol
_ismbcupper
_ismbslead
_ismbstrail
_isnan
_itoa
_j0
_j1
_jn
_kbhit
_lfind
_loaddll
_local_unwind2
_locking
_logb
_lrotl
_lrotr
_lsearch
_lseek
;_ltoa
_ltoa
_makepath
;_matherr
;_mbbtombc
;_mbbtype
;_mbccpy
;_mbcjistojms
;_mbcjmstojis
;_mbclen
;_mbctohira
;_mbctokata
;_mbctolower
;_mbctombb
;_mbctoupper
;_mbctype
;_mbsbtype
;_mbscat
;_mbschr
;_mbscmp
;_mbscpy
;_mbscspn
;_mbsdec
;_mbsdup
;_mbsicmp
;_mbsinc
;_mbslen
;_mbslwr
;_mbsnbcat
;_mbsnbcmp
;_mbsnbcnt
;_mbsnbcpy
;_mbsnbicmp
;_mbsnbset
;_mbsncat
;_mbsnccnt
;_mbsncmp
;_mbsncpy
;_mbsnextc
;_mbsnicmp
;_mbsninc
;_mbsnset
;_mbspbrk
;_mbsrchr
;_mbsrev
;_mbsset
;_mbsspn
;_mbsspnp
;_mbsstr
;_mbstok
;_mbstrlen
;_mbsupr
;_memccpy
;_memicmp
;_mkdir
_matherr
_mbbtombc
_mbbtype
_mbccpy
_mbcjistojms
_mbcjmstojis
_mbclen
_mbctohira
_mbctokata
_mbctolower
_mbctombb
_mbctoupper
_mbctype
_mbsbtype
_mbscat
_mbschr
_mbscmp
_mbscpy
_mbscspn
_mbsdec
_mbsdup
_mbsicmp
_mbsinc
_mbslen
_mbslwr
_mbsnbcat
_mbsnbcmp
_mbsnbcnt
_mbsnbcpy
_mbsnbicmp
_mbsnbset
_mbsncat
_mbsnccnt
_mbsncmp
_mbsncpy
_mbsnextc
_mbsnicmp
_mbsninc
_mbsnset
_mbspbrk
_mbsrchr
_mbsrev
_mbsset
_mbsspn
_mbsspnp
_mbsstr
_mbstok
_mbstrlen
_mbsupr
_memccpy
_memicmp
_mkdir
_mktemp
;_msize
;_nextafter
;_onexit
_msize
_nextafter
_onexit
_open
_open_osfhandle
;_osmajor_dll
;_osminor_dll
;_osmode_dll
;_osver_dll
;_osversion_dll
;_pclose
;_pctype_dll
;_pgmptr_dll
_osmajor_dll
_osminor_dll
_osmode_dll
_osver_dll
_osversion_dll
_pclose
_pctype_dll
_pgmptr_dll
_pipe
;_popen
;_purecall
;_putch
_popen
_purecall
_putch
_putenv
;_putw
;_pwctype_dll
_putw
_pwctype_dll
_read
;_rmdir
;_rmtmp
;_rotl
;_rotr
;_scalb
;_searchenv
;_seterrormode
;_setjmp
_rmdir
_rmtmp
_rotl
_rotr
_scalb
_searchenv
_seterrormode
_setjmp
_setmode
;_setsystime
_setsystime
_sleep
;_snprintf
;_snwprintf
;_sopen
_snprintf
_snwprintf
_sopen
_spawnl
_spawnle
_spawnlp
@ -314,62 +314,62 @@ _spawnvp
_spawnvpe
_splitpath
_stat
;_statusfp
;_strcmpi
;_strdate
;_strdec
_statusfp
_strcmpi
_strdate
_strdec
_strdup
;_strerror
_strerror
_stricmp
;_stricoll
;_strinc
_stricoll
_strinc
_strlwr
;_strncnt
;_strnextc
_strncnt
_strnextc
_strnicmp
;_strninc
;_strnset
;_strrev
;_strset
;_strspnp
;_strtime
_strninc
_strnset
_strrev
_strset
_strspnp
_strtime
_strupr
;_swab
;_sys_errlist
;_sys_nerr_dll
;_tell
;_tempnam
;_timezone_dll
;_tolower
;_toupper
;_tzname
;_tzset
;_ultoa
_swab
_sys_errlist
_sys_nerr_dll
_tell
_tempnam
_timezone_dll
_tolower
_toupper
_tzname
_tzset
_ultoa
_umask
;_ungetch
_ungetch
_unlink
;_unloaddll
_unloaddll
_utime
;_vsnprintf
;_vsnwprintf
;_wcsdup
_vsnprintf
_vsnwprintf
_wcsdup
_wcsicmp
;_wcsicoll
;_wcslwr
;_wcsnicmp
;_wcsnset
;_wcsrev
;_wcsset
;_wcsupr
;_winmajor_dll
;_winminor_dll
;_winver_dll
_wcsicoll
_wcslwr
_wcsnicmp
_wcsnset
_wcsrev
_wcsset
_wcsupr
_winmajor_dll
_winminor_dll
_winver_dll
_write
;_wtoi
;_wtol
;_y0
;_y1
;_yn
_wtoi
_wtol
_y0
_y1
_yn
abort
abs
acos
@ -384,7 +384,7 @@ atol
bsearch
calloc
ceil
;clearerr
clearerr
clock
cos
cosh
@ -401,25 +401,25 @@ fflush
fgetc
fgetpos
fgets
;fgetwc
fgetwc
floor
fmod
fopen
fprintf
fputc
fputs
;fputwc
fputwc
fread
free
;freopen
;frexp
freopen
frexp
fscanf
fseek
fsetpos
ftell
;fwprintf
fwprintf
fwrite
;fwscanf
fwscanf
getc
getchar
getenv
@ -431,7 +431,7 @@ isalpha
iscntrl
isdigit
isgraph
;isleadbyte
isleadbyte
islower
isprint
ispunct
@ -454,15 +454,15 @@ isxdigit
labs
ldexp
ldiv
;localeconv
;localtime
localeconv
localtime
log
log10
;longjmp
longjmp
malloc
;mblen
;mbstowcs
;mbtowc
mblen
mbstowcs
mbtowc
memchr
memcmp
memcpy
@ -478,21 +478,21 @@ putchar
puts
qsort
raise
;rand
rand
realloc
remove
rename
rewind
scanf
setbuf
;setlocale
setlocale
setvbuf
signal
sin
sinh
sprintf
sqrt
;srand
srand
sscanf
strcat
strchr
@ -515,9 +515,9 @@ strtok
strtol
strtoul
strxfrm
;swprintf
;swscanf
;system
swprintf
swscanf
system
tan
tanh
time
@ -525,37 +525,37 @@ tmpfile
tmpnam
tolower
toupper
;towlower
;towupper
towlower
towupper
ungetc
;ungetwc
ungetwc
vfprintf
;vfwprintf
vfwprintf
vprintf
vsprintf
;vswprintf
;vwprintf
vswprintf
vwprintf
wcscat
wcschr
wcscmp
wcscoll
wcscpy
wcscspn
;wcsftime
wcsftime
wcslen
wcsncat
wcsncmp
;wcsncpy
;wcspbrk
;wcsrchr
;wcsspn
;wcsstr
;wcstod
;wcstok
;wcstol
;wcstombs
;wcstoul
;wcsxfrm
;wctomb
;wprintf
;wscanf
wcsncpy
wcspbrk
wcsrchr
wcsspn
wcsstr
wcstod
wcstok
wcstol
wcstombs
wcstoul
wcsxfrm
wctomb
wprintf
wscanf

View file

@ -1,22 +1,23 @@
#include <direct.h>
#include <windows.h>
#include <crtdll/direct.h>
char* _getdcwd (int nDrive, char* caBuffer, int nBufLen)
{
int i =0;
int dr = getdrive();
int dr = _getdrive();
if ( nDrive < 1 || nDrive > 26 )
return NULL;
if ( dr != nDrive )
chdrive(nDrive);
_chdrive(nDrive);
i = GetCurrentDirectory(nBufLen,caBuffer);
i = GetCurrentDirectoryA(nBufLen,caBuffer);
if ( i == nBufLen )
return NULL;
if ( dr != nDrive )
chdrive(dr);
_chdrive(dr);
return caBuffer;
}

View file

@ -17,3 +17,9 @@ int _getdrive( void )
return cur_drive;
}
unsigned long _getdrives(void)
{
return printf("get logical drives\n");
//return GetLogicalDrives();
}

View file

@ -2,5 +2,6 @@
int _abnormal_termination(void)
{
return AbnormalTermination();
printf("Abnormal Termination\n");
// return AbnormalTermination();
}

View file

@ -0,0 +1,19 @@
#include <windows.h>
typedef enum _EXCEPTION_DISPOSITION {
ExceptionContinueExecution,
ExceptionContinueSearch,
ExceptionNestedException,
ExceptionCollidedUnwind
} EXCEPTION_DISPOSITION;
EXCEPTION_DISPOSITION
_except_handler2(
struct _EXCEPTION_RECORD *ExceptionRecord,
void *Frame,
struct _CONTEXT *ContextRecord,
void *DispatcherContext)
{
printf("excpetion handler\n");
}

View file

@ -0,0 +1,22 @@
struct _exception {
int type;
char *name;
double arg1;
double arg2;
double retval;
} ;
int _matherr(struct _exception *e)
{
return 0;
}
#define _FPIEEE_RECORD void
int _fpieee_flt(
unsigned long exception_code,
struct _EXCEPTION_POINTERS *ExceptionPointer,
int (* handler)(_FPIEEE_RECORD *)
)
{
return 0;
}

View file

@ -1,3 +1,6 @@
#include <windows.h>
#define PEXCEPTION_FRAME void*
void _global_unwind2( PEXCEPTION_FRAME frame )
{
//RtlUnwind( frame, 0, NULL, 0 );

View file

@ -0,0 +1,13 @@
#include <crtdll/float.h>
#include <crtdll/internal/ieee.h>
double _copysign (double __d, double __s)
{
double_t *d = (double_t *)&__d;
double_t *s = (double_t *)&__s;
d->sign = s->sign;
return __d;
}

View file

@ -0,0 +1,65 @@
#include <crtdll/float.h>
#include <crtdll/math.h>
#include <crtdll/internal/ieee.h>
#define _FPCLASS_SNAN 0x0001 /* signaling NaN */
#define _FPCLASS_QNAN 0x0002 /* quiet NaN */
#define _FPCLASS_NINF 0x0004 /* negative infinity */
#define _FPCLASS_NN 0x0008 /* negative normal */
#define _FPCLASS_ND 0x0010 /* negative denormal */
#define _FPCLASS_NZ 0x0020 /* -0 */
#define _FPCLASS_PZ 0x0040 /* +0 */
#define _FPCLASS_PD 0x0080 /* positive denormal */
#define _FPCLASS_PN 0x0100 /* positive normal */
#define _FPCLASS_PINF 0x0200 /* positive infinity */
#define FP_SNAN 0x0001 // signaling NaN
#define FP_QNAN 0x0002 // quiet NaN
#define FP_NINF 0x0004 // negative infinity
#define FP_PINF 0x0200 // positive infinity
#define FP_NDENORM 0x0008 // negative denormalized non-zero
#define FP_PDENORM 0x0010 // positive denormalized non-zero
#define FP_NZERO 0x0020 // negative zero
#define FP_PZERO 0x0040 // positive zero
#define FP_NNORM 0x0080 // negative normalized non-zero
#define FP_PNORM 0x0100 // positive normalized non-zero
typedef int fpclass_t;
fpclass_t _fpclass(double __d)
{
double_t *d = (double_t *)&__d;
if ( d->exponent == 0 ) {
if ( d->mantissah == 0 && d->mantissal == 0 ) {
if ( d->sign ==0 )
return FP_NZERO;
else
return FP_PZERO;
} else {
if ( d->sign ==0 )
return FP_NDENORM;
else
return FP_PDENORM;
}
}
if (d->exponent == 0x7ff ) {
if ( d->mantissah == 0 && d->mantissal == 0 ) {
if ( d->sign ==0 )
return FP_NINF;
else
return FP_PINF;
}
else if ( d->mantissah == 0 && d->mantissal != 0 ) {
return FP_QNAN;
}
else if ( d->mantissah == 0 && d->mantissal != 0 ) {
return FP_SNAN;
}
}
return 0;
}

View file

@ -18,9 +18,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
double logb (double __x);
double _logb (double __x);
double logb (double __x)
double _logb (double __x)
{
register double __value, __junk;
__asm __volatile__

View file

@ -0,0 +1,12 @@
#include <crtdll/float.h>
double _nextafter( double x, double y )
{
if ( x == y)
return x;
if ( isnan(x) || isnan(y) )
return x;
return x;
}

View file

@ -0,0 +1,48 @@
#define MAX_DOUBLE 1.7976931348623158e+308
#define MIN_DOUBLE 2.2250738585072014e-308
double _xnextafter( double __x, double __y )
{
double_t *x = ( double_t *)&__x;
double __e;
double_t *e = (double_t *)&__e;
if ( _isnan(__x) || _isinf(__x) )
return __x;
if ( _isnan(__y) )
return __y;
// don't go to infinity just by adding
if ( _isinf(__y) && fabs(__x) >= MAX_DOUBLE )
return __x;
if ( !_isinf(__y) && fabs(__x - __y) <= MIN_DOUBLE )
return __y;
e->mantissal = 1;
e->mantissah = 0;
if ( x->exponent >= 53 )
e->exponent = x->exponent - 52;
else
e->exponent = 1;
if ( fabs(__x) < fabs(__y) )
e->sign = 0;
else
e->sign = 1;
return __x+__e;
}

View file

@ -0,0 +1,12 @@
#include <crtdll/float.h>
#include <crtdll/internal/ieee.h>
double _scalb( double __x, long e )
{
double_t *x = (double_t *)&__x;
x->exponent += e;
return __x;
}

View file

@ -1,8 +1,7 @@
#include <crtdll/io.h>
#include <crtdll/fcntl.h>
#undef creat
int creat(const char *filename, int mode)
int _creat(const char *filename, int mode)
{
return open(filename,_O_CREAT|_O_TRUNC,mode);
}

View file

@ -1,90 +1,4 @@
/*
FUNCTION
<<setlocale>>, <<localeconv>>---select or query locale
INDEX
setlocale
INDEX
localeconv
INDEX
_setlocale_r
INDEX
_localeconv_r
ANSI_SYNOPSIS
#include <crtdll/locale.h>
char *setlocale(int <[category]>, const char *<[locale]>);
lconv *localeconv(void);
char *_setlocale_r(void *<[reent]>,
int <[category]>, const char *<[locale]>);
lconv *_localeconv_r(void *<[reent]>);
TRAD_SYNOPSIS
#include <crtdll/locale.h>
char *setlocale(<[category]>, <[locale]>)
int <[category]>;
char *<[locale]>;
lconv *localeconv();
char *_setlocale_r(<[reent]>, <[category]>, <[locale]>)
char *<[reent]>;
int <[category]>;
char *<[locale]>;
lconv *_localeconv_r(<[reent]>);
char *<[reent]>;
DESCRIPTION
<<setlocale>> is the facility defined by ANSI C to condition the
execution environment for international collating and formatting
information; <<localeconv>> reports on the settings of the current
locale.
This is a minimal implementation, supporting only the required <<``C''>>
value for <[locale]>; strings representing other locales are not
honored unless MB_CAPABLE is defined in which case three new
extensions are allowed for LC_CTYPE only: <<''C-JIS''>>, <<''C-EUCJP''>>,
and <<''C-SJIS''>>. (<<``''>> is also accepted; it represents the default locale
for an implementation, here equivalent to <<``C''>>.)
If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns
a pointer to the string representing the current locale (always
<<``C''>> in this implementation). The acceptable values for
<[category]> are defined in `<<locale.h>>' as macros beginning with
<<"LC_">>, but this implementation does not check the values you pass
in the <[category]> argument.
<<localeconv>> returns a pointer to a structure (also defined in
`<<locale.h>>') describing the locale-specific conventions currently
in effect.
<<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of
<<localeconv>> and <<setlocale>> respectively. The extra argument
<[reent]> is a pointer to a reentrancy structure.
RETURNS
<<setlocale>> returns either a pointer to a string naming the locale
currently in effect (always <<``C''>> for this implementation, or, if
the locale request cannot be honored, <<NULL>>.
<<localeconv>> returns a pointer to a structure of type <<lconv>>,
which describes the formatting and collating conventions in effect (in
this implementation, always those of the C locale).
PORTABILITY
ANSI C requires <<setlocale>>, but the only locale required across all
implementations is the C locale.
No supporting OS subroutines are required.
*/
/*
* setlocale, localeconv : internationalize your locale.
* (Only "C" or null supported).
*/
#include <crtdll/stdio.h>
#include <crtdll/locale.h>
#include <crtdll/string.h>
#include <limits.h>
@ -94,79 +8,117 @@ int _current_category; /* used by setlocale */
const char *_current_locale;
int __mb_cur_max_dll = 1;
static const struct lconv lconv =
int parse_locale(char *locale, char *lang, char *country, char *code_page);
char *setlocale(int category, const char *locale)
{
".", "", "", "", "", "", "", "", "", "",
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
char lang[100];
char country[100];
char code_page[100];
parse_locale((char *)locale,lang,country,code_page);
printf("%s %s %s %s\n",locale,lang,country,code_page);
switch ( category )
{
case LC_COLLATE:
break;
case LC_CTYPE:
break;
case LC_MONETARY:
break;
case LC_NUMERIC:
break;
case LC_TIME:
break;
case LC_ALL:
break;
default:
break;
}
return "C";
}
/*
locale "lang[_country[.code_page]]"
| ".code_page"
| ""
| NULL
*/
int parse_locale(char *locale, char *lang, char *country, char *code_page)
{
while ( *locale != 0 && *locale != '.' && *locale != '_' )
{
*lang = *locale;
lang++;
locale++;
}
*lang = 0;
if ( *locale == '_' ) {
locale++;
while ( *locale != 0 && *locale != '.' )
{
*country = *locale;
country++;
locale++;
}
}
*country = 0;
if ( *locale == '.' ) {
locale++;
while ( *locale != 0 && *locale != '.' )
{
*code_page = *locale;
code_page++;
locale++;
}
}
*code_page = 0;
return 0;
}
const struct map_lcid2str {
short langid;
const char *langname;
const char *country;
} languages[]={
{0x0409,"English", "United States"},
{0x0809,"English", "United Kingdom"},
{0x0000,"Unknown", "Unknown"}
};
const struct map_cntr {
const char *abrev;
const char *country;
} abrev[] = {
{"britain", "united kingdom"},
{"england", "united kingdom"},
{"gbr", "united kingdom"},
{"great britain", "united kingdom"},
{"uk", "united kingdom"},
{"united kingdom", "united kingdom"},
{"united-kingdom", "united kingdom"},
{"america", "united states" },
{"united states", "united states"},
{"united-states", "united states"},
{"us", "united states"},
{"usa" "united states"}
};
char * setlocale(int category ,const char *locale)
{
static char lc_ctype[8] = "C";
static char last_lc_ctype[8] = "C";
#ifndef MB_CAPABLE
if (locale)
{
if (strcmp (locale, "C") && strcmp (locale, ""))
return 0;
_current_category = category;
_current_locale = locale;
}
return "C";
#else
if (locale)
{
if (category != LC_CTYPE)
{
if (strcmp (locale, "C") && strcmp (locale, ""))
return 0;
if (category == LC_ALL)
{
strcpy (last_lc_ctype, lc_ctype);
strcpy (lc_ctype, locale);
__mb_cur_max_dll = 1;
}
}
else
{
if (strcmp (locale, "C") && strcmp (locale, "") &&
strcmp (locale, "C") && strcmp (locale, "C-JIS") &&
strcmp (locale, "C-EUCJP") && strcmp (locale, "C-SJIS"))
return 0;
strcpy (last_lc_ctype, lc_ctype);
strcpy (lc_ctype, locale);
if (!strcmp (locale, "C-JIS"))
__mb_cur_max_dll = 8;
else if (strlen (locale) > 1)
__mb_cur_max_dll = 2;
else
__mb_cur_max_dll = 1;
}
_current_category = category;
_current_locale = locale;
if (category == LC_CTYPE)
return last_lc_ctype;
}
else
{
if (category == LC_CTYPE)
return lc_ctype;
}
return "C";
#endif
}
struct lconv _lconv;
struct lconv *localeconv(void)
{
return (struct lconv *) &lconv;
return (struct lconv *) &_lconv;
}

View file

@ -19,15 +19,32 @@ CTYPE_OBJECTS = ctype/isalnum.o \
ctype/isxdigit.o ctype/toascii.o ctype/tolower.o ctype/toupper.o\
ctype/iscsym.o ctype/isctype.o
CONIO_OBJECTS = conio/cputs.o conio/getch.o conio/getche.o conio/putch.o conio/ungetch.o
CONIO_OBJECTS = conio/cputs.o conio/getch.o conio/getche.o conio/putch.o conio/ungetch.o\
conio/kbhit.o conio/cgets.o conio/cprintf.o conio/cscanf.o
DIRECT_OBJECTS = direct/chdir.o direct/chdrive.o direct/getcwd.o direct/getdrive.o \
direct/rmdir.o direct/mkdir.o direct/getdfree.o
direct/rmdir.o direct/mkdir.o direct/getdfree.o direct/getdcwd.o
EXCEPT_OBJECTS = except/unwind.o except/abnorter.o except/exhand2.o except/matherr.o
LOCALE_OBJECTS = locale/locale.o
MALLOC_OBJECTS = malloc/expand.o malloc/heap.o
#MISC_OBJECTS = misc/GetArgs.o misc/setnew.o misc/purecall.o
MISC_OBJECTS = misc/GetArgs.o
MISC_OBJECTS = misc/GetArgs.o misc/dllmain.o misc/setnew.o misc/purecall.o misc/initterm.o\
misc/amsg.o
MBSTRING_OBJECTS = mbstring/mbsnicmp.o mbstring/mbsnset.o mbstring/mbsnextc.o mbstring/mbsnicoll.o mbstring/islead.o mbstring/mbsspnp.o \
mbstring/mbspbrk.o mbstring/mbsspn.o mbstring/mbbtype.o mbstring/mbscat.o mbstring/mbschr.o \
mbstring/mbccpy.o mbstring/mbslen.o mbstring/mbsrchr.o mbstring/mbsset.o mbstring/mbsncat.o mbstring/mbsncmp.o \
mbstring/mbscmp.o mbstring/mbsncoll.o mbstring/mbscoll.o mbstring/mbsncpy.o mbstring/mbscpy.o mbstring/mbscspn.o \
mbstring/mbsdup.o mbstring/mbsicmp.o mbstring/mbsicoll.o mbstring/mbsnccnt.o mbstring/mbsrev.o mbstring/mbsstr.o \
mbstring/mbsinc.o mbstring/mbsdec.o mbstring/mbsninc.o mbstring/mbclen.o mbstring/iskana.o mbstring/jmstojis.o \
mbstring/jistojms.o mbstring/iskpun.o mbstring/iskmoji.o mbstring/ismbgra.o mbstring/ismbpri.o mbstring/isuppr.o \
mbstring/islwr.o mbstring/ismbkaln.o mbstring/mbstrlen.o mbstring/ismbc.o \
mbstring/ismbtrl.o mbstring/ismblead.o mbstring/ischira.o mbstring/hanzen.o mbstring/ismbaln.o mbstring/ismbal.o \
mbstring/ismbpun.o mbstring/mbslwr.o mbstring/mbsupr.o mbstring/mbstok.o
STRING_OBJECTS = string/memchr.o string/memcmp.o string/strcat.o \
string/strchr.o string/strcmp.o string/strcoll.o \
@ -38,13 +55,19 @@ STRING_OBJECTS = string/memchr.o string/memcmp.o string/strcat.o \
string/strxfrm.o string/memmove.o string/memset.o \
string/strdup.o string/strlwr.o string/strupr.o \
string/str_old.o string/strerror.o string/stricmp.o\
string/strnlen.o string/strnicmp.o
string/strnlen.o string/strnicmp.o string/strrev.o\
string/memccpy.o string/memicmp.o string/strset.o
WCHAR_OBJECTS = wchar/wcscat.o wchar/wcschr.o wchar/wcscmp.o \
wchar/wcscoll.o wchar/wcscpy.o wchar/wcscspn.o \
wchar/wcsdup.o wchar/wcsicmp.o wchar/wcslen.o \
wchar/wcslwr.o wchar/wcsncat.o wchar/wcsncmp.o \
wchar/wcsncpy.o
wchar/wcsncpy.o wchar/wcsnlen.o wchar/wcspbrk.o wchar/wcsrchr.o\
wchar/wcsrev.o wchar/wcsset.o wchar/wcsspn.o wchar/wcsstr.o\
wchar/wcstod.o wchar/wcstok.o wchar/wcstol.o wchar/wcsupr.o\
wchar/wcsxfrm.o wchar/wtoi.o wchar/wcstombs.o wchar/wcsnicmp.o
SETJMP_OBJECTS = setjmp/setjmp.o
STDIO_OBJECTS = stdio/getenv.o stdio/filbuf.o \
stdio/fclose.o stdio/feof.o stdio/ferror.o stdio/fileno.o\
@ -53,46 +76,51 @@ STDIO_OBJECTS = stdio/getenv.o stdio/filbuf.o \
stdio/fread.o stdio/freopen.o stdio/fscanf.o stdio/fseek.o \
stdio/fsetpos.o stdio/ftell.o stdio/fwalk.o stdio/fwrite.o stdio/getc.o \
stdio/getchar.o stdio/gets.o stdio/getw.o stdio/perror.o stdio/clearerr.o \
stdio/putc.o stdio/putchar.o stdio/puts.o stdio/putw.o \
stdio/putc.o stdio/putchar.o stdio/puts.o stdio/putw.o stdio/fputchar.o\
stdio/remove.o stdio/rename.o stdio/rewind.o stdio/allocfil.o\
stdio/setbuf.o stdio/setbuffe.o stdlib/obsol.o stdio/setlineb.o\
stdio/scanf.o stdio/sscanf.o stdio/vscanf.o stdio/vsscanf.o stdio/vfscanf.o\
stdio/stdiohk.o stdio/stdhnd.o stdio/tempnam.o stdio/tmpfile.o stdio/tmpnam.o \
stdio/ungetc.o stdio/printf.o stdio/vfprintf.o stdio/vprintf.o stdio/sprintf.o\
stdio/fdopen.o stdio/vsprintf.o stdio/frlist.o \
stdio/fdopen.o stdio/vsprintf.o stdio/frlist.o stdio/fgetchar.o stdio/rmtmp.o\
stdio/fsopen.o stdio/popen.o
QUAD_OBJECTS = quad/qdivrem.o quad/divdi3.o quad/moddi3.o quad/udivdi3.o quad/umoddi3.o
IO_OBJECTS = io/access.o io/close.o io/create.o io/dup.o io/dup2.o io/find.o io/isatty.o io/lseek.o \
io/open.o io/read.o io/setmode.o io/unlink.o io/write.o io/fmode.o io/mktemp.o\
io/chmod.o io/chsize.o io/commit.o io/locking.o io/pipe.o io/sopen.o io/filelen.o\
io/umask.o io/tell.o io/eof.o io/utime.o
io/umask.o io/tell.o io/eof.o io/utime.o
SEARCH_OBJECTS = search/lsearch.o search/lfind.o
STDLIB_OBJECTS = stdlib/abort.o stdlib/abs.o stdlib/atexit.o stdlib/atof.o stdlib/atoi.o \
stdlib/bsearch.o stdlib/div.o stdlib/errno.o stdlib/_exit.o \
stdlib/fullpath.o stdlib/labs.o stdlib/ldiv.o \
stdlib/fullpath.o stdlib/labs.o stdlib/ldiv.o stdlib/itoa.o\
stdlib/makepath.o stdlib/malloc.o stdlib/putenv.o stdlib/qsort.o \
stdlib/rand.o stdlib/senv.o stdlib/splitp.o stdlib/strtod.o stdlib/strtol.o \
stdlib/strtoul.o stdlib/swab.o stdlib/atol.o
stdlib/strtoul.o stdlib/swab.o stdlib/atol.o stdlib/rot.o stdlib/wcstomb.o\
stdlib/ecvt.o stdlib/ecvtbuf.o stdlib/gcvt.o stdlib/fcvt.o stdlib/fcvtbuf.o\
stdlib/mbstowcs.o
SIGNAL_OBJECTS = signal/signal.o
SIGNAL_OBJECTS = signal/signal.o signal/xcptfil.o signal/xcptinfo.o
PROCESS_OBJECTS = process/_cwait.o process/dll.o process/spawnl.o process/spawnlp.o process/spawnlpe.o process/spawnvpe.o process/spawnvp.o \
process/spawnv.o process/spawnve.o process/spawnle.o process/execl.o process/execlp.o process/execlpe.o \
process/execvpe.o process/execvp.o process/execv.o process/execle.o process/_system.o\
process/threadid.o
process/execve.o process/threadid.o process/thread.o process/procid.o
TCHAR_OBJECTS = tchar/strdec.o tchar/strinc.o tchar/strninc.o tchar/strncnt.o tchar/strnextc.o tchar/strspnp.o
TIME_OBJECTS = time/ctime.o time/difftime.o time/strftime.o time/time.o time/clock.o
TIME_OBJECTS = time/ctime.o time/difftime.o time/strftime.o time/time.o time/clock.o time/strdate.o\
time/strtime.o
# float/fpclass.o
FLOAT_OBJECTS = float/fpreset.o float/clearfp.o float/cntrlfp.o float/statfp.o float/logb.o\
float/chgsign.o float/isnan.o
float/chgsign.o float/fpclass.o float/isnan.o float/nafter.o float/scalb.o\
float/copysign.o
SYS_STAT_OBJECTS = sys_stat/fstat.o sys_stat/stat.o sys_stat/futime.o
SYS_STAT_OBJECTS = sys_stat/fstat.o sys_stat/stat.o sys_stat/futime.o sys_stat/ftime.o\
sys_stat/systime.o
@ -101,34 +129,19 @@ MATH_OBJECTS = math/acos.o math/acosh.o math/asin.o math/asinh.o math/atan.o mat
math/floor.o math/fmod.o math/frexp.o math/huge_val.o math/hypot.o\
math/ldexp.o math/log.o math/log10.o math/modf.o math/pow.o\
math/sin.o math/sinh.o math/sqrt.o math/tan.o\
math/tanh.o math/stubs.o math/j0_y0.o math/j1_y1.o math/jn_yn.o
math/tanh.o math/stubs.o math/j0_y0.o math/j1_y1.o math/jn_yn.o\
math/cabs.o math/ftol.o
#OBJECTS = $(ASSERT_OBJECTS) $(CTYPE_OBJECTS) $(CONIO_OBJECTS) $(DIRECT_OBJECTS)\
# $(MISC_OBJECTS) $(STRING_OBJECTS) $(STDIO_OBJECTS) $(STDLIB_OBJECTS) \
# $(IO_OBJECTS) $(PROCESS_OBJECTS) $(TIME_OBJECTS) $(MALLOC_OBJECTS)\
# $(SYS_STAT_OBJECTS) $(SIGNAL_OBJECTS) $(MATH_OBJECTS) $(FLOAT_OBJECTS)\
# $(SEARCH_OBJECTS) $(QUAD_OBJECTS)
OLD_OBJECTS = $(MISC_OBJECTS) stdlib/malloc.o stdlib/abort.o \
stdlib/_exit.o stdlib/atexit.o stdio/fileno.o io/fmode.o \
float/fpreset.o stdio/stdhnd.o io/setmode.o io/open.o \
stdio/vsprintf.o $(CTYPE_OBJECTS) stdlib/atoi.o stdlib/strtol.o \
stdio/flsbuf.o stdio/putc.o stdio/vfprintf.o $(STRING_OBJECTS)\
io/write.o io/isatty.o sys_stat/fstat.o misc/dllmain.o \
stdlib/errno.o stdio/printf.o stdio/vprintf.o\
$(QUAD_OBJECTS)
#RESOURCE_OBJECT = crtdll.coff
RESOURCE_OBJECT = crtdll.coff
OBJECTS = $(MISC_OBJECTS) $(STDLIB_OBJECTS) $(IO_OBJECTS) \
$(FLOAT_OBJECTS) $(ASSERT_OBJECTS) $(PROCESS_OBJECTS) \
$(STDIO_OBJECTS) $(CTYPE_OBJECTS) $(MATH_OBJECTS) \
$(STRING_OBJECTS) $(TIME_OBJECTS) $(WCHAR_OBJECTS) \
$(SYS_STAT_OBJECTS) misc/dllmain.o $(MALLOC_OBJECTS) \
$(SYS_STAT_OBJECTS) $(MALLOC_OBJECTS) $(MBSTRING_OBJECTS)\
$(SEARCH_OBJECTS) $(CONIO_OBJECTS) $(DIRECT_OBJECTS) \
$(SIGNAL_OBJECTS) $(RESOURCE_OBJECT)
$(SIGNAL_OBJECTS) $(SETJMP_OBJECTS) $(RESOURCE_OBJECT) \
$(LOCALE_OBJECTS) $(EXCEPT_OBJECTS) $(TCHAR_OBJECTS)
ifeq ($(DOSCLI), yes)
CLEAN_FILES = assert\*.o conio\*.o ctype\*.o direct\*.o dirent\*.o \

View file

@ -2,7 +2,8 @@
double _cabs( struct _complex z )
{
return hypot(z.x,z.y);
return sqrt( z.x*z.x + z.y*z.y );
// return hypot(z.x,z.y);
}

View file

@ -1,3 +1,5 @@
long __cdecl ftol(double fl) {
#include <crtdll/float.h>
long _ftol(double fl) {
return (long)fl;
}

View file

@ -1,14 +1,16 @@
#include <mbctype.h>
/*
* japanese code system utilities < jutil.h >
*
*
*
* Copyright (c) 1992-94 Tokyo Denki University, Taiji Yamada
* Copyright (c) 1997 AIHARA Electrical Engineering Co.,Ltd., Taiji Yamada
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/hanzen.c
* PURPOSE: Multibyte conversion routines formerly called hantozen and zentohan
* PROGRAMER: Boudewijn Dekker, Taiji Yamada
* UPDATE HISTORY:
Modified from Taiji Yamada japanese code system utilities
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
static unsigned short han_to_zen_ascii_table[0x5f] = {
0x8140, 0x8149, 0x8168, 0x8194, 0x8190, 0x8193, 0x8195, 0x8166,
0x8169, 0x816a, 0x8196, 0x817b, 0x8143, 0x817c, 0x8144, 0x815e,
@ -59,7 +61,7 @@ static unsigned char zen_to_han_symbol_table_2[ZTOH_SYMBOLS] = {
#define JTOKANA(c) ((c) <= 0x82dd ? (c) + 0xa1 : (c) + 0xa2)
static unsigned short _mbbtombc(unsigned short c)
unsigned short _mbbtombc(unsigned short c)
{
if (c >= 0x20 && c <= 0x7e) {
return han_to_zen_ascii_table[c - 0x20];
@ -70,7 +72,7 @@ static unsigned short _mbbtombc(unsigned short c)
}
static unsigned short _mbctombb(unsigned short c)
unsigned short _mbctombb(unsigned short c)
{
int i;
unsigned short *p;

View file

@ -0,0 +1,32 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/ischira.c
* PURPOSE:
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
int _ismbchira( unsigned int c )
{
return ((c>=0x829F) && (c<=0x82F1));
}
int _ismbckata( unsigned int c )
{
return ((c>=0x8340) && (c<=0x8396));
}
unsigned int _mbctohira( unsigned int c )
{
return c;
}
unsigned int _mbctokata( unsigned int c )
{
return c;
}

View file

@ -0,0 +1,17 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/hanzen.c
* PURPOSE: Checks for kana character
* PROGRAMER: Boudewijn Dekker, Taiji Yamada
* UPDATE HISTORY:
Modified from Taiji Yamada japanese code system utilities
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
int _ismbbkana(unsigned char c)
{
return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_M|_KNJ_P));
}

View file

@ -0,0 +1,6 @@
#include <crtdll/mbctype.h>
int _ismbbkalpha(unsigned char c)
{
return (0xA7 <= c <= 0xDF);
}

View file

@ -0,0 +1,15 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/iskpun.c
* PURPOSE:
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
int _ismbbkpunct( unsigned int c )
{
return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P));
}

View file

@ -3,5 +3,6 @@
int isleadbyte(char *mbstr)
{
return IsDBCSLeadByteEx(0,*c);
return 0;
//return IsDBCSLeadByteEx(0,*c);
}

View file

@ -0,0 +1,23 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/mbsncmp.c
* PURPOSE:
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
// code page 952 only
int _ismbclower( unsigned int c )
{
if ((c & 0xFF00) != 0) {
if ( c >= 0x829A && c<= 0x829A )
return 1;
}
else
return isupper(c);
}

View file

@ -0,0 +1,16 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/hanzen.c
* PURPOSE: Checks for alphabetic multibyte character
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
int _ismbbalpha(unsigned char c)
{
return (isalpha(c) ||_ismbbkalnum(c));
}

View file

@ -0,0 +1,6 @@
#include <crtdll/mbctype.h>
int _ismbbalnum(unsigned char c)
{
return (isalnum(c) || _ismbbkalnum(c));
}

View file

@ -0,0 +1,103 @@
#include <crtdll/mbstring.h>
int _ismbcalnum( unsigned int c )
{
if ((c & 0xFF00) != 0) {
// true multibyte character
return 0;
}
else
return _ismbbalnum(c);
return 0;
}
int _ismbcalpha( unsigned int c )
{
if ((c & 0xFF00) != 0) {
// true multibyte character
return 0;
}
else
return _ismbbalpha(c);
return 0;
}
int _ismbcdigit( unsigned int c )
{
if ((c & 0xFF00) != 0) {
// true multibyte character
return 0;
}
else
return 0;
// return _ismbbdigit(c);
return 0;
}
int _ismbcprint( unsigned int c )
{
if ((c & 0xFF00) != 0) {
// true multibyte character
return 0;
}
else
return 0;
// return _ismbbdigit(c);
return 0;
}
int _ismbcsymbol( unsigned int c )
{
if ((c & 0xFF00) != 0) {
// true multibyte character
return 0;
}
else
return 0;
// return _ismbbdigit(c);
return 0;
}
int _ismbcspace( unsigned int c )
{
if ((c & 0xFF00) != 0) {
// true multibyte character
return 0;
}
else
return 0;
// return _ismbbdigit(c);
return 0;
}
int _ismbclegal(unsigned int c)
{
if ((c & 0xFF00) != 0) {
return _ismbblead(c>>8) && _ismbbtrail(c&0xFF);
}
else
return _ismbbtrail(c&0xFF);
return 0;
}
int _ismbcl0(unsigned int c)
{
return 0;
}
int _ismbcl1(unsigned int c)
{
return 0;
}
int _ismbcl2(unsigned int c)
{
return 0;
}

View file

@ -0,0 +1,8 @@
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
int _ismbbgraph(unsigned char c)
{
return (isgraph(c) || _ismbbkana(c));
}

View file

@ -0,0 +1,15 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/iskpun.c
* PURPOSE:
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
int _ismbbkalnum( unsigned int c )
{
return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P));
}

View file

@ -5,22 +5,16 @@
* PURPOSE: Checks for a lead byte
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* Modified from Taiji Yamada japanese code system utilities
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/stdlib.h>
#include <crtdll/mbctype.h>
#define ___ 0
#define _1_ _KNJ_1 /* Legal 1st byte of double byte code */
#define __2 _KNJ_2 /* Legal 2nd byte of double byte code */
#define _M_ _KNJ_M /* Non-puntuation in Kana-set */
#define _P_ _KNJ_P /* Punctuation of Kana-set */
#define _12 (_1_|__2)
#define _M2 (_M_|__2)
#define _P2 (_P_|__2)
static char _jctype[257] = {
char _jctype[257] = {
/*-1*/ ___,
/*0x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
/*1x*/ ___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,
@ -40,10 +34,8 @@ static char _jctype[257] = {
/*Fx*/ _12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,_12,___,___,___
};
iskanji() : ƒVƒtƒg JIS ƒR<EFBFBD>[ƒhÌ1ƒoƒCƒgÚ(0x81 <= c <= 0x9F é
¢Í0xE0 <= c <= 0xFC) ©Ç¤©
int _ismbblead(char c)
char *_mbctype = _jctype;
int _ismbblead(unsigned int c)
{
return ((_jctype+1)[(unsigned char)(c)] & _KNJ_1);
}
@ -55,12 +47,12 @@ int _ismbblead(char c)
int _ismbslead( const unsigned char *str, const unsigned char *t)
{
char *s = str;
unsigned char *s = (unsigned char *)str;
while(*s != 0 && s != t)
{
s+= mblen(*s);
s+= _mbclen2(*s);
}
return ismbblead( *s)
return _ismbblead( *s);
}

View file

@ -0,0 +1,8 @@
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
int _ismbbprint(unsigned char c)
{
return (isprint(c) || _ismbbkana(c));
}

View file

@ -0,0 +1,13 @@
//iskana() :(0xA1 <= c <= 0xDF)
//iskpun() :(0xA1 <= c <= 0xA6)
//iskmoji() :(0xA7 <= c <= 0xDF)
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
int _ismbbpunct(unsigned char c)
{
// (0xA1 <= c <= 0xA6)
return (ispunct(c) || _ismbbkana(c));
}

View file

@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/ismblead.c
* FILE: lib/crtdll/mbstring/ismbtrail.c
* PURPOSE: Checks for a trailing byte
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
@ -9,9 +9,9 @@
*/
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
iskanji2() : ƒVƒtƒg JIS ƒR<EFBFBD>[ƒhÌ2ƒoƒCƒgÚ(0x40 <= c <= 0x7E é
¢Í0x80 <= c <= 0xFC) ©Ç¤©
// iskanji2() : (0x40 <= c <= 0x7E 0x80 <= c <= 0xFC)
int _ismbbtrail(unsigned int c)
{
@ -26,12 +26,12 @@ int _ismbbtrail(unsigned int c)
int _ismbstrail( const unsigned char *str, const unsigned char *t)
{
char *s = str;
unsigned char *s = (unsigned char *)str;
while(*s != 0 && s != t)
{
s+= mblen(*s);
s+= _mbclen2(*s);
}
return _ismbbtrail( *s)
return _ismbbtrail(*s);
}

View file

@ -0,0 +1,23 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/mbsncmp.c
* PURPOSE:
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
// code page 952 only
int _ismbcupper( unsigned int c )
{
if ((c & 0xFF00) != 0) {
if ( c >= 0x8260 && c<= 0x8279 )
return 1;
}
else
return isupper(c);
}

View file

@ -0,0 +1,24 @@
#include <crtdll/mbstring.h>
unsigned short _mbcjistojms(unsigned short c)
{
int c1, c2;
c2 = (unsigned char)c;
c1 = c >> 8;
if (c1 >= 0x21 && c1 <= 0x7e && c2 >= 0x21 && c2 <= 0x7e) {
if (c1 & 0x01) {
c2 += 0x1f;
if (c2 >= 0x7f)
c2 ++;
} else {
c2 += 0x7e;
}
c1 += 0xe1;
c1 >>= 1;
if (c1 >= 0xa0)
c1 += 0x40;
return ((c1 << 8) | c2);
}
return 0;
}

View file

@ -0,0 +1,25 @@
#include <crtdll/mbstring.h>
unsigned short _mbcjmstojis(unsigned short c)
{
int c1, c2;
c2 = (unsigned char)c;
c1 = c >> 8;
if (c1 < 0xf0 && _ismbblead(c1) && _ismbbtrail(c2)) {
if (c1 >= 0xe0)
c1 -= 0x40;
c1 -= 0x70;
c1 <<= 1;
if (c2 < 0x9f) {
c1 --;
c2 -= 0x1f;
if (c2 >= (0x80-0x1f))
c2 --;
} else {
c2 -= 0x7e;
}
return ((c1 << 8) | c2);
}
return 0;
}

View file

@ -1,29 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/ismblead.c
* PURPOSE: Converts a multi byte byte to a multibyte character
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
char _mbctype[256];
// multibyte byte to multibyte character ????
unsigned int _mbbtombc(unsigned int c)
{
if (( c > = 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) {
// convert
}
return c;
}
unsigned int _mbctombb( unsigned int c )
{
return c;
}

View file

@ -9,11 +9,12 @@
*/
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
int _mbbtype(unsigned char c , int type)
{
if ( type == 1 ) {
if ((b >= 0x40 && b <= 0x7e ) || (b >= 0x80 && b <= 0xfc ) )
if ((c >= 0x40 && c <= 0x7e ) || (c >= 0x80 && c <= 0xfc ) )
{
return _MBC_TRAIL;
}
@ -25,12 +26,12 @@ int _mbbtype(unsigned char c , int type)
}
else {
if (( c > = 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) {
if (( c >= 0x20 && c <= 0x7E ) || ( c >= 0xA1 && c <= 0xDF )) {
return _MBC_SINGLE;
}
else if ( (c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC) )
return _MBC_LEAD;
else if else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
else if (( c >= 0x20 && c >= 0x7E ) || ( c >= 0xA1 && c <= 0xDF ) ||
( c >= 0x81 && c <= 0x9F ) || ( c >= 0xE0 && c <= 0xFC ) )
return _MBC_ILLEGAL;
else
@ -44,5 +45,7 @@ int _mbbtype(unsigned char c , int type)
int _mbsbtype( const unsigned char *str, size_t n )
{
return 0;
if ( str == NULL )
return -1;
return _mbbtype(*(str+n),1);
}

View file

@ -5,5 +5,5 @@ void _mbccpy(unsigned char *dst, const unsigned char *src)
if (!_ismbblead(*src) )
return;
memcpy(dst,src,mbclen(*src));
memcpy(dst,src,_mbclen2(*src));
}

View file

@ -1,18 +1,29 @@
//#include <crtdll/mbstring.h>
#include <crtdll/mbstring.h>
#include <crtdll/stdlib.h>
size_t _mbclen(const unsigned char *s)
{
// return _ismbblead(s) ? 2 : 1;
return 1;
return (_ismbblead(*s>>8) && _ismbbtrail(*s&0x00FF)) ? 2 : 1;
}
int mblen( const char *mbstr, size_t count )
size_t _mbclen2(const unsigned int s)
{
return 1;
return (_ismbblead(s>>8) && _ismbbtrail(s&0x00FF)) ? 2 : 1;
}
// assume MB_CUR_MAX == 2
int mblen( const char *s, size_t count )
{
size_t l;
if ( s == NULL )
return 0;
l = _mbclen(s);
if ( l < count )
return -1;
return l;
}

View file

@ -10,7 +10,86 @@
#include <crtdll/mbstring.h>
int colldif(unsigned short c1, unsigned short c2);
int _mbscoll(const unsigned char *str1, const unsigned char *str2)
{
return strcoll(str1,str2);
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
while ( *s1 != 0 ) {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
}
}
else
return colldif(*s1, *s2);
} ;
return 0;
}
int _mbsbcoll(const unsigned char *str1, const unsigned char *str2)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
while ( *s1 != 0 ) {
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
}
}
else
return colldif(*s1, *s2);
} ;
return 0;
}

View file

@ -1,4 +1,18 @@
size_t _mbscspn(const unsigned char *str, const unsigned char *set)
#include <crtdll/mbstring.h>
// not correct
size_t _mbscspn(const unsigned char *s1, const unsigned char *s2)
{
return strcspn(str,set);
const char *p, *spanp;
char c, sc;
for (p = s1;;)
{
c = *p++;
spanp = s2;
do {
if ((sc = *spanp++) == c)
return (size_t)(p - 1) - (size_t)s1;
} while (sc != 0);
}
/* NOTREACHED */
}

View file

@ -2,5 +2,13 @@
unsigned char * _mbsdec(const unsigned char *str, const unsigned char *cur)
{
return strdec(str,cur);
unsigned char *s = (unsigned char *)cur;
if ( str >= cur )
return NULL;
s--;
if (_ismbblead(*(s-1)) )
s--;
return s;
}

View file

@ -1,4 +1,25 @@
unsigned char * _mbsdup(const unsigned char *str)
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/hanzen.c
* PURPOSE: Duplicates a multi byte string
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
Modified from DJGPP strdup
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/stdlib.h>
unsigned char * _mbsdup(const unsigned char *_s)
{
return strdup(str);
char *rv;
if (_s == 0)
return 0;
rv = (char *)malloc(_mbslen(_s) + 1);
if (rv == 0)
return 0;
_mbscpy(rv, _s);
return rv;
}

View file

@ -1,4 +1,62 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/mbsicmp.c
* PURPOSE: Duplicates a multi byte string
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
int _mbsicmp(const unsigned char *str1, const unsigned char *str2)
{
return stricmp(str1,str2);
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
do {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (toupper(*s1) != toupper(*s2))
return toupper(*s1) - toupper(*s2);
else {
s1 += 1;
s2 += 1;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 ))
return _mbctoupper(*short_s1) - _mbctoupper(*short_s2);
else {
s1 += 2;
s2 += 2;
}
}
else
return *s1 - *s2;
} while (*s1 != 0);
return 0;
while (toupper(*s1) == toupper(*s2))
{
if (*s1 == 0)
return 0;
s1++;
s2++;
}
return toupper(*(unsigned const char *)s1) - toupper(*(unsigned const char *)(s2));
}

View file

@ -1,4 +1,54 @@
int _mbsicoll(const unsigned char *dest, const unsigned char *src)
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/iskpun.c
* PURPOSE:
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/mbctype.h>
#include <crtdll/ctype.h>
int colldif(unsigned short c1, unsigned short c2);
int _mbsicoll(const unsigned char *str1, const unsigned char *str2)
{
return stricoll(dest,src);
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
while ( *s1 != 0 ) {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (toupper(*s1) != toupper(*s2))
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( _mbctoupper(*short_s1) != _mbctoupper(*short_s2 ))
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
}
}
else
return colldif(*s1, *s2);
} ;
return 0;
}

View file

@ -3,5 +3,8 @@
unsigned char * _mbsinc(const unsigned char *s)
{
unsigned char *c = (unsigned char *)s;
return c + (unsigned char *)mbclen(*c);
if (_ismbblead(*s) )
c++;
c++;
return c;
}

View file

@ -1,3 +1,5 @@
#include <crtdll/mbstring.h>
size_t _mbslen(const unsigned char *str)
{
int i = 0;
@ -6,6 +8,6 @@ size_t _mbslen(const unsigned char *str)
if (str == 0)
return 0;
for (s = (unsigned char *)str; *s; s+=mbclen(*s),i++);
for (s = (unsigned char *)str; *s; s+=_mbclen2(*s),i++);
return i;
}

View file

@ -1,20 +1,40 @@
#include <mbstring.h>
#include <crtdll/mbstring.h>
#include <crtdll/ctype.h>
unsigned int _mbctolower(unsigned int c)
unsigned int _mbbtolower(unsigned int c)
{
if (!_ismbblead(c) )
return tolower(c);
return c;
}
// code page 952
#define CASE_DIFF (0x8281 - 0x8260)
unsigned int _mbctolower(unsigned int c)
{
if ((c & 0xFF00) != 0) {
// true multibyte case conversion needed
if ( _ismbclower(c) )
return c + CASE_DIFF;
} else
return _mbbtolower(c);
return 0;
}
unsigned char * _mbslwr(unsigned char *x)
{
char *y=x;
unsigned char *y=x;
while (*y) {
*y=_mbctolower(*y);
y++;
while (*y) {
if (!_ismbblead(*y) )
*y = tolower(*y);
else {
*y=_mbctolower(*(unsigned short *)y);
y++;
}
}
return x;
}

View file

@ -13,11 +13,11 @@
unsigned char * _mbsncat(unsigned char *dst, const unsigned char *src, size_t n)
{
char *d;
const char *s = src;
char *d = (char *)dst;
char *s = (char *)src;
if (n != 0) {
d = dst + strlen(dst); // get the end of string
d += mblen(*d); // move 1 or 2 up
d += _mbclen2(*d); // move 1 or 2 up
do {
if ((*d++ = *s++) == 0)
@ -26,7 +26,7 @@ unsigned char * _mbsncat(unsigned char *dst, const unsigned char *src, size_t n)
*d++ = 0;
break;
}
if (!_ismbblead(*s1) )
if (!_ismbblead(*s) )
n--;
} while (n > 0);
}
@ -36,10 +36,10 @@ unsigned char * _mbsncat(unsigned char *dst, const unsigned char *src, size_t n)
unsigned char * _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t n)
{
char *d;
const char *s = src;
char *s = (char *)src;
if (n != 0) {
d = dst + strlen(dst); // get the end of string
d += mblen(*d); // move 1 or 2 up
d += _mbclen2(*d); // move 1 or 2 up
do {
if ((*d++ = *s++) == 0)
@ -48,7 +48,7 @@ unsigned char * _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t n
*d++ = 0;
break;
}
if ( !(n==1 && _ismbblead(*s1)) )
if ( !(n==1 && _ismbblead(*s)) )
n--;
} while (n > 0);
}

View file

@ -1,11 +1,25 @@
#include <crtdll/mbstring.h>
size_t _mbsnccnt(const unsigned char *str, size_t n)
{
unsigned char *s = (unsigned char *)str;
size_t cnt = 0;
while(*s != 0 && n > 0) {
if (_ismbblead(*s) )
s++;
else
n--;
s++;
cnt++;
}
return cnt;
}
size_t _mbsnbcnt(const unsigned char *str, size_t n)
{
unsigned char *s = str;
while(*s != 0 && n > 0)
unsigned char *s = (unsigned char *)str;
while(*s != 0 && n > 0) {
if (!_ismbblead(*s) )
n--;
s++;

View file

@ -12,36 +12,92 @@
int _mbsncmp(const unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1;
unsigned char *s2;
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
if (n == 0)
return 0;
do {
if (*s1 != *s2++)
return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
if (*s1++ == 0)
break;
if (!_ismbblead(*s1) )
n--;
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return *s1 - *s2;
else {
s1 += 1;
s2 += 1;
n--;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return *short_s1 - *short_s2;
else {
s1 += 2;
s2 += 2;
n--;
}
}
else
return *s1 - *s2;
} while (n > 0);
return 0;
return 0;
}
int _mbsnbcmp(const unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1;
unsigned char *s2;
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
if (n == 0)
return 0;
do {
if (*s1 != *s2++)
return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
if (*s1++ == 0)
break;
if (!(n == 1 && _ismbblead(*s)) )
n--;
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return *s1 - *s2;
else {
s1 += 1;
s2 += 1;
n--;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return *short_s1 - *short_s2;
else {
s1 += 2;
s2 += 2;
n-=2;
}
}
else
return *s1 - *s2;
} while (n > 0);
return 0;
}

View file

@ -9,34 +9,101 @@
*/
#include <crtdll/mbstring.h>
int _mbsncoll(const unsigned char *, const unsigned char *, size_t)
int colldif(unsigned short c1, unsigned short c2);
int _mbsncoll(const unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
int ret;
l1 = mbslen(str1);
l2 = mbslen(str2);
ret = CompareStringA(LOCALE_USER_DEFAULT,0,str1,min(l1,n),str2,min(l2,n));
if ( ret != 0 )
return ret -2;
if (n == 0)
return 0;
do {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
n--;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
n--;
}
}
else
return colldif(*s1, *s2);
} while (n > 0);
return 0;
}
int _mbsnbcoll(const unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
unsigned short *short_s1, *short_s2;
int l1, l2;
int ret;
l1 = strlen(str1);
l2 = strlen(str2);
ret = CompareStringA(LOCALE_USER_DEFAULT,0,str1,min(l1,n),str2,min(l2,n));
if ( ret != 0 )
return ret -2;
if (n == 0)
return 0;
do {
if (*s1 == 0)
break;
l1 = _ismbblead(*s1);
l2 = _ismbblead(*s2);
if ( !l1 && !l2 ) {
if (*s1 != *s2)
return colldif(*s1, *s2);
else {
s1 += 1;
s2 += 1;
n--;
}
}
else if ( l1 && l2 ){
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
if ( *short_s1 != *short_s2 )
return colldif(*short_s1, *short_s2);
else {
s1 += 2;
s2 += 2;
n-=2;
}
}
else
return colldif(*s1, *s2);
} while (n > 0);
return 0;
}
int colldif(unsigned short c1, unsigned short c2)
{
return c1 - c2;
}

View file

@ -1,43 +1,77 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/mbsncpy.c
* PURPOSE: Copies a string to a maximum of n bytes or characters
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
unsigned char * _mbsncpy(unsigned char *dst, const unsigned char *src, size_t n)
unsigned char *_mbsncpy(unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *d = dst;
const unsigned char *s = src;
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
if (n != 0) {
do {
if ((*d++ = *s++) == 0)
{
while (--n != 0) {
*d++ = 0;
}
break;
}
if (!_ismbblead(*s) )
n--;
} while (n > 0);
}
return dst;
unsigned short *short_s1, *short_s2;
if (n == 0)
return 0;
do {
if (*s2 == 0)
break;
if ( !_ismbblead(*s2) ) {
*s1 = *s2;
s1 += 1;
s2 += 1;
n--;
}
else {
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
*short_s1 = *short_s2;
s1 += 2;
s2 += 2;
n--;
}
} while (n > 0);
return str1;
}
unsigned char * _mbsnbcpy(unsigned char *src, const unsigned char *dst, size_t n)
unsigned char * _mbsnbcpy(unsigned char *str1, const unsigned char *str2, size_t n)
{
unsigned char *d = dst;
const unsigned char *s = src;
unsigned char *s1 = (unsigned char *)str1;
unsigned char *s2 = (unsigned char *)str2;
if (n != 0) {
do {
if ((*d++ = *s++) == 0)
{
while (--n != 0) {
*d++ = 0;
}
break;
}
if (!(n == 1 && _ismbblead(*s)) )
n--;
} while (n > 0);
}
return dst;
unsigned short *short_s1, *short_s2;
if (n == 0)
return 0;
do {
if (*s2 == 0)
break;
if ( !_ismbblead(*s2) ) {
*s1 = *s2;
s1 += 1;
s2 += 1;
n--;
}
else {
short_s1 = (unsigned short *)s1;
short_s2 = (unsigned short *)s2;
*short_s1 = *short_s2;
s1 += 2;
s2 += 2;
n-=2;
}
} while (n > 0);
return str1;
}

View file

@ -0,0 +1,18 @@
#include <crtdll/mbstring.h>
unsigned int _mbsnextc (const unsigned char *src)
{
unsigned char *char_src = (unsigned char *)src;
unsigned short *short_src = (unsigned short *)src;
if ( src == NULL )
return 0;
if ( !_ismbblead(*src) )
return *char_src;
else
return *short_src;
return 0;
}

View file

@ -0,0 +1,37 @@
#include <crtdll/mbstring.h>
int _mbsnicmp(const unsigned char *s1, const unsigned char *s2, size_t n)
{
if (n == 0)
return 0;
do {
if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
*s1 += _mbclen2(*s1);
*s2 += _mbclen2(*s2);
if (*s1 == 0)
break;
if (!_ismbblead(*s1) )
n--;
} while (n > 0);
return 0;
}
int _mbsnbicmp(const unsigned char *s1, const unsigned char *s2, size_t n)
{
if (n == 0)
return 0;
do {
if (_mbbtoupper(*s1) != _mbbtoupper(*s2))
return _mbbtoupper(*(unsigned const char *)s1) - _mbbtoupper(*(unsigned const char *)s2);
s1 += _mbclen2(*s1);
s2 += _mbclen2(*s2);
if (*s1 == 0)
break;
n--;
} while (n > 0);
return 0;
}

View file

@ -0,0 +1,10 @@
#include <crtdll/mbstring.h>
int _mbsnicoll(const unsigned char *s1, const unsigned char *s2, size_t n)
{
return 0;
}
int _mbsnbicoll(const unsigned char *s1, const unsigned char *s2, size_t n)
{
return 0;
}

View file

@ -1,8 +1,10 @@
#include <crtdll/mbstring.h>
unsigned char * _mbsninc(const unsigned char *str, size_t n)
{
unsigned char *s = str;
while(*s != 0 && count > 0)
if (!_ismbblead(*s1) )
unsigned char *s = (unsigned char *)str;
while(*s != 0 && n > 0) {
if (!_ismbblead(*s) )
n--;
s++;
}

View file

@ -13,12 +13,12 @@ unsigned char * _mbsnset(unsigned char *src, unsigned int val, size_t count)
{
unsigned char *char_s = src;
unsigned short *short_s = src;
unsigned char *char_src = (unsigned char *)src;
unsigned short *short_src = (unsigned short *)src;
if ( c >> 8 == 0 ) {
if ( _mbclen2(val) == 1 ) {
while(*s != 0 && count > 0) {
while(count > 0) {
*char_src = val;
char_src++;
count--;
@ -26,7 +26,7 @@ unsigned char * _mbsnset(unsigned char *src, unsigned int val, size_t count)
*char_src = 0;
}
else {
while(*s != 0 && count > 0) {
while(count > 0) {
*short_src = val;
short_src++;
count-=2;
@ -41,12 +41,12 @@ unsigned char * _mbsnset(unsigned char *src, unsigned int val, size_t count)
unsigned char * _mbsnbset(unsigned char *src, unsigned int val, size_t count)
{
unsigned char *char_s = src;
unsigned short *short_s = src;
unsigned char *char_src = (unsigned char *)src;
unsigned short *short_src = (unsigned short *)src;
if ( c >> 8 == 0 ) {
if ( _mbclen2(val) == 1 ) {
while(*s != 0 && count > 0) {
while(count > 0) {
*char_src = val;
char_src++;
count--;
@ -54,10 +54,10 @@ unsigned char * _mbsnbset(unsigned char *src, unsigned int val, size_t count)
*char_src = 0;
}
else {
while(*s != 0 && count > 0) {
while(count > 0) {
*short_src = val;
short_src++;
count--;
count-=2;
}
*short_src = 0;
}

View file

@ -0,0 +1,15 @@
#include <crtdll/mbstring.h>
// not correct
unsigned char * _mbspbrk(const unsigned char *s1, const unsigned char *s2)
{
const char *scanp;
int c, sc;
while ((c = *s1++) != 0)
{
for (scanp = s2; (sc = *scanp++) != 0;)
if (sc == c)
return (unsigned char *)((char *)s1 - (char *)1);
}
return 0;
}

View file

@ -10,32 +10,21 @@
#include <crtdll/mbstring.h>
unsigned char * _mbsrchr(const unsigned char *str, unsigned int c)
unsigned char * _mbsrchr(const unsigned char *src, unsigned int val)
{
unsigned char *s = str;
int count = mbblen(s);
s += count;
if ( c >> 8 == 0 ) {
while( count > 0 ) {
if ( *s == c )
return s;
count--;
s--;
}
}
else {
while( count > 0 ) {
if ( *((short *)s) == c )
return s;
count--;
s--;
}
}
return src;
char *s = src;
short cc = val;
const char *sp=(char *)0;
while (*s)
{
if (*(short *)s == cc)
sp = s;
s+= _mbclen2(*s);
}
if (cc == 0)
sp = s;
return (char *)sp;
}

View file

@ -1,4 +1,28 @@
unsigned char * _mbsrev(unsigned char *str)
#include <crtdll/mbstring.h>
unsigned char * _mbsrev(unsigned char *s)
{
return strrev(str);
unsigned char *e;
unsigned char a;
e=s;
while (*e) {
if ( _ismbblead(*e) ) {
a = *e;
*e = *++e;
if ( *e == 0 )
break;
*e = a;
}
e++;
}
while (s<e) {
a=*s;
*s=*e;
*e=a;
s++;
e--;
}
return s;
}

View file

@ -10,22 +10,22 @@
#include <crtdll/mbstring.h>
unsigned char * _mbsset(unsigned char *str, unsigned int c)
unsigned char * _mbsset(unsigned char *src, unsigned int c)
{
unsigned char *char_s = src;
unsigned short *short_s = src;
unsigned char *char_src = src;
unsigned short *short_src = src;
if ( c >> 8 == 0 ) {
if ( _mbclen2(c) == 1 ) {
while(*s != 0) {
*char_src = val;
while(*char_src != 0) {
*char_src = c;
char_src++;
}
*char_src = 0;
}
else {
while(*s != 0) {
*short_src = val;
while(*short_src != 0) {
*short_src = c;
short_src++;
}
*short_src = 0;

View file

@ -0,0 +1,15 @@
#include <crtdll/mbstring.h>
// not correct
size_t _mbsspn(const unsigned char *s1, const unsigned char *s2)
{
const char *p = s1, *spanp;
char c, sc;
cont:
c = *p++;
for (spanp = s2; (sc = *spanp++) != 0;)
if (sc == c)
goto cont;
return (size_t)(p - 1) - (size_t)s1;
// - (char *)s1);
}

View file

@ -0,0 +1,14 @@
#include <crtdll/mbstring.h>
// not correct
unsigned char * _mbsspnp(const unsigned char *s1, const unsigned char *s2)
{
const char *p = s1, *spanp;
char c, sc;
cont:
c = *p++;
for (spanp = s2; (sc = *spanp++) != 0;)
if (sc == c)
goto cont;
return p;
}

View file

@ -1,4 +1,53 @@
unsigned char * _mbstok(unsigned char *x, const unsigned char *y)
#include <crtdll/mbstring.h>
unsigned char * _mbstok(unsigned char *s, const unsigned char *delim)
{
return strtok(x,y);
const char *spanp;
int c, sc;
char *tok;
static char *last;
if (s == NULL && (s = last) == NULL)
return (NULL);
/*
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
*/
cont:
c = *s;
s = _mbsinc(s);
for (spanp = delim; (sc = *spanp) != 0; spanp = _mbsinc(spanp)) {
if (c == sc)
goto cont;
}
if (c == 0) { /* no non-delimiter characters */
last = NULL;
return (NULL);
}
tok = s - 1;
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
* Note that delim must have one NUL; we stop if we see that, too.
*/
for (;;) {
c = *s;
s = _mbsinc(s);
spanp = delim;
do {
if ((sc = *spanp) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
last = s;
return (tok);
}
spanp = _mbsinc(spanp);
} while (sc != 0);
}
/* NOTREACHED */
}

View file

@ -0,0 +1,15 @@
#include <crtdll/mbstring.h>
#include <crtdll/stdlib.h>
size_t _mbstrlen( const char *string )
{
char *s = (char *)string;
size_t i;
while ( *s != 0 ) {
if ( _ismbblead(*s) )
s++;
s++;
i++;
}
return i;
}

View file

@ -1,6 +1,16 @@
#include <mbstring.h>
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/crtdll/mbstring/mbsncmp.c
* PURPOSE:
* PROGRAMER: Boudewijn Dekker
* UPDATE HISTORY:
* 12/04/99: Created
*/
#include <crtdll/mbstring.h>
#include <crtdll/ctype.h>
unsigned int _mbctoupper(unsigned int c)
unsigned int _mbbtoupper(unsigned int c)
{
if (!_ismbblead(c) )
return toupper(c);
@ -8,13 +18,33 @@ unsigned int _mbctoupper(unsigned int c)
return c;
}
unsigned char * _mbsupr(unsigned char *str)
{
char *y=x;
// codepage 952
#define CASE_DIFF (0x8281 - 0x8260)
unsigned int _mbctoupper(unsigned int c)
{
if ((c & 0xFF00) != 0) {
// true multibyte case conversion needed
if ( _ismbcupper(c) )
return c + CASE_DIFF;
} else
return _mbbtoupper(c);
return 0;
}
unsigned char * _mbsupr(unsigned char *x)
{
unsigned char *y=x;
while (*y) {
*y=_mbctoupper(*y);
y++;
if (!_ismbblead(*y) )
*y = toupper(*y);
else {
*y=_mbctoupper(*(unsigned short *)y);
y++;
}
}
return x;
}

View file

@ -17,6 +17,10 @@ unsigned int _osmode_dll;
unsigned int _osver_dll;
unsigned int _osversion_dll;
unsigned int _basemajor_dll;
unsigned int _baseminor_dll;
unsigned int _baseversion_dll;
#undef __argv
#undef __argc

View file

@ -1,4 +1,5 @@
include <stdlib.h>
#include <crtdll/stdlib.h>
#include <crtdll/stdio.h>
int _aexit_rtn_dll(int exitcode)
{

View file

@ -19,3 +19,17 @@ void _initterm (
i++;
}
}
typedef int (* _onexit_t)(void);
_onexit_t __dllonexit (
_onexit_t func,
void (** fStart[])(void),
void (** fEnd[])(void)
)
{
}
_onexit_t _onexit(_onexit_t x)
{
return x;
}

View file

@ -1,9 +1,7 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
//#include <crtdll/stubs.h>
//#include <crtdll/unistd.h>
#include <crtdll/process.h>
int execve(const char *path,const char * const argv[], char * const envp[])
int _execve(const char* szPath, char* const* szaArgv, char* const* szaEnv)
{
return spawnve(P_OVERLAY, path, argv, envp);
return spawnve(P_OVERLAY, szPath, szaArgv, szaEnv);
}

View file

@ -0,0 +1,9 @@
#include <windows.h>
#include <crtdll/process.h>
int _getpid (void)
{
printf("get current processid\n");
//return (int)GetCurrentProcessId();
}

View file

@ -30,6 +30,8 @@
#define D_OK 0x10
#endif
// information about crtdll file handles is not passed to child
int _fileinfo_dll = 0;
static int
direct_exec_tail(const char *program, const char *args,

View file

@ -22,5 +22,7 @@ unsigned long
}
void _endthread(void)
{
ExitThread(0);
printf("fixme ExitThread\n");
//ExitThread(0);
for(;;);
}

View file

@ -6,5 +6,6 @@ int _XcptFilter (
struct _EXCEPTION_POINTERS * ExceptionInfo
)
{
return UnhandledExceptionFilter(ExceptionInfo);
return printf("Unhandled exception info\n");
// return UnhandledExceptionFilter(ExceptionInfo);
}

View file

@ -1,3 +1,5 @@
#include <crtdll/stdlib.h>
void **__pxcptinfoptrs (void)
{
return NULL;

View file

@ -95,3 +95,8 @@ int fflush(FILE *f)
}
return 0;
}
int _flushall( void )
{
return fflush(NULL);
}

View file

@ -1,7 +1,13 @@
#include <crtdll/stdio.h>
#include <crtdll/conio.h>
#include <crtdll/wchar.h>
int _fgetchar (void)
{
return _getch();
}
int _fgetwchar (void)
{
return _getch();
}

View file

@ -1,5 +1,6 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/stdio.h>
#include <crtdll/wchar.h>
#include <crtdll/internal/file.h>
int
@ -27,3 +28,29 @@ fprintf(register FILE *iop, const char *fmt, ...)
len = vfprintf(iop, fmt, a);
return ferror(iop) ? EOF : len;
}
int
fwprintf(register FILE *iop, const wchar_t *fmt, ...)
{
int len;
wchar_t localbuf[BUFSIZ];
va_list a=0;
va_start( a, fmt );
if (iop->_flag & _IONBF)
{
iop->_flag &= ~_IONBF;
iop->_ptr = iop->_base = localbuf;
iop->_bufsiz = BUFSIZ;
len = vfwprintf(iop,fmt,a);
fflush(iop);
iop->_flag |= _IONBF;
iop->_base = NULL;
iop->_bufsiz = 0;
iop->_cnt = 0;
}
else
len = vfwprintf(iop, fmt, a);
return ferror(iop) ? EOF : len;
}

View file

@ -1,7 +1,15 @@
#include <crtdll/stdio.h>
#include <crtdll/conio.h>
#include <crtdll/wchar.h>
int _fputchar (int c)
{
return _putch(c);
}
int _fputwchar (wchar_t c)
{
//return _putch(c);
return 0;
}

View file

@ -0,0 +1,84 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/sys/types.h>
#include <crtdll/stdio.h>
#include <crtdll/io.h>
#include <crtdll/fcntl.h>
#include <crtdll/internal/file.h>
FILE * __alloc_file(void);
FILE* _fsopen(const char *file, const char *mode, int shflag)
{
FILE *f;
int fd, rw, oflags = 0;
char tbchar;
if (file == 0)
return 0;
if (mode == 0)
return 0;
f = __alloc_file();
if (f == NULL)
return NULL;
rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+'));
switch (*mode)
{
case 'a':
oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
break;
case 'r':
oflags = rw ? O_RDWR : O_RDONLY;
break;
case 'w':
oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
break;
default:
return (NULL);
}
if (mode[1] == '+')
tbchar = mode[2];
else
tbchar = mode[1];
if (tbchar == 't')
oflags |= O_TEXT;
else if (tbchar == 'b')
oflags |= O_BINARY;
else
oflags |= (_fmode & (O_TEXT|O_BINARY));
//_SH_COMPAT Sets Compatibility mode for 16-bit applications
//_SH_DENYNO Permits read and write access
//_SH_DENYRD Denies read access to file
//_SH_DENYRW Denies read and write access to file
//_SH_DENYWR Denies write access to file
fd = _open(file, oflags, shflag);
if (fd < 0)
return NULL;
// ms crtdll ensures that writes will end up at the end of file in append mode
// we just move the file pointer to the end of file initially
if (*mode == 'a')
lseek(fd, 0, SEEK_END);
f->_cnt = 0;
f->_file = fd;
f->_bufsiz = 0;
if (rw)
f->_flag = _IOREAD | _IOWRT;
else if (*mode == 'r')
f->_flag = _IOREAD;
else
f->_flag = _IOWRT;
f->_base = f->_ptr = NULL;
return f;
}

View file

@ -21,7 +21,7 @@ Cambridge, MA 02139, USA. */
/* Read a word (int) from STREAM. */
int
getw(FILE *stream)
_getw(FILE *stream)
{
int w;

View file

@ -14,8 +14,11 @@ _popen (const char *cm, const char *md) /* program name, pipe mode */
HANDLE SpawnedProcess;
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,1024,))
return NULL;
printf("CreatePipe\n");
// if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,1024))
// return NULL;
StartupInfo.cb = sizeof(STARTUPINFO);
if ( md == "r" ) {
@ -25,7 +28,7 @@ _popen (const char *cm, const char *md) /* program name, pipe mode */
StartupInfo.hStdInput = hReadPipe;
}
SpawnedProcess = CreateProcess("cmd.exe",cm,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&StartupInfo,&ProcessInformation );
SpawnedProcess = CreateProcessA("cmd.exe",(char *)cm,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&StartupInfo,&ProcessInformation );
if ( *md == 'r' ) {
@ -35,23 +38,21 @@ _popen (const char *cm, const char *md) /* program name, pipe mode */
pf = _fdopen( __fileno_alloc(hWritePipe, _fmode) , "w" );
}
pf->name_to_remove = SpawnedProcess;
pf->_name_to_remove = SpawnedProcess;
return pf;
}
FILE* _wpopen (const wchar_t* szPipeName, const wchar_t* szMode)
{
return NULL;
}
int
pclose (FILE *pp)
_pclose (FILE *pp)
{
fclose(pp);
if (!TerminateProcess(pp->name_to_remove,0))
return -1;
printf("Terminate Process\n");
// if (!TerminateProcess(pp->_name_to_remove,0))
// return -1;
return 0;
}

View file

@ -18,6 +18,7 @@
#include <stdarg.h>
#include <crtdll/stdio.h>
#include <crtdll/wchar.h>
/* Write formatted output to stdout from the format string FORMAT. */
/* VARARGS1 */
@ -33,6 +34,18 @@ printf (const char *format, ...)
return done;
}
int
wprintf (const wchar_t *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
done = vwprintf (format, arg);
va_end (arg);
return done;
}
#ifdef USE_IN_LIBIO
# undef _IO_printf
/* This is for libg++. */

View file

@ -22,7 +22,7 @@ Cambridge, MA 02139, USA. */
/* Write the word (int) W to STREAM. */
int
putw(int w,FILE *stream)
_putw(int w,FILE *stream)
{
/* Is there a better way? */
if (fwrite( &w, sizeof(w), 1, stream) < 1)

View file

@ -8,6 +8,28 @@
* Created 19/01/99
* NOTE Not tested.
*/
#include <crtdll/internal/file.h>
#include <crtdll/stdio.h>
#include <crtdll/string.h>
#ifndef F_OK
#define F_OK 0x01
#endif
#ifndef R_OK
#define R_OK 0x02
#endif
#ifndef W_OK
#define W_OK 0x04
#endif
#ifndef X_OK
#define X_OK 0x08
#endif
#ifndef D_OK
#define D_OK 0x10
#endif
// should be replace by a closure of the tmp files
extern __file_rec *__file_rec_list;
int _rmtmp( void )
@ -18,7 +40,7 @@ loop files and check for name_to_remove
__file_rec *fr = __file_rec_list;
__file_rec **last_fr = &__file_rec_list;
int total_closed;
int total_closed = 0;
int i = 0;
char temp_name[260];
@ -30,7 +52,7 @@ loop files and check for name_to_remove
/* If one of the existing slots is available, return it */
for (i=0; i<fr->count; i++) {
if (fr->files[i]->_name_to_remove != NULL) {
if ( access(fr->files[i]->_name_to_remove) ) {
if ( _access(fr->files[i]->_name_to_remove,W_OK) ) {
strcpy(temp_name,fr->files[i]->_name_to_remove);
fclose(fr->files[i]);
remove(temp_name);
@ -47,4 +69,4 @@ loop files and check for name_to_remove
break;
}
return total_closed;
}
}

View file

@ -49,7 +49,7 @@ int scanf (const char *format, ...)
}
#if 0
int
wscanf(const wchar_t *fmt, ...)
{
@ -58,15 +58,15 @@ wscanf(const wchar_t *fmt, ...)
char *f;
int i, len = wcslen(fmt);
f = alloca(len+1);
f = malloc(len+1);
for(i=0;i<len;i++)
f[i] = fmt[i];
f[i] = 0;
va_start (arg, fmt);
done = VSCANF (f, arg);
va_end (arg);
free(f);
return done;
}
#endif

View file

@ -20,11 +20,12 @@ Cambridge, MA 02139, USA. */
#include <stdarg.h>
#include <crtdll/stdio.h>
#include <crtdll/stdio.h>
#include <crtdll/wchar.h>
#include <limits.h>
#include <crtdll/internal/file.h>
#undef sprintf
#undef wsprintf
int
sprintf(char *str, const char *fmt, ...)
{
@ -33,7 +34,19 @@ sprintf(char *str, const char *fmt, ...)
va_start (arg, fmt);
done = vsprintf (str, fmt, arg);
//va_end (arg);
va_end (arg);
return done;
}
int
swprintf(wchar_t *str, const wchar_t *fmt, ...)
{
va_list arg;
int done;
va_start (arg, fmt);
done = vswprintf (str, fmt, arg);
va_end (arg);
return done;
}
@ -43,15 +56,29 @@ sprintf(char *str, const char *fmt, ...)
string FORMAT, writing no more than MAXLEN characters. */
/* VARARGS3 */
int
snprintf (char *s, size_t maxlen,const char *format, ...)
_snprintf (char *s, size_t maxlen,const char *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
done = vsnprintf (s, maxlen, format, arg);
//va_end (arg);
done = _vsnprintf (s, maxlen, format, arg);
va_end (arg);
return done;
}
int
_snwprintf (wchar_t *s, size_t maxlen,const wchar_t *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
done = _vsnwprintf (s, maxlen, format, arg);
va_end (arg);
return done;
}

View file

@ -45,7 +45,7 @@ strong_alias (sscanf, _IO_sscanf)
#endif
#if 0
int
swscanf(const wchar_t *str, const wchar_t *fmt, ...)
@ -55,7 +55,7 @@ swscanf(const wchar_t *str, const wchar_t *fmt, ...)
char *f , *s;
int i,len = wcslen(fmt);
f = alloca(len+1);
f = malloc(len+1);
for(i=0;i<len;i++)
f[i] = fmt[i];
f[i] = 0;
@ -70,10 +70,10 @@ swscanf(const wchar_t *str, const wchar_t *fmt, ...)
done = __vsscanf (s, f, arg);
va_end (arg);
free(f);
return done;
}
#endif

View file

@ -39,7 +39,11 @@ vfprintf(FILE *f, const char *fmt, va_list ap)
int
vfwprintf(FILE *f, const wchar_t *fmt, va_list ap)
{
}

View file

@ -19,8 +19,10 @@ Cambridge, MA 02139, USA. */
#include <stdarg.h>
#undef __OPTIMIZE__ /* Avoid inline `vprintf' function. */
#include <crtdll/stdio.h>
#include <crtdll/wchar.h>
#undef vprintf
#undef vwprintf
/* Write formatted output to stdout according to the
format string FORMAT, using the argument list in ARG. */
@ -33,3 +35,13 @@ vprintf (format, arg)
fflush(stdout);
return ret;
}
int
vwprintf (format, arg)
const wchar_t *format;
va_list arg;
{
int ret = vfprintf (stdout, format, arg);
fflush(stdout);
return ret;
}

View file

@ -20,7 +20,23 @@ vsprintf(char *str, const char *fmt, va_list ap)
}
int
vsnprintf(char *str, size_t maxlen, const char *fmt, va_list ap)
vswprintf(wchar_t *str, const wchar_t *fmt, va_list ap)
{
FILE f;
int len;
f._flag = _IOWRT|_IOSTRG;
f._ptr = str;
f._cnt = INT_MAX;
f._file = -1;
len = vfwprintf(&f,fmt, ap);
*f._ptr = 0;
return len;
}
int
_vsnprintf(char *str, size_t maxlen, const char *fmt, va_list ap)
{
FILE f;
int len;
@ -34,3 +50,19 @@ vsnprintf(char *str, size_t maxlen, const char *fmt, va_list ap)
return len;
}
int
_vsnwprintf(wchar_t *str, size_t maxlen, const wchar_t *fmt, va_list ap)
{
FILE f;
int len;
f._flag = _IOWRT|_IOSTRG;
f._ptr = str;
f._cnt = maxlen;
f._file = -1;
len = vfwprintf(&f,fmt, ap);
// what if the buffer is full ??
*f._ptr = 0;
return len;
}

View file

@ -11,6 +11,7 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/errno.h>
#include <crtdll/stdlib.h>
#include <crtdll/internal/file.h>
char *
itoa(int value, char *string, int radix)
@ -24,7 +25,7 @@ itoa(int value, char *string, int radix)
if (radix > 36 || radix <= 1)
{
errno = EDOM;
__set_errno(EDOM);
return 0;
}
@ -68,7 +69,7 @@ ltoa(long value, char *string, int radix)
if (radix > 36 || radix <= 1)
{
errno = EDOM;
__set_errno(EDOM);
return 0;
}
@ -99,3 +100,39 @@ ltoa(long value, char *string, int radix)
return string;
}
char *
_ultoa(unsigned long value, char *string, int radix)
{
char tmp[33];
char *tp = tmp;
long i;
unsigned long v = value;
char *sp;
if (radix > 36 || radix <= 1)
{
__set_errno(EDOM);
return 0;
}
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
if (string == 0)
string = (char *)malloc((tp-tmp)+1);
sp = string;
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}

Some files were not shown because too many files have changed in this diff Show more