summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2005-12-16 00:57:39 +0000
committerPeter S. Mazinger <ps.m@gmx.net>2005-12-16 00:57:39 +0000
commitc39976972e4d882f00fc0c4cbd7d25964a1f79f1 (patch)
tree17e9cd1a2dd44da4ab14b260ef38f690950eb73b /libc
parenta9e4cbde64ecadb003bb779e096d3f89303c62b1 (diff)
glob/ftw/regex_old reworked. regex_old did not have MBS_SUPPORT enabled
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/ftw/ftw.c18
-rw-r--r--libc/misc/glob/glob.c46
-rw-r--r--libc/misc/glob/glob64.c10
-rw-r--r--libc/misc/regex/regex_old.c38
4 files changed, 75 insertions, 37 deletions
diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c
index 4bd186561..8a6db98d3 100644
--- a/libc/misc/ftw/ftw.c
+++ b/libc/misc/ftw/ftw.c
@@ -36,7 +36,6 @@
#define _GNU_SOURCE
#include <features.h>
-
#if defined (__UCLIBC_HAS_LFS__) && defined L_ftw64
#ifndef L_ftw
#define L_ftw
@@ -59,17 +58,20 @@
#define NFTW_NAME nftw64
#define INO_T ino64_t
#define STAT stat64
-#define LSTAT lstat64
-#define XSTAT stat64
+#define LSTAT __lstat64
+#define XSTAT __stat64
#define FTW_FUNC_T __ftw64_func_t
#define NFTW_FUNC_T __nftw64_func_t
+#define __readdir __readdir64
#else
+#undef __stat
+#undef __lstat
#define FTW_NAME ftw
#define NFTW_NAME nftw
#define INO_T ino_t
#define STAT stat
-#define LSTAT lstat
-#define XSTAT stat
+#define LSTAT __lstat
+#define XSTAT __stat
#define FTW_FUNC_T __ftw_func_t
#define NFTW_FUNC_T __nftw_func_t
#endif
@@ -89,6 +91,12 @@
#include <assert.h>
#include <dirent.h>
+#if 1 /*ndef L_ftw64*/
+extern struct dirent *__readdir (DIR *__dirp) __nonnull ((1)) attribute_hidden;
+#else
+extern struct dirent64 *__readdir64 (DIR *__dirp) __nonnull ((1)) attribute_hidden;
+#endif
+
/* We define PATH_MAX if the system does not provide a definition.
This does not artificially limit any operation. PATH_MAX is simply
used as a guesstimate for the expected maximal path length.
diff --git a/libc/misc/glob/glob.c b/libc/misc/glob/glob.c
index aa90ae418..6c1e0351b 100644
--- a/libc/misc/glob/glob.c
+++ b/libc/misc/glob/glob.c
@@ -50,11 +50,16 @@ static int prefix_array __P ((const char *prefix, char **array, size_t n,
static int collated_compare __P ((const __ptr_t, const __ptr_t));
#ifdef __GLOB64
-extern int glob_pattern_p(const char *pattern, int quote);
+extern int __glob_pattern_p(const char *pattern, int quote) attribute_hidden;
#else
+extern struct dirent *__readdir (DIR *__dirp) __nonnull ((1)) attribute_hidden;
+extern int __glob (__const char *__restrict __pattern, int __flags,
+ int (*__errfunc) (__const char *, int),
+ glob_t *__restrict __pglob) __THROW attribute_hidden;
+extern void __globfree (glob_t *__pglob) __THROW attribute_hidden;
/* 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)
+int attribute_hidden __glob_pattern_p(const char *pattern, int quote)
{
const char *p;
int open = 0;
@@ -83,6 +88,7 @@ int glob_pattern_p(const char *pattern, int quote)
return 0;
}
+strong_alias(__glob_pattern_p,glob_pattern_p)
#endif
@@ -94,8 +100,8 @@ int glob_pattern_p(const char *pattern, int quote)
`glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
-int
-glob (pattern, flags, errfunc, pglob)
+int attribute_hidden
+__glob (pattern, flags, errfunc, pglob)
const char *pattern;
int flags;
int (*errfunc) __P ((const char *, int));
@@ -140,7 +146,7 @@ glob (pattern, flags, errfunc, pglob)
if (filename[0] == '\0' && dirlen > 1)
/* "pattern/". Expand "pattern", appending slashes. */
{
- int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
+ int val = __glob (dirname, flags | GLOB_MARK, errfunc, pglob);
if (val == 0)
pglob->gl_flags = (pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK);
return val;
@@ -154,7 +160,7 @@ glob (pattern, flags, errfunc, pglob)
oldcount = pglob->gl_pathc;
- if (glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
+ if (__glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
{
/* The directory name contains metacharacters, so we
have to glob for the directory, and then glob for
@@ -162,7 +168,7 @@ glob (pattern, flags, errfunc, pglob)
glob_t dirs;
register int i;
- status = glob (dirname,
+ status = __glob (dirname,
((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE)) |
GLOB_NOSORT),
errfunc, &dirs);
@@ -183,8 +189,8 @@ glob (pattern, flags, errfunc, pglob)
if (interrupt_state)
{
- globfree (&dirs);
- globfree (&files);
+ __globfree (&dirs);
+ __globfree (&files);
return GLOB_ABEND;
}
}
@@ -200,8 +206,8 @@ glob (pattern, flags, errfunc, pglob)
if (status != 0)
{
- globfree (&dirs);
- globfree (pglob);
+ __globfree (&dirs);
+ __globfree (pglob);
return status;
}
@@ -211,8 +217,8 @@ glob (pattern, flags, errfunc, pglob)
pglob->gl_pathc - oldcount,
flags & GLOB_MARK))
{
- globfree (&dirs);
- globfree (pglob);
+ __globfree (&dirs);
+ __globfree (pglob);
return GLOB_NOSPACE;
}
}
@@ -271,7 +277,7 @@ glob (pattern, flags, errfunc, pglob)
pglob->gl_pathc - oldcount,
flags & GLOB_MARK))
{
- globfree (pglob);
+ __globfree (pglob);
return GLOB_NOSPACE;
}
}
@@ -297,11 +303,16 @@ glob (pattern, flags, errfunc, pglob)
return 0;
}
+#ifdef __GLOB64
+strong_alias(__glob64,glob64)
+#else
+strong_alias(__glob,glob)
+#endif
/* Free storage allocated in PGLOB by a previous `glob' call. */
-void
-globfree (pglob)
+void attribute_hidden
+__globfree (pglob)
register glob_t *pglob;
{
if (pglob->gl_pathv != NULL)
@@ -313,6 +324,7 @@ globfree (pglob)
free ((__ptr_t) pglob->gl_pathv);
}
}
+strong_alias(__globfree,globfree)
/* Do a collated comparison of A and B. */
@@ -409,7 +421,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
return GLOB_ABORTED;
}
- meta = glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
+ meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
if (meta)
flags |= GLOB_MAGCHAR;
diff --git a/libc/misc/glob/glob64.c b/libc/misc/glob/glob64.c
index 17e6838aa..f0c65abe0 100644
--- a/libc/misc/glob/glob64.c
+++ b/libc/misc/glob/glob64.c
@@ -18,12 +18,22 @@
#include <glob.h>
#include <sys/stat.h>
+extern struct dirent64 *__readdir64 (DIR *__dirp) __nonnull ((1)) attribute_hidden;
+extern int __glob64 (__const char *__restrict __pattern, int __flags,
+ int (*__errfunc) (__const char *, int),
+ glob64_t *__restrict __pglob) __THROW attribute_hidden;
+extern void __globfree (glob_t *__pglob) __THROW attribute_hidden;
+extern void __globfree64 (glob64_t *__pglob) __THROW attribute_hidden;
+
#define dirent dirent64
#define __readdir(dirp) __readdir64(dirp)
#define glob_t glob64_t
+#define __glob(pattern, flags, errfunc, pglob) \
+ __glob64 (pattern, flags, errfunc, pglob)
#define glob(pattern, flags, errfunc, pglob) \
glob64 (pattern, flags, errfunc, pglob)
+#define __globfree(pglob) __globfree64 (pglob)
#define globfree(pglob) globfree64 (pglob)
#undef stat
diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c
index 6bb319acd..b995cabfa 100644
--- a/libc/misc/regex/regex_old.c
+++ b/libc/misc/regex/regex_old.c
@@ -35,12 +35,15 @@
#define iswctype __iswctype
#define iswalnum __iswalnum
#define printf __printf
+#define btowc __btowc
/* To exclude some unwanted junk.... */
-#undef _LIBC
#undef emacs
#define _REGEX_RE_COMP
#include <features.h>
+#ifdef __UCLIBC__
+# undef _LIBC
+#endif
#include <stdlib.h>
#include <string.h>
#define STDC_HEADERS
@@ -88,7 +91,7 @@ extern void *__mempcpy (void *__restrict __dest,
# include <wctype.h>
# endif
-# ifdef _LIBC
+# if defined _LIBC || defined __UCLIBC__
/* We have to keep the namespace clean. */
# define regfree(preg) __regfree (preg)
# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
@@ -113,11 +116,13 @@ extern void *__mempcpy (void *__restrict __dest,
# define btowc __btowc
/* We are also using some library internals. */
+# ifndef __UCLIBC__
# include <locale/localeinfo.h>
# include <locale/elem-hash.h>
# include <langinfo.h>
# include <locale/coll-lookup.h>
# endif
+# endif
/* This is for other GNU distributions with internationalized messages. */
# if HAVE_LIBINTL_H || defined _LIBC
@@ -217,6 +222,9 @@ char *realloc ();
# endif
/* Get the interface, including the syntax bits. */
+# ifdef __UCLIBC__
+# include "_regex.h"
+# endif
# include <regex.h>
/* isalpha etc. are used for the character classes. */
@@ -1380,7 +1388,7 @@ re_set_syntax (syntax)
# endif /* DEBUG */
return ret;
}
-# ifdef _LIBC
+# if defined _LIBC || defined __UCLIBC__
weak_alias (__re_set_syntax, re_set_syntax)
# endif
@@ -5000,7 +5008,7 @@ re_compile_fastmap (bufp)
# endif
return byte_re_compile_fastmap(bufp);
} /* re_compile_fastmap */
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__re_compile_fastmap, re_compile_fastmap)
#endif
@@ -5039,7 +5047,7 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
regs->start = regs->end = (regoff_t *) 0;
}
}
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__re_set_registers, re_set_registers)
#endif
@@ -5058,7 +5066,7 @@ re_search (bufp, string, size, startpos, range, regs)
return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
regs, size);
}
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__re_search, re_search)
#endif
@@ -5103,7 +5111,7 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
return byte_re_search_2 (bufp, string1, size1, string2, size2, startpos,
range, regs, stop);
} /* re_search_2 */
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__re_search_2, re_search_2)
#endif
@@ -5562,7 +5570,7 @@ re_match (bufp, string, size, pos, regs)
# endif
return result;
}
-# ifdef _LIBC
+# if defined _LIBC || defined __UCLIBC__
weak_alias (__re_match, re_match)
# endif
#endif /* not emacs */
@@ -5623,7 +5631,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
#endif
return result;
}
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__re_match_2, re_match_2)
#endif
@@ -7962,7 +7970,7 @@ re_compile_pattern (pattern, length, bufp)
return NULL;
return gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
}
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__re_compile_pattern, re_compile_pattern)
#endif
@@ -8029,7 +8037,7 @@ re_comp (s)
int
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_function
#endif
re_exec (s)
@@ -8158,7 +8166,7 @@ regcomp (preg, pattern, cflags)
return (int) ret;
}
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__regcomp, regcomp)
#endif
@@ -8236,7 +8244,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
/* We want zero return to mean success, unlike `re_search'. */
return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
}
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__regexec, regexec)
#endif
@@ -8284,7 +8292,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
return msg_size;
}
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__regerror, regerror)
#endif
@@ -8311,7 +8319,7 @@ regfree (preg)
free (preg->translate);
preg->translate = NULL;
}
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
weak_alias (__regfree, regfree)
#endif