The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: kierongreen on August 07, 2012, 03:52:15 PM

Title: r5872 compile fix (itoa added in r5870, not present on gcc/linux)
Post by: kierongreen on August 07, 2012, 03:52:15 PM
r5870 broke compiling on linux/gcc as itoa is not present, this patch changes calls to itoa to sprintf which should achieve the same result:


Index: gui/climates.cc
===================================================================
--- gui/climates.cc    (revision 5872)
+++ gui/climates.cc    (working copy)
@@ -87,7 +87,7 @@
     add_komponente( numberinput_lbl+labelnr );
     labelnr++;

-    itoa( sets->get_climate_borders()[arctic_climate], snowline_txt, 10 );
+    sprintf( snowline_txt ,"%d", sets->get_climate_borders()[arctic_climate] );
     summer_snowline.init( NULL, koord( TEXT_RIGHT, y ), COL_WHITE, gui_label_t::right );
     summer_snowline.set_text_pointer( snowline_txt );
     add_komponente( &summer_snowline );
@@ -234,7 +234,7 @@
         }
         snowline_winter.set_limits( 0, arctic );
     }
-    itoa( sets->get_climate_borders()[arctic_climate], snowline_txt, 10 );
+    sprintf( snowline_txt ,"%d", sets->get_climate_borders()[arctic_climate] );
     return true;
}

Title: Re: r5872 compile fix (itoa added in r5870, not present on gcc/linux)
Post by: Dwachs on August 07, 2012, 05:56:53 PM
thank you!
Title: Re: r5872 compile fix (itoa added in r5870, not present on gcc/linux)
Post by: IgorEliezer on August 08, 2012, 12:40:58 AM
itoa? What the heck, someone here has been poking around with AutoLISP besides me. :D
Title: Re: r5872 compile fix (itoa added in r5870, not present on gcc/linux)
Post by: prissi on August 08, 2012, 07:01:00 AM
That function has been available on my first system, using K&R style C in 1991. Thus I assumed it was a standard function.
Title: Re: r5872 compile fix (itoa added in r5870, not present on gcc/linux)
Post by: Ters on August 08, 2012, 08:17:28 AM
It is rather odd that C hasn't managed to get something as basic as conversion between numbers and text right. There are two (three if sscanf is counted) apparently standardized ways of going from text to number, but neither of them has a standardized inverse (only sprintf, which is the inverse of sscanf).