Hi!

As discussed in the PR, libjava fails to build against latest
glibc, because prims.cc is compiled with -fnon-call-exceptions,
uses ctype.h and libgcj isn't linked against -lsupc++ or -lstdc++.
isspace in latest glibc is a throw() inline that calls a throw()
function pointer.  Unfortunately, with -fnon-call-exceptions
the compiler doesn't have a guarantee that the function pointer
that is being called is always valid (it is in glibc) and thus adds
a __cxa_call_unexpected call if the call would throw and that symbol
isn't satisfied during linking of libgcj and apps against it.

In all locales on my box isspace is equivalent to POSIX locale isspace
(while iswspace is true also for various other characters, they are
always multi-byte and thus isspace which works on single byte only
isn't true for them), so this patch effectively makes no difference
in libgcj behavior.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.6?

2011-11-23  Jakub Jelinek  <ja...@redhat.com>

        PR bootstrap/50888
        * prims.cc: Don't include ctype.h.
        (c_isspace): Define.
        (next_property_key, next_property_value): Use it instead
        of isspace.

--- libjava/prims.cc.jj 2009-05-04 16:46:48.000000000 +0200
+++ libjava/prims.cc    2011-11-23 13:56:34.067198033 +0100
@@ -38,7 +38,6 @@ details.  */
 #endif
 
 #ifndef DISABLE_GETENV_PROPERTIES
-#include <ctype.h>
 #include <java-props.h>
 #define PROCESS_GCJ_PROPERTIES process_gcj_properties()
 #else
@@ -985,6 +984,8 @@ static java::lang::Thread *main_thread;
 
 #ifndef DISABLE_GETENV_PROPERTIES
 
+#define c_isspace(c) (memchr (" \t\n\r\v\f", c, 6) != NULL)
+
 static char *
 next_property_key (char *s, size_t *length)
 {
@@ -993,7 +994,7 @@ next_property_key (char *s, size_t *leng
   JvAssert (s);
 
   // Skip over whitespace
-  while (isspace (*s))
+  while (c_isspace (*s))
     s++;
 
   // If we've reached the end, return NULL.  Also return NULL if for
@@ -1005,7 +1006,7 @@ next_property_key (char *s, size_t *leng
 
   // Determine the length of the property key.
   while (s[l] != 0
-        && ! isspace (s[l])
+        && ! c_isspace (s[l])
         && s[l] != ':'
         && s[l] != '=')
     {
@@ -1027,19 +1028,19 @@ next_property_value (char *s, size_t *le
 
   JvAssert (s);
 
-  while (isspace (*s))
+  while (c_isspace (*s))
     s++;
 
   if (*s == ':'
       || *s == '=')
     s++;
 
-  while (isspace (*s))
+  while (c_isspace (*s))
     s++;
 
   // Determine the length of the property value.
   while (s[l] != 0
-        && ! isspace (s[l])
+        && ! c_isspace (s[l])
         && s[l] != ':'
         && s[l] != '=')
     {

        Jakub

Reply via email to