On 19/09/2025 10:07, Sven Schreiber wrote:
Hi,
maybe I'm not literate enough with the sscanf function, but the
following example is giving a result which I did not expect. Is it a
bug, maybe triggered by the included comma?
<hansl>
string hey = "aha oho, uhu"
string s
sscanf(hey, "aha %s", s) # expected: "oho, uhu"
print s # gives "oho,"
</hansl>
This is a recent snapshot, but I guess if it's really a bug, then it's
not new.
This function is really borrowed from the standard C library. From its
man page:
s Matches a sequence of non-white-space characters; the next
pointer must be a pointer to the initial element of a character
array that is long enough to hold the input sequence and the ter‐
minating null byte ('\0'), which is added automatically. The in‐
put string stops at white space or at the maximum field width,
whichever occurs first.
so the space effectively end the string that the function catches. I
guess (haven't tested) that in C you could use "%[a-z, ]" do do what you
want, but it appears we have a bug that prevents this from working
properly in hansl.
@Allin: it seems that for some reason n at line 1069 in
lib/src/printscan.c is set at 0, but this is as far as I'm able to go
this morning.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------