1
0
Fork 0

add field width to %s & coding style

This commit is contained in:
mfranz 2008-10-01 19:51:44 +00:00
parent d5877f3c5e
commit 5fd89049bb

View file

@ -315,15 +315,19 @@ var scanf = func(test, format, result) {
if (!size(scanstr) and prefix)
return 0;
append(result, sign * num(scanstr));
} elsif (f == `s`) {
while ((var c = str.getc()) != nil and (c != ` `)) {
fnum += 1;
while ((var c = str.getc()) != nil and c != ` ` and (fnum -= 1))
scanstr ~= chr(c);
}
if (c != nil)
str.ungetc();
if (!size(scanstr))
return 0;
append(result, scanstr);
} else {
die("scanf: bad format element %" ~ chr(f));
}
@ -344,3 +348,5 @@ var scanf = func(test, format, result) {
}
return str.getc() == nil and format.getc() == nil ? success : 0;
}