Staticise symbols
This commit is contained in:
parent
c0b9a8533f
commit
41d78c398b
46
col.c
46
col.c
|
@ -80,22 +80,22 @@ struct line_str {
|
||||||
int l_max_col; /* max column in the line */
|
int l_max_col; /* max column in the line */
|
||||||
};
|
};
|
||||||
|
|
||||||
LINE *alloc_line(void);
|
static LINE *alloc_line(void);
|
||||||
void dowarn(int);
|
static void dowarn(int);
|
||||||
void flush_line(LINE *);
|
static void flush_line(LINE *);
|
||||||
void flush_lines(int);
|
static void flush_lines(int);
|
||||||
void flush_blanks(void);
|
static void flush_blanks(void);
|
||||||
void free_line(LINE *);
|
static void free_line(LINE *);
|
||||||
void usage(void);
|
static void usage(void);
|
||||||
void *xmalloc(void *, size_t);
|
static void *xmalloc(void *, size_t);
|
||||||
|
|
||||||
CSET last_set; /* char_set of last char printed */
|
static CSET last_set; /* char_set of last char printed */
|
||||||
LINE *lines;
|
static LINE *lines;
|
||||||
int compress_spaces; /* if doing space -> tab conversion */
|
static int compress_spaces; /* if doing space -> tab conversion */
|
||||||
int fine; /* if `fine' resolution (half lines) */
|
static int fine; /* if `fine' resolution (half lines) */
|
||||||
int max_bufd_lines; /* max # lines to keep in memory */
|
static int max_bufd_lines; /* max # lines to keep in memory */
|
||||||
int nblank_lines; /* # blanks after last flushed line */
|
static int nblank_lines; /* # blanks after last flushed line */
|
||||||
int no_backspaces; /* if not to output any backspaces */
|
static int no_backspaces; /* if not to output any backspaces */
|
||||||
|
|
||||||
#define PUTC(ch) \
|
#define PUTC(ch) \
|
||||||
if (putchar(ch) == EOF) \
|
if (putchar(ch) == EOF) \
|
||||||
|
@ -302,7 +302,7 @@ main(int argc, char *argv[])
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
flush_lines(int nflush)
|
flush_lines(int nflush)
|
||||||
{
|
{
|
||||||
LINE *l;
|
LINE *l;
|
||||||
|
@ -328,7 +328,7 @@ flush_lines(int nflush)
|
||||||
* is the number of half line feeds, otherwise it is the number of whole line
|
* is the number of half line feeds, otherwise it is the number of whole line
|
||||||
* feeds.
|
* feeds.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
flush_blanks(void)
|
flush_blanks(void)
|
||||||
{
|
{
|
||||||
int half, i, nb;
|
int half, i, nb;
|
||||||
|
@ -357,7 +357,7 @@ flush_blanks(void)
|
||||||
* Write a line to stdout taking care of space to tab conversion (-h flag)
|
* Write a line to stdout taking care of space to tab conversion (-h flag)
|
||||||
* and character set shifts.
|
* and character set shifts.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
flush_line(LINE *l)
|
flush_line(LINE *l)
|
||||||
{
|
{
|
||||||
CHAR *c, *endc;
|
CHAR *c, *endc;
|
||||||
|
@ -456,7 +456,7 @@ flush_line(LINE *l)
|
||||||
|
|
||||||
static LINE *line_freelist;
|
static LINE *line_freelist;
|
||||||
|
|
||||||
LINE *
|
static LINE *
|
||||||
alloc_line(void)
|
alloc_line(void)
|
||||||
{
|
{
|
||||||
LINE *l;
|
LINE *l;
|
||||||
|
@ -476,7 +476,7 @@ alloc_line(void)
|
||||||
return (l);
|
return (l);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
free_line(LINE *l)
|
free_line(LINE *l)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ free_line(LINE *l)
|
||||||
line_freelist = l;
|
line_freelist = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
static void *
|
||||||
xmalloc(void *p, size_t size)
|
xmalloc(void *p, size_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -493,13 +493,13 @@ xmalloc(void *p, size_t size)
|
||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-bfhx] [-l num]\n", argv0);
|
eprintf("usage: %s [-bfhx] [-l num]\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
dowarn(int line)
|
dowarn(int line)
|
||||||
{
|
{
|
||||||
warnx("warning: can't back up %s",
|
warnx("warning: can't back up %s",
|
||||||
|
|
60
csplit.c
60
csplit.c
|
@ -61,36 +61,36 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
void cleanup(void);
|
static void cleanup(void);
|
||||||
void do_lineno(const char *);
|
static void do_lineno(const char *);
|
||||||
void do_rexp(const char *);
|
static void do_rexp(const char *);
|
||||||
char *get_line(void);
|
static char *get_line(void);
|
||||||
void handlesig(int);
|
static void handlesig(int);
|
||||||
FILE *newfile(void);
|
static FILE *newfile(void);
|
||||||
void toomuch(FILE *, long);
|
static void toomuch(FILE *, long);
|
||||||
void usage(void);
|
static void usage(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Command line options
|
* Command line options
|
||||||
*/
|
*/
|
||||||
const char *prefix; /* File name prefix */
|
static const char *prefix; /* File name prefix */
|
||||||
long sufflen; /* Number of decimal digits for suffix */
|
static long sufflen; /* Number of decimal digits for suffix */
|
||||||
int sflag; /* Suppress output of file names */
|
static int sflag; /* Suppress output of file names */
|
||||||
int kflag; /* Keep output if error occurs */
|
static int kflag; /* Keep output if error occurs */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Other miscellaneous globals (XXX too many)
|
* Other miscellaneous globals (XXX too many)
|
||||||
*/
|
*/
|
||||||
long lineno; /* Current line number in input file */
|
static long lineno; /* Current line number in input file */
|
||||||
long reps; /* Number of repetitions for this pattern */
|
static long reps; /* Number of repetitions for this pattern */
|
||||||
long nfiles; /* Number of files output so far */
|
static long nfiles; /* Number of files output so far */
|
||||||
long maxfiles; /* Maximum number of files we can create */
|
static long maxfiles; /* Maximum number of files we can create */
|
||||||
char currfile[PATH_MAX]; /* Current output file */
|
static char currfile[PATH_MAX]; /* Current output file */
|
||||||
const char *infn; /* Name of the input file */
|
static const char *infn; /* Name of the input file */
|
||||||
FILE *infile; /* Input file handle */
|
static FILE *infile; /* Input file handle */
|
||||||
FILE *overfile; /* Overflow file for toomuch() */
|
static FILE *overfile; /* Overflow file for toomuch() */
|
||||||
off_t truncofs; /* Offset this file should be truncated at */
|
static off_t truncofs; /* Offset this file should be truncated at */
|
||||||
int doclean; /* Should cleanup() remove output? */
|
static int doclean; /* Should cleanup() remove output? */
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
|
@ -199,14 +199,14 @@ main(int argc, char *argv[])
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-ks] [-f prefix] [-n number] file args ...\n", argv0);
|
eprintf("usage: %s [-ks] [-f prefix] [-n number] file args ...\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
void
|
static void
|
||||||
handlesig(int sig)
|
handlesig(int sig)
|
||||||
{
|
{
|
||||||
const char msg[] = "csplit: caught signal, cleaning up\n";
|
const char msg[] = "csplit: caught signal, cleaning up\n";
|
||||||
|
@ -217,7 +217,7 @@ handlesig(int sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new output file. */
|
/* Create a new output file. */
|
||||||
FILE *
|
static FILE *
|
||||||
newfile(void)
|
newfile(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
@ -233,7 +233,7 @@ newfile(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove partial output, called before exiting. */
|
/* Remove partial output, called before exiting. */
|
||||||
void
|
static void
|
||||||
cleanup(void)
|
cleanup(void)
|
||||||
{
|
{
|
||||||
char fnbuf[PATH_MAX];
|
char fnbuf[PATH_MAX];
|
||||||
|
@ -254,7 +254,7 @@ cleanup(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read a line from the input into a static buffer. */
|
/* Read a line from the input into a static buffer. */
|
||||||
char *
|
static char *
|
||||||
get_line(void)
|
get_line(void)
|
||||||
{
|
{
|
||||||
static char lbuf[LINE_MAX];
|
static char lbuf[LINE_MAX];
|
||||||
|
@ -277,7 +277,7 @@ again: if (fgets(lbuf, sizeof(lbuf), src) == NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Conceptually rewind the input (as obtained by get_line()) back `n' lines. */
|
/* Conceptually rewind the input (as obtained by get_line()) back `n' lines. */
|
||||||
void
|
static void
|
||||||
toomuch(FILE *ofp, long n)
|
toomuch(FILE *ofp, long n)
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
|
@ -336,7 +336,7 @@ toomuch(FILE *ofp, long n)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle splits for /regexp/ and %regexp% patterns. */
|
/* Handle splits for /regexp/ and %regexp% patterns. */
|
||||||
void
|
static void
|
||||||
do_rexp(const char *expr)
|
do_rexp(const char *expr)
|
||||||
{
|
{
|
||||||
regex_t cre;
|
regex_t cre;
|
||||||
|
@ -418,7 +418,7 @@ do_rexp(const char *expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle splits based on line number. */
|
/* Handle splits based on line number. */
|
||||||
void
|
static void
|
||||||
do_lineno(const char *expr)
|
do_lineno(const char *expr)
|
||||||
{
|
{
|
||||||
long lastline, tgtline;
|
long lastline, tgtline;
|
||||||
|
|
75
expr.c
75
expr.c
|
@ -15,22 +15,22 @@
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
|
||||||
struct val *make_int(int);
|
static struct val *make_int(int);
|
||||||
struct val *make_str(char *);
|
static struct val *make_str(char *);
|
||||||
void free_value(struct val *);
|
static void free_value(struct val *);
|
||||||
int is_integer(struct val *, int *);
|
static int is_integer(struct val *, int *);
|
||||||
int to_integer(struct val *);
|
static int to_integer(struct val *);
|
||||||
void to_string(struct val *);
|
static void to_string(struct val *);
|
||||||
int is_zero_or_null(struct val *);
|
static int is_zero_or_null(struct val *);
|
||||||
void nexttoken(int);
|
static void nexttoken(int);
|
||||||
void error(void);
|
static void error(void);
|
||||||
struct val *eval6(void);
|
static struct val *eval6(void);
|
||||||
struct val *eval5(void);
|
static struct val *eval5(void);
|
||||||
struct val *eval4(void);
|
static struct val *eval4(void);
|
||||||
struct val *eval3(void);
|
static struct val *eval3(void);
|
||||||
struct val *eval2(void);
|
static struct val *eval2(void);
|
||||||
struct val *eval1(void);
|
static struct val *eval1(void);
|
||||||
struct val *eval0(void);
|
static struct val *eval0(void);
|
||||||
|
|
||||||
enum token {
|
enum token {
|
||||||
OR, AND, EQ, LT, GT, ADD, SUB, MUL, DIV, MOD, MATCH, RP, LP,
|
OR, AND, EQ, LT, GT, ADD, SUB, MUL, DIV, MOD, MATCH, RP, LP,
|
||||||
|
@ -49,11 +49,11 @@ struct val {
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum token token;
|
static enum token token;
|
||||||
struct val *tokval;
|
static struct val *tokval;
|
||||||
char **av;
|
static char **av;
|
||||||
|
|
||||||
struct val *
|
static struct val *
|
||||||
make_int(int i)
|
make_int(int i)
|
||||||
{
|
{
|
||||||
struct val *vp;
|
struct val *vp;
|
||||||
|
@ -67,8 +67,7 @@ make_int(int i)
|
||||||
return vp;
|
return vp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct val *
|
||||||
struct val *
|
|
||||||
make_str(char *s)
|
make_str(char *s)
|
||||||
{
|
{
|
||||||
struct val *vp;
|
struct val *vp;
|
||||||
|
@ -81,8 +80,7 @@ make_str(char *s)
|
||||||
return vp;
|
return vp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
void
|
|
||||||
free_value(struct val *vp)
|
free_value(struct val *vp)
|
||||||
{
|
{
|
||||||
if (vp->type == string)
|
if (vp->type == string)
|
||||||
|
@ -90,9 +88,8 @@ free_value(struct val *vp)
|
||||||
free(vp);
|
free(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* determine if vp is an integer; if so, return it's value in *r */
|
/* determine if vp is an integer; if so, return it's value in *r */
|
||||||
int
|
static int
|
||||||
is_integer(struct val *vp, int *r)
|
is_integer(struct val *vp, int *r)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -132,9 +129,8 @@ is_integer(struct val *vp, int *r)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* coerce to vp to an integer */
|
/* coerce to vp to an integer */
|
||||||
int
|
static int
|
||||||
to_integer(struct val *vp)
|
to_integer(struct val *vp)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
@ -152,9 +148,8 @@ to_integer(struct val *vp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* coerce to vp to an string */
|
/* coerce to vp to an string */
|
||||||
void
|
static void
|
||||||
to_string(struct val *vp)
|
to_string(struct val *vp)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
@ -169,7 +164,7 @@ to_string(struct val *vp)
|
||||||
vp->u.s = tmp;
|
vp->u.s = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
is_zero_or_null(struct val *vp)
|
is_zero_or_null(struct val *vp)
|
||||||
{
|
{
|
||||||
if (vp->type == integer) {
|
if (vp->type == integer) {
|
||||||
|
@ -180,7 +175,7 @@ is_zero_or_null(struct val *vp)
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
nexttoken(int pat)
|
nexttoken(int pat)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -219,14 +214,14 @@ nexttoken(int pat)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
error(void)
|
error(void)
|
||||||
{
|
{
|
||||||
errx(2, "syntax error");
|
errx(2, "syntax error");
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
struct val *
|
static struct val *
|
||||||
eval6(void)
|
eval6(void)
|
||||||
{
|
{
|
||||||
struct val *v;
|
struct val *v;
|
||||||
|
@ -253,7 +248,7 @@ eval6(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse and evaluate match (regex) expressions */
|
/* Parse and evaluate match (regex) expressions */
|
||||||
struct val *
|
static struct val *
|
||||||
eval5(void)
|
eval5(void)
|
||||||
{
|
{
|
||||||
regex_t rp;
|
regex_t rp;
|
||||||
|
@ -308,7 +303,7 @@ eval5(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse and evaluate multiplication and division expressions */
|
/* Parse and evaluate multiplication and division expressions */
|
||||||
struct val *
|
static struct val *
|
||||||
eval4(void)
|
eval4(void)
|
||||||
{
|
{
|
||||||
struct val *l, *r;
|
struct val *l, *r;
|
||||||
|
@ -347,7 +342,7 @@ eval4(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse and evaluate addition and subtraction expressions */
|
/* Parse and evaluate addition and subtraction expressions */
|
||||||
struct val *
|
static struct val *
|
||||||
eval3(void)
|
eval3(void)
|
||||||
{
|
{
|
||||||
struct val *l, *r;
|
struct val *l, *r;
|
||||||
|
@ -375,7 +370,7 @@ eval3(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse and evaluate comparison expressions */
|
/* Parse and evaluate comparison expressions */
|
||||||
struct val *
|
static struct val *
|
||||||
eval2(void)
|
eval2(void)
|
||||||
{
|
{
|
||||||
struct val *l, *r;
|
struct val *l, *r;
|
||||||
|
@ -448,7 +443,7 @@ eval2(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse and evaluate & expressions */
|
/* Parse and evaluate & expressions */
|
||||||
struct val *
|
static struct val *
|
||||||
eval1(void)
|
eval1(void)
|
||||||
{
|
{
|
||||||
struct val *l, *r;
|
struct val *l, *r;
|
||||||
|
@ -471,7 +466,7 @@ eval1(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse and evaluate | expressions */
|
/* Parse and evaluate | expressions */
|
||||||
struct val *
|
static struct val *
|
||||||
eval0(void)
|
eval0(void)
|
||||||
{
|
{
|
||||||
struct val *l, *r;
|
struct val *l, *r;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user