Added DbgPrint()

Fixed some Rtl functions
Added missing printf() and wprintf() functions

svn path=/trunk/; revision=926
This commit is contained in:
Eric Kohl 2000-01-10 20:34:41 +00:00
parent 686387f8e0
commit be132afdf2
9 changed files with 684 additions and 242 deletions

View file

@ -0,0 +1,37 @@
/* $Id: print.c,v 1.1 2000/01/10 20:31:23 ekohl Exp $
*
*/
#include <ddk/ntddk.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
ULONG
DbgPrint (PCH Format, ...)
{
CHAR Buffer[512];
va_list ap;
UNICODE_STRING UnicodeString;
ANSI_STRING AnsiString;
va_start (ap, Format);
vsprintf (Buffer, Format, ap);
va_end (ap);
RtlInitAnsiString (&AnsiString,
Buffer);
RtlAnsiStringToUnicodeString (&UnicodeString,
&AnsiString,
TRUE);
/* FIXME: send string to debugging subsystem */
NtDisplayString (&UnicodeString);
RtlFreeUnicodeString (&UnicodeString);
return (strlen (Buffer));
}
/* EOF */

View file

@ -1,10 +1,13 @@
; $Id: ntdll.def,v 1.35 1999/12/30 14:39:27 ekohl Exp $
; $Id: ntdll.def,v 1.36 2000/01/10 20:33:50 ekohl Exp $
;
; ReactOS Operating System
;
LIBRARY ntdll.dll
EXPORTS
DbgBreakPoint
DbgPrint
DbgUserBreakPoint
NlsAnsiCodePage
NlsMbCodePageTag
NlsMbOemCodePageTag
@ -552,8 +555,8 @@ _ltoa
_ltow
_memccpy
_memicmp
;_snprintf
;_snwprintf
_snprintf
_snwprintf
_splitpath
_strcmpi
_stricmp
@ -564,7 +567,7 @@ _tolower
_toupper
_ultoa
_ultow
;_vsnprintf
_vsnprintf
_wcsicmp
_wcslwr
_wcsnicmp
@ -622,7 +625,7 @@ strspn
strstr
strtol
strtoul
;swprintf
swprintf
tan
tolower
toupper

View file

@ -1,10 +1,13 @@
; $Id: ntdll.edf,v 1.25 1999/12/30 14:39:27 ekohl Exp $
; $Id: ntdll.edf,v 1.26 2000/01/10 20:33:50 ekohl Exp $
;
; ReactOS Operating System
;
LIBRARY ntdll.dll
EXPORTS
DbgBreakPoint
DbgPrint
DbgUserBreakPoint
NlsAnsiCodePage
NlsMbCodePageTag
NlsMbOemCodePageTag
@ -533,6 +536,8 @@ _ltoa
_ltow
_memccpy
_memicmp
_snprintf
_snwprintf
_splitpath
_strcmpi
_stricmp
@ -543,6 +548,7 @@ _tolower
_toupper
_ultoa
_ultow
_vsnprintf
_wcsicmp
_wcslwr
_wcsnicmp
@ -598,6 +604,7 @@ strspn
strstr
strtol
strtoul
swprintf
tan
tolower
toupper

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.33 1999/12/30 14:39:43 ekohl Exp $
# $Id: makefile,v 1.34 2000/01/10 20:34:41 ekohl Exp $
#
# ReactOS Operating System
#
@ -25,12 +25,14 @@ all: $(DLLTARGET)
CSR_OBJECTS = csr/api.o
DBG_OBJECTS = dbg/brkpoint.o
DBG_OBJECTS = dbg/brkpoint.o dbg/print.o
RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
rtl/math.o rtl/mem.o rtl/nls.o rtl/process.o rtl/security.o \
rtl/thread.o rtl/unicode.o rtl/env.o
STDIO_OBJECTS = stdio/swprintf.o stdio/vsprintf.o
STDLIB_OBJECTS = stdlib/abs.o stdlib/atoi.o stdlib/atoi64.o stdlib/atol.o \
stdlib/itoa.o stdlib/itow.o stdlib/labs.o stdlib/splitp.o \
stdlib/strtol.o stdlib/strtoul.o stdlib/wcstol.o \
@ -48,7 +50,7 @@ STRING_OBJECTS = string/ctype.o string/memccpy.o string/memchr.o \
string/strstr.o string/strupr.o string/wstring.o
OBJECTS = napi.o ldr/startup.o $(DBG_OBJECTS) $(RTL_OBJECTS) \
stdio/vsprintf.o $(STDLIB_OBJECTS) $(STRING_OBJECTS) \
$(STDIO_OBJECTS) $(STDLIB_OBJECTS) $(STRING_OBJECTS) \
stubs/stubs.o ldr/utils.o $(CSR_OBJECTS) $(TARGET).coff
ifeq ($(DOSCLI),yes)

View file

@ -1,4 +1,4 @@
/* $Id: unicode.c,v 1.11 1999/12/10 17:48:34 ekohl Exp $
/* $Id: unicode.c,v 1.12 2000/01/10 20:30:51 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -11,15 +11,12 @@
#include <ddk/ntddk.h>
//#include <internal/nls.h>
#include <ctype.h>
#define NDEBUG
#include <internal/debug.h>
extern unsigned long simple_strtoul(const char *cp, char **endp,
unsigned int base);
/* FUNCTIONS *****************************************************************/
WCHAR
@ -252,7 +249,36 @@ RtlCharToInteger (
IN ULONG Base,
IN OUT PULONG Value)
{
*Value=simple_strtoul((const char *)String, NULL, Base);
ULONG Val;
*Value = 0;
if (Base == 0)
{
Base = 10;
if (*String == '0')
{
Base = 8;
String++;
if ((*String == 'x') && isxdigit (String[1]))
{
String++;
Base = 16;
}
}
}
if (!isxdigit (*String))
return STATUS_INVALID_PARAMETER;
while (isxdigit (*String) &&
(Val = isdigit (*String) ? * String - '0' : (islower (*String)
? toupper (*String) : *String) - 'A' + 10) < Base)
{
*Value = *Value * Base + Val;
String++;
}
return STATUS_SUCCESS;
}
@ -976,68 +1002,87 @@ RtlUnicodeStringToInteger (
IN ULONG Base,
OUT PULONG Value)
{
return STATUS_NOT_IMPLEMENTED;
#if 0
char *str;
unsigned long i, lenmin=0;
BOOLEAN addneg=FALSE;
PWCHAR Str;
ULONG lenmin = 0;
ULONG i;
ULONG Val;
BOOLEAN addneg = FALSE;
str = RtlAllocateHeap (RtlGetProcessHeap (),
0,
String->Length+1);
Str = String->Buffer;
for (i = 0; i < String->Length; i++)
{
if (*Str == L'b')
{
Base = 2;
lenmin++;
}
else if (*Str == L'o')
{
Base = 8;
lenmin++;
}
else if (*Str == L'd')
{
Base = 10;
lenmin++;
}
else if (*Str == L'x')
{
Base = 16;
lenmin++;
}
else if (*Str == L'+')
{
lenmin++;
}
else if (*Str == L'-')
{
addneg = TRUE;
lenmin++;
}
else if ((*Str > L'1') && (Base == 2))
{
*Value = 0;
return STATUS_INVALID_PARAMETER;
}
else if (((*Str > L'7') || (*Str < L'0')) && (Base == 8))
{
*Value = 0;
return STATUS_INVALID_PARAMETER;
}
else if (((*Str > L'9') || (*Str < L'0')) && (Base == 10))
{
*Value = 0;
return STATUS_INVALID_PARAMETER;
}
else if ((((*Str > L'9') || (*Str < L'0')) ||
((towupper (*Str) > L'F') ||
(towupper (*Str) < L'A'))) && (Base == 16))
{
*Value = 0;
return STATUS_INVALID_PARAMETER;
}
else
Str++;
}
for(i=0; i<String->Length; i++)
{
*str=*String->Buffer;
Str = String->Buffer + lenmin;
if(*str=='b') { Base=2; lenmin++; } else
if(*str=='o') { Base=8; lenmin++; } else
if(*str=='d') { Base=10; lenmin++; } else
if(*str=='x') { Base=16; lenmin++; } else
if(*str=='+') { lenmin++; } else
if(*str=='-') { addneg=TRUE; lenmin++; } else
if((*str>'1') && (Base==2)) {
String->Buffer-=i;
*Value=0;
return STATUS_INVALID_PARAMETER;
} else
if(((*str>'7') || (*str<'0')) && (Base==8)) {
String->Buffer-=i;
*Value=0;
return STATUS_INVALID_PARAMETER;
} else
if(((*str>'9') || (*str<'0')) && (Base==10)) {
String->Buffer-=i;
*Value=0;
return STATUS_INVALID_PARAMETER;
} else
if((((*str>'9') || (*str<'0')) ||
((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16))
{
String->Buffer-=i;
*Value=0;
return STATUS_INVALID_PARAMETER;
} else
str++;
if (Base == 0)
Base = 10;
String->Buffer++;
};
while (iswxdigit (*Str) &&
(Val = iswdigit (*Str) ? *Str - L'0' : (iswlower (*Str)
? toupper (*Str) : *Str) - L'A' + 10) < Base)
{
*Value = *Value * Base + Val;
Str++;
}
*str=0;
String->Buffer-=String->Length;
str-=(String->Length-lenmin);
if (addneg == TRUE)
*Value *= -1;
if(addneg==TRUE) {
*Value=simple_strtoul(str, NULL, Base)*-1;
} else
*Value=simple_strtoul(str, NULL, Base);
RtlFreeHeap (RtlGetProcessHeap (),
0,
str);
return(STATUS_SUCCESS);
#endif
return STATUS_SUCCESS;
}

View file

@ -0,0 +1,367 @@
/* $Id: swprintf.c,v 1.1 2000/01/10 20:33:06 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdio/swprintf.c
* PURPOSE: Unicode printf functions
* PROGRAMMERS: David Welch
* Eric Kohl
*/
/*
* linux/lib/vsprintf.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <wchar.h>
#include <limits.h>
#define NDEBUG
#include <internal/debug.h>
static size_t wcsnlen(const wchar_t *str, size_t count)
{
const wchar_t *s;
if (str == 0)
return 0;
for (s = str; *s && count; ++s, count--);
return s-str;
}
static int skip_atoi(const wchar_t **s)
{
int i=0;
while (iswdigit(**s))
i = i*10 + *((*s)++) - L'0';
return i;
}
#define ZEROPAD 1 /* pad with zero */
#define SIGN 2 /* unsigned/signed long */
#define PLUS 4 /* show plus */
#define SPACE 8 /* space if plus */
#define LEFT 16 /* left justified */
#define SPECIAL 32 /* 0x */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
#define do_div(n,base) ({ \
int __res; \
__res = ((unsigned long) n) % (unsigned) base; \
n = ((unsigned long) n) / (unsigned) base; \
__res; })
static wchar_t *
number (wchar_t *str, long num, int base, int size, int precision,
int type)
{
wchar_t c,sign,tmp[66];
const wchar_t *digits = L"0123456789abcdefghijklmnopqrstuvwxyz";
int i;
if (type & LARGE)
digits = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return 0;
c = (type & ZEROPAD) ? L'0' : L' ';
sign = 0;
if (type & SIGN)
{
if (num < 0)
{
sign = L'-';
num = -num;
size--;
}
else if (type & PLUS)
{
sign = L'+';
size--;
}
else if (type & SPACE)
{
sign = L' ';
size--;
}
}
if (type & SPECIAL)
{
if (base == 16)
size -= 2;
else if (base == 8)
size--;
}
i = 0;
if (num == 0)
tmp[i++]='0';
else while (num != 0)
tmp[i++] = digits[do_div(num,base)];
if (i > precision)
precision = i;
size -= precision;
if (!(type&(ZEROPAD+LEFT)))
while(size-->0)
*str++ = L' ';
if (sign)
*str++ = sign;
if (type & SPECIAL)
{
if (base==8)
{
*str++ = L'0';
}
else if (base==16)
{
*str++ = L'0';
*str++ = digits[33];
}
}
if (!(type & LEFT))
while (size-- > 0)
*str++ = c;
while (i < precision--)
*str++ = '0';
while (i-- > 0)
*str++ = tmp[i];
while (size-- > 0)
*str++ = L' ';
return str;
}
int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args)
{
int len;
unsigned long num;
int i, base;
wchar_t * str;
const wchar_t *s;
// const short int* sw; /* needed for '%w' only */
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != L'%') {
*str++ = *fmt;
continue;
}
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case L'-': flags |= LEFT; goto repeat;
case L'+': flags |= PLUS; goto repeat;
case L' ': flags |= SPACE; goto repeat;
case L'#': flags |= SPECIAL; goto repeat;
case L'0': flags |= ZEROPAD; goto repeat;
}
/* get field width */
field_width = -1;
if (iswdigit(*fmt))
field_width = skip_atoi(&fmt);
else if (*fmt == L'*') {
++fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (*fmt == L'.') {
++fmt;
if (iswdigit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == L'*') {
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
if (precision < 0)
precision = 0;
}
/* get the conversion qualifier */
qualifier = -1;
if (*fmt == L'h' || *fmt == L'l' || *fmt == L'L') {
qualifier = *fmt;
++fmt;
}
/* default base */
base = 10;
switch (*fmt) {
case L'c':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = L' ';
*str++ = (wchar_t) va_arg(args, int);
while (--field_width > 0)
*str++ = L' ';
continue;
#if 0
case 'w':
sw = va_arg(args,short int *);
// DPRINT("L %x\n",sw);
if (sw==NULL) {
// CHECKPOINT;
s = "<NULL>";
while ((*s)!=0)
*str++ = *s++;
// CHECKPOINT;
// DbgPrint("str %x\n",str);
} else {
while ((*sw)!=0)
*str++ = (char)(*sw++);
}
// CHECKPOINT;
continue;
#endif
case L's':
s = va_arg(args, wchar_t *);
if (!s)
s = L"<NULL>";
len = wcsnlen((wchar_t *)s, precision);
len = wcslen((wchar_t *)s);
if (len > precision)
len = precision;
if (!(flags & LEFT))
while (len < field_width--)
*str++ = L' ';
for (i = 0; i < len; ++i)
*str++ = *s++;
while (len < field_width--)
*str++ = L' ';
continue;
case L'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
flags |= ZEROPAD;
}
str = number(str,
(unsigned long) va_arg(args, void *), 16,
field_width, precision, flags);
continue;
case L'n':
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
*ip = (str - buf);
} else {
int * ip = va_arg(args, int *);
*ip = (str - buf);
}
continue;
/* integer number formats - set up the flags and "break" */
case L'o':
base = 8;
break;
case L'b':
base = 2;
break;
case L'X':
flags |= LARGE;
case L'x':
base = 16;
break;
case L'd':
case L'i':
flags |= SIGN;
case L'u':
break;
default:
if (*fmt != L'%')
*str++ = L'%';
if (*fmt)
*str++ = *fmt;
else
--fmt;
continue;
}
if (qualifier == 'l')
num = va_arg(args, unsigned long);
else if (qualifier == 'h')
if (flags & SIGN)
num = va_arg(args, short);
else
num = va_arg(args, unsigned short);
else if (flags & SIGN)
num = va_arg(args, int);
else
num = va_arg(args, unsigned int);
str = number(str, num, base, field_width, precision, flags);
}
*str = L'\0';
return str-buf;
}
int swprintf(wchar_t *buf, const wchar_t *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i=_vsnwprintf(buf,INT_MAX,fmt,args);
va_end(args);
return i;
}
int _snwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i=_vsnwprintf(buf,cnt,fmt,args);
va_end(args);
return i;
}
int vswprintf(wchar_t *buf, const wchar_t *fmt, va_list args)
{
return _vsnwprintf(buf,INT_MAX,fmt,args);
}
/* EOF */

View file

@ -11,41 +11,25 @@
/*
* Appropiated for the reactos kernel, March 1998 -- David Welch
*
* TODO:
* - Implement maximum length (cnt) in _vsnprintf().
* - Add MS specific types 'C', 'S', 'Z'...
* - Add long long support ('ll' qualifier).
* - Add MS specific qualifier 'I64'.
* Eric Kohl
*/
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <internal/debug.h>
extern size_t strnlen(const char* string, size_t maxlen);
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
{
unsigned long result = 0,value;
if (!base) {
base = 10;
if (*cp == '0') {
base = 8;
cp++;
if ((*cp == 'x') && isxdigit(cp[1])) {
cp++;
base = 16;
}
}
}
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
? toupper(*cp) : *cp)-'A'+10) < base) {
result = result*base + value;
cp++;
}
if (endp)
*endp = (char *)cp;
return result;
}
/* we use this so that we can do without the ctype library */
#define is_digit(c) ((c) >= '0' && (c) <= '9')
@ -73,96 +57,85 @@ __res = ((unsigned long) n) % (unsigned) base; \
n = ((unsigned long) n) / (unsigned) base; \
__res; })
static char * number(char * str, long num, int base, int size, int precision,
int type)
static char *
number (char * str, long num, int base, int size, int precision, int type)
{
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return 0;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0;
if (type & SIGN)
{
if (num < 0)
{
sign = '-';
num = -num;
size--;
}
else if (type & PLUS)
{
sign = '+';
size--;
}
else if (type & SPACE)
{
sign = ' ';
size--;
}
}
if (type & SPECIAL)
{
if (base == 16)
size -= 2;
else if (base == 8)
size--;
}
i = 0;
if (num == 0)
tmp[i++]='0';
else while (num != 0)
tmp[i++] = digits[do_div(num,base)];
if (i > precision)
precision = i;
size -= precision;
if (!(type&(ZEROPAD+LEFT)))
while(size-->0)
*str++ = ' ';
if (sign)
*str++ = sign;
if (type & SPECIAL)
{
if (base==8)
{
*str++ = '0';
}
else if (base==16)
{
*str++ = '0';
*str++ = digits[33];
}
}
if (!(type & LEFT))
while (size-- > 0)
*str++ = c;
while (i < precision--)
*str++ = '0';
while (i-- > 0)
*str++ = tmp[i];
while (size-- > 0)
*str++ = ' ';
return str;
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return 0;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0;
if (type & SIGN) {
if (num < 0) {
sign = '-';
num = -num;
size--;
} else if (type & PLUS) {
sign = '+';
size--;
} else if (type & SPACE) {
sign = ' ';
size--;
}
}
if (type & SPECIAL) {
if (base == 16)
size -= 2;
else if (base == 8)
size--;
}
i = 0;
if (num == 0)
tmp[i++]='0';
else while (num != 0)
tmp[i++] = digits[do_div(num,base)];
if (i > precision)
precision = i;
size -= precision;
if (!(type&(ZEROPAD+LEFT)))
while(size-->0)
*str++ = ' ';
if (sign)
*str++ = sign;
if (type & SPECIAL) {
if (base==8) {
*str++ = '0';
} else if (base==16) {
*str++ = '0';
*str++ = digits[33];
}
}
if (!(type & LEFT))
while (size-- > 0)
*str++ = c;
while (i < precision--)
*str++ = '0';
while (i-- > 0)
*str++ = tmp[i];
while (size-- > 0)
*str++ = ' ';
return str;
}
int vsprintf(char *buf, const char *fmt, va_list args)
int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args)
{
int len;
unsigned long num;
int i, base;
char * str;
const char *s;
const short int* sw;
const short int* sw;
int flags; /* flags to number() */
@ -170,15 +143,13 @@ int vsprintf(char *buf, const char *fmt, va_list args)
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
/* process flags */
flags = 0;
repeat:
@ -189,8 +160,8 @@ int vsprintf(char *buf, const char *fmt, va_list args)
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
}
/* get field width */
field_width = -1;
if (is_digit(*fmt))
@ -208,7 +179,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
/* get the precision */
precision = -1;
if (*fmt == '.') {
++fmt;
++fmt;
if (is_digit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == '*') {
@ -240,30 +211,32 @@ int vsprintf(char *buf, const char *fmt, va_list args)
*str++ = ' ';
continue;
case 'w':
sw = va_arg(args,short int *);
// DPRINT("L %x\n",sw);
if (sw==NULL)
{
case 'C':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = ' ';
*str++ = (unsigned char) va_arg(args, wchar_t);
while (--field_width > 0)
*str++ = ' ';
continue;
case 'w':
sw = va_arg(args,short int *);
// DPRINT("L %x\n",sw);
if (sw==NULL) {
// CHECKPOINT;
s = "<NULL>";
while ((*s)!=0)
*str++ = *s++;
// CHECKPOINT;
// DbgPrint("str %x\n",str);
} else {
while ((*sw)!=0)
*str++ = (char)(*sw++);
}
// CHECKPOINT;
s = "<NULL>";
while ((*s)!=0)
{
*str++ = *s++;
}
// CHECKPOINT;
// DbgPrint("str %x\n",str);
}
else
{
while ((*sw)!=0)
{
*str++ = (char)(*sw++);
}
}
// CHECKPOINT;
continue;
continue;
case 's':
s = va_arg(args, char *);
if (!s)
@ -280,9 +253,21 @@ int vsprintf(char *buf, const char *fmt, va_list args)
*str++ = ' ';
continue;
case 'S':
sw = va_arg(args,short int *);
if (sw==NULL) {
s = "<NULL>";
while ((*s)!=0)
*str++ = *s++;
} else {
while ((*sw)!=0)
*str++ = (char)(*sw++);
}
continue;
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
field_width = 2 * sizeof(void *);
flags |= ZEROPAD;
}
str = number(str,
@ -290,7 +275,6 @@ int vsprintf(char *buf, const char *fmt, va_list args)
field_width, precision, flags);
continue;
case 'n':
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
@ -305,11 +289,11 @@ int vsprintf(char *buf, const char *fmt, va_list args)
case 'o':
base = 8;
break;
case 'b':
base = 2;
break;
case 'b':
base = 2;
break;
case 'X':
flags |= LARGE;
case 'x':
@ -354,41 +338,25 @@ int sprintf(char * buf, const char *fmt, ...)
int i;
va_start(args, fmt);
i=vsprintf(buf,fmt,args);
i=_vsnprintf(buf,INT_MAX,fmt,args);
va_end(args);
return i;
}
int wsprintfA(char * buf, const char *fmt, ...)
int _snprintf(char * buf, size_t cnt, const char *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i=vsprintf(buf,fmt,args);
i=_vsnprintf(buf,cnt,fmt,args);
va_end(args);
return i;
}
#if 0
int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
int vsprintf(char *buf, const char *fmt, va_list args)
{
va_list args;
int i;
va_start(args, fmt);
//i=vsprintf(buf,fmt,args);
va_end(args);
return i;
return _vsnprintf(buf,INT_MAX,fmt,args);
}
#endif
#if 0
int iswlower(wint_t w)
{
if ( w < L'A' )
return 1;
else
return 0;
}
#endif
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: ctype.c,v 1.6 2000/01/05 17:49:00 ekohl Exp $
/* $Id: ctype.c,v 1.7 2000/01/10 20:30:15 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -355,16 +355,33 @@ int isupper(int c)
return (_isctype (c, _UPPER));
}
int isxdigit(int c)
{
return (_isctype (c, _HEX));
}
int iswalpha(wint_t c)
{
return (iswctype (c, _ALPHA));
}
int isxdigit(int c)
int iswdigit(wint_t c)
{
return (_isctype (c, _HEX));
return (iswctype (c, _DIGIT));
}
int iswlower(wint_t c)
{
return (iswctype (c, _LOWER));
}
int iswxdigit(wint_t c)
{
return (iswctype (c, _HEX));
}
int __toascii(int c)
{
return((unsigned)(c) & 0x7f);

View file

@ -191,10 +191,6 @@ STUB(_aullrem)
STUB(_aullshr)
//STUB(_chkstk)
STUB(_fltused)
STUB(_snprintf)
STUB(_snwprintf)
STUB(_vsnprintf)
STUB(qsort)
STUB(sscanf)
STUB(swprintf)