Commit 7676d000 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Fix to scanf of a scanlist where no match occurs

In this situation, the conversion should fail.
Fixes ticket #252.

Version 5.76. Tagged as 'RISC_OSLib-5_76'
parent e1060d17
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.75"
Module_Version SETA 575
Module_MajorVersion SETS "5.76"
Module_Version SETA 576
Module_MinorVersion SETS ""
Module_Date SETS "15 Jan 2013"
Module_ApplicationDate SETS "15-Jan-13"
Module_Date SETS "20 Mar 2013"
Module_ApplicationDate SETS "20-Mar-13"
Module_ComponentName SETS "RISC_OSLib"
Module_ComponentPath SETS "castle/RiscOS/Sources/Lib/RISC_OSLib"
Module_FullVersion SETS "5.75"
Module_HelpVersion SETS "5.75 (15 Jan 2013)"
Module_FullVersion SETS "5.76"
Module_HelpVersion SETS "5.76 (20 Mar 2013)"
END
/* (5.75)
/* (5.76)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 5.75
#define Module_MajorVersion_CMHG 5.76
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 15 Jan 2013
#define Module_Date_CMHG 20 Mar 2013
#define Module_MajorVersion "5.75"
#define Module_Version 575
#define Module_MajorVersion "5.76"
#define Module_Version 576
#define Module_MinorVersion ""
#define Module_Date "15 Jan 2013"
#define Module_Date "20 Mar 2013"
#define Module_ApplicationDate "15-Jan-13"
#define Module_ApplicationDate "20-Mar-13"
#define Module_ComponentName "RISC_OSLib"
#define Module_ComponentPath "castle/RiscOS/Sources/Lib/RISC_OSLib"
#define Module_FullVersion "5.75"
#define Module_HelpVersion "5.75 (15 Jan 2013)"
#define Module_LibraryVersionInfo "5:75"
#define Module_FullVersion "5.76"
#define Module_HelpVersion "5.76 (20 Mar 2013)"
#define Module_LibraryVersionInfo "5:76"
......@@ -635,8 +635,8 @@ static long int rd_string(FILE *p, va_list res, int flag, int field)
return charcount;
}
/* Ambiguity in Oct 86 ANSI draft: can "%[x]" match a zero-length string? */
/* p119 line 19 suggests no, p121 example suggests yes. Treat as yes here */
/* Can "%[blah]" match a zero-length string? No */
/* ISO9899 7.19.6.2 Matches a nonempty sequence of characters */
static long int rd_string_map(FILE *p, va_list res, int flag, int field,
int charmap[])
{ long int charcount = -1; /* allow for always ungetc */
......@@ -644,12 +644,13 @@ static long int rd_string_map(FILE *p, va_list res, int flag, int field,
if (!(flag & NOSTORE)) s = va_arg(res, char *);
ch = countgetc(p);
if (ch == EOF) return CVTEOF;
while (field > 0 && ch != EOF && (charmap[ch/32] & (1<<(ch%32))) != 0)
while (field > 0 && ch != EOF && (charmap[ch/32] & (1uL<<(ch%32))) != 0)
{ field--;
if (!(flag & NOSTORE)) *s++ = ch;
ch = countgetc(p);
}
__backspace(p); /* OK if ch == EOF */
if (charcount == 0) return CVTFAIL;
if (!(flag & NOSTORE)) *s = 0;
return charcount;
}
......@@ -788,7 +789,7 @@ case '%': { int field = 0, flag = 0;
for (i=0; i<8; i++) charmap[i] = 0;
/* the 'do' next allows special treatment of %[]})] */
do { if (fch==0) return cnt; /* %[... unterminated */
charmap[fch/32] |= 1<<(fch%32);
charmap[fch/32] |= 1uL<<(fch%32);
} while ((fch = *fmt++) != ']');
if (negated) for (i=0; i<8; i++)
charmap[i] = ~charmap[i];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment