summaryrefslogtreecommitdiff
path: root/usr.bin/xstr
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2011-11-06 18:50:39 +0000
committerEd Schouten <ed@FreeBSD.org>2011-11-06 18:50:39 +0000
commit641835f46574ce8339ee22031088875fb37c0806 (patch)
tree4b3cc8f5e28a10d1e8dd12cf5dc29c14e1c99d93 /usr.bin/xstr
parente5ec905575338f8b58c3513510d1d96b6e3c43a1 (diff)
downloadsrc-test-641835f46574ce8339ee22031088875fb37c0806.tar.gz
src-test-641835f46574ce8339ee22031088875fb37c0806.zip
Mark global functions and/or variables in xstr(1) static where possible.
This allows compilers and static analyzers to more thorough analysis.
Notes
Notes: svn path=/head/; revision=227247
Diffstat (limited to 'usr.bin/xstr')
-rw-r--r--usr.bin/xstr/xstr.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/usr.bin/xstr/xstr.c b/usr.bin/xstr/xstr.c
index 1636b79ee83c5..670e09ebafc70 100644
--- a/usr.bin/xstr/xstr.c
+++ b/usr.bin/xstr/xstr.c
@@ -62,35 +62,35 @@ static const char sccsid[] = "@(#)xstr.c 8.1 (Berkeley) 6/9/93";
#define ignore(a) ((void) a)
-off_t tellpt;
+static off_t tellpt;
-off_t mesgpt;
-char cstrings[] = "strings";
-char *strings = cstrings;
+static off_t mesgpt;
+static char cstrings[] = "strings";
+static char *strings = cstrings;
-int cflg;
-int vflg;
-int readstd;
+static int cflg;
+static int vflg;
+static int readstd;
-char lastchr(char *);
+static char lastchr(char *);
-int fgetNUL(char *, int, FILE *);
-int istail(char *, char *);
-int octdigit(char);
-int xgetc(FILE *);
+static int fgetNUL(char *, int, FILE *);
+static int istail(char *, char *);
+static int octdigit(char);
+static int xgetc(FILE *);
-off_t hashit(char *, int);
-off_t yankstr(char **);
+static off_t hashit(char *, int);
+static off_t yankstr(char **);
static void usage(void);
-void flushsh(void);
-void found(int, off_t, char *);
-void inithash(void);
-void onintr(int);
-void process(const char *);
-void prstr(char *);
-void xsdotc(void);
+static void flushsh(void);
+static void found(int, off_t, char *);
+static void inithash(void);
+static void onintr(int);
+static void process(const char *);
+static void prstr(char *);
+static void xsdotc(void);
int
main(int argc, char *argv[])
@@ -155,9 +155,9 @@ usage(void)
exit (1);
}
-char linebuf[BUFSIZ];
+static char linebuf[BUFSIZ];
-void
+static void
process(const char *name)
{
char *cp;
@@ -225,7 +225,7 @@ out:
warn("x.c"), onintr(0);
}
-off_t
+static off_t
yankstr(char **cpp)
{
char *cp = *cpp;
@@ -285,13 +285,13 @@ out:
return (hashit(dbuf, 1));
}
-int
+static int
octdigit(char c)
{
return (isdigit(c) && c != '8' && c != '9');
}
-void
+static void
inithash(void)
{
char buf[BUFSIZ];
@@ -308,7 +308,7 @@ inithash(void)
ignore(fclose(mesgread));
}
-int
+static int
fgetNUL(char *obuf, int rmdr, FILE *file)
{
int c;
@@ -320,7 +320,7 @@ fgetNUL(char *obuf, int rmdr, FILE *file)
return ((feof(file) || ferror(file)) ? 0 : 1);
}
-int
+static int
xgetc(FILE *file)
{
@@ -330,14 +330,14 @@ xgetc(FILE *file)
#define BUCKETS 128
-struct hash {
+static struct hash {
off_t hpt;
char *hstr;
struct hash *hnext;
short hnew;
} bucket[BUCKETS];
-off_t
+static off_t
hashit(char *str, int new)
{
int i;
@@ -362,7 +362,7 @@ hashit(char *str, int new)
return (hp->hpt);
}
-void
+static void
flushsh(void)
{
int i;
@@ -395,7 +395,7 @@ flushsh(void)
err(4, "%s", strings);
}
-void
+static void
found(int new, off_t off, char *str)
{
if (vflg == 0)
@@ -408,7 +408,7 @@ found(int new, off_t off, char *str)
fprintf(stderr, "\n");
}
-void
+static void
prstr(char *cp)
{
int c;
@@ -424,7 +424,7 @@ prstr(char *cp)
fprintf(stderr, "%c", c);
}
-void
+static void
xsdotc(void)
{
FILE *strf = fopen(strings, "r");
@@ -459,7 +459,7 @@ out:
ignore(fclose(strf));
}
-char
+static char
lastchr(char *cp)
{
@@ -468,7 +468,7 @@ lastchr(char *cp)
return (*cp);
}
-int
+static int
istail(char *str, char *of)
{
int d = strlen(of) - strlen(str);
@@ -478,7 +478,7 @@ istail(char *str, char *of)
return (d);
}
-void
+static void
onintr(int dummy __unused)
{