return 1;
}
-Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp )
+Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp, Int* lineno )
{
Char* buf = *bufpp;
SizeT nBuf = *nBufp;
while (True) {
n = get_char(fd, &ch);
if (n == 1 && !VG_(isspace)(ch)) break;
+ if (n == 1 && ch == '\n' && lineno)
+ (*lineno)++;
if (n <= 0) return True;
}
while (True) {
n = get_char(fd, &ch);
if (n <= 0) return False; /* the next call will return True */
+ if (ch == '\n' && lineno)
+ (*lineno)++;
if (ch == '\n') break;
if (i > 0 && i == nBuf-1) {
*nBufp = nBuf = nBuf * 2;
supp->string = supp->extra = NULL;
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof) break;
if (!VG_STREQ(buf, "{")) BOMB("expected '{' or end-of-file");
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof || VG_STREQ(buf, "}")) BOMB("unexpected '}'");
supp->sname = VG_(arena_strdup)(VG_AR_CORE, "errormgr.losf.2", buf);
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof) BOMB("unexpected end-of-file");
else {
// Ignore rest of suppression
while (True) {
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof) BOMB("unexpected end-of-file");
if (VG_STREQ(buf, "}"))
break;
/* the main frame-descriptor reading loop */
i = 0;
while (True) {
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
if (eof)
BOMB("unexpected end-of-file");
if (VG_STREQ(buf, "}")) {
// lines and grab the '}'.
if (!VG_STREQ(buf, "}")) {
do {
- eof = VG_(get_line) ( fd, &buf, &nBuf );
- lineno++;
+ eof = VG_(get_line) ( fd, &buf, &nBuf, &lineno );
} while (!eof && !VG_STREQ(buf, "}"));
}
pointer to size_t holding its size; if the buffer is too small for the
line, it will be realloc'd until big enough (updating *bufpp and *nBufp in
the process). (It will bomb out if the size gets ridiculous). Skips
- leading spaces on the line. Returns True if EOF was hit instead. */
-extern Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp );
+ leading spaces on the line. Increments lineno with the number of lines
+ read if lineno is non-NULL. Returns True if EOF was hit. */
+extern Bool VG_(get_line) ( Int fd, Char** bufpp, SizeT* nBufp, Int* lineno );
/* ------------------------------------------------------------------ */