summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1992-11-08 20:19:58 +0000
committerJim Meyering <jim@meyering.net>1992-11-08 20:19:58 +0000
commit925487607cfed5d4e68ffa375bc17941934dba07 (patch)
treed9333d9e8759a18b2ea1b3550319491cce519cb0 /src
parent40d0a06450310c7abc8b393f130fa76de682313d (diff)
downloadcoreutils-925487607cfed5d4e68ffa375bc17941934dba07.tar.xz
Declared lots of external functions and variables static.
Made several statically-initialized arrays `const'
Diffstat (limited to 'src')
-rw-r--r--src/cat.c35
-rw-r--r--src/cksum.c14
-rw-r--r--src/comm.c18
-rw-r--r--src/csplit.c139
-rw-r--r--src/cut.c55
-rw-r--r--src/expand.c42
-rw-r--r--src/fold.c17
-rw-r--r--src/head.c41
-rw-r--r--src/join.c6
-rw-r--r--src/nl.c103
-rw-r--r--src/od.c2
-rw-r--r--src/paste.c29
-rw-r--r--src/pr.c223
-rw-r--r--src/sort.c32
-rw-r--r--src/split.c57
-rw-r--r--src/sum.c13
-rw-r--r--src/tac.c55
-rw-r--r--src/tail.c71
-rw-r--r--src/tr.c8
-rw-r--r--src/unexpand.c42
-rw-r--r--src/uniq.c33
-rw-r--r--src/wc.c23
22 files changed, 537 insertions, 521 deletions
diff --git a/src/cat.c b/src/cat.c
index 34c438491..f16daaab6 100644
--- a/src/cat.c
+++ b/src/cat.c
@@ -34,44 +34,45 @@
char *stpcpy ();
char *xmalloc ();
-void cat ();
void error ();
-void next_line_num ();
-void simple_cat ();
+
+static void cat ();
+static void next_line_num ();
+static void simple_cat ();
/* Name under which this program was invoked. */
char *program_name;
/* Name of input file. May be "-". */
-char *infile;
+static char *infile;
/* Descriptor on which input file is open. */
-int input_desc;
+static int input_desc;
/* Descriptor on which output file is open. Always is 1. */
-int output_desc;
+static int output_desc;
/* Buffer for line numbers. */
-char line_buf[13] =
+static char line_buf[13] =
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', '\t', '\0'};
/* Position in `line_buf' where printing starts. This will not change
unless the number of lines are more than 999999. */
-char *line_num_print = line_buf + 5;
+static char *line_num_print = line_buf + 5;
/* Position of the first digit in `line_buf'. */
-char *line_num_start = line_buf + 10;
+static char *line_num_start = line_buf + 10;
/* Position of the last digit in `line_buf'. */
-char *line_num_end = line_buf + 10;
+static char *line_num_end = line_buf + 10;
/* Preserves the `cat' function's local `newlines' between invocations. */
-int newlines2 = 0;
+static int newlines2 = 0;
/* Count of non-fatal error conditions. */
-int exit_stat = 0;
+static int exit_stat = 0;
-void
+static void
usage (reason)
char *reason;
{
@@ -133,7 +134,7 @@ main (argc, argv)
int output_tabs = 1;
int options = 0;
- static struct option long_options[] =
+ static struct option const long_options[] =
{
{"number-nonblank", 0, NULL, 'b'},
{"number", 0, NULL, 'n'},
@@ -338,7 +339,7 @@ main (argc, argv)
/* Plain cat. Copies the file behind `input_desc' to the file behind
`output_desc'. */
-void
+static void
simple_cat (buf, bufsize)
/* Pointer to the buffer, used by reads and writes. */
unsigned char *buf;
@@ -382,7 +383,7 @@ simple_cat (buf, bufsize)
A newline character is always put at the end of the buffer, to make
an explicit test for buffer end unnecessary. */
-void
+static void
cat (inbuf, insize, outbuf, outsize, quote,
output_tabs, numbers, numbers_at_empty_lines,
mark_line_ends, squeeze_empty_lines)
@@ -643,7 +644,7 @@ cat (inbuf, insize, outbuf, outsize, quote,
/* Compute the next line number. */
-void
+static void
next_line_num ()
{
char *endp = line_num_end;
diff --git a/src/cksum.c b/src/cksum.c
index df9c3130b..6cce4a8f1 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -57,9 +57,9 @@
#define GEN (BIT(26)|BIT(23)|BIT(22)|BIT(16)|BIT(12)|BIT(11)|BIT(10)\
|BIT(8) |BIT(7) |BIT(5) |BIT(4) |BIT(2) |BIT(1) |BIT(0));
-unsigned long r[8];
+static unsigned long r[8];
-void
+static void
fill_r ()
{
int i;
@@ -69,7 +69,7 @@ fill_r ()
r[i] = (r[i - 1] & SBIT) ? (r[i - 1] << 1) ^ r[0] : r[i - 1] << 1;
}
-unsigned long
+static unsigned long
remainder (m)
int m;
{
@@ -109,7 +109,9 @@ main ()
/* Number of bytes to read at once. */
#define BUFLEN (1 << 16)
-unsigned long crctab[256] =
+void error ();
+
+static unsigned long const crctab[256] =
{
0x0,
0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,
@@ -169,14 +171,14 @@ unsigned long crctab[256] =
char *program_name;
/* Nonzero if any of the files read were the standard input. */
-int have_read_stdin;
+static int have_read_stdin;
/* Calculate and print the checksum and length in bytes
of file FILE, or of the standard input if FILE is "-".
If PRINT_NAME is nonzero, print FILE next to the checksum and size.
Return 0 if successful, -1 if an error occurs. */
-int
+static int
cksum (file, print_name)
char *file;
int print_name;
diff --git a/src/comm.c b/src/comm.c
index 4362b6475..7a7d6accb 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -26,21 +26,21 @@
#define min(x, y) ((x) < (y) ? (x) : (y))
/* If nonzero, print lines that are found only in file 1. */
-int only_file_1;
+static int only_file_1;
/* If nonzero, print lines that are found only in file 2. */
-int only_file_2;
+static int only_file_2;
/* If nonzero, print lines that are found in both files. */
-int both;
+static int both;
/* The name this program was run with. */
char *program_name;
-int compare_files ();
void error ();
-void writeline ();
-void usage ();
+static int compare_files ();
+static void writeline ();
+static void usage ();
void
main (argc, argv)
@@ -86,7 +86,7 @@ main (argc, argv)
merge them and output the result.
Return 0 if successful, 1 if any errors occur. */
-int
+static int
compare_files (infiles)
char **infiles;
{
@@ -176,7 +176,7 @@ compare_files (infiles)
CLASS is 1 for a line found only in file 1,
2 for a line only in file 2, 3 for a line in both. */
-void
+static void
writeline (line, stream, class)
struct linebuffer *line;
FILE *stream;
@@ -213,7 +213,7 @@ writeline (line, stream, class)
putc ('\n', stream);
}
-void
+static void
usage ()
{
fprintf (stderr, "Usage: %s [-123] file1 file2\n", program_name);
diff --git a/src/csplit.c b/src/csplit.c
index 56bffa385..03ee5d79b 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -39,11 +39,14 @@ char *realloc ();
void error ();
-void cleanup ();
-void close_output_file ();
-void create_output_file ();
-void save_line_to_file ();
-void usage ();
+
+static char *xrealloc ();
+static char *xmalloc ();
+static void cleanup ();
+static void close_output_file ();
+static void create_output_file ();
+static void save_line_to_file ();
+static void usage ();
#ifndef TRUE
#define FALSE 0
@@ -121,72 +124,72 @@ struct buffer_record
};
/* Input file descriptor. */
-int input_desc = 0;
+static int input_desc = 0;
/* List of available buffers. */
-struct buffer_record *free_list = NULL;
+static struct buffer_record *free_list = NULL;
/* Start of buffer list. */
-struct buffer_record *head = NULL;
+static struct buffer_record *head = NULL;
/* Partially read line. */
-char *hold_area = NULL;
+static char *hold_area = NULL;
/* Number of chars in `hold_area'. */
-unsigned hold_count = 0;
+static unsigned hold_count = 0;
/* Number of the last line in the buffers. */
-unsigned last_line_number = 0;
+static unsigned last_line_number = 0;
/* Number of the line currently being examined. */
-unsigned current_line = 0;
+static unsigned current_line = 0;
/* Number of the last line in the input file. */
-unsigned last_line_in_file = 0;
+static unsigned last_line_in_file = 0;
/* If TRUE, we have read EOF. */
-boolean have_read_eof = FALSE;
+static boolean have_read_eof = FALSE;
/* Name of output files. */
-char *filename_space = NULL;
+static char *filename_space = NULL;
/* Prefix part of output file names. */
-char *prefix = NULL;
+static char *prefix = NULL;
/* Number of digits to use in output file names. */
-int digits = 2;
+static int digits = 2;
/* Number of files created so far. */
-unsigned files_created = 0;
+static unsigned files_created = 0;
/* Number of bytes written to current file. */
-unsigned bytes_written;
+static unsigned bytes_written;
/* Output file pointer. */
-FILE *output_stream = NULL;
+static FILE *output_stream = NULL;
/* Perhaps it would be cleaner to pass arg values instead of indexes. */
-char **global_argv;
+static char **global_argv;
/* If TRUE, do not print the count of bytes in each output file. */
-boolean suppress_count;
+static boolean suppress_count;
/* If TRUE, remove output files on error. */
-boolean remove_files;
+static boolean remove_files;
/* The compiled pattern arguments, which determine how to split
the input file. */
-struct control *controls;
+static struct control *controls;
/* Number of elements in `controls'. */
-unsigned control_used;
+static unsigned control_used;
/* The name this program was run with. */
char *program_name;
/* Allocate N bytes of memory dynamically, with error checking. */
-char *
+static char *
xmalloc (n)
unsigned n;
{
@@ -206,7 +209,7 @@ xmalloc (n)
If P is NULL, run xmalloc.
If N is 0, run free and return NULL. */
-char *
+static char *
xrealloc (p, n)
char *p;
unsigned n;
@@ -235,7 +238,7 @@ xrealloc (p, n)
(even if it is this one), these chars will be placed at the
start of the new buffer. */
-void
+static void
save_to_hold_area (start, num)
char *start;
unsigned num;
@@ -247,7 +250,7 @@ save_to_hold_area (start, num)
/* Read up to MAX chars from the input stream into DEST.
Return the number of chars read. */
-int
+static int
read_input (dest, max)
char *dest;
unsigned max;
@@ -273,7 +276,7 @@ read_input (dest, max)
/* Initialize existing line record P. */
-void
+static void
clear_line_control (p)
struct line *p;
{
@@ -284,7 +287,7 @@ clear_line_control (p)
/* Initialize all line records in B. */
-void
+static void
clear_all_line_control (b)
struct buffer_record *b;
{
@@ -296,7 +299,7 @@ clear_all_line_control (b)
/* Return a new, initialized line record. */
-struct line *
+static struct line *
new_line_control ()
{
struct line *p;
@@ -312,7 +315,7 @@ new_line_control ()
/* Record LINE_START, which is the address of the start of a line
of length LINE_LEN in the large buffer, in the lines buffer of B. */
-void
+static void
keep_new_line (b, line_start, line_len)
struct buffer_record *b;
char *line_start;
@@ -348,7 +351,7 @@ keep_new_line (b, line_start, line_len)
a pointer is kept to this area, which will be used when
the next buffer is filled. */
-unsigned
+static unsigned
record_line_starts (b)
struct buffer_record *b;
{
@@ -400,7 +403,7 @@ record_line_starts (b)
/* Return a new buffer with room to store SIZE bytes, plus
an extra byte for safety. */
-struct buffer_record *
+static struct buffer_record *
create_new_buffer (size)
unsigned size;
{
@@ -420,7 +423,7 @@ create_new_buffer (size)
/* Return a new buffer of at least MINSIZE bytes. If a buffer of at
least that size is currently free, use it, otherwise create a new one. */
-struct buffer_record *
+static struct buffer_record *
get_new_buffer (min_size)
unsigned min_size;
{
@@ -471,7 +474,7 @@ get_new_buffer (min_size)
/* Add buffer BUF to the list of free buffers. */
-void
+static void
free_buffer (buf)
struct buffer_record *buf;
{
@@ -482,7 +485,7 @@ free_buffer (buf)
/* Append buffer BUF to the linked list of buffers that contain
some data yet to be processed. */
-void
+static void
save_buffer (buf)
struct buffer_record *buf;
{
@@ -514,7 +517,7 @@ save_buffer (buf)
Return TRUE if a new buffer was obtained, otherwise false
(in which case end-of-file must have been encountered). */
-boolean
+static boolean
load_buffer ()
{
struct buffer_record *b;
@@ -565,7 +568,7 @@ load_buffer ()
/* Return the line number of the first line that has not yet been retrieved. */
-unsigned
+static unsigned
get_first_line_in_buffer ()
{
if (head == NULL && !load_buffer ())
@@ -578,7 +581,7 @@ get_first_line_in_buffer ()
next line the logical first line.
Return NULL if there is no more input. */
-struct cstring *
+static struct cstring *
remove_line ()
{
struct cstring *line; /* Return value. */
@@ -617,7 +620,7 @@ remove_line ()
/* Search the buffers for line LINENUM, reading more input if necessary.
Return a pointer to the line, or NULL if it is not found in the file. */
-struct cstring *
+static struct cstring *
find_line (linenum)
unsigned linenum;
{
@@ -655,7 +658,7 @@ find_line (linenum)
/* Return TRUE if at least one more line is available for input. */
-boolean
+static boolean
no_more_lines ()
{
return (find_line (current_line + 1) == NULL) ? TRUE : FALSE;
@@ -663,7 +666,7 @@ no_more_lines ()
/* Set the name of the input file to NAME and open it. */
-void
+static void
set_input_file (name)
char *name;
{
@@ -682,7 +685,7 @@ set_input_file (name)
If IGNORE is TRUE, do not output lines selected here.
ARGNUM is the index in ARGV of the current pattern. */
-void
+static void
write_to_file (last_line, ignore, argnum)
unsigned last_line;
boolean ignore;
@@ -718,7 +721,7 @@ write_to_file (last_line, ignore, argnum)
/* Output any lines left after all regexps have been processed. */
-void
+static void
dump_rest_of_file ()
{
struct cstring *line;
@@ -730,7 +733,7 @@ dump_rest_of_file ()
/* Handle an attempt to read beyond EOF under the control of record P,
on iteration REPETITION if nonzero. */
-void
+static void
handle_line_error (p, repetition)
struct control *p;
int repetition;
@@ -750,7 +753,7 @@ handle_line_error (p, repetition)
P is the control record.
REPETITION is the repetition number. */
-void
+static void
process_line_count (p, repetition)
struct control *p;
int repetition;
@@ -784,7 +787,7 @@ process_line_count (p, repetition)
handle_line_error (p, repetition);
}
-void
+static void
regexp_error (p, repetition, ignore)
struct control *p;
int repetition;
@@ -810,7 +813,7 @@ regexp_error (p, repetition, ignore)
it unless P->IGNORE is TRUE.
REPETITION is this repeat-count; 0 means the first time. */
-void
+static void
process_regexp (p, repetition)
struct control *p;
int repetition;
@@ -890,7 +893,7 @@ process_regexp (p, repetition)
/* Split the input file according to the control records we have built. */
-void
+static void
split_file ()
{
register int i, j;
@@ -916,7 +919,7 @@ split_file ()
/* Return the name of output file number NUM. */
-char *
+static char *
make_filename (num)
int num;
{
@@ -926,7 +929,7 @@ make_filename (num)
/* Create the next output file. */
-void
+static void
create_output_file ()
{
char *name;
@@ -944,7 +947,7 @@ create_output_file ()
/* Delete all the files we have created. */
-void
+static void
delete_all_files ()
{
int i;
@@ -961,7 +964,7 @@ delete_all_files ()
/* Close the current output file and print the count
of characters in this file. */
-void
+static void
close_output_file ()
{
if (output_stream)
@@ -980,7 +983,7 @@ close_output_file ()
/* Optionally remove files created so far; then exit.
Called when an error detected. */
-void
+static void
cleanup ()
{
if (output_stream)
@@ -995,7 +998,7 @@ cleanup ()
/* Save line LINE to the output file and
increment the character count for the current file. */
-void
+static void
save_line_to_file (line)
struct cstring *line;
{
@@ -1005,7 +1008,7 @@ save_line_to_file (line)
/* Return a new, initialized control record. */
-struct control *
+static struct control *
new_control_record ()
{
static unsigned control_allocated = 0; /* Total space allocated. */
@@ -1035,7 +1038,7 @@ new_control_record ()
Return a TRUE if the string consists entirely of digits,
FALSE if not. */
-boolean
+static boolean
string_to_number (result, num)
int *result;
char *num;
@@ -1046,7 +1049,7 @@ string_to_number (result, num)
if (*num == '\0')
return FALSE;
- while (ch = *num++)
+ while ((ch = *num++))
{
if (!isdigit (ch))
return FALSE;
@@ -1063,7 +1066,7 @@ string_to_number (result, num)
P is the control record for this regular expression.
NUM is the numeric part of STR. */
-void
+static void
check_for_offset (argnum, p, str, num)
int argnum;
struct control *p;
@@ -1085,7 +1088,7 @@ check_for_offset (argnum, p, str, num)
and store its value in P.
ARGNUM is the ARGV index of STR. */
-void
+static void
parse_repeat_count (argnum, p, str)
int argnum;
struct control *p;
@@ -1111,7 +1114,7 @@ parse_repeat_count (argnum, p, str)
ARGNUM is the ARGV index of STR.
Unless IGNORE is TRUE, mark these lines for output. */
-struct control *
+static struct control *
extract_regexp (argnum, ignore, str)
int argnum;
boolean ignore;
@@ -1121,7 +1124,7 @@ extract_regexp (argnum, ignore, str)
char delim = *str;
char *closing_delim;
struct control *p;
- char *err;
+ const char *err;
closing_delim = rindex (str + 1, delim);
if (closing_delim == NULL)
@@ -1154,7 +1157,7 @@ extract_regexp (argnum, ignore, str)
/* Extract the break patterns from args START through ARGC - 1 of ARGV.
After each pattern, check if the next argument is a repeat count. */
-void
+static void
parse_patterns (argc, start, argv)
int argc;
int start;
@@ -1186,14 +1189,14 @@ parse_patterns (argc, start, argv)
}
}
-void
+static void
interrupt_handler ()
{
error (0, 0, "interrupted");
cleanup ();
}
-struct option longopts[] =
+static struct option const longopts[] =
{
{"digits", 1, NULL, 'n'},
{"quiet", 0, NULL, 's'},
@@ -1297,7 +1300,7 @@ main (argc, argv)
exit (0);
}
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/cut.c b/src/cut.c
index 93808b063..d0f3b0b68 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -75,32 +75,33 @@
char *xmalloc ();
char *xrealloc ();
-int set_fields ();
-int cut_file ();
-void cut_stream ();
-void cut_bytes ();
-void cut_fields ();
-void enlarge_line ();
void error ();
-void invalid_list ();
-void usage ();
+
+static int set_fields ();
+static int cut_file ();
+static void cut_stream ();
+static void cut_bytes ();
+static void cut_fields ();
+static void enlarge_line ();
+static void invalid_list ();
+static void usage ();
/* The number of elements allocated for the input line
and the byte or field number.
Enlarged as necessary. */
-int line_size;
+static int line_size;
/* Processed output buffer. */
-char *outbuf;
+static char *outbuf;
/* Where to save next char to output. */
-char *outbufptr;
+static char *outbufptr;
/* Raw line buffer for field mode. */
-char *inbuf;
+static char *inbuf;
/* Where to save next input char. */
-char *inbufptr;
+static char *inbufptr;
/* What can be done about a byte or field. */
enum field_action
@@ -113,7 +114,7 @@ enum field_action
In field mode, which `delim'-separated fields to output.
Both bytes and fields are numbered starting with 1,
so the first element of `fields' is unused. */
-enum field_action *fields;
+static enum field_action *fields;
enum operating_mode
{
@@ -126,22 +127,22 @@ enum operating_mode
field_mode
};
-enum operating_mode operating_mode;
+static enum operating_mode operating_mode;
/* If nonzero,
for field mode, do not output lines containing no delimeter characters. */
-int delimited_lines_only;
+static int delimited_lines_only;
/* The delimeter character for field mode. */
-unsigned char delim;
+static unsigned char delim;
/* Nonzero if we have ever read standard input. */
-int have_read_stdin;
+static int have_read_stdin;
/* The name this program was run with. */
char *program_name;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"bytes", 1, 0, 'b'},
{"characters", 1, 0, 'c'},
@@ -253,7 +254,7 @@ main (argc, argv)
Return the number of fields selected. */
-int
+static int
set_fields (fieldstr)
char *fieldstr;
{
@@ -381,7 +382,7 @@ set_fields (fieldstr)
/* Process file FILE to standard output.
Return 0 if successful, 1 if not. */
-int
+static int
cut_file (file)
char *file;
{
@@ -419,7 +420,7 @@ cut_file (file)
return 0;
}
-void
+static void
cut_stream (stream)
FILE *stream;
{
@@ -432,7 +433,7 @@ cut_stream (stream)
/* Print the file open for reading on stream STREAM
with the bytes marked `field_omit' in `fields' removed from each line. */
-void
+static void
cut_bytes (stream)
FILE *stream;
{
@@ -475,7 +476,7 @@ cut_bytes (stream)
All characters are initially stowed in the raw input buffer, until
at least one field has been found. */
-void
+static void
cut_fields (stream)
FILE *stream;
{
@@ -542,7 +543,7 @@ cut_fields (stream)
/* Extend the buffers to accomodate at least NEW_SIZE characters. */
-void
+static void
enlarge_line (new_size)
int new_size;
{
@@ -567,13 +568,13 @@ enlarge_line (new_size)
line_size = new_size;
}
-void
+static void
invalid_list ()
{
error (2, 0, "invalid byte or field list");
}
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/expand.c b/src/expand.c
index 8e471379e..c45f2fc60 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -61,48 +61,48 @@ char *xmalloc ();
char *xrealloc ();
void error ();
-FILE *next_file ();
-void add_tabstop ();
-void expand ();
-void parse_tabstops ();
-void usage ();
-void validate_tabstops ();
+static FILE *next_file ();
+static void add_tabstop ();
+static void expand ();
+static void parse_tabstops ();
+static void usage ();
+static void validate_tabstops ();
/* If nonzero, convert blanks even after nonblank characters have been
read on the line. */
-int convert_entire_line;
+static int convert_entire_line;
/* If nonzero, the size of all tab stops. If zero, use `tab_list' instead. */
-int tab_size;
+static int tab_size;
/* Array of the explicit column numbers of the tab stops;
after `tab_list' is exhausted, each additional tab is replaced
by a space. The first column is column 0. */
-int *tab_list;
+static int *tab_list;
/* The index of the first invalid element of `tab_list',
where the next element can be added. */
-int first_free_tab;
+static int first_free_tab;
/* Null-terminated array of input filenames. */
-char **file_list;
+static char **file_list;
/* Default for `file_list' if no files are given on the command line. */
-char *stdin_argv[] =
+static char *stdin_argv[] =
{
"-", NULL
};
/* Nonzero if we have ever read standard input. */
-int have_read_stdin;
+static int have_read_stdin;
/* Status to return to the system. */
-int exit_status;
+static int exit_status;
/* The name this program was run with. */
char *program_name;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"tabs", 1, NULL, 't'},
{"initial", 0, NULL, 'i'},
@@ -178,7 +178,7 @@ main (argc, argv)
/* Add the comma or blank separated list of tabstops STOPS
to the list of tabstops. */
-void
+static void
parse_tabstops (stops)
char *stops;
{
@@ -207,7 +207,7 @@ parse_tabstops (stops)
/* Add tab stop TABVAL to the end of `tab_list', except
if TABVAL is -1, do nothing. */
-void
+static void
add_tabstop (tabval)
int tabval;
{
@@ -221,7 +221,7 @@ add_tabstop (tabval)
/* Check that the list of tabstops TABS, with ENTRIES entries,
contains only nonzero, ascending values. */
-void
+static void
validate_tabstops (tabs, entries)
int *tabs;
int entries;
@@ -242,7 +242,7 @@ validate_tabstops (tabs, entries)
/* Change tabs to spaces, writing to stdout.
Read each file in `file_list', in order. */
-void
+static void
expand ()
{
FILE *fp; /* Input stream. */
@@ -323,7 +323,7 @@ expand ()
Open a filename of `-' as the standard input.
Return NULL if there are no more input files. */
-FILE *
+static FILE *
next_file (fp)
FILE *fp;
{
@@ -366,7 +366,7 @@ next_file (fp)
return NULL;
}
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/fold.c b/src/fold.c
index d5d4ae3fe..a2fb42a0c 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -28,23 +28,24 @@
#include "system.h"
char *xrealloc ();
-int adjust_column ();
-int fold_file ();
void error ();
+static int adjust_column ();
+static int fold_file ();
+
/* If nonzero, try to break on whitespace. */
-int break_spaces;
+static int break_spaces;
/* If nonzero, count bytes, not column positions. */
-int count_bytes;
+static int count_bytes;
/* If nonzero, at least one of the files we read was standard input. */
-int have_read_stdin;
+static int have_read_stdin;
/* The name this program was run with. */
char *program_name;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"bytes", 0, NULL, 'b'},
{"spaces", 0, NULL, 's'},
@@ -110,7 +111,7 @@ Usage: %s [-bs] [-w width] [--bytes] [--spaces] [--width=width] [file...]\n",
to stdout, with maximum line length WIDTH.
Return 0 if successful, 1 if an error occurs. */
-int
+static int
fold_file (filename, width)
char *filename;
int width;
@@ -225,7 +226,7 @@ fold_file (filename, width)
printing C will move the cursor to.
The first column is 0. */
-int
+static int
adjust_column (column, c)
int column;
char c;
diff --git a/src/head.c b/src/head.c
index 0302b60ac..29995698e 100644
--- a/src/head.c
+++ b/src/head.c
@@ -53,10 +53,10 @@
/* Number of bytes per item we are printing.
If 0, head in lines. */
-int unit_size;
+static int unit_size;
/* If nonzero, print filename headers. */
-int print_headers;
+static int print_headers;
/* When to print the filename banners. */
enum header_mode
@@ -64,24 +64,25 @@ enum header_mode
multiple_files, always, never
};
-int head ();
-int head_bytes ();
-int head_file ();
-int head_lines ();
-long atou ();
void error ();
-void parse_unit ();
-void usage ();
-void write_header ();
void xwrite ();
+static int head ();
+static int head_bytes ();
+static int head_file ();
+static int head_lines ();
+static long atou ();
+static void parse_unit ();
+static void usage ();
+static void write_header ();
+
/* The name this program was run with. */
char *program_name;
/* Have we ever read standard input? */
-int have_read_stdin;
+static int have_read_stdin;
-struct option long_options[] =
+static struct option const long_options[] =
{
{"bytes", 1, NULL, 'c'},
{"lines", 1, NULL, 'n'},
@@ -211,7 +212,7 @@ main (argc, argv)
exit (exit_status);
}
-int
+static int
head_file (filename, number)
char *filename;
long number;
@@ -244,7 +245,7 @@ head_file (filename, number)
}
}
-void
+static void
write_header (filename)
char *filename;
{
@@ -261,7 +262,7 @@ write_header (filename)
xwrite (1, " <==\n", 5);
}
-int
+static int
head (filename, fd, number)
char *filename;
int fd;
@@ -273,7 +274,7 @@ head (filename, fd, number)
return head_lines (filename, fd, number);
}
-int
+static int
head_bytes (filename, fd, bytes_to_write)
char *filename;
int fd;
@@ -300,7 +301,7 @@ head_bytes (filename, fd, bytes_to_write)
return 0;
}
-int
+static int
head_lines (filename, fd, lines_to_write)
char *filename;
int fd;
@@ -329,7 +330,7 @@ head_lines (filename, fd, lines_to_write)
return 0;
}
-void
+static void
parse_unit (str)
char *str;
{
@@ -358,7 +359,7 @@ parse_unit (str)
/* Convert STR, a string of ASCII digits, into an unsigned integer.
Return -1 if STR does not represent a valid unsigned integer. */
-long
+static long
atou (str)
char *str;
{
@@ -369,7 +370,7 @@ atou (str)
return *str ? -1 : value;
}
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/join.c b/src/join.c
index 9ac82e0fd..9e3537c03 100644
--- a/src/join.c
+++ b/src/join.c
@@ -89,10 +89,10 @@ static char *empty_filler;
static int join_field_1, join_field_2;
/* List of fields to print. */
-struct outlist *outlist;
+static struct outlist *outlist;
/* Last element in `outlist', where a new element can be added. */
-struct outlist *outlist_end;
+static struct outlist *outlist_end;
/* Tab character separating fields; if this is NUL fields are separated
by any nonempty string of white space, otherwise by exactly one
@@ -558,7 +558,7 @@ add_field_list (str)
/* When using getopt_long_only, no long option can start with
a character that is a short option. */
-static struct option longopts[] =
+static struct option const longopts[] =
{
{"j", 1, NULL, 'j'},
{"j1", 1, NULL, '1'},
diff --git a/src/nl.c b/src/nl.c
index 368001adc..51cb5c1f9 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -49,105 +49,106 @@ enum section
};
/* Format of body lines (-b). */
-char *body_type = "t";
+static char *body_type = "t";
/* Format of header lines (-h). */
-char *header_type = "n";
+static char *header_type = "n";
/* Format of footer lines (-f). */
-char *footer_type = "n";
+static char *footer_type = "n";
/* Format currently being used (body, header, or footer). */
-char *current_type;
+static char *current_type;
/* Regex for body lines to number (-bp). */
-struct re_pattern_buffer body_regex;
+static struct re_pattern_buffer body_regex;
/* Regex for header lines to number (-hp). */
-struct re_pattern_buffer header_regex;
+static struct re_pattern_buffer header_regex;
/* Regex for footer lines to number (-fp). */
-struct re_pattern_buffer footer_regex;
+static struct re_pattern_buffer footer_regex;
/* Pointer to current regex, if any. */
-struct re_pattern_buffer *current_regex = NULL;
+static struct re_pattern_buffer *current_regex = NULL;
/* Separator string to print after line number (-s). */
-char *separator_str = "\t";
+static char *separator_str = "\t";
/* Input section delimiter string (-d). */
-char *section_del = DEFAULT_SECTION_DELIMITERS;
+static char *section_del = DEFAULT_SECTION_DELIMITERS;
/* Header delimiter string. */
-char *header_del = NULL;
+static char *header_del = NULL;
/* Header section delimiter length. */
-int header_del_len;
+static int header_del_len;
/* Body delimiter string. */
-char *body_del = NULL;
+static char *body_del = NULL;
/* Body section delimiter length. */
-int body_del_len;
+static int body_del_len;
/* Footer delimiter string. */
-char *footer_del = NULL;
+static char *footer_del = NULL;
/* Footer section delimiter length. */
-int footer_del_len;
+static int footer_del_len;
/* Input buffer. */
-struct linebuffer line_buf;
+static struct linebuffer line_buf;
/* printf format string for line number. */
-char *print_fmt;
+static char *print_fmt;
/* printf format string for unnumbered lines. */
-char *print_no_line_fmt = NULL;
+static char *print_no_line_fmt = NULL;
/* Starting line number on each page (-v). */
-int page_start = 1;
+static int page_start = 1;
/* Line number increment (-i). */
-int page_incr = 1;
+static int page_incr = 1;
/* If TRUE, reset line number at start of each page (-p). */
-int reset_numbers = TRUE;
+static int reset_numbers = TRUE;
/* Number of blank lines to consider to be one line for numbering (-l). */
-int blank_join = 1;
+static int blank_join = 1;
/* Width of line numbers (-w). */
-int lineno_width = 6;
+static int lineno_width = 6;
/* Line number format (-n). */
-enum number_format lineno_format = FORMAT_RIGHT_NOLZ;
+static enum number_format lineno_format = FORMAT_RIGHT_NOLZ;
/* Current print line number. */
-int line_no;
+static int line_no;
/* The name this program was run with. */
char *program_name;
/* Nonzero if we have ever read standard input. */
-int have_read_stdin;
+static int have_read_stdin;
-enum section check_section ();
char *xmalloc ();
char *xrealloc ();
-int build_type_arg ();
-int nl_file ();
-void usage ();
-void process_file ();
-void proc_header ();
-void proc_body ();
-void proc_footer ();
-void proc_text ();
-void print_lineno ();
-void build_print_fmt ();
void error ();
+
+static enum section check_section ();
+static int build_type_arg ();
+static int nl_file ();
+static void usage ();
+static void process_file ();
+static void proc_header ();
+static void proc_body ();
+static void proc_footer ();
+static void proc_text ();
+static void print_lineno ();
+static void build_print_fmt ();
-struct option longopts[] =
+static struct option const longopts[] =
{
{"header-numbering", 1, NULL, 'h'},
{"body-numbering", 1, NULL, 'b'},
@@ -300,7 +301,7 @@ main (argc, argv)
/* Process file FILE to standard output.
Return 0 if successful, 1 if not. */
-int
+static int
nl_file (file)
char *file;
{
@@ -340,7 +341,7 @@ nl_file (file)
/* Read and process the file pointed to by FP. */
-void
+static void
process_file (fp)
FILE *fp;
{
@@ -366,7 +367,7 @@ process_file (fp)
/* Return the type of line in `line_buf'. */
-enum section
+static enum section
check_section ()
{
if (line_buf.length < 2 || memcmp (line_buf.buffer, section_del, 2))
@@ -385,7 +386,7 @@ check_section ()
/* Switch to a header section. */
-void
+static void
proc_header ()
{
current_type = header_type;
@@ -397,7 +398,7 @@ proc_header ()
/* Switch to a body section. */
-void
+static void
proc_body ()
{
current_type = body_type;
@@ -407,7 +408,7 @@ proc_body ()
/* Switch to a footer section. */
-void
+static void
proc_footer ()
{
current_type = footer_type;
@@ -417,7 +418,7 @@ proc_footer ()
/* Process a regular text line in `line_buf'. */
-void
+static void
proc_text ()
{
static int blank_lines = 0; /* Consecutive blank lines so far. */
@@ -461,7 +462,7 @@ proc_text ()
/* Print and increment the line number. */
-void
+static void
print_lineno ()
{
printf (print_fmt, line_no);
@@ -470,7 +471,7 @@ print_lineno ()
/* Build the printf format string, based on `lineno_format'. */
-void
+static void
build_print_fmt ()
{
/* 12 = 10 chars for lineno_width, 1 for %, 1 for \0. */
@@ -492,12 +493,12 @@ build_print_fmt ()
/* Set the command line flag TYPEP and possibly the regex pointer REGEXP,
according to `optarg'. */
-int
+static int
build_type_arg (typep, regexp)
char **typep;
struct re_pattern_buffer *regexp;
{
- char *errmsg;
+ const char *errmsg;
int rval = TRUE;
int optlen;
@@ -529,7 +530,7 @@ build_type_arg (typep, regexp)
/* Print a usage message and quit. */
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/od.c b/src/od.c
index f13c6b7bc..ad59ed17c 100644
--- a/src/od.c
+++ b/src/od.c
@@ -240,7 +240,7 @@ static enum size_spec integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1];
#define MAX_FP_TYPE_SIZE sizeof(LONG_DOUBLE)
static enum size_spec fp_type_size[MAX_FP_TYPE_SIZE + 1];
-static struct option long_options[] =
+static struct option const long_options[] =
{
/* POSIX options. */
{"skip-bytes", 1, NULL, 'j'},
diff --git a/src/paste.c b/src/paste.c
index c7058a63c..fc120b49f 100644
--- a/src/paste.c
+++ b/src/paste.c
@@ -43,13 +43,14 @@
#include <sys/types.h>
#include "system.h"
-char *collapse_escapes ();
+void error ();
char *xmalloc ();
char *xrealloc ();
-int paste_parallel ();
-int paste_serial ();
-void error ();
-void usage ();
+
+static char *collapse_escapes ();
+static int paste_parallel ();
+static int paste_serial ();
+static void usage ();
/* Indicates that no delimiter should be added in the current position. */
#define EMPTY_DELIM '\0'
@@ -64,19 +65,19 @@ void usage ();
char *program_name;
/* If nonzero, we have read standard input at some point. */
-int have_read_stdin;
+static int have_read_stdin;
/* If nonzero, merge subsequent lines of each file rather than
corresponding lines from each file in parallel. */
-int serial_merge;
+static int serial_merge;
/* The delimeters between lines of input files (used cyclically). */
-char *delims;
+static char *delims;
/* A pointer to the character after the end of `delims'. */
-char *delim_end;
+static char *delim_end;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"serial", 0, 0, 's'},
{"delimiters", 1, 0, 'd'},
@@ -142,7 +143,7 @@ main (argc, argv)
Return a pointer to the character after the new end of STRPTR. */
-char *
+static char *
collapse_escapes (strptr)
char *strptr;
{
@@ -200,7 +201,7 @@ collapse_escapes (strptr)
Return 0 if no errors, 1 if one or more files could not be
opened or read. */
-int
+static int
paste_parallel (nfiles, fnamptr)
int nfiles;
char **fnamptr;
@@ -368,7 +369,7 @@ paste_parallel (nfiles, fnamptr)
Return 0 if no errors, 1 if one or more files could not be
opened or read. */
-int
+static int
paste_serial (nfiles, fnamptr)
int nfiles;
char **fnamptr;
@@ -447,7 +448,7 @@ paste_serial (nfiles, fnamptr)
return errors;
}
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/pr.c b/src/pr.c
index 10595ad73..fe65c7659 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -108,27 +108,28 @@
#define ISDIGIT(c) isdigit (c)
#endif
-int char_to_clump ();
-int read_line ();
-int print_page ();
-int print_stored ();
char *xmalloc ();
char *xrealloc ();
-int open_file ();
-int skip_to_page ();
void error ();
-void getoptarg ();
-void usage ();
-void print_files ();
-void init_header ();
-void init_store_cols ();
-void store_columns ();
-void balance ();
-void store_char ();
-void pad_down ();
-void read_rest_of_line ();
-void print_char ();
-void cleanup ();
+
+static int char_to_clump ();
+static int read_line ();
+static int print_page ();
+static int print_stored ();
+static int open_file ();
+static int skip_to_page ();
+static void getoptarg ();
+static void usage ();
+static void print_files ();
+static void init_header ();
+static void init_store_cols ();
+static void store_columns ();
+static void balance ();
+static void store_char ();
+static void pad_down ();
+static void read_rest_of_line ();
+static void print_char ();
+static void cleanup ();
#ifndef TRUE
#define TRUE 1
@@ -203,134 +204,134 @@ typedef struct COLUMN COLUMN;
#define NULLCOL (COLUMN *)0
/* All of the columns to print. */
-COLUMN *column_vector;
+static COLUMN *column_vector;
/* When printing a single file in multiple downward columns,
we store the leftmost columns contiguously in buff.
To print a line from buff, get the index of the first char
from line_vector[i], and print up to line_vector[i + 1]. */
-char *buff;
+static char *buff;
/* Index of the position in buff where the next character
will be stored. */
-int buff_current;
+static int buff_current;
/* The number of characters in buff.
Used for allocation of buff and to detect overflow of buff. */
-int buff_allocated;
+static int buff_allocated;
/* Array of indices into buff.
Each entry is an index of the first character of a line.
This is used when storing lines to facilitate shuffling when
we do column balancing on the last page. */
-int *line_vector;
+static int *line_vector;
/* Array of horizonal positions.
For each line in line_vector, end_vector[line] is the horizontal
position we are in after printing that line. We keep track of this
so that we know how much we need to pad to prepare for the next
column. */
-int *end_vector;
+static int *end_vector;
/* (-m) True means we're printing multiple files in parallel. */
-int parallel_files = FALSE;
+static int parallel_files = FALSE;
/* (-[0-9]+) True means we're given an option explicitly specifying
number of columns. Used to detect when this option is used with -m. */
-int explicit_columns = FALSE;
+static int explicit_columns = FALSE;
/* (-t) True means we're printing headers and footers. */
-int extremities = TRUE;
+static int extremities = TRUE;
/* True means we need to print a header as soon as we know we've got input
to print after it. */
-int print_a_header;
+static int print_a_header;
/* (-h) True means we're using the standard header rather than a
customized one specified by the -h flag. */
-int standard_header = TRUE;
+static int standard_header = TRUE;
/* (-f) True means use formfeeds instead of newlines to separate pages. */
-int use_form_feed = FALSE;
+static int use_form_feed = FALSE;
/* True means we haven't encountered any filenames in the argument list. */
-int input_is_stdin = TRUE;
+static int input_is_stdin = TRUE;
/* True means we have read the standard input. */
-int have_read_stdin = FALSE;
+static int have_read_stdin = FALSE;
/* True means the -a flag has been given. */
-int print_across_flag = FALSE;
+static int print_across_flag = FALSE;
/* True means we're printing one file in multiple (>1) downward columns. */
-int storing_columns = TRUE;
+static int storing_columns = TRUE;
/* (-b) True means balance columns on the last page as Sys V does. */
-int balance_columns = FALSE;
+static int balance_columns = FALSE;
/* (-l) Number of lines on a page, including header and footer lines. */
-int lines_per_page = 66;
+static int lines_per_page = 66;
/* Number of lines in the header and footer can be reset to 0 using
the -t flag. */
-int lines_per_header = 5;
-int lines_per_body;
-int lines_per_footer = 5;
+static int lines_per_header = 5;
+static int lines_per_body;
+static int lines_per_footer = 5;
/* (-w) Width in characters of the page. Does not include the width of
the margin. */
-int chars_per_line = 72;
+static int chars_per_line = 72;
/* Number of characters in a column. Based on the gutter and page widths. */
-int chars_per_column;
+static int chars_per_column;
/* (-e) True means convert tabs to spaces on input. */
-int untabify_input = FALSE;
+static int untabify_input = FALSE;
/* (-e) The input tab character. */
-char input_tab_char = '\t';
+static char input_tab_char = '\t';
/* (-e) Tabstops are at chars_per_tab, 2*chars_per_tab, 3*chars_per_tab, ...
where the leftmost column is 1. */
-int chars_per_input_tab = 8;
+static int chars_per_input_tab = 8;
/* (-i) True means convert spaces to tabs on output. */
-int tabify_output = FALSE;
+static int tabify_output = FALSE;
/* (-i) The output tab character. */
-char output_tab_char = '\t';
+static char output_tab_char = '\t';
/* (-i) The width of the output tab. */
-int chars_per_output_tab = 8;
+static int chars_per_output_tab = 8;
/* Keeps track of pending white space. When we hit a nonspace
character after some whitespace, we print whitespace, tabbing
if necessary to get to output_position + spaces_not_printed. */
-int spaces_not_printed;
+static int spaces_not_printed;
/* Number of spaces between columns (though tabs can be used when possible to
use up the equivalent amount of space). Not sure if this is worth making
a flag for. BSD uses 0, Sys V uses 1. Sys V looks better. */
-int chars_per_gutter = 1;
+static int chars_per_gutter = 1;
/* (-o) Number of spaces in the left margin (tabs used when possible). */
-int chars_per_margin = 0;
+static int chars_per_margin = 0;
/* Position where the next character will fall.
Leftmost position is 0 + chars_per_margin.
Rightmost position is chars_per_margin + chars_per_line - 1.
This is important for converting spaces to tabs on output. */
-int output_position;
+static int output_position;
/* Horizontal position relative to the current file.
(output_position depends on where we are on the page;
input_position depends on where we are in the file.)
Important for converting tabs to spaces on input. */
-int input_position;
+static int input_position;
/* Count number of failed opens so we can exit with non-zero
status if there were any. */
-int failed_opens = 0;
+static int failed_opens = 0;
/* The horizontal position we'll be at after printing a tab character
of width c_ from the position h_. */
@@ -341,19 +342,19 @@ int failed_opens = 0;
#define tab_width(c_, h_) - h_ % c_ + c_
/* (-NNN) Number of columns of text to print. */
-int columns = 1;
+static int columns = 1;
/* (+NNN) Page number on which to begin printing. */
-int first_page_number = 1;
+static int first_page_number = 1;
/* Number of files open (not closed, not on hold). */
-int files_ready_to_read = 0;
+static int files_ready_to_read = 0;
/* Number of columns with either an open file or stored lines. */
-int cols_ready_to_print = 0;
+static int cols_ready_to_print = 0;
/* Current page number. Displayed in header. */
-int page_number;
+static int page_number;
/* Current line number. Displayed when -n flag is specified.
@@ -368,75 +369,71 @@ int page_number;
Otherwise, line numbering is as follows:
1 foo 3 goo 5 too
2 moo 4 hoo 6 zoo */
-int line_number;
+static int line_number;
/* (-n) True means lines should be preceded by numbers. */
-int numbered_lines = FALSE;
-
-/* True means print a number as soon as we know we'll be printing
- from the current column. */
-int print_a_number;
+static int numbered_lines = FALSE;
/* (-n) Character which follows each line number. */
-char number_separator = '\t';
+static char number_separator = '\t';
/* (-n) Width in characters of a line number. */
-int chars_per_number = 5;
+static int chars_per_number = 5;
/* Used when widening the first column to accommodate numbers -- only
needed when printing files in parallel. Includes width of both the
number and the number_separator. */
-int number_width;
+static int number_width;
/* Buffer sprintf uses to format a line number. */
-char *number_buff;
+static char *number_buff;
/* (-v) True means unprintable characters are printed as escape sequences.
control-g becomes \007. */
-int use_esc_sequence = FALSE;
+static int use_esc_sequence = FALSE;
/* (-c) True means unprintable characters are printed as control prefixes.
control-g becomes ^G. */
-int use_cntrl_prefix = FALSE;
+static int use_cntrl_prefix = FALSE;
/* (-d) True means output is double spaced. */
-int double_space = FALSE;
+static int double_space = FALSE;
/* Number of files opened initially in init_files. Should be 1
unless we're printing multiple files in parallel. */
-int total_files = 0;
+static int total_files = 0;
/* (-r) True means don't complain if we can't open a file. */
-int ignore_failed_opens = FALSE;
+static int ignore_failed_opens = FALSE;
/* (-s) True means we separate columns with a specified character. */
-int use_column_separator = FALSE;
+static int use_column_separator = FALSE;
/* Character used to separate columns if the the -s flag has been specified. */
-char column_separator = '\t';
+static char column_separator = '\t';
/* Number of separator characters waiting to be printed as soon as we
know that we have any input remaining to be printed. */
-int separators_not_printed;
+static int separators_not_printed;
/* Position we need to pad to, as soon as we know that we have input
remaining to be printed. */
-int padding_not_printed;
+static int padding_not_printed;
/* True means we should pad the end of the page. Remains false until we
know we have a page to print. */
-int pad_vertically;
+static int pad_vertically;
/* (-h) String of characters used in place of the filename in the header. */
-char *custom_header;
+static char *custom_header;
/* String containing the date, filename or custom header, and "Page ". */
-char *header;
+static char *header;
-int *clump_buff;
+static int *clump_buff;
/* True means we truncate lines longer than chars_per_column. */
-int truncate_lines = FALSE;
+static int truncate_lines = FALSE;
/* The name under which this program was invoked. */
char *program_name;
@@ -623,7 +620,7 @@ main (argc, argv)
separator, and k is the optional width of the field used when printing
a number. */
-void
+static void
getoptarg (arg, switch_char, character, number)
char *arg, switch_char, *character;
int *number;
@@ -646,7 +643,7 @@ getoptarg (arg, switch_char, character, number)
/* Set parameters related to formatting. */
-void
+static void
init_parameters (number_of_files)
int number_of_files;
{
@@ -727,7 +724,7 @@ init_parameters (number_of_files)
Return 1 if (number_of_files > 0) and no files can be opened,
0 otherwise. */
-int
+static int
init_fps (number_of_files, av)
int number_of_files;
char **av;
@@ -796,7 +793,7 @@ init_fps (number_of_files, av)
Determine the horizontal position desired when we begin
printing a column (p->start_position). */
-void
+static void
init_funcs ()
{
int i, h, h_next;
@@ -875,7 +872,7 @@ init_funcs ()
/* Open a file. Return nonzero if successful, zero if failed. */
-int
+static int
open_file (name, p)
char *name;
COLUMN *p;
@@ -908,7 +905,7 @@ open_file (name, p)
If we aren't dealing with multiple files in parallel, we change
the status of all columns in the column list to reflect the close. */
-void
+static void
close_file (p)
COLUMN *p;
{
@@ -952,7 +949,7 @@ close_file (p)
If we aren't dealing with parallel files, we must change the
status of all columns in the column list. */
-void
+static void
hold_file (p)
COLUMN *p;
{
@@ -971,7 +968,7 @@ hold_file (p)
/* Undo hold_file -- go through the column list and change any
ON_HOLD columns to OPEN. Used at the end of each page. */
-void
+static void
reset_status ()
{
int i = columns;
@@ -994,7 +991,7 @@ reset_status ()
in each column.
Print the file(s). */
-void
+static void
print_files (number_of_files, av)
int number_of_files;
char **av;
@@ -1036,7 +1033,7 @@ print_files (number_of_files, av)
It might be nice to have a "blank headers" option, since
pr -h "" still prints the date and page number. */
-void
+static void
init_header (filename, desc)
char *filename;
int desc;
@@ -1077,7 +1074,7 @@ init_header (filename, desc)
if we're reading straight from the file)
Keep track of this total so we know when to stop printing */
-void
+static void
init_page ()
{
int j;
@@ -1137,7 +1134,7 @@ init_page ()
reset the status of all files -- any files which where on hold because
of formfeeds are now put back into the lineup. */
-int
+static int
print_page ()
{
int j;
@@ -1230,7 +1227,7 @@ print_page ()
because the last entry tells us the index of the last character,
which we need to know in order to print the last line in buff. */
-void
+static void
init_store_cols ()
{
int total_lines = lines_per_body * columns;
@@ -1263,7 +1260,7 @@ init_store_cols ()
buff_start is the index in buff of the first character in the
current line. */
-void
+static void
store_columns ()
{
int i, j;
@@ -1314,7 +1311,7 @@ store_columns ()
balance (line);
}
-void
+static void
balance (total_stored)
int total_stored;
{
@@ -1337,7 +1334,7 @@ balance (total_stored)
/* Store a character in the buffer. */
-void
+static void
store_char (c)
int c;
{
@@ -1350,7 +1347,7 @@ store_char (c)
buff[buff_current++] = (char) c;
}
-void
+static void
number (p)
COLUMN *p;
{
@@ -1378,7 +1375,7 @@ number (p)
/* Print (or store) padding until the current horizontal position
is position. */
-void
+static void
pad_across_to (position)
int position;
{
@@ -1399,7 +1396,7 @@ pad_across_to (position)
If the user has requested a formfeed, use one.
Otherwise, use newlines. */
-void
+static void
pad_down (lines)
int lines;
{
@@ -1418,7 +1415,7 @@ pad_down (lines)
hit. Used when we've truncated a line and we no longer need
to print or store its characters. */
-void
+static void
read_rest_of_line (p)
COLUMN *p;
{
@@ -1446,7 +1443,7 @@ read_rest_of_line (p)
of our desired horizontal position and delays printing
until this function is called. */
-void
+static void
print_white_space ()
{
register int h_new;
@@ -1471,7 +1468,7 @@ print_white_space ()
We keep a count until we know that we'll be printing a line,
then print_separators() is called. */
-void
+static void
print_separators ()
{
for (; separators_not_printed > 0; --separators_not_printed)
@@ -1481,7 +1478,7 @@ print_separators ()
/* Print (or store, depending on p->char_func) a clump of N
characters. */
-void
+static void
print_clump (p, n, clump)
COLUMN *p;
int n;
@@ -1498,7 +1495,7 @@ print_clump (p, n, clump)
a nonspace is encountered, call print_white_space() to print the
required number of tabs and spaces. */
-void
+static void
print_char (c)
int c;
{
@@ -1526,7 +1523,7 @@ print_char (c)
/* Skip to page PAGE before printing. */
-int
+static int
skip_to_page (page)
int page;
{
@@ -1550,7 +1547,7 @@ skip_to_page (page)
Formfeeds are assumed to use up two lines at the beginning of
the page. */
-void
+static void
print_header ()
{
if (!use_form_feed)
@@ -1587,7 +1584,7 @@ print_header ()
Return FALSE if we exceed chars_per_column before reading
an end of line character, TRUE otherwise. */
-int
+static int
read_line (p)
COLUMN *p;
{
@@ -1679,7 +1676,7 @@ read_line (p)
Return TRUE, meaning there is no need to call read_rest_of_line. */
-int
+static int
print_stored (p)
COLUMN *p;
{
@@ -1722,7 +1719,7 @@ print_stored (p)
characters in clump_buff. (e.g, the width of '\b' is -1, while the
number of characters is 1.) */
-int
+static int
char_to_clump (c)
int c;
{
@@ -1808,7 +1805,7 @@ char_to_clump (c)
Free everything we've xmalloc'ed, except `header'. */
-void
+static void
cleanup ()
{
if (number_buff)
@@ -1827,7 +1824,7 @@ cleanup ()
/* Complain, print a usage message, and die. */
-void
+static void
usage (reason)
char *reason;
{
diff --git a/src/sort.c b/src/sort.c
index de8b937e2..b4522e34a 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -87,20 +87,20 @@ static struct month
{
char *name;
int val;
-} monthtab[] =
+} const monthtab[] =
{
- "APR", 4,
- "AUG", 8,
- "DEC", 12,
- "FEB", 2,
- "JAN", 1,
- "JUL", 7,
- "JUN", 6,
- "MAR", 3,
- "MAY", 5,
- "NOV", 11,
- "OCT", 10,
- "SEP", 9
+ {"APR", 4},
+ {"AUG", 8},
+ {"DEC", 12},
+ {"FEB", 2},
+ {"JAN", 1},
+ {"JUL", 7},
+ {"JUN", 6},
+ {"MAR", 3},
+ {"MAY", 5},
+ {"NOV", 11},
+ {"OCT", 10},
+ {"SEP", 9}
};
/* During the merge phase, the number of files to merge at once. */
@@ -678,7 +678,7 @@ numcompare (a, b)
else
logb = 0;
- if (tmp = logb - loga)
+ if ((tmp = logb - loga) != 0)
return tmp;
if (!loga)
@@ -717,7 +717,7 @@ numcompare (a, b)
else
logb = 0;
- if (tmp = loga - logb)
+ if ((tmp = loga - logb) != 0)
return tmp;
if (!loga)
@@ -875,7 +875,7 @@ keycompare (a, b)
if (diff)
return key->reverse ? -diff : diff;
- if (diff = lena - lenb)
+ if ((diff = lena - lenb) != 0)
return key->reverse ? -diff : diff;
}
diff --git a/src/split.c b/src/split.c
index ccc4535c2..01c53bb38 100644
--- a/src/split.c
+++ b/src/split.c
@@ -30,43 +30,43 @@
char *xmalloc ();
void error ();
-int convint ();
-int isdigits ();
-int stdread ();
-void line_bytes_split ();
-void bytes_split ();
-void cwrite ();
-void lines_split ();
-void next_file_name ();
+static int convint ();
+static int isdigits ();
+static int stdread ();
+static void line_bytes_split ();
+static void bytes_split ();
+static void cwrite ();
+static void lines_split ();
+static void next_file_name ();
/* Name under which this program was invoked. */
char *program_name;
/* Base name of output files. */
-char *outfile;
+static char *outfile;
/* Pointer to the end of the prefix in OUTFILE.
Suffixes are inserted here. */
-char *outfile_mid;
+static char *outfile_mid;
/* Pointer to the end of OUTFILE. */
-char *outfile_end;
+static char *outfile_end;
/* Status for outfile name generation. */
-unsigned outfile_count = -1;
-unsigned outfile_name_limit = 25 * 26;
-unsigned outfile_name_generation = 1;
+static unsigned outfile_count = -1;
+static unsigned outfile_name_limit = 25 * 26;
+static unsigned outfile_name_generation = 1;
/* Name of input file. May be "-". */
-char *infile;
+static char *infile;
/* Descriptor on which input file is open. */
-int input_desc;
+static int input_desc;
/* Descriptor on which output file is open. */
-int output_desc;
+static int output_desc;
-void
+static void
usage (reason)
char *reason;
{
@@ -80,7 +80,7 @@ Usage: %s [-lines] [-l lines] [-b bytes[bkm]] [-C bytes[bkm]]\n\
exit (2);
}
-struct option longopts[] =
+static struct option const longopts[] =
{
{"bytes", 1, NULL, 'b'},
{"lines", 1, NULL, 'l'},
@@ -241,6 +241,9 @@ main (argc, argv)
case type_byteslines:
line_bytes_split (num);
break;
+
+ default:
+ abort ();
}
if (close (input_desc) < 0)
@@ -253,7 +256,7 @@ main (argc, argv)
/* Return nonzero if the string STR is composed entirely of decimal digits. */
-int
+static int
isdigits (str)
char *str;
{
@@ -272,7 +275,7 @@ isdigits (str)
to mean kilo or `m' to mean mega.
Return 0 if STR is valid, -1 if not. */
-int
+static int
convint (str, val)
char *str;
int *val;
@@ -307,7 +310,7 @@ convint (str, val)
/* Split into pieces of exactly NCHARS bytes.
Use buffer BUF, whose size is BUFSIZE. */
-void
+static void
bytes_split (nchars, buf, bufsize)
int nchars;
char *buf;
@@ -354,7 +357,7 @@ bytes_split (nchars, buf, bufsize)
/* Split into pieces of exactly NLINES lines.
Use buffer BUF, whose size is BUFSIZE. */
-void
+static void
lines_split (nlines, buf, bufsize)
int nlines;
char *buf;
@@ -403,7 +406,7 @@ lines_split (nlines, buf, bufsize)
than NCHARS bytes, and are split on line boundaries except
where lines longer than NCHARS bytes occur. */
-void
+static void
line_bytes_split (nchars)
int nchars;
{
@@ -454,7 +457,7 @@ line_bytes_split (nchars)
If NEW_FILE_FLAG is nonzero, open the next output file.
Otherwise add to the same output file already in use. */
-void
+static void
cwrite (new_file_flag, bp, bytes)
int new_file_flag;
char *bp;
@@ -478,7 +481,7 @@ cwrite (new_file_flag, bp, bytes)
Return the number of bytes successfully read.
If this is less than NCHARS, do not call `stdread' again. */
-int
+static int
stdread (buf, nchars)
char *buf;
int nchars;
@@ -502,7 +505,7 @@ stdread (buf, nchars)
/* Compute the next sequential output file name suffix and store it
into the string `outfile' at the position pointed to by `outfile_mid'. */
-void
+static void
next_file_name ()
{
int x;
diff --git a/src/sum.c b/src/sum.c
index 9236614ca..35780d1e5 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -24,20 +24,21 @@
#include <getopt.h>
#include "system.h"
-int bsd_sum_file ();
-int sysv_sum_file ();
+static int bsd_sum_file ();
+static int sysv_sum_file ();
+
void error ();
/* The name this program was run with. */
char *program_name;
/* Nonzero if any of the files read were the standard input. */
-int have_read_stdin;
+static int have_read_stdin;
/* Right-rotate 32-bit integer variable C. */
#define ROTATE_RIGHT(c) if ((c) & 01) (c) = ((c) >>1) + 0x8000; else (c) >>= 1;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"sysv", 0, NULL, 's'},
{NULL, 0, NULL, 0}
@@ -97,7 +98,7 @@ Usage: %s [-rs] [--sysv] [file...]\n", argv[0]);
The checksum varies depending on sizeof(int).
Return 0 if successful, -1 if an error occurs. */
-int
+static int
bsd_sum_file (file, print_name)
char *file;
int print_name;
@@ -159,7 +160,7 @@ bsd_sum_file (file, print_name)
If PRINT_NAME is >0, print FILE next to the checksum and size.
Return 0 if successful, -1 if an error occurs. */
-int
+static int
sysv_sum_file (file, print_name)
char *file;
int print_name;
diff --git a/src/tac.c b/src/tac.c
index 78e18467b..837280101 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -55,52 +55,53 @@ char *realloc ();
char *mktemp ();
-RETSIGTYPE cleanup ();
-int tac ();
-int tac_file ();
-int tac_stdin ();
-char *xmalloc ();
-char *xrealloc ();
-void output ();
+static RETSIGTYPE cleanup ();
+static int tac ();
+static int tac_file ();
+static int tac_stdin ();
+static char *xmalloc ();
+static char *xrealloc ();
+static void output ();
+static void save_stdin ();
+static void xwrite ();
+
void error ();
-void save_stdin ();
-void xwrite ();
/* The name this program was run with. */
char *program_name;
/* The string that separates the records of the file. */
-char *separator;
+static char *separator;
/* If nonzero, print `separator' along with the record preceding it
in the file; otherwise with the record following it. */
-int separator_ends_record;
+static int separator_ends_record;
/* 0 if `separator' is to be matched as a regular expression;
otherwise, the length of `separator', used as a sentinel to
stop the search. */
-int sentinel_length;
+static int sentinel_length;
/* The length of a match with `separator'. If `sentinel_length' is 0,
`match_length' is computed every time a match succeeds;
otherwise, it is simply the length of `separator'. */
-int match_length;
+static int match_length;
/* The input buffer. */
-char *buffer;
+static char *buffer;
/* The number of bytes to read at once into `buffer'. */
-unsigned read_size;
+static unsigned read_size;
/* The size of `buffer'. This is read_size * 2 + sentinel_length + 2.
The extra 2 bytes allow `past_end' to have a value beyond the
end of `buffer' and `match_start' to run off the front of `buffer'. */
-unsigned buffer_size;
+static unsigned buffer_size;
/* The compiled regular expression representing `separator'. */
static struct re_pattern_buffer compiled_separator;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"before", 0, &separator_ends_record, 0},
{"regex", 0, &sentinel_length, 0},
@@ -113,7 +114,7 @@ main (argc, argv)
int argc;
char **argv;
{
- char *error_message; /* Return value from re_compile_pattern. */
+ const char *error_message; /* Return value from re_compile_pattern. */
int optc, errors;
int have_read_stdin = 0;
@@ -213,7 +214,7 @@ char *tempfile;
file `tempfile' first if it is a pipe.
Return 0 if ok, 1 if an error occurs. */
-int
+static int
tac_stdin ()
{
/* Previous values of signal handlers. */
@@ -305,7 +306,7 @@ tac_stdin ()
/* Make a copy of the standard input in `tempfile'. */
-void
+static void
save_stdin ()
{
static char *template = NULL;
@@ -350,7 +351,7 @@ save_stdin ()
/* Print FILE in reverse.
Return 0 if ok, 1 if an error occurs. */
-int
+static int
tac_file (file)
char *file;
{
@@ -374,7 +375,7 @@ tac_file (file)
/* Print in reverse the file open on descriptor FD for reading FILE.
Return 0 if ok, 1 if an error occurs. */
-int
+static int
tac (fd, file)
int fd;
char *file;
@@ -542,7 +543,7 @@ tac (fd, file)
/* Print the characters from START to PAST_END - 1.
If START is NULL, just flush the buffer. */
-void
+static void
output (start, past_end)
char *start;
char *past_end;
@@ -574,14 +575,14 @@ output (start, past_end)
bytes_in_buffer += bytes_to_add;
}
-RETSIGTYPE
+static RETSIGTYPE
cleanup ()
{
unlink (tempfile);
exit (1);
}
-void
+static void
xwrite (desc, buffer, size)
int desc;
char *buffer;
@@ -596,7 +597,7 @@ xwrite (desc, buffer, size)
/* Allocate N bytes of memory dynamically, with error checking. */
-char *
+static char *
xmalloc (n)
unsigned n;
{
@@ -613,7 +614,7 @@ xmalloc (n)
/* Change the size of memory area P to N bytes, with error checking. */
-char *
+static char *
xrealloc (p, n)
char *p;
unsigned n;
diff --git a/src/tail.c b/src/tail.c
index 050c1936f..cddab26b8 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -65,16 +65,16 @@
/* Number of bytes per item we are printing.
If 0, tail in lines. */
-int unit_size;
+static int unit_size;
/* If nonzero, read from end of file until killed. */
-int forever;
+static int forever;
/* If nonzero, count from start of file instead of end. */
-int from_start;
+static int from_start;
/* If nonzero, print filename headers. */
-int print_headers;
+static int print_headers;
/* When to print the filename banners. */
enum header_mode
@@ -83,30 +83,31 @@ enum header_mode
};
char *xmalloc ();
-int file_lines ();
-int pipe_bytes ();
-int pipe_lines ();
-int start_bytes ();
-int start_lines ();
-int tail ();
-int tail_bytes ();
-int tail_file ();
-int tail_lines ();
-long atou();
-void dump_remainder ();
-void error ();
-void parse_unit ();
-void usage ();
-void write_header ();
void xwrite ();
+void error ();
+
+static int file_lines ();
+static int pipe_bytes ();
+static int pipe_lines ();
+static int start_bytes ();
+static int start_lines ();
+static int tail ();
+static int tail_bytes ();
+static int tail_file ();
+static int tail_lines ();
+static long atou();
+static void dump_remainder ();
+static void parse_unit ();
+static void usage ();
+static void write_header ();
/* The name this program was run with. */
char *program_name;
/* Nonzero if we have ever read standard input. */
-int have_read_stdin;
+static int have_read_stdin;
-struct option long_options[] =
+static struct option const long_options[] =
{
{"bytes", 1, NULL, 'c'},
{"follow", 0, NULL, 'f'},
@@ -277,7 +278,7 @@ main (argc, argv)
"-" for FILENAME means the standard input.
Return 0 if successful, 1 if an error occurred. */
-int
+static int
tail_file (filename, number)
char *filename;
long number;
@@ -310,7 +311,7 @@ tail_file (filename, number)
}
}
-void
+static void
write_header (filename)
char *filename;
{
@@ -331,7 +332,7 @@ write_header (filename)
in FD.
Return 0 if successful, 1 if an error occurred. */
-int
+static int
tail (filename, fd, number)
char *filename;
int fd;
@@ -347,7 +348,7 @@ tail (filename, fd, number)
using NUMBER characters.
Return 0 if successful, 1 if an error occurred. */
-int
+static int
tail_bytes (filename, fd, number)
char *filename;
int fd;
@@ -395,7 +396,7 @@ tail_bytes (filename, fd, number)
using NUMBER lines.
Return 0 if successful, 1 if an error occurred. */
-int
+static int
tail_lines (filename, fd, number)
char *filename;
int fd;
@@ -439,7 +440,7 @@ tail_lines (filename, fd, number)
byte of the file + 1).
Return 0 if successful, 1 if an error occurred. */
-int
+static int
file_lines (filename, fd, number, pos)
char *filename;
int fd;
@@ -512,7 +513,7 @@ file_lines (filename, fd, number, pos)
Buffer the text as a linked list of LBUFFERs, adding them as needed.
Return 0 if successful, 1 if an error occured. */
-int
+static int
pipe_lines (filename, fd, number)
char *filename;
int fd;
@@ -634,7 +635,7 @@ free_lbuffers:
This is a stripped down version of pipe_lines.
Return 0 if successful, 1 if an error occurred. */
-int
+static int
pipe_bytes (filename, fd, number)
char *filename;
int fd;
@@ -731,7 +732,7 @@ free_cbuffers:
any extra characters that were read beyond that.
Return 1 on error, 0 if ok. */
-int
+static int
start_bytes (filename, fd, number)
char *filename;
int fd;
@@ -756,7 +757,7 @@ start_bytes (filename, fd, number)
any extra characters that were read beyond that.
Return 1 on error, 0 if ok. */
-int
+static int
start_lines (filename, fd, number)
char *filename;
int fd;
@@ -787,7 +788,7 @@ start_lines (filename, fd, number)
to the end. If `forever' is nonzero, keep reading from the
end of the file until killed. */
-void
+static void
dump_remainder (filename, fd)
char *filename;
int fd;
@@ -807,7 +808,7 @@ output:
}
}
-void
+static void
parse_unit (str)
char *str;
{
@@ -836,7 +837,7 @@ parse_unit (str)
/* Convert STR, a string of ASCII digits, into an unsigned integer.
Return -1 if STR does not represent a valid unsigned integer. */
-long
+static long
atou (str)
char *str;
{
@@ -847,7 +848,7 @@ atou (str)
return *str ? -1 : value;
}
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/tr.c b/src/tr.c
index bd12f383f..a1376381d 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -99,7 +99,7 @@ enum Upper_Lower_class
from upper or lower. In fact, no other character classes are allowed
when translating, but that condition is tested elsewhere. This array
is indexed by values of type enum Upper_Lower_class. */
-static int class_ok[3][3] =
+static int const class_ok[3][3] =
{
{0, 1, 0},
{1, 0, 0},
@@ -263,7 +263,7 @@ static int translating;
#define IO_BUF_SIZE BUFSIZ
static unsigned char io_buf[IO_BUF_SIZE];
-char *char_class_name[] =
+static char const* const char_class_name[] =
{
"alnum", "alpha", "blank", "cntrl", "digit", "graph",
"lower", "print", "punct", "space", "upper", "xdigit"
@@ -289,7 +289,7 @@ static SET_TYPE in_delete_set[N_CHARS];
two specification strings and the delete switch is not given. */
static char xlate[N_CHARS];
-static struct option long_options[] =
+static struct option const long_options[] =
{
{"complement", 0, NULL, 'c'},
{"delete", 0, NULL, 'd'},
@@ -494,7 +494,7 @@ look_up_char_class (class_str)
unsigned int i;
for (i = 0; i < N_CHAR_CLASSES; i++)
- if (strcmp (class_str, char_class_name[i]) == 0)
+ if (strcmp ((const char *) class_str, char_class_name[i]) == 0)
return (enum Char_class) i;
return CC_NO_CLASS;
}
diff --git a/src/unexpand.c b/src/unexpand.c
index 2733ef77a..8bdb773e6 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -63,48 +63,48 @@ char *xmalloc ();
char *xrealloc ();
void error ();
-FILE *next_file ();
-void add_tabstop ();
-void parse_tabstops ();
-void unexpand ();
-void usage ();
-void validate_tabstops ();
+static FILE *next_file ();
+static void add_tabstop ();
+static void parse_tabstops ();
+static void unexpand ();
+static void usage ();
+static void validate_tabstops ();
/* If nonzero, convert blanks even after nonblank characters have been
read on the line. */
-int convert_entire_line;
+static int convert_entire_line;
/* If nonzero, the size of all tab stops. If zero, use `tab_list' instead. */
-int tab_size;
+static int tab_size;
/* Array of the explicit column numbers of the tab stops;
after `tab_list' is exhausted, the rest of the line is printed
unchanged. The first column is column 0. */
-int *tab_list;
+static int *tab_list;
/* The index of the first invalid element of `tab_list',
where the next element can be added. */
-int first_free_tab;
+static int first_free_tab;
/* Null-terminated array of input filenames. */
-char **file_list;
+static char **file_list;
/* Default for `file_list' if no files are given on the command line. */
-char *stdin_argv[] =
+static char *stdin_argv[] =
{
"-", NULL
};
/* Nonzero if we have ever read standard input. */
-int have_read_stdin;
+static int have_read_stdin;
/* Status to return to the system. */
-int exit_status;
+static int exit_status;
/* The name this program was run with. */
char *program_name;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"tabs", 1, NULL, 't'},
{"all", 0, NULL, 'a'},
@@ -180,7 +180,7 @@ main (argc, argv)
/* Add the comma or blank separated list of tabstops STOPS
to the list of tabstops. */
-void
+static void
parse_tabstops (stops)
char *stops;
{
@@ -209,7 +209,7 @@ parse_tabstops (stops)
/* Add tab stop TABVAL to the end of `tab_list', except
if TABVAL is -1, do nothing. */
-void
+static void
add_tabstop (tabval)
int tabval;
{
@@ -223,7 +223,7 @@ add_tabstop (tabval)
/* Check that the list of tabstops TABS, with ENTRIES entries,
contains only nonzero, ascending values. */
-void
+static void
validate_tabstops (tabs, entries)
int *tabs;
int entries;
@@ -244,7 +244,7 @@ validate_tabstops (tabs, entries)
/* Change spaces to tabs, writing to stdout.
Read each file in `file_list', in order. */
-void
+static void
unexpand ()
{
FILE *fp; /* Input stream. */
@@ -378,7 +378,7 @@ unexpand ()
Open a filename of `-' as the standard input.
Return NULL if there are no more input files. */
-FILE *
+static FILE *
next_file (fp)
FILE *fp;
{
@@ -421,7 +421,7 @@ next_file (fp)
return NULL;
}
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/uniq.c b/src/uniq.c
index 0968cbae4..f30c6afe9 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -30,21 +30,22 @@
#define min(x, y) ((x) < (y) ? (x) : (y))
-char *find_field ();
-int different ();
-void check_file ();
void error ();
-void usage ();
-void writeline ();
+
+static char *find_field ();
+static int different ();
+static void check_file ();
+static void usage ();
+static void writeline ();
/* Number of fields to skip on each line when doing comparisons. */
-int skip_fields;
+static int skip_fields;
/* Number of chars to skip after skipping any fields. */
-int skip_chars;
+static int skip_chars;
/* Number of chars to compare; if 0, compare the whole lines. */
-int check_chars;
+static int check_chars;
enum countmode
{
@@ -54,7 +55,7 @@ enum countmode
/* Whether and how to precede the output lines with a count of the number of
times they occurred in the input. */
-enum countmode countmode;
+static enum countmode countmode;
enum output_mode
{
@@ -64,12 +65,12 @@ enum output_mode
};
/* Which lines to output. */
-enum output_mode mode;
+static enum output_mode mode;
/* The name this program was run with. */
char *program_name;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"count", 0, NULL, 'c'},
{"repeated", 0, NULL, 'd'},
@@ -162,7 +163,7 @@ main (argc, argv)
/* Process input file INFILE with output to OUTFILE.
If either is "-", use the standard I/O stream for it instead. */
-void
+static void
check_file (infile, outfile)
char *infile, *outfile;
{
@@ -236,7 +237,7 @@ check_file (infile, outfile)
/* Given a linebuffer LINE,
return a pointer to the beginning of the line's field to be compared. */
-char *
+static char *
find_field (line)
struct linebuffer *line;
{
@@ -264,7 +265,7 @@ find_field (line)
but rather to the beginnings of the fields to compare.
OLDLEN and NEWLEN are their lengths. */
-int
+static int
different (old, new, oldlen, newlen)
char *old;
char *new;
@@ -291,7 +292,7 @@ different (old, new, oldlen, newlen)
If requested, print the number of times it occurred, as well;
LINECOUNT + 1 is the number of times that the line occurred. */
-void
+static void
writeline (line, stream, linecount)
struct linebuffer *line;
FILE *stream;
@@ -308,7 +309,7 @@ writeline (line, stream, linecount)
putc ('\n', stream);
}
-void
+static void
usage ()
{
fprintf (stderr, "\
diff --git a/src/wc.c b/src/wc.c
index 72d6ea665..f2d791824 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -27,26 +27,27 @@
#define BUFFER_SIZE (16 * 1024)
void error ();
-void wc ();
-void wc_file ();
-void write_counts ();
+
+static void wc ();
+static void wc_file ();
+static void write_counts ();
/* Cumulative number of lines, words, and chars in all files so far. */
-unsigned long total_lines, total_words, total_chars;
+static unsigned long total_lines, total_words, total_chars;
/* Which counts to print. */
-int print_lines, print_words, print_chars;
+static int print_lines, print_words, print_chars;
/* Nonzero if we have ever read the standard input. */
-int have_read_stdin;
+static int have_read_stdin;
/* The name this program was run with. */
char *program_name;
/* The error code to return to the system. */
-int exit_status;
+static int exit_status;
-struct option longopts[] =
+static struct option const longopts[] =
{
{"bytes", 0, NULL, 'c'},
{"chars", 0, NULL, 'c'},
@@ -114,7 +115,7 @@ Usage: %s [-clw] [--bytes] [--chars] [--lines] [--words] [file...]\n", argv[0]);
exit (exit_status);
}
-void
+static void
wc_file (file)
char *file;
{
@@ -141,7 +142,7 @@ wc_file (file)
}
}
-void
+static void
wc (fd, file)
int fd;
char *file;
@@ -206,7 +207,7 @@ wc (fd, file)
total_chars += chars;
}
-void
+static void
write_counts (lc, wc, cc, file)
unsigned long lc, wc, cc;
char *file;