diff --git a/reactos/lib/crtdll/conio/cgets.c b/reactos/lib/crtdll/conio/cgets.c index 8787259f608..60052160b07 100644 --- a/reactos/lib/crtdll/conio/cgets.c +++ b/reactos/lib/crtdll/conio/cgets.c @@ -1,5 +1,5 @@ #include - +#include 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++; } } diff --git a/reactos/lib/crtdll/conio/cprintf.c b/reactos/lib/crtdll/conio/cprintf.c index 27c87143f7f..21c33a98d8a 100644 --- a/reactos/lib/crtdll/conio/cprintf.c +++ b/reactos/lib/crtdll/conio/cprintf.c @@ -2,7 +2,7 @@ #include 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; } diff --git a/reactos/lib/crtdll/conio/cscanf.c b/reactos/lib/crtdll/conio/cscanf.c index 9382011771d..7b8e16290c9 100644 --- a/reactos/lib/crtdll/conio/cscanf.c +++ b/reactos/lib/crtdll/conio/cscanf.c @@ -1,26 +1,21 @@ #include - - -/* - * 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 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; + } diff --git a/reactos/lib/crtdll/conio/kbhit.c b/reactos/lib/crtdll/conio/kbhit.c index d8a61021ff9..972a20798bc 100644 --- a/reactos/lib/crtdll/conio/kbhit.c +++ b/reactos/lib/crtdll/conio/kbhit.c @@ -9,19 +9,23 @@ */ #include -#include +#include +#include // 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; diff --git a/reactos/lib/crtdll/conio/ungetch.c b/reactos/lib/crtdll/conio/ungetch.c index adda3010d6e..730ac398afe 100644 --- a/reactos/lib/crtdll/conio/ungetch.c +++ b/reactos/lib/crtdll/conio/ungetch.c @@ -18,7 +18,7 @@ char ungot_char = 0; int -ungetch(int c) +_ungetch(int c) { if (char_avail) return(EOF); diff --git a/reactos/lib/crtdll/crtdll.def b/reactos/lib/crtdll/crtdll.def index 60ce24876cf..c413bcaf1b0 100644 --- a/reactos/lib/crtdll/crtdll.def +++ b/reactos/lib/crtdll/crtdll.def @@ -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 diff --git a/reactos/lib/crtdll/direct/getdcwd.c b/reactos/lib/crtdll/direct/getdcwd.c index f25386d55fe..5e7132412f8 100644 --- a/reactos/lib/crtdll/direct/getdcwd.c +++ b/reactos/lib/crtdll/direct/getdcwd.c @@ -1,22 +1,23 @@ -#include +#include +#include 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; } diff --git a/reactos/lib/crtdll/direct/getdrive.c b/reactos/lib/crtdll/direct/getdrive.c index 6165ef85549..a0101adc853 100644 --- a/reactos/lib/crtdll/direct/getdrive.c +++ b/reactos/lib/crtdll/direct/getdrive.c @@ -17,3 +17,9 @@ int _getdrive( void ) return cur_drive; } + +unsigned long _getdrives(void) +{ + return printf("get logical drives\n"); + //return GetLogicalDrives(); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/except/abnorter.c b/reactos/lib/crtdll/except/abnorter.c index 3a974007aca..9c913832c18 100644 --- a/reactos/lib/crtdll/except/abnorter.c +++ b/reactos/lib/crtdll/except/abnorter.c @@ -2,5 +2,6 @@ int _abnormal_termination(void) { - return AbnormalTermination(); + printf("Abnormal Termination\n"); +// return AbnormalTermination(); } \ No newline at end of file diff --git a/reactos/lib/crtdll/except/exhand2.c b/reactos/lib/crtdll/except/exhand2.c new file mode 100644 index 00000000000..4a4fcd6814b --- /dev/null +++ b/reactos/lib/crtdll/except/exhand2.c @@ -0,0 +1,19 @@ +#include + +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"); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/except/matherr.c b/reactos/lib/crtdll/except/matherr.c new file mode 100644 index 00000000000..338eee1fee0 --- /dev/null +++ b/reactos/lib/crtdll/except/matherr.c @@ -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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/except/unwind.c b/reactos/lib/crtdll/except/unwind.c index d5d34bf51f7..8bf460fe253 100644 --- a/reactos/lib/crtdll/except/unwind.c +++ b/reactos/lib/crtdll/except/unwind.c @@ -1,3 +1,6 @@ +#include +#define PEXCEPTION_FRAME void* + void _global_unwind2( PEXCEPTION_FRAME frame ) { //RtlUnwind( frame, 0, NULL, 0 ); diff --git a/reactos/lib/crtdll/float/copysign.c b/reactos/lib/crtdll/float/copysign.c new file mode 100644 index 00000000000..4d02b38601f --- /dev/null +++ b/reactos/lib/crtdll/float/copysign.c @@ -0,0 +1,13 @@ +#include +#include + +double _copysign (double __d, double __s) +{ + double_t *d = (double_t *)&__d; + double_t *s = (double_t *)&__s; + + d->sign = s->sign; + + return __d; +} + \ No newline at end of file diff --git a/reactos/lib/crtdll/float/fpclass.c b/reactos/lib/crtdll/float/fpclass.c new file mode 100644 index 00000000000..06c404f5ead --- /dev/null +++ b/reactos/lib/crtdll/float/fpclass.c @@ -0,0 +1,65 @@ +#include +#include +#include + +#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; +} + + diff --git a/reactos/lib/crtdll/float/logb.c b/reactos/lib/crtdll/float/logb.c index 71e9996d3a8..db8eff6381a 100644 --- a/reactos/lib/crtdll/float/logb.c +++ b/reactos/lib/crtdll/float/logb.c @@ -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__ diff --git a/reactos/lib/crtdll/float/nafter.c b/reactos/lib/crtdll/float/nafter.c new file mode 100644 index 00000000000..5e2a2ad317f --- /dev/null +++ b/reactos/lib/crtdll/float/nafter.c @@ -0,0 +1,12 @@ +#include + +double _nextafter( double x, double y ) +{ + if ( x == y) + return x; + + if ( isnan(x) || isnan(y) ) + return x; + + return x; +} diff --git a/reactos/lib/crtdll/float/nextaf.c b/reactos/lib/crtdll/float/nextaf.c new file mode 100644 index 00000000000..d97d2dd2a71 --- /dev/null +++ b/reactos/lib/crtdll/float/nextaf.c @@ -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; + + + +} diff --git a/reactos/lib/crtdll/float/scalb.c b/reactos/lib/crtdll/float/scalb.c new file mode 100644 index 00000000000..e035584cb93 --- /dev/null +++ b/reactos/lib/crtdll/float/scalb.c @@ -0,0 +1,12 @@ +#include +#include + +double _scalb( double __x, long e ) +{ + double_t *x = (double_t *)&__x; + + x->exponent += e; + + return __x; + +} diff --git a/reactos/lib/crtdll/io/create.c b/reactos/lib/crtdll/io/create.c index 46175a39c93..4456a82d4eb 100644 --- a/reactos/lib/crtdll/io/create.c +++ b/reactos/lib/crtdll/io/create.c @@ -1,8 +1,7 @@ #include #include -#undef creat -int creat(const char *filename, int mode) +int _creat(const char *filename, int mode) { return open(filename,_O_CREAT|_O_TRUNC,mode); } diff --git a/reactos/lib/crtdll/locale/locale.c b/reactos/lib/crtdll/locale/locale.c index 6db5bf2ba14..c537b7e1a0a 100644 --- a/reactos/lib/crtdll/locale/locale.c +++ b/reactos/lib/crtdll/locale/locale.c @@ -1,90 +1,4 @@ -/* -FUNCTION -<>, <>---select or query locale - -INDEX - setlocale -INDEX - localeconv -INDEX - _setlocale_r -INDEX - _localeconv_r - -ANSI_SYNOPSIS - #include - 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 - 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 -<> is the facility defined by ANSI C to condition the -execution environment for international collating and formatting -information; <> 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 <> as the <[locale]> argument, <> returns -a pointer to the string representing the current locale (always -<<``C''>> in this implementation). The acceptable values for -<[category]> are defined in `<>' as macros beginning with -<<"LC_">>, but this implementation does not check the values you pass -in the <[category]> argument. - -<> returns a pointer to a structure (also defined in -`<>') describing the locale-specific conventions currently -in effect. - -<<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of -<> and <> respectively. The extra argument -<[reent]> is a pointer to a reentrancy structure. - -RETURNS -<> 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, <>. - -<> returns a pointer to a structure of type <>, -which describes the formatting and collating conventions in effect (in -this implementation, always those of the C locale). - -PORTABILITY -ANSI C requires <>, 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 #include #include #include @@ -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; } diff --git a/reactos/lib/crtdll/makefile b/reactos/lib/crtdll/makefile index 6a30ae45ecc..61485687f97 100644 --- a/reactos/lib/crtdll/makefile +++ b/reactos/lib/crtdll/makefile @@ -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 \ diff --git a/reactos/lib/crtdll/math/cabs.c b/reactos/lib/crtdll/math/cabs.c index 015219c8fee..2c3ada9608c 100644 --- a/reactos/lib/crtdll/math/cabs.c +++ b/reactos/lib/crtdll/math/cabs.c @@ -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); } diff --git a/reactos/lib/crtdll/math/ftol.c b/reactos/lib/crtdll/math/ftol.c index 1c58bb630e2..b20aef46aca 100644 --- a/reactos/lib/crtdll/math/ftol.c +++ b/reactos/lib/crtdll/math/ftol.c @@ -1,3 +1,5 @@ -long __cdecl ftol(double fl) { +#include + +long _ftol(double fl) { return (long)fl; } diff --git a/reactos/lib/crtdll/mbstring/hanzen.c b/reactos/lib/crtdll/mbstring/hanzen.c index 78a8e2550d1..23df35a0fde 100644 --- a/reactos/lib/crtdll/mbstring/hanzen.c +++ b/reactos/lib/crtdll/mbstring/hanzen.c @@ -1,14 +1,16 @@ -#include - /* - * 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 + 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; diff --git a/reactos/lib/crtdll/mbstring/ischira.c b/reactos/lib/crtdll/mbstring/ischira.c new file mode 100644 index 00000000000..247e55a164e --- /dev/null +++ b/reactos/lib/crtdll/mbstring/ischira.c @@ -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 +#include + +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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/iskana.c b/reactos/lib/crtdll/mbstring/iskana.c new file mode 100644 index 00000000000..bd9dfa9679d --- /dev/null +++ b/reactos/lib/crtdll/mbstring/iskana.c @@ -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 +#include + +int _ismbbkana(unsigned char c) +{ + return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_M|_KNJ_P)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/iskmoji.c b/reactos/lib/crtdll/mbstring/iskmoji.c new file mode 100644 index 00000000000..dcaaab853bd --- /dev/null +++ b/reactos/lib/crtdll/mbstring/iskmoji.c @@ -0,0 +1,6 @@ +#include + +int _ismbbkalpha(unsigned char c) +{ + return (0xA7 <= c <= 0xDF); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/iskpun.c b/reactos/lib/crtdll/mbstring/iskpun.c new file mode 100644 index 00000000000..470d469abc2 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/iskpun.c @@ -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 + +int _ismbbkpunct( unsigned int c ) +{ + return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/islead.c b/reactos/lib/crtdll/mbstring/islead.c index e40745b5723..8d71a229ee2 100644 --- a/reactos/lib/crtdll/mbstring/islead.c +++ b/reactos/lib/crtdll/mbstring/islead.c @@ -3,5 +3,6 @@ int isleadbyte(char *mbstr) { - return IsDBCSLeadByteEx(0,*c); + return 0; + //return IsDBCSLeadByteEx(0,*c); } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/islwr.c b/reactos/lib/crtdll/mbstring/islwr.c new file mode 100644 index 00000000000..861206c5610 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/islwr.c @@ -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 +#include + +// code page 952 only +int _ismbclower( unsigned int c ) +{ + if ((c & 0xFF00) != 0) { + if ( c >= 0x829A && c<= 0x829A ) + return 1; + } + else + return isupper(c); +} diff --git a/reactos/lib/crtdll/mbstring/ismbal.c b/reactos/lib/crtdll/mbstring/ismbal.c new file mode 100644 index 00000000000..736b67edf33 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/ismbal.c @@ -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 +#include + +int _ismbbalpha(unsigned char c) +{ + return (isalpha(c) ||_ismbbkalnum(c)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/ismbaln.c b/reactos/lib/crtdll/mbstring/ismbaln.c new file mode 100644 index 00000000000..78a39992eca --- /dev/null +++ b/reactos/lib/crtdll/mbstring/ismbaln.c @@ -0,0 +1,6 @@ +#include + +int _ismbbalnum(unsigned char c) +{ + return (isalnum(c) || _ismbbkalnum(c)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/ismbc.c b/reactos/lib/crtdll/mbstring/ismbc.c new file mode 100644 index 00000000000..b69dd90c4bc --- /dev/null +++ b/reactos/lib/crtdll/mbstring/ismbc.c @@ -0,0 +1,103 @@ +#include + +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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/ismbgra.c b/reactos/lib/crtdll/mbstring/ismbgra.c new file mode 100644 index 00000000000..587bbadb522 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/ismbgra.c @@ -0,0 +1,8 @@ +#include +#include +#include + +int _ismbbgraph(unsigned char c) +{ + return (isgraph(c) || _ismbbkana(c)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/ismbkaln.c b/reactos/lib/crtdll/mbstring/ismbkaln.c new file mode 100644 index 00000000000..514c0233e2c --- /dev/null +++ b/reactos/lib/crtdll/mbstring/ismbkaln.c @@ -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 + +int _ismbbkalnum( unsigned int c ) +{ + return ((_jctype+1)[(unsigned char)(c)] & (_KNJ_P)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/ismblead.c b/reactos/lib/crtdll/mbstring/ismblead.c index b1c89aeec5c..b4e3ae654b3 100644 --- a/reactos/lib/crtdll/mbstring/ismblead.c +++ b/reactos/lib/crtdll/mbstring/ismblead.c @@ -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 +#include +#include -#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() : Vtg JIS R[h1oCg(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); } diff --git a/reactos/lib/crtdll/mbstring/ismbpri.c b/reactos/lib/crtdll/mbstring/ismbpri.c new file mode 100644 index 00000000000..3fb654c2445 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/ismbpri.c @@ -0,0 +1,8 @@ +#include +#include +#include + +int _ismbbprint(unsigned char c) +{ + return (isprint(c) || _ismbbkana(c)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/ismbpun.c b/reactos/lib/crtdll/mbstring/ismbpun.c new file mode 100644 index 00000000000..b8ec6f440b3 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/ismbpun.c @@ -0,0 +1,13 @@ + + //iskana() :(0xA1 <= c <= 0xDF) + //iskpun() :(0xA1 <= c <= 0xA6) + //iskmoji() :(0xA7 <= c <= 0xDF) +#include +#include +#include + +int _ismbbpunct(unsigned char c) +{ +// (0xA1 <= c <= 0xA6) + return (ispunct(c) || _ismbbkana(c)); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/ismbtrail.c b/reactos/lib/crtdll/mbstring/ismbtrl.c similarity index 71% rename from reactos/lib/crtdll/mbstring/ismbtrail.c rename to reactos/lib/crtdll/mbstring/ismbtrl.c index 2fb54c8edeb..1fb5fd9bbd6 100644 --- a/reactos/lib/crtdll/mbstring/ismbtrail.c +++ b/reactos/lib/crtdll/mbstring/ismbtrl.c @@ -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 +#include - iskanji2() : Vtg JIS R[h2oCg(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); } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/isuppr.c b/reactos/lib/crtdll/mbstring/isuppr.c new file mode 100644 index 00000000000..47e0ebe1ded --- /dev/null +++ b/reactos/lib/crtdll/mbstring/isuppr.c @@ -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 +#include + +// code page 952 only +int _ismbcupper( unsigned int c ) +{ + if ((c & 0xFF00) != 0) { + if ( c >= 0x8260 && c<= 0x8279 ) + return 1; + } + else + return isupper(c); +} diff --git a/reactos/lib/crtdll/mbstring/jistojms.c b/reactos/lib/crtdll/mbstring/jistojms.c new file mode 100644 index 00000000000..9ed1fd0610c --- /dev/null +++ b/reactos/lib/crtdll/mbstring/jistojms.c @@ -0,0 +1,24 @@ +#include + +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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/jmstojis.c b/reactos/lib/crtdll/mbstring/jmstojis.c new file mode 100644 index 00000000000..087be9bfbd5 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/jmstojis.c @@ -0,0 +1,25 @@ +#include + +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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbbtombc.c b/reactos/lib/crtdll/mbstring/mbbtombc.c deleted file mode 100644 index 6bfd11dba02..00000000000 --- a/reactos/lib/crtdll/mbstring/mbbtombc.c +++ /dev/null @@ -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 - -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; -} - - diff --git a/reactos/lib/crtdll/mbstring/mbbtype.c b/reactos/lib/crtdll/mbstring/mbbtype.c index 76c4e1bea3f..0c74eb0812a 100644 --- a/reactos/lib/crtdll/mbstring/mbbtype.c +++ b/reactos/lib/crtdll/mbstring/mbbtype.c @@ -9,11 +9,12 @@ */ #include +#include 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); } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbccpy.c b/reactos/lib/crtdll/mbstring/mbccpy.c index e8ae46d5bbd..8e2e46e9e17 100644 --- a/reactos/lib/crtdll/mbstring/mbccpy.c +++ b/reactos/lib/crtdll/mbstring/mbccpy.c @@ -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)); } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbclen.c b/reactos/lib/crtdll/mbstring/mbclen.c index dface99aaca..88c58605b6d 100644 --- a/reactos/lib/crtdll/mbstring/mbclen.c +++ b/reactos/lib/crtdll/mbstring/mbclen.c @@ -1,18 +1,29 @@ -//#include +#include #include 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; } diff --git a/reactos/lib/crtdll/mbstring/mbscoll.c b/reactos/lib/crtdll/mbstring/mbscoll.c index e9a3ed93600..669c6de81f4 100644 --- a/reactos/lib/crtdll/mbstring/mbscoll.c +++ b/reactos/lib/crtdll/mbstring/mbscoll.c @@ -10,7 +10,86 @@ #include +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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbscspn.c b/reactos/lib/crtdll/mbstring/mbscspn.c index 4ee3f211ab0..055adce176b 100644 --- a/reactos/lib/crtdll/mbstring/mbscspn.c +++ b/reactos/lib/crtdll/mbstring/mbscspn.c @@ -1,4 +1,18 @@ -size_t _mbscspn(const unsigned char *str, const unsigned char *set) +#include +// 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 */ } diff --git a/reactos/lib/crtdll/mbstring/mbsdec.c b/reactos/lib/crtdll/mbstring/mbsdec.c index fd20b44a189..69a437b25e8 100644 --- a/reactos/lib/crtdll/mbstring/mbsdec.c +++ b/reactos/lib/crtdll/mbstring/mbsdec.c @@ -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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsdup.c b/reactos/lib/crtdll/mbstring/mbsdup.c index 07e8307fc47..65c1c7ec506 100644 --- a/reactos/lib/crtdll/mbstring/mbsdup.c +++ b/reactos/lib/crtdll/mbstring/mbsdup.c @@ -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 +#include + +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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsicmp.c b/reactos/lib/crtdll/mbstring/mbsicmp.c index 01f7213ab46..cff819191c3 100644 --- a/reactos/lib/crtdll/mbstring/mbsicmp.c +++ b/reactos/lib/crtdll/mbstring/mbsicmp.c @@ -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 +#include +#include + 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)); } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsicoll.c b/reactos/lib/crtdll/mbstring/mbsicoll.c index 45e16270085..6b2da159972 100644 --- a/reactos/lib/crtdll/mbstring/mbsicoll.c +++ b/reactos/lib/crtdll/mbstring/mbsicoll.c @@ -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 +#include +#include +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; } diff --git a/reactos/lib/crtdll/mbstring/mbsinc.c b/reactos/lib/crtdll/mbstring/mbsinc.c index ab93ebf8c99..d0620061317 100644 --- a/reactos/lib/crtdll/mbstring/mbsinc.c +++ b/reactos/lib/crtdll/mbstring/mbsinc.c @@ -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; } diff --git a/reactos/lib/crtdll/mbstring/mbslen.c b/reactos/lib/crtdll/mbstring/mbslen.c index f182711408b..8648ca82221 100644 --- a/reactos/lib/crtdll/mbstring/mbslen.c +++ b/reactos/lib/crtdll/mbstring/mbslen.c @@ -1,3 +1,5 @@ +#include + 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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbslwr.c b/reactos/lib/crtdll/mbstring/mbslwr.c index eb418b10119..694724a3d35 100644 --- a/reactos/lib/crtdll/mbstring/mbslwr.c +++ b/reactos/lib/crtdll/mbstring/mbslwr.c @@ -1,20 +1,40 @@ -#include +#include +#include -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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsncat.c b/reactos/lib/crtdll/mbstring/mbsncat.c index 2e1196f2e56..3d7e81bdb30 100644 --- a/reactos/lib/crtdll/mbstring/mbsncat.c +++ b/reactos/lib/crtdll/mbstring/mbsncat.c @@ -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); } diff --git a/reactos/lib/crtdll/mbstring/mbsnccnt.c b/reactos/lib/crtdll/mbstring/mbsnccnt.c index e47cda5ad3b..05ae2867735 100644 --- a/reactos/lib/crtdll/mbstring/mbsnccnt.c +++ b/reactos/lib/crtdll/mbstring/mbsnccnt.c @@ -1,11 +1,25 @@ +#include + 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++; diff --git a/reactos/lib/crtdll/mbstring/mbsncmp.c b/reactos/lib/crtdll/mbstring/mbsncmp.c index e5269b3d23f..88eb41d9b4a 100644 --- a/reactos/lib/crtdll/mbstring/mbsncmp.c +++ b/reactos/lib/crtdll/mbstring/mbsncmp.c @@ -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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsncoll.c b/reactos/lib/crtdll/mbstring/mbsncoll.c index 86bfefee49b..f1a27031861 100644 --- a/reactos/lib/crtdll/mbstring/mbsncoll.c +++ b/reactos/lib/crtdll/mbstring/mbsncoll.c @@ -9,34 +9,101 @@ */ #include -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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsncpy.c b/reactos/lib/crtdll/mbstring/mbsncpy.c index ba3481d1a38..220d17fcf66 100644 --- a/reactos/lib/crtdll/mbstring/mbsncpy.c +++ b/reactos/lib/crtdll/mbstring/mbsncpy.c @@ -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 -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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsnextc.c b/reactos/lib/crtdll/mbstring/mbsnextc.c new file mode 100644 index 00000000000..d3746d803da --- /dev/null +++ b/reactos/lib/crtdll/mbstring/mbsnextc.c @@ -0,0 +1,18 @@ +#include + +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; + +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsnicmp.c b/reactos/lib/crtdll/mbstring/mbsnicmp.c new file mode 100644 index 00000000000..09e6afb54eb --- /dev/null +++ b/reactos/lib/crtdll/mbstring/mbsnicmp.c @@ -0,0 +1,37 @@ +#include + +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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsnicoll.c b/reactos/lib/crtdll/mbstring/mbsnicoll.c new file mode 100644 index 00000000000..12f7806ab2e --- /dev/null +++ b/reactos/lib/crtdll/mbstring/mbsnicoll.c @@ -0,0 +1,10 @@ +#include + +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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsninc.c b/reactos/lib/crtdll/mbstring/mbsninc.c index 043344ad8ad..3fb6e4f079f 100644 --- a/reactos/lib/crtdll/mbstring/mbsninc.c +++ b/reactos/lib/crtdll/mbstring/mbsninc.c @@ -1,8 +1,10 @@ +#include + 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++; } diff --git a/reactos/lib/crtdll/mbstring/mbsnset.c b/reactos/lib/crtdll/mbstring/mbsnset.c index 3789bb7405b..f4f94d60571 100644 --- a/reactos/lib/crtdll/mbstring/mbsnset.c +++ b/reactos/lib/crtdll/mbstring/mbsnset.c @@ -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; } diff --git a/reactos/lib/crtdll/mbstring/mbspbrk.c b/reactos/lib/crtdll/mbstring/mbspbrk.c new file mode 100644 index 00000000000..8112be9643b --- /dev/null +++ b/reactos/lib/crtdll/mbstring/mbspbrk.c @@ -0,0 +1,15 @@ +#include +// 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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsrchr.c b/reactos/lib/crtdll/mbstring/mbsrchr.c index bb9aa729ddd..ee747277182 100644 --- a/reactos/lib/crtdll/mbstring/mbsrchr.c +++ b/reactos/lib/crtdll/mbstring/mbsrchr.c @@ -10,32 +10,21 @@ #include -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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsrev.c b/reactos/lib/crtdll/mbstring/mbsrev.c index 1532c593fd9..6a9eb1e2f37 100644 --- a/reactos/lib/crtdll/mbstring/mbsrev.c +++ b/reactos/lib/crtdll/mbstring/mbsrev.c @@ -1,4 +1,28 @@ -unsigned char * _mbsrev(unsigned char *str) +#include + +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 -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; diff --git a/reactos/lib/crtdll/mbstring/mbsspn.c b/reactos/lib/crtdll/mbstring/mbsspn.c new file mode 100644 index 00000000000..9cd0498f801 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/mbsspn.c @@ -0,0 +1,15 @@ +#include +// 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); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsspnp.c b/reactos/lib/crtdll/mbstring/mbsspnp.c new file mode 100644 index 00000000000..b847dd08131 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/mbsspnp.c @@ -0,0 +1,14 @@ +#include +// 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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbstok.c b/reactos/lib/crtdll/mbstring/mbstok.c index a5eb8d002e7..b27cf76769a 100644 --- a/reactos/lib/crtdll/mbstring/mbstok.c +++ b/reactos/lib/crtdll/mbstring/mbstok.c @@ -1,4 +1,53 @@ -unsigned char * _mbstok(unsigned char *x, const unsigned char *y) +#include + +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 */ } \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbstrlen.c b/reactos/lib/crtdll/mbstring/mbstrlen.c new file mode 100644 index 00000000000..2a0e0ebc5f3 --- /dev/null +++ b/reactos/lib/crtdll/mbstring/mbstrlen.c @@ -0,0 +1,15 @@ +#include +#include + +size_t _mbstrlen( const char *string ) +{ + char *s = (char *)string; + size_t i; + while ( *s != 0 ) { + if ( _ismbblead(*s) ) + s++; + s++; + i++; + } + return i; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/mbstring/mbsupr.c b/reactos/lib/crtdll/mbstring/mbsupr.c index 7b5762f8dd2..5ca7ae5d63c 100644 --- a/reactos/lib/crtdll/mbstring/mbsupr.c +++ b/reactos/lib/crtdll/mbstring/mbsupr.c @@ -1,6 +1,16 @@ -#include +/* + * 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 +#include -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; } \ No newline at end of file diff --git a/reactos/lib/crtdll/misc/GetArgs.c b/reactos/lib/crtdll/misc/GetArgs.c index 46ae863e0b4..efebd308cf6 100644 --- a/reactos/lib/crtdll/misc/GetArgs.c +++ b/reactos/lib/crtdll/misc/GetArgs.c @@ -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 diff --git a/reactos/lib/crtdll/misc/amsg.c b/reactos/lib/crtdll/misc/amsg.c index 79a904dff12..dd991c9cf86 100644 --- a/reactos/lib/crtdll/misc/amsg.c +++ b/reactos/lib/crtdll/misc/amsg.c @@ -1,4 +1,5 @@ -include +#include +#include int _aexit_rtn_dll(int exitcode) { diff --git a/reactos/lib/crtdll/misc/initterm.c b/reactos/lib/crtdll/misc/initterm.c index 390175f563a..c834b61ec5b 100644 --- a/reactos/lib/crtdll/misc/initterm.c +++ b/reactos/lib/crtdll/misc/initterm.c @@ -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; +} diff --git a/reactos/lib/crtdll/process/execve.c b/reactos/lib/crtdll/process/execve.c index 707a1de512f..3ea6ae91a0d 100644 --- a/reactos/lib/crtdll/process/execve.c +++ b/reactos/lib/crtdll/process/execve.c @@ -1,9 +1,7 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ -//#include -//#include #include -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); } diff --git a/reactos/lib/crtdll/process/procid.c b/reactos/lib/crtdll/process/procid.c new file mode 100644 index 00000000000..150b5439bbb --- /dev/null +++ b/reactos/lib/crtdll/process/procid.c @@ -0,0 +1,9 @@ +#include +#include + +int _getpid (void) +{ + printf("get current processid\n"); + //return (int)GetCurrentProcessId(); +} + diff --git a/reactos/lib/crtdll/process/spawnve.c b/reactos/lib/crtdll/process/spawnve.c index eb1da5bb253..4917f8a4eac 100644 --- a/reactos/lib/crtdll/process/spawnve.c +++ b/reactos/lib/crtdll/process/spawnve.c @@ -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, diff --git a/reactos/lib/crtdll/process/thread.c b/reactos/lib/crtdll/process/thread.c index 06e2816cf90..5578a8047ad 100644 --- a/reactos/lib/crtdll/process/thread.c +++ b/reactos/lib/crtdll/process/thread.c @@ -22,5 +22,7 @@ unsigned long } void _endthread(void) { - ExitThread(0); +printf("fixme ExitThread\n"); + //ExitThread(0); + for(;;); } \ No newline at end of file diff --git a/reactos/lib/crtdll/signal/xcptfil.c b/reactos/lib/crtdll/signal/xcptfil.c index 59d935d821e..3ab79f1aad6 100644 --- a/reactos/lib/crtdll/signal/xcptfil.c +++ b/reactos/lib/crtdll/signal/xcptfil.c @@ -6,5 +6,6 @@ int _XcptFilter ( struct _EXCEPTION_POINTERS * ExceptionInfo ) { - return UnhandledExceptionFilter(ExceptionInfo); + return printf("Unhandled exception info\n"); +// return UnhandledExceptionFilter(ExceptionInfo); } \ No newline at end of file diff --git a/reactos/lib/crtdll/signal/xcptinfo.c b/reactos/lib/crtdll/signal/xcptinfo.c index 0711c76dde7..a19f71011aa 100644 --- a/reactos/lib/crtdll/signal/xcptinfo.c +++ b/reactos/lib/crtdll/signal/xcptinfo.c @@ -1,3 +1,5 @@ +#include + void **__pxcptinfoptrs (void) { return NULL; diff --git a/reactos/lib/crtdll/stdio/fflush.c b/reactos/lib/crtdll/stdio/fflush.c index ad9f56ead24..353ebafb162 100644 --- a/reactos/lib/crtdll/stdio/fflush.c +++ b/reactos/lib/crtdll/stdio/fflush.c @@ -95,3 +95,8 @@ int fflush(FILE *f) } return 0; } + +int _flushall( void ) +{ + return fflush(NULL); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdio/fgetchar.c b/reactos/lib/crtdll/stdio/fgetchar.c index c098b05e12e..8c925d4da27 100644 --- a/reactos/lib/crtdll/stdio/fgetchar.c +++ b/reactos/lib/crtdll/stdio/fgetchar.c @@ -1,7 +1,13 @@ #include #include +#include int _fgetchar (void) { return _getch(); } + +int _fgetwchar (void) +{ + return _getch(); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdio/fprintf.c b/reactos/lib/crtdll/stdio/fprintf.c index 88ab33c67ca..7a03b6bec14 100644 --- a/reactos/lib/crtdll/stdio/fprintf.c +++ b/reactos/lib/crtdll/stdio/fprintf.c @@ -1,5 +1,6 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include +#include #include 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; +} diff --git a/reactos/lib/crtdll/stdio/fputchar.c b/reactos/lib/crtdll/stdio/fputchar.c index a9c5c8eff79..235a0850868 100644 --- a/reactos/lib/crtdll/stdio/fputchar.c +++ b/reactos/lib/crtdll/stdio/fputchar.c @@ -1,7 +1,15 @@ #include #include +#include int _fputchar (int c) { return _putch(c); } + +int _fputwchar (wchar_t c) +{ + //return _putch(c); + return 0; +} + diff --git a/reactos/lib/crtdll/stdio/fsopen.c b/reactos/lib/crtdll/stdio/fsopen.c new file mode 100644 index 00000000000..ff2e8b0127d --- /dev/null +++ b/reactos/lib/crtdll/stdio/fsopen.c @@ -0,0 +1,84 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include +#include +#include + + +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; +} diff --git a/reactos/lib/crtdll/stdio/getw.c b/reactos/lib/crtdll/stdio/getw.c index 659061d9924..54b93c56db5 100644 --- a/reactos/lib/crtdll/stdio/getw.c +++ b/reactos/lib/crtdll/stdio/getw.c @@ -21,7 +21,7 @@ Cambridge, MA 02139, USA. */ /* Read a word (int) from STREAM. */ int -getw(FILE *stream) +_getw(FILE *stream) { int w; diff --git a/reactos/lib/crtdll/stdio/popen.c b/reactos/lib/crtdll/stdio/popen.c index 8ab3562ebd2..35da266dd51 100644 --- a/reactos/lib/crtdll/stdio/popen.c +++ b/reactos/lib/crtdll/stdio/popen.c @@ -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; } diff --git a/reactos/lib/crtdll/stdio/printf.c b/reactos/lib/crtdll/stdio/printf.c index a215d78d7e1..2e8a45bce03 100644 --- a/reactos/lib/crtdll/stdio/printf.c +++ b/reactos/lib/crtdll/stdio/printf.c @@ -18,6 +18,7 @@ #include #include +#include /* 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++. */ diff --git a/reactos/lib/crtdll/stdio/putw.c b/reactos/lib/crtdll/stdio/putw.c index 51a69163bd4..5b8227a8e7a 100644 --- a/reactos/lib/crtdll/stdio/putw.c +++ b/reactos/lib/crtdll/stdio/putw.c @@ -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) diff --git a/reactos/lib/crtdll/stdio/rmtmp.c b/reactos/lib/crtdll/stdio/rmtmp.c index 883c4919713..18d0fe410a5 100644 --- a/reactos/lib/crtdll/stdio/rmtmp.c +++ b/reactos/lib/crtdll/stdio/rmtmp.c @@ -8,6 +8,28 @@ * Created 19/01/99 * NOTE Not tested. */ + +#include +#include +#include + +#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; icount; 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; -} \ No newline at end of file +} diff --git a/reactos/lib/crtdll/stdio/scanf.c b/reactos/lib/crtdll/stdio/scanf.c index 3dd47bc0157..9d44102eb61 100644 --- a/reactos/lib/crtdll/stdio/scanf.c +++ b/reactos/lib/crtdll/stdio/scanf.c @@ -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 #include -#include +#include #include #include - +#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; +} + + diff --git a/reactos/lib/crtdll/stdio/sscanf.c b/reactos/lib/crtdll/stdio/sscanf.c index b3c3210da05..a81dde41dc7 100644 --- a/reactos/lib/crtdll/stdio/sscanf.c +++ b/reactos/lib/crtdll/stdio/sscanf.c @@ -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 #undef __OPTIMIZE__ /* Avoid inline `vprintf' function. */ #include +#include #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; +} diff --git a/reactos/lib/crtdll/stdio/vsprintf.c b/reactos/lib/crtdll/stdio/vsprintf.c index 75112b0c4f7..362c29f8f12 100644 --- a/reactos/lib/crtdll/stdio/vsprintf.c +++ b/reactos/lib/crtdll/stdio/vsprintf.c @@ -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; +} + + diff --git a/reactos/lib/crtdll/stdlib/itoa.c b/reactos/lib/crtdll/stdlib/itoa.c index f4f1acb92fd..f8b77cf8f90 100644 --- a/reactos/lib/crtdll/stdlib/itoa.c +++ b/reactos/lib/crtdll/stdlib/itoa.c @@ -11,6 +11,7 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include +#include 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; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdlib/mbstowcs.c b/reactos/lib/crtdll/stdlib/mbstowcs.c new file mode 100644 index 00000000000..26cf8232f7a --- /dev/null +++ b/reactos/lib/crtdll/stdlib/mbstowcs.c @@ -0,0 +1,11 @@ +#include + +size_t mbstowcs( wchar_t *wcstr, const char *mbstr, size_t count ) +{ + return 0; +} + +int mbtowc( wchar_t *wchar, const char *mbchar, size_t count ) +{ + return 0; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/stdlib/wcstom.c b/reactos/lib/crtdll/stdlib/wcstom.c index 3d04153c3c2..9533eb2d44c 100644 --- a/reactos/lib/crtdll/stdlib/wcstom.c +++ b/reactos/lib/crtdll/stdlib/wcstom.c @@ -10,8 +10,5 @@ int wctomb (char* mbDest, wchar_t wc) return 0; } -int mblen (const char* mbs, size_t sizeString) -{ - return 0; -} + diff --git a/reactos/lib/crtdll/stdlib/wcstomb.c b/reactos/lib/crtdll/stdlib/wcstomb.c new file mode 100644 index 00000000000..4742dd3afb8 --- /dev/null +++ b/reactos/lib/crtdll/stdlib/wcstomb.c @@ -0,0 +1,122 @@ +/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#include +#include +#include + +#ifndef EILSEQ +#define EILSEQ EINVAL +#endif + +static const wchar_t encoding_mask[] = +{ + ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff +}; + +static const unsigned char encoding_byte[] = +{ + 0xc0, 0xe0, 0xf0, 0xf8, 0xfc +}; + +/* The state is for this UTF8 encoding not used. */ +//static mbstate_t internal; + + +//extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ + +size_t +__wcrtomb (char *s, wchar_t wc); + +/* Convert WCHAR into its multibyte character representation, + putting this in S and returning its length. + + Attention: this function should NEVER be intentionally used. + The interface is completely stupid. The state is shared between + all conversion functions. You should use instead the restartable + version `wcrtomb'. */ +int +wctomb (char *s, wchar_t wchar) +{ + /* If S is NULL the function has to return null or not null + depending on the encoding having a state depending encoding or + not. This is nonsense because any multibyte encoding has a + state. The ISO C amendment 1 corrects this while introducing the + restartable functions. We simply say here all encodings have a + state. */ + if (s == NULL) + return 1; + + return __wcrtomb (s, wchar); +} + + +size_t +__wcrtomb (char *s, wchar_t wc) +{ + char fake[1]; + size_t written = 0; + + + + if (s == NULL) + { + s = fake; + wc = L'\0'; + } + + /* Store the UTF8 representation of WC. */ + if (wc < 0 || wc > 0x7fffffff) + { + /* This is no correct ISO 10646 character. */ + __set_errno (EILSEQ); + return (size_t) -1; + } + + if (wc < 0x80) + { + /* It's a one byte sequence. */ + if (s != NULL) + *s = (char) wc; + return 1; + } + + for (written = 2; written < 6; ++written) + if ((wc & encoding_mask[written - 2]) == 0) + break; + + if (s != NULL) + { + size_t cnt = written; + s[0] = encoding_byte[cnt - 2]; + + --cnt; + do + { + s[cnt] = 0x80 | (wc & 0x3f); + wc >>= 6; + } + while (--cnt > 0); + s[0] |= wc; + } + + return written; +} diff --git a/reactos/lib/crtdll/stdlib/wcstombs.c b/reactos/lib/crtdll/stdlib/wcstombs.c new file mode 100644 index 00000000000..32fb7a0681a --- /dev/null +++ b/reactos/lib/crtdll/stdlib/wcstombs.c @@ -0,0 +1,152 @@ +/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + +#include +#include + +#ifndef EILSEQ +#define EILSEQ EINVAL +#endif + + +static const wchar_t encoding_mask[] = +{ + ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff +}; + +static const unsigned char encoding_byte[] = +{ + 0xc0, 0xe0, 0xf0, 0xf8, 0xfc +}; + +/* We don't need the state really because we don't have shift states + to maintain between calls to this function. */ +static mbstate_t internal; + + +extern mbstate_t __no_r_state; /* Defined in mbtowc.c. */ + +size_t +__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps); + +/* Convert the `wchar_t' string in PWCS to a multibyte character string + in S, writing no more than N characters. Return the number of bytes + written, or (size_t) -1 if an invalid `wchar_t' was found. + + Attention: this function should NEVER be intentionally used. + The interface is completely stupid. The state is shared between + all conversion functions. You should use instead the restartable + version `wcsrtombs'. */ +size_t +wcstombs (char *s, const wchar_t *pwcs, size_t n) +{ + mbstate_t save_shift = __no_r_state; + size_t written; + + written = __wcsrtombs (s, &pwcs, n, &__no_r_state); + + /* Restore the old shift state. */ + __no_r_state = save_shift; + + /* Return how many we wrote (or maybe an error). */ + return written; +} + +size_t +__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps) +{ + size_t written = 0; + const wchar_t *run = *src; + + if (ps == NULL) + ps = &internal; + + if (dst == NULL) + /* The LEN parameter has to be ignored if we don't actually write + anything. */ + len = ~0; + + while (written < len) + { + wchar_t wc = *run++; + + if (wc < 0 || wc > 0x7fffffff) + { + /* This is no correct ISO 10646 character. */ + __set_errno (EILSEQ); + return (size_t) -1; + } + + if (wc == L'\0') + { + /* Found the end. */ + if (dst != NULL) + *dst = '\0'; + *src = NULL; + return written; + } + else if (wc < 0x80) + { + /* It's an one byte sequence. */ + if (dst != NULL) + *dst++ = (char) wc; + ++written; + } + else + { + size_t step; + + for (step = 2; step < 6; ++step) + if ((wc & encoding_mask[step - 2]) == 0) + break; + + if (written + step >= len) + /* Too long. */ + break; + + if (dst != NULL) + { + size_t cnt = step; + + dst[0] = encoding_byte[cnt - 2]; + + --cnt; + do + { + dst[cnt] = 0x80 | (wc & 0x3f); + wc >>= 6; + } + while (--cnt > 0); + dst[0] |= wc; + + dst += step; + } + + written += step; + } + } + + /* Store position of first unprocessed word. */ + *src = run; + + return written; +} +//weak_alias (__wcsrtombs, wcsrtombs) \ No newline at end of file diff --git a/reactos/lib/crtdll/string/memccpy.c b/reactos/lib/crtdll/string/memccpy.c new file mode 100644 index 00000000000..eda7e7ddc4b --- /dev/null +++ b/reactos/lib/crtdll/string/memccpy.c @@ -0,0 +1,9 @@ +#include + + +void * +_memccpy (void *to, const void *from,int c,size_t count) +{ + memcpy(to,from,count); + return memchr(to,c,count); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/string/memicmp.c b/reactos/lib/crtdll/string/memicmp.c new file mode 100644 index 00000000000..e95d771b6dd --- /dev/null +++ b/reactos/lib/crtdll/string/memicmp.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +_memicmp(const void *s1, const void *s2, size_t n) +{ + if (n != 0) + { + const unsigned char *p1 = s1, *p2 = s2; + + do { + if (toupper(*p1) != toupper(*p2)) + return (*p1 - *p2); + p1++; + p2++; + } while (--n != 0); + } + return 0; +} diff --git a/reactos/lib/crtdll/string/strcoll.c b/reactos/lib/crtdll/string/strcoll.c index de9290acda6..07f5e248eab 100644 --- a/reactos/lib/crtdll/string/strcoll.c +++ b/reactos/lib/crtdll/string/strcoll.c @@ -7,6 +7,12 @@ #if 1 int strcoll (const char* s1, const char* s2) { + return strcmp(s1,s2); +} + +int _stricoll (const char* s1, const char* s2) +{ + return _stricmp(s1,s2); } #else int strcoll (const char *s1,const char *s2) diff --git a/reactos/lib/crtdll/string/strerror.c b/reactos/lib/crtdll/string/strerror.c index 0f9f9eb0395..7fad6fb8e84 100644 --- a/reactos/lib/crtdll/string/strerror.c +++ b/reactos/lib/crtdll/string/strerror.c @@ -45,7 +45,7 @@ char __syserr36[] = "No such process (ESRCH)"; char __syserr37[] = "Improper link (EXDEV)"; char __syserr38[] = "No more files (ENMFILE)"; -const char *__sys_errlist[] = { +const char *_sys_errlist[] = { __syserr00, __syserr01, __syserr02, __syserr03, __syserr04, __syserr05, __syserr06, __syserr07, __syserr08, __syserr09, __syserr10, __syserr11, __syserr12, __syserr13, __syserr14, @@ -56,7 +56,7 @@ __syserr30, __syserr31, __syserr32, __syserr33, __syserr34, __syserr35, __syserr36, __syserr37, __syserr38 }; -int __sys_nerr = sizeof(__sys_errlist) / sizeof(__sys_errlist[0]); +int __sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]); int* _sys_nerr_dll = &__sys_nerr; @@ -67,7 +67,7 @@ char *strerror(int errnum) int v=1000000, lz=0; if (errnum >= 0 && errnum < __sys_nerr) - return((char *)__sys_errlist[errnum]); + return((char *)_sys_errlist[errnum]); strcpy(ebuf, "Unknown error: "); cp = ebuf + 15; diff --git a/reactos/lib/crtdll/string/strrev.c b/reactos/lib/crtdll/string/strrev.c new file mode 100644 index 00000000000..4510839cb76 --- /dev/null +++ b/reactos/lib/crtdll/string/strrev.c @@ -0,0 +1,18 @@ +#include + +char * _strrev(char *s) +{ + char *e; + char a; + e=s; + while (*e) + e++; + while (s +#include + +char* _strnset (char* szToFill, int szFill, size_t sizeMaxFill) +{ + char *t = szToFill; + int i = 0; + while( *szToFill != 0 && i < sizeMaxFill) + { + *szToFill = szFill; + szToFill++; + i++; + + } + return t; +} + +char* _strset (char* szToFill, int szFill) +{ + char *t = szToFill; + while( *szToFill != 0 ) + { + *szToFill = szFill; + szToFill++; + + } + return t; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/string/strspnp.c b/reactos/lib/crtdll/string/strspnp.c new file mode 100644 index 00000000000..bbb1e3b9985 --- /dev/null +++ b/reactos/lib/crtdll/string/strspnp.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +char * +strspnp(const char *s1, const 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; +} diff --git a/reactos/lib/crtdll/sys_stat/ftime.c b/reactos/lib/crtdll/sys_stat/ftime.c new file mode 100644 index 00000000000..c78ad444543 --- /dev/null +++ b/reactos/lib/crtdll/sys_stat/ftime.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1994, 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +// crtdll has void return type instead of int +void +_ftime (timebuf) + struct timeb *timebuf; +{ + int save = errno; + struct tm *tp; + + __set_errno (0); + if (time (&timebuf->time) == (time_t) -1 && errno != 0) + return; + timebuf->millitm = 0; + tp = localtime(&timebuf->time); + if (tp == NULL) + return; + + timebuf->_timezone = tp->tm_gmtoff / 60; + timebuf->dstflag = tp->tm_isdst; + + free(tp); + __set_errno (save); + return; +} + diff --git a/reactos/lib/crtdll/sys_stat/systime.c b/reactos/lib/crtdll/sys_stat/systime.c new file mode 100644 index 00000000000..76859f501c4 --- /dev/null +++ b/reactos/lib/crtdll/sys_stat/systime.c @@ -0,0 +1,14 @@ +#include + +unsigned int _getsystime(struct tm *tp) +{ + printf("getsystime\n"); + return 0; +} + + +unsigned int _setsystime(struct tm *tp, unsigned int ms) +{ + printf("setsystime\n"); + return 0; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/tchar/strninc.c b/reactos/lib/crtdll/tchar/strninc.c index 72169a51ffb..75f279bee2e 100644 --- a/reactos/lib/crtdll/tchar/strninc.c +++ b/reactos/lib/crtdll/tchar/strninc.c @@ -1,4 +1,5 @@ #include +#include char * _strninc(const char *str, size_t inc) { diff --git a/reactos/lib/crtdll/tchar/strspnp.c b/reactos/lib/crtdll/tchar/strspnp.c index 1a56476a798..06b5626b31b 100644 --- a/reactos/lib/crtdll/tchar/strspnp.c +++ b/reactos/lib/crtdll/tchar/strspnp.c @@ -1,4 +1,5 @@ #include +#include char * _strspnp( const char * str1, const char * str2) diff --git a/reactos/lib/crtdll/time/ctime.c b/reactos/lib/crtdll/time/ctime.c index 0eee0f9dc89..a9f3e78b2f9 100644 --- a/reactos/lib/crtdll/time/ctime.c +++ b/reactos/lib/crtdll/time/ctime.c @@ -82,6 +82,7 @@ static char sccsid[] = "@(#)ctime.c 5.23 (Berkeley) 6/22/90"; ** that tzname[0] has the "normal" length of three characters). */ int _daylight_dll; +int _timezone_dll; static char WILDABBR[] = " "; @@ -176,7 +177,7 @@ static struct state gmtmem; static int lcl_is_set; static int gmt_is_set; -char * tzname[2] = { +char * _tzname[2] = { WILDABBR, WILDABBR }; @@ -199,12 +200,12 @@ settzname(void) const struct state * const sp = lclptr; int i; - tzname[0] = WILDABBR; - tzname[1] = WILDABBR; + _tzname[0] = WILDABBR; + _tzname[1] = WILDABBR; #ifdef ALL_STATE if (sp == NULL) { - tzname[0] = tzname[1] = GMT; + _tzname[0] = _tzname[1] = GMT; return; } #endif /* defined ALL_STATE */ @@ -212,13 +213,13 @@ settzname(void) { register const struct ttinfo * const ttisp = &sp->ttis[i]; - tzname[ttisp->tt_isdst] = + _tzname[ttisp->tt_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; #if 0 if (ttisp->tt_isdst) _daylight = 1; if (i == 0 || !ttisp->tt_isdst) - _timezone = -(ttisp->tt_gmtoff); + _timezone_dll = -(ttisp->tt_gmtoff); if (i == 0 || ttisp->tt_isdst) _altzone = -(ttisp->tt_gmtoff); #endif @@ -230,7 +231,7 @@ settzname(void) { const struct ttinfo * const ttisp = &sp->ttis[sp->types[i]]; - tzname[ttisp->tt_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; + _tzname[ttisp->tt_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; } } @@ -894,7 +895,7 @@ gmtload(struct state * const sp) } void -tzset(void) +_tzset(void) { const char * name; @@ -972,7 +973,7 @@ localsub(const time_t * const timep, const long offset, struct tm * const tmp) const time_t t = *timep; if (!lcl_is_set) - tzset(); + _tzset(); sp = lclptr; #ifdef ALL_STATE if (sp == NULL) @@ -1007,7 +1008,7 @@ localsub(const time_t * const timep, const long offset, struct tm * const tmp) */ timesub(&t, ttisp->tt_gmtoff, sp, tmp); tmp->tm_isdst = ttisp->tt_isdst; - tzname[tmp->tm_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; + _tzname[tmp->tm_isdst] = (char *)&sp->chars[ttisp->tt_abbrind]; tmp->tm_zone = (char *)&sp->chars[ttisp->tt_abbrind]; } diff --git a/reactos/lib/crtdll/time/strdate.c b/reactos/lib/crtdll/time/strdate.c new file mode 100644 index 00000000000..253bfc0178f --- /dev/null +++ b/reactos/lib/crtdll/time/strdate.c @@ -0,0 +1,18 @@ +#include +#include + +// copy date according to mm/dd/yy format +char *_strdate( const char *datestr ) +{ + + time_t t; + struct tm *d; + char *dt = (char *)datestr; + + if ( datestr == NULL ) + return NULL; + t = time(NULL); + d = localtime(&t); + sprintf(dt,"%d\%d\%d",d->tm_mday,d->tm_mon+1,d->tm_year); + return dt; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/time/strftime.c b/reactos/lib/crtdll/time/strftime.c index cc6f0e9dcda..94f18d25835 100644 --- a/reactos/lib/crtdll/time/strftime.c +++ b/reactos/lib/crtdll/time/strftime.c @@ -226,3 +226,9 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *t) } return 0; } + +size_t +wcsftime(wchar_t *s, size_t maxsize, const wchar_t *format, const struct tm *t) +{ + printf("wcsftime\n"); +} \ No newline at end of file diff --git a/reactos/lib/crtdll/time/strtime.c b/reactos/lib/crtdll/time/strtime.c new file mode 100644 index 00000000000..6ec310555a2 --- /dev/null +++ b/reactos/lib/crtdll/time/strtime.c @@ -0,0 +1,7 @@ +#include + +char *_strtime(char* buf) +{ + printf("strtime\n"); + return ""; +} \ No newline at end of file diff --git a/reactos/lib/crtdll/wchar/wcscoll.c b/reactos/lib/crtdll/wchar/wcscoll.c index cbebef173f1..98a65d73a83 100644 --- a/reactos/lib/crtdll/wchar/wcscoll.c +++ b/reactos/lib/crtdll/wchar/wcscoll.c @@ -12,6 +12,6 @@ int wcscoll(const wchar_t *a1,const wchar_t *a2) int _wcsicoll(const wchar_t *a1,const wchar_t *a2) { /* FIXME: handle collates */ - return wcscmp(a1,a2); + return _wcsicmp(a1,a2); } diff --git a/reactos/lib/crtdll/wchar/wcsnicmp.c b/reactos/lib/crtdll/wchar/wcsnicmp.c index b39ce446678..d71ed6c4de7 100644 --- a/reactos/lib/crtdll/wchar/wcsnicmp.c +++ b/reactos/lib/crtdll/wchar/wcsnicmp.c @@ -2,7 +2,7 @@ int _wcsnicmp(const wchar_t * cs,const wchar_t * ct,size_t count) { - wchar_t *save = cs; + wchar_t *save = (char *)cs; while (towlower(*cs) == towlower(*ct) && (int)(cs - save) < count) { if (*cs == 0) diff --git a/reactos/lib/crtdll/wchar/wcspbrk.c b/reactos/lib/crtdll/wchar/wcspbrk.c index 8d126bcacf8..f3643665fd5 100644 --- a/reactos/lib/crtdll/wchar/wcspbrk.c +++ b/reactos/lib/crtdll/wchar/wcspbrk.c @@ -2,4 +2,15 @@ wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2) { + const wchar_t *scanp; + int c, sc; + + while ((c = *s1++) != 0) + { + for (scanp = s2; (sc = *scanp++) != 0;) + if (sc == c) { + return (wchar_t *)(--s1); + } + } + return 0; } \ No newline at end of file diff --git a/reactos/lib/crtdll/wchar/wcsset.c b/reactos/lib/crtdll/wchar/wcsset.c index 7ff176361f4..f6b061358d5 100644 --- a/reactos/lib/crtdll/wchar/wcsset.c +++ b/reactos/lib/crtdll/wchar/wcsset.c @@ -1,4 +1,4 @@ -#inlcude +#include wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill) { @@ -14,7 +14,7 @@ wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill) return t; } -wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcToFill) +wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcFill) { wchar_t *t = wsToFill; while( *wsToFill != 0 ) diff --git a/reactos/lib/crtdll/wchar/wcstok.c b/reactos/lib/crtdll/wchar/wcstok.c index 19e0e7fe6c1..3afd7174d03 100644 --- a/reactos/lib/crtdll/wchar/wcstok.c +++ b/reactos/lib/crtdll/wchar/wcstok.c @@ -1,6 +1,6 @@ #include -wchar_t *_wcstok(wchar_t *s, const wchar_t *ct) +wchar_t *wcstok(wchar_t *s, const wchar_t *ct) { const wchar_t *spanp; int c, sc; diff --git a/reactos/lib/crtdll/wchar/wcstol.c b/reactos/lib/crtdll/wchar/wcstol.c index 1c399763a62..5a5ae97df77 100644 --- a/reactos/lib/crtdll/wchar/wcstol.c +++ b/reactos/lib/crtdll/wchar/wcstol.c @@ -1,14 +1,14 @@ #include -long wcstol(const wchar_t *cp,wchar_t **endp,unsigned int base) +long wcstol(const wchar_t *cp,wchar_t **endp,int base) { long result = 0,value; int sign = 1; if ( *cp == L'-' ) { sign = -1; - *cp++; + cp++; } if (!base) { @@ -33,7 +33,7 @@ long wcstol(const wchar_t *cp,wchar_t **endp,unsigned int base) } -unsigned long wcstoul(const wchar_t *cp,wchar_t **endp,unsigned int base) +unsigned long wcstoul(const wchar_t *cp,wchar_t **endp,int base) { unsigned long result = 0,value; diff --git a/reactos/lib/crtdll/wchar/wcstombs.c b/reactos/lib/crtdll/wchar/wcstombs.c index 6cb254ea82b..f660411840d 100644 --- a/reactos/lib/crtdll/wchar/wcstombs.c +++ b/reactos/lib/crtdll/wchar/wcstombs.c @@ -1,4 +1,5 @@ - +#include +#include size_t wcstombs( char *dst, const wchar_t *src, size_t len ) { diff --git a/reactos/lib/crtdll/wchar/wcsxfrm.c b/reactos/lib/crtdll/wchar/wcsxfrm.c index 0fd6c6bf1f6..c5499792540 100644 --- a/reactos/lib/crtdll/wchar/wcsxfrm.c +++ b/reactos/lib/crtdll/wchar/wcsxfrm.c @@ -1,6 +1,6 @@ #include -size_t _wcsxfrm(char *dst,const char *src, size_t n) +size_t wcsxfrm(wchar_t *dst,const wchar_t *src, size_t n) { size_t r = 0; int c; diff --git a/reactos/lib/crtdll/wchar/wtoi.c b/reactos/lib/crtdll/wchar/wtoi.c new file mode 100644 index 00000000000..003f7c8e571 --- /dev/null +++ b/reactos/lib/crtdll/wchar/wtoi.c @@ -0,0 +1,11 @@ +#include + +int _wtoi( const wchar_t *str ) +{ + return (int)wcstol(str, 0, 10); +} + +long _wtol( const wchar_t *str ) +{ + return (int)wcstol(str, 0, 10); +} \ No newline at end of file