53 |
#include "alias.h" |
#include "alias.h" |
54 |
#include "parser.h" |
#include "parser.h" |
55 |
#include "main.h" |
#include "main.h" |
56 |
|
#include "var.h" |
57 |
#ifndef SMALL |
#ifndef SMALL |
58 |
#include "myhistedit.h" |
#include "myhistedit.h" |
59 |
#endif |
#endif |
108 |
|
|
109 |
STATIC void pushfile(void); |
STATIC void pushfile(void); |
110 |
static int preadfd(void); |
static int preadfd(void); |
111 |
|
static void setinputfd(int fd, int push); |
112 |
|
|
113 |
#ifdef mkinit |
#ifdef mkinit |
114 |
INCLUDE <stdio.h> |
INCLUDE <stdio.h> |
127 |
|
|
128 |
|
|
129 |
/* |
/* |
|
* Read a line from the script. |
|
|
*/ |
|
|
|
|
|
char * |
|
|
pfgets(char *line, int len) |
|
|
{ |
|
|
char *p = line; |
|
|
int nleft = len; |
|
|
int c; |
|
|
|
|
|
while (--nleft > 0) { |
|
|
c = pgetc2(); |
|
|
if (c == PEOF) { |
|
|
if (p == line) |
|
|
return NULL; |
|
|
break; |
|
|
} |
|
|
*p++ = c; |
|
|
if (c == '\n') |
|
|
break; |
|
|
} |
|
|
*p = '\0'; |
|
|
return line; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
130 |
* Read a character from the script, returning PEOF on end of file. |
* Read a character from the script, returning PEOF on end of file. |
131 |
* Nul characters in the input are silently discarded. |
* Nul characters in the input are silently discarded. |
132 |
*/ |
*/ |
411 |
sh_error("Can't open %s", fname); |
sh_error("Can't open %s", fname); |
412 |
} |
} |
413 |
if (fd < 10) |
if (fd < 10) |
414 |
fd = savefd(fd); |
fd = savefd(fd, fd); |
415 |
setinputfd(fd, flags & INPUT_PUSH_FILE); |
setinputfd(fd, flags & INPUT_PUSH_FILE); |
416 |
out: |
out: |
417 |
INTON; |
INTON; |
424 |
* interrupts off. |
* interrupts off. |
425 |
*/ |
*/ |
426 |
|
|
427 |
void |
static void |
428 |
setinputfd(int fd, int push) |
setinputfd(int fd, int push) |
429 |
{ |
{ |
430 |
if (push) { |
if (push) { |
529 |
parsefile->fd = 0; |
parsefile->fd = 0; |
530 |
} |
} |
531 |
} |
} |
532 |
|
|
533 |
|
|
534 |
|
int lineno_inc(void) |
535 |
|
{ |
536 |
|
int lineno = plinno++; |
537 |
|
|
538 |
|
setvarint("LINENO", lineno, 0); |
539 |
|
return lineno; |
540 |
|
} |