Lines Matching refs:lf
643 LoadF *lf = (LoadF *)ud;
645 if (lf->n > 0) { /* are there pre-read characters to be read? */
646 *size = lf->n; /* return them (chars already in buffer) */
647 lf->n = 0; /* no more pre-read characters */
653 if (feof(lf->f)) return NULL;
654 *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */
656 return lf->buff;
669 static int skipBOM (LoadF *lf) {
672 lf->n = 0;
674 c = getc(lf->f);
676 lf->buff[lf->n++] = c; /* to be read by the parser */
678 lf->n = 0; /* prefix matched; discard it */
679 return getc(lf->f); /* return next character */
690 static int skipcomment (LoadF *lf, int *cp) {
691 int c = *cp = skipBOM(lf);
694 c = getc(lf->f);
696 *cp = getc(lf->f); /* skip end-of-line, if present */
705 LoadF lf;
711 lf.f = stdin;
715 lf.f = fopen(filename, "r");
716 if (lf.f == NULL) return errfile(L, "open", fnameindex);
718 if (skipcomment(&lf, &c)) /* read initial portion */
719 lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */
721 lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
722 if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
723 skipcomment(&lf, &c); /* re-read initial portion */
726 lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */
727 status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode);
728 readstatus = ferror(lf.f);
729 if (filename) fclose(lf.f); /* close file (even in case of errors) */