diff options
author | Jim Meyering <meyering@redhat.com> | 2008-05-10 16:53:12 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-05-17 12:53:29 +0200 |
commit | baa6f970bd311b25498bedb6d3554eb0719d2daf (patch) | |
tree | bf5870b3fd2922ba4652800d65ab9ecd76b3e866 /src | |
parent | 3abe5c7f968cb2905ecf2c0920f283e5c60016d2 (diff) | |
download | idutils-baa6f970bd311b25498bedb6d3554eb0719d2daf.tar.gz idutils-baa6f970bd311b25498bedb6d3554eb0719d2daf.tar.bz2 idutils-baa6f970bd311b25498bedb6d3554eb0719d2daf.zip |
make functions static
Diffstat (limited to 'src')
-rw-r--r-- | src/fid.c | 16 | ||||
-rw-r--r-- | src/fnid.c | 3 | ||||
-rw-r--r-- | src/lid.c | 172 | ||||
-rw-r--r-- | src/mkid.c | 102 | ||||
-rw-r--r-- | src/xtokid.c | 8 |
5 files changed, 154 insertions, 147 deletions
@@ -1,5 +1,5 @@ /* fid.c -- list all tokens in the given file(s) - Copyright (C) 1986, 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1986, 1995, 1996, 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 @@ -32,10 +32,10 @@ #include "idfile.h" #include "iduglobal.h" -int get_file_index (char *file_name); -int is_hit (unsigned char const *hits, int file_number); -int is_hit_1 (unsigned char const **hits, int level, int file_number); -void skip_hits (unsigned char const **hits, int level); +static int get_file_index (char *file_name); +static int is_hit (unsigned char const *hits, int file_number); +static int is_hit_1 (unsigned char const **hits, int level, int file_number); +static void skip_hits (unsigned char const **hits, int level); void usage (void); struct idhead idh; @@ -205,7 +205,7 @@ main (int argc, char **argv) return 0; } -int +static int get_file_index (char *file_name) { struct file_link **members; @@ -250,13 +250,13 @@ get_file_index (char *file_name) return idx; } -int +static int is_hit (unsigned char const *hits, int file_number) { return is_hit_1 (&hits, tree8_levels, file_number); } -int +static int is_hit_1 (unsigned char const **hits, int level, int file_number) { int file_hit = 1 << ((file_number >> (3 * --level)) & 7); @@ -1,5 +1,5 @@ /* fnid.c -- report which files constitute an ID database - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 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 @@ -33,7 +33,6 @@ #include "idfile.h" #include "iduglobal.h" -void scan_files (struct idhead *idhp); void scan_member_file (struct member_file const *member); void usage (void); @@ -88,52 +88,56 @@ enum radix void usage (void); static void help_me (void); -void lower_caseify (char *str); -enum key_style parse_key_style (char const *arg); -enum result_style parse_result_style (char const *arg); -query_func_t get_query_func (char *pattern); -report_func_t get_report_func (void); -void report_filenames (char const *name, struct file_link **flinkv); -void report_grep (char const *name, struct file_link **flinkv); -void report_edit (char const *name, struct file_link **flinkv); -void report_nothing (char const *name, struct file_link **flinkv); -int vector_cardinality (void *vector); -int search_flinkv (struct file_link **flinkv); -int query_literal_word (char const *pattern, report_func_t report_func); -int query_literal_prefix (char const *pattern, report_func_t report_func); -int query_regexp (char const *pattern_0, report_func_t report_func); -char const *add_regexp_word_delimiters (char const *pattern_0); -int query_number (char const *pattern, report_func_t report_func); -int query_ambiguous_prefix (unsigned int, report_func_t report_func); -int query_literal_substring (char const *pattern, report_func_t report_func); -void parse_frequency_arg (char const *arg); -int desired_frequency (char const *tok); +static void lower_caseify (char *str); +static enum key_style parse_key_style (char const *arg); +static enum result_style parse_result_style (char const *arg); +static query_func_t get_query_func (char *pattern); +static report_func_t get_report_func (void); +static void report_filenames (char const *name, struct file_link **flinkv); +static void report_grep (char const *name, struct file_link **flinkv); +static void report_edit (char const *name, struct file_link **flinkv); +static void report_nothing (char const *name, struct file_link **flinkv); +static int vector_cardinality (void *vector); +static int search_flinkv (struct file_link **flinkv); +static int query_literal_word (char const *pattern, report_func_t report_func); +static int query_literal_prefix (char const *pattern, report_func_t report_func); +static int query_regexp (char const *pattern_0, report_func_t report_func); +static char const *add_regexp_word_delimiters (char const *pattern_0); +static int query_number (char const *pattern, report_func_t report_func); +static int query_ambiguous_prefix (unsigned int, report_func_t report_func); +static int query_literal_substring (char const *pattern, + report_func_t report_func); +static void parse_frequency_arg (char const *arg); +static int desired_frequency (char const *tok); char *strcasestr (char const *s1, char const *s2); -char const *file_regexp (char const *name_0, char const *left_delimit, char const *right_delimit); -off_t query_binary_search (char const *token); -int is_regexp (char *name); -int has_left_delimiter (char const *pattern); -int has_right_delimiter (char const *pattern); -int file_name_wildcard (char const *re, char const *fn); -int word_match (char const *name_0, char const *line); -int get_radix (char const *str); -int is_number (char const *str); -int stoi (char const *str); -int otoi (char const *str); -int dtoi (char const *str); -int xtoi (char const *str); -unsigned char *tree8_to_bits (unsigned char *bits_vec, unsigned char const *hits_tree8); -void tree8_to_bits_1 (unsigned char **bits_vec, unsigned char const **hits_tree8, int level); -struct file_link **tree8_to_flinkv (unsigned char const *hits_tree8); -struct file_link **bits_to_flinkv (unsigned char const *bits_vec); +static char const *file_regexp (char const *name_0, char const *left_delimit, + char const *right_delimit); +static off_t query_binary_search (char const *token); +static int is_regexp (char *name); +static int has_left_delimiter (char const *pattern); +static int has_right_delimiter (char const *pattern); +static int file_name_wildcard (char const *re, char const *fn); +static int word_match (char const *name_0, char const *line); +static int get_radix (char const *str); +static int is_number (char const *str); +static int stoi (char const *str); +static int otoi (char const *str); +static int dtoi (char const *str); +static int xtoi (char const *str); +static unsigned char *tree8_to_bits (unsigned char *bits_vec, + unsigned char const *hits_tree8); +static void tree8_to_bits_1 (unsigned char **bits_vec, + unsigned char const **hits_tree8, int level); +static struct file_link **tree8_to_flinkv (unsigned char const *hits_tree8); +static struct file_link **bits_to_flinkv (unsigned char const *bits_vec); #if HAVE_TERMIOS_H || HAVE_TERMIO_H || HAVE_SGTTY_H #endif -void savetty (void); -void restoretty (void); -void linetty (void); -void chartty (void); +static void savetty (void); +static void restoretty (void); +static void linetty (void); +static void chartty (void); #if HAVE_TERMIOS_H || HAVE_TERMIO_H || HAVE_SGTTY_H #endif @@ -453,7 +457,7 @@ main (int argc, char **argv) exit (0); } -void +static void lower_caseify (char *str) { while (*str) @@ -463,7 +467,7 @@ lower_caseify (char *str) } } -enum key_style +static enum key_style parse_key_style (char const *arg) { MAYBE_RETURN_PREFIX_MATCH (arg, "none", ks_none); @@ -474,7 +478,7 @@ parse_key_style (char const *arg) return ks_bogus; } -enum result_style +static enum result_style parse_result_style (char const *arg) { MAYBE_RETURN_PREFIX_MATCH (arg, "none", rs_none); @@ -486,7 +490,7 @@ parse_result_style (char const *arg) return rs_bogus; } -query_func_t +static query_func_t get_query_func (char *pattern) { switch (pattern_style) @@ -516,7 +520,7 @@ get_query_func (char *pattern) } } -report_func_t +static report_func_t get_report_func (void) { switch (result_style) @@ -528,7 +532,7 @@ get_report_func (void) } } -void +static void report_filenames (char const *name, struct file_link **flinkv) { if (name && key_style != ks_none) @@ -536,7 +540,7 @@ report_filenames (char const *name, struct file_link **flinkv) print_filenames (flinkv, separator_style); } -void +static void report_grep (char const *name, struct file_link **flinkv) { char line[1<<020]; @@ -623,7 +627,7 @@ get_editor_argv(char *fullstring, int* argc) return argv; } -void +static void report_edit (char const *name, struct file_link **flinkv) { static char *editor; /* editor program name from env */ @@ -779,14 +783,14 @@ editit: } } -void +static void report_nothing (char const *name, struct file_link **flinkv) { if (key_style != ks_none) puts (name); } -int +static int vector_cardinality (void *vector) { void **v = (void **) vector; @@ -797,7 +801,7 @@ vector_cardinality (void *vector) return count; } -int +static int search_flinkv (struct file_link **flinkv) { char pattern[BUFSIZ]; @@ -820,7 +824,7 @@ search_flinkv (struct file_link **flinkv) return -1; } -int +static int query_literal_word (char const *arg, report_func_t report_func) { if (ignore_case_flag) @@ -836,7 +840,7 @@ query_literal_word (char const *arg, report_func_t report_func) return 1; } -int +static int query_literal_prefix (char const *arg, report_func_t report_func) { int count; @@ -871,7 +875,7 @@ query_literal_prefix (char const *arg, report_func_t report_func) return count; } -int +static int query_regexp (char const *pattern_0, report_func_t report_func) { int count; @@ -920,7 +924,7 @@ query_regexp (char const *pattern_0, report_func_t report_func) return count; } -char const * +static char const * add_regexp_word_delimiters (char const *pattern_0) { int length = strlen (pattern_0); @@ -945,7 +949,7 @@ add_regexp_word_delimiters (char const *pattern_0) } } -int +static int query_number (char const *arg, report_func_t report_func) { int count; @@ -990,7 +994,7 @@ query_number (char const *arg, report_func_t report_func) /* Find identifiers that are non-unique within the first `count' characters. */ -int +static int query_ambiguous_prefix (unsigned int limit, report_func_t report_func) { char *old = hits_buf_1; @@ -1046,7 +1050,7 @@ query_ambiguous_prefix (unsigned int limit, report_func_t report_func) return count; } -int +static int query_literal_substring (char const *arg, report_func_t report_func) { int count; @@ -1086,7 +1090,7 @@ query_literal_substring (char const *arg, report_func_t report_func) return count; } -void +static void parse_frequency_arg (char const *arg) { if (strnequ (arg, "..", 2)) @@ -1113,7 +1117,7 @@ parse_frequency_arg (char const *arg) } } -int +static int desired_frequency (char const *tok) { unsigned int count = token_count (tok); @@ -1141,7 +1145,7 @@ strcasestr (char const *s1, char const *s2) in the id database into one suitable for locating the identifiers in files. */ -char const * +static char const * file_regexp (char const *name_0, char const *left_delimit, char const *right_delimit) { static char pat_buf[BUFSIZ]; @@ -1171,7 +1175,7 @@ file_regexp (char const *name_0, char const *left_delimit, char const *right_del return pat_buf; } -off_t +static off_t query_binary_search (char const *token_0) { off_t offset = 0; @@ -1227,7 +1231,7 @@ query_binary_search (char const *token_0) /* Are there any regexp meta-characters in name?? */ -int +static int is_regexp (char *name) { int backslash = 0; @@ -1258,13 +1262,13 @@ is_regexp (char *name) return 0; } -int +static int has_left_delimiter (char const *pattern) { return (*pattern == '^' || strnequ (pattern, "\\<", 2)); } -int +static int has_right_delimiter (char const *pattern) { return (pattern[-1] == '$' || strequ (pattern - 2, "\\>")); @@ -1278,7 +1282,7 @@ has_right_delimiter (char const *pattern) [] - any char in set (if first char is !, any not in set) \ - literal match next char */ -int +static int file_name_wildcard (char const *pattern, char const *fn) { int c; @@ -1349,7 +1353,7 @@ file_name_wildcard (char const *pattern, char const *fn) /* Does `name' occur in `line' delimited by non-alphanumerics?? */ -int +static int word_match (char const *name_0, char const *line) { char const *name = name_0; @@ -1384,7 +1388,7 @@ word_match (char const *name_0, char const *line) apply. In particular, it is impossible to determine the radix of 0, so return all possibilities. */ -int +static int get_radix (char const *str) { if (!isdigit (*str)) @@ -1399,7 +1403,7 @@ get_radix (char const *str) return (*str ? radix_oct : (radix_oct | radix_dec)); } -int +static int is_number (char const *str) { if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) @@ -1419,7 +1423,7 @@ is_number (char const *str) /* Convert an ascii string number to an integer. Determine the radix before converting. */ -int +static int stoi (char const *str) { switch (get_radix (str)) @@ -1439,7 +1443,7 @@ stoi (char const *str) /* Convert an ascii octal number to an integer. */ -int +static int otoi (char const *str) { int n = 0; @@ -1456,7 +1460,7 @@ otoi (char const *str) /* Convert an ascii decimal number to an integer. */ -int +static int dtoi (char const *str) { int n = 0; @@ -1473,7 +1477,7 @@ dtoi (char const *str) /* Convert an ascii hex number to an integer. */ -int +static int xtoi (char const *str) { int n = 0; @@ -1493,7 +1497,7 @@ xtoi (char const *str) return (*str ? -1 : n); } -unsigned char * +static unsigned char * tree8_to_bits (unsigned char *bv_0, unsigned char const *hits_tree8) { unsigned char* bv = bv_0; @@ -1501,7 +1505,7 @@ tree8_to_bits (unsigned char *bv_0, unsigned char const *hits_tree8) return bv_0; } -void +static void tree8_to_bits_1 (unsigned char **bv, unsigned char const **hits_tree8, int level) { int hits = *(*hits_tree8)++; @@ -1522,7 +1526,7 @@ tree8_to_bits_1 (unsigned char **bv, unsigned char const **hits_tree8, int level *(*bv)++ |= hits; } -struct file_link ** +static struct file_link ** bits_to_flinkv (unsigned char const *bv) { int const reserved_flinkv_slots = 3; @@ -1561,7 +1565,7 @@ out: return &flinkv_0[reserved_flinkv_slots]; } -struct file_link ** +static struct file_link ** tree8_to_flinkv (unsigned char const *hits_tree8) { memset (bits_vec, 0, bits_vec_size); @@ -1620,7 +1624,7 @@ struct sgttyb savemode; #if HAVE_TERMIOS_H || HAVE_TERMIO_H -void +static void savetty (void) { GET_TTY_MODES (&savemode); @@ -1639,7 +1643,7 @@ savetty (void) # if HAVE_SGTTY_H -void +static void savetty (void) { # ifdef TIOCGETP @@ -1658,7 +1662,7 @@ savetty (void) # else /* not HAVE_SGTTY_H */ -void +static void savetty (void) { } @@ -1666,19 +1670,19 @@ savetty (void) # endif /* not HAVE_SGTTY_H */ #endif /* not (HAVE_TERMIOS_H || HAVE_TERMIO_H) */ -void +static void restoretty (void) { SET_TTY_MODES (&savemode); } -void +static void linetty (void) { SET_TTY_MODES (&linemode); } -void +static void chartty (void) { SET_TTY_MODES (&charmode); @@ -60,30 +60,34 @@ struct summary void usage (void); static void help_me (void); int main (int argc, char **argv); -int ceil_log_8 (unsigned long n); -int ceil_log_2 (unsigned long n); -void assert_writeable (char const *file_name); -void scan_files (struct idhead *idhp); -void scan_member_file (struct member_file const *member); -void scan_member_file_1 (get_token_func_t get_token, void const *args, FILE *source_FILE); -void report_statistics (void); -void write_id_file (struct idhead *idhp); -unsigned long token_hash_1 (void const *key); -unsigned long token_hash_2 (void const *key); -int token_hash_cmp (void const *x, void const *y); -int token_qsort_cmp (void const *x, void const *y); -void bump_current_hits_signature (void); -void init_hits_signature (int i); -void free_summary_tokens (void); -void summarize (void); -void init_summary (void); -struct summary *make_sibling_summary (struct summary *summary); -int count_vec_size (struct summary *summary, unsigned char const *tail_hits); -int count_buf_size (struct summary *summary, unsigned char const *tail_hits); -void assert_hits (struct summary* summary); -void write_hits (FILE *fp, struct summary *summary, unsigned char const *tail_hits); -void sign_token (struct token *token); -void add_token_to_summary (struct summary *summary, struct token *token); +static int ceil_log_8 (unsigned long n); +static int ceil_log_2 (unsigned long n); +static void assert_writeable (char const *file_name); +static void scan_files (struct idhead *idhp); +static void scan_member_file (struct member_file const *member); +static void scan_member_file_1 (get_token_func_t get_token, + void const *args, FILE *source_FILE); +static void report_statistics (void); +static void write_id_file (struct idhead *idhp); +static unsigned long token_hash_1 (void const *key); +static unsigned long token_hash_2 (void const *key); +static int token_hash_cmp (void const *x, void const *y); +static int token_qsort_cmp (void const *x, void const *y); +static void bump_current_hits_signature (void); +static void init_hits_signature (int i); +static void free_summary_tokens (void); +static void summarize (void); +static void init_summary (void); +static struct summary *make_sibling_summary (struct summary *summary); +static int count_vec_size (struct summary *summary, + unsigned char const *tail_hits); +static int count_buf_size (struct summary *summary, + unsigned char const *tail_hits); +static void assert_hits (struct summary* summary); +static void write_hits (FILE *fp, struct summary *summary, + unsigned char const *tail_hits); +static void sign_token (struct token *token); +static void add_token_to_summary (struct summary *summary, struct token *token); struct hash_table token_table; @@ -126,7 +130,7 @@ usage (void) exit (1); } -static struct option const long_options[] = +static const struct option const long_options[] = { { "file", required_argument, 0, 'f' }, { "output", required_argument, 0, 'o' }, @@ -338,7 +342,7 @@ main (int argc, char **argv) /* Return the integer ceiling of the base-8 logarithm of N. */ -int +static int ceil_log_8 (unsigned long n) { int log_8 = 0; @@ -354,7 +358,7 @@ ceil_log_8 (unsigned long n) /* Return the integer ceiling of the base-2 logarithm of N. */ -int +static int ceil_log_2 (unsigned long n) { int log_2 = 0; @@ -372,7 +376,7 @@ ceil_log_2 (unsigned long n) writable. If it doesn't exist, make sure it can be created. Exit with a diagnostic if this is not so. */ -void +static void assert_writeable (char const *filename) { if (access (filename, 06) < 0) @@ -393,7 +397,7 @@ assert_writeable (char const *filename) /* Iterate over all eligible files (the members of the set of scannable files). Create a tree8 to store the set of files where a token occurs. */ -void +static void scan_files (struct idhead *idhp) { struct member_file **members_0 @@ -443,7 +447,7 @@ scan_files (struct idhead *idhp) /* Open a file and scan it. */ -void +static void scan_member_file (struct member_file const *member) { struct lang_args const *lang_args = member->mf_lang_args; @@ -486,7 +490,7 @@ scan_member_file (struct member_file const *member) /* Iterate over all tokens in the file, and merge the file's tree8 signature into the token table entry. */ -void +static void scan_member_file_1 (get_token_func_t get_token, void const *args, FILE *source_FILE) { struct token **slot; @@ -538,7 +542,7 @@ scan_member_file_1 (get_token_func_t get_token, void const *args, FILE *source_F } } -void +static void report_statistics (void) { printf (_("Name=%ld, "), name_tokens); @@ -569,7 +573,7 @@ report_statistics (void) directory which you have no write access to, so you cannot create the ID file.) */ -void +static void write_id_file (struct idhead *idhp) { struct token **tokens; @@ -666,26 +670,26 @@ write_id_file (struct idhead *idhp) /* Define primary and secondary hash and comparison functions for the token table. */ -unsigned long +static unsigned long token_hash_1 (void const *key) { return_STRING_HASH_1 (TOKEN_NAME ((struct token const *) key)); } -unsigned long +static unsigned long token_hash_2 (void const *key) { return_STRING_HASH_2 (TOKEN_NAME ((struct token const *) key)); } -int +static int token_hash_cmp (void const *x, void const *y) { return_STRING_COMPARE (TOKEN_NAME ((struct token const *) x), TOKEN_NAME ((struct token const *) y)); } -int +static int token_qsort_cmp (void const *x, void const *y) { return_STRING_COMPARE (TOKEN_NAME (*(struct token const *const *) x), @@ -698,7 +702,7 @@ token_qsort_cmp (void const *x, void const *y) /* Advance the tree8 hit signature that corresponds to the file we are now scanning. */ -void +static void bump_current_hits_signature (void) { unsigned char *hits = current_hits_signature; @@ -709,7 +713,7 @@ bump_current_hits_signature (void) /* Initialize the tree8 hit signature for the first file we scan. */ -void +static void init_hits_signature (int i) { unsigned char *hits = current_hits_signature; @@ -722,7 +726,7 @@ init_hits_signature (int i) } } -void +static void free_summary_tokens (void) { struct summary *summary = summary_leaf; @@ -733,7 +737,7 @@ free_summary_tokens (void) } } -void +static void summarize (void) { unsigned char const *hits_sig = current_hits_signature; @@ -772,7 +776,7 @@ summarize (void) summary_leaf = make_sibling_summary (summary_leaf); } -void +static void init_summary (void) { unsigned long size = INIT_TOKENS_SIZE (0); @@ -781,7 +785,7 @@ init_summary (void) summary_root->sum_tokens = xmalloc (sizeof(struct token *) * size); } -struct summary * +static struct summary * make_sibling_summary (struct summary *summary) { struct summary *parent = summary->sum_parent; @@ -822,7 +826,7 @@ make_sibling_summary (struct summary *summary) return summary; } -int +static int count_vec_size (struct summary *summary, unsigned char const *tail_hits) { struct summary **kids; @@ -846,7 +850,7 @@ count_vec_size (struct summary *summary, unsigned char const *tail_hits) } } -int +static int count_buf_size (struct summary *summary, unsigned char const *tail_hits) { struct summary **kids; @@ -867,7 +871,7 @@ count_buf_size (struct summary *summary, unsigned char const *tail_hits) } } -void +static void assert_hits (struct summary* summary) { struct summary **kids = summary->sum_kids; @@ -882,7 +886,7 @@ assert_hits (struct summary* summary) assert_hits (*kids++); } -void +static void write_hits (FILE *fp, struct summary *summary, unsigned char const *tail_hits) { struct summary **kids; @@ -902,7 +906,7 @@ write_hits (FILE *fp, struct summary *summary, unsigned char const *tail_hits) } } -void +static void sign_token (struct token *token) { unsigned char *tok_hits = TOKEN_HITS (token); @@ -931,7 +935,7 @@ sign_token (struct token *token) } } -void +static void add_token_to_summary (struct summary *summary, struct token *token) { size_t size = summary->sum_tokens_size; diff --git a/src/xtokid.c b/src/xtokid.c index 70b327d..e04ac9b 100644 --- a/src/xtokid.c +++ b/src/xtokid.c @@ -31,8 +31,8 @@ #include "idfile.h" #include "iduglobal.h" -void scan_files (struct idhead *idhp); -void scan_member_file (struct member_file const *member); +static void scan_files (struct idhead *idhp); +static void scan_member_file (struct member_file const *member); void usage (void); char const *program_name; @@ -181,7 +181,7 @@ main (int argc, char **argv) return 0; } -void +static void scan_files (struct idhead *idhp) { struct member_file **members_0 @@ -201,7 +201,7 @@ scan_files (struct idhead *idhp) free (members_0); } -void +static void scan_member_file (struct member_file const *member) { struct lang_args const *lang_args = member->mf_lang_args; |