X11 messageboxes should treat "\r\n" as "\n" by ignoring the '\r' char.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 16 Dec 2012 14:39:49 -0500
changeset 6758 2a218048b45f
parent 6757 9935f71c8c81
child 6759 b74da0b33530
X11 messageboxes should treat "\r\n" as "\n" by ignoring the '\r' char.
src/video/x11/SDL_x11messagebox.c
test/testmessage.c
--- a/src/video/x11/SDL_x11messagebox.c	Sat Dec 15 21:50:17 2012 -0800
+++ b/src/video/x11/SDL_x11messagebox.c	Sun Dec 16 14:39:49 2012 -0500
@@ -250,6 +250,10 @@
             data->text_height = IntMax( data->text_height, height );
             text_width_max = IntMax( text_width_max, plinedata->width );
 
+            if (lf && (lf > text) && (lf[-1] == '\r')) {
+                plinedata->length--;
+            }
+
             text += plinedata->length + 1;
 
             /* Break if there are no more linefeeds. */
--- a/test/testmessage.c	Sat Dec 15 21:50:17 2012 -0800
+++ b/test/testmessage.c	Sun Dec 16 14:39:49 2012 -0500
@@ -49,6 +49,15 @@
         quit(1);
     }
 
+    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
+                "Simple MessageBox",
+                "This is a simple MessageBox with a newline:\r\nHello world!",
+                NULL);
+    if (success == -1) {
+        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+        quit(1);
+    }
+
     /* Google says this is Traditional Chinese for "beef with broccoli" */
     success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                 "UTF-8 Simple MessageBox",
@@ -59,6 +68,16 @@
         quit(1);
     }
 
+    /* Google says this is Traditional Chinese for "beef with broccoli" */
+    success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
+                "UTF-8 Simple MessageBox",
+                "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
+                NULL);
+    if (success == -1) {
+        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+        quit(1);
+    }
+
     {
         const SDL_MessageBoxButtonData buttons[] = {
             {