summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/currency-manager.c20
-rw-r--r--src/currency.c8
-rw-r--r--src/financial.c10
-rw-r--r--src/mate-calc-cmd.c1
-rw-r--r--src/mate-calc.c4
-rw-r--r--src/math-buttons.c57
-rw-r--r--src/math-converter.c19
-rw-r--r--src/math-display.c9
-rw-r--r--src/math-equation.c88
-rw-r--r--src/math-history-entry.c2
-rw-r--r--src/math-history-entry.h2
-rw-r--r--src/math-history.c2
-rw-r--r--src/math-history.h2
-rw-r--r--src/math-preferences.c22
-rw-r--r--src/math-variable-popup.c12
-rw-r--r--src/math-variables.c10
-rw-r--r--src/math-window.c7
-rw-r--r--src/meson.build120
-rw-r--r--src/mp-binary.c11
-rw-r--r--src/mp-convert.c9
-rw-r--r--src/mp-equation.c7
-rw-r--r--src/mp-serializer.c29
-rw-r--r--src/mp-trigonometric.c13
-rw-r--r--src/mp.c1
-rw-r--r--src/mp.h14
-rw-r--r--src/parserfunc.h2
-rw-r--r--src/test-mp-equation.c108
-rw-r--r--src/test-mp.c6
-rw-r--r--src/unit-category.c12
-rw-r--r--src/unit-category.h2
-rw-r--r--src/unit-manager.c11
-rw-r--r--src/unit.c15
-rw-r--r--src/unittest.c766
-rw-r--r--src/unittest.h24
-rw-r--r--src/utility.h1
35 files changed, 244 insertions, 1182 deletions
diff --git a/src/currency-manager.c b/src/currency-manager.c
index 5ffffa4..5445881 100644
--- a/src/currency-manager.c
+++ b/src/currency-manager.c
@@ -14,6 +14,7 @@
#include <glib/gstdio.h>
#include <gio/gio.h>
#include <libxml/tree.h>
+#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <glib/gi18n.h>
@@ -101,7 +102,6 @@ struct CurrencyManagerPrivate
G_DEFINE_TYPE_WITH_PRIVATE (CurrencyManager, currency_manager, G_TYPE_OBJECT);
-
enum {
UPDATED,
LAST_SIGNAL
@@ -110,7 +110,6 @@ static guint signals[LAST_SIGNAL] = { 0, };
static CurrencyManager *default_currency_manager = NULL;
-
CurrencyManager *
currency_manager_get_default(void)
{
@@ -131,7 +130,6 @@ currency_manager_get_default(void)
return default_currency_manager;
}
-
GList *
currency_manager_get_currencies(CurrencyManager *manager)
{
@@ -139,7 +137,6 @@ currency_manager_get_currencies(CurrencyManager *manager)
return manager->priv->currencies;
}
-
Currency *
currency_manager_get_currency(CurrencyManager *manager, const gchar *name)
{
@@ -165,7 +162,6 @@ currency_manager_get_currency(CurrencyManager *manager, const gchar *name)
return NULL;
}
-
static char *
get_imf_rate_filepath(void)
{
@@ -175,7 +171,6 @@ get_imf_rate_filepath(void)
NULL);
}
-
static char *
get_ecb_rate_filepath(void)
{
@@ -185,7 +180,6 @@ get_ecb_rate_filepath(void)
NULL);
}
-
static Currency *
add_currency(CurrencyManager *manager, const gchar *short_name)
{
@@ -205,7 +199,6 @@ add_currency(CurrencyManager *manager, const gchar *short_name)
return c;
}
-
/* A file needs to be redownloaded if it doesn't exist, or is too old.
* When an error occur, it probably won't hurt to try to download again.
*/
@@ -226,7 +219,6 @@ file_needs_update(gchar *filename, double max_age)
return FALSE;
}
-
static void
download_imf_cb(GObject *object, GAsyncResult *result, gpointer user_data)
{
@@ -242,7 +234,6 @@ download_imf_cb(GObject *object, GAsyncResult *result, gpointer user_data)
load_rates(manager);
}
-
static void
download_ecb_cb(GObject *object, GAsyncResult *result, gpointer user_data)
{
@@ -258,7 +249,6 @@ download_ecb_cb(GObject *object, GAsyncResult *result, gpointer user_data)
load_rates(manager);
}
-
static void
download_file(CurrencyManager *manager, gchar *uri, gchar *filename, GAsyncReadyCallback callback)
{
@@ -277,7 +267,6 @@ download_file(CurrencyManager *manager, gchar *uri, gchar *filename, GAsyncReady
g_object_unref(dest);
}
-
static void
load_imf_rates(CurrencyManager *manager)
{
@@ -414,7 +403,6 @@ load_imf_rates(CurrencyManager *manager)
g_strfreev(lines);
}
-
static void
set_ecb_rate(CurrencyManager *manager, xmlNodePtr node, Currency *eur_rate)
{
@@ -455,7 +443,6 @@ set_ecb_rate(CurrencyManager *manager, xmlNodePtr node, Currency *eur_rate)
xmlFree(value);
}
-
static void
set_ecb_fixed_rate(CurrencyManager *manager, const gchar *name, const gchar *value, Currency *eur_rate)
{
@@ -473,7 +460,6 @@ set_ecb_fixed_rate(CurrencyManager *manager, const gchar *name, const gchar *val
mp_clear(&v);
}
-
static void
load_ecb_rates(CurrencyManager *manager)
{
@@ -538,7 +524,6 @@ load_ecb_rates(CurrencyManager *manager)
xmlCleanupParser();
}
-
static gboolean
load_rates(CurrencyManager *manager)
{
@@ -575,7 +560,6 @@ load_rates(CurrencyManager *manager)
return TRUE;
}
-
const MPNumber *
currency_manager_get_value(CurrencyManager *manager, const gchar *currency)
{
@@ -611,7 +595,6 @@ currency_manager_get_value(CurrencyManager *manager, const gchar *currency)
return NULL;
}
-
static void
currency_manager_class_init(CurrencyManagerClass *klass)
{
@@ -625,7 +608,6 @@ currency_manager_class_init(CurrencyManagerClass *klass)
G_TYPE_NONE, 0);
}
-
static void
currency_manager_init(CurrencyManager *manager)
{
diff --git a/src/currency.c b/src/currency.c
index a6295ee..6829267 100644
--- a/src/currency.c
+++ b/src/currency.c
@@ -25,7 +25,6 @@ struct CurrencyPrivate
G_DEFINE_TYPE_WITH_PRIVATE (Currency, currency, G_TYPE_OBJECT);
-
Currency *
currency_new(const gchar *name,
const gchar *display_name,
@@ -41,7 +40,6 @@ currency_new(const gchar *name,
return currency;
}
-
const gchar *
currency_get_name(Currency *currency)
{
@@ -49,7 +47,6 @@ currency_get_name(Currency *currency)
return currency->priv->name;
}
-
const gchar *
currency_get_display_name(Currency *currency)
{
@@ -57,7 +54,6 @@ currency_get_display_name(Currency *currency)
return currency->priv->display_name;
}
-
const gchar *
currency_get_symbol(Currency *currency)
{
@@ -65,7 +61,6 @@ currency_get_symbol(Currency *currency)
return currency->priv->symbol;
}
-
void
currency_set_value(Currency *currency, MPNumber *value)
{
@@ -74,7 +69,6 @@ currency_set_value(Currency *currency, MPNumber *value)
mp_set_from_mp (value, &currency->priv->value);
}
-
const MPNumber *
currency_get_value(Currency *currency)
{
@@ -82,13 +76,11 @@ currency_get_value(Currency *currency)
return &currency->priv->value;
}
-
static void
currency_class_init(CurrencyClass *klass)
{
}
-
static void
currency_init(Currency *currency)
{
diff --git a/src/financial.c b/src/financial.c
index 97ae50c..8bb208d 100644
--- a/src/financial.c
+++ b/src/financial.c
@@ -41,7 +41,6 @@ calc_ctrm(MPNumber *t, MPNumber *pint, MPNumber *fv, MPNumber *pv)
mp_clear(&MP4);
}
-
static void
calc_ddb(MathEquation *equation, MPNumber *t, MPNumber *cost, MPNumber *life, MPNumber *period)
{
@@ -85,7 +84,6 @@ calc_ddb(MathEquation *equation, MPNumber *t, MPNumber *cost, MPNumber *life, MP
mp_clear(&MP2);
}
-
static void
calc_fv(MPNumber *t, MPNumber *pmt, MPNumber *pint, MPNumber *n)
{
@@ -114,7 +112,6 @@ calc_fv(MPNumber *t, MPNumber *pmt, MPNumber *pint, MPNumber *n)
mp_clear(&MP4);
}
-
static void
calc_gpm(MPNumber *t, MPNumber *cost, MPNumber *margin)
{
@@ -136,7 +133,6 @@ calc_gpm(MPNumber *t, MPNumber *cost, MPNumber *margin)
mp_clear(&MP2);
}
-
static void
calc_pmt(MPNumber *t, MPNumber *prin, MPNumber *pint, MPNumber *n)
{
@@ -167,7 +163,6 @@ calc_pmt(MPNumber *t, MPNumber *prin, MPNumber *pint, MPNumber *n)
mp_clear(&MP4);
}
-
static void
calc_pv(MPNumber *t, MPNumber *pmt, MPNumber *pint, MPNumber *n)
{
@@ -198,7 +193,6 @@ calc_pv(MPNumber *t, MPNumber *pmt, MPNumber *pint, MPNumber *n)
mp_clear(&MP4);
}
-
static void
calc_rate(MPNumber *t, MPNumber *fv, MPNumber *pv, MPNumber *n)
{
@@ -227,7 +221,6 @@ calc_rate(MPNumber *t, MPNumber *fv, MPNumber *pv, MPNumber *n)
mp_clear(&MP4);
}
-
static void
calc_sln(MPNumber *t, MPNumber *cost, MPNumber *salvage, MPNumber *life)
{
@@ -245,7 +238,6 @@ calc_sln(MPNumber *t, MPNumber *cost, MPNumber *salvage, MPNumber *life)
mp_clear(&MP1);
}
-
static void
calc_syd(MPNumber *t, MPNumber *cost, MPNumber *salvage, MPNumber *life, MPNumber *period)
{
@@ -280,7 +272,6 @@ calc_syd(MPNumber *t, MPNumber *cost, MPNumber *salvage, MPNumber *life, MPNumbe
mp_clear(&MP4);
}
-
static void
calc_term(MPNumber *t, MPNumber *pmt, MPNumber *fv, MPNumber *pint)
{
@@ -311,7 +302,6 @@ calc_term(MPNumber *t, MPNumber *pmt, MPNumber *fv, MPNumber *pint)
mp_clear(&MP4);
}
-
void
do_finc_expression(MathEquation *equation, int function, MPNumber *arg1, MPNumber *arg2, MPNumber *arg3, MPNumber *arg4)
{
diff --git a/src/mate-calc-cmd.c b/src/mate-calc-cmd.c
index 9075310..842eab5 100644
--- a/src/mate-calc-cmd.c
+++ b/src/mate-calc-cmd.c
@@ -49,7 +49,6 @@ solve(const char *equation)
mp_clear(&z);
}
-
/* Adjust user input equation string before solving it. */
static void
str_adjust(char *str)
diff --git a/src/mate-calc.c b/src/mate-calc.c
index 99224ba..da95462 100644
--- a/src/mate-calc.c
+++ b/src/mate-calc.c
@@ -36,14 +36,12 @@ version(const gchar *progname)
fprintf(stderr, "%1$s %2$s\n", progname, VERSION);
}
-
static int
do_convert(const MPNumber *x, const char *x_units, const char *z_units, MPNumber *z, void *data)
{
return unit_manager_convert_by_symbol(unit_manager_get_default(), x, x_units, z_units, z);
}
-
static void
solve(const char *equation)
{
@@ -77,7 +75,6 @@ solve(const char *equation)
}
}
-
static void
usage(const gchar *progname, gboolean show_application, gboolean show_gtk)
{
@@ -123,7 +120,6 @@ usage(const gchar *progname, gboolean show_application, gboolean show_gtk)
}
}
-
static void
get_options(int argc, char *argv[])
{
diff --git a/src/math-buttons.c b/src/math-buttons.c
index b2cb131..19195aa 100644
--- a/src/math-buttons.c
+++ b/src/math-buttons.c
@@ -94,8 +94,12 @@ static ButtonData button_data[] = {
{"eulers_number", "e", NUMBER,
/* Tooltip for the Euler's Number button */
N_("Euler’s Number")},
- {"imaginary", "i", NUMBER, NULL},
- {"numeric_point", NULL, NUMBER, NULL},
+ {"imaginary", "i", NUMBER,
+ /* Tooltip for the imaginary number button */
+ N_("Imaginary unit")},
+ {"numeric_point", NULL, NUMBER,
+ /* Tooltip for the numeric point button */
+ N_("Decimal point")},
{"subscript", NULL, NUMBER_BOLD,
/* Tooltip for the subscript button */
N_("Subscript mode [Alt]")},
@@ -297,7 +301,6 @@ static char *finc_dialog_fields[][5] = {
{NULL, NULL, NULL, NULL, NULL}
};
-
MathButtons *
math_buttons_new(MathEquation *equation)
{
@@ -313,7 +316,6 @@ set_data(GtkBuilder *ui, const gchar *object_name, const gchar *name, const char
g_object_set_data(object, name, GINT_TO_POINTER(value));
}
-
static void
set_int_data(GtkBuilder *ui, const gchar *object_name, const gchar *name, gint value)
{
@@ -323,7 +325,6 @@ set_int_data(GtkBuilder *ui, const gchar *object_name, const gchar *name, gint v
g_object_set_data(object, name, GINT_TO_POINTER(value));
}
-
static void
load_finc_dialogs(MathButtons *buttons)
{
@@ -350,7 +351,6 @@ load_finc_dialogs(MathButtons *buttons)
}
}
-
static void
update_bit_panel(MathButtons *buttons)
{
@@ -426,14 +426,12 @@ update_bit_panel(MathButtons *buttons)
mp_clear(&x);
}
-
static void
display_changed_cb(MathEquation *equation, GParamSpec *spec, MathButtons *buttons)
{
update_bit_panel(buttons);
}
-
static void
base_combobox_changed_cb(GtkWidget *combo, MathButtons *buttons)
{
@@ -448,7 +446,6 @@ base_combobox_changed_cb(GtkWidget *combo, MathButtons *buttons)
math_buttons_set_programming_base(buttons, value);
}
-
static void
base_changed_cb(MathEquation *equation, GParamSpec *spec, MathButtons *buttons)
{
@@ -477,7 +474,6 @@ base_changed_cb(MathEquation *equation, GParamSpec *spec, MathButtons *buttons)
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(buttons->priv->base_combo), &iter);
}
-
static GtkWidget *
load_mode(MathButtons *buttons, ButtonMode mode)
{
@@ -546,8 +542,6 @@ load_mode(MathButtons *buttons, ButtonMode mode)
if (button_data[i].tooltip)
gtk_widget_set_tooltip_text(button, _(button_data[i].tooltip));
-
- atk_object_set_name(gtk_widget_get_accessible(button), button_data[i].widget_name);
}
/* Set special button data */
@@ -673,7 +667,6 @@ out:
return *panel;
}
-
static void
converter_changed_cb(MathConverter *converter, MathButtons *buttons)
{
@@ -693,7 +686,6 @@ converter_changed_cb(MathConverter *converter, MathButtons *buttons)
g_object_unref(to_unit);
}
-
static void
load_buttons(MathButtons *buttons)
{
@@ -722,7 +714,6 @@ load_buttons(MathButtons *buttons)
gtk_widget_show(panel);
}
-
void
math_buttons_set_mode(MathButtons *buttons, ButtonMode mode)
{
@@ -757,14 +748,12 @@ math_buttons_set_mode(MathButtons *buttons, ButtonMode mode)
g_object_notify(G_OBJECT(buttons), "mode");
}
-
ButtonMode
math_buttons_get_mode(MathButtons *buttons)
{
return buttons->priv->mode;
}
-
void
math_buttons_set_programming_base(MathButtons *buttons, gint base)
{
@@ -781,7 +770,6 @@ math_buttons_set_programming_base(MathButtons *buttons, gint base)
math_equation_set_base(buttons->priv->equation, base);
}
-
gint
math_buttons_get_programming_base(MathButtons *buttons)
{
@@ -789,7 +777,6 @@ math_buttons_get_programming_base(MathButtons *buttons)
return buttons->priv->programming_base;
}
-
void exponent_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -798,7 +785,6 @@ exponent_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_insert_exponent(buttons->priv->equation);
}
-
void subtract_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -807,7 +793,6 @@ subtract_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_insert_subtract(buttons->priv->equation);
}
-
void button_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -816,7 +801,6 @@ button_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_insert(buttons->priv->equation, g_object_get_data(G_OBJECT(widget), "calc_text"));
}
-
void solve_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -825,7 +809,6 @@ solve_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_solve(buttons->priv->equation);
}
-
void clear_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -834,7 +817,6 @@ clear_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_clear(buttons->priv->equation);
}
-
void delete_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -843,7 +825,6 @@ delete_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_delete(buttons->priv->equation);
}
-
void undo_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -852,7 +833,6 @@ undo_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_undo(buttons->priv->equation);
}
-
static void
shift_cb(GtkWidget *widget, MathButtons *buttons)
{
@@ -869,7 +849,6 @@ popup_button_menu(GtkWidget *widget, GtkMenu *menu)
NULL);
}
-
void memory_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -888,7 +867,6 @@ memory_cb(GtkWidget *widget, MathButtons *buttons)
gtk_widget_show(GTK_WIDGET(popup));
}
-
void shift_left_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -930,7 +908,6 @@ shift_left_cb(GtkWidget *widget, MathButtons *buttons)
popup_button_menu(widget, GTK_MENU(buttons->priv->shift_left_menu));
}
-
void shift_right_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -972,14 +949,12 @@ shift_right_cb(GtkWidget *widget, MathButtons *buttons)
popup_button_menu(widget, GTK_MENU(buttons->priv->shift_right_menu));
}
-
static void
insert_function_cb(GtkWidget *widget, MathButtons *buttons)
{
math_equation_insert(buttons->priv->equation, g_object_get_data(G_OBJECT(widget), "function"));
}
-
void function_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1031,7 +1006,6 @@ insert_const_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_insert(buttons->priv->equation, g_object_get_data(G_OBJECT(widget), "const"));
}
-
void const_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1092,7 +1066,6 @@ factorize_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_factorize(buttons->priv->equation);
}
-
void digit_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1101,7 +1074,6 @@ digit_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_insert_digit(buttons->priv->equation, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "calc_digit")));
}
-
void numeric_point_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1110,8 +1082,6 @@ numeric_point_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_insert_numeric_point(buttons->priv->equation);
}
-
-
void finc_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1124,7 +1094,6 @@ finc_cb(GtkWidget *widget, MathButtons *buttons)
gtk_widget_hide(GTK_WIDGET(GET_WIDGET(buttons->priv->financial_ui, name)));
}
-
void insert_character_code_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1133,7 +1102,6 @@ insert_character_code_cb(GtkWidget *widget, MathButtons *buttons)
gtk_window_present(GTK_WINDOW(buttons->priv->character_code_dialog));
}
-
void finc_activate_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1160,7 +1128,6 @@ finc_activate_cb(GtkWidget *widget, MathButtons *buttons)
}
}
-
void finc_response_cb(GtkWidget *widget, gint response_id, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1194,7 +1161,6 @@ finc_response_cb(GtkWidget *widget, gint response_id, MathButtons *buttons)
}
}
-
void character_code_dialog_response_cb(GtkWidget *dialog, gint response_id, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1224,7 +1190,6 @@ character_code_dialog_response_cb(GtkWidget *dialog, gint response_id, MathButto
gtk_widget_hide(dialog);
}
-
void character_code_dialog_activate_cb(GtkWidget *entry, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1233,7 +1198,6 @@ character_code_dialog_activate_cb(GtkWidget *entry, MathButtons *buttons)
character_code_dialog_response_cb(buttons->priv->character_code_dialog, GTK_RESPONSE_OK, buttons);
}
-
gboolean character_code_dialog_delete_cb(GtkWidget *dialog, GdkEvent *event, MathButtons *buttons);
G_MODULE_EXPORT
gboolean
@@ -1243,7 +1207,6 @@ character_code_dialog_delete_cb(GtkWidget *dialog, GdkEvent *event, MathButtons
return TRUE;
}
-
gboolean bit_toggle_cb(GtkWidget *event_box, GdkEventButton *event, MathButtons *buttons);
G_MODULE_EXPORT
gboolean
@@ -1253,7 +1216,6 @@ bit_toggle_cb(GtkWidget *event_box, GdkEventButton *event, MathButtons *buttons)
return TRUE;
}
-
static void
remove_trailing_spaces(MathButtons *buttons)
{
@@ -1269,7 +1231,6 @@ remove_trailing_spaces(MathButtons *buttons)
}
}
-
void set_superscript_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1285,7 +1246,6 @@ set_superscript_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_set_number_mode(buttons->priv->equation, NORMAL);
}
-
void set_subscript_cb(GtkWidget *widget, MathButtons *buttons);
G_MODULE_EXPORT
void
@@ -1301,7 +1261,6 @@ set_subscript_cb(GtkWidget *widget, MathButtons *buttons)
math_equation_set_number_mode(buttons->priv->equation, NORMAL);
}
-
static void
number_mode_changed_cb(MathEquation *equation, GParamSpec *spec, MathButtons *buttons)
{
@@ -1320,7 +1279,6 @@ number_mode_changed_cb(MathEquation *equation, GParamSpec *spec, MathButtons *bu
}
}
-
static void
math_buttons_set_property(GObject *object,
guint prop_id,
@@ -1354,7 +1312,6 @@ math_buttons_set_property(GObject *object,
}
}
-
static void
math_buttons_get_property(GObject *object,
guint prop_id,
@@ -1381,7 +1338,6 @@ math_buttons_get_property(GObject *object,
}
}
-
static void
math_buttons_class_init(MathButtonsClass *klass)
{
@@ -1424,7 +1380,6 @@ math_buttons_class_init(MathButtonsClass *klass)
G_PARAM_READWRITE));
}
-
static void
math_buttons_init(MathButtons *buttons)
{
diff --git a/src/math-converter.c b/src/math-converter.c
index 10d5336..a94f986 100644
--- a/src/math-converter.c
+++ b/src/math-converter.c
@@ -32,13 +32,11 @@ struct MathConverterPrivate
GtkWidget *result_label;
};
-
G_DEFINE_TYPE_WITH_PRIVATE (MathConverter, math_converter, GTK_TYPE_BOX);
static void display_changed_cb(MathEquation *equation, GParamSpec *spec, MathConverter *converter);
static void update_from_model(MathConverter *converter);
-
MathConverter *
math_converter_new(MathEquation *equation)
{
@@ -49,7 +47,6 @@ math_converter_new(MathEquation *equation)
return converter;
}
-
static gboolean
convert_equation(MathConverter *converter, const MPNumber *x, MPNumber *z)
{
@@ -77,7 +74,6 @@ convert_equation(MathConverter *converter, const MPNumber *x, MPNumber *z)
return result;
}
-
static void
update_result_label(MathConverter *converter)
{
@@ -116,14 +112,12 @@ update_result_label(MathConverter *converter)
mp_clear(&z);
}
-
static void
display_changed_cb(MathEquation *equation, GParamSpec *spec, MathConverter *converter)
{
update_result_label(converter);
}
-
static void
update_from_model(MathConverter *converter)
{
@@ -169,7 +163,6 @@ update_from_model(MathConverter *converter)
gtk_combo_box_set_model(GTK_COMBO_BOX(converter->priv->from_combo), GTK_TREE_MODEL(from_model));
}
-
void
math_converter_set_category(MathConverter *converter, const gchar *category)
{
@@ -186,7 +179,6 @@ math_converter_set_category(MathConverter *converter, const gchar *category)
update_from_model(converter);
}
-
const gchar *
math_converter_get_category(MathConverter *converter)
{
@@ -194,9 +186,8 @@ math_converter_get_category(MathConverter *converter)
return converter->priv->category;
}
-
static gboolean
-iter_is_unit(GtkTreeModel *model, GtkTreeIter *iter, Unit *unit)
+iter_is_unit(GtkTreeModel *model, GtkTreeIter *iter, const Unit *unit)
{
Unit *u;
@@ -212,7 +203,6 @@ iter_is_unit(GtkTreeModel *model, GtkTreeIter *iter, Unit *unit)
return FALSE;
}
-
static gboolean
set_active_unit(GtkComboBox *combo, GtkTreeIter *iter, Unit *unit)
{
@@ -237,7 +227,6 @@ set_active_unit(GtkComboBox *combo, GtkTreeIter *iter, Unit *unit)
return FALSE;
}
-
void
math_converter_set_conversion(MathConverter *converter, /*const gchar *category,*/ const gchar *unit_a, const gchar *unit_b)
{
@@ -270,7 +259,6 @@ math_converter_set_conversion(MathConverter *converter, /*const gchar *category,
set_active_unit(GTK_COMBO_BOX(converter->priv->to_combo), NULL, ub);
}
-
void
math_converter_get_conversion(MathConverter *converter, Unit **from_unit, Unit **to_unit)
{
@@ -287,7 +275,6 @@ math_converter_get_conversion(MathConverter *converter, Unit **from_unit, Unit *
gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(converter->priv->to_combo)), &to_iter, 2, to_unit, -1);
}
-
static void
math_converter_class_init(MathConverterClass *klass)
{
@@ -301,7 +288,6 @@ math_converter_class_init(MathConverterClass *klass)
G_TYPE_NONE, 0);
}
-
static void
from_combobox_changed_cb(GtkWidget *combo, MathConverter *converter)
{
@@ -334,7 +320,6 @@ from_combobox_changed_cb(GtkWidget *combo, MathConverter *converter)
g_object_unref(unit);
}
-
static void
to_combobox_changed_cb(GtkWidget *combo, MathConverter *converter)
{
@@ -344,7 +329,6 @@ to_combobox_changed_cb(GtkWidget *combo, MathConverter *converter)
g_signal_emit(converter, signals[CHANGED], 0);
}
-
static void
from_cell_data_func(GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
@@ -355,7 +339,6 @@ from_cell_data_func(GtkCellLayout *cell_layout,
g_object_set(cell, "sensitive", !gtk_tree_model_iter_has_child(tree_model, iter), NULL);
}
-
static void
currency_updated_cb(CurrencyManager *manager, MathConverter *converter)
{
diff --git a/src/math-display.c b/src/math-display.c
index 7a24838..b0f3e0e 100644
--- a/src/math-display.c
+++ b/src/math-display.c
@@ -42,21 +42,18 @@ math_display_new()
return g_object_new(math_display_get_type(), "equation", math_equation_new(), NULL);
}
-
MathDisplay *
math_display_new_with_equation(MathEquation *equation)
{
return g_object_new(math_display_get_type(), "equation", equation, NULL);
}
-
MathEquation *
math_display_get_equation(MathDisplay *display)
{
return display->priv->equation;
}
-
static gboolean
display_key_press_cb(GtkWidget *widget, GdkEventKey *event, MathDisplay *display)
{
@@ -294,7 +291,6 @@ display_key_press_cb(GtkWidget *widget, GdkEventKey *event, MathDisplay *display
return FALSE;
}
-
static gboolean
key_press_cb(MathDisplay *display, GdkEventKey *event)
{
@@ -303,7 +299,6 @@ key_press_cb(MathDisplay *display, GdkEventKey *event)
return result;
}
-
static void
status_changed_cb(MathEquation *equation, GParamSpec *spec, MathDisplay *display)
{
@@ -414,7 +409,6 @@ create_gui(MathDisplay *display)
status_changed_cb(display->priv->equation, NULL, display);
}
-
static void
math_display_set_property(GObject *object,
guint prop_id,
@@ -436,7 +430,6 @@ math_display_set_property(GObject *object,
}
}
-
static void
math_display_get_property(GObject *object,
guint prop_id,
@@ -457,7 +450,6 @@ math_display_get_property(GObject *object,
}
}
-
static void
math_display_class_init(MathDisplayClass *klass)
{
@@ -475,7 +467,6 @@ math_display_class_init(MathDisplayClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
-
static void
math_display_init(MathDisplay *display)
{
diff --git a/src/math-equation.c b/src/math-equation.c
index d332718..2ce3ab8 100644
--- a/src/math-equation.c
+++ b/src/math-equation.c
@@ -103,21 +103,18 @@ typedef struct {
G_DEFINE_TYPE_WITH_PRIVATE (MathEquation, math_equation, GTK_TYPE_TEXT_BUFFER);
-
MathEquation *
math_equation_new()
{
return g_object_new(math_equation_get_type(), NULL);
}
-
MathVariables *
math_equation_get_variables(MathEquation *equation)
{
return equation->priv->variables;
}
-
static void
get_ans_offsets(MathEquation *equation, gint *start, gint *end)
{
@@ -134,7 +131,6 @@ get_ans_offsets(MathEquation *equation, gint *start, gint *end)
*end = gtk_text_iter_get_offset(&iter);
}
-
static void
reformat_ans(MathEquation *equation)
{
@@ -173,7 +169,6 @@ reformat_ans(MathEquation *equation)
g_free(ans_text);
}
-
static gint
count_digits(MathEquation *equation, const gchar *text)
{
@@ -200,7 +195,6 @@ count_digits(MathEquation *equation, const gchar *text)
return count;
}
-
static void
reformat_separators(MathEquation *equation)
{
@@ -279,7 +273,6 @@ reformat_separators(MathEquation *equation)
equation->priv->in_undo_operation = FALSE;
}
-
static void
reformat_display(MathEquation *equation)
{
@@ -292,7 +285,6 @@ reformat_display(MathEquation *equation)
g_signal_emit_by_name(equation, "display-changed");
}
-
static MathEquationState *
get_current_state(MathEquation *equation)
{
@@ -324,7 +316,6 @@ get_current_state(MathEquation *equation)
return state;
}
-
static void
free_state(MathEquationState *state)
{
@@ -333,7 +324,6 @@ free_state(MathEquationState *state)
g_free(state);
}
-
static void
math_equation_push_undo_stack(MathEquation *equation)
{
@@ -357,7 +347,6 @@ math_equation_push_undo_stack(MathEquation *equation)
equation->priv->undo_stack = g_list_prepend(equation->priv->undo_stack, state);
}
-
static void
clear_ans(MathEquation *equation, gboolean remove_tag)
{
@@ -378,7 +367,6 @@ clear_ans(MathEquation *equation, gboolean remove_tag)
equation->priv->ans_end = NULL;
}
-
static void
apply_state(MathEquation *equation, MathEquationState *state)
{
@@ -411,7 +399,6 @@ apply_state(MathEquation *equation, MathEquationState *state)
equation->priv->in_undo_operation = FALSE;
}
-
void
math_equation_copy(MathEquation *equation)
{
@@ -428,7 +415,6 @@ math_equation_copy(MathEquation *equation)
g_free(text);
}
-
static void
on_paste(GtkClipboard *clipboard, const gchar *text, gpointer data)
{
@@ -437,7 +423,6 @@ on_paste(GtkClipboard *clipboard, const gchar *text, gpointer data)
math_equation_insert(equation, text);
}
-
void
math_equation_paste(MathEquation *equation)
{
@@ -445,7 +430,6 @@ math_equation_paste(MathEquation *equation)
gtk_clipboard_request_text(gtk_clipboard_get(GDK_NONE), on_paste, equation);
}
-
void
math_equation_undo(MathEquation *equation)
{
@@ -472,7 +456,6 @@ math_equation_undo(MathEquation *equation)
free_state(state);
}
-
void
math_equation_redo(MathEquation *equation)
{
@@ -499,7 +482,6 @@ math_equation_redo(MathEquation *equation)
free_state(state);
}
-
gunichar
math_equation_get_digit_text(MathEquation *equation, guint digit)
{
@@ -509,7 +491,6 @@ math_equation_get_digit_text(MathEquation *equation, guint digit)
return equation->priv->digits[digit];
}
-
void
math_equation_set_accuracy(MathEquation *equation, gint accuracy)
{
@@ -522,7 +503,6 @@ math_equation_set_accuracy(MathEquation *equation, gint accuracy)
g_object_notify(G_OBJECT(equation), "accuracy");
}
-
gint
math_equation_get_accuracy(MathEquation *equation)
{
@@ -531,7 +511,6 @@ math_equation_get_accuracy(MathEquation *equation)
return mp_serializer_get_trailing_digits(equation->priv->serializer);
}
-
void
math_equation_set_show_thousands_separators(MathEquation *equation, gboolean visible)
{
@@ -545,7 +524,6 @@ math_equation_set_show_thousands_separators(MathEquation *equation, gboolean vis
g_object_notify(G_OBJECT(equation), "show-thousands-separators");
}
-
gboolean
math_equation_get_show_thousands_separators(MathEquation *equation)
{
@@ -553,7 +531,6 @@ math_equation_get_show_thousands_separators(MathEquation *equation)
return mp_serializer_get_show_thousands_separators(equation->priv->serializer);
}
-
void
math_equation_set_show_trailing_zeroes(MathEquation *equation, gboolean visible)
{
@@ -567,7 +544,6 @@ math_equation_set_show_trailing_zeroes(MathEquation *equation, gboolean visible)
g_object_notify(G_OBJECT(equation), "show-trailing-zeroes");
}
-
gboolean
math_equation_get_show_trailing_zeroes(MathEquation *equation)
{
@@ -575,7 +551,6 @@ math_equation_get_show_trailing_zeroes(MathEquation *equation)
return mp_serializer_get_show_trailing_zeroes(equation->priv->serializer);
}
-
void
math_equation_set_number_format(MathEquation *equation, MpDisplayFormat format)
{
@@ -589,7 +564,6 @@ math_equation_set_number_format(MathEquation *equation, MpDisplayFormat format)
g_object_notify(G_OBJECT(equation), "number-format");
}
-
MpDisplayFormat
math_equation_get_number_format(MathEquation *equation)
{
@@ -597,7 +571,6 @@ math_equation_get_number_format(MathEquation *equation)
return mp_serializer_get_number_format(equation->priv->serializer);
}
-
void
math_equation_set_base(MathEquation *equation, gint base)
{
@@ -611,7 +584,6 @@ math_equation_set_base(MathEquation *equation, gint base)
g_object_notify(G_OBJECT(equation), "base");
}
-
gint
math_equation_get_base(MathEquation *equation)
{
@@ -619,7 +591,6 @@ math_equation_get_base(MathEquation *equation)
return mp_serializer_get_base(equation->priv->serializer);
}
-
void
math_equation_set_word_size(MathEquation *equation, gint word_size)
{
@@ -632,7 +603,6 @@ math_equation_set_word_size(MathEquation *equation, gint word_size)
g_object_notify(G_OBJECT(equation), "word-size");
}
-
gint
math_equation_get_word_size(MathEquation *equation)
{
@@ -640,7 +610,6 @@ math_equation_get_word_size(MathEquation *equation)
return equation->priv->word_size;
}
-
void
math_equation_set_angle_units(MathEquation *equation, MPAngleUnit angle_units)
{
@@ -653,7 +622,6 @@ math_equation_set_angle_units(MathEquation *equation, MPAngleUnit angle_units)
g_object_notify(G_OBJECT(equation), "angle-units");
}
-
MPAngleUnit
math_equation_get_angle_units(MathEquation *equation)
{
@@ -661,7 +629,6 @@ math_equation_get_angle_units(MathEquation *equation)
return equation->priv->angle_units;
}
-
void
math_equation_set_source_currency(MathEquation *equation, const gchar *currency)
{
@@ -676,7 +643,6 @@ math_equation_set_source_currency(MathEquation *equation, const gchar *currency)
math_equation_get_source_currency(equation));
}
-
const gchar *
math_equation_get_source_currency(MathEquation *equation)
{
@@ -684,7 +650,6 @@ math_equation_get_source_currency(MathEquation *equation)
return equation->priv->source_currency;
}
-
void
math_equation_set_target_currency(MathEquation *equation, const gchar *currency)
{
@@ -699,7 +664,6 @@ math_equation_set_target_currency(MathEquation *equation, const gchar *currency)
math_equation_get_target_currency(equation));
}
-
const gchar *
math_equation_get_target_currency(MathEquation *equation)
{
@@ -707,7 +671,6 @@ math_equation_get_target_currency(MathEquation *equation)
return equation->priv->target_currency;
}
-
void
math_equation_set_source_units(MathEquation *equation, const gchar *units)
{
@@ -730,7 +693,6 @@ math_equation_get_source_units(MathEquation *equation)
return equation->priv->source_units;
}
-
void
math_equation_set_target_units(MathEquation *equation, const gchar *units)
{
@@ -746,7 +708,6 @@ math_equation_set_target_units(MathEquation *equation, const gchar *units)
math_equation_get_target_units(equation));
}
-
const gchar *
math_equation_get_target_units(MathEquation *equation)
{
@@ -754,7 +715,6 @@ math_equation_get_target_units(MathEquation *equation)
return equation->priv->target_units;
}
-
void
math_equation_set_status(MathEquation *equation, const gchar *status)
{
@@ -769,7 +729,6 @@ math_equation_set_status(MathEquation *equation, const gchar *status)
g_object_notify(G_OBJECT(equation), "status");
}
-
const gchar *
math_equation_get_status(MathEquation *equation)
{
@@ -777,7 +736,6 @@ math_equation_get_status(MathEquation *equation)
return equation->priv->state.status;
}
-
gboolean
math_equation_is_empty(MathEquation *equation)
{
@@ -785,7 +743,6 @@ math_equation_is_empty(MathEquation *equation)
return gtk_text_buffer_get_char_count(GTK_TEXT_BUFFER(equation)) == 0;
}
-
gboolean
math_equation_is_result(MathEquation *equation)
{
@@ -801,7 +758,6 @@ math_equation_is_result(MathEquation *equation)
return result;
}
-
gchar *
math_equation_get_display(MathEquation *equation)
{
@@ -813,7 +769,6 @@ math_equation_get_display(MathEquation *equation)
return gtk_text_buffer_get_text(GTK_TEXT_BUFFER(equation), &start, &end, FALSE);
}
-
gchar *
math_equation_get_equation(MathEquation *equation)
{
@@ -867,7 +822,6 @@ math_equation_get_equation(MathEquation *equation)
return text;
}
-
gboolean
math_equation_get_number(MathEquation *equation, MPNumber *z)
{
@@ -889,7 +843,6 @@ math_equation_get_number(MathEquation *equation, MPNumber *z)
}
}
-
MpSerializer *
math_equation_get_serializer(MathEquation *equation)
{
@@ -897,7 +850,6 @@ math_equation_get_serializer(MathEquation *equation)
return equation->priv->serializer;
}
-
void
math_equation_set_number_mode(MathEquation *equation, NumberMode mode)
{
@@ -912,7 +864,6 @@ math_equation_set_number_mode(MathEquation *equation, NumberMode mode)
g_object_notify(G_OBJECT(equation), "number-mode");
}
-
NumberMode
math_equation_get_number_mode(MathEquation *equation)
{
@@ -920,7 +871,6 @@ math_equation_get_number_mode(MathEquation *equation)
return equation->priv->number_mode;
}
-
gboolean
math_equation_in_solve(MathEquation *equation)
{
@@ -928,7 +878,6 @@ math_equation_in_solve(MathEquation *equation)
return equation->priv->in_solve;
}
-
const MPNumber *
math_equation_get_answer(MathEquation *equation)
{
@@ -936,7 +885,6 @@ math_equation_get_answer(MathEquation *equation)
return &equation->priv->state.ans;
}
-
void
math_equation_store(MathEquation *equation, const gchar *name)
{
@@ -952,7 +900,6 @@ math_equation_store(MathEquation *equation, const gchar *name)
mp_clear(&t);
}
-
void
math_equation_recall(MathEquation *equation, const gchar *name)
{
@@ -961,7 +908,6 @@ math_equation_recall(MathEquation *equation, const gchar *name)
math_equation_insert(equation, name);
}
-
void
math_equation_set(MathEquation *equation, const gchar *text)
{
@@ -988,7 +934,6 @@ math_equation_set_with_history(MathEquation *equation, const gchar *text)
mp_clear(&x);
}
-
void
math_equation_set_number(MathEquation *equation, const MPNumber *x)
{
@@ -1021,7 +966,6 @@ math_equation_set_number(MathEquation *equation, const MPNumber *x)
free_state(state);
}
-
void
math_equation_insert(MathEquation *equation, const gchar *text)
{
@@ -1051,7 +995,6 @@ math_equation_insert(MathEquation *equation, const gchar *text)
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(equation), text, -1);
}
-
void
math_equation_insert_digit(MathEquation *equation, guint digit)
{
@@ -1074,7 +1017,6 @@ math_equation_insert_digit(MathEquation *equation, guint digit)
math_equation_insert(equation, subscript_digits[digit]);
}
-
void
math_equation_insert_numeric_point(MathEquation *equation)
{
@@ -1088,7 +1030,6 @@ math_equation_insert_numeric_point(MathEquation *equation)
math_equation_insert(equation, buffer);
}
-
void
math_equation_insert_number(MathEquation *equation, const MPNumber *x)
{
@@ -1102,7 +1043,6 @@ math_equation_insert_number(MathEquation *equation, const MPNumber *x)
g_free(text);
}
-
void
math_equation_insert_exponent(MathEquation *equation)
{
@@ -1111,7 +1051,6 @@ math_equation_insert_exponent(MathEquation *equation)
math_equation_set_number_mode(equation, SUPERSCRIPT);
}
-
void
math_equation_insert_subtract(MathEquation *equation)
{
@@ -1126,7 +1065,6 @@ math_equation_insert_subtract(MathEquation *equation)
}
}
-
static int
variable_is_defined(const char *name, void *data)
{
@@ -1147,7 +1085,6 @@ variable_is_defined(const char *name, void *data)
return math_variables_get(equation->priv->variables, name) != NULL;
}
-
static int
get_variable(const char *name, MPNumber *z, void *data)
{
@@ -1176,7 +1113,6 @@ get_variable(const char *name, MPNumber *z, void *data)
return result;
}
-
static void
set_variable(const char *name, const MPNumber *x, void *data)
{
@@ -1185,14 +1121,12 @@ set_variable(const char *name, const MPNumber *x, void *data)
math_variables_set(equation->priv->variables, name, x);
}
-
static int
convert(const MPNumber *x, const char *x_units, const char *z_units, MPNumber *z, void *data)
{
return unit_manager_convert_by_symbol(unit_manager_get_default(), x, x_units, z_units, z);
}
-
static int
parse(MathEquation *equation, const char *text, MPNumber *z, char **error_token)
{
@@ -1211,7 +1145,6 @@ parse(MathEquation *equation, const char *text, MPNumber *z, char **error_token)
return mp_equation_parse(text, &options, z, error_token);
}
-
/*
* Executed in separate thread. It is thus not a good idea to write to anything
* in MathEquation but the async queue from here.
@@ -1242,7 +1175,6 @@ math_equation_solve_real(gpointer data)
n_brackets--;
}
-
result = parse(equation, equation_text->str, &z, &error_token);
g_string_free(equation_text, TRUE);
@@ -1295,7 +1227,6 @@ math_equation_solve_real(gpointer data)
return NULL;
}
-
static gboolean
math_equation_show_in_progress(gpointer data)
{
@@ -1305,7 +1236,6 @@ math_equation_show_in_progress(gpointer data)
return false;
}
-
static gboolean
math_equation_look_for_answer(gpointer data)
{
@@ -1338,7 +1268,6 @@ math_equation_look_for_answer(gpointer data)
return false;
}
-
void
math_equation_solve(MathEquation *equation)
{
@@ -1367,7 +1296,6 @@ math_equation_solve(MathEquation *equation)
g_timeout_add(100, math_equation_show_in_progress, equation);
}
-
static gpointer
math_equation_factorize_real(gpointer data)
{
@@ -1426,7 +1354,6 @@ math_equation_factorize_real(gpointer data)
return NULL;
}
-
void
math_equation_factorize(MathEquation *equation)
{
@@ -1453,7 +1380,6 @@ math_equation_factorize(MathEquation *equation)
g_timeout_add(100, math_equation_show_in_progress, equation);
}
-
void
math_equation_delete(MathEquation *equation)
{
@@ -1471,7 +1397,6 @@ math_equation_delete(MathEquation *equation)
gtk_text_buffer_delete(GTK_TEXT_BUFFER(equation), &start, &end);
}
-
void
math_equation_backspace(MathEquation *equation)
{
@@ -1490,7 +1415,6 @@ math_equation_backspace(MathEquation *equation)
}
}
-
void
math_equation_clear(MathEquation *equation)
{
@@ -1501,7 +1425,6 @@ math_equation_clear(MathEquation *equation)
clear_ans(equation, FALSE);
}
-
void
math_equation_shift(MathEquation *equation, gint count)
{
@@ -1522,7 +1445,6 @@ math_equation_shift(MathEquation *equation, gint count)
mp_clear(&z);
}
-
void
math_equation_toggle_bit(MathEquation *equation, guint bit)
{
@@ -1560,7 +1482,6 @@ math_equation_toggle_bit(MathEquation *equation, guint bit)
mp_clear(&x);
}
-
static void
math_equation_set_property(GObject *object,
guint prop_id,
@@ -1620,7 +1541,6 @@ math_equation_set_property(GObject *object,
}
}
-
static void
math_equation_get_property(GObject *object,
guint prop_id,
@@ -1691,7 +1611,6 @@ math_equation_get_property(GObject *object,
}
}
-
static void
math_equation_constructed(GObject *object)
{
@@ -1703,7 +1622,6 @@ math_equation_constructed(GObject *object)
MATH_EQUATION(object)->priv->ans_tag = gtk_text_buffer_create_tag(GTK_TEXT_BUFFER(object), NULL, "weight", PANGO_WEIGHT_BOLD, NULL);
}
-
static void
math_equation_class_init(MathEquationClass *klass)
{
@@ -1871,7 +1789,6 @@ math_equation_class_init(MathEquationClass *klass)
NULL);
}
-
static void
pre_insert_text_cb(MathEquation *equation,
GtkTextIter *location,
@@ -1914,7 +1831,6 @@ pre_insert_text_cb(MathEquation *equation,
}
}
-
static gboolean
on_delete(MathEquation *equation)
{
@@ -1922,7 +1838,6 @@ on_delete(MathEquation *equation)
return FALSE;
}
-
static void
pre_delete_range_cb(MathEquation *equation,
GtkTextIter *start,
@@ -1951,7 +1866,6 @@ pre_delete_range_cb(MathEquation *equation,
}
}
-
static void
insert_text_cb(MathEquation *equation,
GtkTextIter *location,
@@ -1970,7 +1884,6 @@ insert_text_cb(MathEquation *equation,
g_object_notify(G_OBJECT(equation), "display");
}
-
static void
delete_range_cb(MathEquation *equation,
GtkTextIter *start,
@@ -1989,7 +1902,6 @@ delete_range_cb(MathEquation *equation,
g_object_notify(G_OBJECT(equation), "display");
}
-
static void
math_equation_init(MathEquation *equation)
{
diff --git a/src/math-history-entry.c b/src/math-history-entry.c
index f3f0f5b..5557e4b 100644
--- a/src/math-history-entry.c
+++ b/src/math-history-entry.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 MATE developers
+ * Copyright (C) 2020-2021 MATE developers
*
* 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
diff --git a/src/math-history-entry.h b/src/math-history-entry.h
index f46f15f..4a9261e 100644
--- a/src/math-history-entry.h
+++ b/src/math-history-entry.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 MATE developers
+ * Copyright (C) 2020-2021 MATE developers
*
* 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
diff --git a/src/math-history.c b/src/math-history.c
index 55bad21..b547371 100644
--- a/src/math-history.c
+++ b/src/math-history.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 MATE developers
+ * Copyright (C) 2020-2021 MATE developers
*
* 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
diff --git a/src/math-history.h b/src/math-history.h
index dc9349e..17088d6 100644
--- a/src/math-history.h
+++ b/src/math-history.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 MATE developers
+ * Copyright (C) 2020-2021 MATE developers
*
* 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
diff --git a/src/math-preferences.c b/src/math-preferences.c
index 33565d9..41e43a6 100644
--- a/src/math-preferences.c
+++ b/src/math-preferences.c
@@ -14,7 +14,6 @@
#include "math-preferences.h"
#include "utility.h"
-
enum {
PROP_0,
PROP_EQUATION
@@ -32,21 +31,18 @@ G_DEFINE_TYPE_WITH_PRIVATE (MathPreferencesDialog, math_preferences, GTK_TYPE_DI
#define GET_WIDGET(ui, name) \
GTK_WIDGET(gtk_builder_get_object(ui, name))
-
MathPreferencesDialog *
math_preferences_dialog_new(MathEquation *equation)
{
return g_object_new(math_preferences_get_type(), "equation", equation, NULL);
}
-
static void
preferences_response_cb(GtkWidget *widget, gint id)
{
gtk_widget_hide(widget);
}
-
static gboolean
preferences_dialog_delete_cb(GtkWidget *widget, GdkEvent *event)
{
@@ -54,7 +50,6 @@ preferences_dialog_delete_cb(GtkWidget *widget, GdkEvent *event)
return TRUE;
}
-
void number_format_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog);
G_MODULE_EXPORT
void
@@ -70,7 +65,6 @@ number_format_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialo
math_equation_set_number_format(dialog->priv->equation, value);
}
-
void angle_unit_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog);
G_MODULE_EXPORT
void
@@ -86,7 +80,6 @@ angle_unit_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
math_equation_set_angle_units(dialog->priv->equation, value);
}
-
void word_size_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog);
G_MODULE_EXPORT
void
@@ -102,7 +95,6 @@ word_size_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
math_equation_set_word_size(dialog->priv->equation, value);
}
-
void decimal_places_spin_change_value_cb(GtkWidget *spin, MathPreferencesDialog *dialog);
G_MODULE_EXPORT
void
@@ -114,7 +106,6 @@ decimal_places_spin_change_value_cb(GtkWidget *spin, MathPreferencesDialog *dial
math_equation_set_accuracy(dialog->priv->equation, value);
}
-
void thousands_separator_check_toggled_cb(GtkWidget *check, MathPreferencesDialog *dialog);
G_MODULE_EXPORT
void
@@ -126,7 +117,6 @@ thousands_separator_check_toggled_cb(GtkWidget *check, MathPreferencesDialog *di
math_equation_set_show_thousands_separators(dialog->priv->equation, value);
}
-
void trailing_zeroes_check_toggled_cb(GtkWidget *check, MathPreferencesDialog *dialog);
G_MODULE_EXPORT
void
@@ -138,7 +128,6 @@ trailing_zeroes_check_toggled_cb(GtkWidget *check, MathPreferencesDialog *dialog
math_equation_set_show_trailing_zeroes(dialog->priv->equation, value);
}
-
static void
set_combo_box_from_int(GtkWidget *combo, int value)
{
@@ -163,7 +152,6 @@ set_combo_box_from_int(GtkWidget *combo, int value)
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
}
-
static void
accuracy_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog)
{
@@ -172,7 +160,6 @@ accuracy_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dia
g_settings_set_int(g_settings_var, "accuracy", math_equation_get_accuracy(equation));
}
-
static void
show_thousands_separators_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog)
{
@@ -181,7 +168,6 @@ show_thousands_separators_cb(MathEquation *equation, GParamSpec *spec, MathPrefe
g_settings_set_boolean(g_settings_var, "show-thousands", math_equation_get_show_thousands_separators(equation));
}
-
static void
show_trailing_zeroes_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog)
{
@@ -190,7 +176,6 @@ show_trailing_zeroes_cb(MathEquation *equation, GParamSpec *spec, MathPreference
g_settings_set_boolean(g_settings_var, "show-zeroes", math_equation_get_show_trailing_zeroes(equation));
}
-
static void
number_format_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog)
{
@@ -198,7 +183,6 @@ number_format_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog
g_settings_set_enum(g_settings_var, "number-format", math_equation_get_number_format(equation));
}
-
static void
word_size_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog)
{
@@ -206,7 +190,6 @@ word_size_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *di
g_settings_set_int(g_settings_var, "word-size", math_equation_get_word_size(equation));
}
-
static void
angle_unit_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog)
{
@@ -214,7 +197,6 @@ angle_unit_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *d
g_settings_set_enum(g_settings_var, "angle-units", math_equation_get_angle_units(equation));
}
-
static void
create_gui(MathPreferencesDialog *dialog)
{
@@ -335,7 +317,6 @@ create_gui(MathPreferencesDialog *dialog)
angle_unit_cb(dialog->priv->equation, NULL, dialog);
}
-
static void
math_preferences_set_property(GObject *object,
guint prop_id,
@@ -357,7 +338,6 @@ math_preferences_set_property(GObject *object,
}
}
-
static void
math_preferences_get_property(GObject *object,
guint prop_id,
@@ -378,7 +358,6 @@ math_preferences_get_property(GObject *object,
}
}
-
static void
math_preferences_class_init(MathPreferencesDialogClass *klass)
{
@@ -396,7 +375,6 @@ math_preferences_class_init(MathPreferencesDialogClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
-
static void
math_preferences_init(MathPreferencesDialog *dialog)
{
diff --git a/src/math-variable-popup.c b/src/math-variable-popup.c
index 26bc4f5..0a78455 100644
--- a/src/math-variable-popup.c
+++ b/src/math-variable-popup.c
@@ -35,14 +35,12 @@ math_variable_popup_new(MathEquation *equation)
return g_object_new(math_variable_popup_get_type(), "equation", equation, NULL);
}
-
static void
variable_focus_out_event_cb(GtkWidget *widget, GdkEventFocus *event, MathVariablePopup *popup)
{
gtk_widget_destroy(widget);
}
-
static void
insert_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
{
@@ -54,7 +52,6 @@ insert_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
gtk_widget_destroy(gtk_widget_get_toplevel(widget));
}
-
static gboolean
variable_name_key_press_cb(GtkWidget *widget, GdkEventKey *event, MathVariablePopup *popup)
{
@@ -65,7 +62,6 @@ variable_name_key_press_cb(GtkWidget *widget, GdkEventKey *event, MathVariablePo
return FALSE;
}
-
static void
variable_name_changed_cb(GtkWidget *widget, MathVariablePopup *popup)
{
@@ -73,7 +69,6 @@ variable_name_changed_cb(GtkWidget *widget, MathVariablePopup *popup)
gtk_widget_set_sensitive(popup->priv->add_variable_button, text[0] != '\0');
}
-
static void
add_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
{
@@ -95,7 +90,6 @@ add_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
mp_clear(&z);
}
-
static void
save_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
{
@@ -114,7 +108,6 @@ save_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
mp_clear(&z);
}
-
static void
delete_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
{
@@ -126,7 +119,6 @@ delete_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
gtk_widget_destroy(gtk_widget_get_toplevel(widget));
}
-
static GtkWidget *
make_variable_entry(MathVariablePopup *popup, const gchar *name, const MPNumber *value, gboolean writable)
{
@@ -184,7 +176,6 @@ make_variable_entry(MathVariablePopup *popup, const gchar *name, const MPNumber
return hbox;
}
-
static void
math_variable_popup_set_property(GObject *object,
guint prop_id,
@@ -248,7 +239,6 @@ math_variable_popup_set_property(GObject *object,
}
}
-
static void
math_variable_popup_get_property(GObject *object,
guint prop_id,
@@ -269,7 +259,6 @@ math_variable_popup_get_property(GObject *object,
}
}
-
static void
math_variable_popup_class_init(MathVariablePopupClass *klass)
{
@@ -287,7 +276,6 @@ math_variable_popup_class_init(MathVariablePopupClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
-
static void
math_variable_popup_init(MathVariablePopup *popup)
{
diff --git a/src/math-variables.c b/src/math-variables.c
index b44b387..3eddc4d 100644
--- a/src/math-variables.c
+++ b/src/math-variables.c
@@ -14,7 +14,6 @@
#include "math-variables.h"
#include "mp-serializer.h"
-
struct MathVariablesPrivate
{
gchar *file_name;
@@ -24,14 +23,12 @@ struct MathVariablesPrivate
G_DEFINE_TYPE_WITH_PRIVATE (MathVariables, math_variables, G_TYPE_OBJECT);
-
MathVariables *
math_variables_new()
{
return g_object_new (math_variables_get_type(), NULL);
}
-
static void
registers_load(MathVariables *variables)
{
@@ -71,7 +68,6 @@ registers_load(MathVariables *variables)
fclose(f);
}
-
static void
registers_save(MathVariables *variables)
{
@@ -102,7 +98,6 @@ registers_save(MathVariables *variables)
fclose(f);
}
-
// FIXME: Sort
gchar **
math_variables_get_names(MathVariables *variables)
@@ -128,7 +123,6 @@ math_variables_get_names(MathVariables *variables)
return names;
}
-
void
math_variables_set(MathVariables *variables, const char *name, const MPNumber *value)
{
@@ -145,7 +139,6 @@ math_variables_set(MathVariables *variables, const char *name, const MPNumber *v
registers_save(variables);
}
-
MPNumber *
math_variables_get(MathVariables *variables, const char *name)
{
@@ -154,7 +147,6 @@ math_variables_get(MathVariables *variables, const char *name)
return g_hash_table_lookup(variables->priv->registers, name);
}
-
void
math_variables_delete(MathVariables *variables, const char *name)
{
@@ -164,13 +156,11 @@ math_variables_delete(MathVariables *variables, const char *name)
registers_save(variables);
}
-
static void
math_variables_class_init (MathVariablesClass *klass)
{
}
-
static void
math_variables_init(MathVariables *variables)
{
diff --git a/src/math-window.c b/src/math-window.c
index 8d6f79d..320f83b 100644
--- a/src/math-window.c
+++ b/src/math-window.c
@@ -86,7 +86,6 @@ math_window_get_equation(MathWindow *window)
return window->priv->equation;
}
-
MathDisplay *
math_window_get_display(MathWindow *window)
{
@@ -94,7 +93,6 @@ math_window_get_display(MathWindow *window)
return window->priv->display;
}
-
MathButtons *
math_window_get_buttons(MathWindow *window)
{
@@ -393,7 +391,6 @@ scroll_changed_cb(GtkAdjustment *adjustment, MathWindow *window)
gtk_adjustment_set_value(adjustment, gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment));
}
-
static void
scroll_value_changed_cb(GtkAdjustment *adjustment, MathWindow *window)
{
@@ -630,7 +627,6 @@ create_gui(MathWindow *window)
gtk_widget_show(GTK_WIDGET(window->priv->buttons));
}
-
static void
math_window_set_property(GObject *object,
guint prop_id,
@@ -655,7 +651,6 @@ math_window_set_property(GObject *object,
}
}
-
static void
math_window_get_property(GObject *object,
guint prop_id,
@@ -679,7 +674,6 @@ math_window_get_property(GObject *object,
}
}
-
static void
math_window_class_init(MathWindowClass *klass)
{
@@ -713,7 +707,6 @@ math_window_class_init(MathWindowClass *klass)
G_TYPE_NONE, 0);
}
-
static void
math_window_init(MathWindow *window)
{
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..bb183cd
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,120 @@
+src = []
+src_cmd = []
+test_mp_src = []
+test_mp_eq_src = []
+
+enums = []
+
+enums += gnome.mkenums('types',
+ sources: 'mp-serializer.h',
+ c_template: 'mp-enums.c.template',
+ h_template: 'mp-enums.h.template')
+
+ui_files = files(
+ 'buttons-advanced.ui',
+ 'buttons-basic.ui',
+ 'buttons-financial.ui',
+ 'preferences.ui'
+)
+
+ui_resources = gnome.compile_resources(
+ 'ui_resources',
+ 'org.mate.calculator.gresource.xml',
+ source_dir: 'src'
+)
+
+src += [
+ 'mate-calc.c',
+ 'currency-manager.c',
+ 'currency.c',
+ 'financial.c',
+ 'lexer.c',
+ 'math-buttons.c',
+ 'math-converter.c',
+ 'math-display.c',
+ 'math-equation.c',
+ 'math-history.c',
+ 'math-history-entry.c',
+ 'math-preferences.c',
+ 'math-variable-popup.c',
+ 'math-variables.c',
+ 'math-window.c',
+ 'mp-binary.c',
+ 'mp-convert.c',
+ 'mp-equation.c',
+ 'mp-trigonometric.c',
+ 'mp-serializer.c',
+ 'mp.c',
+ 'parser.c',
+ 'parserfunc.c',
+ 'prelexer.c',
+ 'unit-category.c',
+ 'unit-manager.c',
+ 'unit.c',
+ enums,
+ ui_resources
+]
+
+src_cmd += [
+ 'mate-calc-cmd.c',
+ 'currency.c',
+ 'currency-manager.c',
+ 'mp.c',
+ 'mp-binary.c',
+ 'mp-convert.c',
+ 'mp-equation.c',
+ 'mp-serializer.c',
+ 'mp-trigonometric.c',
+ 'unit.c',
+ 'unit-category.c',
+ 'unit-manager.c',
+ 'prelexer.c',
+ 'lexer.c',
+ 'parserfunc.c',
+ 'parser.c',
+ enums
+]
+
+test_mp_src += [
+ 'test-mp.c',
+ 'mp.c',
+ 'mp-convert.c',
+ 'mp-trigonometric.c'
+]
+
+test_mp_eq_src += [
+ 'test-mp-equation.c',
+ 'currency.c',
+ 'currency-manager.c',
+ 'mp.c',
+ 'mp-convert.c',
+ 'mp-binary.c',
+ enums,
+ 'mp-equation.c',
+ 'mp-serializer.c',
+ 'mp-trigonometric.c',
+ 'unit.c',
+ 'unit-category.c',
+ 'unit-manager.c',
+ 'prelexer.c',
+ 'lexer.c',
+ 'parserfunc.c',
+ 'parser.c',
+]
+
+executable('mate-calc', src, include_directories: top_inc,
+ dependencies : [gio, glib, gobject,gtk, libxml, mpc, mpfr],
+ link_args: '-rdynamic',
+ install : true,
+ install_dir : get_option('bindir'))
+
+executable('mate-calc-cmd', src_cmd, include_directories: top_inc,
+ dependencies : [gio, libxml, mpc, mpfr],
+ install : true,
+ install_dir : get_option('bindir'))
+
+executable('test-mp', test_mp_src, include_directories: top_inc,
+ dependencies : [gio, libxml, mpc, mpfr])
+
+executable('test-mp-equation', test_mp_eq_src, include_directories: top_inc,
+ dependencies: [gio, libxml, mpc, mpfr])
diff --git a/src/mp-binary.c b/src/mp-binary.c
index 800724c..046bd92 100644
--- a/src/mp-binary.c
+++ b/src/mp-binary.c
@@ -30,7 +30,6 @@ static int hex_to_int(char digit)
return 0;
}
-
static gchar *
to_hex_string(const MPNumber *x)
{
@@ -44,7 +43,6 @@ to_hex_string(const MPNumber *x)
return result;
}
-
static void
mp_bitwise(const MPNumber *x, const MPNumber *y, int (*bitwise_operator)(int, int), MPNumber *z, int wordlen)
{
@@ -88,13 +86,11 @@ mp_bitwise(const MPNumber *x, const MPNumber *y, int (*bitwise_operator)(int, in
g_free(text2);
}
-
static int mp_bitwise_and(int v1, int v2) { return v1 & v2; }
static int mp_bitwise_or(int v1, int v2) { return v1 | v2; }
static int mp_bitwise_xor(int v1, int v2) { return v1 ^ v2; }
static int mp_bitwise_not(int v1, int dummy) { return v1 ^ 0xF; }
-
bool
mp_is_overflow (const MPNumber *x, int wordlen)
{
@@ -109,7 +105,6 @@ mp_is_overflow (const MPNumber *x, int wordlen)
return is_overflow;
}
-
void
mp_and(const MPNumber *x, const MPNumber *y, MPNumber *z)
{
@@ -122,7 +117,6 @@ mp_and(const MPNumber *x, const MPNumber *y, MPNumber *z)
mp_bitwise(x, y, mp_bitwise_and, z, 0);
}
-
void
mp_or(const MPNumber *x, const MPNumber *y, MPNumber *z)
{
@@ -135,7 +129,6 @@ mp_or(const MPNumber *x, const MPNumber *y, MPNumber *z)
mp_bitwise(x, y, mp_bitwise_or, z, 0);
}
-
void
mp_xor(const MPNumber *x, const MPNumber *y, MPNumber *z)
{
@@ -148,7 +141,6 @@ mp_xor(const MPNumber *x, const MPNumber *y, MPNumber *z)
mp_bitwise(x, y, mp_bitwise_xor, z, 0);
}
-
void
mp_not(const MPNumber *x, int wordlen, MPNumber *z)
{
@@ -166,7 +158,6 @@ mp_not(const MPNumber *x, int wordlen, MPNumber *z)
mp_clear(&temp);
}
-
void
mp_shift(const MPNumber *x, int count, MPNumber *z)
{
@@ -192,7 +183,6 @@ mp_shift(const MPNumber *x, int count, MPNumber *z)
mp_clear(&multiplier);
}
-
void
mp_ones_complement(const MPNumber *x, int wordlen, MPNumber *z)
{
@@ -203,7 +193,6 @@ mp_ones_complement(const MPNumber *x, int wordlen, MPNumber *z)
mp_clear(&t);
}
-
void
mp_twos_complement(const MPNumber *x, int wordlen, MPNumber *z)
{
diff --git a/src/mp-convert.c b/src/mp-convert.c
index c0a88c1..5f097c8 100644
--- a/src/mp-convert.c
+++ b/src/mp-convert.c
@@ -24,28 +24,24 @@ mp_set_from_mp(const MPNumber *x, MPNumber *z)
mpc_set(z->num, x->num, MPC_RNDNN);
}
-
void
mp_set_from_double(double dx, MPNumber *z)
{
mpc_set_d(z->num, dx, MPC_RNDNN);
}
-
void
mp_set_from_integer(long x, MPNumber *z)
{
mpc_set_si(z->num, x, MPC_RNDNN);
}
-
void
mp_set_from_unsigned_integer(ulong x, MPNumber *z)
{
mpc_set_ui(z->num, x, MPC_RNDNN);
}
-
void
mp_set_from_fraction(long numerator, long denominator, MPNumber *z)
{
@@ -59,7 +55,6 @@ mp_set_from_fraction(long numerator, long denominator, MPNumber *z)
mp_divide_integer(z, denominator, z);
}
-
void
mp_set_from_polar(const MPNumber *r, MPAngleUnit unit, const MPNumber *theta, MPNumber *z)
{
@@ -94,7 +89,6 @@ mp_to_integer(const MPNumber *x)
return mpfr_get_si(mpc_realref(x->num), MPFR_RNDN);
}
-
ulong
mp_to_unsigned_integer(const MPNumber *x)
{
@@ -182,7 +176,6 @@ char_val(char **c, int base)
return value;
}
-
static int
ends_with(const char *start, const char *end, const char *word)
{
@@ -194,7 +187,6 @@ ends_with(const char *start, const char *end, const char *word)
return strncmp(end - word_len, word, word_len) == 0;
}
-
// FIXME: Doesn't handle errors well (e.g. trailing space)
static bool
set_from_sexagesimal(const char *str, int length, MPNumber *z)
@@ -225,7 +217,6 @@ set_from_sexagesimal(const char *str, int length, MPNumber *z)
return false;
}
-
bool
mp_set_from_string(const char *str, int default_base, MPNumber *z)
{
diff --git a/src/mp-equation.c b/src/mp-equation.c
index df9d872..0c9e204 100644
--- a/src/mp-equation.c
+++ b/src/mp-equation.c
@@ -37,7 +37,6 @@ variable_is_defined(ParserState *state, const char *name)
return 0;
}
-
static int
get_variable(ParserState *state, const char *name, MPNumber *z)
{
@@ -103,7 +102,6 @@ set_variable(ParserState *state, const char *name, const MPNumber *x)
// i.e. numbers+letters = variable or function depending on following arg
// letters+numbers = numbers+letters+numbers = function
-
int
sub_atoi(const char *data)
{
@@ -143,7 +141,6 @@ super_atoi(const char *data)
return sign * value;
}
-
static int
function_is_defined(ParserState *state, const char *name)
{
@@ -188,7 +185,6 @@ function_is_defined(ParserState *state, const char *name)
return 0;
}
-
static int
get_function(ParserState *state, const char *name, const MPNumber *x, MPNumber *z)
{
@@ -280,7 +276,6 @@ get_function(ParserState *state, const char *name, const MPNumber *x, MPNumber *
return result;
}
-
static int
convert(ParserState *state, const MPNumber *x, const char *x_units, const char *z_units, MPNumber *z)
{
@@ -290,7 +285,6 @@ convert(ParserState *state, const MPNumber *x, const char *x_units, const char *
return 0;
}
-
MPErrorCode
mp_equation_parse(const char *expression, MPEquationOptions *options, MPNumber *result, char **error_token)
{
@@ -336,7 +330,6 @@ mp_equation_parse(const char *expression, MPEquationOptions *options, MPNumber *
return PARSER_ERR_NONE;
}
-
const char *
mp_error_code_to_string(MPErrorCode error_code)
{
diff --git a/src/mp-serializer.c b/src/mp-serializer.c
index cd72eee..4c04f64 100644
--- a/src/mp-serializer.c
+++ b/src/mp-serializer.c
@@ -41,7 +41,6 @@ struct MpSerializerPrivate
gint tsep_count; /* Number of digits between separator. */
};
-
G_DEFINE_TYPE_WITH_PRIVATE (MpSerializer, mp_serializer, G_TYPE_OBJECT);
MpSerializer *
@@ -54,7 +53,6 @@ mp_serializer_new(MpDisplayFormat format, int base, int trailing_digits)
return serializer;
}
-
static void
mp_to_string_real(MpSerializer *serializer, const MPNumber *x, int base, gboolean force_sign, int *n_digits, GString *string)
{
@@ -180,7 +178,6 @@ mp_to_string_real(MpSerializer *serializer, const MPNumber *x, int base, gboolea
mp_clear(&temp);
}
-
static gchar *
mp_to_string(MpSerializer *serializer, const MPNumber *x, int *n_digits)
{
@@ -243,7 +240,6 @@ mp_to_string(MpSerializer *serializer, const MPNumber *x, int *n_digits)
return result;
}
-
static int
mp_to_exponential_string_real(MpSerializer *serializer, const MPNumber *x, GString *string, gboolean eng_format, int *n_digits)
{
@@ -307,7 +303,6 @@ mp_to_exponential_string_real(MpSerializer *serializer, const MPNumber *x, GStri
return exponent;
}
-
static void
append_exponent(GString *string, int exponent)
{
@@ -329,7 +324,6 @@ append_exponent(GString *string, int exponent)
g_free (super_value);
}
-
static gchar *
mp_to_exponential_string(MpSerializer *serializer, const MPNumber *x, gboolean eng_format, int *n_digits)
{
@@ -392,7 +386,6 @@ mp_to_exponential_string(MpSerializer *serializer, const MPNumber *x, gboolean e
return result;
}
-
gchar *
mp_serializer_to_string(MpSerializer *serializer, const MPNumber *x)
{
@@ -418,133 +411,114 @@ mp_serializer_to_string(MpSerializer *serializer, const MPNumber *x)
}
}
-
gboolean
mp_serializer_from_string(MpSerializer *serializer, const gchar *str, MPNumber *z)
{
return mp_set_from_string(str, serializer->priv->base, z);
}
-
void
mp_serializer_set_base(MpSerializer *serializer, gint base)
{
serializer->priv->base = base;
}
-
int
mp_serializer_get_base(MpSerializer *serializer)
{
return serializer->priv->base;
}
-
void
mp_serializer_set_radix(MpSerializer *serializer, gunichar radix)
{
serializer->priv->radix = radix;
}
-
gunichar
mp_serializer_get_radix(MpSerializer *serializer)
{
return serializer->priv->radix;
}
-
void
mp_serializer_set_thousands_separator(MpSerializer *serializer, gunichar separator)
{
serializer->priv->tsep = separator;
}
-
gunichar
mp_serializer_get_thousands_separator(MpSerializer *serializer)
{
return serializer->priv->tsep;
}
-
gint
mp_serializer_get_thousands_separator_count(MpSerializer *serializer)
{
return serializer->priv->tsep_count;
}
-
void
mp_serializer_set_show_thousands_separators(MpSerializer *serializer, gboolean visible)
{
serializer->priv->show_tsep = visible;
}
-
gboolean
mp_serializer_get_show_thousands_separators(MpSerializer *serializer)
{
return serializer->priv->show_tsep;
}
-
void
mp_serializer_set_show_trailing_zeroes(MpSerializer *serializer, gboolean visible)
{
serializer->priv->show_zeroes = visible;
}
-
gboolean
mp_serializer_get_show_trailing_zeroes(MpSerializer *serializer)
{
return serializer->priv->show_zeroes;
}
-
int
mp_serializer_get_leading_digits(MpSerializer *serializer)
{
return serializer->priv->leading_digits;
}
-
void
mp_serializer_set_leading_digits(MpSerializer *serializer, int leading_digits)
{
serializer->priv->leading_digits = leading_digits;
}
-
int
mp_serializer_get_trailing_digits(MpSerializer *serializer)
{
return serializer->priv->trailing_digits;
}
-
void
mp_serializer_set_trailing_digits(MpSerializer *serializer, int trailing_digits)
{
serializer->priv->trailing_digits = trailing_digits;
}
-
MpDisplayFormat
mp_serializer_get_number_format(MpSerializer *serializer)
{
return serializer->priv->format;
}
-
void
mp_serializer_set_number_format(MpSerializer *serializer, MpDisplayFormat format)
{
serializer->priv->format = format;
}
-
static void
mp_serializer_set_property(GObject *object,
guint prop_id,
@@ -569,7 +543,6 @@ mp_serializer_set_property(GObject *object,
}
}
-
static void
mp_serializer_get_property(GObject *object,
guint prop_id,
@@ -594,7 +567,6 @@ mp_serializer_get_property(GObject *object,
}
}
-
static void
mp_serializer_class_init(MpSerializerClass *klass)
{
@@ -633,7 +605,6 @@ mp_serializer_class_init(MpSerializerClass *klass)
G_PARAM_READWRITE));
}
-
static void
mp_serializer_init(MpSerializer *serializer)
{
diff --git a/src/mp-trigonometric.c b/src/mp-trigonometric.c
index 622d2dd..70838f8 100644
--- a/src/mp-trigonometric.c
+++ b/src/mp-trigonometric.c
@@ -71,7 +71,6 @@ convert_from_radians(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mpfr_clear(scale);
}
-
void
mp_get_pi (MPNumber *z)
{
@@ -79,7 +78,6 @@ mp_get_pi (MPNumber *z)
mpfr_set_zero(mpc_imagref(z->num), 0);
}
-
void
mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
@@ -90,7 +88,6 @@ mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mpc_sin(z->num, z->num, MPC_RNDNN);
}
-
void
mp_cos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
@@ -101,7 +98,6 @@ mp_cos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mpc_cos(z->num, z->num, MPC_RNDNN);
}
-
void
mp_tan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
@@ -135,7 +131,6 @@ mp_tan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_clear(&t1);
}
-
void
mp_asin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
@@ -160,7 +155,6 @@ mp_asin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_clear(&x_min);
}
-
void
mp_acos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
@@ -185,7 +179,6 @@ mp_acos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_clear(&x_min);
}
-
void
mp_atan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
@@ -211,35 +204,30 @@ mp_atan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_clear(&minus_i);
}
-
void
mp_sinh(const MPNumber *x, MPNumber *z)
{
mpc_sinh(z->num, x->num, MPC_RNDNN);
}
-
void
mp_cosh(const MPNumber *x, MPNumber *z)
{
mpc_cosh(z->num, x->num, MPC_RNDNN);
}
-
void
mp_tanh(const MPNumber *x, MPNumber *z)
{
mpc_tanh(z->num, x->num, MPC_RNDNN);
}
-
void
mp_asinh(const MPNumber *x, MPNumber *z)
{
mpc_asinh(z->num, x->num, MPC_RNDNN);
}
-
void
mp_acosh(const MPNumber *x, MPNumber *z)
{
@@ -260,7 +248,6 @@ mp_acosh(const MPNumber *x, MPNumber *z)
mp_clear(&t);
}
-
void
mp_atanh(const MPNumber *x, MPNumber *z)
{
diff --git a/src/mp.c b/src/mp.c
index 40aacdc..31a84d4 100644
--- a/src/mp.c
+++ b/src/mp.c
@@ -645,7 +645,6 @@ mp_zeta(const MPNumber *x, MPNumber *z)
/** FACTORIZATION **/
/***********************************************************************/
-
/**
* mp_is_pprime uses the Miller-Rabin primality test to decide
* whether or not a number is probable prime.
diff --git a/src/mp.h b/src/mp.h
index 22bc986..437f6f7 100644
--- a/src/mp.h
+++ b/src/mp.h
@@ -139,7 +139,7 @@ void mp_invert_sign(const MPNumber *x, MPNumber *z);
void mp_add(const MPNumber *x, const MPNumber *y, MPNumber *z);
/* Sets z = x + y */
-void mp_add_integer(const MPNumber *x, int64_t y, MPNumber *z);
+void mp_add_integer(const MPNumber *x, long y, MPNumber *z);
/* Sets z = x − y */
void mp_subtract(const MPNumber *x, const MPNumber *y, MPNumber *z);
@@ -148,13 +148,13 @@ void mp_subtract(const MPNumber *x, const MPNumber *y, MPNumber *z);
void mp_multiply(const MPNumber *x, const MPNumber *y, MPNumber *z);
/* Sets z = x × y */
-void mp_multiply_integer(const MPNumber *x, int64_t y, MPNumber *z);
+void mp_multiply_integer(const MPNumber *x, long y, MPNumber *z);
/* Sets z = x ÷ y */
void mp_divide(const MPNumber *x, const MPNumber *y, MPNumber *z);
/* Sets z = x ÷ y */
-void mp_divide_integer(const MPNumber *x, int64_t y, MPNumber *z);
+void mp_divide_integer(const MPNumber *x, long y, MPNumber *z);
/* Sets z = 1 ÷ x */
void mp_reciprocal(const MPNumber *, MPNumber *);
@@ -183,7 +183,7 @@ void mp_round(const MPNumber *x, MPNumber *z);
void mp_ln(const MPNumber *x, MPNumber *z);
/* Sets z = log_n x */
-void mp_logarithm(int64_t n, const MPNumber *x, MPNumber *z);
+void mp_logarithm(long n, const MPNumber *x, MPNumber *z);
/* Sets z = π */
void mp_get_pi(MPNumber *z);
@@ -233,13 +233,13 @@ void mp_set_from_float(float x, MPNumber *z);
void mp_set_from_double(double x, MPNumber *z);
/* Sets z = x */
-void mp_set_from_integer(int64_t x, MPNumber *z);
+void mp_set_from_integer(long x, MPNumber *z);
/* Sets z = x */
-void mp_set_from_unsigned_integer(uint64_t x, MPNumber *z);
+void mp_set_from_unsigned_integer(ulong x, MPNumber *z);
/* Sets z = numerator ÷ denominator */
-void mp_set_from_fraction(int64_t numerator, int64_t denominator, MPNumber *z);
+void mp_set_from_fraction(long numerator, long denominator, MPNumber *z);
/* Sets z = r(cos theta + i sin theta) */
void mp_set_from_polar(const MPNumber *r, MPAngleUnit unit, const MPNumber *theta, MPNumber *z);
diff --git a/src/parserfunc.h b/src/parserfunc.h
index cf049b0..d794839 100644
--- a/src/parserfunc.h
+++ b/src/parserfunc.h
@@ -1,4 +1,4 @@
-#ifndef PAESERFUNC_H
+#ifndef PARSERFUNC_H
#define PARSERFUNC_H
#include "parser.h"
diff --git a/src/test-mp-equation.c b/src/test-mp-equation.c
index 761deb4..5d480df 100644
--- a/src/test-mp-equation.c
+++ b/src/test-mp-equation.c
@@ -33,7 +33,6 @@ static int passes = 0;
static void pass(const char *format, ...) __attribute__((format(printf, 1, 2)));
static void fail(const char *format, ...) __attribute__((format(printf, 1, 2)));
-
static void pass(const char *format, ...)
{
/* va_list args;
@@ -59,7 +58,6 @@ static void fail(const char *format, ...)
fails++;
}
-
static const char *
error_code_to_string(MPErrorCode error)
{
@@ -72,7 +70,6 @@ error_code_to_string(MPErrorCode error)
return error_string;
}
-
static void
Test(char *expression, char *expected, int expected_error, int trailing_digits)
{
@@ -113,14 +110,12 @@ Test(char *expression, char *expected, int expected_error, int trailing_digits)
mp_clear(&result);
}
-
static int
do_convert(const MPNumber *x, const char *x_units, const char *z_units, MPNumber *z, void *data)
{
return unit_manager_convert_by_symbol(unit_manager_get_default(), x, x_units, z_units, z);
}
-
static void
test_conversions(void)
{
@@ -161,6 +156,105 @@ test_conversions(void)
test("0 K in degC", "−273.15", 0);
}
+static void try(const char* string, bool result, bool expected)
+{
+ if ((result && !expected) || (!result && expected))
+ {
+ fail("%s -> %s, expected %s", string, expected ? "true" : "false", result ? "true" : "false");
+ }
+ else
+ {
+ pass("%s -> %s", string, result ? "true" : "false");
+ }
+}
+
+static void test_mp()
+{
+ MPNumber zero = mp_new();
+ MPNumber one = mp_new();
+ MPNumber minus_one = mp_new();
+ mp_set_from_integer(0, &zero);
+ mp_set_from_integer(1, &one);
+ mp_set_from_integer(-1, &minus_one);
+
+ try("mp_is_zero(-1)", mp_is_zero(&minus_one), false);
+ try("mp_is_zero(0)", mp_is_zero(&zero), true);
+ try("mp_is_zero(1)", mp_is_zero(&one), false);
+
+ try("mp_is_negative(-1)", mp_is_negative(&minus_one), true);
+ try("mp_is_negative(0)", mp_is_negative(&zero), false);
+ try("mp_is_negative(1)", mp_is_negative(&one), false);
+
+ try("mp_is_integer(-1)", mp_is_integer(&minus_one), true);
+ try("mp_is_integer(0)", mp_is_integer(&zero), true);
+ try("mp_is_integer(1)", mp_is_integer(&one), true);
+
+ try("mp_is_positive_integer(-1)", mp_is_positive_integer(&minus_one), false);
+ try("mp_is_positive_integer(0)", mp_is_positive_integer(&zero), true);
+ try("mp_is_positive_integer(1)", mp_is_positive_integer(&one), true);
+
+ try("mp_is_natural(-1)", mp_is_natural(&minus_one), false);
+ try("mp_is_natural(0)", mp_is_natural(&zero), false);
+ try("mp_is_natural(1)", mp_is_natural(&one), true);
+
+ try("mp_is_complex(-1)", mp_is_complex(&minus_one), false);
+ try("mp_is_complex(0)", mp_is_complex(&zero), false);
+ try("mp_is_complex(1)", mp_is_complex(&one), false);
+
+ try("mp_is_equal(-1, -1)", mp_is_equal(&minus_one, &minus_one), true);
+ try("mp_is_equal(-1, 0)", mp_is_equal(&minus_one, &zero), false);
+ try("mp_is_equal(-1, 1)", mp_is_equal(&minus_one, &one), false);
+ try("mp_is_equal(0, -1)", mp_is_equal(&zero, &minus_one), false);
+ try("mp_is_equal(0, 0)", mp_is_equal(&zero, &zero), true);
+ try("mp_is_equal(0, 1)", mp_is_equal(&zero, &one), false);
+ try("mp_is_equal(1, -1)", mp_is_equal(&one, &minus_one), false);
+ try("mp_is_equal(1, 0)", mp_is_equal(&one, &zero), false);
+ try("mp_is_equal(1, 1)", mp_is_equal(&one, &one), true);
+
+ try("mp_is_greater_than(0, -1)", mp_is_greater_than (&zero, &minus_one), true);
+ try("mp_is_greater_than(0, 0)", mp_is_greater_than (&zero, &zero), false);
+ try("mp_is_greater_than(0, 1)", mp_is_greater_than (&zero, &one), false);
+ try("mp_is_greater_than(1, -1)", mp_is_greater_than (&one, &minus_one), true);
+ try("mp_is_greater_than(1, 0)", mp_is_greater_than (&one, &zero), true);
+ try("mp_is_greater_than(1, 1)", mp_is_greater_than (&one, &one), false);
+ try("mp_is_greater_than(-1, -1)", mp_is_greater_than (&minus_one, &minus_one), false);
+ try("mp_is_greater_than(-1, 0)", mp_is_greater_than (&minus_one, &zero), false);
+ try("mp_is_greater_than(-1, 1)", mp_is_greater_than (&minus_one, &one), false);
+
+ try("mp_is_greater_equal(0, -1)", mp_is_greater_equal (&zero, &minus_one), true);
+ try("mp_is_greater_equal(0, 0)", mp_is_greater_equal (&zero, &zero), true);
+ try("mp_is_greater_equal(0, 1)", mp_is_greater_equal (&zero, &one), false);
+ try("mp_is_greater_equal(1, -1)", mp_is_greater_equal (&one, &minus_one), true);
+ try("mp_is_greater_equal(1, 0)", mp_is_greater_equal (&one, &zero), true);
+ try("mp_is_greater_equal(1, 1)", mp_is_greater_equal (&one, &one), true);
+ try("mp_is_greater_equal(-1, -1)", mp_is_greater_equal (&minus_one, &minus_one), true);
+ try("mp_is_greater_equal(-1, 0)", mp_is_greater_equal (&minus_one, &zero), false);
+ try("mp_is_greater_equal(-1, 1)", mp_is_greater_equal (&minus_one, &one), false);
+
+ try("mp_is_less_than(0, -1)", mp_is_less_than (&zero, &minus_one), false);
+ try("mp_is_less_than(0, 0)", mp_is_less_than (&zero, &zero), false);
+ try("mp_is_less_than(0, 1)", mp_is_less_than (&zero, &one), true);
+ try("mp_is_less_than(1, -1)", mp_is_less_than (&one, &minus_one), false);
+ try("mp_is_less_than(1, 0)", mp_is_less_than (&one, &zero), false);
+ try("mp_is_less_than(1, 1)", mp_is_less_than (&one, &one), false);
+ try("mp_is_less_than(-1, -1)", mp_is_less_than (&minus_one, &minus_one), false);
+ try("mp_is_less_than(-1, 0)", mp_is_less_than (&minus_one, &zero), true);
+ try("mp_is_less_than(-1, 1)", mp_is_less_than (&minus_one, &one), true);
+
+ try("mp_is_less_equal(0, -1)", mp_is_less_equal (&zero, &minus_one), false);
+ try("mp_is_less_equal(0, 0)", mp_is_less_equal (&zero, &zero), true);
+ try("mp_is_less_equal(0, 1)", mp_is_less_equal (&zero, &one), true);
+ try("mp_is_less_equal(1, -1)", mp_is_less_equal (&one, &minus_one), false);
+ try("mp_is_less_equal(1, 0)", mp_is_less_equal (&one, &zero), false);
+ try("mp_is_less_equal(1, 1)", mp_is_less_equal (&one, &one), true);
+ try("mp_is_less_equal(-1, -1)", mp_is_less_equal (&minus_one, &minus_one), true);
+ try("mp_is_less_equal(-1, 0)", mp_is_less_equal (&minus_one, &zero), true);
+ try("mp_is_less_equal(-1, 1)", mp_is_less_equal (&minus_one, &one), true);
+
+ mp_clear(&zero);
+ mp_clear(&one);
+ mp_clear(&minus_one);
+}
static int
variable_is_defined(const char *name, void *data)
@@ -168,7 +262,6 @@ variable_is_defined(const char *name, void *data)
return strcmp (name, "x") == 0 || strcmp (name, "y") == 0;
}
-
static int
get_variable(const char *name, MPNumber *z, void *data)
{
@@ -183,7 +276,6 @@ get_variable(const char *name, MPNumber *z, void *data)
return 0;
}
-
static void
set_variable(const char *name, const MPNumber *x, void *data)
{
@@ -681,12 +773,12 @@ test_equations(void)
//test("¬¬10₂", "10₂", 0);
}
-
int
main (void)
{
setlocale(LC_ALL, "C");
+ test_mp();
test_conversions();
test_equations();
if (fails == 0)
diff --git a/src/test-mp.c b/src/test-mp.c
index 1a8c0d7..f367093 100644
--- a/src/test-mp.c
+++ b/src/test-mp.c
@@ -27,7 +27,6 @@ static int passes = 0;
static void pass(const char *format, ...) __attribute__((format(printf, 1, 2)));
static void fail(const char *format, ...) __attribute__((format(printf, 1, 2)));
-
static void pass(const char *format, ...)
{
/* va_list args;
@@ -53,7 +52,6 @@ static void fail(const char *format, ...)
fails++;
}
-
static void
print_number(MPNumber *x)
{
@@ -86,7 +84,6 @@ test_integer(int number)
mp_clear(&t);
}
-
static void
test_numbers(void)
{
@@ -119,7 +116,6 @@ test_numbers(void)
test_string("16384.00006103515625");
}
-
static void
try(const char *string, bool result, bool expected)
{
@@ -129,7 +125,6 @@ try(const char *string, bool result, bool expected)
pass("%s -> %s", string, result ? "true" : "false");
}
-
static void
test_mp(void)
{
@@ -219,7 +214,6 @@ test_mp(void)
mp_clear(&minus_one);
}
-
int
main (void)
{
diff --git a/src/unit-category.c b/src/unit-category.c
index 72f50d5..a19b68b 100644
--- a/src/unit-category.c
+++ b/src/unit-category.c
@@ -22,7 +22,6 @@ struct UnitCategoryPrivate
G_DEFINE_TYPE_WITH_PRIVATE (UnitCategory, unit_category, G_TYPE_OBJECT);
-
UnitCategory *
unit_category_new(const gchar *name, const gchar *display_name)
{
@@ -32,7 +31,6 @@ unit_category_new(const gchar *name, const gchar *display_name)
return category;
}
-
const gchar *
unit_category_get_name(UnitCategory *category)
{
@@ -40,7 +38,6 @@ unit_category_get_name(UnitCategory *category)
return category->priv->name;
}
-
const gchar *
unit_category_get_display_name(UnitCategory *category)
{
@@ -48,7 +45,6 @@ unit_category_get_display_name(UnitCategory *category)
return category->priv->display_name;
}
-
void
unit_category_add_unit(UnitCategory *category, Unit *unit)
{
@@ -57,7 +53,6 @@ unit_category_add_unit(UnitCategory *category, Unit *unit)
category->priv->units = g_list_append(category->priv->units, g_object_ref(unit));
}
-
Unit *
unit_category_get_unit_by_name(UnitCategory *category, const gchar *name)
{
@@ -76,7 +71,6 @@ unit_category_get_unit_by_name(UnitCategory *category, const gchar *name)
return NULL;
}
-
Unit *
unit_category_get_unit_by_symbol(UnitCategory *category, const gchar *symbol)
{
@@ -94,7 +88,6 @@ unit_category_get_unit_by_symbol(UnitCategory *category, const gchar *symbol)
return NULL;
}
-
const GList *
unit_category_get_units(UnitCategory *category)
{
@@ -102,9 +95,8 @@ unit_category_get_units(UnitCategory *category)
return category->priv->units;
}
-
gboolean
-unit_category_convert(UnitCategory *category, const MPNumber *x, Unit *x_units, Unit *z_units, MPNumber *z)
+unit_category_convert(const UnitCategory *category, const MPNumber *x, Unit *x_units, Unit *z_units, MPNumber *z)
{
g_return_val_if_fail (category != NULL, FALSE);
g_return_val_if_fail (x_units != NULL, FALSE);
@@ -126,13 +118,11 @@ unit_category_convert(UnitCategory *category, const MPNumber *x, Unit *x_units,
return TRUE;
}
-
static void
unit_category_class_init(UnitCategoryClass *klass)
{
}
-
static void
unit_category_init(UnitCategory *category)
{
diff --git a/src/unit-category.h b/src/unit-category.h
index c5e699c..76c375b 100644
--- a/src/unit-category.h
+++ b/src/unit-category.h
@@ -49,7 +49,7 @@ void unit_category_add_unit(UnitCategory *category, Unit *unit);
const GList *unit_category_get_units(UnitCategory *category);
-gboolean unit_category_convert(UnitCategory *category, const MPNumber *x, Unit *x_units, Unit *z_units, MPNumber *z);
+gboolean unit_category_convert(const UnitCategory *category, const MPNumber *x, Unit *x_units, Unit *z_units, MPNumber *z);
G_END_DECLS
diff --git a/src/unit-manager.c b/src/unit-manager.c
index cb81045..91ec8b6 100644
--- a/src/unit-manager.c
+++ b/src/unit-manager.c
@@ -22,17 +22,14 @@ struct UnitManagerPrivate
G_DEFINE_TYPE_WITH_PRIVATE (UnitManager, unit_manager, G_TYPE_OBJECT);
-
static UnitManager *default_unit_manager = NULL;
-
static gint
compare_currencies(gconstpointer a, gconstpointer b)
{
return strcmp(currency_get_display_name((Currency *)a), currency_get_display_name((Currency *)b));
}
-
UnitManager *
unit_manager_get_default(void)
{
@@ -145,7 +142,6 @@ unit_manager_get_default(void)
return default_unit_manager;
}
-
UnitCategory *
unit_manager_add_category(UnitManager *manager, const gchar *name, const gchar *display_name)
{
@@ -162,7 +158,6 @@ unit_manager_add_category(UnitManager *manager, const gchar *name, const gchar *
return category;
}
-
const GList *
unit_manager_get_categories(UnitManager *manager)
{
@@ -170,7 +165,6 @@ unit_manager_get_categories(UnitManager *manager)
return manager->priv->categories;
}
-
UnitCategory *
unit_manager_get_category(UnitManager *manager, const gchar *category)
{
@@ -188,7 +182,6 @@ unit_manager_get_category(UnitManager *manager, const gchar *category)
return NULL;
}
-
Unit *
unit_manager_get_unit_by_name(UnitManager *manager, const gchar *name)
{
@@ -208,7 +201,6 @@ unit_manager_get_unit_by_name(UnitManager *manager, const gchar *name)
return NULL;
}
-
Unit *
unit_manager_get_unit_by_symbol(UnitManager *manager, const gchar *symbol)
{
@@ -228,7 +220,6 @@ unit_manager_get_unit_by_symbol(UnitManager *manager, const gchar *symbol)
return NULL;
}
-
gboolean
unit_manager_convert_by_symbol(UnitManager *manager, const MPNumber *x, const char *x_symbol, const char *z_symbol, MPNumber *z)
{
@@ -253,13 +244,11 @@ unit_manager_convert_by_symbol(UnitManager *manager, const MPNumber *x, const ch
return FALSE;
}
-
static void
unit_manager_class_init(UnitManagerClass *klass)
{
}
-
static void
unit_manager_init(UnitManager *manager)
{
diff --git a/src/unit.c b/src/unit.c
index 8f33a10..35dcca5 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -29,7 +29,6 @@ struct UnitPrivate
G_DEFINE_TYPE_WITH_PRIVATE (Unit, unit, G_TYPE_OBJECT);
-
Unit *
unit_new(const gchar *name,
const gchar *display_name,
@@ -49,13 +48,12 @@ unit_new(const gchar *name,
unit->priv->to_function = g_strdup(to_function);
symbol_names = g_strsplit(symbols, ",", 0);
for (i = 0; symbol_names[i]; i++)
- unit->priv->symbols = g_list_append(unit->priv->symbols, g_strdup(symbol_names[i]));
+ unit->priv->symbols = g_list_append(unit->priv->symbols, symbol_names[i]);
g_free(symbol_names);
return unit;
}
-
const gchar *
unit_get_name(Unit *unit)
{
@@ -63,7 +61,6 @@ unit_get_name(Unit *unit)
return unit->priv->name;
}
-
const gchar *
unit_get_display_name(Unit *unit)
{
@@ -71,7 +68,6 @@ unit_get_display_name(Unit *unit)
return unit->priv->display_name;
}
-
gboolean
unit_matches_symbol(Unit *unit, const gchar *symbol)
{
@@ -89,7 +85,6 @@ unit_matches_symbol(Unit *unit, const gchar *symbol)
return FALSE;
}
-
const GList *
unit_get_symbols(Unit *unit)
{
@@ -97,14 +92,12 @@ unit_get_symbols(Unit *unit)
return unit->priv->symbols;
}
-
static int
variable_is_defined(const char *name, void *data)
{
return TRUE;
}
-
static int
get_variable(const char *name, MPNumber *z, void *data)
{
@@ -113,7 +106,6 @@ get_variable(const char *name, MPNumber *z, void *data)
return TRUE;
}
-
static gboolean
solve_function(const gchar *function, const MPNumber *x, MPNumber *z)
{
@@ -135,7 +127,6 @@ solve_function(const gchar *function, const MPNumber *x, MPNumber *z)
return TRUE;
}
-
gboolean
unit_convert_from(Unit *unit, const MPNumber *x, MPNumber *z)
{
@@ -157,7 +148,6 @@ unit_convert_from(Unit *unit, const MPNumber *x, MPNumber *z)
}
}
-
gboolean
unit_convert_to(Unit *unit, const MPNumber *x, MPNumber *z)
{
@@ -179,7 +169,6 @@ unit_convert_to(Unit *unit, const MPNumber *x, MPNumber *z)
}
}
-
gchar *
unit_format(Unit *unit, MPNumber *x)
{
@@ -195,13 +184,11 @@ unit_format(Unit *unit, MPNumber *x)
return text;
}
-
static void
unit_class_init(UnitClass *klass)
{
}
-
static void
unit_init(Unit *unit)
{
diff --git a/src/unittest.c b/src/unittest.c
deleted file mode 100644
index 5039115..0000000
--- a/src/unittest.c
+++ /dev/null
@@ -1,766 +0,0 @@
-/* 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
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include "unittest.h"
-#include "mp-equation.h"
-
-static MPEquationOptions options;
-
-static int fails = 0;
-
-/* If we're not using GNU C, elide __attribute__ */
-#ifndef __GNUC__
- #define __attribute__(x) /*NOTHING*/
-#endif
-
-static void pass(const char* format, ...) __attribute__((format(printf, 1, 2)));
-static void fail(const char* format, ...) __attribute__((format(printf, 1, 2)));
-
-static void pass(const char* format, ...)
-{
- va_list args;
-
- printf(" PASS: ");
- va_start(args, format);
- vprintf(format, args);
- va_end(args);
- printf("\n");
-}
-
-static void fail(const char* format, ...)
-{
- va_list args;
-
- printf("*FAIL: ");
- va_start(args, format);
- vprintf(format, args);
- va_end(args);
- printf("\n");
- fails++;
-}
-
-
-static const char* error_code_to_string(MPErrorCode error)
-{
- static char error_string[1024];
-
- if (error != PARSER_ERR_MP)
- {
- return mp_error_code_to_string(error);
- }
-
- snprintf(error_string, 1024, "PARSER_ERR_MP(\"%s\")", mp_get_error());
- return error_string;
-}
-
-
-static void test(char* expression, char* expected, int expected_error)
-{
- MPErrorCode error;
- MPNumber result = mp_new();
- char result_str[1024] = "";
-
- error = mp_equation_parse(expression, &options, &result, NULL);
-
- if (error == 0)
- {
- mp_cast_to_string(&result, options.base, options.base, 9, 1, result_str, 1024);
-
- if (expected_error != 0)
- {
- fail("'%s' -> %s, expected error %s", expression, result_str, error_code_to_string(expected_error));
- }
- else if(strcmp(result_str, expected) != 0)
- {
- fail("'%s' -> '%s', expected '%s'", expression, result_str, expected);
- }
- else
- {
- pass("'%s' -> '%s'", expression, result_str);
- }
- }
- else
- {
- if (error == expected_error)
- {
- pass("'%s' -> error %s", expression, error_code_to_string(error));
- }
- else
- {
- fail("'%s' -> error %s, expected error %s", expression, error_code_to_string(error), error_code_to_string(expected_error));
- }
- }
- mp_clear(result);
-}
-
-
-static void test_conversions()
-{
- memset(&options, 0, sizeof(options));
- options.base = 10;
- options.wordlen = 32;
- options.angle_units = MP_DEGREES;
-
- /* Length */
- test("1 meter in mm", "1000", 0);
- test("1m in mm", "1000", 0);
- test("1 inch in cm", "2.54", 0);
-
- /* Area */
- test("1m² in mm²", "1000000", 0);
-
- /* Volume */
- test("1m³ in mm³", "1000000000", 0);
-
- /* Weight */
- test("1 kg in pounds", "2.204622622", 0);
-
- /* Time */
- test("1 minute in seconds", "60", 0);
-}
-
-
-static int variable_is_defined(const char* name, void* data)
-{
- return strcmp (name, "x") == 0 || strcmp (name, "y") == 0;
-}
-
-
-static int get_variable(const char* name, MPNumber* z, void* data)
-{
- if (strcmp (name, "x") == 0)
- {
- mp_set_from_integer (2, z);
- return 1;
- }
-
- if (strcmp (name, "y") == 0)
- {
- mp_set_from_integer (3, z);
- return 1;
- }
-
- return 0;
-}
-
-
-static void set_variable(const char* name, const MPNumber* x, void* data)
-{
- /* nothing */
-}
-
-static void test_equations()
-{
- memset(&options, 0, sizeof(options));
- options.base = 10;
- options.wordlen = 32;
- options.angle_units = MP_DEGREES;
- options.variable_is_defined = variable_is_defined;
- options.get_variable = get_variable;
- options.set_variable = set_variable;
-
- options.base = 2;
- test("2₁₀", "10", 0);
-
- options.base = 8;
- test("16434824₁₀", "76543210", 0);
-
- options.base = 16;
- test("FF", "FF", 0);
- test("18364758544493064720₁₀", "FEDCBA9876543210", 0);
-
- options.base = 10;
- test("0₂", "0", 0); test("0₈", "0", 0); test("0", "0", 0); test("0₁₆", "0", 0);
- test("1₂", "1", 0); test("1₈", "1", 0); test("1", "1", 0); test("1₁₆", "1", 0);
- test("2₂", "", PARSER_ERR_INVALID); test("2₈", "2", 0); test("2", "2", 0); test("2₁₆", "2", 0);
- test("3₂", "", PARSER_ERR_INVALID); test("3₈", "3", 0); test("3", "3", 0); test("3₁₆", "3", 0);
- test("4₂", "", PARSER_ERR_INVALID); test("4₈", "4", 0); test("4", "4", 0); test("4₁₆", "4", 0);
- test("5₂", "", PARSER_ERR_INVALID); test("5₈", "5", 0); test("5", "5", 0); test("5₁₆", "5", 0);
- test("6₂", "", PARSER_ERR_INVALID); test("6₈", "6", 0); test("6", "6", 0); test("6₁₆", "6", 0);
- test("7₂", "", PARSER_ERR_INVALID); test("7₈", "7", 0); test("7", "7", 0); test("7₁₆", "7", 0);
- test("8₂", "", PARSER_ERR_INVALID); test("8₈", "", PARSER_ERR_INVALID); test("8", "8", 0); test("8₁₆", "8", 0);
- test("9₂", "", PARSER_ERR_INVALID); test("9₈", "", PARSER_ERR_INVALID); test("9", "9", 0); test("9₁₆", "9", 0);
- test("A₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("A₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("A", "", PARSER_ERR_UNKNOWN_VARIABLE); test("A₁₆", "10", 0);
- test("B₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("B₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("B", "", PARSER_ERR_UNKNOWN_VARIABLE); test("B₁₆", "11", 0);
- test("C₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("C₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("C", "", PARSER_ERR_UNKNOWN_VARIABLE); test("C₁₆", "12", 0);
- test("D₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("D₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("D", "", PARSER_ERR_UNKNOWN_VARIABLE); test("D₁₆", "13", 0);
- test("E₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("E₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("E", "", PARSER_ERR_UNKNOWN_VARIABLE); test("E₁₆", "14", 0);
- test("F₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("F₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("F", "", PARSER_ERR_UNKNOWN_VARIABLE); test("F₁₆", "15", 0);
- test("a₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("a₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("a", "", PARSER_ERR_UNKNOWN_VARIABLE); test("a₁₆", "10", 0);
- test("b₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("b₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("b", "", PARSER_ERR_UNKNOWN_VARIABLE); test("b₁₆", "11", 0);
- test("c₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("c₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("c", "", PARSER_ERR_UNKNOWN_VARIABLE); test("c₁₆", "12", 0);
- test("d₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("d₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("d", "", PARSER_ERR_UNKNOWN_VARIABLE); test("d₁₆", "13", 0);
- test("e₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("e₈", "", PARSER_ERR_UNKNOWN_VARIABLE); /* e is a built-in variable */ test("e₁₆", "14", 0);
- test("f₂", "", PARSER_ERR_UNKNOWN_VARIABLE); test("f₈", "", PARSER_ERR_UNKNOWN_VARIABLE); test("f", "", PARSER_ERR_UNKNOWN_VARIABLE); test("f₁₆", "15", 0);
-
- test("+1", "1", 0);
- test("−1", "−1", 0);
- test("+ 1", "1", 0); // FIXME: Should this be allowed?
- test("− 1", "−1", 0); // FIXME: Should this be allowed?
- test("++1", "1", PARSER_ERR_INVALID);
- test("−−1", "1", 0);
- test("255", "255", 0);
- test("256", "256", 0);
- test("½", "0.5", 0);
- test("1½", "1.5", 0);
- test("0°", "0", 0);
- test("1°", "1", 0);
- test("0°30'", "0.5", 0);
- //test("0°0.1'", "1", 0); // FIXME: Not yet supported
- test("0°0'1\"", "0.000277778", 0);
- test("0°0'0.1\"", "0.000027778", 0);
- test("1.00", "1", 0);
- test("1.01", "1.01", 0);
-
- test("١٢٣٤٥٦٧٨٩٠", "1234567890", 0);
- test("۱۲۳۴۵۶۷۸۹۰", "1234567890", 0);
-
-/*
- //test("2A", "2000000000000000", 0);
- test("2T", "2000000000000", 0);
- test("2G", "2000000000", 0);
- test("2M", "2000000", 0);
- test("2k", "2000", 0);
- test("2c", "0.02", 0);
- test("2d", "0.2", 0);
- test("2c", "0.02", 0);
- test("2m", "0.002", 0);
- test("2u", "0.000002", 0);
- test("2µ", "0.000002", 0);
- test("2n", "0.000000002", 0);
- //test("2p", "0.000000000002", 0); // FIXME: Need to print out significant figures, not decimal places
- //test("2f", "0.000000000000002", 0); // FIXME: Need to print out significant figures, not decimal places
- //test("2A3", "2300000000000000", 0);
- test("2T3", "2300000000000", 0);
- test("2G3", "2300000000", 0);
- test("2M3", "2300000", 0);
- test("2k3", "2300", 0);
- test("2c3", "0.023", 0);
- test("2d3", "0.23", 0);
- test("2c3", "0.023", 0);
- test("2m3", "0.0023", 0);
- test("2u3", "0.0000023", 0);
- test("2µ3", "0.0000023", 0);
- //test("2n3", "0.0000000023", 0); // FIXME: Need to print out significant figures, not decimal places
- //test("2p3", "0.0000000000023", 0); // FIXME: Need to print out significant figures, not decimal places
- //test("2f3", "0.0000000000000023", 0); // FIXME: Need to print out significant figures, not decimal places
-*/
-
- test("2×10^3", "2000", 0);
- test("2×10^−3", "0.002", 0);
-
- test("x", "2", 0);
- test("y", "3", 0);
- test("z", "", PARSER_ERR_UNKNOWN_VARIABLE);
- test("2y", "6", 0);
- test("y2", "", PARSER_ERR_INVALID);
- test("y 2", "", PARSER_ERR_INVALID);
- test("2z", "", PARSER_ERR_UNKNOWN_VARIABLE);
- test("z2", "", PARSER_ERR_UNKNOWN_VARIABLE);
- test("z 2", "", PARSER_ERR_UNKNOWN_VARIABLE);
- test("z(2)", "", PARSER_ERR_UNKNOWN_VARIABLE);
- test("y²", "9", 0);
- test("2y²", "18", 0);
- test("x×y", "6", 0);
- test("xy", "6", 0);
- test("yx", "6", 0);
- test("2xy", "12", 0);
- test("x²y", "12", 0);
- test("xy²", "18", 0);
- test("(xy)²", "36", 0);
- test("2x²y", "24", 0);
- test("2xy²", "36", 0);
- test("2x²y²", "72", 0);
- test("x²yx²y", "144", 0);
- test("x³+2x²−5", "11", 0);
- test("2(x+3y)", "22", 0);
- test("x(x+3y)", "22", 0);
- test("(x+3y)(2x-4y)", "−88", 0);
- test("2x²+2xy−12y²", "−88", 0);
-
- test("π", "3.141592654", 0);
- test("e", "2.718281828", 0);
-
- test("z=99", "99", 0);
- test("longname=99", "99", 0);
- //test("e=99", "", PARSER_ERR_BUILTIN_VARIABLE);
-
- test("0+0", "0", 0);
- test("1+1", "2", 0);
- test("1+4", "5", 0);
- test("4+1", "5", 0);
- test("40000+0.001", "40000.001", 0);
- test("0.001+40000", "40000.001", 0);
- test("2-3", "−1", 0);
- test("2−3", "−1", 0);
- test("3−2", "1", 0);
- test("40000−0.001", "39999.999", 0);
- test("0.001−40000", "−39999.999", 0);
- test("2*3", "6", 0);
- test("2×3", "6", 0);
- test("−2×3", "−6", 0);
- test("2×−3", "−6", 0);
- test("−2×−3", "6", 0);
- test("6/3", "2", 0);
- test("6÷3", "2", 0);
- test("1÷2", "0.5", 0);
- test("−6÷3", "−2", 0);
- test("6÷−3", "−2", 0);
- test("−6÷−3", "2", 0);
- test("(−3)÷(−6)", "0.5", 0);
- test("2÷2", "1", 0);
- test("1203÷1", "1203", 0);
- test("−0÷32352.689", "0", 0);
- test("1÷4", "0.25", 0);
- test("1÷3", "0.333333333", 0);
- test("2÷3", "0.666666667", 0);
- test("1÷0", "", PARSER_ERR_MP);
- test("0÷0", "", PARSER_ERR_MP);
-
- /* Precision */
- test("1000000000000000−1000000000000000", "0", 0);
- test("1000000000000000÷1000000000000000", "1", 0);
- test("1000000000000000×0.000000000000001", "1", 0);
-
- /* Order of operations */
- test("1−0.9−0.1", "0", 0);
- test("1+2×3", "7", 0);
- 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);
- test("100+1%", "101", 0);
- test("100−1%", "99", 0);
- test("100×1%", "1", 0);
- test("100÷1%", "10000", 0);
-
- /* Factorial */
- test("0!", "1", 0);
- test("1!", "1", 0);
- test("5!", "120", 0);
- test("69!", "171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000", 0);
- test("0.1!", "", PARSER_ERR_MP);
- test("−1!", "−1", 0);
- test("(−1)!", "", PARSER_ERR_MP);
- test("−(1!)", "−1", 0);
-
- /* Powers */
- test("2²", "4", 0);
- test("2³", "8", 0);
- test("2¹⁰", "1024", 0);
- test("(1+2)²", "9", 0);
- test("(x)²", "4", 0);
- test("|1−3|²", "4", 0);
- test("|x|²", "4", 0);
- test("0^0", "1", 0);
- test("2^0", "1", 0);
- test("2^1", "2", 0);
- test("2^2", "4", 0);
- test("2⁻¹", "0.5", 0);
- //test("2⁻", "", PARSER_ERR_MP); // FIXME: Maybe an error in bison?
- test("2^−1", "0.5", 0);
- test("2^(−1)", "0.5", 0);
- test("x⁻¹", "0.5", 0);
- test("−10^2", "−100", 0);
- test("(−10)^2", "100", 0);
- test("−(10^2)", "−100", 0);
- test("2^100", "1267650600228229401496703205376", 0);
- test("4^3^2", "262144", 0);
- test("4^(3^2)", "262144", 0);
- test("(4^3)^2", "4096", 0);
- test("√4", "2", 0);
- test("√4−2", "0", 0);
- test("∛8", "2", 0);
- test("∜16", "2", 0);
- test("₃√8", "2", 0);
- test("₁₀√1024", "2", 0);
- test("√(2+2)", "2", 0);
- test("2√4", "4", 0);
- test("2×√4", "4", 0);
- test("Sqrt(4)", "2", 0);
- test("Sqrt(2)", "1.414213562", 0);
- test("4^0.5", "2", 0);
- test("2^0.5", "1.414213562", 0);
- test("₃√−8", "−2", 0);
- 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("sgn 0", "0", 0);
- test("sgn 3", "1", 0);
- test("sgn −3", "−1", 0);
- test("⌊3⌋", "3", 0);
- test("⌈3⌉", "3", 0);
- test("[3]", "3", 0);
- test("⌊−3⌋", "−3", 0);
- test("⌈−3⌉", "−3", 0);
- test("[−3]", "−3", 0);
- test("⌊3.2⌋", "3", 0);
- test("⌈3.2⌉", "4", 0);
- test("[3.2]", "3", 0);
- test("⌊−3.2⌋", "−4", 0);
- test("⌈−3.2⌉", "−3", 0);
- test("[−3.2]", "−3", 0);
- test("⌊3.5⌋", "3", 0);
- test("⌈3.5⌉", "4", 0);
- test("[3.5]", "4", 0);
- test("⌊−3.5⌋", "−4", 0);
- test("⌈−3.5⌉", "−3", 0);
- test("[−3.5]", "−4", 0);
- test("⌊3.7⌋", "3", 0);
- test("⌈3.7⌉", "4", 0);
- test("[3.7]", "4", 0);
- test("⌊−3.7⌋", "−4", 0);
- test("⌈−3.7⌉", "−3", 0);
- test("[−3.7]", "−4", 0);
- test("{3.2}", "0.2", 0);
- test("{−3.2}", "0.8", 0);
-
- test("|1|", "1", 0);
- test("|−1|", "1", 0);
- test("|3−5|", "2", 0);
- test("|x|", "2", 0);
- test("abs 1", "1", 0);
- test("abs (−1)", "1", 0);
-
- test("log 0", "", PARSER_ERR_MP);
- test("log 1", "0", 0);
- test("log 2", "0.301029996", 0);
- test("log 10", "1", 0);
- test("log₁₀ 10", "1", 0);
- test("log₂ 2", "1", 0);
- test("2 log 2", "0.602059991", 0);
-
- test("ln 0", "", PARSER_ERR_MP);
- test("ln 1", "0", 0);
- test("ln 2", "0.693147181", 0);
- test("ln e", "1", 0);
- test("2 ln 2", "1.386294361", 0);
-
- options.angle_units = MP_DEGREES;
- test("sin 0", "0", 0);
- test("sin 45 − 1÷√2", "0", 0);
- test("sin 20 + sin(−20)", "0", 0);
- test("sin 90", "1", 0);
- 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);
- test("cos 90", "0", 0);
- test("cos 180", "−1", 0);
- test("2 cos 0", "2", 0);
- test("cos²45", "0.5", 0);
-
- test("tan 0", "0", 0);
- test("tan 10 − sin 10÷cos 10", "0", 0);
- test("tan 90", "", PARSER_ERR_MP);
- test("tan 10", "0.176326981", 0);
- test("tan²10", "0.031091204", 0);
-
- test("cos⁻¹ 0", "90", 0);
- test("cos⁻¹ 1", "0", 0);
- test("cos⁻¹ (−1)", "180", 0);
- test("cos⁻¹ (1÷√2)", "45", 0);
-
- test("sin⁻¹ 0", "0", 0);
- test("sin⁻¹ 1", "90", 0);
- test("sin⁻¹ (−1)", "−90", 0);
- test("sin⁻¹ (1÷√2)", "45", 0);
-
- test("cosh 0", "1", 0);
- test("cosh 10 − (e^10 + e^−10)÷2", "0", 0);
-
- test("sinh 0", "0", 0);
- test("sinh 10 − (e^10 − e^−10)÷2", "0", 0);
- test("sinh (−10) + sinh 10", "0", 0);
-
- test("cosh² (−5) − sinh² (−5)", "1", 0);
- test("tanh 0", "0", 0);
- test("tanh 10 − sinh 10 ÷ cosh 10", "0", 0);
-
- test("atanh 0", "0", 0);
- test("atanh (1÷10) − 0.5 ln(11÷9)", "0", 0);
-
- 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);
-
- /* Complex numbers */
- options.angle_units = MP_DEGREES;
- test("i", "i", 0);
- test("−i", "−i", 0);
- test("2i", "2i", 0);
- test("1+i", "1+i", 0);
- test("i+1", "1+i", 0);
- test("1−i", "1−i", 0);
- test("i−1", "−1+i", 0);
- test("i×i", "−1", 0);
- test("i÷i", "1", 0);
- test("1÷i", "−i", 0);
- test("|i|", "1", 0);
- test("|3+4i|", "5", 0);
- test("arg 0", "", PARSER_ERR_MP);
- test("arg 1", "0", 0);
- test("arg (1+i)", "45", 0);
- test("arg i", "90", 0);
- test("arg (−1+i)", "135", 0);
- test("arg −1", "180", 0);
- test("arg (1+−i)", "−45", 0);
- test("arg −i", "−90", 0);
- test("arg (−1−i)", "−135", 0);
- test("i⁻¹", "−i", 0);
- test("√−1", "i", 0);
- test("(−1)^0.5", "i", 0);
- test("√−4", "2i", 0);
- test("e^iπ", "−1", 0);
- test("log (−10) − (1 + πi÷ln(10))", "0", 0);
- test("ln (−e) − (1 + πi)", "0", 0);
- test("sin(iπ÷4) − i×sinh(π÷4)", "0", 0);
- test("cos(iπ÷4) − cosh(π÷4)", "0", 0);
-
- /* Boolean */
- test("0 and 0", "0", 0);
- test("1 and 0", "0", 0);
- test("0 and 1", "0", 0);
- test("1 and 1", "1", 0);
- test("3 and 5", "1", 0);
-
- test("0 or 0", "0", 0);
- test("1 or 0", "1", 0);
- test("0 or 1", "1", 0);
- test("1 or 1", "1", 0);
- test("3 or 5", "7", 0);
-
- test("0 xor 0", "0", 0);
- test("1 xor 0", "1", 0);
- test("0 xor 1", "1", 0);
- test("1 xor 1", "0", 0);
- test("3 xor 5", "6", 0);
-
- options.base = 16;
- test("ones 1", "FFFFFFFE", 0);
- test("ones 7FFFFFFF", "80000000", 0);
- test("twos 1", "FFFFFFFF", 0);
- test("twos 7FFFFFFF", "80000001", 0);
- test("~7A₁₆", "FFFFFF85", 0);
-
- options.base = 2;
- options.wordlen = 4;
- test("1100∧1010", "1000", 0);
- test("1100∨1010", "1110", 0);
- test("1100⊻1010", "110", 0);
- test("1100⊕1010", "110", 0);
- //test("1100⊼1010", "0111", 0);
- //test("1100⊽1010", "0001", 0);
- //options.wordlen = 2;
- //test("¬01₂", "10₂", 0);
- //test("¬¬10₂", "10₂", 0);
-}
-
-
-static void print_number(MPNumber* x)
-{
- mpc_out_str(stdout, 10, 5, x->num, MPC_RNDNN);
-}
-
-static void test_string(const char* number)
-{
- MPNumber t = mp_new();
-
- mp_set_from_string(number, 10, &t);
-
- printf("MPNumber(%s) -> {", number);
- print_number(&t);
- printf("}\n");
- mp_clear(&t);
-}
-
-static void test_integer(int number)
-{
- MPNumber t = mp_new();
-
- mp_set_from_integer(number, &t);
-
- printf("MPNumber(%d) -> {", number);
- print_number(&t);
- printf("}\n");
- mp_clear(&t);
-}
-
-static void test_numbers()
-{
- test_integer(0);
- test_integer(1);
- test_integer(-1);
- test_integer(2);
- 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("16384");
- test_string("16385");
- test_string("268435456");
-
- 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");
-}
-
-
-static void try(const char* string, bool result, bool expected)
-{
- if ((result && !expected) || (!result && expected))
- {
- fail("%s -> %s, expected %s", string, expected ? "true" : "false", result ? "true" : "false");
- }
- else
- {
- pass("%s -> %s", string, result ? "true" : "false");
- }
-}
-
-
-static void test_mp()
-{
- MPNumber zero = mp_new();
- MPNumber one = mp_new();
- MPNumber minus_one = mp_new();
- mp_set_from_integer(0, &zero);
- mp_set_from_integer(1, &one);
- mp_set_from_integer(-1, &minus_one);
-
- try("mp_is_zero(-1)", mp_is_zero(&minus_one), false);
- try("mp_is_zero(0)", mp_is_zero(&zero), true);
- try("mp_is_zero(1)", mp_is_zero(&one), false);
-
- try("mp_is_negative(-1)", mp_is_negative(&minus_one), true);
- try("mp_is_negative(0)", mp_is_negative(&zero), false);
- try("mp_is_negative(1)", mp_is_negative(&one), false);
-
- try("mp_is_integer(-1)", mp_is_integer(&minus_one), true);
- try("mp_is_integer(0)", mp_is_integer(&zero), true);
- try("mp_is_integer(1)", mp_is_integer(&one), true);
-
- try("mp_is_positive_integer(-1)", mp_is_positive_integer(&minus_one), false);
- try("mp_is_positive_integer(0)", mp_is_positive_integer(&zero), true);
- try("mp_is_positive_integer(1)", mp_is_positive_integer(&one), true);
-
- try("mp_is_natural(-1)", mp_is_natural(&minus_one), false);
- try("mp_is_natural(0)", mp_is_natural(&zero), false);
- try("mp_is_natural(1)", mp_is_natural(&one), true);
-
- try("mp_is_complex(-1)", mp_is_complex(&minus_one), false);
- try("mp_is_complex(0)", mp_is_complex(&zero), false);
- try("mp_is_complex(1)", mp_is_complex(&one), false);
-
- try("mp_is_equal(-1, -1)", mp_is_equal(&minus_one, &minus_one), true);
- try("mp_is_equal(-1, 0)", mp_is_equal(&minus_one, &zero), false);
- try("mp_is_equal(-1, 1)", mp_is_equal(&minus_one, &one), false);
- try("mp_is_equal(0, -1)", mp_is_equal(&zero, &minus_one), false);
- try("mp_is_equal(0, 0)", mp_is_equal(&zero, &zero), true);
- try("mp_is_equal(0, 1)", mp_is_equal(&zero, &one), false);
- try("mp_is_equal(1, -1)", mp_is_equal(&one, &minus_one), false);
- try("mp_is_equal(1, 0)", mp_is_equal(&one, &zero), false);
- try("mp_is_equal(1, 1)", mp_is_equal(&one, &one), true);
-
- try("mp_is_greater_than(0, -1)", mp_is_greater_than (&zero, &minus_one), true);
- try("mp_is_greater_than(0, 0)", mp_is_greater_than (&zero, &zero), false);
- try("mp_is_greater_than(0, 1)", mp_is_greater_than (&zero, &one), false);
- try("mp_is_greater_than(1, -1)", mp_is_greater_than (&one, &minus_one), true);
- try("mp_is_greater_than(1, 0)", mp_is_greater_than (&one, &zero), true);
- try("mp_is_greater_than(1, 1)", mp_is_greater_than (&one, &one), false);
- try("mp_is_greater_than(-1, -1)", mp_is_greater_than (&minus_one, &minus_one), false);
- try("mp_is_greater_than(-1, 0)", mp_is_greater_than (&minus_one, &zero), false);
- try("mp_is_greater_than(-1, 1)", mp_is_greater_than (&minus_one, &one), false);
-
- try("mp_is_greater_equal(0, -1)", mp_is_greater_equal (&zero, &minus_one), true);
- try("mp_is_greater_equal(0, 0)", mp_is_greater_equal (&zero, &zero), true);
- try("mp_is_greater_equal(0, 1)", mp_is_greater_equal (&zero, &one), false);
- try("mp_is_greater_equal(1, -1)", mp_is_greater_equal (&one, &minus_one), true);
- try("mp_is_greater_equal(1, 0)", mp_is_greater_equal (&one, &zero), true);
- try("mp_is_greater_equal(1, 1)", mp_is_greater_equal (&one, &one), true);
- try("mp_is_greater_equal(-1, -1)", mp_is_greater_equal (&minus_one, &minus_one), true);
- try("mp_is_greater_equal(-1, 0)", mp_is_greater_equal (&minus_one, &zero), false);
- try("mp_is_greater_equal(-1, 1)", mp_is_greater_equal (&minus_one, &one), false);
-
- try("mp_is_less_than(0, -1)", mp_is_less_than (&zero, &minus_one), false);
- try("mp_is_less_than(0, 0)", mp_is_less_than (&zero, &zero), false);
- try("mp_is_less_than(0, 1)", mp_is_less_than (&zero, &one), true);
- try("mp_is_less_than(1, -1)", mp_is_less_than (&one, &minus_one), false);
- try("mp_is_less_than(1, 0)", mp_is_less_than (&one, &zero), false);
- try("mp_is_less_than(1, 1)", mp_is_less_than (&one, &one), false);
- try("mp_is_less_than(-1, -1)", mp_is_less_than (&minus_one, &minus_one), false);
- try("mp_is_less_than(-1, 0)", mp_is_less_than (&minus_one, &zero), true);
- try("mp_is_less_than(-1, 1)", mp_is_less_than (&minus_one, &one), true);
-
- try("mp_is_less_equal(0, -1)", mp_is_less_equal (&zero, &minus_one), false);
- try("mp_is_less_equal(0, 0)", mp_is_less_equal (&zero, &zero), true);
- try("mp_is_less_equal(0, 1)", mp_is_less_equal (&zero, &one), true);
- try("mp_is_less_equal(1, -1)", mp_is_less_equal (&one, &minus_one), false);
- try("mp_is_less_equal(1, 0)", mp_is_less_equal (&one, &zero), false);
- try("mp_is_less_equal(1, 1)", mp_is_less_equal (&one, &one), true);
- try("mp_is_less_equal(-1, -1)", mp_is_less_equal (&minus_one, &minus_one), true);
- try("mp_is_less_equal(-1, 0)", mp_is_less_equal (&minus_one, &zero), true);
- try("mp_is_less_equal(-1, 1)", mp_is_less_equal (&minus_one, &one), true);
-
- mp_clear(&zero);
- mp_clear(&one);
- mp_clear(&minus_one);
-}
-
-
-void unittest()
-{
- test_mp();
- test_numbers();
- test_conversions();
- test_equations();
- exit(fails > 0 ? 1 : 0);
-}
diff --git a/src/unittest.h b/src/unittest.h
deleted file mode 100644
index 5101b20..0000000
--- a/src/unittest.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* 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
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#ifndef UNITTEST_H
-#define UNITTEST_H
-
-void unittest(void);
-
-#endif /* UNITTEST_H */
diff --git a/src/utility.h b/src/utility.h
index 91745ed..15d40b2 100644
--- a/src/utility.h
+++ b/src/utility.h
@@ -2,6 +2,7 @@
#define UTILITY_H
#include <glib/gi18n.h>
+#include "config.h"
extern GSettings *g_settings_var;