mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Reimplement Qgets using Qgetc.
This commit is contained in:
parent
813e2010da
commit
341726afb9
1 changed files with 14 additions and 17 deletions
|
@ -386,25 +386,22 @@ Qputs (QFile *file, const char *buf)
|
||||||
VISIBLE char *
|
VISIBLE char *
|
||||||
Qgets (QFile *file, char *buf, int count)
|
Qgets (QFile *file, char *buf, int count)
|
||||||
{
|
{
|
||||||
char *ret = buf;
|
char *ret = buf;
|
||||||
|
char c;
|
||||||
|
|
||||||
if (file->c != -1) {
|
while (buf - ret < count - 1) {
|
||||||
*buf++ = file->c;
|
c = Qgetc (file);
|
||||||
count--;
|
if (c < 0)
|
||||||
file->c = -1;
|
break;
|
||||||
if (!count)
|
*buf++ = c;
|
||||||
return ret;
|
if (c == '\n')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (file->file)
|
if (buf == ret)
|
||||||
buf = fgets (buf, count, file->file);
|
|
||||||
else {
|
|
||||||
#ifdef HAVE_ZLIB
|
|
||||||
buf = gzgets (file->gzfile, buf, count);
|
|
||||||
#else
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
}
|
*buf++ = 0;
|
||||||
return buf ? ret : 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE int
|
VISIBLE int
|
||||||
|
@ -537,7 +534,7 @@ Qeof (QFile *file)
|
||||||
/*
|
/*
|
||||||
Qgetline
|
Qgetline
|
||||||
|
|
||||||
Dynamic length version of Qgets. DO NOT free the buffer.
|
Dynamic length version of Qgets. Do NOT free the buffer.
|
||||||
*/
|
*/
|
||||||
VISIBLE const char *
|
VISIBLE const char *
|
||||||
Qgetline (QFile *file)
|
Qgetline (QFile *file)
|
||||||
|
|
Loading…
Reference in a new issue