msvcrt/wcs.c: Honor precision argument for strings

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Fri Feb 25 10:26:52 CST 2005


Changelog:
	wine/dlls/msvcrt/wcs.c: pf_output_format_X()
	Honor precision argument (plus test case)
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/msvcrt/wcs.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/wcs.c,v
retrieving revision 1.19
diff -u -w -r1.19 wcs.c
--- wine/dlls/msvcrt/wcs.c	14 Feb 2005 20:53:42 -0000	1.19
+++ wine/dlls/msvcrt/wcs.c	25 Feb 2005 16:22:59 -0000
@@ -309,6 +309,9 @@
     if( len < 0 )
         len = strlenW( str );
 
+    if (flags->Precision && flags->Precision < len)
+      len = flags->Precision;
+
     r = pf_fill( out, len, flags, 1 );
 
     if( r>=0 )
@@ -328,6 +331,9 @@
     if( len < 0 )
         len = strlen( str );
 
+    if (flags->Precision && flags->Precision < len)
+      len = flags->Precision;
+
     r = pf_fill( out, len, flags, 1 );
 
     if( r>=0 )
Index: wine/dlls/msvcrt/tests/printf.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/tests/printf.c,v
retrieving revision 1.3
diff -u -w -r1.3 printf.c
--- wine/dlls/msvcrt/tests/printf.c	14 Feb 2005 20:53:42 -0000	1.3
+++ wine/dlls/msvcrt/tests/printf.c	25 Feb 2005 16:25:39 -0000
@@ -76,6 +76,16 @@
     ok(!strcmp(buffer,"0foo"),"String not zero-prefixed \"%s\"\n",buffer);
     ok( r==4, "return count wrong\n");
 
+    format = "%.1s";
+    r = sprintf(buffer,format,"foo");
+    ok(!strcmp(buffer,"f"),"Precision ignored \"%s\"\n",buffer);
+    ok( r==1, "return count wrong\n");
+
+    format = "%.*s";
+    r = sprintf(buffer,format,1,"foo");
+    ok(!strcmp(buffer,"f"),"Precision ignored \"%s\"\n",buffer);
+    ok( r==1, "return count wrong\n");
+
     format = "%#-012p";
     r = sprintf(buffer,format,(void *)57);
     ok(!strcmp(buffer,"0X00000039  "),"Pointer formatted incorrectly\n");



More information about the wine-patches mailing list