More Sun Studio fixes (patch #911).

This commit is contained in:
Mark de Wever 2008-01-01 21:29:15 +00:00
parent 3ef108017d
commit 3fcdae4768
9 changed files with 24 additions and 20 deletions

View file

@ -519,7 +519,7 @@ namespace dfool {
temp= atof((*a).c_str()) / atof((*b).c_str());
}
if((*token)[0]=='%'){
temp= fmod(atof((*a).c_str()), atof((*b).c_str()));
temp= std::fmod(atof((*a).c_str()), atof((*b).c_str()));
}
if((*token)[0]=='+'){
temp= atof((*a).c_str()) + atof((*b).c_str());
@ -528,7 +528,7 @@ namespace dfool {
temp= atof((*a).c_str()) - atof((*b).c_str());
}
if((*token)[0]=='^'){
temp= pow(atof((*a).c_str()),atof((*b).c_str()));
temp= std::pow(atof((*a).c_str()),atof((*b).c_str()));
}
std::cout<<"got here token2:"<<temp<<"\n";
std::stringstream r;

View file

@ -438,7 +438,7 @@ void save_preview_pane::draw_contents()
SDL_BlitSurface(map_surf,NULL,screen,&map_rect);
}
char* old_locale= setlocale(LC_TIME, get_locale().localename.c_str());
char* old_locale= std::setlocale(LC_TIME, get_locale().localename.c_str());
char time_buf[256];
const size_t res = strftime(time_buf,sizeof(time_buf),_("%a %b %d %H:%M %Y"),localtime(&((*info_)[index_].time_modified)));
if(res == 0) {
@ -446,7 +446,7 @@ void save_preview_pane::draw_contents()
}
if(old_locale) {
setlocale(LC_TIME, old_locale);
std::setlocale(LC_TIME, old_locale);
}
std::stringstream str;

View file

@ -41,6 +41,10 @@
#include <algorithm>
#include <cassert>
#ifdef __SUNPRO_CC
// GCC doesn't have hypot in cmath so include it for Sun Studio
#include <math.h>
#endif
#include <cmath>
#include <iostream>
#include <sstream>
@ -865,8 +869,8 @@ static void draw_background(surface screen, const SDL_Rect& area, const std::str
const unsigned int width = background->w;
const unsigned int height = background->h;
const unsigned int w_count = static_cast<int>(ceil(static_cast<double>(area.w) / static_cast<double>(width)));
const unsigned int h_count = static_cast<int>(ceil(static_cast<double>(area.h) / static_cast<double>(height)));
const unsigned int w_count = static_cast<int>(std::ceil(static_cast<double>(area.w) / static_cast<double>(width)));
const unsigned int h_count = static_cast<int>(std::ceil(static_cast<double>(area.h) / static_cast<double>(height)));
for(unsigned int w = 0, w_off = area.x; w < w_count; ++w, w_off += width) {
for(unsigned int h = 0, h_off = area.y; h < h_count; ++h, h_off += height) {
@ -1633,7 +1637,7 @@ double display::turbo_speed() const
void display::set_idle_anim_rate(int rate)
{
idle_anim_rate_ = pow(2.0, -rate/10.0);
idle_anim_rate_ = std::pow(2.0, -rate/10.0);
}
void display::redraw_everything()

View file

@ -2115,8 +2115,8 @@ static int play_game(int argc, char** argv)
// initialized to have get_intl_dir() to work. Note: this
// setlocale() but this does not take GUI language setting
// into account.
setlocale(LC_ALL, "C");
setlocale(LC_MESSAGES, "");
std::setlocale(LC_ALL, "C");
std::setlocale(LC_MESSAGES, "");
const std::string& intl_dir = get_intl_dir();
bindtextdomain (PACKAGE, intl_dir.c_str());
bind_textdomain_codeset (PACKAGE, "UTF-8");

View file

@ -27,7 +27,7 @@ const char* sgettext (const char *msgid)
{
const char *msgval = gettext (msgid);
if (msgval == msgid) {
msgval = strrchr (msgid, '^');
msgval = std::strrchr (msgid, '^');
if (msgval == NULL)
msgval = msgid;
else
@ -41,7 +41,7 @@ const char* dsgettext (const char * domainname, const char *msgid)
bind_textdomain_codeset(domainname, "UTF-8");
const char *msgval = dgettext (domainname, msgid);
if (msgval == msgid) {
msgval = strrchr (msgid, '^');
msgval = std::strrchr (msgid, '^');
if (msgval == NULL)
msgval = msgid;
else
@ -54,7 +54,7 @@ const char* sngettext (const char *singular, const char *plural, int n)
{
const char *msgval = ngettext (singular, plural, n);
if (msgval == singular) {
msgval = strrchr (singular, '^');
msgval = std::strrchr (singular, '^');
if (msgval == NULL)
msgval = singular;
else
@ -68,7 +68,7 @@ const char* dsngettext (const char * domainname, const char *singular, const cha
bind_textdomain_codeset(domainname, "UTF-8");
const char *msgval = dngettext (domainname, singular, plural, n);
if (msgval == singular) {
msgval = strrchr (singular, '^');
msgval = std::strrchr (singular, '^');
if (msgval == NULL)
msgval = singular;
else

View file

@ -170,15 +170,15 @@ static void wesnoth_setlocale(int category, std::string const &slocale,
std::vector<std::string>::const_iterator i;
if (alternates) i = alternates->begin();
while (true) {
res = setlocale(category, try_loc);
res = std::setlocale(category, try_loc);
if (res) break;
std::string utf8 = std::string(try_loc) + std::string(".utf-8");
res = setlocale(category, utf8.c_str());
res = std::setlocale(category, utf8.c_str());
if (res) break;
utf8 = std::string(try_loc) + std::string(".UTF-8");
res = setlocale(category, utf8.c_str());
res = std::setlocale(category, utf8.c_str());
if (res) break;
if (!alternates) break;

View file

@ -744,7 +744,7 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse, bool update)
int mx = drag_from_x_; // some default value to prevent unlikely SDL bug
int my = drag_from_y_;
if (dragging_ && !dragging_started_ && (SDL_GetMouseState(&mx,&my) & SDL_BUTTON_LEFT != 0)) {
const double drag_distance = pow((double) (drag_from_x_- mx), 2) + pow((double) (drag_from_y_- my), 2);
const double drag_distance = std::pow((double) (drag_from_x_- mx), 2) + std::pow((double) (drag_from_y_- my), 2);
if (drag_distance > drag_threshold*drag_threshold) {
dragging_started_ = true;
cursor::set_dragging(true);

View file

@ -30,7 +30,7 @@ static int calculate_volume(int x, int y, const display &disp)
// An obscure formula to calculate SDL_Mixer's "distance" based on the source's
// distance from screen's center
return maximum<int>(0, 128 * static_cast<int>(std::sqrt((double) (dx + dy)) / (sqrt((double) (area.w*area.w + area.h * area.h)))));
return maximum<int>(0, 128 * static_cast<int>(std::sqrt((double) (dx + dy)) / (std::sqrt((double) (area.w*area.w + area.h * area.h)))));
}
namespace soundsource {

View file

@ -61,9 +61,9 @@ inline int round_damage(int base_damage, int bonus, int divisor) {
// not guaranteed to have exactly the same result on different platforms
inline int round_double(double d) {
#ifdef HAVE_ROUND
return static_cast<int>(round(d)); //surprisingly, not implemented everywhere
return static_cast<int>(std::round(d)); //surprisingly, not implemented everywhere
#else
return static_cast<int>((d >= 0.0)? floor(d + 0.5) : ceil(d - 0.5));
return static_cast<int>((d >= 0.0)? std::floor(d + 0.5) : std::ceil(d - 0.5));
#endif
}