stevenxiao / box2d

Automatically exported from code.google.com/p/box2d
0 stars 0 forks source link

Patch to avoid build problems in v2.2.1 (and onward) for glui_textbox.cpp #278

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I work for a company that's extremely anal about warnings; any warning is an 
error and warnings are turned up to "11" on the dial. 

This is what I had to do to make this compile (diff between new<my code> and 
existing 2.2.1 code:

--- old/glui_textbox.cpp    2012-04-19 19:27:19.278408706 -0700
+++ new/glui_textbox.cpp    2012-04-19 19:26:15.810464699 -0700
@@ -95,7 +95,7 @@
 {
   int tmp_insertion_pt;

-  if ( debug )    dump( stdout, "-> MOUSE DOWN" );
+  if ( debug )    dump( stdout, (char *)"-> MOUSE DOWN" );

   tmp_insertion_pt = find_insertion_pt( local_x, local_y );  
   if ( tmp_insertion_pt == -1 ) {
@@ -113,7 +113,7 @@
   if ( can_draw())
     update_and_draw_text();

-  if ( debug )    dump( stdout, "<- MOUSE UP" );
+  if ( debug )    dump( stdout, (char *)"<- MOUSE UP" );

   return true;
 }
@@ -136,7 +136,7 @@

   if ( NOT new_inside )     return false;

-  if ( debug )    dump( stdout, "-> HELD DOWN" );
+  if ( debug )    dump( stdout, (char *)"-> HELD DOWN" );

   tmp_pt = find_insertion_pt( local_x, local_y );
   keygoal_x = insert_x;
@@ -155,7 +155,7 @@
   }

   if ( debug )
-    dump( stdout, "<- HELD DOWN" );
+    dump( stdout, (char *)"<- HELD DOWN" );

   return false;
 }
@@ -171,7 +171,7 @@
     return false;

   if ( debug )
-    dump( stdout, "-> KEY HANDLER" );
+    dump( stdout, (char *)"-> KEY HANDLER" );

   regular_key = false;
   bool ctrl_down = (modifiers & GLUT_ACTIVE_CTRL)!=0;
@@ -309,7 +309,7 @@

   if ( debug )
-    dump( stdout, "<- KEY HANDLER" );
+    dump( stdout, (char *)"<- KEY HANDLER" );

   return true;
 }
@@ -335,7 +335,7 @@
 void    GLUI_TextBox::activate( int how )
 {
   if ( debug )
-    dump( stdout, "-> ACTIVATE" );
+    dump( stdout, (char *)"-> ACTIVATE" );
   active = true;

   if ( how == GLUI_ACTIVATE_MOUSE )
@@ -347,7 +347,7 @@
   sel_end      = text.length();
   insertion_pt = 0;
   if ( debug )
-    dump( stdout, "<- ACTIVATE" );
+    dump( stdout, (char *)"<- ACTIVATE" );
 }

@@ -361,7 +361,7 @@
     return;

   if ( debug )
-    dump( stdout, "-> DISACTIVATE" );
+    dump( stdout, (char *)"-> DISACTIVATE" );

   sel_start = sel_end = insertion_pt = -1; 

@@ -383,7 +383,7 @@

   if ( debug )
-    dump( stdout, "<- DISACTIVATE" );
+    dump( stdout, (char *)"<- DISACTIVATE" );
 }

 /****************************** GLUI_TextBox::draw() **********/
@@ -508,7 +508,7 @@
   CLAMP( substring_end, 0, MAX(text_len-1,0) );
   CLAMP( substring_start, 0, MAX(text_len-1,0) );

-  if ( debug )    dump( stdout, "-> UPDATE SS" );
+  if ( debug )    dump( stdout, (char *)"-> UPDATE SS" );

   if ( insertion_pt >= 0 AND 
        insertion_pt < substring_start ) {   /* cursor moved left */
@@ -546,7 +546,7 @@
     sel_start = sel_end = 0;
   }

-  if ( debug )    dump( stdout, "<- UPDATE SS" );
+  if ( debug )    dump( stdout, (char *)"<- UPDATE SS" );

   if ( substring_start == old_start AND substring_end == old_end )
     return false;  /*** bounds did not change ***/
@@ -570,7 +570,7 @@
   GLUI_DRAWINGSENTINAL_IDIOM
   int text_x, i, sel_lo, sel_hi, x_pos;

-  if ( debug )    dump( stdout, "-> DRAW_TEXT" );
+  if ( debug )    dump( stdout, (char *)"-> DRAW_TEXT" );

   /** Find where to draw the text **/

@@ -654,7 +654,7 @@
     }
   }

-  if ( debug )    dump( stdout, "<- DRAW_TEXT" );  
+  if ( debug )    dump( stdout, (char *)"<- DRAW_TEXT" );
 }

@@ -774,7 +774,7 @@
     return;  /* Don't draw insertion point if there is a current selection */
   }

-  if ( debug )    dump( stdout, "-> DRAW_INS_PT" );
+  if ( debug )    dump( stdout, (char *)"-> DRAW_INS_PT" );

   /*    printf( "insertion pt: %d\n", insertion_pt );              */

@@ -827,8 +827,9 @@
                                           between the text and the box       **/

   curr_x += substring_width(sol,insertion_pt-1);
-  if (insertion_pt == text.length() && text[text.length()-1] == '\n'
-      || curr_x-this->x_abs > (w - 2 - GLUI_TEXTBOX_BOXINNERMARGINX)) { // 
Insert on the next line 
+  if (((insertion_pt == (int)(text.length()))
+         && (text[text.length()-1] == '\n'))
+      || (curr_x-this->x_abs > (w - 2 - GLUI_TEXTBOX_BOXINNERMARGINX))) { // 
Insert on the next line
     curr_x = this->x_abs + GLUI_TEXTBOX_BOXINNERMARGINX;
     line++;
   } 
@@ -848,7 +849,7 @@
   glEnd();

-  if ( debug )    dump( stdout, "-> DRAW_INS_PT" );
+  if ( debug )    dump( stdout, (char *)"-> DRAW_INS_PT" );
 }

@@ -1071,7 +1072,7 @@
        "%s (edittext@%p):   line:%d ins_pt:%d  subs:%d/%d  sel:%d/%d   len:%d\n",
        name, this, curr_line,
        insertion_pt, substring_start, substring_end, sel_start, sel_end,
-       text.length());
+       (int)(text.length()));
 }

Original issue reported on code.google.com by garybrad...@gmail.com on 20 Apr 2012 at 2:47

GoogleCodeExporter commented 9 years ago
The testbed is now using a new GUI system.

Original comment by erinca...@gmail.com on 4 Apr 2014 at 4:19