[gcalctool] Remove trailing whitespace
- From: Robert Ancell <rancell src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gcalctool] Remove trailing whitespace
- Date: Mon, 28 Sep 2009 02:37:55 +0000 (UTC)
commit 2ef06d76247b190ace189f3bc05cbf0ef67b998e
Author: Robert Ancell <robert ancell gmail com>
Date: Mon Sep 28 12:37:42 2009 +1000
Remove trailing whitespace
src/calctool.c | 26 +++---
src/calctool.h | 10 +-
src/display.c | 146 ++++++++++++++++----------------
src/display.h | 14 ++--
src/financial.c | 20 ++--
src/financial.h | 10 +-
src/get.c | 34 ++++----
src/get.h | 10 +-
src/gtk.c | 206 ++++++++++++++++++++++----------------------
src/mp-binary.c | 28 +++---
src/mp-convert.c | 72 ++++++++--------
src/mp-equation-lexer.l | 16 ++--
src/mp-equation-parser.y | 10 +-
src/mp-equation-private.h | 6 +-
src/mp-equation.c | 30 ++++----
src/mp-equation.h | 10 +-
src/mp-internal.h | 10 +-
src/mp-trigonometric.c | 48 +++++-----
src/mp.c | 142 ++++++++++++++++----------------
src/mp.h | 12 ++--
src/register.c | 24 +++---
src/ui.h | 10 +-
src/unittest.c | 50 ++++++------
src/unittest.h | 10 +-
24 files changed, 477 insertions(+), 477 deletions(-)
---
diff --git a/src/calctool.c b/src/calctool.c
index 994a551..062f2dd 100644
--- a/src/calctool.c
+++ b/src/calctool.c
@@ -49,11 +49,11 @@ solve(const char *equation)
int error;
MPNumber result;
char result_str[MAXLINE];
-
+
memset(&options, 0, sizeof(options));
options.wordlen = 32;
options.angle_units = MP_DEGREES;
-
+
error = mp_equation_parse(equation, &options, &result);
if(error != 0) {
fprintf(stderr, "Error %d\n", error);
@@ -86,7 +86,7 @@ usage(int show_gtk)
" --help-gtk Show GTK+ options"));
fprintf(stderr,
"\n\n");
-
+
if (show_gtk) {
/* Translators: Description on gcalctool command-line GTK+ options displayed on command-line */
fprintf(stderr,
@@ -101,7 +101,7 @@ usage(int show_gtk)
"\n\n");
}
- /* Translators: Description on gcalctool application options displayed on command-line */
+ /* Translators: Description on gcalctool application options displayed on command-line */
fprintf(stderr,
_("Application Options:\n"
" -u, --unittest Perform unittests\n"
@@ -115,17 +115,17 @@ get_options(int argc, char *argv[])
{
int i;
char *arg;
-
+
for (i = 1; i < argc; i++) {
arg = argv[i];
- if (strcmp(arg, "-v") == 0 ||
+ if (strcmp(arg, "-v") == 0 ||
strcmp(arg, "--version") == 0 ||
strcmp(arg, "-?") == 0) {
version();
exit(0);
}
- else if (strcmp(arg, "-h") == 0 ||
+ else if (strcmp(arg, "-h") == 0 ||
strcmp(arg, "--help") == 0) {
usage(FALSE);
exit(0);
@@ -193,7 +193,7 @@ main(int argc, char **argv)
{
memset(&calc_state, 0, sizeof(calc_state));
v = &calc_state;
-
+
g_type_init();
bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
@@ -201,12 +201,12 @@ main(int argc, char **argv)
textdomain(GETTEXT_PACKAGE);
v->progname = g_path_get_basename(argv[0]);
-
- /* Seed random number generator. */
+
+ /* Seed random number generator. */
srand48((long) time((time_t *) 0));
-
+
resources_init();
-
+
init_state();
register_init();
display_init(&v->display);
@@ -216,6 +216,6 @@ main(int argc, char **argv)
ui_load();
ui_start();
-
+
return(0);
}
diff --git a/src/calctool.h b/src/calctool.h
index 9727fc9..aa35ef9 100644
--- a/src/calctool.h
+++ b/src/calctool.h
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
diff --git a/src/display.c b/src/display.c
index 2b9f9ea..d886c5e 100644
--- a/src/display.c
+++ b/src/display.c
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -47,7 +47,7 @@ str_replace(char *str, char *from, char *to)
char *c;
int flen = strlen(from);
int tlen = strlen(to);
-
+
for (c = str; *c && offset < MAX_DISPLAY - 1; c++, offset++) {
if (strncasecmp(from, c, flen) == 0) {
SNPRINTF(output + offset, MAX_DISPLAY - offset, "%s", to);
@@ -61,9 +61,9 @@ str_replace(char *str, char *from, char *to)
if (offset >= MAX_DISPLAY)
offset = MAX_DISPLAY - 1;
output[offset] = '\0';
-
+
free(str);
-
+
return strdup(output);
}
@@ -79,7 +79,7 @@ localize_expression(GCDisplay *display, char *dest, const char *src, int dest_le
const char *c, *d;
int digit_count = -1, read_cursor, new_cursor;
gboolean after_radix = FALSE;
-
+
if (cursor) {
new_cursor = *cursor;
} else {
@@ -98,9 +98,9 @@ localize_expression(GCDisplay *display, char *dest, const char *src, int dest_le
digit_count++;
}
}
-
+
g_string_append_unichar(output, g_utf8_get_char(c));
-
+
/* Insert separator after nth digit */
if (display->show_tsep && display->format == DEC &&
!after_radix && digit_count > 1 && digit_count % v->tsep_count == 1) {
@@ -126,10 +126,10 @@ localize_expression(GCDisplay *display, char *dest, const char *src, int dest_le
g_string_append_unichar(output, g_utf8_get_char(c));
}
}
-
+
STRNCPY(dest, output->str, dest_length - 1);
g_string_free(output, TRUE);
-
+
if (cursor != NULL && *cursor != -1) {
*cursor = new_cursor;
}
@@ -180,7 +180,7 @@ gboolean display_get_unsigned_integer(GCDisplay *display, guint64 *value)
display_make_number(display, buf, MAX_DISPLAY, display_get_answer(display));
text = buf;
}
-
+
/* strtoull() treats the string like a 2's complement number which is not what we want */
if(strncmp(text, "-", strlen("-")) == 0 || strncmp(text, "â??", strlen("â??")) == 0)
return FALSE;
@@ -229,7 +229,7 @@ display_make_text(GCDisplay *display, char *localized, int length, int *cursor)
GCDisplayState *e;
e = get_state(display);
-
+
/* Substitute answer register */
if (display_is_result(display)) {
char temp[MAX_LOCALIZED];
@@ -249,7 +249,7 @@ display_refresh(GCDisplay *display)
{
char localized[MAX_LOCALIZED];
int cursor;
-
+
cursor = display_get_cursor(display);
display_make_text(display, localized, MAX_LOCALIZED, &cursor);
ui_set_display(localized, cursor);
@@ -260,15 +260,15 @@ void
display_set_string(GCDisplay *display, const char *value, int cursor)
{
GCDisplayState *e;
-
+
if (value[0] == '\0')
cursor = -1;
-
+
e = get_state(display);
free(e->expression);
e->expression = strdup(value);
e->cursor = cursor;
-
+
display_refresh(display);
}
@@ -335,7 +335,7 @@ void display_clear_stack(GCDisplay *display)
void display_push(GCDisplay *display)
{
int c;
-
+
if (display->h.current != display->h.end) {
int i = display->h.current;
@@ -370,7 +370,7 @@ void display_pop(GCDisplay *display)
ui_set_statusbar(_("No undo history"));
}
update_undo_redo_button_sensitivity(display);
-
+
display_refresh(display);
}
@@ -401,7 +401,7 @@ void
display_insert(GCDisplay *display, int cursor_start, int cursor_end, const char *text)
{
char buf[MAX_DISPLAY];
-
+
if (cursor_start < 0) {
SNPRINTF(buf, MAX_DISPLAY, "%s%s", display_get_text(display), text);
display_set_string(display, buf, -1);
@@ -409,7 +409,7 @@ display_insert(GCDisplay *display, int cursor_start, int cursor_end, const char
GString *new_text;
const char *c;
gint cursor, new_cursor;
-
+
/* Get display text and strip out thousand separators */
new_text = g_string_new("");
new_cursor = 0;
@@ -417,26 +417,26 @@ display_insert(GCDisplay *display, int cursor_start, int cursor_end, const char
g_string_append(new_text, text);
new_cursor += g_utf8_strlen(text, -1);
}
-
+
cursor = 0;
for (c = ui_get_display(); *c; c = g_utf8_next_char(c), cursor++) {
gboolean use = TRUE;
-
+
/* Ignore selected part */
if (cursor_start != cursor_end && cursor >= cursor_start && cursor < cursor_end)
use = FALSE;
-
+
/* Ignore thousands separators */
if (strncmp(c, v->tsep, strlen(v->tsep)) == 0)
use = FALSE;
-
+
/* Copy existing text */
if (use) {
g_string_append_unichar(new_text, g_utf8_get_char(c));
if (cursor < cursor_start)
new_cursor++;
}
-
+
/* Insert text */
if ((cursor + 1) == cursor_start) {
g_string_append(new_text, text);
@@ -465,19 +465,19 @@ display_backspace(GCDisplay *display, int cursor_start, int cursor_end)
char buf[MAX_DISPLAY] = "";
GCDisplayState *e = get_state(display);
int cursor;
-
+
/* Can't delete empty display */
if (display_is_empty(display))
return;
cursor = display_get_cursor(display);
-
+
/* If cursor is at end of the line then delete the last character preserving accuracy */
if (cursor_start < 0) {
int len;
-
+
len = g_utf8_strlen(ui_get_display(), -1);
-
+
if (display_is_result(display)) {
display_make_number(display, buf, MAX_DISPLAY, &e->ans);
e->expression = str_replace(e->expression, "ans", buf);
@@ -507,7 +507,7 @@ void
display_surround(GCDisplay *display, const char *prefix, const char *suffix)
{
char buffer[MAX_DISPLAY];
-
+
SNPRINTF(buffer, MAX_DISPLAY, "%s%s%s", prefix, display_get_text(display), suffix);
display_set_string(display, buffer, -1);
}
@@ -525,7 +525,7 @@ display_is_result(GCDisplay *display)
{
if (strcmp(display_get_text(display), "ans") == 0)
return TRUE;
-
+
return FALSE;
}
@@ -549,10 +549,10 @@ void
display_init(GCDisplay *display)
{
int i;
-
+
memset(display, 0, sizeof(GCDisplay));
-
- display->show_zeroes = FALSE;
+
+ display->show_zeroes = FALSE;
display->show_tsep = FALSE;
display->format = DEC;
display->accuracy = 9;
@@ -568,7 +568,7 @@ void display_set_accuracy(GCDisplay *display, int accuracy)
{
display->accuracy = accuracy;
get_state(display)->cursor = -1;
- display_refresh(display);
+ display_refresh(display);
}
@@ -609,16 +609,16 @@ void display_set_angle_unit(GCDisplay *display, MPAngleUnit angle_unit)
static void
make_eng_sci(GCDisplay *display, char *target, int target_len, const MPNumber *x, int base_)
{
- static char digits[] = "0123456789ABCDEF";
+ static char digits[] = "0123456789ABCDEF";
char fixed[MAX_DIGITS];
MPNumber t, z, base, base3, base10, base10inv, mantissa;
int ddig, eng, exponent = 0;
GString *string;
-
+
string = g_string_sized_new(target_len);
eng = display->format == ENG;
-
+
mp_abs(x, &z);
if (mp_is_negative(x))
g_string_append(string, "â??");
@@ -635,43 +635,43 @@ make_eng_sci(GCDisplay *display, char *target, int target_len, const MPNumber *x
exponent += 10;
mp_multiply(&mantissa, &base10inv, &mantissa);
}
-
+
while ((!eng && mp_is_greater_equal(&mantissa, &base)) ||
(eng && (mp_is_greater_equal(&mantissa, &base3) || exponent % 3 != 0))) {
exponent += 1;
mp_divide(&mantissa, &base, &mantissa);
}
-
+
while (!eng && mp_is_less_than(&mantissa, &base10inv)) {
exponent -= 10;
mp_multiply(&mantissa, &base10, &mantissa);
}
-
+
mp_set_from_integer(1, &t);
while (mp_is_less_than(&mantissa, &t) || (eng && exponent % 3 != 0)) {
exponent -= 1;
mp_multiply(&mantissa, &base, &mantissa);
}
}
-
+
mp_cast_to_string(&mantissa, base_, display->accuracy, !display->show_zeroes, fixed, MAX_DIGITS);
g_string_append(string, fixed);
g_string_append(string, "Ã?10^");
-
+
if (exponent < 0) {
exponent = -exponent;
g_string_append(string, "â??");
} else {
- g_string_append(string, "+");
+ g_string_append(string, "+");
}
-
+
mp_set_from_string("0.5", &t);
mp_add_integer(&t, exponent, &z);
mp_set_from_integer(1, &t);
for (ddig = 0; mp_is_greater_equal(&z, &t); ddig++) {
mp_divide(&z, &base, &z);
}
-
+
while (ddig-- > 0) {
int dval;
@@ -718,7 +718,7 @@ get_variable(const char *name, MPNumber *z, void *data)
char *c, *lower_name;
int result = 1;
GCDisplay *display = data;
-
+
lower_name = strdup(name);
for (c = lower_name; *c; c++)
*c = tolower(*c);
@@ -769,7 +769,7 @@ do_paste(GCDisplay *display, int cursor_start, int cursor_end, const char *text)
/* Copy input to modify, no operation can make the clean string longer than
* the original string */
clean_text = strdup(text);
-
+
output = clean_text;
for (input = text; *input; input++) {
/* If the clipboard buffer contains any occurances of the "thousands
@@ -779,28 +779,28 @@ do_paste(GCDisplay *display, int cursor_start, int cursor_end, const char *text)
input += strlen(v->tsep) - 1;
continue;
}
-
+
/* Replace radix with "." */
else if (strncmp(input, v->radix, strlen(v->radix)) == 0) {
input += strlen(v->radix) - 1;
c = '.';
}
- /* Replace tabs with spaces */
+ /* Replace tabs with spaces */
else if (*input == '\t') {
c = ' ';
}
-
- /* Terminate on newlines */
+
+ /* Terminate on newlines */
else if (*input == '\r' || *input == '\n') {
c = '\0';
}
-
- /* If an "A", "B", "C", "D" or "F" character is encountered, it
- * will be converted to its lowercase equivalent. If an "E" is
- * found, and the next character is a "-" or a "+", then it
- * remains as an upper case "E" (it's assumed to be a possible
- * exponential number), otherwise its converted to a lower case
+
+ /* If an "A", "B", "C", "D" or "F" character is encountered, it
+ * will be converted to its lowercase equivalent. If an "E" is
+ * found, and the next character is a "-" or a "+", then it
+ * remains as an upper case "E" (it's assumed to be a possible
+ * exponential number), otherwise its converted to a lower case
* "e". See bugs #455889 and #469245 for more details.
*/
else if (*input >= 'A' && *input <= 'F') {
@@ -812,10 +812,10 @@ do_paste(GCDisplay *display, int cursor_start, int cursor_end, const char *text)
else
c = tolower(*input);
}
-
+
else
c = *input;
-
+
*output++ = c;
}
*output++ = '\0';
@@ -869,7 +869,7 @@ do_factorize()
display_insert(&v->display, -1, -1, "â??");
mp_invert_sign(&value, &value);
}
-
+
mp_set_from_integer(1, &tmp);
if (mp_is_equal(&value, &tmp)) {
display_insert(&v->display, -1, -1, v->digits[1]);
@@ -915,7 +915,7 @@ static void
do_sto(GCDisplay *display, int index)
{
MPNumber temp;
-
+
if (!display_is_usable_number(display, &temp))
ui_set_statusbar(_("No sane value to store"));
else
@@ -930,7 +930,7 @@ display_do_function(GCDisplay *display, int function, int arg, int cursor_start,
MPNumber *ans;
int enabled;
guint64 bit_value;
-
+
switch (function) {
case FN_UNDO:
display_pop(display);
@@ -943,7 +943,7 @@ display_do_function(GCDisplay *display, int function, int arg, int cursor_start,
default:
break;
}
-
+
display_push(display);
display_set_cursor(display, cursor_start);
@@ -968,10 +968,10 @@ display_do_function(GCDisplay *display, int function, int arg, int cursor_start,
case FN_PASTE:
do_paste(display, cursor_start, cursor_end, (const char *)arg); // FIXME: Probably not 64 bit safe
return;
-
+
case FN_INSERT_CHARACTER:
do_insert_character(display, (const char *)arg); // FIXME: Probably not 64 bit safe
- return;
+ return;
case FN_STORE:
do_sto(display, arg);
@@ -985,7 +985,7 @@ display_do_function(GCDisplay *display, int function, int arg, int cursor_start,
case FN_BACKSPACE:
display_backspace(display, cursor_start, cursor_end);
break;
-
+
case FN_DELETE:
display_delete(display, cursor_start, cursor_end);
break;
@@ -996,7 +996,7 @@ display_do_function(GCDisplay *display, int function, int arg, int cursor_start,
MPNumber MP;
bit_value ^= (1LL << (63 - arg));
-
+
/* FIXME: Convert to string since we don't support setting MP numbers from 64 bit integers */
SNPRINTF(buf, MAX_DISPLAY, "%llu", bit_value);
mp_set_from_string(buf, &MP);
@@ -1015,10 +1015,10 @@ display_do_function(GCDisplay *display, int function, int arg, int cursor_start,
display_pop(display);
}
- /* Do nothing */
+ /* Do nothing */
} else if (display_is_empty(display)) {
;
-
+
/* Solve the equation */
} else {
MPNumber z;
diff --git a/src/display.h b/src/display.h
index d62ab13..7957a00 100644
--- a/src/display.h
+++ b/src/display.h
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -34,7 +34,7 @@ typedef struct {
int cursor;
} GCDisplayState;
-/* Circular list of Arithmetic Precedence Mode states*/
+/* Circular list of Arithmetic Precedence Mode states*/
typedef struct {
unsigned int begin;
unsigned int end;
@@ -63,7 +63,7 @@ enum
FN_CALCULATE,
FN_CLEAR,
FN_BACKSPACE,
- FN_DELETE,
+ FN_DELETE,
FN_TOGGLE_BIT,
FN_SHIFT,
FN_FACTORIZE,
diff --git a/src/financial.c b/src/financial.c
index 806361c..29850b0 100644
--- a/src/financial.c
+++ b/src/financial.c
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -32,7 +32,7 @@ calc_ctrm(MPNumber *t, MPNumber *pint, MPNumber *fv, MPNumber *pv)
* pv (present value).
*
* RESULT = log(fv / pv) / log(1 + pint)
- */
+ */
MPNumber MP1, MP2, MP3, MP4;
mp_divide(fv, pv, &MP1);
@@ -76,7 +76,7 @@ calc_ddb(MPNumber *t, MPNumber *cost, MPNumber *life, MPNumber *period)
}
if (len >= 0) {
- display_set_error (&v->display,
+ display_set_error (&v->display,
("Error: the number of periods must be positive"));
mp_set_from_integer(0, t);
}
@@ -95,7 +95,7 @@ calc_fv(MPNumber *t, MPNumber *pmt, MPNumber *pint, MPNumber *n)
*/
MPNumber MP1, MP2, MP3, MP4;
-
+
mp_add_integer(pint, 1, &MP1);
mp_xpowy(&MP1, n, &MP2);
mp_add_integer(&MP2, -1, &MP3);
@@ -199,7 +199,7 @@ calc_sln(MPNumber *t, MPNumber *cost, MPNumber *salvage, MPNumber *life)
*
* RESULT = (cost - salvage) / life
*/
-
+
MPNumber MP1;
mp_subtract(cost, salvage, &MP1);
mp_divide(&MP1, life, t);
@@ -253,7 +253,7 @@ calc_term(MPNumber *t, MPNumber *pmt, MPNumber *fv, MPNumber *pint)
mp_add_integer(&MP3, 1, &MP4);
mp_ln(&MP4, &MP1);
mp_divide(&MP1, &MP2, t);
-}
+}
void
do_finc_expression(int function, MPNumber *arg1, MPNumber *arg2, MPNumber *arg3, MPNumber *arg4)
diff --git a/src/financial.h b/src/financial.h
index bfc6fff..7b4a6f4 100644
--- a/src/financial.h
+++ b/src/financial.h
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
diff --git a/src/get.c b/src/get.c
index ea93603..25b70bb 100644
--- a/src/get.c
+++ b/src/get.c
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -34,7 +34,7 @@
#include "register.h"
#include "mp.h"
-#define EQUAL(a, b) (strlen(a)==strlen(b)) & !strcmp(a, b)
+#define EQUAL(a, b) (strlen(a)==strlen(b)) & !strcmp(a, b)
/* Various string values read/written as X resources. */
@@ -63,7 +63,7 @@ void
set_int_resource(const char *key, int value)
{
char key_name[MAXLINE];
- SNPRINTF(key_name, MAXLINE, "/apps/gcalctool/%s", key);
+ SNPRINTF(key_name, MAXLINE, "/apps/gcalctool/%s", key);
gconf_client_set_int(client, key_name, value, NULL);
}
@@ -72,7 +72,7 @@ void
set_boolean_resource(const char *key, int value)
{
char key_name[MAXLINE];
- SNPRINTF(key_name, MAXLINE, "/apps/gcalctool/%s", key);
+ SNPRINTF(key_name, MAXLINE, "/apps/gcalctool/%s", key);
gconf_client_set_bool(client, key_name, value, NULL);
}
@@ -95,7 +95,7 @@ get_int_resource(const char *key, int *intval)
if (error)
return FALSE;
*intval = v;
-
+
return TRUE;
}
@@ -106,13 +106,13 @@ get_boolean_resource(const char *key, int *boolval)
char key_name[MAXLINE];
GError *error = NULL;
gboolean v;
-
+
SNPRINTF(key_name, MAXLINE, "/apps/gcalctool/%s", key);
v = gconf_client_get_bool(client, key_name, &error);
if (error)
return FALSE;
*boolval = v;
-
+
return TRUE;
}
@@ -126,7 +126,7 @@ get_enumerated_resource(const char *key, const char *values[], int *value)
val = get_resource(key);
if (!val)
return FALSE;
-
+
for (i = 0; values[i]; i++) {
if (strcmp(values[i], val) == 0) {
*value = i;
@@ -135,12 +135,12 @@ get_enumerated_resource(const char *key, const char *values[], int *value)
}
}
free(val);
-
+
return retval;
}
-/* Return the radix character. For most locales, this is a period.
+/* Return the radix character. For most locales, this is a period.
* If nl_langinfo(RADIXCHAR) returns an empty string, return ",".
*/
const char *
@@ -161,8 +161,8 @@ get_radix()
}
-/* Return the thousands separator string. For most locales, this is a
- * comma.
+/* Return the thousands separator string. For most locales, this is a
+ * comma.
*/
const char *
get_tsep()
@@ -191,7 +191,7 @@ get_tsep_count()
void
resources_init()
-{
+{
assert(client == NULL);
client = gconf_client_get_default();
gconf_client_add_dir(client, "/apps/gcalctool", GCONF_CLIENT_PRELOAD_NONE, NULL);
diff --git a/src/get.h b/src/get.h
index d534496..96f2fd1 100644
--- a/src/get.h
+++ b/src/get.h
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
diff --git a/src/gtk.c b/src/gtk.c
index 93f2fab..41338c4 100644
--- a/src/gtk.c
+++ b/src/gtk.c
@@ -1,14 +1,14 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
@@ -85,7 +85,7 @@ static ButtonData button_data[] = {
{"fractional_portion", "frac"},
{"ones_complement", "ones"},
{"twos_complement", "twos"},
- {"trunc", "trunc"},
+ {"trunc", "trunc"},
{"start_group", "("},
{"end_group", ")"},
{NULL, NULL}
@@ -95,7 +95,7 @@ static ButtonData button_data[] = {
static char *titles[] = {
/* Translators: The window title when in basic mode */
N_("Calculator"),
- /* Translators: The window title when in advanced mode */
+ /* Translators: The window title when in advanced mode */
N_("Calculator - Advanced"),
/* Translators: The window title when in financial mode */
N_("Calculator - Financial"),
@@ -143,13 +143,13 @@ typedef enum {
/* Gtk+/Xlib graphics object. */
typedef struct {
- ModeType mode; /* Current calculator mode. */
+ ModeType mode; /* Current calculator mode. */
GtkBuilder *ui;
GtkBuilder *financial;
-
+
GtkWidget *main_window;
-
+
GtkWidget *menubar; // FIXME: Why is this needed?
GtkWidget *bit_panel;
@@ -160,7 +160,7 @@ typedef struct {
GtkWidget *display_item; /* Calculator display. */
GtkTextBuffer *display_buffer; /* Buffer used in display */
- GtkTextBuffer *info_buffer; /* Buffer used in info messages */
+ GtkTextBuffer *info_buffer; /* Buffer used in info messages */
GtkWidget *scrolledwindow; /* Scrolled window for display_item. */
GtkWidget *bas_panel; /* Panel containing basic mode widgets. */
@@ -168,18 +168,18 @@ typedef struct {
GtkWidget *fin_panel; /* Panel containing financial mode widgets. */
GtkWidget *sci_panel; /* Panel containing scientific mode widgets. */
GtkWidget *prog_panel; /* Panel containing programming mode widgets. */
-
+
GtkWidget *superscript_toggle;
GtkWidget *subscript_toggle;
-
+
/* Labels for popup menus */
GtkWidget *memory_store_labels[MAX_REGISTERS];
GtkWidget *memory_recall_labels[MAX_REGISTERS];
-
+
GtkWidget *preferences_dialog;
-
+
GdkAtom clipboard_atom;
- GdkAtom primary_atom;
+ GdkAtom primary_atom;
char *shelf; /* PUT selection shelf contents. */
/* Last text entered */
@@ -218,7 +218,7 @@ static void load_ui(GtkBuilder *ui, const gchar *filename)
gtk_builder_add_from_file(ui, filename, &error);
if (error == NULL)
return;
-
+
dialog = gtk_message_dialog_new(NULL, 0,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_NONE,
@@ -228,7 +228,7 @@ static void load_ui(GtkBuilder *ui, const gchar *filename)
/* Translators: Description in UI error dialog when unable to load the UI files. %s is replaced with the error message provided by GTK+ */
N_("A required file is missing or damaged, please check your installation.\n\n%s"), error->message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_QUIT, GTK_RESPONSE_ACCEPT, NULL);
-
+
gtk_dialog_run(GTK_DIALOG(dialog));
exit(0);
}
@@ -249,7 +249,7 @@ static void set_int_data(GtkBuilder *ui, const gchar *object_name, const gchar *
}
static void
-position_popup(GtkWidget *base, GtkWidget *popup,
+position_popup(GtkWidget *base, GtkWidget *popup,
PopupLocation location_op)
{
int base_x, base_y, base_width, base_height;
@@ -322,10 +322,10 @@ position_popup(GtkWidget *base, GtkWidget *popup,
}
-void
+void
ui_set_undo_enabled(gboolean undo, gboolean redo)
{
-// gtk_widget_set_sensitive(GET_WIDGET("undo_menu"), undo);
+// gtk_widget_set_sensitive(GET_WIDGET("undo_menu"), undo);
// gtk_widget_set_sensitive(GET_WIDGET("redo_menu"), redo);
}
@@ -344,7 +344,7 @@ ui_set_bitfield(int enabled, guint64 bits)
{
int i;
const gchar *label;
-
+
gtk_widget_set_sensitive(X.bit_panel, enabled);
for (i = 0; i < MAXBITS; i++) {
@@ -396,7 +396,7 @@ do_text(const char *text)
{
do_button(FN_TEXT, (int)text); // FIXME: Not 64 bit safe
}
-
+
static void
do_finc(char* dialog)
@@ -416,7 +416,7 @@ ui_set_mode(ModeType mode)
/* Save mode */
set_enumerated_resource(R_MODE, mode_names, (int)mode);
-
+
/* Show/enable the widgets used in this mode */
g_object_set(G_OBJECT(X.adv_panel), "visible", mode != BASIC, NULL);
g_object_set(G_OBJECT(X.fin_panel), "visible", mode == FINANCIAL, NULL);
@@ -443,7 +443,7 @@ ui_set_mode(ModeType mode)
case SCIENTIFIC:
menu = GET_WIDGET("view_scientific_menu");
break;
-
+
case PROGRAMMING:
menu = GET_WIDGET("view_programming_menu");
break;
@@ -456,7 +456,7 @@ ui_set_mode(ModeType mode)
}
-void
+void
ui_set_statusbar(const gchar *text)
{
gtk_text_buffer_set_text(X.info_buffer, text, -1);
@@ -473,15 +473,15 @@ redo_display(gpointer data)
gtk_text_buffer_get_start_iter(X.display_buffer, &start);
gtk_text_buffer_get_end_iter(X.display_buffer, &end);
text = gtk_text_buffer_get_text(X.display_buffer, &start, &end, FALSE);
-
+
g_object_get(G_OBJECT(X.display_buffer), "cursor-position", &cursor_position, NULL);
- gtk_text_buffer_set_text(X.display_buffer, text, -1);
+ gtk_text_buffer_set_text(X.display_buffer, text, -1);
gtk_text_buffer_get_iter_at_offset(X.display_buffer, &cursor, cursor_position);
gtk_text_buffer_place_cursor(X.display_buffer, &cursor);
g_free(text);
-
+
return FALSE;
}
@@ -497,21 +497,21 @@ ui_set_display(char *str, int cursor)
str = " ";
gtk_text_buffer_set_text(X.display_buffer, str, -1);
-
+
if (cursor < 0)
gtk_text_buffer_get_end_iter(X.display_buffer, &iter);
else
gtk_text_buffer_get_iter_at_offset(X.display_buffer, &iter, cursor);
gtk_text_buffer_place_cursor(X.display_buffer, &iter);
gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(X.display_item), &iter, 0.0, TRUE, 1.0, 0.0);
-
+
/* This is a workaround for bug #524602.
* Basically the above code can cause the display to disappear when going from
* a display that is wider than the widget to one that is thinner. The following
* causes the display to be set twice which seems to work the second time.
*/
g_idle_add(redo_display, NULL);
-
+
/* Align to the right */
if (cursor < 0) {
adj = gtk_scrolled_window_get_hadjustment(
@@ -536,7 +536,7 @@ about_cb(GtkWidget *widget)
"Sun Microsystems",
NULL
};
-
+
/* Translators: The translator credits. Please translate this with your name(s). */
const gchar *translator_credits = _("translator-credits");
@@ -577,12 +577,12 @@ void
ascii_dialog_response_cb(GtkWidget *dialog, gint response_id)
{
const gchar *text;
-
+
text = gtk_entry_get_text(GTK_ENTRY(X.ascii_entry));
-
+
if (response_id == GTK_RESPONSE_OK)
do_button(FN_INSERT_CHARACTER, GPOINTER_TO_INT(text));
-
+
gtk_widget_hide(dialog);
}
@@ -612,7 +612,7 @@ help_display(void)
screen = gtk_widget_get_screen (GTK_WIDGET (X.main_window));
gtk_show_uri (screen, "ghelp:gcalctool", gtk_get_current_event_time (), &error);
-
+
if (error != NULL)
{
GtkWidget *d;
@@ -627,7 +627,7 @@ help_display(void)
"%s", error->message);
g_signal_connect (d, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (d));
-
+
g_error_free (error);
}
}
@@ -658,7 +658,7 @@ finc_activate_cb(GtkWidget *widget) {
dialog = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "finc_dialog"));
field = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "finc_field"));
-
+
if (finc_dialog_fields[dialog][field+1] == NULL) {
GtkWidget *dialog_widget;
dialog_widget = gtk_widget_get_toplevel(widget);
@@ -687,7 +687,7 @@ finc_response_cb(GtkWidget *widget, gint response_id)
if (response_id != GTK_RESPONSE_OK)
return;
-
+
dialog = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(widget), "finc_dialog"));
for (i = 0; i < 4; i++) {
@@ -709,10 +709,10 @@ static void
setup_finc_dialogs(void)
{
int i, j;
-
+
X.financial = gtk_builder_new();
load_ui(X.financial, UI_FINC_FILE);
-
+
set_int_data(X.financial, "ctrm_dialog", "finc_dialog", FINC_CTRM_DIALOG);
set_int_data(X.financial, "ddb_dialog", "finc_dialog", FINC_DDB_DIALOG);
set_int_data(X.financial, "fv_dialog", "finc_dialog", FINC_FV_DIALOG);
@@ -723,7 +723,7 @@ setup_finc_dialogs(void)
set_int_data(X.financial, "sln_dialog", "finc_dialog", FINC_SLN_DIALOG);
set_int_data(X.financial, "syd_dialog", "finc_dialog", FINC_SYD_DIALOG);
set_int_data(X.financial, "term_dialog", "finc_dialog", FINC_TERM_DIALOG);
-
+
for (i = 0; finc_dialog_fields[i][0] != NULL; i++) {
for (j = 0; finc_dialog_fields[i][j]; j++) {
GObject *o;
@@ -732,7 +732,7 @@ setup_finc_dialogs(void)
g_object_set_data(o, "finc_dialog", GINT_TO_POINTER(i));
}
}
-
+
gtk_builder_connect_signals(X.financial, NULL);
}
@@ -774,12 +774,12 @@ update_memory_menus()
for (i = 0; i < MAX_REGISTERS; i++) {
const char *name, *register_prefix;
-
+
name = register_get_name(i);
- /* Translators: R is the short form of register used inter alia in popup menus */
+ /* Translators: R is the short form of register used inter alia in popup menus */
register_prefix = _("R");
-
+
display_make_number(&v->display, value, MAXLINE, register_get_value(i));
if (name[0] != '\0')
SNPRINTF(mstr, MAXLINE, "<span weight=\"bold\">%s_%d:</span> %s [%s]", register_prefix, i, value, name);
@@ -827,7 +827,7 @@ check_for_localized_numeric_point(int keyval)
G_MODULE_EXPORT
-void
+void
help_cb(GtkWidget *widget)
{
help_display();
@@ -876,10 +876,10 @@ popup_cb(GtkWidget *widget, GdkEventButton *event)
GtkWidget *menu;
GdkPoint loc;
- /* If gcalctool is being driven by gok, the on-screen keyboard
- * assistive technology, it's possible that the event returned by
- * gtk_get_current_event() is NULL. If this is the case, we need
- * to fudge the popping up on the menu associated with this menu
+ /* If gcalctool is being driven by gok, the on-screen keyboard
+ * assistive technology, it's possible that the event returned by
+ * gtk_get_current_event() is NULL. If this is the case, we need
+ * to fudge the popping up on the menu associated with this menu
* button.
*/
@@ -888,7 +888,7 @@ popup_cb(GtkWidget *widget, GdkEventButton *event)
menu = (GtkWidget *)g_object_get_data(G_OBJECT(widget), "calc_menu");
if (event == NULL) {
GtkAllocation allocation;
-
+
gdk_window_get_origin(gtk_widget_get_window(widget), &loc.x, &loc.y);
gtk_widget_get_allocation(widget, &allocation);
loc.x += allocation.x;
@@ -919,7 +919,7 @@ digit_cb(GtkWidget *widget, GdkEventButton *event)
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(X.subscript_toggle)))
do_text(g_object_get_data(G_OBJECT(widget), "calc_subscript_text"));
else
- do_text(g_object_get_data(G_OBJECT(widget), "calc_text"));
+ do_text(g_object_get_data(G_OBJECT(widget), "calc_text"));
}
@@ -935,7 +935,7 @@ button_cb(GtkWidget *widget, GdkEventButton *event)
select_display_entry(int offset)
{
GtkTextIter iter;
-
+
gtk_text_buffer_get_iter_at_offset(X.display_buffer, &iter, offset);
gtk_text_buffer_place_cursor(X.display_buffer, &iter);
gtk_widget_grab_focus(X.display_item);
@@ -949,18 +949,18 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
int i, state;
const char *conversions[] = {"-", "*", "/", "\t", NULL};
const char *conversion_values[] = {"â??", "Ã?", "÷", " ", };
-
+
/* Only look at the modifiers we use */
state = event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK);
-
+
// FIXME: Convert event to character
// FIXME: Or safer to intercept characters as they enter the text input (handles input methods)
-
+
if (check_for_localized_numeric_point(event->keyval) == TRUE) {
event->state = 0;
event->keyval = GDK_KP_Decimal;
}
-
+
/* Shortcuts */
if (state == GDK_CONTROL_MASK) {
switch(event->keyval)
@@ -997,7 +997,7 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
return TRUE;
case GDK_u:
do_text("µ");
- return TRUE;
+ return TRUE;
case GDK_e:
do_text("Ã?10^");
return TRUE;
@@ -1050,7 +1050,7 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
return TRUE;
}
}
-
+
/* Delete in display */
if (event->keyval == GDK_Delete && state == 0 && (event->state & GDK_SHIFT_MASK) == 0) {
do_button(FN_DELETE, 0);
@@ -1060,7 +1060,7 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
do_button(FN_BACKSPACE, 0);
return TRUE;
}
-
+
/* Clear display */
if ((event->keyval == GDK_Escape && state == 0) ||
(event->keyval == GDK_BackSpace && state == GDK_CONTROL_MASK) ||
@@ -1068,19 +1068,19 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
do_button(FN_CLEAR, 0);
return TRUE;
}
-
+
/* Solve */
if ((event->keyval == GDK_Return && state == 0) ||
(event->keyval == GDK_KP_Enter && state == 0)) {
do_button(FN_CALCULATE, 0);
return TRUE;
}
-
+
if (state != 0)
return FALSE;
-
+
// FIXME: event->string deprecated
-
+
for (i = 0; conversions[i]; i++) {
if (strcmp(event->string, conversions[i]) == 0) {
do_text(conversion_values[i]);
@@ -1091,7 +1091,7 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
do_text(v->radix);
return TRUE;
}
-
+
/* Some keyboards use this keyval for '^' (e.g. German) */
if (event->keyval == GDK_dead_circumflex) {
do_text("^");
@@ -1102,7 +1102,7 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
{
case '<':
button_cb(GET_WIDGET("calc_shift_left_button"), NULL);
- return TRUE;
+ return TRUE;
case '>':
button_cb(GET_WIDGET("calc_shift_right_button"), NULL);
return TRUE;
@@ -1111,12 +1111,12 @@ main_window_key_press_cb(GtkWidget *widget, GdkEventKey *event)
do_button(FN_CALCULATE, 0);
return TRUE;
}
-
+
if (event->string[0] != '\0') {
do_text(event->string);
return TRUE;
}
-
+
return FALSE;
}
@@ -1125,18 +1125,18 @@ G_MODULE_EXPORT void
edit_cb(GtkWidget *widget)
{
gboolean can_paste, can_copy;
-
+
can_copy = gtk_text_buffer_get_has_selection(X.display_buffer);
can_paste = gtk_clipboard_wait_is_text_available(
gtk_clipboard_get(X.clipboard_atom));
-
+
gtk_widget_set_sensitive(GET_WIDGET("copy_menu"), can_copy);
gtk_widget_set_sensitive(GET_WIDGET("paste_menu"), can_paste);
}
G_MODULE_EXPORT
-void
+void
copy_cb(GtkWidget *widget)
{
get_display();
@@ -1164,7 +1164,7 @@ middle_click_paste_cb(GtkWidget *widget, GdkEventButton *event)
G_MODULE_EXPORT
-void
+void
paste_cb(GtkWidget *widget)
{
gtk_clipboard_request_text(gtk_clipboard_get(X.clipboard_atom),
@@ -1173,7 +1173,7 @@ paste_cb(GtkWidget *widget)
G_MODULE_EXPORT
-void
+void
popup_paste_cb(GtkWidget *menu)
{
paste_cb(menu);
@@ -1192,7 +1192,7 @@ G_MODULE_EXPORT
void
redo_cb(GtkWidget *widget)
{
- do_button(FN_REDO, 0);
+ do_button(FN_REDO, 0);
}
@@ -1240,7 +1240,7 @@ G_MODULE_EXPORT
void
shift_cb(GtkWidget *widget)
{
- int count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
+ int count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
"shiftcount"));
do_button(FN_SHIFT, count);
}
@@ -1301,7 +1301,7 @@ create_main_window()
GtkWidget *widget;
PangoFontDescription *font_desc;
GtkCellRenderer *renderer;
-
+
X.ui = gtk_builder_new();
load_ui(X.ui, UI_FILE);
gtk_builder_connect_signals(X.ui, NULL);
@@ -1324,7 +1324,7 @@ create_main_window()
X.subscript_toggle = GET_WIDGET("subscript_togglebutton");
X.preferences_dialog = GET_WIDGET("preferences_dialog");
X.info_buffer = GTK_TEXT_BUFFER(GET_OBJECT("info_buffer"));
-
+
/* Connect text to buttons */
for (i = 0; button_data[i].widget_name != NULL; i++) {
SNPRINTF(name, MAXLINE, "calc_%s_button", button_data[i].widget_name);
@@ -1361,11 +1361,11 @@ create_main_window()
widget = GET_WIDGET(name);
g_object_set_data(G_OBJECT(widget), "register_id", GINT_TO_POINTER(i));
X.memory_store_labels[i] = gtk_bin_get_child(GTK_BIN(widget));
-
+
SNPRINTF(name, MAXLINE, "recall_menu_item%d", i);
widget = GET_WIDGET(name);
g_object_set_data(G_OBJECT(widget), "register_id", GINT_TO_POINTER(i));
- X.memory_recall_labels[i] = gtk_bin_get_child(GTK_BIN(widget));
+ X.memory_recall_labels[i] = gtk_bin_get_child(GTK_BIN(widget));
}
/* Load bit panel */
@@ -1386,7 +1386,7 @@ create_main_window()
gtk_widget_modify_font(X.display_item, font_desc);
pango_font_description_free(font_desc);
gtk_widget_set_name(X.display_item, "displayitem");
- atk_object_set_role(gtk_widget_get_accessible(X.display_item),
+ atk_object_set_role(gtk_widget_get_accessible(X.display_item),
ATK_ROLE_EDITBAR);
gtk_widget_realize(X.main_window);
@@ -1415,7 +1415,7 @@ create_main_window()
set_data(X.ui, "calc_finc_straight_line_depreciation_button", "finc_dialog", "sln_dialog");
set_data(X.ui, "calc_finc_sum_of_the_years_digits_depreciation_button", "finc_dialog", "syd_dialog");
set_data(X.ui, "calc_finc_term_button", "finc_dialog", "term_dialog");
-
+
/* Configuration dialog */
widget = GET_WIDGET("angle_unit_combobox");
@@ -1427,19 +1427,19 @@ create_main_window()
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
-
+
widget = GET_WIDGET("word_size_combobox");
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
-
+
// _("Show %d decimal places") decimal_places_label1, decimal_places_label2
}
void
ui_init(int *argc, char ***argv)
-{
+{
gchar *path;
int value;
@@ -1448,7 +1448,7 @@ ui_init(int *argc, char ***argv)
memset(&X, 0, sizeof(X));
gtk_rc_get_default_files();
-
+
if (get_enumerated_resource(R_MODE, mode_names, &value))
X.mode = (ModeType) value;
else
@@ -1481,7 +1481,7 @@ angle_unit_combobox_changed_cb(GtkWidget *combo)
{"gradians", MP_GRADIANS},
{NULL, MP_DEGREES}
};
-
+
model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
gtk_tree_model_get(model, &iter, 1, &value, -1);
@@ -1532,7 +1532,7 @@ word_size_combobox_changed_cb(GtkWidget *combo)
gint value;
GtkTreeModel *model;
GtkTreeIter iter;
-
+
model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
gtk_tree_model_get(model, &iter, 1, &value, -1);
@@ -1588,11 +1588,11 @@ set_combo_box_from_config(const gchar *name, const gchar *key_name, GType key_ty
int int_key_value;
GtkTreeIter iter;
gboolean valid;
-
+
combo = GET_WIDGET(name);
model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
valid = gtk_tree_model_get_iter_first(model, &iter);
-
+
switch (key_type)
{
case G_TYPE_STRING:
@@ -1612,7 +1612,7 @@ set_combo_box_from_config(const gchar *name, const gchar *key_name, GType key_ty
gchar *str_value;
gint int_value;
gboolean matched = FALSE;
-
+
switch (key_type)
{
case G_TYPE_STRING:
@@ -1620,23 +1620,23 @@ set_combo_box_from_config(const gchar *name, const gchar *key_name, GType key_ty
matched = strcmp(str_value, str_key_value) == 0;
break;
case G_TYPE_INT:
- gtk_tree_model_get(model, &iter, 1, &int_value, -1);
+ gtk_tree_model_get(model, &iter, 1, &int_value, -1);
matched = int_value == int_key_value;
break;
default:
break;
}
-
+
if (matched)
break;
-
+
valid = gtk_tree_model_iter_next(model, &iter);
}
if (!valid)
valid = gtk_tree_model_get_iter_first(model, &iter);
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
-
+
g_free(str_key_value);
}
@@ -1645,23 +1645,23 @@ void
ui_load(void)
{
int value;
-
+
/* Create main gcalctool window. */
create_main_window();
ui_set_undo_enabled(FALSE, FALSE);
-
+
set_combo_box_from_config("angle_unit_combobox", R_TRIG, G_TYPE_STRING);
set_combo_box_from_config("display_format_combobox", R_DISPLAY, G_TYPE_STRING);
set_combo_box_from_config("word_size_combobox", R_WORDLEN, G_TYPE_INT);
-
+
if (!get_int_resource(R_ACCURACY, &value))
value = 9;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(GET_OBJECT("decimal_places_spin")), value);
-
+
if (!get_boolean_resource(R_TSEP, &value))
value = FALSE;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GET_OBJECT("thousands_separator_check")), value);
-
+
if (!get_boolean_resource(R_ZEROES, &value))
value = FALSE;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GET_OBJECT("trailing_zeroes_check")), value);
@@ -1673,7 +1673,7 @@ add_buttons_to_size_group()
{
int i;
GtkSizeGroup *size_group;
-
+
const char *button_names[] = {
"calc_finc_straight_line_depreciation_button",
"calc_finc_periodic_interest_rate_button",
@@ -1769,13 +1769,13 @@ add_buttons_to_size_group()
void
ui_start(void)
-{
+{
ui_set_mode(X.mode);
gtk_widget_show(X.main_window);
/* Add buttons to size group so they are all the same size.
- *
+ *
* This is supported in GtkBuilder but it does not appear to work, setting
* the group after showing the widgets works. It would have been preferrable
* to make the table homogeneous but this does not ignore hidden rows.
diff --git a/src/mp-binary.c b/src/mp-binary.c
index 5de3186..b27b467 100644
--- a/src/mp-binary.c
+++ b/src/mp-binary.c
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -44,7 +44,7 @@ mp_bitwise(const MPNumber *x, const MPNumber *y, int (*bitwise_operator)(int, in
{
char text1[MAX_DIGITS], text2[MAX_DIGITS], text_out[MAX_DIGITS], text_out2[MAX_DIGITS];
int offset1, offset2, offset_out;
-
+
mp_cast_to_string(x, 16, 0, 0, text1, MAX_DIGITS);
mp_cast_to_string(y, 16, 0, 0, text2, MAX_DIGITS);
offset1 = strlen(text1) - 1 - strlen("â??â??");
@@ -57,11 +57,11 @@ mp_bitwise(const MPNumber *x, const MPNumber *y, int (*bitwise_operator)(int, in
mperr("Overflow. Try a bigger word size");
return;
}
-
+
/* Perform bitwise operator on each character from right to left */
for (text_out[offset_out+1] = '\0'; offset_out >= 0; offset_out--) {
int v1 = 0, v2 = 0;
-
+
if (offset1 >= 0) {
v1 = hex_to_int(text1[offset1]);
offset1--;
@@ -72,7 +72,7 @@ mp_bitwise(const MPNumber *x, const MPNumber *y, int (*bitwise_operator)(int, in
}
text_out[offset_out] = digits[bitwise_operator(v1, v2)];
}
-
+
snprintf(text_out2, MAX_DIGITS, "%sâ??â??", text_out);
mp_set_from_string(text_out2, z);
}
@@ -112,7 +112,7 @@ mp_or(const MPNumber *x, const MPNumber *y, MPNumber *z)
{
if (!mp_is_natural(x) || !mp_is_natural(y))
{
- /* Translators: Error displayed when boolean OR attempted on non-integer values */
+ /* Translators: Error displayed when boolean OR attempted on non-integer values */
mperr(_("Boolean OR only defined for natural numbers"));
}
@@ -137,7 +137,7 @@ void
mp_not(const MPNumber *x, int wordlen, MPNumber *z)
{
MPNumber temp;
-
+
if (!mp_is_natural(x))
{
/* Translators: Error displayed when boolean XOR attempted on non-integer values */
@@ -154,7 +154,7 @@ mp_mask(const MPNumber *x, int wordlen, MPNumber *z)
{
char text[MAX_DIGITS];
size_t len, offset;
-
+
/* Convert to a hexadecimal string and use last characters */
mp_cast_to_string(x, 16, 0, 0, text, MAX_DIGITS);
len = strlen(text) - strlen("â??â??");
@@ -168,13 +168,13 @@ void
mp_shift(const MPNumber *x, int count, MPNumber *z)
{
int i, multiplier = 1;
-
+
if (!mp_is_integer(x)) {
/* Translators: Error displayed when bit shift attempted on non-integer values */
mperr(_("Shift only possible on integer values"));
return;
}
-
+
if (count >= 0) {
for (i = 0; i < count; i++)
multiplier *= 2;
diff --git a/src/mp-convert.c b/src/mp-convert.c
index e5ac3d5..976e05f 100644
--- a/src/mp-convert.c
+++ b/src/mp-convert.c
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -38,9 +38,9 @@ mp_set_from_float(float rx, MPNumber *z)
{
int i, k, i2, ib, ie, tp;
float rb, rj;
-
+
i2 = MP_T + 4;
-
+
memset(z, 0, sizeof(MPNumber));
/* CHECK SIGN */
@@ -58,7 +58,7 @@ mp_set_from_float(float rx, MPNumber *z)
ie = 0;
- /* INCREASE IE AND DIVIDE RJ BY 16. */
+ /* INCREASE IE AND DIVIDE RJ BY 16. */
while (rj >= (float)1.0) {
++ie;
rj *= (float) 0.0625;
@@ -133,7 +133,7 @@ mp_set_from_double(double dx, MPNumber *z)
} else {
mp_set_from_integer(0, z);
return;
- }
+ }
/* INCREASE IE AND DIVIDE DJ BY 16. */
for (ie = 0; dj >= 1.0; ie++)
@@ -272,7 +272,7 @@ mp_cast_to_int(const MPNumber *x)
j = ret_val;
for (i = x2 - 1; i >= 0; i--) {
int j1, kx;
-
+
j1 = j / MP_BASE;
kx = 0;
if (i < MP_T)
@@ -298,7 +298,7 @@ static double
mppow_ri(float ap, int bp)
{
double pow;
-
+
if (bp == 0)
return 1.0;
@@ -308,9 +308,9 @@ mppow_ri(float ap, int bp)
bp = -bp;
ap = 1 / ap;
}
-
+
pow = 1.0;
- for (;;) {
+ for (;;) {
if (bp & 01)
pow *= ap;
if (bp >>= 1)
@@ -318,7 +318,7 @@ mppow_ri(float ap, int bp)
else
break;
}
-
+
return pow;
}
@@ -328,7 +328,7 @@ mp_cast_to_float(const MPNumber *x)
{
int i;
float rb, rz = 0.0;
-
+
if (x->sign == 0)
return 0.0;
@@ -367,13 +367,13 @@ mppow_di(double ap, int bp)
{
double pow = 1.0;
- if (bp != 0) {
+ if (bp != 0) {
if (bp < 0) {
if (ap == 0) return(pow);
bp = -bp;
ap = 1/ap;
}
- for (;;) {
+ for (;;) {
if (bp & 01) pow *= ap;
if (bp >>= 1) ap *= ap;
else break;
@@ -438,14 +438,14 @@ mp_cast_to_string(const MPNumber *x, int base, int accuracy, int trim_zeroes, ch
MPNumber number, integer_component, fractional_component, MPbase, temp;
int i, last_non_zero;
GString *string;
-
+
string = g_string_sized_new(buffer_length);
if (mp_is_negative(x))
mp_abs(x, &number);
else
mp_set_from_mp(x, &number);
-
+
/* Add rounding factor */
mp_set_from_integer(base, &MPbase);
mp_xpowy_integer(&MPbase, -(accuracy+1), &temp);
@@ -455,28 +455,28 @@ mp_cast_to_string(const MPNumber *x, int base, int accuracy, int trim_zeroes, ch
/* Split into integer and fractional component */
mp_integer_component(&number, &integer_component);
- mp_fractional_component(&number, &fractional_component);
+ mp_fractional_component(&number, &fractional_component);
/* Write out the integer component least significant digit to most */
mp_set_from_mp(&integer_component, &temp);
do {
MPNumber t, t2, t3;
-
+
mp_divide_integer(&temp, base, &t);
mp_integer_component(&t, &t);
mp_multiply_integer(&t, base, &t2);
-
+
mp_subtract(&temp, &t2, &t3);
mp_integer_component(&t3, &t3);
g_string_prepend_c(string, digits[mp_cast_to_int(&t3)]);
-
+
mp_set_from_mp(&t, &temp);
} while (!mp_is_zero(&temp));
last_non_zero = string->len;
g_string_append_c(string, '.');
-
+
/* Write out the fractional component */
mp_set_from_mp(&fractional_component, &temp);
for (i = accuracy; i > 0 && !mp_is_zero(&temp); i--) {
@@ -486,7 +486,7 @@ mp_cast_to_string(const MPNumber *x, int base, int accuracy, int trim_zeroes, ch
mp_multiply_integer(&temp, base, &temp);
mp_integer_component(&temp, &digit);
d = mp_cast_to_int(&digit);
-
+
g_string_append_c(string, digits[d]);
if(d != 0)
@@ -497,7 +497,7 @@ mp_cast_to_string(const MPNumber *x, int base, int accuracy, int trim_zeroes, ch
/* Strip trailing zeroes */
if (trim_zeroes || accuracy == 0)
g_string_truncate(string, last_non_zero);
-
+
/* Remove negative sign if the number was rounded down to zero */
if (mp_is_negative(x) && strcmp(string->str, "0") != 0)
g_string_prepend(string, "â??");
@@ -517,7 +517,7 @@ mp_cast_to_string(const MPNumber *x, int base, int accuracy, int trim_zeroes, ch
g_string_append(string, "â??â??");
break;
}
-
+
// FIXME: Check for truncation
strncpy(buffer, string->str, buffer_length);
g_string_free(string, TRUE);
@@ -585,7 +585,7 @@ char_val(char **c, int base)
}
if (value >= base)
return -1;
-
+
*c += offset;
return value;
@@ -598,7 +598,7 @@ mp_set_from_string(const char *str, MPNumber *z)
int i, base, negate = 0, multiplier = 0;
const char *c, *end;
gboolean has_fraction = FALSE;
-
+
const char *base_suffixes[] = {"â??", "â??", "â??â??", NULL};
int base_values[] = {2, 8, 16, 10};
const char *fractions[] = {"½", "â??", "â??", "¼", "¾", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", NULL};
@@ -606,7 +606,7 @@ mp_set_from_string(const char *str, MPNumber *z)
int denominators[] = { 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 8, 8, 8, 8};
const char *si_suffixes[] = {"T", "G", "M", "k", "d", "c", "m", "u", "µ", "n", "p", "f", NULL};
int si_multipliers[] = { 12, 9, 6, 3, -1, -2, -3, -6, -6, -9, -12, -15};
-
+
/* Find the base */
end = str;
while (*end != '\0')
@@ -637,7 +637,7 @@ mp_set_from_string(const char *str, MPNumber *z)
mp_multiply_integer(z, base, z);
mp_add_integer(z, i, z);
}
-
+
/* Look for fraction characters, e.g. â?? */
for (i = 0; fractions[i] != NULL; i++) {
if (end - strlen(fractions[i]) < str)
@@ -650,7 +650,7 @@ mp_set_from_string(const char *str, MPNumber *z)
mp_set_from_fraction(numerators[i], denominators[i], &fraction);
mp_add(z, &fraction, z);
}
-
+
if (*c == '.') {
has_fraction = TRUE;
c++;
@@ -665,7 +665,7 @@ mp_set_from_string(const char *str, MPNumber *z)
c += strlen(si_suffixes[i]);
}
}
-
+
/* Convert fractional part */
if (has_fraction) {
MPNumber numerator, denominator;
@@ -680,18 +680,18 @@ mp_set_from_string(const char *str, MPNumber *z)
mp_divide(&numerator, &denominator, &numerator);
mp_add(z, &numerator, z);
}
-
+
if (c != end) {
return 1;
}
-
+
if (multiplier != 0) {
MPNumber t;
mp_set_from_integer(10, &t);
mp_xpowy_integer(&t, multiplier, &t);
mp_multiply(z, &t, z);
}
-
+
if (negate == 1)
mp_invert_sign(z, z);
diff --git a/src/mp-equation-lexer.l b/src/mp-equation-lexer.l
index 8531304..668b975 100644
--- a/src/mp-equation-lexer.l
+++ b/src/mp-equation-lexer.l
@@ -13,12 +13,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -37,7 +37,7 @@ static int super_atoi(const char *data)
{
int i, value = 0;
const char *digits[11] = {"�", "¹", "²", "³", "�", "�", "�", "�", "�", "�", NULL};
-
+
while(*data != '\0') {
for(i = 0; digits[i] != NULL && strncmp(data, digits[i], strlen(digits[i])) != 0; i++);
if(digits[i] == NULL)
@@ -45,7 +45,7 @@ static int super_atoi(const char *data)
value = value * 10 + i;
data += strlen(digits[i]);
}
-
+
return value;
}
@@ -61,7 +61,7 @@ static int sub_atoi(const char *data)
data += strlen(digits[i]);
value = value * 10 + i;
}
-
+
return value;
}
%}
@@ -134,4 +134,4 @@ NOT "¬"|"~"|[nN][oO][tT]
[ \t\n]
. {return *yytext;}
-%%
+%%
diff --git a/src/mp-equation-parser.y b/src/mp-equation-parser.y
index 33d352b..ae671fa 100644
--- a/src/mp-equation-parser.y
+++ b/src/mp-equation-parser.y
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -19,7 +19,7 @@
*/
#include <stdio.h>
-#include <stdlib.h>
+#include <stdlib.h>
#include <math.h>
#include <errno.h>
diff --git a/src/mp-equation-private.h b/src/mp-equation-private.h
index 333e6f9..d47d60a 100644
--- a/src/mp-equation-private.h
+++ b/src/mp-equation-private.h
@@ -28,13 +28,13 @@ typedef struct MPEquationParserState MPEquationParserState;
struct MPEquationParserState {
/* User provided options */
MPEquationOptions *options;
-
+
/* Function to get variable values */
int (*get_variable)(MPEquationParserState *state, const char *name, MPNumber *z);
-
+
/* Function to set variable values */
void (*set_variable)(MPEquationParserState *state, const char *name, const MPNumber *x);
-
+
/* Function to solve functions */
int (*get_function)(MPEquationParserState *state, const char *name, const MPNumber *x, MPNumber *z);
diff --git a/src/mp-equation.c b/src/mp-equation.c
index f129904..91d6690 100644
--- a/src/mp-equation.c
+++ b/src/mp-equation.c
@@ -5,12 +5,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -29,7 +29,7 @@ static int
get_variable(MPEquationParserState *state, const char *name, MPNumber *z)
{
int result = 1;
-
+
if (strcmp(name, "e") == 0)
mp_get_eulers(z);
else if (strcmp(name, "Ï?") == 0)
@@ -47,7 +47,7 @@ set_variable(MPEquationParserState *state, const char *name, const MPNumber *x)
{
if (strcmp(name, "e") == 0 || strcmp(name, "Ï?") == 0)
return; // FALSE
-
+
if (state->options->set_variable)
state->options->set_variable(name, x, state->options->callback_data);
}
@@ -62,7 +62,7 @@ static int sub_atoi(const char *data)
{
int i, value = 0;
const char *digits[] = {"â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", NULL};
-
+
do {
for(i = 0; digits[i] != NULL && strncmp(data, digits[i], strlen(digits[i])) != 0; i++);
if(digits[i] == NULL)
@@ -80,18 +80,18 @@ get_function(MPEquationParserState *state, const char *name, const MPNumber *x,
{
char *c, *lower_name;
int result = 1;
-
+
lower_name = strdup(name);
for (c = lower_name; *c; c++)
*c = tolower(*c);
-
+
// FIXME: Re Im ?
if (strcmp(lower_name, "log") == 0)
mp_logarithm(10, x, z); // FIXME: Default to ln
else if (strncmp(lower_name, "log", 3) == 0) {
int base;
-
+
base = sub_atoi(lower_name + 3);
if (base < 0)
result = 0;
@@ -113,13 +113,13 @@ get_function(MPEquationParserState *state, const char *name, const MPNumber *x,
else if (strcmp(lower_name, "cos") == 0)
mp_cos(x, state->options->angle_units, z);
else if (strcmp(lower_name, "tan") == 0)
- mp_tan(x, state->options->angle_units, z);
+ mp_tan(x, state->options->angle_units, z);
else if (strcmp(lower_name, "sin�¹") == 0 || strcmp(lower_name, "asin") == 0)
mp_asin(x, state->options->angle_units, z);
else if (strcmp(lower_name, "cos�¹") == 0 || strcmp(lower_name, "acos") == 0)
mp_acos(x, state->options->angle_units, z);
else if (strcmp(lower_name, "tan�¹") == 0 || strcmp(lower_name, "atan") == 0)
- mp_atan(x, state->options->angle_units, z);
+ mp_atan(x, state->options->angle_units, z);
else if (strcmp(lower_name, "sinh") == 0)
mp_sinh(x, z);
else if (strcmp(lower_name, "cosh") == 0)
@@ -140,9 +140,9 @@ get_function(MPEquationParserState *state, const char *name, const MPNumber *x,
result = state->options->get_function(name, x, z, state->options->callback_data);
else
result = 0;
-
+
free(lower_name);
-
+
return result;
}
@@ -178,7 +178,7 @@ mp_equation_parse(const char *expression, MPEquationOptions *options, MPNumber *
/* Failed to parse */
if (ret)
return -PARSER_ERR_INVALID;
-
+
/* Error during parsing */
if (state.error)
return state.error;
diff --git a/src/mp-equation.h b/src/mp-equation.h
index 8d4c59e..b9cd8e0 100644
--- a/src/mp-equation.h
+++ b/src/mp-equation.h
@@ -32,19 +32,19 @@
typedef struct {
/* The wordlength for binary operations in bits (e.g. 8, 16, 32) */
int wordlen;
-
+
/* Units for angles (e.g. radians, degrees) */
MPAngleUnit angle_units;
-
+
// FIXME:
// int enable_builtins;
-
+
/* Data to pass to callbacks */
void *callback_data;
-
+
/* Function to get variable values */
int (*get_variable)(const char *name, MPNumber *z, void *data);
-
+
/* Function to set variable values */
void (*set_variable)(const char *name, const MPNumber *x, void *data);
diff --git a/src/mp-internal.h b/src/mp-internal.h
index 367b072..de3eb34 100644
--- a/src/mp-internal.h
+++ b/src/mp-internal.h
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
diff --git a/src/mp-trigonometric.c b/src/mp-trigonometric.c
index ff90108..ba51adc 100644
--- a/src/mp-trigonometric.c
+++ b/src/mp-trigonometric.c
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -28,7 +28,7 @@
static int
mp_compare_mp_to_int(const MPNumber *x, int i)
{
- MPNumber t;
+ MPNumber t;
mp_set_from_integer(i, &t);
return mp_compare_mp_to_mp(x, &t);
}
@@ -52,7 +52,7 @@ convert_to_radians(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_divide_integer(&t2, 180, z);
break;
- case MP_GRADIANS:
+ case MP_GRADIANS:
mp_get_pi(&t1);
mp_multiply(x, &t1, &t2);
mp_divide_integer(&t2, 200, z);
@@ -72,19 +72,19 @@ static void
convert_from_radians(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
MPNumber t1, t2;
-
+
switch (unit) {
default:
case MP_RADIANS:
mp_set_from_mp(x, z);
break;
-
+
case MP_DEGREES:
mp_multiply_integer(x, 180, &t2);
mp_get_pi(&t1);
mp_divide(&t2, &t1, z);
break;
-
+
case MP_GRADIANS:
mp_multiply_integer(x, 200, &t2);
mp_get_pi(&t1);
@@ -145,7 +145,7 @@ mpsin1(const MPNumber *x, MPNumber *z, int do_sin)
mp_divide_integer(&t1, -i * (i + 1), &t1);
}
mp_add(&t1, z, z);
-
+
i += 2;
} while (t1.sign != 0);
@@ -207,7 +207,7 @@ mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
if (x_radians.sign == 0) {
mp_set_from_integer(0, z);
return;
- }
+ }
x_radians.sign = 1;
mp_multiply_integer(&x_radians, 2, &x_radians);
@@ -242,7 +242,7 @@ mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
void
mp_cos(const MPNumber *xi, MPAngleUnit unit, MPNumber *z)
{
- /* cos(0) = 1 */
+ /* cos(0) = 1 */
if (xi->sign == 0) {
mp_set_from_integer(1, z);
return;
@@ -266,7 +266,7 @@ mp_cos(const MPNumber *xi, MPAngleUnit unit, MPNumber *z)
}
-void
+void
mp_tan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
MPNumber cos_x, sin_x;
@@ -278,7 +278,7 @@ mp_tan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mperr(_("Tangent not defined for angles that are multiples of Ï?â??2 (180°) from Ï?â??4 (90°)"));
return;
}
-
+
/* tan(x) = sin(x) / cos(x) */
mp_sin(x, unit, &sin_x);
mp_divide(&sin_x, &cos_x, z);
@@ -319,7 +319,7 @@ mp_asin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
/* X == +-1 SO RETURN +-PI/2 */
mp_get_pi(z);
mp_divide_integer(z, t2.sign << 1, z);
-
+
convert_from_radians(z, unit, z);
}
@@ -344,7 +344,7 @@ mp_acos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_set_from_integer(0, z);
} else if (mp_is_equal(x, &MPn1)) {
mp_set_from_mp(&pi, z);
- } else {
+ } else {
mp_multiply(x, x, &t2);
mp_subtract(&t1, &t2, &t2);
mp_sqrt(&t2, &t2);
@@ -356,7 +356,7 @@ mp_acos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_add(&MPy, &pi, z);
}
}
-
+
convert_from_radians(z, unit, z);
}
@@ -400,7 +400,7 @@ mp_atan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
for (i = 1; ; i += 2) {
if (MP_T + 2 + t2.exponent <= 1)
break;
-
+
mp_multiply(&t2, &t1, &t2);
mp_multiply_fraction(&t2, -i, i + 2, &t2);
@@ -443,7 +443,7 @@ mp_sinh(const MPNumber *x, MPNumber *z)
/* If |x| < 1 USE MPEXP TO AVOID CANCELLATION, otherwise IF TOO LARGE MP_EPOWY GIVES ERROR MESSAGE */
if (abs_x.exponent <= 0) {
MPNumber exp_x, a, b;
-
+
/* ((e^|x| + 1) * (e^|x| - 1)) / e^|x| */
// FIXME: Solves to e^|x| - e^-|x|, why not lower branch always? */
mp_epowy(&abs_x, &exp_x);
@@ -472,7 +472,7 @@ mp_cosh(const MPNumber *x, MPNumber *z)
{
MPNumber t;
- /* cosh(0) = 1 */
+ /* cosh(0) = 1 */
if (x->sign == 0) {
mp_set_from_integer(1, z);
return;
@@ -493,7 +493,7 @@ mp_tanh(const MPNumber *x, MPNumber *z)
float r__1;
MPNumber t;
- /* tanh(0) = 0 */
+ /* tanh(0) = 0 */
if (x->sign == 0) {
mp_set_from_integer(0, z);
return;
@@ -555,7 +555,7 @@ mp_acosh(const MPNumber *x, MPNumber *z)
mp_set_from_integer(0, z);
return;
}
-
+
/* acosh(x) = ln(x + sqrt(x^2 - 1)) */
mp_multiply(x, x, &t);
mp_add_integer(&t, -1, &t);
@@ -579,7 +579,7 @@ mp_atanh(const MPNumber *x, MPNumber *z)
mp_set_from_integer(0, z);
return;
}
-
+
/* atanh(x) = 0.5 * ln((1 + x) / (1 - x)) */
mp_add_integer(x, 1, &n);
mp_set_from_mp(x, &d);
diff --git a/src/mp.c b/src/mp.c
index f2f4208..e1c4041 100644
--- a/src/mp.c
+++ b/src/mp.c
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -37,7 +37,7 @@ mperr(const char *format, ...)
{
char text[1024];
va_list args;
-
+
va_start(args, format);
vsnprintf(text, 1024, format, args);
va_end(args);
@@ -78,7 +78,7 @@ mpext(int i, int j, MPNumber *x)
q = (j + 1) / i + 1;
s = MP_BASE * x->fraction[MP_T - 2] + x->fraction[MP_T - 1];
- /* SET LAST TWO DIGITS TO ZERO */
+ /* SET LAST TWO DIGITS TO ZERO */
if (s <= q) {
x->fraction[MP_T - 2] = 0;
x->fraction[MP_T - 1] = 0;
@@ -121,7 +121,7 @@ static int
mp_add3(const MPNumber *x, const MPNumber *y, int *r, int s, int med)
{
int i, c;
-
+
/* CLEAR GUARD DIGITS TO RIGHT OF X DIGITS */
for(i = 3; i >= med; i--)
r[MP_T + i] = 0;
@@ -134,7 +134,7 @@ mp_add3(const MPNumber *x, const MPNumber *y, int *r, int s, int med)
c = 0;
for (; i >= med; i--) {
c = y->fraction[i] + x->fraction[i - med] + c;
-
+
if (c < MP_BASE) {
/* NO CARRY GENERATED HERE */
r[i] = c;
@@ -145,25 +145,25 @@ mp_add3(const MPNumber *x, const MPNumber *y, int *r, int s, int med)
c = 1;
}
}
-
+
for (; i >= 0; i--)
{
c = y->fraction[i] + c;
if (c < MP_BASE) {
r[i] = c;
i--;
-
+
/* NO CARRY POSSIBLE HERE */
for (; i >= 0; i--)
r[i] = y->fraction[i];
return 0;
}
-
+
r[i] = 0;
c = 1;
}
-
+
/* MUST SHIFT RIGHT HERE AS CARRY OFF END */
if (c != 0) {
for (i = MP_T + 3; i > 0; i--)
@@ -180,8 +180,8 @@ mp_add3(const MPNumber *x, const MPNumber *y, int *r, int s, int med)
/* HERE DO SUBTRACTION, ABS(Y) > ABS(X) */
r[i] = c - x->fraction[i - med];
c = 0;
-
- /* BORROW GENERATED HERE */
+
+ /* BORROW GENERATED HERE */
if (r[i] < 0) {
c = -1;
r[i] += MP_BASE;
@@ -195,7 +195,7 @@ mp_add3(const MPNumber *x, const MPNumber *y, int *r, int s, int med)
r[i] = c;
c = 0;
} else {
- /* BORROW GENERATED HERE */
+ /* BORROW GENERATED HERE */
r[i] = c + MP_BASE;
c = -1;
}
@@ -207,14 +207,14 @@ mp_add3(const MPNumber *x, const MPNumber *y, int *r, int s, int med)
if (c >= 0) {
r[i] = c;
i--;
-
+
/* NO CARRY POSSIBLE HERE */
for (; i >= 0; i--)
r[i] = y->fraction[i];
return 0;
}
-
+
r[i] = c + MP_BASE;
c = -1;
}
@@ -231,7 +231,7 @@ mp_add2(const MPNumber *x, const MPNumber *y, int y_sign, MPNumber *z)
int exp_diff, med;
int x_largest = 0;
MPNumber zt; // Use stack variable because of mp_normalize brokeness
-
+
memset(&zt, 0, sizeof(MPNumber));
/* X = 0 OR NEGLIGIBLE, SO RESULT = +-Y */
@@ -241,7 +241,7 @@ mp_add2(const MPNumber *x, const MPNumber *y, int y_sign, MPNumber *z)
return;
}
- /* Y = 0 OR NEGLIGIBLE, SO RESULT = X */
+ /* Y = 0 OR NEGLIGIBLE, SO RESULT = X */
if (y->sign == 0 || y->sign == 0) {
mp_set_from_mp(x, z);
return;
@@ -290,7 +290,7 @@ mp_add2(const MPNumber *x, const MPNumber *y, int y_sign, MPNumber *z)
x_largest = 1;
break;
}
-
+
/* Both mantissas equal, so result is zero. */
if (j >= MP_T) {
mp_set_from_integer(0, z);
@@ -360,7 +360,7 @@ mp_fractional_component(const MPNumber *x, MPNumber *z)
mp_set_from_mp(x, z);
return;
}
-
+
/* Shift fractional component */
shift = x->exponent;
for (i = shift; i < MP_SIZE && x->fraction[i] == 0; i++)
@@ -382,7 +382,7 @@ void
mp_integer_component(const MPNumber *x, MPNumber *z)
{
int i;
-
+
/* Integer component of zero = 0 */
if (x->sign == 0) {
mp_set_from_mp(x, z);
@@ -396,7 +396,7 @@ mp_integer_component(const MPNumber *x, MPNumber *z)
}
/* Clear fraction */
- mp_set_from_mp(x, z);
+ mp_set_from_mp(x, z);
for (i = z->exponent; i < MP_SIZE; i++)
z->fraction[i] = 0;
}
@@ -408,12 +408,12 @@ mp_compare_mp_to_mp(const MPNumber *x, const MPNumber *y)
int i;
if (x->sign != y->sign) {
- if (x->sign > y->sign)
+ if (x->sign > y->sign)
return 1;
else
return -1;
}
-
+
/* x = y = 0 */
if (x->sign == 0)
return 0;
@@ -492,7 +492,7 @@ mp_divide_integer(const MPNumber *x, int y, MPNumber *z)
mp_set_from_integer(0, z);
return;
}
-
+
/* 0/y = 0 */
if (x->sign == 0) {
mp_set_from_integer(0, z);
@@ -564,20 +564,20 @@ mp_divide_integer(const MPNumber *x, int y, MPNumber *z)
if (c < 0)
goto L210;
}
-
+
for (k = kh; k < i2; k++) {
z->fraction[k] = c / y;
c = MP_BASE * (c - y * z->fraction[k]);
}
if (c < 0)
goto L210;
-
+
/* NORMALIZE AND ROUND RESULT */
mp_normalize(z);
return;
}
-
+
/* HERE NEED SIMULATED DOUBLE-PRECISION DIVISION */
j1 = y / MP_BASE;
@@ -625,10 +625,10 @@ mp_divide_integer(const MPNumber *x, int y, MPNumber *z)
/* R(K) = QUOTIENT, C = REMAINDER */
z->fraction[k - 1] = iqj + ir;
c = iq - y * iqj;
-
+
if (c < 0)
goto L210;
-
+
++k;
if (k > i2) {
mp_normalize(z);
@@ -649,8 +649,8 @@ mp_is_integer(const MPNumber *x)
MPNumber t1, t2, t3;
/* This fix is required for 1/3 repiprocal not being detected as an integer */
- /* Multiplication and division by 10000 is used to get around a
- * limitation to the "fix" for Sun bugtraq bug #4006391 in the
+ /* Multiplication and division by 10000 is used to get around a
+ * limitation to the "fix" for Sun bugtraq bug #4006391 in the
* mp_integer_component() routine in mp.c, when the exponent is less than 1.
*/
mp_set_from_integer(10000, &t3);
@@ -661,7 +661,7 @@ mp_is_integer(const MPNumber *x)
/* Correct way to check for integer */
/*int i;
-
+
// Zero is an integer
if (x->sign == 0)
return 1;
@@ -675,14 +675,14 @@ mp_is_integer(const MPNumber *x)
if (x->fraction[i] != 0)
return 0;
}
-
+
return 1;*/
}
int
mp_is_natural(const MPNumber *x)
-{
+{
return x->sign > 0 && mp_is_integer(x);
}
@@ -763,7 +763,7 @@ mpexp(const MPNumber *x, MPNumber *z)
mp_add_integer(z, 2, &t1);
mp_multiply(&t1, z, z);
}
-
+
mp_add_integer(z, 1, z);
}
@@ -824,7 +824,7 @@ mp_epowy(const MPNumber *x, MPNumber *z)
for (i = 2 ; ; i++) {
if (min(tss, tss + 2 + t1.exponent) <= 2)
break;
-
+
mp_divide_integer(&t1, i * xs, &t1);
mp_add(&t2, &t1, &t2);
if (t1.sign == 0)
@@ -901,7 +901,7 @@ mp_is_zero(const MPNumber *x)
}
-int
+int
mp_is_negative(const MPNumber *x)
{
MPNumber zero;
@@ -941,7 +941,7 @@ mplns(const MPNumber *x, MPNumber *z)
{
int t, it0;
MPNumber t1, t2, t3;
-
+
/* ln(1) = 0 */
if (x->sign == 0) {
mp_set_from_integer(0, z);
@@ -974,7 +974,7 @@ mplns(const MPNumber *x, MPNumber *z)
while(1)
{
int ts2, ts3;
-
+
mp_epowy(z, &t3);
mp_add_integer(&t3, -1, &t3);
mp_multiply(&t2, &t3, &t1);
@@ -996,7 +996,7 @@ mplns(const MPNumber *x, MPNumber *z)
} while (t > ts3);
t = ts2;
}
-
+
/* CHECK THAT NEWTON ITERATION WAS CONVERGING AS EXPECTED */
if (t3.sign != 0 && t3.exponent << 1 > it0 - MP_T) {
mperr("*** ERROR OCCURRED IN MPLNS, NEWTON ITERATION NOT CONVERGING PROPERLY ***");
@@ -1014,7 +1014,7 @@ mp_ln(const MPNumber *x, MPNumber *z)
int e, k;
float rx, rlx;
MPNumber t1, t2;
-
+
/* ln(-x) invalid */
if (x->sign <= 0) {
/* Translators: Error displayed attempted to take logarithm of negative value */
@@ -1057,7 +1057,7 @@ mp_ln(const MPNumber *x, MPNumber *z)
/* COMPUTE RESIDUAL WHOSE LOG IS STILL TO BE FOUND */
mp_multiply(&t1, &t2, &t1);
-
+
/* MAKE SURE NOT LOOPING INDEFINITELY */
++k;
if (k >= 10) {
@@ -1112,11 +1112,11 @@ mp_multiply(const MPNumber *x, const MPNumber *y, MPNumber *z)
mp_set_from_integer(0, z);
return;
}
-
+
z->sign = x->sign * y->sign;
z->exponent = x->exponent + y->exponent;
memset(&r, 0, sizeof(MPNumber));
-
+
/* PERFORM MULTIPLICATION */
c = 8;
for (i = 0; i < MP_T; i++) {
@@ -1167,7 +1167,7 @@ mp_multiply(const MPNumber *x, const MPNumber *y, MPNumber *z)
mp_set_from_integer(0, z);
return;
}
-
+
c = 0;
for (j = MP_T + 3; j >= 0; j--) {
int ri = r.fraction[j] + c;
@@ -1179,7 +1179,7 @@ mp_multiply(const MPNumber *x, const MPNumber *y, MPNumber *z)
c = ri / MP_BASE;
r.fraction[j] = ri - MP_BASE * c;
}
-
+
if (c != 0) {
mperr("*** ILLEGAL BASE B DIGIT IN CALL TO MP_MULTIPLY, POSSIBLE OVERWRITING PROBLEM ***");
mp_set_from_integer(0, z);
@@ -1211,7 +1211,7 @@ mp_multiply_new(const MPNumber *x, const MPNumber *y, MPNumber *z)
y_length = MP_SIZE;
while (y_length > 0 && y->fraction[y_length - 1] == 0)
y_length--;
-
+
/* Multiply together */
memset(fraction, 0, sizeof(fraction));
for (i = MP_SIZE - 1; i >= 0; i--) {
@@ -1219,7 +1219,7 @@ mp_multiply_new(const MPNumber *x, const MPNumber *y, MPNumber *z)
continue;
for (j = y_length - 1; j >= 0; j--) {
int pos = i + j + 1;
-
+
fraction[pos] += x->fraction[i] * y->fraction[j];
fraction[pos-1] += fraction[pos] / MP_BASE;
fraction[pos] = fraction[pos] % MP_BASE;
@@ -1237,7 +1237,7 @@ mp_multiply_new(const MPNumber *x, const MPNumber *y, MPNumber *z)
else
z->fraction[i] = fraction[i + offset];
}
-
+
/*for (i = MP_SIZE + offset; i < MP_SIZE * 2; i++) {
if (fraction[i] != 0) {
printf("truncated\n");
@@ -1252,7 +1252,7 @@ mp_multiply_integer(const MPNumber *x, int y, MPNumber *z)
{
int c, i, c1, c2, j1, j2;
int t1, t3, t4, ij, ri = 0, is, ix;
-
+
/* x*0 = 0*y = 0 */
if (x->sign == 0 || y == 0) {
mp_set_from_integer(0, z);
@@ -1266,7 +1266,7 @@ mp_multiply_integer(const MPNumber *x, int y, MPNumber *z)
z->sign *= y;
return;
}*/
-
+
/* If multiplying by base then can optimise */
if (y % MP_BASE == 0) {
mp_set_from_mp(x, z);
@@ -1275,7 +1275,7 @@ mp_multiply_integer(const MPNumber *x, int y, MPNumber *z)
z->exponent += -y / MP_BASE;
}
else
- z->exponent += y / MP_BASE;
+ z->exponent += y / MP_BASE;
return;
}
@@ -1350,13 +1350,13 @@ mp_multiply_integer(const MPNumber *x, int y, MPNumber *z)
mp_normalize(z);
return;
}
-
+
if (c < 0) {
mperr("*** INTEGER OVERFLOW IN mp_multiply_integer, B TOO LARGE ***");
mp_set_from_integer(0, z);
return;
}
-
+
for (ij = 1; ij <= t3; ++ij) {
i = t4 - ij;
z->fraction[i] = z->fraction[i - 1];
@@ -1410,7 +1410,7 @@ mp_normalize(MPNumber *x)
/* Normalized zero is zero */
if (x->sign == 0)
return;
-
+
/* CHECK THAT SIGN = +-1 */
if (abs(x->sign) > 1) {
mperr("*** SIGN NOT 0, +1 OR -1 IN CALL TO MP_NORMALIZE, POSSIBLE OVERWRITING PROBLEM ***");
@@ -1420,7 +1420,7 @@ mp_normalize(MPNumber *x)
i2 = MP_T + 4;
- /* Normalize by shifting the fraction to the left */
+ /* Normalize by shifting the fraction to the left */
if (x->fraction[0] == 0) {
/* Find how many places to shift and detect 0 fraction */
for (i = 1; i < i2 && x->fraction[i] == 0; i++);
@@ -1428,7 +1428,7 @@ mp_normalize(MPNumber *x)
mp_set_from_integer(0, x);
return;
}
-
+
x->exponent -= i;
i2m = i2 - i;
for (j = 0; j < i2m; j++)
@@ -1507,7 +1507,7 @@ mp_pwr(const MPNumber *x, const MPNumber *y, MPNumber *z)
mp_set_from_integer(0, z);
return;
}
-
+
/* x^0 = 1 */
if (y->sign == 0) {
mp_set_from_integer(1, z);
@@ -1563,11 +1563,11 @@ mp_reciprocal(const MPNumber *x, MPNumber *z)
t = 3;
it0 = (t + 4) / 2;
- /* MAIN ITERATION LOOP */
- if (t <= MP_T) {
+ /* MAIN ITERATION LOOP */
+ if (t <= MP_T) {
while(1) {
int ts2, ts3;
-
+
mp_multiply(x, &t1, &t2);
mp_add_integer(&t2, -1, &t2);
mp_multiply(&t1, &t2, &t2);
@@ -1586,7 +1586,7 @@ mp_reciprocal(const MPNumber *x, MPNumber *z)
} while (t > ts3);
t = min(ts2, MP_T);
}
-
+
/* RETURN IF NEWTON ITERATION WAS CONVERGING */
if (t2.sign != 0 && (t1.exponent - t2.exponent) << 1 < MP_T - it0) {
/* THE FOLLOWING MESSAGE MAY INDICATE THAT B**(T-1) IS TOO SMALL,
@@ -1639,7 +1639,7 @@ mp_root(const MPNumber *x, int n, MPNumber *z)
mperr(_("Negative root of zero is undefined"));
return;
}
-
+
if (x->sign < 0 && np % 2 == 0) {
mperr(_("nth root of negative number not defined for even n"));
mp_set_from_integer(0, z);
@@ -1673,8 +1673,8 @@ mp_root(const MPNumber *x, int n, MPNumber *z)
if (MP_BASE < 10)
t = it[MP_BASE - 1];
else
- t = 3;
-
+ t = 3;
+
if (t <= MP_T) {
/* IT0 IS A NECESSARY SAFETY FACTOR */
it0 = (t + 4) / 2;
@@ -1750,7 +1750,7 @@ void
mp_factorial(const MPNumber *x, MPNumber *z)
{
int i, value;
-
+
/* 0! == 1 */
if (x->sign == 0) {
mp_set_from_integer(1, z);
@@ -1812,14 +1812,14 @@ mp_xpowy_integer(const MPNumber *x, int n, MPNumber *z)
{
int i;
MPNumber t;
-
+
/* 0^-n invalid */
if (x->sign == 0 && n < 0) {
/* Translators: Error displayed when attempted to raise 0 to a negative exponent */
mperr(_("The power of zero is not defined for a negative exponent"));
return;
}
-
+
/* 0^n = 0 */
if (x->sign == 0) {
mp_set_from_integer(0, z);
diff --git a/src/mp.h b/src/mp.h
index 82fd003..14a270b 100644
--- a/src/mp.h
+++ b/src/mp.h
@@ -1,17 +1,17 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -46,7 +46,7 @@
#define MP_BASE 10000
/* Object for a high precision floating point number representation
- *
+ *
* x = sign * (MP_BASE^(exponent-1) + MP_BASE^(exponent-2) + ...)
*/
typedef struct
diff --git a/src/register.c b/src/register.c
index 9f9ae96..9912ed7 100644
--- a/src/register.c
+++ b/src/register.c
@@ -1,15 +1,15 @@
/* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -57,7 +57,7 @@ static const char *default_registers[][2] =
void register_init()
{
int i;
-
+
for (i = 0; i < MAX_REGISTERS; i++) {
char nkey[MAXLINE], *nline;
char vkey[MAXLINE], *vline = NULL;
@@ -85,11 +85,11 @@ void register_init()
register_set_value(i, &value);
}
}
-
+
for (i = 0; i < MAX_FUNCTIONS; i++) {
char nkey[MAXLINE], *nline;
char vkey[MAXLINE], *vline;
-
+
SNPRINTF(nkey, MAXLINE, "function%1dname", i);
nline = get_resource(nkey);
if (nline) {
@@ -98,7 +98,7 @@ void register_init()
if (vline == NULL)
g_free(nline);
}
-
+
if (nline && vline) {
function_set(i, nline, vline);
g_free(nline);
@@ -132,7 +132,7 @@ register_get_value(int index)
void register_set_name(int index, const char *name)
{
char key[MAXLINE];
-
+
STRNCPY(register_names[index], name, MAXLINE - 1);
SNPRINTF(key, MAXLINE, "register%1dname", index);
set_resource(key, name);
@@ -149,9 +149,9 @@ void function_set(int index, const char *name, const char *value)
{
char key[MAXLINE];
- STRNCPY(function_names[index], name, MAXLINE - 1);
+ STRNCPY(function_names[index], name, MAXLINE - 1);
STRNCPY(function_values[index], value, MAXLINE - 1);
-
+
SNPRINTF(key, MAXLINE, "function%1dname", index);
set_resource(key, name);
SNPRINTF(key, MAXLINE, "function%1dvalue", index);
diff --git a/src/ui.h b/src/ui.h
index b9dc284..68f8ead 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -1,16 +1,16 @@
/* Copyright (c) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
diff --git a/src/unittest.c b/src/unittest.c
index 45de8b8..f0646a4 100644
--- a/src/unittest.c
+++ b/src/unittest.c
@@ -1,15 +1,15 @@
/* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -66,7 +66,7 @@ test(char *expression, char *expected, int expected_error)
int error;
MPNumber result;
char result_str[1024] = "";
-
+
error = mp_equation_parse(expression, &options, &result);
if(error == 0) {
@@ -100,7 +100,7 @@ test_parser()
base = 8;
test("16434824", "76543210â??", 0);
-
+
base = 16;
test("18364758544493064720", "FEDCBA9876543210â??â??", 0);
@@ -213,11 +213,11 @@ test_parser()
test("2÷3", "0.666666667", 0);
test("1÷0", "", -9);
test("0÷0", "", -9);
-
+
/* Precision */
test("1000000000000000â??1000000000000000", "0", 0);
test("1000000000000000÷1000000000000000", "1", 0);
- test("1000000000000000Ã?0.000000000000001", "1", 0);
+ test("1000000000000000Ã?0.000000000000001", "1", 0);
/* Order of operations */
test("1â??0.9â??0.1", "0", 0);
@@ -225,7 +225,7 @@ test_parser()
test("1+(2Ã?3)", "7", 0);
test("(1+2)Ã?3", "9", 0);
test("(1+2Ã?3)", "7", 0);
-
+
/* Percentage */
test("100%", "1", 0);
test("1%", "0.01", 0);
@@ -278,13 +278,13 @@ test_parser()
test("2^0.5", "1.414213562", 0);
test("(â??4)^0.5", "", -9);
test("(â??8)^(1÷3)", "â??2", 0);
-
+
test("0 mod 7", "0", 0);
test("6 mod 7", "6", 0);
test("7 mod 7", "0", 0);
test("8 mod 7", "1", 0);
test("â??1 mod 7", "6", 0);
-
+
test("int 3.2", "3", 0);
test("frac 3.2", "0.2", 0);
test("int â??3.2", "â??3", 0);
@@ -322,7 +322,7 @@ test_parser()
test("sin 180", "0", 0);
test("2 sin 90", "2", 0);
test("sin²45", "0.5", 0);
-
+
test("cos 0", "1", 0);
test("cos 45 â?? 1÷â??2", "0", 0);
test("cos 20 â?? cos â??20", "0", 0);
@@ -334,7 +334,7 @@ test_parser()
test("tan 0", "0", 0);
test("tan 10 â?? sin 10÷cos 10", "0", 0);
test("tan 90", "", -9);
- test("tan 10", "0.176326981", 0);
+ test("tan 10", "0.176326981", 0);
test("tan²10", "0.031091204", 0);
test("cos�¹ 0", "90", 0);
@@ -363,10 +363,10 @@ test_parser()
options.angle_units = MP_DEGREES;
test("sin 90", "1", 0);
-
+
options.angle_units = MP_RADIANS;
test("sin (Ï?÷2)", "1", 0); // FIXME: Shouldn't need brackets
-
+
options.angle_units = MP_GRADIANS;
test("sin 100", "1", 0);
@@ -403,7 +403,7 @@ static void
test_string(const char *number)
{
MPNumber t;
-
+
mp_set_from_string(number, &t);
printf("MPNumber(%s) -> {", number);
@@ -415,7 +415,7 @@ static void
test_integer(int number)
{
MPNumber t;
-
+
mp_set_from_integer(number, &t);
printf("MPNumber(%d) -> {", number);
@@ -432,29 +432,29 @@ test_numbers()
test_integer(1);
test_integer(-1);
test_integer(2);
- test_integer(9999);
+ test_integer(9999);
test_integer(10000);
test_integer(10001);
test_integer(2147483647);
-
+
test_string("0");
test_string("1");
test_string("-1");
- test_string("16383");
+ test_string("16383");
test_string("16384");
test_string("16385");
test_string("268435456");
-
- test_string("0.1");
+
+ test_string("0.1");
test_string("0.5");
test_string("0.25");
test_string("0.125");
test_string("0.0625");
test_string("0.00006103515625");
test_string("0.000030517578125");
-
+
test_string("1.00006103515625");
- test_string("16384.00006103515625");
+ test_string("16384.00006103515625");
}
diff --git a/src/unittest.h b/src/unittest.h
index 6c1b25d..394f7cd 100644
--- a/src/unittest.h
+++ b/src/unittest.h
@@ -1,15 +1,15 @@
/* Copyright (c) 2008-2009 Robert Ancell
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
- * This program is distributed in the hope that it will be useful, but
+ *
+ * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]