Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Oh, I've seen copies [of Linux Journal] around the terminal room at The Labs. -- Dennis Ritchie


devel / comp.os.ms-windows.programmer.win32 / Re: fscanf formatting oddity & question

SubjectAuthor
* fscanf formatting oddity & questionR.Wieser
+- fscanf formatting oddity & questionR.Wieser
`* fscanf formatting oddity & questionPaul N
 `- fscanf formatting oddity & questionR.Wieser

1
fscanf formatting oddity & question

<t8fg7e$n70$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1072&group=comp.os.ms-windows.programmer.win32#1072

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!aioe.org!XakcSTEO51npqVb7OVl71w.user.46.165.242.75.POSTED!not-for-mail
From: address@not.available (R.Wieser)
Newsgroups: comp.os.ms-windows.programmer.win32
Subject: fscanf formatting oddity & question
Date: Thu, 16 Jun 2022 16:54:28 +0200
Organization: Aioe.org NNTP Server
Lines: 25
Message-ID: <t8fg7e$n70$1@gioia.aioe.org>
Injection-Info: gioia.aioe.org; logging-data="23776"; posting-host="XakcSTEO51npqVb7OVl71w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MSMail-Priority: Normal
X-Priority: 3
 by: R.Wieser - Thu, 16 Jun 2022 14:54 UTC

Hello all,

I'm trying to use fscanf to read a certain string, using this formatting :

" someid=%u%[;]c"

The latter part, "%[;]c" is a trick to detect if the whole string is read :
Only if the ";" is encountered the result of fscanf equals 2 (can't use
"%n", as that doesn't up the result count).

The thing is that I actually took a look at what got stored, and found that
instead of a single byte, 0x3B, *two* where stored, 0x003B. When I remove
the "[;]" it goes back to storing a just single byte.

Can somebody explain to my why the extra 0x00 happens (what the reason for
it is) ?

Second question : Is there some way I can tell fscanf that it should match
upto the terminating zero (so I can do away with the "%[;]c" cludge
altogether) ?

Regards,
Rudy Wieser

Re: fscanf formatting oddity & question

<t8fhse$1g0s$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1073&group=comp.os.ms-windows.programmer.win32#1073

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!aioe.org!XakcSTEO51npqVb7OVl71w.user.46.165.242.75.POSTED!not-for-mail
From: address@not.available (R.Wieser)
Newsgroups: comp.os.ms-windows.programmer.win32
Subject: Re: fscanf formatting oddity & question
Date: Thu, 16 Jun 2022 17:22:45 +0200
Organization: Aioe.org NNTP Server
Lines: 21
Message-ID: <t8fhse$1g0s$1@gioia.aioe.org>
References: <t8fg7e$n70$1@gioia.aioe.org>
Injection-Info: gioia.aioe.org; logging-data="49180"; posting-host="XakcSTEO51npqVb7OVl71w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-Priority: 3
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Response
X-MSMail-Priority: Normal
 by: R.Wieser - Thu, 16 Jun 2022 15:22 UTC

Hmmm ...

> The latter part, "%[;]c" is a trick to detect if the whole string is read

Hmmm ... It seems I misunderstood what the "[","]" brackets are for, and
from it I see that in the above the "c" isn't regarded as a formatting
specifier. It also explains the 'extra' "0x00" in the result.

And as a result the above needs to be changed to "%1[;]".

The second part of my question still stands though, as I would gladly do
away with the the whole trick (of sorts).

... remarkable how answers always seem to pop up /after/ the question about
them is submitted. :-)

Regards,
Rudy Wieser

Re: fscanf formatting oddity & question

<b75d307a-5205-4744-9e08-3af73da30d59n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1074&group=comp.os.ms-windows.programmer.win32#1074

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
X-Received: by 2002:a5d:5234:0:b0:21b:829c:3058 with SMTP id i20-20020a5d5234000000b0021b829c3058mr6491768wra.13.1655581215157;
Sat, 18 Jun 2022 12:40:15 -0700 (PDT)
X-Received: by 2002:a05:620a:bcd:b0:6ab:84b8:25ee with SMTP id
s13-20020a05620a0bcd00b006ab84b825eemr9101120qki.512.1655581214690; Sat, 18
Jun 2022 12:40:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.87.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.os.ms-windows.programmer.win32
Date: Sat, 18 Jun 2022 12:40:14 -0700 (PDT)
In-Reply-To: <t8fg7e$n70$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=89.240.148.226; posting-account=0B-afgoAAABP6274zLUJKa8ZpdIdhsYx
NNTP-Posting-Host: 89.240.148.226
References: <t8fg7e$n70$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b75d307a-5205-4744-9e08-3af73da30d59n@googlegroups.com>
Subject: Re: fscanf formatting oddity & question
From: gw7rib@aol.com (Paul N)
Injection-Date: Sat, 18 Jun 2022 19:40:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Paul N - Sat, 18 Jun 2022 19:40 UTC

On Thursday, June 16, 2022 at 3:54:41 PM UTC+1, R.Wieser wrote:
> Hello all,
>
> I'm trying to use fscanf to read a certain string, using this formatting :
>
> " someid=%u%[;]c"
>
> The latter part, "%[;]c" is a trick to detect if the whole string is read :
> Only if the ";" is encountered the result of fscanf equals 2 (can't use
> "%n", as that doesn't up the result count).

(snip)

> Second question : Is there some way I can tell fscanf that it should match
> upto the terminating zero (so I can do away with the "%[;]c" cludge
> altogether) ?

If you're using fscanf there presumably isn't a terminating zero, you will be looking at '\n' or EOF or the like. I think it is recommended not to use fscanf, rather to read in a line and process it using sscanf, which gives more control. Of course whether this is worthwhile will depend on the details, eg whether you want to simply ignore and/or complain about badly formed lines, or whether you want to abort the whole reading.

Re: fscanf formatting oddity & question

<t8mlvh$b77$1@gioia.aioe.org>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=1076&group=comp.os.ms-windows.programmer.win32#1076

  copy link   Newsgroups: comp.os.ms-windows.programmer.win32
Path: i2pn2.org!i2pn.org!aioe.org!XakcSTEO51npqVb7OVl71w.user.46.165.242.75.POSTED!not-for-mail
From: address@not.available (R.Wieser)
Newsgroups: comp.os.ms-windows.programmer.win32
Subject: Re: fscanf formatting oddity & question
Date: Sun, 19 Jun 2022 10:15:30 +0200
Organization: Aioe.org NNTP Server
Lines: 31
Message-ID: <t8mlvh$b77$1@gioia.aioe.org>
References: <t8fg7e$n70$1@gioia.aioe.org> <b75d307a-5205-4744-9e08-3af73da30d59n@googlegroups.com>
Injection-Info: gioia.aioe.org; logging-data="11495"; posting-host="XakcSTEO51npqVb7OVl71w.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-Notice: Filtered by postfilter v. 0.9.2
X-RFC2646: Format=Flowed; Original
X-Priority: 3
X-MSMail-Priority: Normal
 by: R.Wieser - Sun, 19 Jun 2022 08:15 UTC

Paul,

> If you're using fscanf there presumably isn't a terminating zero,

The terminating zero was ment in regard to the formatting string.

The problem is that (f|s)scanf will simply ignore any part it cannot match
to the provided format string. And in my case that just doesn't work.

> Of course whether this is worthwhile will depend on the details, eg
> whether you
> want to simply ignore and/or complain about badly formed lines, or whether
> you
> want to abort the whole reading.

I have not considered trying to find the end of a badly-formatted (part of
a) line so I can continue reading the next string. So, aborting - or
rather terminating the scanning for more strings - on a "badly-formatted"
line it is.

I'm already considering a (better) way to check if I have an unrecognised
formatting string, or if the target is actually badly formatted.

It doesn't change anything to the question though - can I tell (f|s)scanf to
force a full matching of the formatting string (upto its terminating zero) ?
Other than the kludges I've mentioned I mean.

Regards,
Rudy Wieser

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor