summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libidu/fnprint.c15
-rw-r--r--libidu/idfile.c4
-rw-r--r--libidu/idread.c4
-rw-r--r--libidu/idwrite.c6
-rw-r--r--libidu/scanners.c13
-rw-r--r--libidu/walker.c138
-rw-r--r--src/Makefile.am4
7 files changed, 100 insertions, 84 deletions
diff --git a/libidu/fnprint.c b/libidu/fnprint.c
index 1245fd6..e08e97e 100644
--- a/libidu/fnprint.c
+++ b/libidu/fnprint.c
@@ -1,5 +1,5 @@
/* fnprint.c -- print a list of file names
- Copyright (C) 1986, 1995, 1996, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1986, 1995, 1996, 2007-2008 Free Software Foundation, Inc.
Written by Greg McGary <gkm@gnu.ai.mit.edu>
This program is free software; you can redistribute it and/or modify
@@ -29,16 +29,17 @@
#include "xnls.h"
#include "iduglobal.h"
-char const *root_name (char const *path);
-char const *suff_name (char const *path);
-int common_prefix_suffix (struct file_link const *flink_1, struct file_link const *flink_2);
+static char const *root_name (char const *path);
+static char const *suff_name (char const *path);
+static int common_prefix_suffix (struct file_link const *flink_1,
+ struct file_link const *flink_2);
extern void usage (void);
extern struct file_link *cw_dlink;
/* Return the file name with the suffix stripped off. */
-char const *
+static char const *
root_name (char const *file_name)
{
static char file_name_buffer[BUFSIZ];
@@ -58,7 +59,7 @@ root_name (char const *file_name)
/* Return the suffix, including the dot, or an empty string if there
is no suffix. */
-char const *
+static char const *
suff_name (char const *file_name)
{
char const *dot = strrchr (file_name, '.');
@@ -69,7 +70,7 @@ suff_name (char const *file_name)
fully common directory prefix and a common suffix (i.e., they're
eligible for coalescing with brace notation. */
-int
+static int
common_prefix_suffix (struct file_link const *flink_1, struct file_link const *flink_2)
{
return (flink_1->fl_parent == flink_2->fl_parent
diff --git a/libidu/idfile.c b/libidu/idfile.c
index 20b9d55..9f20788 100644
--- a/libidu/idfile.c
+++ b/libidu/idfile.c
@@ -30,7 +30,7 @@
#include "xalloc.h"
#include "xnls.h"
-int io_size (FILE *, void *, unsigned int size, int);
+static int io_size (FILE *, void *, unsigned int size, int);
/****************************************************************************/
@@ -99,7 +99,7 @@ sizeof_idhead ()
return io_idhead (0, io_size, 0);
}
-int
+static int
io_size (FILE *ignore_FILE, void *ignore_addr, unsigned int size, int io_type)
{
if (io_type == IO_TYPE_STR)
diff --git a/libidu/idread.c b/libidu/idread.c
index c25410f..28f5fda 100644
--- a/libidu/idread.c
+++ b/libidu/idread.c
@@ -30,7 +30,7 @@
#include "xnls.h"
#include "iduglobal.h"
-int fgets0 (char *buf0, int size, FILE *in_FILE);
+static int fgets0 (char *buf0, int size, FILE *in_FILE);
/****************************************************************************/
@@ -145,7 +145,7 @@ read_idhead (struct idhead *idhp)
rather than newlines. Also, we return the number of characters
read rather than the address of buf0. */
-int
+static int
fgets0 (char *buf0, int size, FILE * in_FILE)
{
char *buf;
diff --git a/libidu/idwrite.c b/libidu/idwrite.c
index cffeded..00fc205 100644
--- a/libidu/idwrite.c
+++ b/libidu/idwrite.c
@@ -1,5 +1,5 @@
/* idwrite.c -- functions to write ID database files
- Copyright (C) 1995, 1996, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 2007, 2008 Free Software Foundation, Inc.
Written by Greg McGary <gkm@gnu.ai.mit.edu>
This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
#include "hash.h"
#include "xnls.h"
-int file_link_qsort_compare (void const *x, void const *y);
+static int file_link_qsort_compare (void const *x, void const *y);
/****************************************************************************/
@@ -85,7 +85,7 @@ serialize_file_links (struct idhead *idhp)
- Among used: breadth-first (dirs before files, parent dirs before children)
- Among files: collate by mf_index. */
-int
+static int
file_link_qsort_compare (void const *x, void const *y)
{
struct file_link const *flx = *(struct file_link const *const *) x;
diff --git a/libidu/scanners.c b/libidu/scanners.c
index 98343c4..9633c4d 100644
--- a/libidu/scanners.c
+++ b/libidu/scanners.c
@@ -47,9 +47,10 @@ extern char *program_name;
/****************************************************************************/
-struct lang_args **parse_language_map_file (char const *file_name, struct lang_args **next_ptr);
-char *read_language_map_file (char const *file_name);
-void tokenize_args_string (char *args_string, int *argcp, char ***argvp);
+static struct lang_args **parse_language_map_file (char const *file_name,
+ struct lang_args **next_ptr);
+static char *read_language_map_file (char const *file_name);
+static void tokenize_args_string (char *args_string, int *argcp, char ***argvp);
static struct token *get_token_c (FILE *in_FILE, void const *args, int *flags);
static void *parse_args_c (char **argv, int argc);
@@ -157,7 +158,7 @@ parse_language_map (char const *file_name)
parse_language_map_file (file_name, &lang_args_list);
}
-struct lang_args **
+static struct lang_args **
parse_language_map_file (char const *file_name, struct lang_args **next_ptr)
{
static char white_space[] = " \t\r\n\v\f";
@@ -258,7 +259,7 @@ parse_language_map_file (char const *file_name, struct lang_args **next_ptr)
return next_ptr;
}
-char *
+static char *
read_language_map_file (char const *file_name)
{
int map_fd;
@@ -291,7 +292,7 @@ read_language_map_file (char const *file_name)
/****************************************************************************/
-void
+static void
tokenize_args_string (char *args_string, int *argcp, char ***argvp)
{
static char horizontal_space[] = " \t";
diff --git a/libidu/walker.c b/libidu/walker.c
index ff18ca3..29d09b4 100644
--- a/libidu/walker.c
+++ b/libidu/walker.c
@@ -41,36 +41,45 @@
int walker_verbose_flag = 0;
off_t largest_member_file = 0;
-int walk_dir (struct file_link *dir_link);
-struct member_file *get_member_file (struct file_link *flink);
-struct lang_args *get_lang_args (struct file_link const *flink);
-void print_member_file (struct member_file *member);
-int walk_sub_dirs (struct dynvec *sub_dirs_vec);
-void reparent_children (struct file_link *dlink, struct file_link *slink);
-int classify_link (struct file_link *flink, struct stat *stp);
-struct file_link *get_link_from_dirent (struct dirent *dirent, struct file_link *parent);
-struct file_link *make_link_from_dirent (struct dirent *dirent, struct file_link *parent);
-struct file_link *get_link_from_string (char const *name, struct file_link *parent);
-struct file_link *make_link_from_string (char const *name, struct file_link *parent);
-int lang_wanted (char const *lang_name);
-char **append_strings_to_vector (char **vector_0, char *string, char const *delimiter_class);
-int vector_length (char **vector);
-int string_in_vector (char const *string, char **vector);
+static int walk_dir (struct file_link *dir_link);
+static struct member_file *get_member_file (struct file_link *flink);
+static struct lang_args *get_lang_args (struct file_link const *flink);
+static void print_member_file (struct member_file *member);
+static int walk_sub_dirs (struct dynvec *sub_dirs_vec);
+static void reparent_children (struct file_link *dlink, struct file_link *slink);
+static int classify_link (struct file_link *flink, struct stat *stp);
+static struct file_link *get_link_from_dirent (struct dirent *dirent,
+ struct file_link *parent);
+static struct file_link *make_link_from_dirent (struct dirent *dirent,
+ struct file_link *parent);
+static struct file_link *get_link_from_string (char const *name,
+ struct file_link *parent);
+static struct file_link *make_link_from_string (char const *name,
+ struct file_link *parent);
+static int lang_wanted (char const *lang_name);
+static char **append_strings_to_vector (char **vector_0, char *string,
+ char const *delimiter_class);
+static int vector_length (char **vector);
+static int string_in_vector (char const *string, char **vector);
static int same_as_dot (char const *cwd);
-struct file_link const **fill_link_vector (struct file_link const **vec_buf, struct file_link const *flink);
-struct file_link const **fill_link_vector_1 (struct file_link const **vec_buf, struct file_link const *flink);
-char *fill_dot_dots (char *buf, int levels);
+static struct file_link const
+ **fill_link_vector (struct file_link const **vec_buf,
+ struct file_link const *flink);
+static struct file_link const
+ **fill_link_vector_1 (struct file_link const **vec_buf,
+ struct file_link const *flink);
+static char *fill_dot_dots (char *buf, int levels);
static char *absolute_file_name_1 (char *buffer, struct file_link const *flink);
-unsigned long member_file_hash_1 (void const *key);
-unsigned long member_file_hash_2 (void const *key);
-int member_file_hash_compare (void const *x, void const *y);
-unsigned long file_link_hash_1 (void const *key);
-unsigned long file_link_hash_2 (void const *key);
-int file_link_hash_compare (void const *x, void const *y);
-unsigned long dev_ino_hash_1 (void const *key);
-unsigned long dev_ino_hash_2 (void const *key);
-int dev_ino_hash_compare (void const *x, void const *y);
-int symlink_ancestry (struct file_link *flink);
+static unsigned long member_file_hash_1 (void const *key);
+static unsigned long member_file_hash_2 (void const *key);
+static int member_file_hash_compare (void const *x, void const *y);
+static unsigned long file_link_hash_1 (void const *key);
+static unsigned long file_link_hash_2 (void const *key);
+static int file_link_hash_compare (void const *x, void const *y);
+static unsigned long dev_ino_hash_1 (void const *key);
+static unsigned long dev_ino_hash_2 (void const *key);
+static int dev_ino_hash_compare (void const *x, void const *y);
+static int symlink_ancestry (struct file_link *flink);
#ifndef HAVE_LSTAT
#undef lstat
@@ -82,8 +91,10 @@ int lstat(const char *filename, struct stat *sbuf)
#if HAVE_LINK
-struct file_link *find_alias_link (struct file_link *flink, struct stat *stp);
-struct member_file *maybe_get_member_file (struct file_link *flink, struct stat *stp);
+static struct file_link *find_alias_link (struct file_link *flink,
+ struct stat *stp);
+static struct member_file *maybe_get_member_file (struct file_link *flink,
+ struct stat *stp);
#endif
@@ -103,7 +114,7 @@ char* xgetcwd (void);
/* Walk the file-system tree rooted at `dir_link', looking for files
that are eligible for scanning. */
-int
+static int
walk_dir (struct file_link *dir_link)
{
int scannable_files;
@@ -146,7 +157,7 @@ walk_dir (struct file_link *dir_link)
/* Walk the directories found by walk_dir, calling walk_dir
recursively for each directory. */
-int
+static int
walk_sub_dirs (struct dynvec *sub_dirs_vec)
{
struct file_link **sub_dirs;
@@ -234,7 +245,7 @@ walk_flink (struct file_link *flink, struct dynvec *sub_dirs_vec)
search the entire hash-table for the children. With each child, we
must delete it, reset its parent link, then reinsert. */
-void
+static void
reparent_children (struct file_link *dlink, struct file_link *slink)
{
void **slot = idh.idh_file_link_table.ht_vec;
@@ -293,7 +304,7 @@ mark_member_file_links (struct idhead *idhp)
hard-links dominate symbolic-links; [2] for two hard-links: first
come, first served). */
-struct member_file *
+static struct member_file *
maybe_get_member_file (struct file_link *flink, struct stat *stp)
{
struct file_link *alias_link;
@@ -335,7 +346,7 @@ maybe_get_member_file (struct file_link *flink, struct stat *stp)
/* Return a previously registered alias for `flink', if any. */
-struct file_link *
+static struct file_link *
find_alias_link (struct file_link *flink, struct stat *stp)
{
struct dev_ino *dev_ino;
@@ -362,7 +373,7 @@ find_alias_link (struct file_link *flink, struct stat *stp)
directory. PATH_MAX is considered an infinite distance (e.g.,
there are no symlinks between `flink' and the root). */
-int
+static int
symlink_ancestry (struct file_link *flink)
{
int ancestry = 0;
@@ -378,7 +389,7 @@ symlink_ancestry (struct file_link *flink)
#endif /* HAVE_LINK */
-struct member_file *
+static struct member_file *
get_member_file (struct file_link *flink)
{
struct member_file *member;
@@ -436,7 +447,7 @@ find_member_file (struct file_link const *flink)
pattern matches FLINK. Return the matching lang_args, if a
scanner exists for that language, otherwise return 0. */
-struct lang_args *
+static struct lang_args *
get_lang_args (struct file_link const *flink)
{
struct lang_args *args = lang_args_list;
@@ -461,7 +472,7 @@ get_lang_args (struct file_link const *flink)
? lang_args_default : 0);
}
-void
+static void
print_member_file (struct member_file *member)
{
char *file_name = alloca (PATH_MAX);
@@ -476,7 +487,7 @@ print_member_file (struct member_file *member)
static char **langs_included;
static char **langs_excluded;
-int
+static int
lang_wanted (char const *lang_name)
{
if (langs_excluded)
@@ -503,8 +514,9 @@ exclude_languages (char *lang_names)
langs_excluded = append_strings_to_vector (langs_excluded, lang_names, white_space);
}
-char **
-append_strings_to_vector (char **vector_0, char *string, char const *delimiter_class)
+static char **
+append_strings_to_vector (char **vector_0, char *string,
+ char const *delimiter_class)
{
char **vector;
if (vector_0)
@@ -523,7 +535,7 @@ append_strings_to_vector (char **vector_0, char *string, char const *delimiter_c
return xnrealloc (vector_0, vector - vector_0, sizeof *vector_0);
}
-int
+static int
vector_length (char **vector)
{
int length = 0;
@@ -532,7 +544,7 @@ vector_length (char **vector)
return length;
}
-int
+static int
string_in_vector (char const *string, char **vector)
{
while (*vector)
@@ -724,7 +736,7 @@ prune_file_names (char *str, struct file_link *from_link)
/* Gather information about the link at `flink'. If it's a good
file or directory, return its mod-time and type. */
-int
+static int
classify_link (struct file_link *flink, struct stat *stp)
{
unsigned int flags = 0;
@@ -765,7 +777,7 @@ classify_link (struct file_link *flink, struct stat *stp)
/****************************************************************************/
/* Retrieve an existing flink; or if none exists, create one. */
-struct file_link *
+static struct file_link *
get_link_from_dirent (struct dirent *dirent, struct file_link *parent)
{
struct file_link **slot;
@@ -781,7 +793,7 @@ get_link_from_dirent (struct dirent *dirent, struct file_link *parent)
return *slot;
}
-struct file_link *
+static struct file_link *
get_link_from_string (char const *name, struct file_link *parent)
{
struct file_link **slot;
@@ -811,7 +823,7 @@ make_link_from_dirent (struct dirent* dirent, struct file_link *parent)
return flink;
}
-struct file_link *
+static struct file_link *
make_link_from_string (char const* name, struct file_link *parent)
{
struct file_link *flink;
@@ -830,16 +842,18 @@ make_link_from_string (char const* name, struct file_link *parent)
/* Convert a `file_link' chain to a vector of component `file_link's,
with the root at [0]. Return a pointer beyond the final component. */
-struct file_link const **
-fill_link_vector (struct file_link const **vec_buf, struct file_link const *flink)
+static struct file_link const **
+fill_link_vector (struct file_link const **vec_buf,
+ struct file_link const *flink)
{
vec_buf = fill_link_vector_1 (vec_buf, flink);
*vec_buf = 0;
return vec_buf;
}
-struct file_link const **
-fill_link_vector_1 (struct file_link const **vec_buf, struct file_link const *flink)
+static struct file_link const **
+fill_link_vector_1 (struct file_link const **vec_buf,
+ struct file_link const *flink)
{
if (!IS_ROOT_FILE_LINK (flink))
vec_buf = fill_link_vector_1 (vec_buf, flink->fl_parent);
@@ -937,7 +951,7 @@ out:
/* Fill `buf' with sequences of "../" in order to ascend so many
`levels' in a directory tree. */
-char *
+static char *
fill_dot_dots (char *buf, int levels)
{
while (levels--)
@@ -998,19 +1012,19 @@ absolute_file_name_1 (char *buf, struct file_link const *flink)
/****************************************************************************/
/* Hash stuff for `struct member_file'. */
-unsigned long
+static unsigned long
member_file_hash_1 (void const *key)
{
return_ADDRESS_HASH_1 (((struct member_file const *) key)->mf_link);
}
-unsigned long
+static unsigned long
member_file_hash_2 (void const *key)
{
return_ADDRESS_HASH_2 (((struct member_file const *) key)->mf_link);
}
-int
+static int
member_file_hash_compare (void const *x, void const *y)
{
return_ADDRESS_COMPARE (((struct member_file const *) x)->mf_link,
@@ -1052,7 +1066,7 @@ member_file_qsort_compare (void const *x, void const *y)
/****************************************************************************/
/* Hash stuff for `struct file_link'. */
-unsigned long
+static unsigned long
file_link_hash_1 (void const *key)
{
unsigned long result = 0;
@@ -1063,7 +1077,7 @@ file_link_hash_1 (void const *key)
return result;
}
-unsigned long
+static unsigned long
file_link_hash_2 (void const *key)
{
unsigned long result = 0;
@@ -1074,7 +1088,7 @@ file_link_hash_2 (void const *key)
return result;
}
-int
+static int
file_link_hash_compare (void const *x, void const *y)
{
int result;
@@ -1109,7 +1123,7 @@ links_depth (struct file_link const *flink)
/****************************************************************************/
/* Hash stuff for `struct dev_ino'. */
-unsigned long
+static unsigned long
dev_ino_hash_1 (void const *key)
{
unsigned long result = 0;
@@ -1118,7 +1132,7 @@ dev_ino_hash_1 (void const *key)
return result;
}
-unsigned long
+static unsigned long
dev_ino_hash_2 (void const *key)
{
unsigned long result = 0;
@@ -1127,7 +1141,7 @@ dev_ino_hash_2 (void const *key)
return result;
}
-int
+static int
dev_ino_hash_compare (void const *x, void const *y)
{
int result;
diff --git a/src/Makefile.am b/src/Makefile.am
index 35fd15d..3b872bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,7 @@ sc_tight_scope: $(all_programs)
( printf '^main$$\n^usage$$\n'; \
grep -h -A1 '^extern .*[^;]$$' $(SOURCES) \
| grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t; \
- nm -e *.$(OBJEXT) \
+ nm -e *.$(OBJEXT) ../libidu/*.$(OBJEXT) \
| sed -n 's/.* T //p' \
| grep -Ev -f $$t && \
{ echo 'the above functions should have static scope' 1>&2; \
@@ -32,7 +32,7 @@ sc_tight_scope: $(all_programs)
( printf '^program_name$$\n'; \
sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p' \
$(noinst_HEADERS) /dev/null ) > $$t; \
- nm -e *.$(OBJEXT) \
+ nm -e *.$(OBJEXT) ../libidu/*.$(OBJEXT) \
| sed -n 's/.* [BD] //p' \
| grep -Ev -f $$t && \
{ echo 'the above variables should have static scope' 1>&2; \