delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/11/16/14:38:18

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
From: <ams AT ludd DOT luth DOT se>
Message-Id: <200311161909.hAGJ9bqY004445@speedy.ludd.luth.se>
Subject: Re: Problems with sscanf & suppressions [PATCH]
In-Reply-To: <E1AIyEJ-0000ka-00@phekda.freeserve.co.uk> "from Richard Dawe at
Nov 9, 2003 10:51:54 pm"
To: djgpp-workers AT delorie DOT com
Date: Sun, 16 Nov 2003 20:09:37 +0100 (CET)
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
X-MailScanner: Found to be clean
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

According to Richard Dawe:
> --- /dev/null	2003-11-09 22:46:33.000000000 +0000
> +++ tests/libc/ansi/stdio/sscanf3.c	2003-11-09 22:45:12.000000000 +0000
> @@ -0,0 +1,92 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +
> +typedef struct {
> +  const char *input;
> +  const char *fmt;
> +
> +  const int expected;
> +  const char expected_c[2];
> +  const char expected_c2[2];
> +
> +  char c[2];
> +  char c2[2];
> +} sscanf_testcase_t;
> +
> +sscanf_testcase_t sscanf_testcases[] = {
> +  /* No assignment */
> +  { "", "%*[0123456789]%*c", EOF, "", "" },
> +  { "X", "%*[0123456789]%*c", 0, "", "" },
> +  { "1", "%*[0123456789]%*c", EOF, "", "" },
> +  { "1X2", "%*[0123456789]%*[0123456789]", 1, "", "" },
> +  { "1,2", "%*[0123456789],%*[0123456789]", 2, "", "" },

If I'm not mistaken the last two lines are coded to check that
sscanf() returns 1 and 2. That's wrong. There were no
assignments. Thus sscanf() should return 0. 

> +
> +  /* Assign first */
> +  { "", "%[0123456789]%*c", EOF, "", "" },
> +  { "X", "%[0123456789]%*c", 0, "", "" },
> +  { "1", "%[0123456789]%*c", EOF, "1", "" },
> +  { "1X2", "%[0123456789]%*[0123456789]", 1, "1", "" },
> +  { "1,2", "%[0123456789],%*[0123456789]", 2, "1", "" },

Similarly, last line should have 1 as result.

> +
> +  /* Assign second */
> +  { "", "%*[0123456789]%c", EOF, "", "" },
> +  { "X", "%*[0123456789]%c", 0, "", "" },
> +  { "1", "%*[0123456789]%c", EOF, "", "" },
> +  { "1X2", "%*[0123456789]%[0123456789]", 1, "", "" },
> +  { "1,2", "%*[0123456789],%[0123456789]", 2, "2", "" },

Here the results of the last two lines should be 0 and 1.

> +
> +  /* Assign both */
> +  { "", "%[0123456789]%c", EOF, "", "" },
> +  { "X", "%[0123456789]%c", 0, "", "" },
> +  { "1", "%[0123456789]%c", EOF, "1", "" },
> +  { "1X2", "%[0123456789]%[0123456789]", 1, "1", "" },
> +  { "1,2", "%[0123456789],%[0123456789]", 2, "1", "2" },

This one is correct.


Anyway, thanks for trying. Keep up the good work!


Right,

						MartinS

- Raw text -


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