diff options
-rw-r--r-- | lauxlib.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.184 2009/02/27 18:18:19 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.185 2009/03/31 17:25:08 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -496,6 +496,9 @@ static const char *getF (lua_State *L, void *ud, size_t *size) { | |||
496 | *size = 1; | 496 | *size = 1; |
497 | return "\n"; | 497 | return "\n"; |
498 | } | 498 | } |
499 | /* 'fread' can return > 0 *and* set the EOF flag. If next call to | ||
500 | 'getF' calls 'fread', terminal may still wait for user input. | ||
501 | The next check avoids this problem. */ | ||
499 | if (feof(lf->f)) return NULL; | 502 | if (feof(lf->f)) return NULL; |
500 | *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); | 503 | *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); |
501 | return (*size > 0) ? lf->buff : NULL; | 504 | return (*size > 0) ? lf->buff : NULL; |