Added _BITMAPSIZE_ and split _CONVERT_ macro to remove #ifdefs.
This commit is contained in:
parent
1c875a4f4f
commit
ccd749684f
|
@ -29,16 +29,20 @@
|
||||||
#define _EOF_RET MSVCRT_WEOF
|
#define _EOF_RET MSVCRT_WEOF
|
||||||
#define _ISSPACE_(c) MSVCRT_iswspace(c)
|
#define _ISSPACE_(c) MSVCRT_iswspace(c)
|
||||||
#define _ISDIGIT_(c) MSVCRT_iswdigit(c)
|
#define _ISDIGIT_(c) MSVCRT_iswdigit(c)
|
||||||
#define _CONVERT_(c) c /*** FIXME ***/
|
#define _WIDE2SUPPORTED_(c) c /* No conversion needed (wide to wide) */
|
||||||
|
#define _CHAR2SUPPORTED_(c) c /* FIXME: convert char to wide char */
|
||||||
#define _CHAR2DIGIT_(c, base) wchar2digit((c), (base))
|
#define _CHAR2DIGIT_(c, base) wchar2digit((c), (base))
|
||||||
|
#define _BITMAPSIZE_ 256*256
|
||||||
#else /* WIDE_SCANF */
|
#else /* WIDE_SCANF */
|
||||||
#define _CHAR_ char
|
#define _CHAR_ char
|
||||||
#define _EOF_ MSVCRT_EOF
|
#define _EOF_ MSVCRT_EOF
|
||||||
#define _EOF_RET MSVCRT_EOF
|
#define _EOF_RET MSVCRT_EOF
|
||||||
#define _ISSPACE_(c) isspace(c)
|
#define _ISSPACE_(c) isspace(c)
|
||||||
#define _ISDIGIT_(c) isdigit(c)
|
#define _ISDIGIT_(c) isdigit(c)
|
||||||
#define _CONVERT_(c) c /*** FIXME ***/
|
#define _WIDE2SUPPORTED_(c) c /* FIXME: convert wide char to char */
|
||||||
|
#define _CHAR2SUPPORTED_(c) c /* No conversion needed (char to char) */
|
||||||
#define _CHAR2DIGIT_(c, base) char2digit((c), (base))
|
#define _CHAR2DIGIT_(c, base) char2digit((c), (base))
|
||||||
|
#define _BITMAPSIZE_ 256
|
||||||
#endif /* WIDE_SCANF */
|
#endif /* WIDE_SCANF */
|
||||||
|
|
||||||
#ifdef CONSOLE
|
#ifdef CONSOLE
|
||||||
|
@ -348,11 +352,7 @@ int _FUNCTION_ {
|
||||||
nch = _GETC_(file);
|
nch = _GETC_(file);
|
||||||
/* read until whitespace */
|
/* read until whitespace */
|
||||||
while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
|
while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
|
||||||
#ifdef WIDE_SCANF
|
if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch);
|
||||||
if (!suppress) *sptr++ = _CONVERT_(nch);
|
|
||||||
#else /* WIDE_SCANF */
|
|
||||||
if (!suppress) *sptr++ = nch;
|
|
||||||
#endif /* WIDE_SCANF */
|
|
||||||
st++;
|
st++;
|
||||||
nch = _GETC_(file);
|
nch = _GETC_(file);
|
||||||
if (width>0) width--;
|
if (width>0) width--;
|
||||||
|
@ -370,11 +370,7 @@ int _FUNCTION_ {
|
||||||
nch = _GETC_(file);
|
nch = _GETC_(file);
|
||||||
/* read until whitespace */
|
/* read until whitespace */
|
||||||
while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
|
while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
|
||||||
#ifdef WIDE_SCANF
|
if (!suppress) *sptr++ = _WIDE2SUPPORTED_(nch);
|
||||||
if (!suppress) *sptr++ = nch;
|
|
||||||
#else /* WIDE_SCANF */
|
|
||||||
if (!suppress) *sptr++ = _CONVERT_(nch);
|
|
||||||
#endif /* WIDE_SCANF */
|
|
||||||
st++;
|
st++;
|
||||||
nch = _GETC_(file);
|
nch = _GETC_(file);
|
||||||
if (width>0) width--;
|
if (width>0) width--;
|
||||||
|
@ -404,11 +400,7 @@ int _FUNCTION_ {
|
||||||
character: { /* read single character into char */
|
character: { /* read single character into char */
|
||||||
if (!suppress) {
|
if (!suppress) {
|
||||||
char*c = va_arg(ap, char*);
|
char*c = va_arg(ap, char*);
|
||||||
#ifdef WIDE_SCANF
|
*c = _CHAR2SUPPORTED_(nch);
|
||||||
*c = _CONVERT_(nch);
|
|
||||||
#else /* WIDE_SCANF */
|
|
||||||
*c = nch;
|
|
||||||
#endif /* WIDE_SCANF */
|
|
||||||
}
|
}
|
||||||
st = 1;
|
st = 1;
|
||||||
nch = _GETC_(file);
|
nch = _GETC_(file);
|
||||||
|
@ -417,11 +409,7 @@ int _FUNCTION_ {
|
||||||
widecharacter: {
|
widecharacter: {
|
||||||
if (!suppress) { /* read single character into a wchar_t */
|
if (!suppress) { /* read single character into a wchar_t */
|
||||||
MSVCRT_wchar_t*c = va_arg(ap, MSVCRT_wchar_t*);
|
MSVCRT_wchar_t*c = va_arg(ap, MSVCRT_wchar_t*);
|
||||||
#ifdef WIDE_SCANF
|
*c = _WIDE2SUPPORTED_(nch);
|
||||||
*c = nch;
|
|
||||||
#else /* WIDE_SCANF */
|
|
||||||
*c = _CONVERT_(nch);
|
|
||||||
#endif /* WIDE_SCANF */
|
|
||||||
}
|
}
|
||||||
nch = _GETC_(file);
|
nch = _GETC_(file);
|
||||||
st = 1;
|
st = 1;
|
||||||
|
@ -442,13 +430,8 @@ int _FUNCTION_ {
|
||||||
int invert = 0; /* Set if we are NOT to find the chars */
|
int invert = 0; /* Set if we are NOT to find the chars */
|
||||||
|
|
||||||
/* Init our bitmap */
|
/* Init our bitmap */
|
||||||
#ifdef WIDE_SCANF
|
Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, _BITMAPSIZE_/8);
|
||||||
Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 65536/8);
|
RtlInitializeBitMap(&bitMask, Mask, _BITMAPSIZE_);
|
||||||
RtlInitializeBitMap(&bitMask, Mask, 65536);
|
|
||||||
#else /* WIDE_SCANF */
|
|
||||||
Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 256/8);
|
|
||||||
RtlInitializeBitMap(&bitMask, Mask, 256);
|
|
||||||
#endif /* WIDE_SCANF */
|
|
||||||
|
|
||||||
/* Read the format */
|
/* Read the format */
|
||||||
format++;
|
format++;
|
||||||
|
@ -474,20 +457,12 @@ int _FUNCTION_ {
|
||||||
while ((width != 0) && (nch != _EOF_)) {
|
while ((width != 0) && (nch != _EOF_)) {
|
||||||
if(!invert) {
|
if(!invert) {
|
||||||
if(RtlAreBitsSet(&bitMask, nch, 1)) {
|
if(RtlAreBitsSet(&bitMask, nch, 1)) {
|
||||||
#ifdef WIDE_SCANF
|
if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch);
|
||||||
if (!suppress) *sptr++ = _CONVERT_(nch);
|
|
||||||
#else /* WIDE_SCANF */
|
|
||||||
if (!suppress) *sptr++ = nch;
|
|
||||||
#endif /* WIDE_SCANF */
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if(RtlAreBitsClear(&bitMask, nch, 1)) {
|
if(RtlAreBitsClear(&bitMask, nch, 1)) {
|
||||||
#ifdef WIDE_SCANF
|
if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch);
|
||||||
if (!suppress) *sptr++ = _CONVERT_(nch);
|
|
||||||
#else /* WIDE_SCANF */
|
|
||||||
if (!suppress) *sptr++ = nch;
|
|
||||||
#endif /* WIDE_SCANF */
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -543,8 +518,10 @@ int _FUNCTION_ {
|
||||||
#undef _EOF_RET
|
#undef _EOF_RET
|
||||||
#undef _ISSPACE_
|
#undef _ISSPACE_
|
||||||
#undef _ISDIGIT_
|
#undef _ISDIGIT_
|
||||||
#undef _CONVERT_
|
#undef _CHAR2SUPPORTED_
|
||||||
|
#undef _WIDE2SUPPORTED_
|
||||||
#undef _CHAR2DIGIT_
|
#undef _CHAR2DIGIT_
|
||||||
#undef _GETC_
|
#undef _GETC_
|
||||||
#undef _UNGETC_
|
#undef _UNGETC_
|
||||||
#undef _FUNCTION_
|
#undef _FUNCTION_
|
||||||
|
#undef _BITMAPSIZE_
|
||||||
|
|
Loading…
Reference in New Issue