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]
Other format: [Raw text]

FreeBSD port (19): localedef calling fopen("")


Hi,

When run during "make check", localedef calls repertoire_read(""),
which calls fopen(""), which calls open(""). Since we don't use repertoire
maps any more, the desired behaviour is to return a NULL repertoire pointer.
Instead the code makes useless system calls. On FreeBSD, the open("")
even succeeds, and the code attempts to parse the contents of the current
directory as a repertoire map - ouch.

The fix is to treat repertoire_read("") like repertoire_read(NULL). This
saves CPU cycles on every platform.


2002-07-06  Bruno Haible  <bruno@clisp.org>

	* locale/programs/ld-collate.c (collate_read): Avoid calling
	repertoire_read with an empty filename.
	* locale/programs/ld-ctype.c (ctype_finish, ctype_read): Likewise.
	* locale/programs/ld-messages.c (messages_read): Likewise.
	* locale/programs/ld-monetary.c (monetary_read): Likewise.
	* locale/programs/ld-numeric.c (numeric_read): Likewise.
	* locale/programs/ld-time.c (time_read): Likewise.

diff -r -c3 glibc-20020627.bak/locale/programs/ld-collate.c glibc-20020627/locale/programs/ld-collate.c
--- glibc-20020627.bak/locale/programs/ld-collate.c	Sat May  4 00:00:20 2002
+++ glibc-20020627/locale/programs/ld-collate.c	Fri Jul  5 01:17:05 2002
@@ -2603,7 +2603,7 @@
   int state = 0;
 
   /* Get the repertoire we have to use.  */
-  if (repertoire_name != NULL)
+  if (repertoire_name != NULL && repertoire_name[0] != '\0')
     repertoire = repertoire_read (repertoire_name);
 
   /* The rest of the line containing `LC_COLLATE' must be free.  */
diff -r -c3 glibc-20020627.bak/locale/programs/ld-ctype.c glibc-20020627/locale/programs/ld-ctype.c
--- glibc-20020627.bak/locale/programs/ld-ctype.c	Sat Apr 20 02:38:15 2002
+++ glibc-20020627/locale/programs/ld-ctype.c	Fri Jul  5 01:17:05 2002
@@ -421,7 +421,7 @@
 
       /* Get the repertoire we have to use.  */
       repertoire_name = locale->repertoire_name ?: repertoire_global;
-      if (repertoire_name != NULL)
+      if (repertoire_name != NULL && repertoire_name[0] != '\0')
 	ctype->repertoire = repertoire_read (repertoire_name);
     }
 
@@ -2183,7 +2183,7 @@
   struct localedef_t *copy_locale = NULL;
 
   /* Get the repertoire we have to use.  */
-  if (repertoire_name != NULL)
+  if (repertoire_name != NULL && repertoire_name[0] != '\0')
     repertoire = repertoire_read (repertoire_name);
 
   /* The rest of the line containing `LC_CTYPE' must be free.  */
diff -r -c3 glibc-20020627.bak/locale/programs/ld-messages.c glibc-20020627/locale/programs/ld-messages.c
--- glibc-20020627.bak/locale/programs/ld-messages.c	Sat Apr 20 02:38:15 2002
+++ glibc-20020627/locale/programs/ld-messages.c	Fri Jul  5 01:17:05 2002
@@ -243,7 +243,7 @@
   enum token_t nowtok;
 
   /* Get the repertoire we have to use.  */
-  if (repertoire_name != NULL)
+  if (repertoire_name != NULL && repertoire_name[0] != '\0')
     repertoire = repertoire_read (repertoire_name);
 
   /* The rest of the line containing `LC_MESSAGES' must be free.  */
diff -r -c3 glibc-20020627.bak/locale/programs/ld-monetary.c glibc-20020627/locale/programs/ld-monetary.c
--- glibc-20020627.bak/locale/programs/ld-monetary.c	Sat Apr 20 02:38:15 2002
+++ glibc-20020627/locale/programs/ld-monetary.c	Fri Jul  5 01:17:05 2002
@@ -636,7 +636,7 @@
   enum token_t nowtok;
 
   /* Get the repertoire we have to use.  */
-  if (repertoire_name != NULL)
+  if (repertoire_name != NULL && repertoire_name[0] != '\0')
     repertoire = repertoire_read (repertoire_name);
 
   /* The rest of the line containing `LC_MONETARY' must be free.  */
diff -r -c3 glibc-20020627.bak/locale/programs/ld-numeric.c glibc-20020627/locale/programs/ld-numeric.c
--- glibc-20020627.bak/locale/programs/ld-numeric.c	Sat Apr 20 02:38:15 2002
+++ glibc-20020627/locale/programs/ld-numeric.c	Fri Jul  5 01:17:05 2002
@@ -204,7 +204,7 @@
   enum token_t nowtok;
 
   /* Get the repertoire we have to use.  */
-  if (repertoire_name != NULL)
+  if (repertoire_name != NULL && repertoire_name[0] != '\0')
     repertoire = repertoire_read (repertoire_name);
 
   /* The rest of the line containing `LC_NUMERIC' must be free.  */
diff -r -c3 glibc-20020627.bak/locale/programs/ld-time.c glibc-20020627/locale/programs/ld-time.c
--- glibc-20020627.bak/locale/programs/ld-time.c	Sat Apr 20 02:38:16 2002
+++ glibc-20020627/locale/programs/ld-time.c	Fri Jul  5 01:17:05 2002
@@ -923,7 +923,7 @@
   size_t cnt;
 
   /* Get the repertoire we have to use.  */
-  if (repertoire_name != NULL)
+  if (repertoire_name != NULL && repertoire_name[0] != '\0')
     repertoire = repertoire_read (repertoire_name);
 
   /* The rest of the line containing `LC_TIME' must be free.  */


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