Lines Matching refs:lf

694   LoadF *lf = (LoadF *)ud;  in getF()  local
696 if (lf->n > 0) { /* are there pre-read characters to be read? */ in getF()
697 *size = lf->n; /* return them (chars already in buffer) */ in getF()
698 lf->n = 0; /* no more pre-read characters */ in getF()
704 if (feof(lf->f)) return NULL; in getF()
705 *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */ in getF()
707 return lf->buff; in getF()
720 static int skipBOM (LoadF *lf) { in skipBOM() argument
723 lf->n = 0; in skipBOM()
725 c = getc(lf->f); in skipBOM()
727 lf->buff[lf->n++] = c; /* to be read by the parser */ in skipBOM()
729 lf->n = 0; /* prefix matched; discard it */ in skipBOM()
730 return getc(lf->f); /* return next character */ in skipBOM()
741 static int skipcomment (LoadF *lf, int *cp) { in skipcomment() argument
742 int c = *cp = skipBOM(lf); in skipcomment()
745 c = getc(lf->f); in skipcomment()
747 *cp = getc(lf->f); /* skip end-of-line, if present */ in skipcomment()
756 LoadF lf; in luaL_loadfilex() local
762 lf.f = stdin; in luaL_loadfilex()
766 lf.f = fopen(filename, "r"); in luaL_loadfilex()
767 if (lf.f == NULL) return errfile(L, "open", fnameindex); in luaL_loadfilex()
769 if (skipcomment(&lf, &c)) /* read initial portion */ in luaL_loadfilex()
770 lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */ in luaL_loadfilex()
772 lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ in luaL_loadfilex()
773 if (lf.f == NULL) return errfile(L, "reopen", fnameindex); in luaL_loadfilex()
774 skipcomment(&lf, &c); /* re-read initial portion */ in luaL_loadfilex()
777 lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ in luaL_loadfilex()
778 status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); in luaL_loadfilex()
779 readstatus = ferror(lf.f); in luaL_loadfilex()
780 if (filename) fclose(lf.f); /* close file (even in case of errors) */ in luaL_loadfilex()