This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

intl patches (15)



This patch adds support for non-POSIX pathname systems. Needed for platforms
like DOS, OS/2, Windows (excluding Cygwin).

It also reduces the running time for a very long getcwd() from quadratic to
linear.


2001-03-04  Bruno Haible  <haible@clisp.cons.org>
 
	* intl/dcigettext.c (ISSLASH, HAS_DEVICE, IS_ABSOLUTE_PATH,
	IS_PATH_WITH_DIR): New macros.
	(DCIGETTEXT): Use IS_ABSOLUTE_PATH and IS_PATH_WITH_DIR. Increment
	path_max proportionally.
	* intl/loadinfo.h (PATH_SEPARATOR): New macro.
	* intl/l10nflist.c (_nl_make_l10nflist): Use PATH_SEPARATOR instead of
	':'.
	* intl/localealias.c (_nl_expand_alias): Likewise.

diff -r -c3 intl/dcigettext.c intl-98/dcigettext.c
*** intl/dcigettext.c	Sat Mar 17 19:35:37 2001
--- intl/dcigettext.c	Sat Mar 17 14:40:20 2001
***************
*** 191,196 ****
--- 191,218 ----
  # define PATH_MAX _POSIX_PATH_MAX
  #endif
  
+ /* Pathname support.
+    ISSLASH(C)           tests whether C is a directory separator character.
+    IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
+                         it may be concatenated to a directory pathname.
+    IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
+  */
+ #if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
+   /* Win32, OS/2, DOS */
+ # define ISSLASH(C) ((C) == '/' || (C) == '\\')
+ # define HAS_DEVICE(P) \
+     ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
+      && (P)[1] == ':')
+ # define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
+ # define IS_PATH_WITH_DIR(P) \
+     (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
+ #else
+   /* Unix */
+ # define ISSLASH(C) ((C) == '/')
+ # define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
+ # define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
+ #endif
+ 
  /* XPG3 defines the result of `setlocale (category, NULL)' as:
     ``Directs `setlocale()' to query `category' and return the current
       setting of `local'.''
***************
*** 466,472 ****
  
    if (binding == NULL)
      dirname = (char *) _nl_default_dirname;
!   else if (binding->dirname[0] == '/')
      dirname = binding->dirname;
    else
      {
--- 488,494 ----
  
    if (binding == NULL)
      dirname = (char *) _nl_default_dirname;
!   else if (IS_ABSOLUTE_PATH (binding->dirname))
      dirname = binding->dirname;
    else
      {
***************
*** 478,493 ****
        path_max = (unsigned int) PATH_MAX;
        path_max += 2;		/* The getcwd docs say to do this.  */
  
!       dirname = (char *) alloca (path_max + dirname_len);
!       ADD_BLOCK (block_list, dirname);
! 
!       __set_errno (0);
!       while ((ret = getcwd (dirname, path_max)) == NULL && errno == ERANGE)
  	{
- 	  path_max += PATH_INCR;
  	  dirname = (char *) alloca (path_max + dirname_len);
  	  ADD_BLOCK (block_list, dirname);
  	  __set_errno (0);
  	}
  
        if (ret == NULL)
--- 500,517 ----
        path_max = (unsigned int) PATH_MAX;
        path_max += 2;		/* The getcwd docs say to do this.  */
  
!       for (;;)
  	{
  	  dirname = (char *) alloca (path_max + dirname_len);
  	  ADD_BLOCK (block_list, dirname);
+ 
  	  __set_errno (0);
+ 	  ret = getcwd (dirname, path_max);
+ 	  if (ret != NULL || errno != ERANGE)
+ 	    break;
+ 
+ 	  path_max += path_max / 2;
+ 	  path_max += PATH_INCR;
  	}
  
        if (ret == NULL)
***************
*** 548,554 ****
  
  	  /* When this is a SUID binary we must not allow accessing files
  	     outside the dedicated directories.  */
! 	  if (ENABLE_SECURE && strchr (single_locale, '/') != NULL)
  	    /* Ingore this entry.  */
  	    continue;
  	}
--- 572,578 ----
  
  	  /* When this is a SUID binary we must not allow accessing files
  	     outside the dedicated directories.  */
! 	  if (ENABLE_SECURE && IS_PATH_WITH_DIR (single_locale))
  	    /* Ingore this entry.  */
  	    continue;
  	}
diff -r -c3 intl/l10nflist.c intl-98/l10nflist.c
*** intl/l10nflist.c	Sat Mar 17 18:31:03 2001
--- intl/l10nflist.c	Sat Mar 17 14:37:28 2001
***************
*** 229,235 ****
  
    /* Construct file name.  */
    memcpy (abs_filename, dirlist, dirlist_len);
!   __argz_stringify (abs_filename, dirlist_len, ':');
    cp = abs_filename + (dirlist_len - 1);
    *cp++ = '/';
    cp = stpcpy (cp, language);
--- 229,235 ----
  
    /* Construct file name.  */
    memcpy (abs_filename, dirlist, dirlist_len);
!   __argz_stringify (abs_filename, dirlist_len, PATH_SEPARATOR);
    cp = abs_filename + (dirlist_len - 1);
    *cp++ = '/';
    cp = stpcpy (cp, language);
diff -r -c3 intl/loadinfo.h intl-98/loadinfo.h
*** intl/loadinfo.h	Fri Jan  5 15:10:57 2001
--- intl/loadinfo.h	Sat Mar 17 14:12:46 2001
***************
*** 1,4 ****
! /* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
  
--- 1,4 ----
! /* Copyright (C) 1996-1999, 2000, 2001 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
  
***************
*** 38,43 ****
--- 38,52 ----
  # define __builtin_expect(expr, val) (expr)
  #endif
  
+ /* Separator in PATH like lists of pathnames.  */
+ #if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
+   /* Win32, OS/2, DOS */
+ # define PATH_SEPARATOR ';'
+ #else
+   /* Unix */
+ # define PATH_SEPARATOR ':'
+ #endif
+ 
  /* Encoding of locale name parts.  */
  #define CEN_REVISION		1
  #define CEN_SPONSOR		2
diff -r -c3 intl/localealias.c intl-98/localealias.c
*** intl/localealias.c	Sat Mar 17 19:26:46 2001
--- intl/localealias.c	Sat Mar 17 14:52:01 2001
***************
*** 181,191 ****
  	{
  	  const char *start;
  
! 	  while (locale_alias_path[0] == ':')
  	    ++locale_alias_path;
  	  start = locale_alias_path;
  
! 	  while (locale_alias_path[0] != '\0' && locale_alias_path[0] != ':')
  	    ++locale_alias_path;
  
  	  if (start < locale_alias_path)
--- 181,192 ----
  	{
  	  const char *start;
  
! 	  while (locale_alias_path[0] == PATH_SEPARATOR)
  	    ++locale_alias_path;
  	  start = locale_alias_path;
  
! 	  while (locale_alias_path[0] != '\0'
! 		 && locale_alias_path[0] != PATH_SEPARATOR)
  	    ++locale_alias_path;
  
  	  if (start < locale_alias_path)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]