[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeutils/kcalc
From: Evan Teran <eteran () alum ! rit ! edu>
Date: 2010-09-05 5:58:17
Message-ID: 20100905055817.9BC15AC884 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1171786 by teran:
mostely cosmetic changes, making usage of white space more consistant.
also did a few minor actual code changes:
instead of memset'ing struct sigaction to 0. I use the proper sigemptyset
function.
also adding const where appropriate, this will likely be an ongoing process
as I continue to digg through the code.
U kcalc_core.cpp
U knumber/knumber.cpp
U knumber/knumber.h
M +13 -31 knumber/knumber_priv.cpp
U knumber/knumber_priv.h
U stats.h
--- trunk/KDE/kdeutils/kcalc/knumber/knumber_priv.cpp #1171785:1171786
@@ -136,8 +136,6 @@
}
}
-
-
detail::knumerror::knumerror(const QString &num)
{
if (num == "nan")
@@ -208,11 +206,11 @@
// TODO: i18n these strings here and elsewhere, as they're user visible
switch (error_) {
case UndefinedNumber:
- return QString("nan");
+ return "nan";
case Infinity:
- return QString("inf");
+ return "inf";
case MinusInfinity:
- return QString("-inf");
+ return "-inf";
default:
return QString();
}
@@ -224,7 +222,7 @@
char *tmp_ptr = 0;
// get the size of the string
- size_t size = gmp_snprintf(tmp_ptr, 0, "%Zd", mpz_) + 1;
+ const size_t size = gmp_snprintf(tmp_ptr, 0, "%Zd", mpz_) + 1;
tmp_ptr = new char[size];
gmp_snprintf(tmp_ptr, size, "%Zd", mpz_);
@@ -238,7 +236,7 @@
{
Q_UNUSED(prec);
char *tmp_ptr = mpq_get_str(0, 10, mpq_);
- QString ret_str = tmp_ptr;
+ const QString ret_str = tmp_ptr;
free(tmp_ptr);
return ret_str;
@@ -312,8 +310,6 @@
return tmp_num;
}
-
-
detail::knumber * detail::knumerror::intPart() const
{
return new knumerror(*this);
@@ -345,8 +341,6 @@
}
-
-
int detail::knumerror::sign() const
{
switch (error_) {
@@ -395,21 +389,19 @@
detail::knumber * detail::knumerror::cbrt() const
{
// infty ^3 = infty; -infty^3 = -infty
- knumerror *tmp_num = new knumerror(*this);
-
- return tmp_num;
+ return new knumerror(*this);
}
detail::knumber * detail::knuminteger::cbrt() const
{
- knuminteger * tmp_num = new knuminteger();
+ knuminteger *const tmp_num = new knuminteger();
if (mpz_root(tmp_num->mpz_, mpz_, 3))
return tmp_num; // root is perfect
delete tmp_num; // root was not perfect, result will be float
- knumfloat * tmp_num2 = new knumfloat();
+ knumfloat *const tmp_num2 = new knumfloat();
mpf_set_z(tmp_num2->mpf_, mpz_);
cube_root(tmp_num2->mpf_);
@@ -443,9 +435,6 @@
return tmp_num;
}
-
-
-
detail::knumber * detail::knumerror::sqrt() const
{
knumerror *tmp_num = new knumerror(*this);
@@ -458,20 +447,18 @@
detail::knumber * detail::knuminteger::sqrt() const
{
if (mpz_sgn(mpz_) < 0) {
- knumerror *tmp_num = new knumerror(UndefinedNumber);
+ knumerror *const tmp_num = new knumerror(UndefinedNumber);
return tmp_num;
}
- if (mpz_perfect_square_p(mpz_)) {
- knuminteger * tmp_num = new knuminteger();
+ if (mpz_perfect_square_p(mpz_)) {
+ knuminteger *const tmp_num = new knuminteger();
mpz_sqrt(tmp_num->mpz_, mpz_);
-
return tmp_num;
} else {
- knumfloat * tmp_num = new knumfloat();
+ knumfloat *const tmp_num = new knumfloat();
mpf_set_z(tmp_num->mpf_, mpz_);
mpf_sqrt(tmp_num->mpf_, tmp_num->mpf_);
-
return tmp_num;
}
}
@@ -541,8 +528,7 @@
struct sigaction new_sa;
struct sigaction old_sa;
- memset(&new_sa, 0, sizeof(new_sa));
-
+ sigemptyset(&new_sa.sa_mask);
new_sa.sa_handler = factorial_abort_handler;
sigaction(SIGABRT, &new_sa, &old_sa);
@@ -838,10 +824,6 @@
return tmp_num;
}
-
-
-
-
detail::knumber * detail::knumber::divide(const knumber &arg2) const
{
knumber * tmp_num = arg2.reciprocal();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic