From 20131e54d3631b0c3ce493b71b38f32245408974 Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 12 Jul 2005 11:32:48 -0300
Subject: no more "getc" when testing if file exists

---
 lauxlib.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/lauxlib.c b/lauxlib.c
index 07f2eba6..ace7df42 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.c,v 1.138 2005/07/11 14:01:28 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.139 2005/07/11 16:41:51 roberto Exp roberto $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -354,13 +354,10 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
 
 
 static int readable (const char *fname) {
-  int err;
   FILE *f = fopen(fname, "r");  /* try to open file */
   if (f == NULL) return 0;  /* open failed */
-  getc(f);  /* try to read it */
-  err = ferror(f);
   fclose(f);
-  return (err == 0);
+  return 1;
 }
 
 
@@ -369,11 +366,8 @@ LUALIB_API const char *luaL_searchpath (lua_State *L, const char *name,
   const char *p = path;
   for (;;) {
     const char *fname;
-    if ((p = pushnexttemplate(L, p)) == NULL) {
-      lua_pushfstring(L, "no readable " LUA_QS " in path " LUA_QS "",
-                         name, path);
+    if ((p = pushnexttemplate(L, p)) == NULL)
       return NULL;
-    }
     fname = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
     lua_remove(L, -2);  /* remove path template */
     if (readable(fname))  /* does file exist and is readable? */
-- 
cgit v1.2.3-55-g6feb