// frees buffer before tossing an error
static int getcguard(naContext ctx, FILE* f, void* buf)
{
- char c;
+ int c;
naModUnlock(); c = fgetc(f); naModLock();
if(ferror(f)) {
naFree(buf);
{
naRef result;
struct naIOGhost* g = argc==1 ? ioghost(args[0]) : 0;
- int i=0, sz = 128;
- char c, *buf;
+ int i=0, sz = 128, c, c2;
+ char *buf;
if(!g || g->type != &naStdIOType)
naRuntimeError(ctx, "bad argument to readln()");
buf = naAlloc(sz);
c = getcguard(ctx, g->handle, buf);
if(c == EOF || c == '\n') break;
if(c == '\r') {
- char c2 = getcguard(ctx, g->handle, buf);
+ c2 = getcguard(ctx, g->handle, buf);
if(c2 != EOF && c2 != '\n')
if(EOF == ungetc(c2, g->handle))
break;