From a98126d69b176a35ca30bbdb469e84478d76f08d Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Wed, 31 Aug 2005 02:30:25 +0000 Subject: [PATCH] quick 'fix' for crashers in some locales (#157871) basicly the same + * compose/ucompose.hpp: quick 'fix' for crashers in some locales (#157871) * include/Utils.h: basicly the same + minor cleanups * src/GParted_Core.cc: replaced C-style cast with static_cast.. --- ChangeLog | 6 ++++++ compose/ucompose.hpp | 7 ++++--- include/Utils.h | 10 ++++------ src/GParted_Core.cc | 10 +++++----- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 953ffaca..fd908a73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-08-30 Bart Hakvoort + + * compose/ucompose.hpp: quick 'fix' for crashers in some locales (#157871) + * include/Utils.h: basicly the same + minor cleanups + * src/GParted_Core.cc: replaced C-style cast with static_cast.. + 2005-07-31 Ilkka Tuohela * configure.in: Added 'fi' to ALL_LINGUAS. diff --git a/compose/ucompose.hpp b/compose/ucompose.hpp index 0288dffb..7d529c27 100644 --- a/compose/ucompose.hpp +++ b/compose/ucompose.hpp @@ -124,7 +124,7 @@ namespace UStringPrivate os << obj; std::wstring str = os.str(); - + return Glib::convert(std::string(reinterpret_cast(str.data()), str.size() * sizeof(wchar_t)), "UTF-8", "WCHAR_T"); @@ -157,7 +157,7 @@ namespace UStringPrivate inline Composition &Composition::arg(const T &obj) { Glib::ustring rep = stringify(obj); - + if (!rep.empty()) { // manipulators don't produce output for (specification_map::const_iterator i = specs.lower_bound(arg_no), end = specs.upper_bound(arg_no); i != end; ++i) { @@ -179,7 +179,8 @@ namespace UStringPrivate : arg_no(1) { #if __GNUC__ >= 3 - os.imbue(std::locale("")); // use the user's locale for the stream + //plors: i've uncommented this one since it caused a crasher at line 124 for some locales (e.g. nl_BE) + //os.imbue(std::locale("")); // use the user's locale for the stream #endif std::string::size_type b = 0, i = 0; diff --git a/include/Utils.h b/include/Utils.h index 85855e36..0ae08c90 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -55,8 +55,7 @@ struct FS FS( ) { read = create = grow = shrink = move = check = copy = false ; - MIN = 0 ; - MAX = 0 ; + MIN = MAX = 0 ; } }; @@ -99,10 +98,9 @@ inline Gtk::Label * mk_label( const Glib::ustring & text, bool use_markup = true inline Glib::ustring num_to_str( Sector number ) { - std::ostringstream os; - os .imbue( std::locale( "" ) ); - os << number ; - return os .str( ) ; + std::stringstream ss; + ss << number ; + return ss .str( ) ; } //use http://developer.gnome.org/projects/gup/hig/2.0/design.html#Palette as a starting point.. diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index e5f91699..3a69fda9 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -80,7 +80,7 @@ void GParted_Core::get_devices( std::vector & devices ) //in certain cases (e.g. when there's a cd in the cdrom-drive) ped_device_probe_all will find a 'ghost' device that has no name or contains //random garbage. Those 2 checks try to prevent such a ghostdevice from being initialized.. (tested over a 1000 times with and without cd) - while ( device && strlen( device ->path ) > 6 && ( (Glib::ustring) device ->path ) .is_ascii( ) ) + while ( device && strlen( device ->path ) > 6 && static_cast( device ->path ) .is_ascii( ) ) { if ( open_device( device ->path, device ) ) device_paths .push_back( get_sym_path( device ->path ) ) ; @@ -108,7 +108,7 @@ void GParted_Core::get_devices( std::vector & devices ) //make sure cylsize is at least 1 MB if ( temp_device .cylsize < 1 ) temp_device .cylsize = 1 ; - + //normal harddisk if ( disk ) { @@ -130,7 +130,7 @@ void GParted_Core::get_devices( std::vector & devices ) partition_temp .Set_Unallocated( 0, temp_device .length, false ); temp_device .device_partitions .push_back( partition_temp ); } - + devices .push_back( temp_device ) ; close_device_and_disk( device, disk ) ; @@ -183,7 +183,7 @@ void GParted_Core::set_device_partitions( Device & device ) switch ( c_partition ->type ) { case PED_PARTITION_NORMAL: - case PED_PARTITION_LOGICAL: + case PED_PARTITION_LOGICAL: partition_temp .Set( device .path + num_to_str( c_partition ->num ), c_partition ->num, c_partition ->type == 0 ? GParted::PRIMARY : GParted::LOGICAL , @@ -191,7 +191,7 @@ void GParted_Core::set_device_partitions( Device & device ) c_partition ->geom .end, c_partition ->type, ped_partition_is_busy( c_partition ) ); - + if ( partition_temp .filesystem != "linux-swap" ) { Set_Used_Sectors( partition_temp ) ;