remove whitespace at beginning of sscanf, fixes #512
This commit is contained in:
Родитель
f1d11329a4
Коммит
d8f3b43e24
|
@ -2282,6 +2282,14 @@ LibraryManager.library = {
|
|||
var fields = 0;
|
||||
var argIndex = 0;
|
||||
var next;
|
||||
// remove initial whitespace
|
||||
while (1) {
|
||||
next = get();
|
||||
if (next == 0) return 0;
|
||||
if (!(next in __scanString.whiteSpace)) break;
|
||||
}
|
||||
unget();
|
||||
next = 1;
|
||||
for (var formatIndex = 0; formatIndex < format.length; formatIndex++) {
|
||||
if (next <= 0) return fields;
|
||||
var next = get();
|
||||
|
|
|
@ -3970,6 +3970,10 @@ at function.:blag
|
|||
|
||||
printf("%f, %f\n", atof("1.234567"), atof("cheez"));
|
||||
|
||||
float n = -1;
|
||||
sscanf(" 2.8208", "%f", &n);
|
||||
printf("%.4f\n", n);
|
||||
|
||||
float a = -1;
|
||||
sscanf("-3.03", "%f", &a);
|
||||
printf("%.4f\n", a);
|
||||
|
@ -3999,7 +4003,7 @@ at function.:blag
|
|||
return 0;
|
||||
}
|
||||
'''
|
||||
self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n-3.0300\n|some|\n|something|\n|somethingmoar|\n' +
|
||||
self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n2.8208\n-3.0300\n|some|\n|something|\n|somethingmoar|\n' +
|
||||
'1\n1499\n' +
|
||||
'5\n87,0.481565,0.059481,0,1\n' +
|
||||
'3\n-123,4294966531,-34\n')
|
||||
|
|
Загрузка…
Ссылка в новой задаче