diff options
author | Eric Andersen <andersen@codepoet.org> | 2006-07-05 23:01:52 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2006-07-05 23:01:52 +0000 |
commit | 9aa22cc9745be04035873b26f82adc4581e602b4 (patch) | |
tree | 668f3cb4f9b2053f42632b47ad9191fee4ca3c2c | |
parent | e3c51c27098bbb8989c3d6c14fbc09af5ca06103 (diff) |
remove jump relocs, with minor related cleanups
-rw-r--r-- | libc/misc/glob/glob.c | 83 | ||||
-rw-r--r-- | libc/misc/glob/glob64.c | 10 |
2 files changed, 53 insertions, 40 deletions
diff --git a/libc/misc/glob/glob.c b/libc/misc/glob/glob.c index f8200757f..49d48e2da 100644 --- a/libc/misc/glob/glob.c +++ b/libc/misc/glob/glob.c @@ -31,22 +31,51 @@ #include <fnmatch.h> #include <glob.h> -libc_hidden_proto(memcpy) -libc_hidden_proto(strcat) -libc_hidden_proto(strcmp) -libc_hidden_proto(strlen) -libc_hidden_proto(strrchr) -libc_hidden_proto(strcoll) -libc_hidden_proto(opendir) libc_hidden_proto(closedir) libc_hidden_proto(fnmatch) +libc_hidden_proto(free) +libc_hidden_proto(malloc) +libc_hidden_proto(memcpy) +libc_hidden_proto(mempcpy) +libc_hidden_proto(opendir) libc_hidden_proto(qsort) +libc_hidden_proto(readdir) +libc_hidden_proto(readdir64) +libc_hidden_proto(realloc) +libc_hidden_proto(stat) +libc_hidden_proto(stat64) +libc_hidden_proto(strchr) +libc_hidden_proto(strcoll) +libc_hidden_proto(strcpy) +libc_hidden_proto(strdup) +libc_hidden_proto(strlen) +libc_hidden_proto(strrchr) + #ifdef ENABLE_GLOB_TILDE_EXPANSION #include <pwd.h> libc_hidden_proto(getpwnam_r) #endif +#ifdef COMPILE_GLOB64 +#undef stat +#define stat stat64 +#define struct_stat64 struct stat64 +#define __stat64(fname, buf) stat64 (fname, buf) +#define dirent dirent64 +#define __readdir readdir64 +#define __readdir64 readdir64 +#define glob_t glob64_t +#define glob(pattern, flags, errfunc, pglob) glob64 (pattern, flags, errfunc, pglob) +#define globfree(pglob) globfree64 (pglob) +#else +#define __readdir readdir +#define __readdir64 readdir64 +#define struct_stat64 struct stat +#define __stat64(fname, buf) stat (fname, buf) +#endif + + /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available if the `d_type' member for `struct dirent' is available. HAVE_STRUCT_DIRENT_D_TYPE plays the same role in GNULIB. */ @@ -99,29 +128,16 @@ extern __ptr_t (*__glob_opendir_hook) (const char *directory) attribute_hidden; extern void (*__glob_closedir_hook) (__ptr_t stream) attribute_hidden; extern const char *(*__glob_readdir_hook) (__ptr_t stream) attribute_hidden; -extern int __collated_compare (const void *a, const void *b) attribute_hidden; -extern int __prefix_array (const char *dirname, char **array, size_t n) attribute_hidden; +extern int collated_compare (const void *a, const void *b) attribute_hidden; +extern int prefix_array (const char *dirname, char **array, size_t n) attribute_hidden; #if defined ENABLE_GLOB_BRACE_EXPANSION extern const char *__next_brace_sub (const char *cp, int flags) attribute_hidden; #endif libc_hidden_proto(glob_pattern_p) -#ifdef COMPILE_GLOB64 -libc_hidden_proto(glob64) -libc_hidden_proto(globfree64) -libc_hidden_proto(readdir64) -#define __readdir readdir64 -#define __readdir64 readdir64 -#define struct_stat64 struct stat64 -#define __stat64(fname, buf) stat64 (fname, buf) -#else -libc_hidden_proto(glob) -libc_hidden_proto(globfree) -#define __readdir readdir -#define __readdir64 readdir64 -#define struct_stat64 struct stat -#define __stat64(fname, buf) stat (fname, buf) -libc_hidden_proto(readdir) +libc_hidden_proto(collated_compare) +libc_hidden_proto(prefix_array) +#ifndef COMPILE_GLOB64 /* Return nonzero if PATTERN contains any metacharacters. Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ int glob_pattern_p(const char *pattern, int quote) @@ -157,7 +173,7 @@ libc_hidden_def(glob_pattern_p) /* Do a collated comparison of A and B. */ -int __collated_compare (const void *a, const void *b) +int collated_compare (const void *a, const void *b) { const char *const s1 = *(const char *const * const) a; const char *const s2 = *(const char *const * const) b; @@ -178,7 +194,7 @@ int __collated_compare (const void *a, const void *b) unless DIRNAME is just "/". Each old element of ARRAY is freed. If ADD_SLASH is non-zero, allocate one character more than necessary, so that a slash can be appended later. */ -int __prefix_array (const char *dirname, char **array, size_t n) +int prefix_array (const char *dirname, char **array, size_t n) { register size_t i; size_t dirlen = strlen (dirname); @@ -477,6 +493,13 @@ static int glob_in_dir (const char *pattern, const char *directory, int flags, return GLOB_NOSPACE; } +#ifdef COMPILE_GLOB64 +libc_hidden_proto(glob64) +libc_hidden_proto(globfree64) +#else +libc_hidden_proto(glob) +libc_hidden_proto(globfree) +#endif /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. If a directory cannot be opened or read and ERRFUNC is not nil, @@ -930,7 +953,7 @@ glob (pattern, flags, errfunc, pglob) } /* Stick the directory on the front of each name. */ - if (__prefix_array (dirs.gl_pathv[i], + if (prefix_array (dirs.gl_pathv[i], &pglob->gl_pathv[old_pathc + pglob->gl_offs], pglob->gl_pathc - old_pathc)) { @@ -999,7 +1022,7 @@ glob (pattern, flags, errfunc, pglob) if (dirlen > 0) { /* Stick the directory on the front of each name. */ - if (__prefix_array (dirname, + if (prefix_array (dirname, &pglob->gl_pathv[old_pathc + pglob->gl_offs], pglob->gl_pathc - old_pathc)) { @@ -1042,7 +1065,7 @@ glob (pattern, flags, errfunc, pglob) /* Sort the vector. */ qsort (&pglob->gl_pathv[oldcount], pglob->gl_pathc + pglob->gl_offs - oldcount, - sizeof (char *), __collated_compare); + sizeof (char *), collated_compare); } return 0; diff --git a/libc/misc/glob/glob64.c b/libc/misc/glob/glob64.c index 3ca7a93f8..b84af92b3 100644 --- a/libc/misc/glob/glob64.c +++ b/libc/misc/glob/glob64.c @@ -10,16 +10,6 @@ #include <glob.h> #include <sys/stat.h> -#define dirent dirent64 - -#define glob_t glob64_t -#define glob(pattern, flags, errfunc, pglob) \ - glob64 (pattern, flags, errfunc, pglob) -#define globfree(pglob) globfree64 (pglob) - -#undef stat -#define stat stat64 - #define COMPILE_GLOB64 1 #include "glob.c" |