[kaffe] CVS kaffe (kaz): libraries/javalib/external/classpath/java/text/DecimalFormat.java,

Kaffe CVS cvs-commits at kaffe.org
Fri Jan 19 19:54:17 PST 2007


PatchSet 7468 
Date: 2007/01/20 03:53:27
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2007-01-20  Ito Kazumitsu  <kaz at maczuka.gcd.org>

	* libraries/javalib/external/classpath/java/text/DecimalFormat.java,
	libraries/javalib/external/classpath/java/text/SimpleDateFormat.java,
	libraries/javalib/external/classpath/native/jni/native-lib/cpnet.c,
	libraries/javalib/external/classpath/native/jni/native-lib/cpnet.h:
	Copied from GNU Classpath. Some bugs have been fixed.

Members: 
	ChangeLog:1.4968->1.4969 
	libraries/javalib/external/classpath/java/text/DecimalFormat.java:1.5->1.6 
	libraries/javalib/external/classpath/java/text/SimpleDateFormat.java:1.3->1.4 
	libraries/javalib/external/classpath/native/jni/native-lib/cpnet.c:1.2->1.3 
	libraries/javalib/external/classpath/native/jni/native-lib/cpnet.h:1.1->1.2 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4968 kaffe/ChangeLog:1.4969
--- kaffe/ChangeLog:1.4968	Thu Jan 11 15:13:31 2007
+++ kaffe/ChangeLog	Sat Jan 20 03:53:27 2007
@@ -1,3 +1,11 @@
+2007-01-20  Ito Kazumitsu  <kaz at maczuka.gcd.org>
+
+	* libraries/javalib/external/classpath/java/text/DecimalFormat.java,
+	libraries/javalib/external/classpath/java/text/SimpleDateFormat.java,
+	libraries/javalib/external/classpath/native/jni/native-lib/cpnet.c,
+	libraries/javalib/external/classpath/native/jni/native-lib/cpnet.h:
+	Copied from GNU Classpath. Some bugs have been fixed.
+
 2007-01-11  Ito Kazumitsu  <kaz at maczuka.gcd.org>
 
 	* libraries/javalib/vmspecific/java/net/VMInetAddress.java
Index: kaffe/libraries/javalib/external/classpath/java/text/DecimalFormat.java
diff -u kaffe/libraries/javalib/external/classpath/java/text/DecimalFormat.java:1.5 kaffe/libraries/javalib/external/classpath/java/text/DecimalFormat.java:1.6
--- kaffe/libraries/javalib/external/classpath/java/text/DecimalFormat.java:1.5	Fri Jan  5 20:23:27 2007
+++ kaffe/libraries/javalib/external/classpath/java/text/DecimalFormat.java	Sat Jan 20 03:53:27 2007
@@ -439,8 +439,8 @@
         FieldPosition pos = (FieldPosition) attributes.get(i);
         Format.Field attribute = pos.getFieldAttribute();
         
-        as.addAttribute(attribute, attribute, pos.getBeginIndex(), pos
-                        .getEndIndex());
+        as.addAttribute(attribute, attribute, pos.getBeginIndex(),
+                        pos.getEndIndex());
       }
     
     // return the CharacterIterator from AttributedString
@@ -659,6 +659,7 @@
     // correct the size of the end parsing flag
     int len = str.length();
     if (len < stop) stop = len;
+    char groupingSeparator = symbols.getGroupingSeparator();
     
     int i = start;
     while (i < stop)
@@ -672,6 +673,7 @@
           }
         else if (this.parseIntegerOnly)
           {
+            i--;
             break;
           }
         else if (ch == decimalSeparator)
@@ -688,8 +690,19 @@
             if (inExponent)
               number.append(ch);
             else
-              break;
+	      {
+		i--;
+        	break;
+	      }
           }
+	else
+	  {
+	    if (!groupingUsed || ch != groupingSeparator)
+	      {
+	        i--;
+	        break;
+	      }
+	  }
       }
 
     // 2nd special case: infinity
@@ -723,25 +736,25 @@
 
     // now we have to check the suffix, done here after number parsing
     // or the index will not be updated correctly...
-    boolean isNegativeSuffix = str.endsWith(this.negativeSuffix);
-    boolean isPositiveSuffix = str.endsWith(this.positiveSuffix);
+    boolean hasNegativeSuffix = str.endsWith(this.negativeSuffix);
+    boolean hasPositiveSuffix = str.endsWith(this.positiveSuffix);
     boolean positiveEqualsNegative = negativeSuffix.equals(positiveSuffix);
 
     positiveLen = positiveSuffix.length();
     negativeLen = negativeSuffix.length();
     
-    if (isNegative && !isNegativeSuffix)
+    if (isNegative && !hasNegativeSuffix)
       {
         pos.setErrorIndex(i);
         return null;
       }
-    else if (isNegativeSuffix &&
+    else if (hasNegativeSuffix &&
              !positiveEqualsNegative &&
              (negativeLen > positiveLen))
       {
         isNegative = true;
       }
-    else if (!isPositiveSuffix)
+    else if (!hasPositiveSuffix)
       {
         pos.setErrorIndex(i);
         return null;
@@ -749,7 +762,7 @@
     
     if (isNegative) number.insert(0, '-');
    
-    pos.setIndex(i - 1);
+    pos.setIndex(i);
     
     // now we handle the return type
     BigDecimal bigDecimal = new BigDecimal(number.toString());
Index: kaffe/libraries/javalib/external/classpath/java/text/SimpleDateFormat.java
diff -u kaffe/libraries/javalib/external/classpath/java/text/SimpleDateFormat.java:1.3 kaffe/libraries/javalib/external/classpath/java/text/SimpleDateFormat.java:1.4
--- kaffe/libraries/javalib/external/classpath/java/text/SimpleDateFormat.java:1.3	Fri Dec  8 01:57:49 2006
+++ kaffe/libraries/javalib/external/classpath/java/text/SimpleDateFormat.java	Sat Jan 20 03:53:27 2007
@@ -1101,11 +1101,21 @@
 	    if (is_numeric)
 	      {
 		numberFormat.setMinimumIntegerDigits(fmt_count);
-		if (limit_digits)
-		  numberFormat.setMaximumIntegerDigits(fmt_count);
 		if (maybe2DigitYear)
 		  index = pos.getIndex();
-		Number n = numberFormat.parse(dateStr, pos);
+		Number n = null;
+		if (limit_digits)
+		  {
+		    // numberFormat.setMaximumIntegerDigits(fmt_count) may
+		    // not work as expected. So we explicitly use substring
+		    // of dateStr.
+		    int origPos = pos.getIndex();
+		    pos.setIndex(0);
+		    n = numberFormat.parse(dateStr.substring(origPos, origPos + fmt_count), pos);
+		    pos.setIndex(origPos + pos.getIndex());
+		  }
+		else
+		  n = numberFormat.parse(dateStr, pos);
 		if (pos == null || ! (n instanceof Long))
 		  return null;
 		value = n.intValue() + offset;
Index: kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.c
diff -u kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.c:1.2 kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.c:1.3
--- kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.c:1.2	Fri Jan  5 15:03:09 2007
+++ kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.c	Sat Jan 20 03:53:27 2007
@@ -55,14 +55,6 @@
 
 #define SOCKET_DEFAULT_TIMEOUT -1 /* milliseconds */
 
-#if defined (HAVE_MSG_NOSIGNAL)
-#define SOCKET_NOSIGNAL MSG_NOSIGNAL
-#elif defined (HAVE_SO_NOSIGPIPE)
-#define SOCKET_NOSIGNAL SO_NOSIGPIPE
-#else
-#error "No suitable flag found to ommit a SIGPIPE on signal errors with send()."
-#endif
-
 static int socketTimeouts[FD_SETSIZE];
 
 static jint waitForWritable(jint fd)
@@ -249,6 +241,15 @@
   return 0;
 }
 
+#if defined (HAVE_MSG_NOSIGNAL)
+#elif defined (HAVE_SO_NOSIGPIPE)
+static int setsockopt_NOSIGPIPE (int fd)
+{
+  int setToTrue = 1;
+  return setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &setToTrue, sizeof(setToTrue));
+}
+#endif
+
 jint cpnet_send (JNIEnv *env UNUSED, jint fd, jbyte *data, jint len, jint *bytes_sent)
 {
   ssize_t ret;
@@ -256,7 +257,17 @@
   if (waitForWritable(fd) < 0)
     return ETIMEDOUT;
 
-  ret = send(fd, data, len, SOCKET_NOSIGNAL);
+#if defined (HAVE_MSG_NOSIGNAL)
+  ret = send(fd, data, len, MSG_NOSIGNAL);
+#elif defined (HAVE_SO_NOSIGPIPE)
+  ret = setsockopt_NOSIGPIPE(fd);
+  if (ret == 0) ret = send(fd, data, len, 0);
+#else
+  /* We want SIGPIPE to be omitted. But this configuration does not have an
+   * option for that.
+   */
+  ret = send(fd, data, len, 0);
+#endif
   if (ret < 0)
     return errno;
 
@@ -272,8 +283,24 @@
   if (waitForWritable(fd) < 0)
     return ETIMEDOUT;
 
-  ret = sendto(fd, data, len, SOCKET_NOSIGNAL, (struct sockaddr *)addr->data,
+#if defined (HAVE_MSG_NOSIGNAL)
+  ret = sendto(fd, data, len, MSG_NOSIGNAL, (struct sockaddr *)addr->data,
 	       addr->len);
+#elif defined (HAVE_SO_NOSIGPIPE)
+  ret = setsockopt_NOSIGPIPE(fd);
+  if (ret == 0)
+  {
+    ret = sendto(fd, data, len, 0, (struct sockaddr *)addr->data,
+	       addr->len);
+  }
+#else
+  /* We want SIGPIPE to be omitted. But this configuration does not have an
+   * option for that.
+   */
+  ret = sendto(fd, data, len, 0, (struct sockaddr *)addr->data,
+	       addr->len);
+#endif
+
   if (ret < 0)
     return errno;
 
Index: kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.h
diff -u kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.h:1.1 kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.h:1.2
--- kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.h:1.1	Wed Jan  3 23:02:28 2007
+++ kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpnet.h	Sat Jan 20 03:53:27 2007
@@ -42,7 +42,9 @@
 #include <jcl.h>
 #include <string.h>
 
+#include <sys/types.h>
 #include <sys/socket.h>
+#include <netinet/in_systm.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
 




More information about the kaffe mailing list