msvcrt: Use BOOL type where appropriate

Frédéric Delanoy frederic.delanoy at gmail.com
Tue Jan 7 20:37:53 CST 2014


---
 dlls/msvcrt/mbcs.c   |  8 ++++----
 dlls/msvcrt/msvcrt.h |  2 +-
 dlls/msvcrt/scanf.h  | 50 ++++++++++++++++++++++++--------------------------
 3 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c
index b25649b6..8ad5c39 100644
--- a/dlls/msvcrt/mbcs.c
+++ b/dlls/msvcrt/mbcs.c
@@ -275,7 +275,7 @@ int _setmbcp_l(int cp, LCID lcid, MSVCRT_pthreadmbcinfo mbcinfo)
     /* trail bytes not available through kernel32 but stored in a structure in msvcrt */
     struct cp_extra_info_t *cpextra = g_cpextrainfo;
 
-    mbcinfo->ismbcodepage = 1;
+    mbcinfo->ismbcodepage = TRUE;
     while (TRUE)
     {
       if (cpextra->cp == 0 || cpextra->cp == newcp)
@@ -296,7 +296,7 @@ int _setmbcp_l(int cp, LCID lcid, MSVCRT_pthreadmbcinfo mbcinfo)
     }
   }
   else
-    mbcinfo->ismbcodepage = 0;
+    mbcinfo->ismbcodepage = FALSE;
 
   /* we can't use GetStringTypeA directly because we don't have a locale - only a code page
    */
@@ -657,7 +657,7 @@ int CDECL _mbsnbcpy_s(unsigned char* dst, MSVCRT_size_t size, const unsigned cha
 
     if(get_mbcinfo()->ismbcodepage)
     {
-        int is_lead = 0;
+        BOOL is_lead = FALSE;
         while (*src && n)
         {
             if(pos == size)
@@ -713,7 +713,7 @@ unsigned char* CDECL _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSV
     return dst;
   if(get_mbcinfo()->ismbcodepage)
   {
-    int is_lead = 0;
+    BOOL is_lead = FALSE;
     while (*src && n)
     {
       is_lead = (!is_lead && _ismbblead(*src));
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 4e41a7d..896203f 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -165,7 +165,7 @@ typedef struct MSVCRT_threadlocaleinfostruct {
 typedef struct MSVCRT_threadmbcinfostruct {
     int refcount;
     int mbcodepage;
-    int ismbcodepage;
+    BOOL ismbcodepage;
     int mblcid;
     unsigned short mbulinfo[6];
     unsigned char mbctype[257];
diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h
index 7f618f4..08edb64 100644
--- a/dlls/msvcrt/scanf.h
+++ b/dlls/msvcrt/scanf.h
@@ -174,20 +174,18 @@ _FUNCTION_ {
 	 * to an argument in the argument list.  Format specifications have
 	 * the form %[*][width][{h | l | I64 | L}]type */
         else if (*format == '%') {
-            int st = 0; int suppress = 0; int width = 0;
+            int st = 0, width = 0;
+            BOOL suppress = FALSE;
 	    int base;
 	    int h_prefix = 0;
-	    int l_prefix = 0;
-	    int L_prefix = 0;
-	    int w_prefix = 0;
-	    int prefix_finished = 0;
-	    int I64_prefix = 0;
+            BOOL l_prefix = FALSE, L_prefix = FALSE, w_prefix = FALSE;
+            BOOL prefix_finished = FALSE, I64_prefix = FALSE;
             format++;
 	    /* look for leading asterisk, which means 'suppress assignment of
 	     * this field'. */
 	    if (*format=='*') {
 		format++;
-		suppress=1;
+                suppress = TRUE;
 	    }
 	    /* look for width specification */
 	    while (_ISDIGIT_(*format)) {
@@ -201,22 +199,22 @@ _FUNCTION_ {
 		case 'h': h_prefix++; break;
 		case 'l':
                     if(*(format+1) == 'l') {
-                        I64_prefix = 1;
+                        I64_prefix = TRUE;
                         format++;
                     }
-                    l_prefix = 1;
+                    l_prefix = TRUE;
                     break;
-		case 'w': w_prefix = 1; break;
-		case 'L': L_prefix = 1; break;
+                case 'w': w_prefix = TRUE; break;
+                case 'L': L_prefix = TRUE; break;
 		case 'I':
 		    if (*(format + 1) == '6' &&
 			*(format + 2) == '4') {
-			I64_prefix = 1;
+                        I64_prefix = TRUE;
 			format += 2;
 		    }
 		    break;
 		default:
-		    prefix_finished = 1;
+                    prefix_finished = TRUE;
 		}
 		if (!prefix_finished) format++;
 	    }
@@ -224,7 +222,7 @@ _FUNCTION_ {
             switch(*format) {
 	    case 'p':
 	    case 'P': /* pointer. */
-                if (sizeof(void *) == sizeof(LONGLONG)) I64_prefix = 1;
+                if (sizeof(void *) == sizeof(LONGLONG)) I64_prefix = TRUE;
                 /* fall through */
 	    case 'x':
 	    case 'X': /* hexadecimal integer. */
@@ -244,8 +242,7 @@ _FUNCTION_ {
 	    number: {
 		    /* read an integer */
 		    ULONGLONG cur = 0;
-		    int negative = 0;
-		    int seendigit=0;
+                    BOOL negative = FALSE, seendigit = FALSE;
                     /* skip initial whitespace */
                     while ((nch!=_EOF_) && _ISSPACE_(nch))
                         nch = _GETC_(file);
@@ -259,14 +256,14 @@ _FUNCTION_ {
 		    if (width!=0 && nch == '0' && *format != 'p' && *format != 'P') {
                         nch = _GETC_(file);
 			if (width>0) width--;
-			seendigit=1;
+                        seendigit = TRUE;
 			if (width!=0 && (nch=='x' || nch=='X')) {
 			    if (base==0)
 				base=16;
 			    if (base==16) {
 				nch = _GETC_(file);
 				if (width>0) width--;
-				seendigit=0;
+                                seendigit = FALSE;
 			    }
 			} else if (base==0)
 			    base = 8;
@@ -278,20 +275,20 @@ _FUNCTION_ {
 		    while (width!=0 && nch=='0') {
                         nch = _GETC_(file);
 			if (width>0) width--;
-			seendigit=1;
+                        seendigit = TRUE;
 		    }
 		    if (width!=0 && _CHAR2DIGIT_(nch, base)!=-1) {
 			cur = _CHAR2DIGIT_(nch, base);
 			nch = _GETC_(file);
 			if (width>0) width--;
-			seendigit=1;
+                        seendigit = TRUE;
 		    }
                     /* read until no more digits */
                     while (width!=0 && (nch!=_EOF_) && _CHAR2DIGIT_(nch, base)!=-1) {
                         cur = cur*base + _CHAR2DIGIT_(nch, base);
                         nch = _GETC_(file);
 			if (width>0) width--;
-			seendigit=1;
+                        seendigit = TRUE;
                     }
 		    /* okay, done! */
 		    if (!seendigit) break; /* not a valid number */
@@ -312,7 +309,8 @@ _FUNCTION_ {
             case 'G': { /* read a float */
                     long double cur = 1, expcnt = 10;
                     ULONGLONG d, hlp;
-                    int exp = 0, negative = 0;
+                    int exp = 0;
+                    BOOL negative = FALSE;
                     unsigned fpcontrol;
                     BOOL negexp;
 
@@ -597,7 +595,7 @@ _FUNCTION_ {
 		     * looking at expects the behavior I've coded here
 		     * (which happens to be what glibc does as well).
 		     */
-		    suppress = 1;
+                    suppress = TRUE;
 		    st = 1;
 	        }
 		break;
@@ -606,7 +604,7 @@ _FUNCTION_ {
                     _CHAR_ *sptr = str;
 		    RTL_BITMAP bitMask;
                     ULONG *Mask;
-		    int invert = 0; /* Set if we are NOT to find the chars */
+                    BOOL invert = FALSE; /* Set if we are NOT to find the chars */
 #ifdef SECURE
                     unsigned size = suppress ? UINT_MAX : va_arg(ap, unsigned)/sizeof(_CHAR_);
 #else
@@ -620,7 +618,7 @@ _FUNCTION_ {
 		    /* Read the format */
 		    format++;
 		    if(*format == '^') {
-			invert = 1;
+                        invert = TRUE;
 			format++;
 		    }
 		    if(*format == ']') {
@@ -679,7 +677,7 @@ _FUNCTION_ {
                 while ((nch!=_EOF_) && _ISSPACE_(nch))
                     nch = _GETC_(file);
                 if (nch==*format) {
-                    suppress = 1; /* whoops no field to be read */
+                    suppress = TRUE; /* whoops no field to be read */
                     st = 1; /* but we got what we expected */
                     nch = _GETC_(file);
                 }
-- 
1.8.5.2




More information about the wine-patches mailing list