Thanks, I fixed this.
Committed.

2005-11-25  Lillian Angel  <[EMAIL PROTECTED]>

        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
        (drawString): Changed pointer to be const, and fixed check to
        draw characters only if they are >= ' '. Handles all control
        characters.


On Fri, 2005-11-25 at 12:28 -0700, Tom Tromey wrote:
> >>>>> "Lillian" == Lillian Angel <[EMAIL PROTECTED]> writes:
> 
> Lillian>         PR 24937
> Lillian>         * gnu/java/awt/peer/gtk/GdkGraphics.java
> Lillian>         (drawString): Removed pattern matching code. This is now
> Lillian>         done in native.
> Lillian>         * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
> Lillian>         (Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString): Added
> Lillian>         a loop to filter out all non-printing characters.
> 
> Lillian>    cstr = (*env)->GetStringUTFChars (env, str, NULL);
> 
> Lillian> +  sTmp = cstr;
> Lillian> +  for (; *sTmp != '\0'; sTmp++)
> Lillian> +    if (isprint(*sTmp))
> 
> I don't think this does what you intend it to do.
> 
> isprint() takes a C 'char' and tells you whether it is printable.
> But, this string doesn't contain plain old chars -- a given char might
> be the start of a multi-byte UTF-8 representation of some Unicode
> character.  isprint() won't know about this, and might well return
> false for something which is perfectly displayable... I suggest
> testing with some characters outside of the ordinary Latin 1 range.
> 
> If you are only trying to delete newlines, I suggest just checking for
> those directly.  Or, if you want to handle all control characters I
> think you could just do something like: if ((unsigned char) *sTmp < ' ')...
> 
> Tom
> 
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c,v
retrieving revision 1.30
diff -u -r1.30 gnu_java_awt_peer_gtk_GdkGraphics.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c	22 Nov 2005 19:08:44 -0000	1.30
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c	25 Nov 2005 20:54:24 -0000
@@ -291,9 +291,9 @@
   struct peerfont *pfont = NULL;
   struct graphics *g = NULL;
   const char *cstr = NULL;
+  const char *sTmp = NULL;
   char *p = NULL;
   char *tmp = NULL;
-  char *sTmp = NULL;
   int count = 0;
   int charSize = 0;
   int baseline_y = 0;
@@ -317,7 +317,7 @@
   tmp = p;
   sTmp = cstr;
   for (; *sTmp != '\0'; sTmp++)
-    if (isprint(*sTmp))
+    if (((unsigned char) *sTmp) >= ' ')
       {
         *p = *sTmp;
         count++;
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to