svn commit: trunk/uClibc/libc/misc: ftw glob regex

psm at uclibc.org psm at uclibc.org
Fri Dec 16 00:58:04 UTC 2005


Author: psm
Date: 2005-12-15 16:57:39 -0800 (Thu, 15 Dec 2005)
New Revision: 12916

Log:
glob/ftw/regex_old reworked. regex_old did not have MBS_SUPPORT enabled

Modified:
   trunk/uClibc/libc/misc/ftw/ftw.c
   trunk/uClibc/libc/misc/glob/glob.c
   trunk/uClibc/libc/misc/glob/glob64.c
   trunk/uClibc/libc/misc/regex/regex_old.c


Changeset:
Modified: trunk/uClibc/libc/misc/ftw/ftw.c
===================================================================
--- trunk/uClibc/libc/misc/ftw/ftw.c	2005-12-16 00:51:04 UTC (rev 12915)
+++ trunk/uClibc/libc/misc/ftw/ftw.c	2005-12-16 00:57:39 UTC (rev 12916)
@@ -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.

Modified: trunk/uClibc/libc/misc/glob/glob.c
===================================================================
--- trunk/uClibc/libc/misc/glob/glob.c	2005-12-16 00:51:04 UTC (rev 12915)
+++ trunk/uClibc/libc/misc/glob/glob.c	2005-12-16 00:57:39 UTC (rev 12916)
@@ -50,11 +50,16 @@
 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 @@
 
     return 0;
 }
+strong_alias(__glob_pattern_p,glob_pattern_p)
 #endif
 
 
@@ -94,8 +100,8 @@
    `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 @@
   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 @@
 
   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_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 @@
 
 	    if (interrupt_state)
 	      {
-		globfree (&dirs);
-		globfree (&files);
+		__globfree (&dirs);
+		__globfree (&files);
 		return GLOB_ABEND;
 	      }
 	  }
@@ -200,8 +206,8 @@
 
 	  if (status != 0)
 	    {
-	      globfree (&dirs);
-	      globfree (pglob);
+	      __globfree (&dirs);
+	      __globfree (pglob);
 	      return status;
 	    }
 
@@ -211,8 +217,8 @@
 			    pglob->gl_pathc - oldcount,
 			    flags & GLOB_MARK))
 	    {
-	      globfree (&dirs);
-	      globfree (pglob);
+	      __globfree (&dirs);
+	      __globfree (pglob);
 	      return GLOB_NOSPACE;
 	    }
 	}
@@ -271,7 +277,7 @@
 			    pglob->gl_pathc - oldcount,
 			    flags & GLOB_MARK))
 	    {
-	      globfree (pglob);
+	      __globfree (pglob);
 	      return GLOB_NOSPACE;
 	    }
 	}
@@ -297,11 +303,16 @@
 
   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 @@
       free ((__ptr_t) pglob->gl_pathv);
     }
 }
+strong_alias(__globfree,globfree)
 
 
 /* Do a collated comparison of A and B.  */
@@ -409,7 +421,7 @@
 	return GLOB_ABORTED;
     }
 
-  meta = glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
+  meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
 
   if (meta)
     flags |= GLOB_MAGCHAR;

Modified: trunk/uClibc/libc/misc/glob/glob64.c
===================================================================
--- trunk/uClibc/libc/misc/glob/glob64.c	2005-12-16 00:51:04 UTC (rev 12915)
+++ trunk/uClibc/libc/misc/glob/glob64.c	2005-12-16 00:57:39 UTC (rev 12916)
@@ -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

Modified: trunk/uClibc/libc/misc/regex/regex_old.c
===================================================================
--- trunk/uClibc/libc/misc/regex/regex_old.c	2005-12-16 00:51:04 UTC (rev 12915)
+++ trunk/uClibc/libc/misc/regex/regex_old.c	2005-12-16 00:57:39 UTC (rev 12916)
@@ -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 @@
 #  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 @@
 #  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 @@
 # 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 @@
 # endif /* DEBUG */
   return ret;
 }
-# ifdef _LIBC
+# if defined _LIBC || defined __UCLIBC__
 weak_alias (__re_set_syntax, re_set_syntax)
 # endif
 
@@ -5000,7 +5008,7 @@
 # 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 @@
       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 @@
   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 @@
     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 @@
 # endif
   return result;
 }
-# ifdef _LIBC
+# if defined _LIBC || defined __UCLIBC__
 weak_alias (__re_match, re_match)
 # endif
 #endif /* not emacs */
@@ -5623,7 +5631,7 @@
 #endif
   return result;
 }
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
 weak_alias (__re_match_2, re_match_2)
 #endif
 
@@ -7962,7 +7970,7 @@
     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 @@
 
 
 int
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
 weak_function
 #endif
 re_exec (s)
@@ -8158,7 +8166,7 @@
 
   return (int) ret;
 }
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
 weak_alias (__regcomp, regcomp)
 #endif
 
@@ -8236,7 +8244,7 @@
   /* 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 @@
 
   return msg_size;
 }
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
 weak_alias (__regerror, regerror)
 #endif
 
@@ -8311,7 +8319,7 @@
     free (preg->translate);
   preg->translate = NULL;
 }
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
 weak_alias (__regfree, regfree)
 #endif
 




More information about the uClibc-cvs mailing list