News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

r5872 compile fix (itoa added in r5870, not present on gcc/linux)

Started by kierongreen, August 07, 2012, 03:52:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kierongreen

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;
}


Dwachs

Parsley, sage, rosemary, and maggikraut.

IgorEliezer

itoa? What the heck, someone here has been poking around with AutoLISP besides me. :D

prissi

That function has been available on my first system, using K&R style C in 1991. Thus I assumed it was a standard function.

Ters

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).