Re: improve scanf

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

 



Wrong place, I hope its all right now.

> Ooops, that patch has got an error in it, use this one instead.
>
>> ChangeLog:
>>  * dlls/msvcrt/scanf.c
>>  * dlls/msvcrt/scanf.h
>>    Implement [ format specifier.
>>
>> nog.


Index: dlls/msvcrt/scanf.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/scanf.c,v
retrieving revision 1.1
diff -u -r1.1 scanf.c
--- dlls/msvcrt/scanf.c	17 Aug 2002 01:22:00 -0000	1.1
+++ dlls/msvcrt/scanf.c	12 Oct 2002 17:04:57 -0000
@@ -24,6 +24,7 @@
  */
 
 #include "winbase.h"
+#include "winternl.h"
 #include "msvcrt.h"
 #include "msvcrt/conio.h"
 #include "msvcrt/io.h"
Index: dlls/msvcrt/scanf.h
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/scanf.h,v
retrieving revision 1.3
diff -u -r1.3 scanf.h
--- dlls/msvcrt/scanf.h	29 Sep 2002 18:00:23 -0000	1.3
+++ dlls/msvcrt/scanf.h	12 Oct 2002 17:05:01 -0000
@@ -442,6 +442,79 @@
 		    }
 	        }
 		break;
+	    case _L_('['): {
+#ifdef WIDE_SCANF
+                    WCHAR *str = suppress ? NULL : va_arg(ap, WCHAR*);
+                    WCHAR *sptr = str;
+#else /* WIDE_SCANF */
+                    char *str = suppress ? NULL : va_arg(ap, char*);
+                    char *sptr = str;
+#endif /* WIDE_SCANF */
+		    RTL_BITMAP bitMask;
+                    LPBYTE Mask;
+		    int invert = 0; /* Set if we are NOT to find the chars */
+
+		    /* Init our bitmap */
+#ifdef WIDE_SCANF
+		    Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+                                     sizeof(WCHAR) * 32);
+		    RtlInitializeBitMap(&bitMask, Mask, sizeof(WCHAR) * 256);
+#else /* WIDE_SCANF */
+		    Mask = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+                                     sizeof(char) * 32);
+		    RtlInitializeBitMap(&bitMask, Mask, sizeof(char) * 256);
+#endif /* WIDE_SCANF */
+
+		    /* Read the format */
+		    format++;
+		    if(*format == '^') {
+			invert = 1;
+			format++;
+		    }
+		    if(*format == ']') {
+			RtlSetBits(&bitMask, ']', 1);
+			format++;
+		    }
+                    while(*format && (*format != ']')) {
+			if((*format == '-') && (*(format + 1) != ']')) {
+			    int n = 0;
+			    for(;(n + *(format - 1)) < *(format + 1); n++)
+				RtlSetBits(&bitMask, n + *(format - 1), 1);
+			    format++;
+			}
+			RtlSetBits(&bitMask, *format, 1);
+			format++;
+		    }
+                    /* read until char is not suitable */
+                    while ((width != 0) && (nch != _EOF_)) {
+			if(!invert) {
+			    if(RtlAreBitsSet(&bitMask, nch, 1)) {
+#ifdef WIDE_SCANF
+				if (!suppress) *sptr++ = _CONVERT_(nch);
+#else /* WIDE_SCANF */
+				if (!suppress) *sptr++ = nch;
+#endif /* WIDE_SCANF */
+			    } else
+				break;
+			} else {
+			    if(RtlAreBitsClear(&bitMask, nch, 1)) {
+#ifdef WIDE_SCANF
+				if (!suppress) *sptr++ = _CONVERT_(nch);
+#else /* WIDE_SCANF */
+				if (!suppress) *sptr++ = nch;
+#endif /* WIDE_SCANF */
+			    } else
+				break;
+			}
+                        st++;
+                        nch = _GETC_(file);
+                        if (width>0) width--;
+                    }
+                    /* terminate */
+                    if (!suppress) *sptr = 0;
+		    HeapFree(GetProcessHeap(), 0, Mask);
+                }
+                break;
             default: FIXME("unhandled: %%%c\n", *format);
 		/* From spec: "if a percent sign is followed by a character
 		 * that has no meaning as a format-control character, that


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

  Powered by Linux