delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/04/01/06:48:58

Date: Mon, 1 Apr 1996 15:47:06 +0400 (MSD)
From: "Alexander V. Lukyanov" <lav AT video DOT yars DOT free DOT net>
Message-Id: <199604011147.PAA25741@video.yars.free.net>
To: djgpp-workers AT delorie DOT com
Subject: scanf fix #2

... and this patch should fix another bug which caused scanf family
to ignore errors in fields parsing. Excuse me for two separate patches :-)

--- doscan.c~~	Mon Apr  1 14:49:48 1996
+++ doscan.c	Mon Apr  1 15:19:38 1996
@@ -103,12 +103,17 @@
     if (ch == '\0')
       return(-1);
     if (_innum(ptr, ch, len, size, iop, scan_getc, scan_ungetc,
-	       &fileended) && ptr)
-      nmatch++;
-/* breaks %n */
-/*    if (fileended) {
-      return(nmatch? nmatch: -1);
-    } */
+	       &fileended))
+    {
+      if (ptr)
+        nmatch++;
+    }
+    else
+    {
+      if (fileended && nmatch==0)
+        return(-1);
+      return(nmatch);
+    }
     break;
   case ' ':
   case '\n':

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019