3rd patch to fix locale behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Here is my third attempt to fix some locale functions, I hope this is 
the last ;-).

Alexandre, I have fixed strncpy() I'm doing now exactly as Windows (see
locale test)

Mehmet


diff -u /home/mehmet/CVS/wine/ole/ole2nls.c ole/ole2nls.c
--- /home/mehmet/CVS/wine/ole/ole2nls.c	Sun Apr 28 15:42:21 2002
+++ ole/ole2nls.c	Fri May 24 13:35:39 2002
@@ -574,8 +574,9 @@
     }
     /* if len=0 return only the length, don't touch the buffer*/
     if (len) {
-	lstrcpynA(buf,retString,len);
-	return strlen(buf) + 1;
+	/* Like Windows we copy len bytes to buffer and we check len after */
+	strncpy(buf, retString, min(len, strlen(retString)+1));
+	return (len < strlen(retString) + 1)? 0 : strlen(retString)+1;
     }
     return strlen(retString)+1;
 }
@@ -3275,9 +3276,8 @@
         retVal = strlen(sDestination) + 1;
     else           
     {
-        strncpy (lpNumberStr, sDestination, cchNumber-1);
-        *(lpNumberStr+cchNumber-1) = '\0';   /* ensure we got a NULL at the end */
-        retVal = strlen(lpNumberStr);
+        strncpy (lpNumberStr, sDestination, min(cchNumber, strlen(sDestination)+1));
+	retVal = cchNumber < (strlen(sDestination)+1) ? 0: strlen(sDestination)+1;
     }
           
     return retVal;
@@ -3531,9 +3531,8 @@
 
     else
     {
-        strncpy (lpCurrencyStr, pDestination, cchCurrency-1);
-        *(lpCurrencyStr+cchCurrency-1) = '\0';   /* ensure we got a NULL at the end */
-        return  strlen(lpCurrencyStr);
+        strncpy (lpCurrencyStr, pDestination, min(cchCurrency, strlen(pDestination)+1));
+	return (cchCurrency < (strlen(pDestination)+1) ? 0: strlen(pDestination)+1);
     }    
 }
 


Attachment: locale.zip
Description: Binary data


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux