summaryrefslogtreecommitdiff
path: root/pic/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'pic/input.c')
-rw-r--r--pic/input.c78
1 files changed, 22 insertions, 56 deletions
diff --git a/pic/input.c b/pic/input.c
index 900d985576764..d052f67ed5a97 100644
--- a/pic/input.c
+++ b/pic/input.c
@@ -18,11 +18,6 @@
#include "pic.h"
#include "y.tab.h"
-#if defined (__GLIBC__) && defined (_IO_getc_unlocked)
-#undef getc
-#define getc(f) _IO_getc_unlocked(f)
-#endif
-
Infile infile[10];
Infile *curfile = infile;
@@ -33,10 +28,12 @@ Src *srcp = src;
void do_thru(void);
int nextchar(void);
int getarg(char *);
-void freedef(char *);
-int baldelim(int, char *);
+int baldelim(int, const char *);
+static void popsrc(void);
+
+static char *addnewline(char *);
-void pushsrc(int type, char *ptr) /* new input source */
+void pushsrc(int type, const char *ptr) /* new input source */
{
if (++srcp >= src + MAXSRC)
FATAL("inputs nested too deep");
@@ -70,7 +67,7 @@ void pushsrc(int type, char *ptr) /* new input source */
}
}
-void popsrc(void) /* restore an old one */
+static void popsrc(void) /* restore an old one */
{
if (srcp <= src)
FATAL("too many inputs popped");
@@ -102,7 +99,7 @@ void popsrc(void) /* restore an old one */
srcp--;
}
-void definition(char *s) /* collect definition for s and install */
+void definition(const char *s) /* collect definition for s and install */
/* definitions picked up lexically */
{
char *p;
@@ -125,7 +122,7 @@ void definition(char *s) /* collect definition for s and install */
dprintf("installing %s as `%s'\n", s, p);
}
-char *delimstr(char *s) /* get body of X ... X */
+char *delimstr(const char *s) /* get body of X ... X */
/* message if too big */
{
int c, delim, rdelim, n, deep;
@@ -160,7 +157,7 @@ char *delimstr(char *s) /* get body of X ... X */
return tostring(buf);
}
-int baldelim(int c, char *s) /* replace c by balancing entry in s */
+int baldelim(int c, const char *s) /* replace c by balancing entry in s */
{
for ( ; *s; s += 2)
if (*s == c)
@@ -178,9 +175,9 @@ void undefine(char *s) /* undefine macro */
}
-Arg args[10]; /* argument frames */
-Arg *argfp = args; /* frame pointer */
-int argcnt; /* number of arguments seen so far */
+static Arg args[10]; /* argument frames */
+static Arg *argfp = args; /* frame pointer */
+static int argcnt; /* number of arguments seen so far */
void dodef(struct symtab *stp) /* collect args and switch input to defn */
{
@@ -239,13 +236,13 @@ int getarg(char *p) /* pick up single argument, store in p, return length */
}
#define PBSIZE 2000
-char pbuf[PBSIZE]; /* pushback buffer */
-char *pb = pbuf-1; /* next pushed back character */
+static char pbuf[PBSIZE]; /* pushback buffer */
+static char *pb = pbuf-1; /* next pushed back character */
-char ebuf[200]; /* collect input here for error reporting */
-char *ep = ebuf;
+static char ebuf[200]; /* collect input here for error reporting */
+static char *ep = ebuf;
-int begin = 0;
+static int begin = 0;
extern int thru;
extern struct symtab *thrudef;
extern char *untilstr;
@@ -429,7 +426,7 @@ int unput(int c)
return c;
}
-void pbstr(char *s)
+void pbstr(const char *s)
{
pushsrc(String, s);
}
@@ -450,7 +447,6 @@ void eprint(void);
void yyerror(char *s)
{
- extern char *cmdname;
int ern = errno; /* cause some libraries clobber it */
if (synerr)
@@ -498,7 +494,7 @@ void eprint(void) /* try to print context around error */
void yywrap(void) {}
-char *newfile = 0; /* filename for file copy */
+static char *newfile = 0; /* filename for file copy */
char *untilstr = 0; /* string that terminates a thru */
int thru = 0; /* 1 if copying thru macro */
struct symtab *thrudef = 0; /* macro being used */
@@ -513,7 +509,7 @@ void copydef(struct symtab *p) /* remember macro symtab ptr */
thrudef = p;
}
-struct symtab *copythru(char *s) /* collect the macro name or body for thru */
+struct symtab *copythru(const char *s) /* collect the macro name or body for thru */
{
struct symtab *p;
char *q, *addnewline(char *);
@@ -545,7 +541,7 @@ struct symtab *copythru(char *s) /* collect the macro name or body for thru */
return p;
}
-char *addnewline(char *p) /* add newline to end of p */
+static char *addnewline(char *p) /* add newline to end of p */
{
int n;
@@ -584,7 +580,7 @@ void copy(void) /* begin input from file, etc. */
}
}
-char shellbuf[1000], *shellp;
+static char shellbuf[1000], *shellp;
void shell_init(void) /* set up to interpret a shell command */
{
@@ -608,33 +604,3 @@ void shell_exec(void) /* do it */
else
system(shellbuf);
}
-
-#define LSIZE 128
-
-char *fgetline(char **line, size_t *linesize, size_t *llen, FILE *fp)
-{
- int c;
- size_t n = 0;
-
- if (*line == NULL || *linesize < LSIZE + n + 1)
- *line = realloc(*line, *linesize = LSIZE + n + 1);
- for (;;) {
- if (n >= *linesize - LSIZE / 2)
- *line = realloc(*line, *linesize += LSIZE);
- c = getc(fp);
- if (c != EOF) {
- (*line)[n++] = c;
- (*line)[n] = '\0';
- if (c == '\n')
- break;
- } else {
- if (n > 0)
- break;
- else
- return NULL;
- }
- }
- if (llen)
- *llen = n;
- return *line;
-}