fclose(fp);
}
-void fpclose1(FILE *fp, int is_pipe) {
- if (is_pipe)
- pclose(fp);
+void fpclose1(lkfile_t *fp) {
+ if (fp->pipe)
+ pclose(fp->fd);
else
- fclose(fp);
+ fclose(fp->fd);
}
#define SIZE(a) (sizeof(a)/sizeof(a[0]))
typedef struct lkfile {
FILE *fd;
int pipe;
-} lkfile_y;
+} lkfile_t;
extern char pathname[];
extern int ispipe;
extern void fpclose(FILE *fp);
-extern void fpclose1(FILE *fp, int pipe);
-//extern void fpclose1(lkfile_t *fp);
+extern void fpclose1(lkfile_t *fp);
extern FILE *findfile(char *fnam, char **dirpath, char **suffixes);
#endif /* _FINDFILE_H */
/* Include file handling - unfortunately flex-specific. */
#define MAX_INCLUDE_DEPTH 20
static struct infile {
- FILE *fd;
+ lkfile_t fp;
char *filename;
- int pipe;
int linenr;
YY_BUFFER_STATE buffer;
} infile_stack[MAX_INCLUDE_DEPTH];
infile_stack_ptr++;
infile_stack[infile_stack_ptr].buffer = yy_create_buffer(fd, YY_BUF_SIZE);
- infile_stack[infile_stack_ptr].fd = fd;
- infile_stack[infile_stack_ptr].pipe = is_pipe;
+ infile_stack[infile_stack_ptr].fp.fd = fd;
+ infile_stack[infile_stack_ptr].fp.pipe = is_pipe;
infile_stack[infile_stack_ptr].filename = strdup(fname);
infile_stack[infile_stack_ptr].linenr = line_nr;
}
static int stack_pop(void) {
- fpclose1(infile_stack[infile_stack_ptr].fd, infile_stack[infile_stack_ptr].pipe);
+ fpclose1(&infile_stack[infile_stack_ptr].fp);
// Free previous filename
xfree(infile_stack[infile_stack_ptr].filename);
if (infile_stack_ptr >= 0) {
// Set new state
- //yyin = infile_stack[infile_stack_ptr].fd; // ???
- ispipe = infile_stack[infile_stack_ptr].pipe;
+ ispipe = infile_stack[infile_stack_ptr].fp.pipe;
filename = infile_stack[infile_stack_ptr].filename;
line_nr = infile_stack[infile_stack_ptr].linenr;