From a600bd1bd7a15059374e6d527b23403a8133b410 Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Wed, 10 Jul 2024 10:11:07 +0000 Subject: Deploy mate-desktop/mate-calc to github.com/mate-desktop/mate-calc.git:gh-pages --- .../0.html | 1467 +++++++ .../1.html | 345 ++ .../10.html | 395 ++ .../11.html | 441 +++ .../12.html | 2519 ++++++++++++ .../13.html | 767 ++++ .../14.html | 357 ++ .../15.html | 329 ++ .../16.html | 349 ++ .../17.html | 319 ++ .../18.html | 345 ++ .../19.html | 349 ++ .../2.html | 923 +++++ .../20.html | 357 ++ .../21.html | 255 ++ .../22.html | 3021 ++++++++++++++ .../23.html | 343 ++ .../24.html | 317 ++ .../25.html | 1095 +++++ .../26.html | 1185 ++++++ .../27.html | 4173 ++++++++++++++++++++ .../28.html | 277 ++ .../29.html | 491 +++ .../3.html | 413 ++ .../30.html | 347 ++ .../31.html | 367 ++ .../32.html | 561 +++ .../33.html | 1001 +++++ .../34.html | 829 ++++ .../35.html | 583 +++ .../36.html | 1681 ++++++++ .../37.html | 639 +++ .../38.html | 933 +++++ .../39.html | 959 +++++ .../4.html | 395 ++ .../40.html | 1507 +++++++ .../41.html | 779 ++++ .../42.html | 2255 +++++++++++ .../43.html | 2749 +++++++++++++ .../44.html | 2203 +++++++++++ .../45.html | 665 ++++ .../46.html | 1813 +++++++++ .../47.html | 693 ++++ .../48.html | 497 +++ .../49.html | 773 ++++ .../5.html | 923 +++++ .../50.html | 633 +++ .../6.html | 493 +++ .../7.html | 333 ++ .../8.html | 1441 +++++++ .../9.html | 423 ++ .../index.html | 523 +++ .../stats.html | 195 + .../style.css | 177 + 54 files changed, 48202 insertions(+) create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/0.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/1.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/10.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/11.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/12.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/13.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/14.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/15.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/16.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/17.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/18.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/19.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/2.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/20.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/21.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/22.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/23.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/24.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/25.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/26.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/27.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/28.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/29.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/3.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/30.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/31.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/32.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/33.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/34.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/35.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/36.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/37.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/38.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/39.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/4.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/40.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/41.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/42.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/43.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/44.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/45.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/46.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/47.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/48.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/49.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/5.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/50.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/6.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/7.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/8.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/9.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/index.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/stats.html create mode 100644 2023-11-25-191150-4354-cppcheck@be25688b3305_master/style.css (limited to '2023-11-25-191150-4354-cppcheck@be25688b3305_master') diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/0.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/0.html new file mode 100644 index 0000000..55b350e --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/0.html @@ -0,0 +1,1467 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/tree.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/parser.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpath.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libxml/xpathInternals.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "currency-manager.h"
+#include "mp.h"
+
+typedef struct {
+    char *short_name;
+    char *symbol;
+    char *long_name;
+} CurrencyInfo;
+static const CurrencyInfo currency_info[] = {
+    {"AED", "إ.د",  N_("UAE Dirham")},
+    {"AUD", "$",    N_("Australian Dollar")},
+    {"BGN", "лв",   N_("Bulgarian Lev")},
+    {"BHD", ".ب.د", N_("Bahraini Dinar")},
+    {"BND", "$",    N_("Brunei Dollar")},
+    {"BRL", "R$",   N_("Brazilian Real")},
+    {"BWP", "P",    N_("Botswana Pula")},
+    {"CAD", "$",    N_("Canadian Dollar")},
+    {"CFA", "Fr",   N_("CFA Franc")},
+    {"CHF", "Fr",   N_("Swiss Franc")},
+    {"CLP", "$",    N_("Chilean Peso")},
+    {"CNY", "元",   N_("Chinese Yuan")},
+    {"COP", "$",    N_("Colombian Peso")},
+    {"CZK", "Kč",   N_("Czech Koruna")},
+    {"DKK", "kr",   N_("Danish Krone")},
+    {"DZD", "ج.د",  N_("Algerian Dinar")},
+    {"EEK", "KR",   N_("Estonian Kroon")},
+    {"EUR", "€",    N_("Euro")},
+    {"GBP", "£",    N_("Pound Sterling")},
+    {"HKD", "$",    N_("Hong Kong Dollar")},
+    {"HRK", "kn",   N_("Croatian Kuna")},
+    {"HUF", "Ft",   N_("Hungarian Forint")},
+    {"IDR", "Rp",   N_("Indonesian Rupiah")},
+    {"ILS", "₪",    N_("Israeli New Shekel")},
+    {"INR", "₹",    N_("Indian Rupee")},
+    {"IRR", "﷼",    N_("Iranian Rial")},
+    {"ISK", "kr",   N_("Icelandic Krona")},
+    {"JPY", "¥",    N_("Japanese Yen")},
+    {"KRW", "₩",    N_("South Korean Won")},
+    {"KWD", "ك.د",  N_("Kuwaiti Dinar")},
+    {"KZT", "₸",    N_("Kazakhstani Tenge")},
+    {"LKR", "Rs",   N_("Sri Lankan Rupee")},
+    {"LTL", "Lt",   N_("Lithuanian Litas")},
+    {"LVL", "Ls",   N_("Latvian Lats")},
+    {"LYD", "د.ل",  N_("Libyan Dinar")},
+    {"MUR", "Rs",   N_("Mauritian Rupee")},
+    {"MXN", "$",    N_("Mexican Peso")},
+    {"MYR", "RM",   N_("Malaysian Ringgit")},
+    {"NOK", "kr",   N_("Norwegian Krone")},
+    {"NPR", "Rs",   N_("Nepalese Rupee")},
+    {"NZD", "$",    N_("New Zealand Dollar")},
+    {"OMR", "ع.ر.", N_("Omani Rial")},
+    {"PEN", "S/.",  N_("Peruvian Nuevo Sol")},
+    {"PHP", "₱",    N_("Philippine Peso")},
+    {"PKR", "Rs",   N_("Pakistani Rupee")},
+    {"PLN", "zł",   N_("Polish Zloty")},
+    {"QAR", "ق.ر",  N_("Qatari Riyal")},
+    {"RON", "L",    N_("New Romanian Leu")},
+    {"RUB", "руб.", N_("Russian Rouble")},
+    {"SAR", "س.ر",  N_("Saudi Riyal")},
+    {"SEK", "kr",   N_("Swedish Krona")},
+    {"SGD", "$",    N_("Singapore Dollar")},
+    {"THB", "฿",    N_("Thai Baht")},
+    {"TND", "ت.د",  N_("Tunisian Dinar")},
+    {"TRY", "TL",   N_("New Turkish Lira")},
+    {"TTD", "$",    N_("T&T Dollar (TTD)")},
+    {"USD", "$",    N_("US Dollar")},
+    {"UYU", "$",    N_("Uruguayan Peso")},
+    {"VEF", "Bs F", N_("Venezuelan Bolívar")},
+    {"ZAR", "R",    N_("South African Rand")},
+    {NULL, NULL}
+};
+
+static gboolean downloading_imf_rates = FALSE, downloading_ecb_rates = FALSE;
+static gboolean loaded_rates = FALSE;
+static gboolean load_rates(CurrencyManager *manager);
+
+struct CurrencyManagerPrivate
+{
+    GList *currencies;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (CurrencyManager, currency_manager, G_TYPE_OBJECT);
+
+enum {
+    UPDATED,
+    LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0, };
+
+static CurrencyManager *default_currency_manager = NULL;
+
+CurrencyManager *
+currency_manager_get_default(void)
+{
+    int i;
+
+    if (default_currency_manager)
+        return default_currency_manager;
+
+    default_currency_manager = g_object_new(currency_manager_get_type(), NULL);
+
+    for (i = 0; currency_info[i].short_name; i++) {
+        Currency *c = currency_new(currency_info[i].short_name,
+                                   _(currency_info[i].long_name),
+                                   currency_info[i].symbol);
+        default_currency_manager->priv->currencies = g_list_append(default_currency_manager->priv->currencies, c);
+    }
+
+    return default_currency_manager;
+}
+
+GList *
+currency_manager_get_currencies(CurrencyManager *manager)
+{
+    g_return_val_if_fail(manager != NULL, NULL);
+    return manager->priv->currencies;
+}
+
+Currency *
+currency_manager_get_currency(CurrencyManager *manager, const gchar *name)
+{
+    g_return_val_if_fail(manager != NULL, NULL);
+    g_return_val_if_fail(name != NULL, NULL);
+
+    GList *link;
+    for (link = manager->priv->currencies; link; link = link->next) {
+        Currency *c = link->data;
+        const MPNumber *value;
+
+        value = currency_get_value(c);
+
+        if (!strcmp(name, currency_get_name(c))) {
+            if (mp_is_negative(value) ||
+                mp_is_zero(value)) {
+                return NULL;
+            }
+            else
+                return c;
+        }
+    }
+    return NULL;
+}
+
+static char *
+get_imf_rate_filepath(void)
+{
+    return g_build_filename(g_get_user_cache_dir (),
+                            "mate-calc",
+                            "rms_five.xls",
+                            NULL);
+}
+
+static char *
+get_ecb_rate_filepath(void)
+{
+    return g_build_filename(g_get_user_cache_dir (),
+                            "mate-calc",
+                            "eurofxref-daily.xml",
+                            NULL);
+}
+
+static Currency *
+add_currency(CurrencyManager *manager, const gchar *short_name)
+{
+    GList *iter;
+    Currency *c;
+
+    for (iter = manager->priv->currencies; iter; iter = iter->next) {
+        c = iter->data;
+        if (strcmp(short_name, currency_get_name(c)) == 0)
+            return c;
+    }
+
+    g_warning("Currency %s is not in the currency table", short_name);
+    c = currency_new(short_name, short_name, short_name);
+    manager->priv->currencies = g_list_append(manager->priv->currencies, c);
+
+    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.
+ */
+static gboolean
+file_needs_update(gchar *filename, double max_age)
+{
+    struct stat buf;
+
+    if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
+        return TRUE;
+
+    if (g_stat(filename, &buf) == -1)
+        return TRUE;
+
+    if (difftime(time(NULL), buf.st_mtime) > max_age)
+        return TRUE;
+
+    return FALSE;
+}
+
+static void
+download_imf_cb(GObject *object, GAsyncResult *result, gpointer user_data)
+{
+    CurrencyManager *manager = user_data;
+    GError *error = NULL;
+
+    if (g_file_copy_finish(G_FILE(object), result, &error))
+        g_debug("IMF rates updated");
+    else
+        g_warning("Couldn't download IMF currency rate file: %s", error->message);
+    g_clear_error(&error);
+    downloading_imf_rates = FALSE;
+    load_rates(manager);
+}
+
+static void
+download_ecb_cb(GObject *object, GAsyncResult *result, gpointer user_data)
+{
+    CurrencyManager *manager = user_data;
+    GError *error = NULL;
+
+    if (g_file_copy_finish(G_FILE(object), result, &error))
+        g_debug("ECB rates updated");
+    else
+        g_warning("Couldn't download ECB currency rate file: %s", error->message);
+    g_clear_error(&error);
+    downloading_ecb_rates = FALSE;
+    load_rates(manager);
+}
+
+static void
+download_file(CurrencyManager *manager, gchar *uri, gchar *filename, GAsyncReadyCallback callback)
+{
+    gchar *directory;
+    GFile *source, *dest;
+
+    directory = g_path_get_dirname(filename);
+    g_mkdir_with_parents(directory, 0755);
+    g_free(directory);
+
+    source = g_file_new_for_uri(uri);
+    dest = g_file_new_for_path(filename);
+
+    g_file_copy_async(source, dest, G_FILE_COPY_OVERWRITE, G_PRIORITY_DEFAULT, NULL, NULL, NULL, callback, manager);
+    g_object_unref(source);
+    g_object_unref(dest);
+}
+
+static void
+load_imf_rates(CurrencyManager *manager)
+{
+    gchar *filename;
+    gchar *data, **lines;
+    gsize length;
+    GError *error = NULL;
+    int i;
+    gboolean result, in_data = FALSE;
+    struct
+    {
+        const gchar *name, *symbol;
+    } name_map[] =
+    {
+        {"Algerian dinar",	"DZD"},
+        {"Australian dollar",   "AUD"},
+        {"Bahrain Dinar",	"BHD"},
+        {"Bolivar Fuerte",	"VEF"},
+        {"Botswana pula",	"BWP"},
+        {"Brazilian real",	"BRL"},
+        {"Brunei dollar",	"BND"},
+        {"Canadian dollar",     "CAD"},
+        {"Chilean peso",        "CLP"},
+        {"Chinese yuan",        "CNY"},
+        {"Colombian peso",	"COP"},
+        {"Czech koruna",        "CZK"},
+        {"Danish krone",        "DKK"},
+        {"Euro",                "EUR"},
+        {"Hungarian Forint",    "HUF"},
+        {"Icelandic Krona",     "ISK"},
+        {"Indian rupee",        "INR"},
+        {"Indonesian Rupiah",   "IDR"},
+        {"Iranian Rial",        "IRR"},
+        {"Israeli New Shekel",  "ILS"},
+        {"Japanese yen",        "JPY"},
+        {"Kazakhstani Tenge",   "KZT"},
+        {"Korean won",          "KRW"},
+        {"Kuwaiti dinar",	"KWD"},
+        {"Libyan Dinar",        "LYD"},
+        {"Malaysian ringgit",   "MYR"},
+        {"Mauritian rupee",     "MUR"},
+        {"Mexican peso",        "MXN"},
+        {"Nepalese Rupee",	"NPR"},
+        {"New Zealand dollar",  "NZD"},
+        {"Norwegian krone",     "NOK"},
+        {"Nuevo Sol",           "PEN"},
+        {"Omani rial",		"OMR"},
+        {"Pakistani Rupee",     "PKR"},
+        {"Peruvian sol",	"PEN"},
+        {"Philippine peso",     "PHP"},
+        {"Polish zloty",        "PLN"},
+        {"Qatari riyal",        "QAR"},
+        {"Rial Omani",          "OMR"},
+        {"Russian ruble",	"RUB"},
+        {"Saudi Arabian riyal", "SAR"},
+        {"Singapore dollar",    "SGD"},
+        {"South African rand",  "ZAR"},
+        {"Sri Lanka Rupee",     "LKR"},
+        {"Swedish krona",	"SEK"},
+        {"Swiss franc",         "CHF"},
+        {"Thai baht",           "THB"},
+        {"Trinidadian dollar",  "TTD"},
+        {"Tunisian Dinar",	"TND"},
+        {"U.A.E. dirham",	"AED"},
+        {"U.K. pound",          "GBP"},
+        {"Uruguayan peso",	"UYU"},
+        {"U.S. dollar",         "USD"},
+        {NULL, NULL}
+    };
+
+    filename = get_imf_rate_filepath();
+    result = g_file_get_contents(filename, &data, &length, &error);
+    g_free(filename);
+    if (!result)
+    {
+        g_warning("Failed to read exchange rates: %s", error->message);
+        g_clear_error(&error);
+        return;
+    }
+
+    lines = g_strsplit(data, "\n", 0);
+    g_free(data);
+
+    for (i = 0; lines[i]; i++) {
+        gchar *line, **tokens;
+
+        line = g_strchug(lines[i]);
+
+        /* Start after first blank line, stop on next */
+        if (line[0] == '\0') {
+            if (!in_data) {
+               in_data = TRUE;
+               continue;
+            }
+            else
+               break;
+        }
+        if (!in_data)
+            continue;
+
+        tokens = g_strsplit(line, "\t", 0);
+        if (strcmp(tokens[0], "Currency") != 0) {
+            gint value_index, name_index;
+
+            for (value_index = 1; tokens[value_index]; value_index++) {
+                gchar *value = g_strchug (tokens[value_index]);<--- Variable 'value' can be declared as pointer to const
+                if (value[0] != '\0')
+                    break;
+            }
+            if (tokens[value_index]) {
+                for (name_index = 0; name_map[name_index].name; name_index++) {
+                    if (strcmp(name_map[name_index].name, tokens[0]) == 0)
+                        break;
+                }
+                if (name_map[name_index].name) {
+                    Currency *c = currency_manager_get_currency(manager, name_map[name_index].symbol);
+                    MPNumber value = mp_new();
+
+                    if (!c) {
+                        g_debug ("Using IMF rate of %s for %s", tokens[value_index], name_map[name_index].symbol);
+                        c = add_currency(manager, name_map[name_index].symbol);
+                    }
+                    mp_set_from_string(tokens[value_index], 10, &value);
+                    mp_reciprocal(&value, &value);
+                    currency_set_value(c, &value);
+                    mp_clear(&value);
+                }
+                else
+                    g_warning("Unknown currency '%s'", tokens[0]);
+            }
+        }
+        g_strfreev(tokens);
+    }
+    g_strfreev(lines);
+}
+
+static void
+set_ecb_rate(CurrencyManager *manager, xmlNodePtr node, Currency *eur_rate)
+{
+    xmlAttrPtr attribute;
+    gchar *name = NULL, *value = NULL;
+
+    for (attribute = node->properties; attribute; attribute = attribute->next) {
+        if (strcmp((char *)attribute->name, "currency") == 0) {
+            if (name)
+                xmlFree(name);
+            name = (gchar *)xmlNodeGetContent((xmlNodePtr)attribute);
+        } else if (strcmp ((char *)attribute->name, "rate") == 0) {
+            if (value)
+                xmlFree(value);
+            value = (gchar *)xmlNodeGetContent((xmlNodePtr)attribute);
+        }
+    }
+
+    /* Use data if value and no rate currently defined */
+    if (name && value && !currency_manager_get_currency(manager, name)) {
+        Currency *c;
+        MPNumber r = mp_new();
+        MPNumber v = mp_new();
+
+        g_debug ("Using ECB rate of %s for %s", value, name);
+        c = add_currency(manager, name);
+        mp_set_from_string(value, 10, &r);
+        mp_set_from_mp(currency_get_value(eur_rate), &v);
+        mp_multiply(&v, &r, &v);
+        currency_set_value(c, &v);
+        mp_clear(&r);
+        mp_clear(&v);
+    }
+
+    if (name)
+        xmlFree(name);
+    if (value)
+        xmlFree(value);
+}
+
+static void
+set_ecb_fixed_rate(CurrencyManager *manager, const gchar *name, const gchar *value, Currency *eur_rate)
+{
+    Currency *c;
+    MPNumber r = mp_new();
+    MPNumber v = mp_new();
+
+    g_debug ("Using ECB fixed rate of %s for %s", value, name);
+    c = add_currency(manager, name);
+    mp_set_from_string(value, 10, &r);
+    mp_set_from_mp(currency_get_value(eur_rate), &v);
+    mp_divide(&v, &r, &v);
+    currency_set_value(c, &v);
+    mp_clear(&r);
+    mp_clear(&v);
+}
+
+static void
+load_ecb_rates(CurrencyManager *manager)
+{
+    Currency *eur_rate;
+    char *filename;
+    xmlDocPtr document;
+    xmlXPathContextPtr xpath_ctx;
+    xmlXPathObjectPtr xpath_obj;
+    int i, len;
+
+    /* Scale rates to the EUR value */
+    eur_rate = currency_manager_get_currency(manager, "EUR");
+    if (!eur_rate) {
+        g_warning("Cannot use ECB rates as don't have EUR rate");
+        return;
+    }
+
+    /* Set some fixed rates */
+    set_ecb_fixed_rate(manager, "EEK", "0.06391", eur_rate);
+    set_ecb_fixed_rate(manager, "CFA", "0.152449", eur_rate);
+
+    xmlInitParser();
+    filename = get_ecb_rate_filepath();
+    document = xmlReadFile(filename, NULL, 0);
+    if (!document)
+        g_warning("Couldn't parse ECB rate file %s", filename);
+    g_free (filename);
+    if (!document)
+        return;
+
+    xpath_ctx = xmlXPathNewContext(document);
+    if (xpath_ctx == NULL) {
+        xmlFreeDoc(document);
+        g_warning("Couldn't create XPath context");
+        return;
+    }
+
+    xmlXPathRegisterNs(xpath_ctx,
+                       BAD_CAST("xref"),
+                       BAD_CAST("http://www.ecb.int/vocabulary/2002-08-01/eurofxref"));
+    xpath_obj = xmlXPathEvalExpression(BAD_CAST("//xref:Cube[@currency][@rate]"),
+                                       xpath_ctx);
+    if (xpath_obj == NULL) {
+        xmlXPathFreeContext(xpath_ctx);
+        xmlFreeDoc(document);
+        g_warning("Couldn't create XPath object");
+        return;
+    }
+    len = (xpath_obj->nodesetval) ? xpath_obj->nodesetval->nodeNr : 0;
+    for (i = 0; i < len; i++) {
+        if (xpath_obj->nodesetval->nodeTab[i]->type == XML_ELEMENT_NODE)
+            set_ecb_rate(manager, xpath_obj->nodesetval->nodeTab[i], eur_rate);
+
+        /* Avoid accessing removed elements */
+        if (xpath_obj->nodesetval->nodeTab[i]->type != XML_NAMESPACE_DECL)
+            xpath_obj->nodesetval->nodeTab[i] = NULL;
+    }
+
+    xmlXPathFreeObject(xpath_obj);
+    xmlXPathFreeContext(xpath_ctx);
+    xmlFreeDoc(document);
+    xmlCleanupParser();
+}
+
+static gboolean
+load_rates(CurrencyManager *manager)
+{
+    int i;
+
+    /* Already loaded */
+    if (loaded_rates)
+        return TRUE;
+
+    /* In process */
+    if (downloading_imf_rates || downloading_ecb_rates)
+        return FALSE;
+
+    /* Use the IMF provided values and top up with currencies tracked by the ECB and not the IMF */
+    load_imf_rates(manager);
+    load_ecb_rates(manager);
+
+    for (i = 0; currency_info[i].short_name; i++) {
+       GList *link;
+       for (link = manager->priv->currencies; link; link = link->next) {
+           Currency *c = link->data;
+           if (strcmp(currency_get_name(c), currency_info[i].short_name) == 0)
+              break;
+       }
+       if (!link)
+           g_warning("Currency %s is not provided by IMF or ECB", currency_info[i].short_name);
+    }
+
+    g_debug("Rates loaded");
+    loaded_rates = TRUE;
+
+    g_signal_emit(manager, signals[UPDATED], 0);
+
+    return TRUE;
+}
+
+const MPNumber *
+currency_manager_get_value(CurrencyManager *manager, const gchar *currency)
+{
+    gchar *path;
+    Currency *c;
+
+    g_return_val_if_fail(manager != NULL, NULL);
+    g_return_val_if_fail(currency != NULL, NULL);
+
+    /* Update rates if necessary */
+    path = get_imf_rate_filepath();
+    if (!downloading_imf_rates && file_needs_update(path, 60 * 60 * 24 * 7)) {
+        downloading_imf_rates = TRUE;
+        g_debug("Downloading rates from the IMF...");
+        download_file(manager, "http://www.imf.org/external/np/fin/data/rms_five.aspx?tsvflag=Y", path, download_imf_cb);
+    }
+    g_free(path);
+    path = get_ecb_rate_filepath();
+    if (!downloading_ecb_rates && file_needs_update(path, 60 * 60 * 24 * 7)) {
+        downloading_ecb_rates = TRUE;
+        g_debug("Downloading rates from the ECB...");
+        download_file(manager, "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml", path, download_ecb_cb);
+    }
+    g_free(path);
+
+    if (!load_rates(manager))
+        return NULL;
+
+    c = currency_manager_get_currency(manager, currency);
+    if (c)
+        return currency_get_value(c);
+    else
+        return NULL;
+}
+
+static void
+currency_manager_class_init(CurrencyManagerClass *klass)
+{
+    signals[UPDATED] =
+        g_signal_new("updated",
+                     G_TYPE_FROM_CLASS (klass),
+                     G_SIGNAL_RUN_LAST,
+                     G_STRUCT_OFFSET (CurrencyManagerClass, updated),
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE, 0);
+}
+
+static void
+currency_manager_init(CurrencyManager *manager)
+{
+    manager->priv = currency_manager_get_instance_private (manager);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/1.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/1.html new file mode 100644 index 0000000..7476e26 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/1.html @@ -0,0 +1,345 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef CURRENCY_H
+#define CURRENCY_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "mp.h"
+
+G_BEGIN_DECLS
+
+#define CURRENCY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), currency_get_type(), Currency))
+
+typedef struct CurrencyPrivate CurrencyPrivate;
+
+typedef struct
+{
+    GObject parent_instance;
+    CurrencyPrivate *priv;
+} Currency;
+
+typedef struct
+{
+    GObjectClass parent_class;
+} CurrencyClass;
+
+GType currency_get_type(void);
+
+Currency *currency_new(const gchar *name,
+                       const gchar *display_name,
+                       const gchar *symbol);
+
+const gchar *currency_get_name(Currency *currency);
+
+const gchar *currency_get_short_display_name(Currency *currency);
+
+const gchar *currency_get_display_name(Currency *currency);
+
+const gchar *currency_get_symbol(Currency *currency);
+
+void currency_set_value(Currency *currency, MPNumber *value);
+
+const MPNumber *currency_get_value(Currency *currency);
+
+G_END_DECLS
+
+#endif /* CURRENCY_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/10.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/10.html new file mode 100644 index 0000000..da84e94 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/10.html @@ -0,0 +1,395 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
#ifndef PARSER_H
+#define PARSER_H
+
+#include <lexer.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp-equation.h"
+#include "mp.h"
+
+/* Operator Associativity. */
+typedef enum
+{
+    LEFT_ASSOCIATIVE,
+    RIGHT_ASSOCIATIVE
+} Associativity;
+
+/* Operator Precedence. */
+typedef enum
+{
+    P_Unknown = 0,
+    P_AddSubtract=1,
+    P_Multiply=2,
+    P_Mod=3,
+    P_Divide=4,
+    P_Not=5,
+    P_Root=6,
+    P_Function=7,
+    P_Boolean=8,
+    P_Percentage=9,
+    /* UnaryMinus and Power must have same precedence. */
+    P_UnaryMinus=10,
+    P_Power=10,
+    P_Factorial=11,
+    P_NumberVariable=12,
+    /* P_Depth should be always at the bottom. It stops node jumping off the current depth level. */
+    P_Depth
+} Precedence;
+
+/* ParseNode structure for parse tree. */
+typedef struct parse_node
+{
+    struct parse_node *parent;
+    struct parse_node *left, *right;
+    LexerToken *token;
+    guint precedence;
+    Associativity associativity;
+    void* value;
+    struct parser_state* state;
+    void* (*evaluate) (struct parse_node* self);
+} ParseNode;
+
+/* ParserState structure. Stores parser state. */
+typedef struct parser_state
+{
+    ParseNode *root;
+    ParseNode *right_most;
+    LexerState *lexer;
+    guint depth_level;
+    MPEquationOptions *options;
+    int error;
+    char *error_token;
+    MPNumber ret;
+    int (*variable_is_defined)(struct parser_state *state, const char *name);
+    int (*get_variable)(struct parser_state *state, const char *name, MPNumber *z);
+    void (*set_variable)(struct parser_state *state, const char *name, const MPNumber *x);
+    int (*function_is_defined)(struct parser_state *state, const char *name);
+    int (*get_function)(struct parser_state *state, const char *name, const MPNumber *x, MPNumber *z);
+    int (*convert)(struct parser_state *state, const MPNumber *x, const char *x_units, const char *z_units, MPNumber *z);
+} ParserState;
+
+/* Create ParserState object. */
+ParserState* p_create_parser(const gchar*, MPEquationOptions*);
+
+/* Destroy ParserState object. */
+void p_destroy_parser(ParserState*);
+
+/* Parse string from ParserState. */
+guint p_parse(ParserState*);
+
+#endif /* PARSER_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/11.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/11.html new file mode 100644 index 0000000..a70eeed --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/11.html @@ -0,0 +1,441 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
/*
+ * Copyright (C) 2009 Rich Burridge
+ *
+ * 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp-equation.h"
+#include "mp-serializer.h"
+
+#define MAXLINE 1024
+
+static MpSerializer *result_serializer;
+
+static void
+solve(const char *equation)
+{
+    int ret;
+    MPEquationOptions options;
+    MPNumber z = mp_new();
+    gchar *result_str = NULL;
+
+    memset(&options, 0, sizeof(options));
+    options.base = 10;
+    options.wordlen = 32;
+    options.angle_units = MP_DEGREES;
+
+    ret = mp_equation_parse(equation, &options, &z, NULL);
+
+    if (ret == PARSER_ERR_MP)
+        fprintf(stderr, "Error %s\n", mp_get_error());
+    else if (ret)
+        fprintf(stderr, "Error %d\n", ret);
+    else {
+        result_str = mp_serializer_to_string(result_serializer, &z);
+        printf("%s\n", result_str);
+    }
+    g_free(result_str);
+    mp_clear(&z);
+}
+
+/* Adjust user input equation string before solving it. */
+static void
+str_adjust(char *str)
+{
+    int i, j = 0;
+
+    str[strlen(str)-1] = '\0';        /* Remove newline at end of string. */
+    for (i = 0; str[i] != '\0'; i++) {        /* Remove whitespace. */
+        if (str[i] != ' ' && str[i] != '\t')
+            str[j++] = str[i];
+    }
+    str[j] = '\0';
+    if (j > 0 && str[j-1] == '=')     /* Remove trailing '=' (if present). */
+        str[j-1] = '\0';
+}
+
+int
+main(void)
+{
+    char *equation, *line;
+
+    /* Seed random number generator. */
+    srand48((long) time((time_t *) 0));
+
+    setlocale(LC_ALL, "");
+
+    result_serializer = mp_serializer_new(MP_DISPLAY_FORMAT_AUTOMATIC, 10, 9);
+
+    equation = (char *) malloc(MAXLINE * sizeof(char));
+    while (1) {
+        printf("> ");
+        line = fgets(equation, MAXLINE, stdin);
+
+        if (line != NULL)
+            str_adjust(equation);
+
+        if (line == NULL || strcmp(equation, "exit") == 0 || strcmp(equation, "quit") == 0 || strlen(equation) == 0)
+            break;
+
+        solve(equation);
+    }
+    free(equation);
+
+    return 0;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/12.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/12.html new file mode 100644 index 0000000..f6f73d9 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/12.html @@ -0,0 +1,2519 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
+# define SECTION __attribute__ ((section (".gresource.calculator"), aligned (8)))
+#else
+# define SECTION
+#endif
+
+static const SECTION union { const guint8 data[14931]; const double alignment; void * const ptr;}  calculator_resource_data = { {<--- union member 'Anonymous0::alignment' is never used.<--- union member 'Anonymous0::ptr' is never used.
+  0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0030, 0000, 0000, 0000, 0160, 0001, 0000, 0000, 0000, 0000, 0000, 0050, 0014, 0000, 0000, 0000, 
+  0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 0003, 0000, 0000, 0000, 
+  0004, 0000, 0000, 0000, 0005, 0000, 0000, 0000, 0006, 0000, 0000, 0000, 0007, 0000, 0000, 0000, 
+  0010, 0000, 0000, 0000, 0012, 0000, 0000, 0000, 0012, 0000, 0000, 0000, 0013, 0000, 0000, 0000, 
+  0205, 0246, 0306, 0274, 0003, 0000, 0000, 0000, 0160, 0001, 0000, 0000, 0016, 0000, 0166, 0000, 
+  0200, 0001, 0000, 0000, 0130, 0007, 0000, 0000, 0145, 0112, 0236, 0026, 0003, 0000, 0000, 0000, 
+  0130, 0007, 0000, 0000, 0023, 0000, 0166, 0000, 0160, 0007, 0000, 0000, 0175, 0017, 0000, 0000, 
+  0021, 0233, 0356, 0164, 0003, 0000, 0000, 0000, 0175, 0017, 0000, 0000, 0020, 0000, 0166, 0000, 
+  0220, 0017, 0000, 0000, 0361, 0023, 0000, 0000, 0047, 0275, 0327, 0315, 0012, 0000, 0000, 0000, 
+  0361, 0023, 0000, 0000, 0003, 0000, 0114, 0000, 0364, 0023, 0000, 0000, 0020, 0024, 0000, 0000, 
+  0144, 0005, 0305, 0271, 0003, 0000, 0000, 0000, 0020, 0024, 0000, 0000, 0020, 0000, 0166, 0000, 
+  0040, 0024, 0000, 0000, 0075, 0026, 0000, 0000, 0201, 0321, 0040, 0031, 0007, 0000, 0000, 0000, 
+  0075, 0026, 0000, 0000, 0005, 0000, 0114, 0000, 0104, 0026, 0000, 0000, 0110, 0026, 0000, 0000, 
+  0362, 0233, 0121, 0203, 0003, 0000, 0000, 0000, 0110, 0026, 0000, 0000, 0026, 0000, 0166, 0000, 
+  0140, 0026, 0000, 0000, 0240, 0044, 0000, 0000, 0113, 0120, 0220, 0013, 0010, 0000, 0000, 0000, 
+  0240, 0044, 0000, 0000, 0004, 0000, 0114, 0000, 0244, 0044, 0000, 0000, 0250, 0044, 0000, 0000, 
+  0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 0250, 0044, 0000, 0000, 0001, 0000, 0114, 0000, 
+  0254, 0044, 0000, 0000, 0260, 0044, 0000, 0000, 0224, 0227, 0342, 0142, 0003, 0000, 0000, 0000, 
+  0260, 0044, 0000, 0000, 0024, 0000, 0166, 0000, 0310, 0044, 0000, 0000, 0070, 0067, 0000, 0000, 
+  0372, 0007, 0066, 0115, 0005, 0000, 0000, 0000, 0070, 0067, 0000, 0000, 0013, 0000, 0114, 0000, 
+  0104, 0067, 0000, 0000, 0110, 0067, 0000, 0000, 0367, 0356, 0116, 0135, 0003, 0000, 0000, 0000, 
+  0110, 0067, 0000, 0000, 0017, 0000, 0166, 0000, 0130, 0067, 0000, 0000, 0122, 0072, 0000, 0000, 
+  0160, 0162, 0145, 0146, 0145, 0162, 0145, 0156, 0143, 0145, 0163, 0056, 0165, 0151, 0000, 0000, 
+  0147, 0047, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0132, 0315, 0216, 0333, 0066, 
+  0020, 0276, 0347, 0051, 0130, 0136, 0123, 0305, 0053, 0357, 0306, 0330, 0056, 0154, 0005, 0151, 
+  0212, 0004, 0005, 0202, 0240, 0300, 0246, 0350, 0221, 0240, 0045, 0256, 0315, 0204, 0042, 0125, 
+  0222, 0132, 0257, 0363, 0022, 0075, 0366, 0375, 0372, 0044, 0035, 0122, 0362, 0217, 0144, 0332, 
+  0336, 0365, 0217, 0222, 0024, 0075, 0331, 0242, 0206, 0234, 0031, 0316, 0067, 0177, 0244, 0206, 
+  0257, 0036, 0162, 0201, 0356, 0231, 0066, 0134, 0311, 0021, 0216, 0137, 0134, 0140, 0304, 0144, 
+  0252, 0062, 0056, 0047, 0043, 0374, 0373, 0307, 0267, 0321, 0065, 0176, 0225, 0074, 0033, 0376, 
+  0020, 0105, 0350, 0035, 0223, 0114, 0123, 0313, 0062, 0064, 0343, 0166, 0212, 0046, 0202, 0146, 
+  0014, 0135, 0276, 0350, 0367, 0137, 0304, 0050, 0212, 0200, 0210, 0113, 0313, 0364, 0035, 0115, 
+  0131, 0062, 0324, 0354, 0317, 0222, 0153, 0146, 0220, 0340, 0343, 0021, 0236, 0330, 0317, 0317, 
+  0361, 0212, 0213, 0233, 0203, 0173, 0311, 0120, 0215, 0077, 0261, 0324, 0242, 0124, 0120, 0143, 
+  0106, 0370, 0235, 0375, 0374, 0236, 0033, 0173, 0153, 0225, 0146, 0030, 0361, 0154, 0204, 0251, 
+  0234, 0010, 0106, 0112, 0311, 0055, 0311, 0125, 0306, 0004, 0116, 0206, 0251, 0022, 0145, 0056, 
+  0115, 0342, 0005, 0252, 0036, 0042, 0111, 0163, 0206, 0004, 0035, 0063, 0341, 0304, 0250, 0111, 
+  0220, 0235, 0027, 0014, 0070, 0247, 0123, 0252, 0251, 0326, 0164, 0356, 0030, 0266, 0047, 0271, 
+  0245, 0115, 0140, 0022, 0050, 0342, 0310, 0173, 0113, 0156, 0275, 0112, 0324, 0200, 0310, 0257, 
+  0263, 0117, 0245, 0261, 0071, 0203, 0031, 0136, 0346, 0214, 0245, 0074, 0247, 0202, 0024, 0002, 
+  0366, 0301, 0020, 0272, 0172, 0235, 0014, 0013, 0255, 0012, 0246, 0355, 0034, 0071, 0346, 0043, 
+  0134, 0026, 0360, 0204, 0223, 0370, 0342, 0142, 0330, 0133, 0274, 0332, 0040, 0062, 0226, 0025, 
+  0204, 0313, 0124, 0263, 0152, 0221, 0170, 0007, 0155, 0101, 0047, 0154, 0053, 0355, 0166, 0025, 
+  0176, 0315, 0141, 0136, 0045, 0075, 0167, 0177, 0343, 0115, 0121, 0357, 0271, 0341, 0143, 0301, 
+  0160, 0362, 0121, 0227, 0154, 0207, 0004, 0051, 0225, 0344, 0116, 0245, 0245, 0301, 0311, 0133, 
+  0052, 0314, 0056, 0122, 0236, 0052, 0111, 0334, 0137, 0234, 0314, 0270, 0314, 0324, 0054, 0112, 
+  0205, 0152, 0316, 0330, 0056, 0162, 0013, 0050, 0262, 0314, 0307, 0114, 0003, 0147, 0235, 0323, 
+  0163, 0141, 0245, 0132, 0374, 0070, 0260, 0264, 0304, 0236, 0051, 0235, 0021, 0303, 0277, 0260, 
+  0063, 0211, 0354, 0226, 0176, 0214, 0300, 0031, 0265, 0024, 0134, 0126, 0315, 0074, 0245, 0027, 
+  0015, 0302, 0200, 0325, 0124, 0032, 0001, 0257, 0300, 0360, 0043, 0074, 0147, 0006, 0303, 0342, 
+  0271, 0103, 0026, 0050, 0363, 0007, 0210, 0136, 0255, 0017, 0143, 0143, 0165, 0203, 0256, 0321, 
+  0030, 0174, 0011, 0047, 0327, 0021, 0374, 0372, 0265, 0127, 0213, 0001, 0240, 0256, 0353, 0241, 
+  0236, 0347, 0162, 0034, 0253, 0170, 0120, 0363, 0212, 0007, 0141, 0146, 0361, 0340, 0204, 0334, 
+  0056, 0373, 0065, 0267, 0313, 0176, 0230, 0333, 0145, 0377, 0204, 0334, 0006, 0127, 0065, 0267, 
+  0301, 0125, 0230, 0333, 0340, 0252, 0301, 0255, 0127, 0331, 0156, 0073, 0344, 0176, 0341, 0124, 
+  0250, 0111, 0205, 0267, 0102, 0263, 0073, 0246, 0041, 0274, 0103, 0140, 0312, 0252, 0361, 0143, 
+  0074, 0170, 0014, 0302, 0203, 0327, 0315, 0170, 0146, 0247, 0336, 0302, 0133, 0051, 0055, 0267, 
+  0020, 0074, 0002, 0133, 0221, 0374, 0266, 0022, 0151, 0327, 0174, 0000, 0056, 0231, 0072, 0334, 
+  0046, 0322, 0271, 0241, 0130, 0247, 0065, 0174, 0042, 0251, 0250, 0051, 0301, 0215, 0230, 0145, 
+  0021, 0273, 0367, 0001, 0171, 0112, 0145, 0046, 0230, 0016, 0151, 0116, 0052, 0112, 0222, 0216, 
+  0061, 0062, 0063, 0012, 0241, 0330, 0305, 0021, 0345, 0034, 0243, 0261, 0040, 0344, 0260, 0102, 
+  0111, 0303, 0266, 0054, 0266, 0170, 0035, 0132, 0047, 0235, 0162, 0221, 0201, 0056, 0056, 0023, 
+  0114, 0225, 0200, 0275, 0362, 0136, 0127, 0215, 0372, 0037, 0344, 0063, 0046, 0060, 0213, 0374, 
+  0043, 0304, 0331, 0261, 0172, 0300, 0001, 0053, 0376, 0014, 0303, 0125, 0172, 0361, 0302, 0107, 
+  0216, 0356, 0252, 0223, 0060, 0255, 0064, 0207, 0255, 0244, 0026, 0022, 0067, 0116, 0040, 0203, 
+  0133, 0236, 0066, 0267, 0277, 0235, 0257, 0012, 0232, 0102, 0355, 0200, 0223, 0227, 0353, 0104, 
+  0141, 0155, 0151, 0352, 0226, 0045, 0124, 0063, 0032, 0124, 0272, 0264, 0126, 0311, 0266, 0352, 
+  0153, 0223, 0272, 0331, 0001, 0101, 0347, 0252, 0264, 0304, 0330, 0271, 0133, 0227, 0311, 0154, 
+  0103, 0261, 0255, 0262, 0127, 0202, 0217, 0375, 0377, 0100, 0126, 0365, 0101, 0075, 0350, 0026, 
+  0344, 0115, 0073, 0027, 0036, 0257, 0347, 0036, 0112, 0315, 0122, 0306, 0357, 0235, 0177, 0260, 
+  0073, 0132, 0012, 0273, 0167, 0202, 0257, 0025, 0160, 0122, 0225, 0014, 0073, 0350, 0112, 0343, 
+  0152, 0070, 0100, 0277, 0340, 0062, 0040, 0360, 0062, 0164, 0001, 0160, 0076, 0003, 0162, 0066, 
+  0346, 0263, 0207, 0002, 0074, 0157, 0277, 0235, 0356, 0270, 0020, 0373, 0251, 0012, 0145, 0170, 
+  0005, 0346, 0106, 0325, 0325, 0133, 0162, 0137, 0070, 0150, 0327, 0162, 0001, 0027, 0342, 0342, 
+  0334, 0006, 0304, 0016, 0125, 0140, 0033, 0064, 0337, 0151, 0236, 0155, 0346, 0003, 0217, 0276, 
+  0116, 0374, 0251, 0231, 0066, 0136, 0356, 0202, 0244, 0232, 0221, 0145, 0074, 0211, 0373, 0273, 
+  0330, 0373, 0122, 0146, 0105, 0074, 0170, 0214, 0217, 0276, 0257, 0334, 0317, 0355, 0204, 0367, 
+  0304, 0353, 0216, 0302, 0311, 0026, 0247, 0137, 0053, 0013, 0326, 0262, 0042, 0252, 0302, 0336, 
+  0015, 0362, 0322, 0272, 0052, 0024, 0371, 0266, 0310, 0367, 0056, 0125, 0325, 0200, 0174, 0322, 
+  0040, 0257, 0227, 0303, 0346, 0346, 0160, 0167, 0154, 0121, 0347, 0222, 0345, 0112, 0362, 0324, 
+  0231, 0153, 0302, 0040, 0050, 0254, 0365, 0144, 0236, 0071, 0360, 0336, 0061, 0375, 0201, 0012, 
+  0110, 0246, 0155, 0250, 0356, 0363, 0054, 0301, 0356, 0054, 0241, 0326, 0322, 0164, 0332, 0232, 
+  0332, 0256, 0013, 0124, 0261, 0244, 0353, 0037, 0346, 0015, 0155, 0020, 0374, 0364, 0235, 0200, 
+  0040, 0343, 0006, 0012, 0213, 0371, 0242, 0055, 0131, 0003, 0302, 0007, 0337, 0014, 0041, 0362, 
+  0326, 0277, 0071, 0043, 0024, 0232, 0135, 0327, 0267, 0205, 0206, 0003, 0143, 0343, 0033, 0247, 
+  0304, 0262, 0342, 0010, 0140, 0275, 0023, 0164, 0324, 0335, 0140, 0373, 0370, 0143, 0153, 0321, 
+  0013, 0115, 0240, 0234, 0260, 0154, 0255, 0104, 0015, 0110, 0116, 0152, 0252, 0120, 0245, 0372, 
+  0064, 0033, 0304, 0347, 0365, 0310, 0246, 0015, 0302, 0040, 0353, 0322, 0014, 0201, 0303, 0205, 
+  0047, 0130, 0042, 0054, 0177, 0367, 0306, 0070, 0211, 0103, 0254, 0016, 0054, 0276, 0206, 0041, 
+  0132, 0307, 0045, 0117, 0060, 0302, 0246, 0334, 0335, 0033, 0340, 0362, 0064, 0371, 0051, 0216, 
+  0277, 0351, 0004, 0045, 0226, 0011, 0152, 0326, 0074, 0332, 0250, 0162, 0223, 0077, 0357, 0360, 
+  0226, 0070, 0143, 0136, 0332, 0264, 0366, 0267, 0221, 0223, 0016, 0104, 0300, 0153, 0047, 0340, 
+  0352, 0200, 0231, 0056, 0036, 0343, 0216, 0252, 0165, 0150, 0136, 0163, 0122, 0320, 0054, 0333, 
+  0254, 0254, 0103, 0273, 0262, 0244, 0154, 0026, 0354, 0373, 0273, 0021, 0017, 0262, 0176, 0047, 
+  0112, 0065, 0032, 0213, 0107, 0365, 0012, 0157, 0246, 0054, 0155, 0064, 0365, 0340, 0031, 0034, 
+  0340, 0071, 0041, 0137, 0230, 0126, 0320, 0077, 0245, 0216, 0000, 0237, 0301, 0217, 0314, 0124, 
+  0315, 0320, 0202, 0033, 0252, 0270, 0041, 0317, 0015, 0125, 0007, 0013, 0070, 0271, 0155, 0220, 
+  0324, 0022, 0175, 0345, 0303, 0203, 0175, 0046, 0230, 0326, 0176, 0147, 0054, 0325, 0366, 0144, 
+  0261, 0040, 0323, 0164, 0106, 0270, 0314, 0170, 0112, 0255, 0322, 0233, 0344, 0215, 0074, 0141, 
+  0325, 0004, 0252, 0244, 0365, 0074, 0021, 0064, 0052, 0251, 0351, 0216, 0117, 0025, 0217, 0015, 
+  0024, 0361, 0201, 0271, 0172, 0003, 0243, 0123, 0125, 0032, 0320, 0315, 0020, 0303, 0012, 0252, 
+  0335, 0226, 0234, 0033, 0247, 0013, 0216, 0150, 0311, 0061, 0204, 0125, 0022, 0240, 0373, 0037, 
+  0260, 0207, 0000, 0166, 0233, 0205, 0273, 0007, 0355, 0201, 0325, 0376, 0262, 0266, 0234, 0102, 
+  0236, 0356, 0046, 0245, 0035, 0174, 0112, 0324, 0272, 0333, 0255, 0352, 0261, 0056, 0313, 0261, 
+  0225, 0057, 0176, 0120, 0166, 0351, 0254, 0054, 0103, 0343, 0071, 0002, 0121, 0237, 0377, 0210, 
+  0270, 0131, 0037, 0246, 0006, 0051, 0311, 0220, 0261, 0332, 0353, 0353, 0174, 0357, 0174, 0145, 
+  0127, 0153, 0167, 0114, 0301, 0345, 0311, 0353, 0256, 0247, 0235, 0271, 0356, 0321, 0340, 0350, 
+  0223, 0324, 0133, 0120, 0161, 0075, 0336, 0006, 0166, 0000, 0167, 0020, 0313, 0270, 0254, 0327, 
+  0164, 0115, 0015, 0304, 0220, 0177, 0376, 0376, 0153, 0007, 0365, 0372, 0027, 0011, 0133, 0077, 
+  0126, 0330, 0032, 0202, 0356, 0251, 0050, 0131, 0264, 0331, 0141, 0005, 0124, 0257, 0133, 0054, 
+  0342, 0247, 0034, 0024, 0207, 0316, 0144, 0355, 0370, 0350, 0116, 0054, 0024, 0010, 0372, 0337, 
+  0121, 0040, 0250, 0345, 0107, 0265, 0002, 0377, 0215, 0230, 0260, 0107, 0266, 0047, 0202, 0244, 
+  0177, 0344, 0355, 0320, 0071, 0116, 0055, 0227, 0114, 0317, 0053, 0305, 0256, 0023, 0215, 0372, 
+  0326, 0246, 0337, 0351, 0335, 0331, 0251, 0074, 0173, 0143, 0377, 0252, 0273, 0344, 0250, 0102, 
+  0253, 0151, 0075, 0243, 0305, 0335, 0276, 0373, 0214, 0043, 0251, 0057, 0161, 0207, 0275, 0006, 
+  0115, 0322, 0172, 0136, 0377, 0372, 0247, 0267, 0372, 0034, 0356, 0331, 0277, 0355, 0222, 0140, 
+  0076, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0142, 0165, 0164, 0164, 0157, 0156, 0163, 0055, 
+  0141, 0144, 0166, 0141, 0156, 0143, 0145, 0144, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0000, 
+  0343, 0177, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0135, 0335, 0156, 0333, 0066, 
+  0024, 0276, 0357, 0123, 0150, 0272, 0050, 0122, 0024, 0116, 0374, 0227, 0064, 0355, 0142, 0027, 
+  0151, 0261, 0026, 0005, 0072, 0014, 0330, 0322, 0355, 0322, 0240, 0044, 0132, 0146, 0115, 0223, 
+  0032, 0111, 0305, 0366, 0320, 0213, 0135, 0015, 0275, 0135, 0167, 0121, 0140, 0057, 0262, 0007, 
+  0350, 0003, 0354, 0035, 0372, 0044, 0043, 0345, 0377, 0237, 0230, 0212, 0103, 0123, 0216, 0307, 
+  0233, 0104, 0226, 0050, 0221, 0074, 0337, 0371, 0016, 0217, 0016, 0017, 0251, 0213, 0347, 0203, 
+  0036, 0366, 0256, 0041, 0343, 0210, 0222, 0206, 0137, 0071, 0056, 0373, 0036, 0044, 0041, 0215, 
+  0020, 0211, 0033, 0376, 0273, 0253, 0127, 0245, 0163, 0377, 0171, 0363, 0301, 0305, 0067, 0245, 
+  0222, 0367, 0032, 0022, 0310, 0200, 0200, 0221, 0327, 0107, 0242, 0343, 0305, 0030, 0104, 0320, 
+  0253, 0035, 0127, 0253, 0307, 0025, 0257, 0124, 0222, 0205, 0020, 0021, 0220, 0265, 0101, 0010, 
+  0233, 0027, 0014, 0376, 0232, 0042, 0006, 0271, 0207, 0121, 0320, 0360, 0143, 0321, 0175, 0354, 
+  0317, 0152, 0121, 0367, 0370, 0047, 0315, 0013, 0032, 0274, 0207, 0241, 0360, 0102, 0014, 0070, 
+  0157, 0370, 0257, 0105, 0367, 0027, 0104, 0042, 0332, 0367, 0075, 0024, 0065, 0374, 0176, 0166, 
+  0134, 0361, 0233, 0027, 0011, 0243, 0011, 0144, 0142, 0350, 0021, 0320, 0203, 0015, 0077, 0004, 
+  0244, 0325, 0246, 0141, 0312, 0375, 0346, 0053, 0200, 0071, 0274, 0070, 0231, 0024, 0150, 0136, 
+  0204, 0035, 0204, 0043, 0117, 0014, 0023, 0131, 0116, 0040, 0201, 0141, 0000, 0230, 0172, 0002, 
+  0226, 0215, 0352, 0120, 0034, 0101, 0046, 0253, 0075, 0311, 0112, 0215, 0013, 0257, 0151, 0305, 
+  0153, 0206, 0242, 0121, 0033, 0202, 0124, 0010, 0112, 0132, 0011, 0040, 0020, 0257, 0066, 0344, 
+  0032, 0161, 0024, 0140, 0350, 0067, 0257, 0130, 0272, 0320, 0212, 0133, 0064, 0170, 0251, 0050, 
+  0243, 0375, 0126, 0207, 0366, 0150, 0054, 0105, 0115, 0325, 0015, 0272, 0107, 0123, 0234, 0366, 
+  0310, 0346, 0133, 0156, 0352, 0346, 0213, 0254, 0163, 0243, 0216, 0206, 0000, 0207, 0055, 0211, 
+  0234, 0240, 0254, 0065, 0352, 0364, 0152, 0167, 0061, 0010, 0224, 0024, 0300, 0227, 0317, 0301, 
+  0206, 0026, 0155, 0041, 0024, 0115, 0311, 0254, 0124, 0113, 0302, 0020, 0142, 0024, 0166, 0163, 
+  0310, 0020, 0206, 0020, 0135, 0103, 0336, 0212, 0140, 0033, 0244, 0130, 0150, 0053, 0110, 0071, 
+  0154, 0245, 0104, 0352, 0006, 0106, 0144, 0115, 0303, 0071, 0212, 0011, 0300, 0223, 0146, 0253, 
+  0066, 0100, 0251, 0036, 0035, 0100, 0042, 0014, 0231, 0154, 0136, 0046, 0065, 0364, 0033, 0154, 
+  0205, 0201, 0357, 0361, 0076, 0110, 0022, 0050, 0045, 0112, 0250, 0322, 0360, 0221, 0076, 0146, 
+  0274, 0220, 0317, 0050, 0145, 0077, 0033, 0076, 0010, 0103, 0310, 0307, 0142, 0132, 0302, 0345, 
+  0122, 0164, 0177, 0310, 0116, 0334, 0204, 0113, 0011, 0210, 0356, 0350, 0226, 0125, 0204, 0246, 
+  0067, 0077, 0173, 0066, 0253, 0242, 0244, 0256, 0371, 0236, 0140, 0200, 0160, 0014, 0004, 0220, 
+  0247, 0032, 0376, 0020, 0162, 0337, 0013, 0151, 0257, 0007, 0211, 0120, 0265, 0116, 0113, 0147, 
+  0117, 0362, 0332, 0224, 0171, 0242, 0043, 0377, 0117, 0372, 0346, 0115, 0224, 0342, 0325, 0344, 
+  0314, 0274, 0204, 0116, 0106, 0015, 0232, 0061, 0153, 0172, 0042, 0001, 0141, 0127, 0132, 0222, 
+  0125, 0135, 0202, 0155, 0321, 0002, 0102, 0200, 0260, 0343, 0067, 0117, 0067, 0140, 0043, 0150, 
+  0062, 0055, 0127, 0137, 0250, 0163, 0372, 0150, 0035, 0235, 0127, 0364, 0034, 0365, 0100, 0214, 
+  0010, 0140, 0303, 0126, 0102, 0231, 0220, 0026, 0111, 0247, 0362, 0157, 0172, 0116, 0341, 0147, 
+  0012, 0077, 0066, 0212, 0153, 0264, 0375, 0166, 0260, 0077, 0051, 0014, 0366, 0233, 0340, 0166, 
+  0120, 0056, 0032, 0256, 0065, 0122, 0175, 0233, 0061, 0042, 0023, 0352, 0114, 0236, 0143, 0232, 
+  0130, 0030, 0037, 0307, 0065, 0075, 0304, 0342, 0133, 0364, 0060, 0126, 0177, 0344, 0321, 0111, 
+  0166, 0250, 0021, 0122, 0017, 0260, 0156, 0232, 0254, 0266, 0345, 0216, 0266, 0253, 0152, 0131, 
+  0211, 0353, 0072, 0133, 0125, 0167, 0246, 0152, 0246, 0337, 0021, 0212, 0221, 0270, 0273, 0245, 
+  0052, 0347, 0004, 0271, 0152, 0010, 0344, 0047, 0072, 0220, 0237, 0070, 0220, 0013, 0003, 0271, 
+  0142, 0010, 0344, 0163, 0035, 0310, 0347, 0016, 0144, 0343, 0040, 0127, 0054, 0203, 0374, 0124, 
+  0007, 0362, 0123, 0007, 0262, 0161, 0220, 0253, 0226, 0101, 0076, 0325, 0201, 0174, 0352, 0100, 
+  0056, 0214, 0311, 0246, 0306, 0344, 0063, 0035, 0310, 0147, 0016, 0344, 0302, 0230, 0154, 0012, 
+  0344, 0010, 0135, 0243, 0010, 0352, 0220, 0376, 0362, 0217, 0203, 0332, 0174, 0070, 0240, 0146, 
+  0331, 0152, 0127, 0165, 0060, 0127, 0035, 0312, 0205, 0131, 0355, 0232, 0041, 0220, 0111, 0332, 
+  0203, 0014, 0205, 0255, 0204, 0042, 0042, 0064, 0200, 0317, 0305, 0103, 0263, 0050, 0207, 0207, 
+  0270, 0307, 0241, 0360, 0020, 0361, 0142, 0321, 0075, 0016, 0075, 0101, 0125, 0221, 0004, 0017, 
+  0107, 0363, 0037, 0157, 0137, 0172, 0155, 0014, 0142, 0011, 0355, 0261, 0323, 0224, 0231, 0246, 
+  0054, 0212, 0334, 0232, 0306, 0230, 0012, 0260, 0324, 0164, 0146, 0241, 0346, 0300, 0056, 0154, 
+  0234, 0067, 0145, 0026, 0172, 0122, 0062, 0110, 0022, 0131, 0073, 0322, 0177, 0166, 0140, 0027, 
+  0067, 0322, 0233, 0362, 0352, 0170, 0032, 0010, 0006, 0102, 0235, 0375, 0157, 0176, 0375, 0370, 
+  0311, 0301, 0075, 0203, 0173, 0052, 0066, 0153, 0200, 0233, 0242, 0067, 0210, 0042, 0035, 0326, 
+  0217, 0035, 0322, 0305, 0021, 0333, 0324, 0130, 0315, 0040, 0227, 0302, 0321, 0271, 0165, 0033, 
+  0147, 0276, 0107, 0236, 0036, 0045, 0331, 0164, 0067, 0247, 0370, 0172, 0062, 0325, 0355, 0035, 
+  0145, 0162, 0222, 0015, 0223, 0227, 0224, 0047, 0250, 0256, 0361, 0254, 0130, 0204, 0170, 0202, 
+  0301, 0020, 0106, 0236, 0152, 0105, 0052, 0037, 0215, 0050, 0171, 0344, 0067, 0033, 0116, 0247, 
+  0346, 0254, 0207, 0222, 0327, 0072, 0225, 0342, 0142, 0210, 0241, 0004, 0131, 0301, 0072, 0276, 
+  0233, 0247, 0161, 0014, 0271, 0200, 0121, 0111, 0232, 0033, 0051, 0313, 0114, 0363, 0306, 0345, 
+  0156, 0247, 0201, 0165, 0313, 0032, 0030, 0142, 0010, 0330, 0355, 0025, 0260, 0371, 0122, 0335, 
+  0167, 0317, 0325, 0105, 0243, 0000, 0043, 0321, 0344, 0123, 0200, 0110, 0242, 0317, 0122, 0211, 
+  0375, 0065, 0274, 0263, 0012, 0344, 0315, 0046, 0051, 0033, 0122, 0001, 0070, 0110, 0050, 0221, 
+  0306, 0004, 0001, 0354, 0022, 0013, 0046, 0340, 0117, 0204, 0262, 0145, 0152, 0101, 0106, 0234, 
+  0252, 0315, 0214, 0202, 0057, 0237, 0053, 0145, 0225, 0113, 0300, 0323, 0104, 0045, 0023, 0114, 
+  0023, 0014, 0206, 0263, 0004, 0203, 0354, 0150, 0174, 0335, 0124, 0262, 0201, 0221, 0374, 0260, 
+  0125, 0015, 0264, 0232, 0044, 0306, 0103, 0244, 0052, 0157, 0243, 0320, 0233, 0264, 0144, 0232, 
+  0056, 0366, 0323, 0354, 0332, 0167, 0343, 0153, 0005, 0044, 0137, 0230, 0242, 0172, 0217, 0106, 
+  0051, 0226, 0264, 0313, 0027, 0046, 0226, 0245, 0235, 0103, 0120, 0234, 0223, 0151, 0012, 0164, 
+  0056, 0000, 0023, 0255, 0230, 0321, 0064, 0321, 0041, 0176, 0344, 0360, 0066, 0217, 0167, 0335, 
+  0362, 0274, 0000, 0044, 0121, 0076, 0264, 0037, 0071, 0264, 0315, 0243, 0175, 0152, 0031, 0355, 
+  0036, 0354, 0321, 0173, 0236, 0021, 0252, 0101, 0146, 0334, 0303, 0133, 0070, 0142, 0057, 0350, 
+  0140, 0044, 0241, 0116, 0100, 0007, 0325, 0362, 0156, 0334, 0260, 0334, 0136, 0140, 0315, 0242, 
+  0033, 0270, 0331, 0001, 0272, 0222, 0316, 0016, 0236, 0217, 0027, 0214, 0104, 0073, 0165, 0166, 
+  0006, 0363, 0317, 0227, 0212, 0312, 0220, 0274, 0002, 0371, 0334, 0361, 0344, 0175, 0127, 0275, 
+  0327, 0370, 0336, 0065, 0300, 0251, 0374, 0205, 0004, 0220, 0240, 0145, 0124, 0231, 0277, 0111, 
+  0313, 0033, 0351, 0154, 0111, 0214, 0365, 0012, 0207, 0060, 0326, 0026, 0112, 0050, 0107, 0331, 
+  0153, 0327, 0266, 0303, 0346, 0045, 0143, 0223, 0205, 0073, 0100, 0035, 0126, 0352, 0126, 0140, 
+  0313, 0352, 0152, 0251, 0365, 0076, 0176, 0063, 0242, 0175, 0262, 0326, 0271, 0324, 0011, 0120, 
+  0127, 0311, 0055, 0045, 0250, 0061, 0115, 0273, 0171, 0007, 0130, 0260, 0143, 0126, 0335, 0377, 
+  0045, 0022, 0174, 0237, 0375, 0064, 0350, 0344, 0327, 0267, 0231, 0055, 0130, 0052, 0327, 0107, 
+  0221, 0060, 0070, 0241, 0300, 0240, 0174, 0323, 0312, 0271, 0166, 0344, 0107, 0350, 0334, 0004, 
+  0363, 0156, 0302, 0231, 0355, 0070, 0037, 0045, 0357, 0323, 0030, 0010, 0355, 0113, 0237, 0052, 
+  0350, 0000, 0067, 0017, 0370, 0271, 0145, 0300, 0011, 0020, 0051, 0223, 0054, 0307, 0064, 0006, 
+  0014, 0211, 0116, 0117, 0007, 0074, 0046, 0016, 0166, 0363, 0260, 0077, 0265, 0074, 0163, 0230, 
+  0037, 0156, 0032, 0037, 0166, 0370, 0336, 0066, 0161, 0115, 0041, 0070, 0220, 0003, 0163, 0277, 
+  0165, 0320, 0157, 0164, 0167, 0132, 0265, 0067, 0221, 0117, 0161, 0153, 0366, 0006, 0213, 0041, 
+  0365, 0373, 0030, 0161, 0137, 0124, 0062, 0253, 0356, 0366, 0054, 0330, 0257, 0274, 0117, 0357, 
+  0150, 0240, 0322, 0022, 0325, 0005, 0331, 0042, 0310, 0074, 0332, 0366, 0206, 0217, 0246, 0316, 
+  0370, 0016, 0142, 0356, 0147, 0226, 0371, 0314, 0050, 0315, 0221, 0270, 0363, 0267, 0033, 0174, 
+  0213, 0133, 0240, 0155, 0012, 0152, 0331, 0143, 0272, 0305, 0134, 0372, 0073, 0171, 0333, 0141, 
+  0217, 0305, 0231, 0140, 0254, 0005, 0322, 0115, 0115, 0234, 0044, 0310, 0315, 0207, 0033, 0031, 
+  0262, 0245, 0040, 0255, 0217, 0326, 0377, 0376, 0136, 0314, 0172, 0372, 0272, 0145, 0233, 0003, 
+  0123, 0211, 0017, 0127, 0353, 0004, 0002, 0310, 0234, 0276, 0032, 0321, 0327, 0105, 0231, 0026, 
+  0347, 0150, 0302, 0242, 0067, 0207, 0070, 0335, 0255, 0062, 0317, 0366, 0251, 0312, 0206, 0303, 
+  0312, 0341, 0357, 0120, 0025, 0122, 0056, 0265, 0131, 0037, 0203, 0343, 0356, 0335, 0334, 0344, 
+  0226, 0007, 0306, 0122, 0051, 0162, 0200, 0047, 0313, 0070, 0360, 0114, 0056, 0214, 0062, 0005, 
+  0236, 0000, 0044, 0206, 0332, 0105, 0164, 0115, 0131, 0314, 0341, 0267, 0217, 0311, 0153, 0235, 
+  0241, 0174, 0106, 0100, 0145, 0177, 0362, 0362, 0260, 0343, 0200, 0334, 0307, 0075, 0105, 0346, 
+  0200, 0314, 0317, 0111, 0207, 0345, 0136, 0156, 0035, 0202, 0210, 0332, 0024, 0025, 0346, 0141, 
+  0344, 0272, 0320, 0007, 0160, 0243, 0345, 0236, 0156, 0027, 0062, 0001, 0066, 0037, 0103, 0327, 
+  0142, 0353, 0106, 0322, 0075, 0335, 0045, 0144, 0316, 0000, 0347, 0176, 0041, 0161, 0366, 0167, 
+  0057, 0067, 0141, 0233, 0320, 0064, 0027, 0216, 0153, 0131, 0352, 0136, 0066, 0355, 0156, 0242, 
+  0270, 0233, 0331, 0252, 0262, 0076, 0171, 0154, 0123, 0144, 0262, 0003, 0121, 0334, 0021, 0346, 
+  0242, 0222, 0355, 0224, 0204, 0033, 0223, 0313, 0016, 0100, 0257, 0246, 0175, 0334, 0072, 0063, 
+  0271, 0330, 0304, 0344, 0123, 0233, 0061, 0315, 0366, 0321, 0340, 0321, 0126, 0271, 0255, 0373, 
+  0231, 0034, 0354, 0162, 0203, 0155, 0346, 0006, 0057, 0131, 0023, 0273, 0213, 0003, 0005, 0145, 
+  0160, 0224, 0351, 0076, 0133, 0024, 0250, 0316, 0031, 0014, 0263, 0127, 0154, 0307, 0061, 0047, 
+  0136, 0203, 0313, 0061, 0332, 0264, 0160, 0243, 0274, 0107, 0331, 0105, 0137, 0077, 0176, 0252, 
+  0030, 0310, 0046, 0132, 0052, 0372, 0076, 0345, 0002, 0265, 0207, 0322, 0301, 0207, 0212, 0241, 
+  0273, 0317, 0073, 0132, 0124, 0074, 0253, 0104, 0036, 0127, 0075, 0045, 0361, 0233, 0321, 0357, 
+  0042, 0150, 0154, 0312, 0371, 0037, 0177, 0335, 0342, 0236, 0257, 0333, 0337, 0071, 0221, 0055, 
+  0055, 0345, 0331, 0100, 0344, 0157, 0366, 0052, 0371, 0157, 0131, 0155, 0212, 0370, 0042, 0213, 
+  0004, 0174, 0351, 0213, 0054, 0000, 0027, 0101, 0105, 0123, 0041, 0025, 0020, 0160, 0227, 0174, 
+  0141, 0220, 0262, 0066, 0031, 0373, 0141, 0035, 0145, 0077, 0354, 0025, 0145, 0147, 0352, 0145, 
+  0225, 0254, 0262, 0132, 0212, 0325, 0262, 0317, 0105, 0377, 0367, 0162, 0162, 0372, 0147, 0165, 
+  0272, 0010, 0332, 0032, 0333, 0150, 0215, 0305, 0272, 0330, 0347, 0045, 0213, 0135, 0156, 0156, 
+  0161, 0013, 0143, 0266, 0134, 0017, 0165, 0105, 0343, 0030, 0303, 0065, 0073, 0051, 0312, 0047, 
+  0361, 0220, 0241, 0104, 0034, 0262, 0317, 0304, 0241, 0130, 0350, 0352, 0035, 0054, 0261, 0315, 
+  0325, 0353, 0315, 0257, 0177, 0374, 0111, 0366, 0312, 0356, 0256, 0352, 0213, 0335, 0340, 0303, 
+  0254, 0172, 0257, 0107, 0243, 0271, 0010, 0304, 0354, 0202, 0111, 0363, 0273, 0333, 0060, 0304, 
+  0215, 0234, 0014, 0376, 0057, 0214, 0014, 0356, 0316, 0307, 0272, 0135, 0076, 0376, 0265, 0157, 
+  0174, 0014, 0212, 0144, 0143, 0260, 0236, 0213, 0201, 0161, 0046, 0332, 0016, 0010, 0126, 0164, 
+  0136, 0120, 0305, 0371, 0100, 0205, 0175, 0260, 0313, 0224, 0263, 0133, 0326, 0201, 0254, 0235, 
+  0104, 0154, 0251, 0257, 0042, 0103, 0056, 0345, 0173, 0132, 0166, 0012, 0121, 0230, 0102, 0030, 
+  0334, 0024, 0202, 0037, 0364, 0250, 0073, 0352, 0340, 0266, 0363, 0263, 0265, 0042, 0346, 0147, 
+  0013, 0335, 0053, 0252, 0231, 0011, 0354, 0160, 0346, 0151, 0153, 0156, 0236, 0066, 0347, 0074, 
+  0355, 0216, 0342, 0064, 0365, 0155, 0233, 0161, 0222, 0071, 0212, 0155, 0020, 0302, 0346, 0203, 
+  0377, 0000, 0216, 0314, 0365, 0242, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0142, 0165, 0164, 
+  0164, 0157, 0156, 0163, 0055, 0142, 0141, 0163, 0151, 0143, 0056, 0165, 0151, 0000, 0000, 0000, 
+  0126, 0061, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0133, 0335, 0156, 0333, 0066, 
+  0024, 0276, 0357, 0123, 0160, 0002, 0126, 0044, 0050, 0374, 0237, 0264, 0151, 0153, 0251, 0350, 
+  0212, 0065, 0067, 0001, 0166, 0323, 0142, 0227, 0002, 0115, 0036, 0313, 0234, 0151, 0122, 0045, 
+  0051, 0377, 0274, 0301, 0256, 0167, 0063, 0140, 0057, 0262, 0007, 0330, 0233, 0354, 0111, 0106, 
+  0312, 0212, 0355, 0304, 0261, 0351, 0244, 0232, 0264, 0016, 0272, 0123, 0304, 0103, 0362, 0360, 
+  0373, 0276, 0163, 0016, 0111, 0053, 0303, 0167, 0313, 0031, 0107, 0163, 0120, 0232, 0111, 0021, 
+  0006, 0275, 0166, 0067, 0100, 0040, 0210, 0244, 0114, 0044, 0141, 0360, 0371, 0323, 0307, 0326, 
+  0125, 0360, 0056, 0172, 0066, 0374, 0256, 0325, 0102, 0327, 0040, 0100, 0141, 0003, 0024, 0055, 
+  0230, 0231, 0240, 0204, 0143, 0012, 0150, 0320, 0356, 0367, 0333, 0075, 0324, 0152, 0131, 0043, 
+  0046, 0014, 0250, 0061, 0046, 0020, 0015, 0025, 0174, 0311, 0230, 0002, 0215, 0070, 0033, 0205, 
+  0101, 0142, 0246, 0057, 0202, 0355, 0054, 0256, 0117, 0320, 0211, 0206, 0162, 0364, 0013, 0020, 
+  0203, 0010, 0307, 0132, 0207, 0301, 0265, 0231, 0376, 0314, 0004, 0225, 0213, 0000, 0061, 0032, 
+  0006, 0213, 0374, 0271, 0027, 0104, 0303, 0124, 0311, 0024, 0224, 0131, 0041, 0201, 0147, 0020, 
+  0006, 0004, 0213, 0170, 0054, 0111, 0246, 0203, 0350, 0043, 0346, 0032, 0206, 0235, 0133, 0203, 
+  0150, 0110, 0046, 0214, 0123, 0144, 0126, 0251, 0265, 0063, 0314, 0160, 0030, 0141, 0345, 0106, 
+  0340, 0326, 0251, 0211, 0344, 0024, 0224, 0235, 0266, 0223, 0133, 0025, 0306, 0017, 0170, 0161, 
+  0255, 0030, 0135, 0373, 0060, 0312, 0214, 0221, 0042, 0116, 0261, 0000, 0276, 0357, 0310, 0234, 
+  0151, 0066, 0342, 0020, 0104, 0237, 0124, 0166, 0307, 0213, 0107, 0070, 0174, 0317, 0124, 0311, 
+  0105, 0074, 0221, 0063, 0231, 0130, 0250, 0245, 0353, 0340, 0033, 0132, 0362, 0154, 0046, 0216, 
+  0167, 0071, 0264, 0314, 0037, 0362, 0305, 0255, 0027, 0112, 0060, 0047, 0361, 0105, 0274, 0136, 
+  0357, 0376, 0112, 0071, 0036, 0071, 0000, 0056, 0216, 0170, 0362, 0004, 0060, 0074, 0226, 0271, 
+  0125, 0154, 0341, 0047, 0234, 0221, 0351, 0011, 0330, 0001, 0001, 0066, 0007, 0035, 0123, 0030, 
+  0343, 0214, 0033, 0177, 0217, 0114, 0103, 0234, 0011, 0053, 0012, 0316, 0304, 0003, 0236, 0153, 
+  0226, 0010, 0314, 0157, 0375, 0166, 0116, 0200, 0325, 0305, 0004, 0013, 0312, 0101, 0205, 0001, 
+  0145, 0011, 0063, 0061, 0031, 0005, 0110, 0057, 0160, 0232, 0202, 0205, 0121, 0110, 0047, 0353, 
+  0316, 0032, 0152, 0073, 0035, 0046, 0123, 0033, 0107, 0373, 0160, 0302, 0330, 0304, 0330, 0030, 
+  0114, 0046, 0101, 0324, 0075, 0342, 0240, 0221, 0351, 0306, 0256, 0267, 0153, 0327, 0331, 0014, 
+  0355, 0023, 0363, 0036, 0313, 0127, 0076, 0226, 0257, 0032, 0226, 0313, 0147, 0271, 0167, 0042, 
+  0313, 0335, 0222, 0130, 0176, 0355, 0143, 0371, 0165, 0303, 0162, 0371, 0054, 0367, 0053, 0146, 
+  0371, 0322, 0307, 0362, 0145, 0303, 0162, 0175, 0261, 0134, 0126, 0306, 0176, 0351, 0143, 0371, 
+  0145, 0303, 0162, 0175, 0261, 0134, 0026, 0313, 0224, 0315, 0031, 0005, 0037, 0325, 0177, 0375, 
+  0331, 0160, 0275, 0303, 0165, 0261, 0101, 0377, 0152, 0262, 0007, 0025, 0047, 0356, 0276, 0217, 
+  0347, 0176, 0103, 0163, 0175, 0211, 0273, 0137, 0022, 0313, 0042, 0233, 0201, 0142, 0044, 0116, 
+  0245, 0075, 0031, 0173, 0030, 0107, 0104, 0316, 0146, 0040, 0214, 0035, 0352, 0306, 0275, 0100, 
+  0114, 0043, 0015, 0006, 0061, 0201, 0354, 0351, 0271, 0115, 0220, 0221, 0316, 0044, 0345, 0253, 
+  0365, 0351, 0373, 0346, 0003, 0032, 0163, 0234, 0130, 0156, 0333, 0215, 0124, 0166, 0244, 0162, 
+  0027, 0363, 0312, 0044, 0063, 0050, 0111, 0062, 0166, 0004, 0142, 0125, 0200, 0023, 0157, 0045, 
+  0370, 0376, 0033, 0243, 0335, 0063, 0301, 0177, 0243, 0016, 0364, 0053, 0246, 0173, 0340, 0143, 
+  0171, 0320, 0004, 0167, 0175, 0133, 0273, 0262, 0352, 0300, 0314, 0102, 0303, 0154, 0346, 0366, 
+  0156, 0356, 0176, 0157, 0330, 0256, 0161, 0163, 0127, 0326, 0116, 0136, 0147, 0043, 0243, 0060, 
+  0361, 0125, 0374, 0350, 0357, 0137, 0177, 0153, 0370, 0336, 0341, 0173, 0203, 0133, 0145, 0214, 
+  0227, 0025, 0340, 0230, 0122, 0037, 0331, 0057, 0032, 0252, 0153, 0014, 0355, 0262, 0352, 0265, 
+  0002, 0155, 0321, 0361, 0155, 0345, 0255, 0212, 0205, 0346, 0330, 0140, 0113, 0152, 0030, 0254, 
+  0100, 0357, 0357, 0356, 0245, 0100, 0146, 0002, 0110, 0113, 0076, 0007, 0264, 0036, 0016, 0235, 
+  0345, 0070, 0131, 0307, 0154, 0223, 0333, 0375, 0273, 0066, 0235, 0233, 0121, 0246, 0123, 0216, 
+  0127, 0100, 0221, 0363, 0042, 0263, 0103, 0063, 0051, 0316, 0203, 0050, 0154, 0104, 0265, 0233, 
+  0077, 0034, 0140, 0017, 0151, 0112, 0233, 0025, 0007, 0313, 0262, 0343, 0265, 0350, 0255, 0263, 
+  0044, 0001, 0155, 0200, 0266, 0154, 0302, 0261, 0140, 0346, 0322, 0053, 0354, 0036, 0047, 0301, 
+  0213, 0247, 0110, 0360, 0236, 0335, 0202, 0121, 0123, 0142, 0072, 0322, 0006, 0053, 0023, 0047, 
+  0112, 0146, 0251, 0057, 0055, 0235, 0065, 0247, 0210, 0362, 0263, 0322, 0105, 0305, 0033, 0016, 
+  0020, 0364, 0064, 0266, 0317, 0033, 0266, 0313, 0147, 0373, 0262, 0142, 0266, 0011, 0007, 0254, 
+  0036, 0137, 0202, 0242, 0017, 0256, 0337, 0067, 0056, 0000, 0017, 0245, 0153, 0150, 0116, 0253, 
+  0000, 0324, 0246, 0177, 0225, 0331, 0344, 0077, 0207, 0257, 0256, 0001, 0227, 0025, 0137, 0037, 
+  0353, 0057, 0031, 0126, 0020, 0053, 0051, 0117, 0070, 0144, 0374, 0321, 0004, 0175, 0175, 0101, 
+  0137, 0126, 0111, 0267, 0053, 0226, 0117, 0210, 0371, 0317, 0266, 0133, 0103, 0377, 0226, 0376, 
+  0034, 0306, 0312, 0352, 0173, 0131, 0341, 0376, 0312, 0027, 0344, 0257, 0232, 0163, 0100, 0175, 
+  0037, 0146, 0225, 0305, 0362, 0262, 0110, 0353, 0207, 0257, 0022, 0376, 0007, 0025, 0372, 0160, 
+  0376, 0075, 0204, 0323, 0315, 0072, 0271, 0071, 0230, 0266, 0010, 0025, 0272, 0257, 0340, 0213, 
+  0314, 0142, 0246, 0347, 0334, 0274, 0145, 0317, 0023, 0363, 0166, 0351, 0236, 0072, 0371, 0243, 
+  0173, 0322, 0131, 0172, 0373, 0230, 0277, 0353, 0337, 0155, 0356, 0024, 0355, 0036, 0255, 0317, 
+  0260, 0232, 0146, 0351, 0276, 0333, 0033, 0301, 0336, 0021, 0023, 0312, 0277, 0263, 0265, 0050, 
+  0267, 0362, 0077, 0303, 0000, 0023, 0002, 0272, 0130, 0371, 0075, 0000, 0337, 0233, 0351, 0117, 
+  0371, 0213, 0043, 0102, 0153, 0141, 0063, 0135, 0367, 0332, 0107, 0164, 0323, 0377, 0315, 0233, 
+  0355, 0054, 0055, 0327, 0346, 0271, 0346, 0170, 0277, 0261, 0316, 0107, 0102, 0143, 0251, 0362, 
+  0253, 0014, 0130, 0246, 0122, 0130, 0023, 0226, 0337, 0141, 0240, 0263, 0245, 0373, 0141, 0323, 
+  0065, 0244, 0162, 0001, 0012, 0311, 0061, 0132, 0235, 0243, 0333, 0000, 0370, 0261, 0060, 0076, 
+  0212, 0311, 0277, 0223, 0273, 0313, 0052, 0334, 0075, 0137, 0356, 0356, 0065, 0271, 0273, 0276, 
+  0334, 0135, 0026, 0313, 0135, 0037, 0313, 0135, 0337, 0355, 0117, 0354, 0276, 0230, 0267, 0107, 
+  0022, 0273, 0265, 0354, 0066, 0212, 0250, 0117, 0021, 0236, 0233, 0342, 0303, 0331, 0247, 0263, 
+  0375, 0357, 0207, 0147, 0377, 0000, 0331, 0034, 0031, 0272, 0000, 0050, 0165, 0165, 0141, 0171, 
+  0051, 0165, 0151, 0057, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0011, 0000, 0000, 0000, 
+  0006, 0000, 0000, 0000, 0004, 0000, 0000, 0000, 0013, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 
+  0150, 0151, 0163, 0164, 0157, 0162, 0171, 0055, 0145, 0156, 0164, 0162, 0171, 0056, 0165, 0151, 
+  0331, 0011, 0000, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0325, 0126, 0115, 0163, 0233, 0060, 
+  0020, 0275, 0347, 0127, 0250, 0272, 0166, 0060, 0206, 0072, 0235, 0034, 0200, 0314, 0164, 0246, 
+  0361, 0245, 0307, 0364, 0314, 0054, 0322, 0032, 0124, 0013, 0211, 0112, 0302, 0037, 0375, 0365, 
+  0025, 0004, 0307, 0116, 0322, 0142, 0347, 0303, 0231, 0366, 0046, 0055, 0157, 0127, 0117, 0157, 
+  0237, 0166, 0110, 0256, 0067, 0265, 0044, 0053, 0064, 0126, 0150, 0225, 0322, 0150, 0062, 0245, 
+  0004, 0025, 0323, 0134, 0250, 0062, 0245, 0337, 0157, 0157, 0202, 0053, 0172, 0235, 0135, 0044, 
+  0037, 0202, 0200, 0314, 0121, 0241, 0001, 0207, 0234, 0254, 0205, 0253, 0110, 0051, 0201, 0043, 
+  0371, 0064, 0211, 0343, 0111, 0104, 0202, 0300, 0203, 0204, 0162, 0150, 0026, 0300, 0060, 0113, 
+  0014, 0376, 0154, 0205, 0101, 0113, 0244, 0050, 0122, 0132, 0272, 0345, 0107, 0272, 0077, 0245, 
+  0313, 0241, 0141, 0226, 0350, 0342, 0007, 0062, 0107, 0230, 0004, 0153, 0123, 0072, 0167, 0313, 
+  0271, 0021, 0234, 0022, 0301, 0175, 0106, 0267, 0312, 0222, 0306, 0350, 0006, 0215, 0333, 0022, 
+  0005, 0065, 0246, 0164, 0045, 0254, 0050, 0044, 0322, 0354, 0326, 0264, 0230, 0204, 0273, 0257, 
+  0117, 0160, 0014, 0124, 0276, 0320, 0254, 0265, 0064, 0273, 0001, 0151, 0307, 0240, 0065, 0230, 
+  0122, 0250, 0134, 0342, 0302, 0321, 0054, 0212, 0217, 0043, 0215, 0050, 0253, 0016, 0372, 0371, 
+  0070, 0324, 0072, 0060, 0047, 0126, 0105, 0305, 0217, 0324, 0144, 0132, 0266, 0265, 0312, 0053, 
+  0135, 0353, 0322, 0067, 0102, 0167, 0227, 0173, 0054, 0003, 0253, 0204, 0344, 0177, 0320, 0365, 
+  0353, 0012, 0225, 0373, 0242, 0067, 0167, 0332, 0372, 0326, 0200, 0363, 0215, 0310, 0261, 0013, 
+  0027, 0076, 0174, 0026, 0241, 0255, 0050, 0025, 0310, 0001, 0130, 0264, 0316, 0151, 0025, 0064, 
+  0336, 0022, 0066, 0350, 0317, 0245, 0244, 0002, 0305, 0045, 0232, 0003, 0102, 0114, 0012, 0266, 
+  0104, 0236, 0263, 0202, 0022, 0273, 0206, 0246, 0101, 0117, 0127, 0351, 0316, 0053, 0177, 0273, 
+  0332, 0067, 0050, 0120, 0076, 0272, 0227, 0354, 0143, 0357, 0341, 0036, 0224, 0122, 0064, 0126, 
+  0374, 0362, 0105, 0175, 0007, 0107, 0333, 0274, 0311, 0327, 0202, 0273, 0052, 0147, 0025, 0030, 
+  0137, 0071, 0032, 0001, 0157, 0100, 0172, 0355, 0150, 0066, 0035, 0301, 0154, 0167, 0230, 0311, 
+  0345, 0041, 0012, 0234, 0063, 0302, 0213, 0215, 0366, 0140, 0075, 0244, 0364, 0074, 0311, 0012, 
+  0144, 0353, 0067, 0321, 0154, 0072, 0235, 0166, 0302, 0206, 0207, 0051, 0341, 0235, 0276, 0176, 
+  0061, 0350, 0175, 0037, 0150, 0200, 0055, 0375, 0114, 0170, 0302, 0243, 0173, 0070, 0271, 0057, 
+  0001, 0254, 0032, 0047, 0354, 0164, 0163, 0022, 0256, 0127, 0211, 0146, 0263, 0103, 0110, 0170, 
+  0177, 0372, 0216, 0327, 0163, 0354, 0140, 0267, 0165, 0241, 0337, 0307, 0017, 0203, 0363, 0322, 
+  0067, 0167, 0302, 0303, 0056, 0277, 0336, 0013, 0153, 0354, 0307, 0330, 0316, 0015, 0262, 0337, 
+  0205, 0307, 0074, 0023, 0217, 0172, 0346, 0044, 0213, 0314, 0136, 0142, 0221, 0323, 0373, 0377, 
+  0160, 0322, 0201, 0262, 0153, 0064, 0377, 0314, 0234, 0033, 0350, 0274, 0156, 0312, 0015, 0105, 
+  0376, 0213, 0031, 0027, 0237, 0140, 0355, 0350, 0254, 0306, 0366, 0017, 0237, 0037, 0367, 0365, 
+  0071, 0146, 0341, 0345, 0333, 0315, 0302, 0170, 0374, 0055, 0354, 0211, 0356, 0177, 0300, 0056, 
+  0176, 0003, 0003, 0135, 0215, 0340, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0155, 0141, 0164, 
+  0145, 0057, 0000, 0000, 0012, 0000, 0000, 0000, 0142, 0165, 0164, 0164, 0157, 0156, 0163, 0055, 
+  0160, 0162, 0157, 0147, 0162, 0141, 0155, 0155, 0151, 0156, 0147, 0056, 0165, 0151, 0000, 0000, 
+  0146, 0071, 0001, 0000, 0001, 0000, 0000, 0000, 0170, 0332, 0355, 0135, 0313, 0216, 0343, 0066, 
+  0026, 0335, 0347, 0053, 0024, 0055, 0202, 0004, 0201, 0272, 0054, 0311, 0162, 0331, 0235, 0262, 
+  0203, 0112, 0115, 0167, 0243, 0201, 0040, 0001, 0222, 0236, 0307, 0316, 0240, 0045, 0332, 0146, 
+  0112, 0026, 0035, 0221, 0362, 0043, 0310, 0142, 0046, 0213, 0040, 0333, 0311, 0054, 0006, 0230, 
+  0335, 0174, 0305, 0174, 0100, 0376, 0244, 0277, 0144, 0110, 0311, 0157, 0273, 0054, 0333, 0115, 
+  0221, 0125, 0054, 0256, 0312, 0045, 0121, 0022, 0171, 0317, 0341, 0345, 0345, 0021, 0171, 0165, 
+  0363, 0345, 0154, 0024, 0133, 0023, 0230, 0022, 0204, 0223, 0266, 0355, 0276, 0250, 0331, 0026, 
+  0114, 0102, 0034, 0241, 0144, 0320, 0266, 0377, 0374, 0356, 0265, 0323, 0264, 0277, 0354, 0174, 
+  0164, 0363, 0261, 0343, 0130, 0157, 0140, 0002, 0123, 0100, 0141, 0144, 0115, 0021, 0035, 0132, 
+  0203, 0030, 0104, 0320, 0362, 0137, 0370, 0315, 0027, 0236, 0345, 0070, 0254, 0020, 0112, 0050, 
+  0114, 0373, 0040, 0204, 0235, 0233, 0024, 0376, 0230, 0241, 0024, 0022, 0053, 0106, 0275, 0266, 
+  0075, 0240, 0367, 0237, 0333, 0353, 0247, 0370, 0057, 0074, 0317, 0276, 0352, 0334, 0340, 0336, 
+  0017, 0060, 0244, 0126, 0030, 0003, 0102, 0332, 0366, 0033, 0172, 0377, 0047, 0004, 0142, 0074, 
+  0260, 0055, 0024, 0265, 0355, 0160, 0010, 0122, 0020, 0262, 0033, 0166, 0131, 0155, 0140, 0067, 
+  0052, 0116, 0165, 0156, 0306, 0051, 0036, 0303, 0224, 0316, 0255, 0004, 0214, 0040, 0053, 0006, 
+  0022, 0247, 0217, 0303, 0214, 0330, 0235, 0327, 0040, 0046, 0360, 0346, 0152, 0131, 0140, 0257, 
+  0150, 0017, 0247, 0021, 0114, 0235, 0051, 0212, 0350, 0320, 0356, 0064, 0216, 0224, 0244, 0210, 
+  0306, 0320, 0266, 0150, 0012, 0022, 0022, 0003, 0012, 0172, 0061, 0073, 0070, 0207, 0304, 0266, 
+  0102, 0074, 0032, 0301, 0204, 0262, 0352, 0276, 0343, 0145, 0054, 0334, 0267, 0120, 0102, 0330, 
+  0245, 0326, 0252, 0276, 0026, 0257, 0257, 0265, 0254, 0357, 0333, 0342, 0354, 0335, 0352, 0354, 
+  0035, 0073, 0173, 0344, 0321, 0314, 0146, 0350, 0047, 0376, 0300, 0362, 0366, 0240, 0020, 0047, 
+  0016, 0377, 0151, 0167, 0100, 0030, 0102, 0102, 0160, 0212, 0040, 0161, 0102, 0020, 0207, 0031, 
+  0253, 0065, 0116, 0217, 0265, 0160, 0076, 0206, 0316, 0220, 0001, 0146, 0167, 0212, 0232, 0156, 
+  0226, 0045, 0150, 0220, 0200, 0170, 0121, 0062, 0202, 0061, 0244, 0320, 0201, 0023, 0326, 0154, 
+  0333, 0032, 0202, 0044, 0212, 0141, 0372, 0000, 0074, 0335, 0242, 0160, 0067, 0354, 0331, 0026, 
+  0231, 0202, 0361, 0030, 0062, 0040, 0023, 0314, 0261, 0336, 0272, 0047, 0153, 0344, 0030, 0063, 
+  0303, 0224, 0336, 0157, 0131, 0360, 0320, 0035, 0303, 0041, 0212, 0043, 0053, 0347, 0034, 0273, 
+  0263, 0223, 0377, 0333, 0266, 0047, 0075, 0074, 0263, 0017, 0120, 0353, 0053, 0166, 0070, 0347, 
+  0125, 0161, 0147, 0207, 0227, 0363, 0367, 0351, 0064, 0101, 0004, 0345, 0306, 0177, 0227, 0146, 
+  0307, 0154, 0177, 0006, 0355, 0070, 0052, 0011, 0005, 0224, 0121, 0337, 0356, 0260, 0076, 0100, 
+  0021, 0103, 0350, 0110, 0171, 0062, 0006, 0041, 0353, 0175, 0166, 0307, 0365, 0066, 0113, 0035, 
+  0156, 0056, 0063, 0031, 0273, 0157, 0027, 0244, 0020, 0034, 0154, 0165, 0106, 0051, 0116, 0166, 
+  0333, 0276, 0161, 0221, 0034, 0023, 0304, 0140, 0216, 0063, 0352, 0020, 0072, 0347, 0367, 0205, 
+  0111, 0264, 0327, 0260, 0007, 0353, 0136, 0124, 0274, 0227, 0377, 0156, 0331, 0007, 0356, 0334, 
+  0203, 0361, 0241, 0236, 0332, 0351, 0336, 0201, 0044, 0204, 0307, 0014, 0175, 0101, 0103, 0117, 
+  0050, 0031, 0301, 0076, 0310, 0142, 0132, 0132, 0066, 0205, 0041, 0104, 0023, 0326, 0137, 0117, 
+  0275, 0040, 0043, 0320, 0311, 0022, 0346, 0301, 0142, 0224, 0034, 0250, 0364, 0125, 0141, 0100, 
+  0166, 0031, 0010, 0357, 0031, 0177, 0366, 0256, 0207, 0263, 0061, 0353, 0154, 0345, 0140, 0365, 
+  0121, 0034, 0227, 0227, 0032, 0143, 0202, 0012, 0112, 0327, 0266, 0152, 0261, 0172, 0372, 0325, 
+  0002, 0327, 0323, 0341, 0155, 0236, 0001, 0357, 0206, 0043, 0136, 0170, 0330, 0333, 0357, 0357, 
+  0336, 0276, 0135, 0270, 0335, 0227, 0126, 0161, 0167, 0213, 0342, 0245, 0173, 0046, 0314, 0063, 
+  0205, 0174, 0354, 0132, 0071, 0032, 0106, 0221, 0342, 0122, 0103, 0221, 0252, 0051, 0342, 0036, 
+  0247, 0210, 0340, 0172, 0225, 0030, 0211, 0077, 0304, 0341, 0343, 0337, 0236, 0047, 0022, 0116, 
+  0361, 0245, 0337, 0035, 0262, 0301, 0306, 0163, 0245, 0270, 0332, 0355, 0040, 0047, 0270, 0160, 
+  0234, 0071, 0320, 0230, 0257, 0213, 0256, 0310, 0233, 0223, 0367, 0112, 0277, 0045, 0151, 0350, 
+  0270, 0320, 0003, 0344, 0365, 0265, 0172, 0260, 0217, 0123, 0270, 0021, 0234, 0261, 0053, 0322, 
+  0271, 0335, 0271, 0033, 0166, 0027, 0107, 0136, 0136, 0336, 0237, 0166, 0112, 0217, 0022, 0070, 
+  0302, 0011, 0012, 0271, 0361, 0007, 0220, 0365, 0326, 0235, 0230, 0046, 0177, 0364, 0123, 0166, 
+  0331, 0257, 0162, 0333, 0035, 0212, 0316, 0027, 0126, 0255, 0336, 0175, 0216, 0300, 0314, 0211, 
+  0141, 0062, 0340, 0344, 0166, 0037, 0214, 0131, 0171, 0200, 0063, 0141, 0063, 0225, 0322, 0370, 
+  0162, 0131, 0360, 0120, 0174, 0051, 0331, 0053, 0011, 0167, 0226, 0045, 0017, 0254, 0250, 0126, 
+  0313, 0003, 0105, 0214, 0271, 0350, 0012, 0144, 0347, 0177, 0153, 0031, 0327, 0267, 0155, 0247, 
+  0141, 0167, 0026, 0321, 0335, 0315, 0325, 0126, 0241, 0043, 0327, 0004, 0313, 0153, 0232, 0173, 
+  0327, 0134, 0355, 0076, 0170, 0125, 0263, 0075, 0072, 0377, 0025, 0045, 0021, 0236, 0026, 0174, 
+  0236, 0346, 0277, 0335, 0363, 0346, 0227, 0245, 0176, 0277, 0250, 0144, 0227, 0341, 0301, 0174, 
+  0330, 0243, 0236, 0153, 0064, 0316, 0152, 0027, 0037, 0317, 0344, 0014, 0147, 0347, 0125, 0360, 
+  0016, 0217, 0172, 0170, 0155, 0175, 0300, 0047, 0216, 0374, 0220, 0224, 0252, 0346, 0305, 0034, 
+  0106, 0275, 0060, 0106, 0341, 0375, 0201, 0362, 0252, 0034, 0312, 0205, 0336, 0176, 0143, 0300, 
+  0317, 0055, 0131, 0214, 0304, 0022, 0307, 0374, 0365, 0000, 0377, 0152, 0006, 0106, 0343, 0230, 
+  0015, 0343, 0230, 0115, 0177, 0271, 0146, 0361, 0372, 0365, 0373, 0137, 0376, 0361, 0376, 0227, 
+  0137, 0055, 0057, 0150, 0344, 0277, 0376, 0176, 0344, 0166, 0063, 0020, 0263, 0301, 0141, 0327, 
+  0205, 0075, 0156, 0067, 0372, 0064, 0050, 0162, 0313, 0015, 0073, 0312, 0205, 0241, 0234, 0046, 
+  0210, 0112, 0364, 0165, 0063, 0302, 0174, 0033, 0334, 0251, 0373, 0116, 0231, 0371, 0241, 0062, 
+  0213, 0326, 0160, 0111, 0223, 0165, 0126, 0034, 0147, 0243, 0204, 0264, 0375, 0026, 0373, 0047, 
+  0305, 0123, 0322, 0256, 0163, 0061, 0163, 0277, 0255, 0157, 0122, 0024, 0255, 0233, 0111, 0013, 
+  0211, 0256, 0212, 0146, 0076, 0030, 0175, 0161, 0005, 0156, 0355, 0334, 0130, 0045, 0162, 0115, 
+  0216, 0271, 0342, 0156, 0105, 0276, 0170, 0053, 0246, 0052, 0306, 0062, 0147, 0314, 0206, 0141, 
+  0262, 0247, 0006, 0346, 0046, 0301, 0203, 0101, 0374, 0260, 0122, 0127, 0342, 0141, 0330, 0015, 
+  0362, 0156, 0337, 0165, 0045, 0272, 0230, 0216, 0125, 0073, 0301, 0157, 0324, 0016, 0372, 0215, 
+  0223, 0273, 0154, 0014, 0373, 0324, 0001, 0224, 0202, 0160, 0067, 0146, 0335, 0325, 0144, 0361, 
+  0170, 0125, 0356, 0322, 0010, 0375, 0141, 0216, 0170, 0032, 0161, 0304, 0323, 0232, 0043, 0236, 
+  0062, 0216, 0370, 0032, 0161, 0304, 0327, 0232, 0043, 0276, 0062, 0216, 0324, 0065, 0342, 0110, 
+  0135, 0153, 0216, 0004, 0312, 0070, 0022, 0150, 0304, 0221, 0100, 0153, 0216, 0064, 0224, 0161, 
+  0244, 0241, 0021, 0107, 0032, 0132, 0163, 0344, 0132, 0031, 0107, 0256, 0065, 0342, 0310, 0265, 
+  0326, 0034, 0151, 0052, 0343, 0110, 0123, 0043, 0216, 0064, 0365, 0236, 0373, 0326, 0224, 0221, 
+  0244, 0245, 0021, 0111, 0132, 0172, 0223, 0104, 0235, 0102, 0342, 0326, 0164, 0222, 0321, 0152, 
+  0172, 0323, 0104, 0235, 0110, 0342, 0152, 0245, 0266, 0152, 0056, 0267, 0252, 0323, 0111, 0134, 
+  0235, 0004, 0127, 0127, 0157, 0305, 0325, 0125, 0047, 0225, 0270, 0072, 0151, 0256, 0256, 0336, 
+  0242, 0253, 0253, 0116, 0055, 0161, 0165, 0222, 0135, 0135, 0275, 0165, 0127, 0127, 0235, 0140, 
+  0342, 0352, 0244, 0274, 0272, 0172, 0113, 0257, 0256, 0072, 0315, 0304, 0327, 0051, 0204, 0365, 
+  0365, 0016, 0141, 0175, 0205, 0064, 0321, 0151, 0102, 0354, 0353, 0075, 0041, 0366, 0325, 0015, 
+  0072, 0236, 0116, 0352, 0232, 0247, 0267, 0274, 0346, 0253, 0013, 0141, 0075, 0235, 0224, 0172, 
+  0117, 0157, 0251, 0336, 0127, 0067, 0041, 0366, 0164, 0172, 0351, 0347, 0351, 0375, 0326, 0317, 
+  0127, 0047, 0257, 0171, 0072, 0255, 0037, 0360, 0364, 0136, 0100, 0340, 0253, 0023, 0353, 0075, 
+  0235, 0046, 0304, 0236, 0336, 0023, 0142, 0137, 0341, 0342, 0150, 0235, 0344, 0065, 0117, 0157, 
+  0171, 0315, 0127, 0267, 0214, 0300, 0323, 0111, 0254, 0367, 0364, 0026, 0353, 0075, 0165, 0272, 
+  0211, 0247, 0325, 0136, 0013, 0315, 0067, 0133, 0050, 0324, 0115, 0164, 0122, 0141, 0075, 0275, 
+  0125, 0130, 0117, 0241, 0156, 0242, 0223, 0012, 0353, 0351, 0255, 0302, 0172, 0012, 0027, 0022, 
+  0350, 0244, 0302, 0272, 0172, 0253, 0260, 0236, 0302, 0145, 0111, 0072, 0251, 0260, 0256, 0336, 
+  0052, 0254, 0247, 0160, 0221, 0243, 0116, 0052, 0254, 0253, 0267, 0012, 0353, 0051, 0134, 0062, 
+  0255, 0223, 0012, 0353, 0352, 0255, 0302, 0172, 0025, 0353, 0046, 0073, 0066, 0035, 0201, 0364, 
+  0036, 0246, 0205, 0151, 0245, 0116, 0041, 0217, 0252, 0315, 0077, 0144, 0204, 0242, 0376, 0334, 
+  0356, 0204, 0220, 0147, 0122, 0275, 0030, 0002, 0261, 0113, 0067, 0134, 0341, 0026, 0227, 0252, 
+  0024, 0327, 0236, 0234, 0301, 0175, 0361, 0153, 0145, 0264, 0312, 0235, 0340, 0233, 0044, 0054, 
+  0273, 0211, 0070, 0304, 0260, 0104, 0247, 0367, 0014, 0176, 0335, 0244, 0141, 0251, 0206, 0045, 
+  0072, 0275, 0264, 0364, 0003, 0223, 0210, 0245, 0032, 0226, 0350, 0024, 0173, 0373, 0015, 0223, 
+  0212, 0245, 0032, 0226, 0350, 0064, 0221, 0367, 0257, 0115, 0062, 0226, 0152, 0130, 0242, 0223, 
+  0052, 0350, 0067, 0115, 0072, 0226, 0152, 0130, 0242, 0323, 0053, 0006, 0277, 0145, 0022, 0262, 
+  0124, 0302, 0222, 0272, 0116, 0357, 0053, 0353, 0065, 0223, 0222, 0245, 0042, 0232, 0350, 0264, 
+  0372, 0241, 0356, 0232, 0244, 0054, 0025, 0321, 0104, 0247, 0265, 0124, 0165, 0317, 0044, 0145, 
+  0251, 0210, 0046, 0072, 0311, 0257, 0165, 0337, 0044, 0145, 0251, 0210, 0046, 0132, 0145, 0257, 
+  0255, 0233, 0244, 0054, 0025, 0321, 0104, 0047, 0001, 0266, 0036, 0230, 0244, 0054, 0025, 0321, 
+  0104, 0047, 0005, 0266, 0336, 0060, 0111, 0131, 0052, 0242, 0211, 0116, 0022, 0154, 0375, 0332, 
+  0044, 0145, 0251, 0210, 0046, 0072, 0151, 0260, 0365, 0246, 0131, 0113, 0125, 0021, 0115, 0164, 
+  0022, 0141, 0353, 0055, 0263, 0062, 0263, 0032, 0232, 0004, 0072, 0251, 0260, 0101, 0315, 0254, 
+  0363, 0256, 0210, 0046, 0072, 0251, 0260, 0201, 0153, 0166, 0215, 0124, 0104, 0023, 0235, 0124, 
+  0330, 0300, 0063, 0173, 0320, 0052, 0242, 0211, 0116, 0052, 0154, 0340, 0233, 0035, 0255, 0025, 
+  0321, 0104, 0047, 0025, 0066, 0250, 0233, 0375, 0361, 0025, 0321, 0104, 0253, 0317, 0210, 0005, 
+  0046, 0333, 0106, 0105, 0064, 0321, 0111, 0205, 0015, 0032, 0046, 0167, 0117, 0105, 0064, 0321, 
+  0111, 0205, 0015, 0256, 0115, 0046, 0260, 0212, 0150, 0242, 0223, 0012, 0033, 0064, 0115, 0136, 
+  0301, 0212, 0150, 0242, 0223, 0012, 0033, 0264, 0114, 0226, 0322, 0152, 0150, 0322, 0320, 0111, 
+  0205, 0155, 0324, 0114, 0316, 0343, 0212, 0150, 0242, 0223, 0012, 0333, 0160, 0115, 0006, 0365, 
+  0212, 0150, 0242, 0223, 0012, 0333, 0360, 0314, 0367, 0030, 0052, 0242, 0211, 0116, 0052, 0154, 
+  0303, 0067, 0137, 0167, 0371, 0000, 0232, 0034, 0111, 0021, 0042, 0325, 0115, 0327, 0257, 0037, 
+  0113, 0216, 0220, 0223, 0227, 0156, 0210, 0117, 0312, 0042, 0125, 0051, 0076, 0272, 0174, 0366, 
+  0161, 0132, 0334, 0377, 0140, 0213, 0027, 0331, 0206, 0344, 0112, 0255, 0126, 0265, 0326, 0253, 
+  0113, 0313, 0332, 0124, 0030, 0257, 0241, 0223, 0361, 0132, 0222, 0215, 0167, 0255, 0223, 0361, 
+  0134, 0331, 0324, 0153, 0152, 0145, 0075, 0331, 0334, 0153, 0351, 0144, 0075, 0117, 0062, 0367, 
+  0044, 0177, 0035, 0256, 0152, 0353, 0111, 0346, 0236, 0344, 0117, 0060, 0126, 0154, 0075, 0137, 
+  0066, 0367, 0274, 0347, 0030, 0257, 0170, 0202, 0214, 0347, 0077, 0307, 0170, 0105, 0224, 0361, 
+  0352, 0317, 0062, 0136, 0021, 0145, 0275, 0340, 0131, 0306, 0053, 0242, 0254, 0327, 0170, 0226, 
+  0361, 0212, 0050, 0353, 0135, 0077, 0313, 0170, 0105, 0224, 0365, 0232, 0317, 0062, 0136, 0021, 
+  0057, 0065, 0353, 0364, 0172, 0123, 0357, 0267, 0233, 0352, 0222, 0177, 0113, 0265, 0153, 0303, 
+  0177, 0054, 0252, 0247, 0154, 0231, 0171, 0145, 0157, 0251, 0001, 0361, 0321, 0225, 0132, 0217, 
+  0322, 0336, 0025, 0244, 0376, 0326, 0351, 0265, 0254, 0357, 0031, 0067, 0170, 0362, 0120, 0071, 
+  0216, 0101, 0010, 0207, 0070, 0216, 0140, 0172, 0145, 0116, 0232, 0223, 0346, 0244, 0071, 0151, 
+  0116, 0232, 0223, 0346, 0244, 0071, 0271, 0035, 0234, 0234, 0034, 0255, 0300, 0331, 0230, 0105, 
+  0165, 0345, 0001, 0124, 0037, 0305, 0161, 0151, 0100, 0066, 0306, 0004, 0121, 0204, 0223, 0123, 
+  0147, 0031, 0037, 0073, 0216, 0225, 0070, 0041, 0216, 0263, 0121, 0102, 0332, 0156, 0215, 0375, 
+  0223, 0342, 0051, 0151, 0007, 0226, 0343, 0034, 0010, 0040, 0337, 0244, 0050, 0052, 0342, 0107, 
+  0020, 0115, 0100, 0022, 0302, 0250, 0313, 0052, 0317, 0343, 0072, 0011, 0021, 0044, 0253, 0230, 
+  0063, 0304, 0043, 0074, 0200, 0011, 0304, 0374, 0202, 0262, 0133, 0347, 0255, 0072, 0176, 0311, 
+  0103, 0221, 0362, 0127, 0171, 0360, 0135, 0064, 0065, 0004, 0161, 0330, 0115, 0061, 0246, 0335, 
+  0042, 0044, 0267, 0037, 0212, 0155, 0337, 0377, 0366, 0237, 0043, 0325, 0271, 0300, 0042, 0045, 
+  0045, 0363, 0122, 0016, 0233, 0043, 0204, 0061, 0012, 0357, 0117, 0060, 0040, 0014, 0041, 0232, 
+  0100, 0342, 0104, 0260, 0017, 0262, 0230, 0226, 0076, 0040, 0043, 0320, 0311, 0022, 0106, 0360, 
+  0030, 0045, 0007, 0052, 0276, 0065, 0135, 0311, 0353, 0000, 0243, 0315, 0071, 0112, 0156, 0255, 
+  0103, 0363, 0223, 0107, 0225, 0376, 0174, 0017, 0352, 0030, 0017, 0100, 0212, 0350, 0160, 0124, 
+  0206, 0067, 0053, 0370, 0304, 0361, 0176, 0144, 0010, 0372, 0202, 0020, 0354, 0203, 0220, 0342, 
+  0264, 0014, 0076, 0136, 0312, 0364, 0327, 0065, 0332, 0205, 0325, 0320, 0117, 0017, 0113, 0012, 
+  0026, 0342, 0252, 0016, 0273, 0207, 0223, 0377, 0313, 0106, 0201, 0060, 0204, 0144, 0141, 0246, 
+  0035, 0134, 0156, 0351, 0375, 0267, 0371, 0201, 0207, 0160, 0141, 0250, 0337, 0027, 0227, 0354, 
+  0043, 0264, 0272, 0370, 0345, 0313, 0365, 0043, 0034, 0176, 0316, 0266, 0150, 0012, 0022, 0022, 
+  0003, 0012, 0330, 0241, 0266, 0075, 0207, 0304, 0266, 0102, 0074, 0032, 0301, 0204, 0362, 0247, 
+  0256, 0112, 0347, 0167, 0262, 0372, 0070, 0265, 0350, 0220, 0375, 0135, 0266, 0315, 0132, 0222, 
+  0342, 0365, 0362, 0210, 0202, 0017, 0065, 0324, 0005, 0361, 0074, 0001, 0064, 0113, 0101, 0174, 
+  0206, 0307, 0112, 0014, 0341, 0305, 0273, 0267, 0246, 0144, 0367, 0006, 0172, 0344, 0101, 0240, 
+  0015, 0210, 0347, 0250, 0240, 0362, 0227, 0305, 0377, 0374, 0111, 0114, 0277, 0100, 0237, 0014, 
+  0350, 0027, 0063, 0376, 0353, 0052, 0377, 0371, 0163, 0211, 0165, 0370, 0313, 0225, 0154, 0274, 
+  0137, 0233, 0075, 0167, 0045, 0304, 0113, 0257, 0351, 0045, 0325, 0105, 0263, 0307, 0262, 0200, 
+  0235, 0102, 0153, 0002, 0342, 0154, 0355, 0247, 0157, 0227, 0207, 0377, 0302, 0017, 0013, 0164, 
+  0326, 0255, 0152, 0137, 0327, 0354, 0365, 0132, 0216, 0312, 0000, 0246, 0335, 0061, 0116, 0371, 
+  0014, 0255, 0314, 0125, 0263, 0342, 0306, 0127, 0213, 0367, 0325, 0055, 0331, 0241, 0150, 0312, 
+  0342, 0014, 0006, 0067, 0033, 0245, 0117, 0004, 0236, 0137, 0141, 0220, 0127, 0207, 0274, 0250, 
+  0340, 0054, 0102, 0023, 0024, 0301, 0062, 0264, 0377, 0370, 0237, 0301, 0132, 0074, 0326, 0165, 
+  0311, 0276, 0175, 0304, 0114, 0203, 0306, 0361, 0274, 0024, 0355, 0177, 0033, 0264, 0325, 0241, 
+  0055, 0112, 0040, 0042, 0131, 0217, 0162, 0267, 0136, 0256, 0007, 0376, 0156, 0340, 0136, 0303, 
+  0275, 0062, 0233, 0064, 0300, 0205, 0115, 0270, 0242, 0250, 0014, 0353, 0317, 0015, 0322, 0352, 
+  0072, 0266, 0250, 0041, 0073, 0205, 0204, 0031, 0247, 0004, 0352, 0343, 0263, 0233, 0174, 0162, 
+  0151, 0341, 0044, 0237, 0322, 0260, 0231, 0313, 0144, 0071, 0223, 0261, 0076, 0315, 0355, 0304, 
+  0052, 0306, 0116, 0041, 0122, 0234, 0043, 0171, 0261, 0010, 0221, 0161, 0014, 0346, 0060, 0262, 
+  0170, 0055, 0062, 0166, 0153, 0026, 0046, 0176, 0146, 0167, 0332, 0206, 0123, 0033, 0336, 0203, 
+  0333, 0353, 0020, 0245, 0010, 0235, 0307, 0220, 0201, 0314, 0141, 0135, 0134, 0115, 0262, 0301, 
+  0000, 0022, 0012, 0043, 0247, 0010, 0276, 0163, 0346, 0055, 0312, 0125, 0363, 0201, 0136, 0121, 
+  0014, 0014, 0143, 0010, 0322, 0363, 0011, 0330, 0271, 0343, 0327, 0031, 0272, 0254, 0351, 0122, 
+  0030, 0362, 0064, 0272, 0104, 0214, 0053, 0151, 0306, 0230, 0062, 0201, 0322, 0010, 0043, 0152, 
+  0150, 0162, 0313, 0006, 0046, 0327, 0260, 0142, 0315, 0212, 0010, 0015, 0220, 0200, 0370, 0303, 
+  0225, 0354, 0025, 0274, 0062, 0220, 0075, 0003, 0262, 0160, 0220, 0075, 0311, 0040, 0373, 0145, 
+  0040, 0373, 0006, 0144, 0341, 0040, 0373, 0222, 0101, 0016, 0312, 0100, 0016, 0014, 0310, 0312, 
+  0334, 0265, 0250, 0061, 0271, 0121, 0006, 0162, 0303, 0200, 0254, 0314, 0135, 0213, 0002, 0371, 
+  0272, 0014, 0344, 0153, 0003, 0262, 0062, 0167, 0055, 0012, 0344, 0126, 0031, 0310, 0055, 0003, 
+  0262, 0062, 0167, 0055, 0112, 0316, 0165, 0153, 0145, 0050, 0337, 0032, 0224, 0225, 0371, 0153, 
+  0141, 0050, 0227, 0316, 0224, 0277, 0062, 0050, 0053, 0163, 0330, 0302, 0120, 0056, 0235, 0105, 
+  0375, 0311, 0240, 0254, 0314, 0143, 0213, 0172, 0335, 0352, 0326, 0313, 0120, 0176, 0145, 0120, 
+  0126, 0346, 0261, 0205, 0241, 0134, 0072, 0131, 0176, 0155, 0120, 0126, 0346, 0261, 0057, 0104, 
+  0371, 0135, 0276, 0151, 0375, 0300, 0053, 0165, 0166, 0047, 0022, 0246, 0150, 0114, 0237, 0364, 
+  0322, 0326, 0262, 0227, 0130, 0220, 0156, 0065, 0365, 0003, 0126, 0255, 0112, 0115, 0372, 0360, 
+  0376, 0327, 0177, 0046, 0217, 0152, 0215, 0352, 0076, 0137, 0244, 0256, 0125, 0335, 0170, 0274, 
+  0065, 0302, 0321, 0172, 0265, 0352, 0367, 0353, 0023, 0042, 0277, 0121, 0137, 0155, 0052, 0227, 
+  0375, 0175, 0005, 0331, 0010, 0246, 0050, 0354, 0216, 0061, 0203, 0251, 0354, 0155, 0344, 0356, 
+  0273, 0157, 0376, 0156, 0033, 0122, 0006, 0260, 0065, 0240, 0367, 0057, 0102, 0213, 0142, 0136, 
+  0144, 0034, 0317, 0255, 0051, 0242, 0103, 0353, 0353, 0073, 0253, 0037, 0203, 0001, 0343, 0336, 
+  0013, 0343, 0275, 0327, 0236, 0141, 0333, 0344, 0322, 0306, 0152, 0121, 0214, 0031, 0301, 0021, 
+  0116, 0347, 0072, 0273, 0356, 0105, 0013, 0317, 0360, 0330, 0253, 0334, 0061, 0303, 0036, 0236, 
+  0171, 0162, 0222, 0042, 0021, 0006, 0041, 0103, 0160, 0147, 0030, 0077, 0071, 0243, 0260, 0314, 
+  0101, 0345, 0270, 0347, 0175, 0307, 0274, 0154, 0274, 0271, 0226, 0246, 0260, 0377, 0312, 0321, 
+  0316, 0316, 0312, 0033, 0264, 0334, 0143, 0135, 0106, 0252, 0363, 0266, 0130, 0137, 0330, 0171, 
+  0156, 0323, 0024, 0117, 0027, 0273, 0250, 0371, 0117, 0127, 0116, 0116, 0316, 0374, 0131, 0016, 
+  0235, 0217, 0331, 0135, 0043, 0074, 0115, 0056, 0062, 0240, 0334, 0115, 0352, 0325, 0304, 0016, 
+  0133, 0276, 0112, 0156, 0330, 0100, 0161, 0272, 0273, 0277, 0345, 0173, 0176, 0114, 0344, 0367, 
+  0105, 0044, 0173, 0376, 0131, 0371, 0106, 0333, 0277, 0175, 0373, 0235, 0031, 0352, 0305, 0257, 
+  0216, 0014, 0044, 0277, 0273, 0056, 0007, 0332, 0340, 0254, 0022, 0147, 0141, 0253, 0235, 0223, 
+  0322, 0325, 0316, 0267, 0337, 0030, 0031, 0125, 0041, 0322, 0242, 0324, 0162, 0066, 0165, 0315, 
+  0342, 0214, 0234, 0270, 0125, 0211, 0225, 0066, 0240, 0253, 0003, 0135, 0224, 0254, 0112, 0050, 
+  0110, 0151, 0167, 0220, 0342, 0154, 0134, 0206, 0370, 0247, 0006, 0157, 0165, 0233, 0032, 0104, 
+  0005, 0150, 0220, 0271, 0363, 0223, 0320, 0376, 0314, 0240, 0255, 0256, 0167, 0213, 0102, 0233, 
+  0014, 0121, 0237, 0166, 0171, 0025, 0264, 0326, 0321, 0327, 0255, 0274, 0124, 0220, 0161, 0335, 
+  0047, 0040, 0310, 0134, 0313, 0100, 0157, 0321, 0375, 0171, 0072, 0012, 0175, 0104, 0225, 0300, 
+  0150, 0052, 0062, 0065, 0225, 0075, 0267, 0043, 0127, 0127, 0341, 0117, 0267, 0370, 0323, 0327, 
+  0262, 0112, 0176, 0350, 0153, 0166, 0110, 0240, 0266, 0322, 0120, 0342, 0314, 0123, 0064, 0030, 
+  0076, 0003, 0157, 0136, 0064, 0363, 0142, 0167, 0376, 0024, 0364, 0365, 0206, 0114, 0167, 0076, 
+  0320, 0311, 0235, 0033, 0211, 0134, 0201, 0073, 0337, 0164, 0074, 0012, 0374, 0171, 0376, 0370, 
+  0035, 0207, 0376, 0035, 0077, 0246, 0040, 0143, 0237, 0260, 0067, 0353, 0345, 0131, 0144, 0277, 
+  0371, 0366, 0235, 0231, 0210, 0211, 0237, 0210, 0065, 0044, 0153, 0153, 0213, 0214, 0223, 0040, 
+  0326, 0171, 0344, 0026, 0220, 0174, 0117, 0352, 0007, 0011, 0017, 0045, 0337, 0373, 0370, 0121, 
+  0055, 0154, 0332, 0245, 0215, 0212, 0054, 0251, 0014, 0360, 0235, 0054, 0251, 0040, 0026, 0350, 
+  0163, 0233, 0222, 0337, 0133, 0241, 0144, 0002, 0123, 0002, 0115, 0077, 0074, 0272, 0364, 0243, 
+  0246, 0272, 0037, 0362, 0137, 0044, 0033, 0363, 0237, 0357, 0177, 0373, 0335, 0315, 0117, 0054, 
+  0376, 0277, 0260, 0207, 0236, 0376, 0161, 0252, 0152, 0372, 0362, 0066, 0361, 0244, 0366, 0344, 
+  0305, 0243, 0127, 0375, 0370, 0155, 0361, 0277, 0202, 0364, 0231, 0242, 0306, 0323, 0131, 0167, 
+  0214, 0247, 0335, 0271, 0351, 0305, 0017, 0364, 0342, 0245, 0175, 0026, 0075, 0354, 0321, 0364, 
+  0345, 0325, 0351, 0371, 0366, 0351, 0017, 0354, 0333, 0325, 0364, 0330, 0155, 0222, 0111, 0355, 
+  0261, 0154, 0372, 0210, 0023, 0126, 0004, 0345, 0331, 0237, 0254, 0117, 0147, 0174, 0341, 0054, 
+  0077, 0301, 0152, 0004, 0123, 0013, 0367, 0255, 0371, 0147, 0253, 0356, 0374, 0152, 0121, 0130, 
+  0301, 0250, 0054, 0252, 0077, 0263, 0372, 0223, 0156, 0276, 0060, 0030, 0162, 0313, 0224, 0315, 
+  0212, 0170, 0161, 0063, 0055, 0122, 0067, 0055, 0022, 0365, 0366, 0231, 0116, 0361, 0071, 0260, 
+  0363, 0342, 0006, 0166, 0165, 0137, 0344, 0020, 0275, 0313, 0247, 0367, 0134, 0366, 0370, 0364, 
+  0076, 0174, 0207, 0117, 0135, 0356, 0016, 0237, 0177, 0075, 0266, 0035, 0076, 0075, 0225, 0373, 
+  0173, 0172, 0207, 0167, 0367, 0364, 0204, 0357, 0355, 0251, 0111, 0126, 0040, 0335, 0322, 0144, 
+  0142, 0167, 0306, 0341, 0012, 0337, 0125, 0131, 0223, 0074, 0314, 0066, 0313, 0100, 0156, 0032, 
+  0220, 0225, 0201, 0054, 0052, 0204, 0056, 0335, 0005, 0137, 0067, 0040, 0053, 0003, 0131, 0324, 
+  0152, 0354, 0322, 0344, 0064, 0307, 0052, 0064, 0105, 0021, 0035, 0072, 0051, 0374, 0061, 0203, 
+  0204, 0331, 0067, 0250, 0031, 0102, 0050, 0043, 0204, 0260, 0024, 0301, 0103, 0300, 0263, 0250, 
+  0303, 0322, 0335, 0030, 0177, 0374, 0127, 0357, 0257, 0023, 0242, 0204, 0260, 0162, 0033, 0366, 
+  0010, 0131, 0254, 0126, 0331, 0267, 0353, 0166, 0315, 0056, 0131, 0316, 0345, 0115, 0265, 0126, 
+  0165, 0330, 0320, 0165, 0363, 0023, 0167, 0313, 0023, 0012, 0004, 0241, 0323, 0102, 0226, 0017, 
+  0371, 0224, 0256, 0334, 0025, 0053, 0336, 0231, 0013, 0056, 0326, 0007, 0162, 0206, 0365, 0131, 
+  0123, 0072, 0037, 0375, 0037, 0370, 0335, 0211, 0060, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 
+  0157, 0162, 0147, 0057, 0005, 0000, 0000, 0000, 0057, 0000, 0000, 0000, 0007, 0000, 0000, 0000, 
+  0142, 0165, 0164, 0164, 0157, 0156, 0163, 0055, 0146, 0151, 0156, 0141, 0156, 0143, 0151, 0141, 
+  0154, 0056, 0165, 0151, 0000, 0000, 0000, 0000, 0126, 0127, 0001, 0000, 0001, 0000, 0000, 0000, 
+  0170, 0332, 0355, 0135, 0351, 0216, 0343, 0270, 0021, 0376, 0237, 0247, 0140, 0014, 0044, 0331, 
+  0105, 0332, 0335, 0355, 0253, 0217, 0311, 0264, 0203, 0311, 0314, 0356, 0040, 0300, 0154, 0062, 
+  0310, 0116, 0022, 0344, 0227, 0100, 0113, 0264, 0315, 0264, 0044, 0152, 0105, 0311, 0156, 0357, 
+  0023, 0344, 0137, 0200, 0374, 0131, 0040, 0057, 0222, 0007, 0310, 0233, 0344, 0111, 0122, 0044, 
+  0045, 0265, 0344, 0113, 0076, 0144, 0133, 0007, 0007, 0003, 0264, 0114, 0221, 0022, 0305, 0072, 
+  0130, 0254, 0257, 0130, 0174, 0373, 0333, 0027, 0307, 0106, 0063, 0342, 0163, 0312, 0334, 0247, 
+  0126, 0347, 0372, 0266, 0205, 0210, 0153, 0062, 0213, 0272, 0223, 0247, 0326, 0237, 0277, 0174, 
+  0333, 0176, 0150, 0375, 0166, 0370, 0263, 0267, 0077, 0157, 0267, 0321, 0107, 0342, 0022, 0037, 
+  0007, 0304, 0102, 0163, 0032, 0114, 0321, 0304, 0306, 0026, 0101, 0275, 0353, 0156, 0367, 0272, 
+  0203, 0332, 0155, 0250, 0104, 0335, 0200, 0370, 0143, 0154, 0222, 0341, 0133, 0237, 0374, 0020, 
+  0122, 0237, 0160, 0144, 0323, 0321, 0123, 0153, 0022, 0074, 0377, 0272, 0365, 0372, 0026, 0321, 
+  0246, 0165, 0063, 0174, 0313, 0106, 0177, 0047, 0146, 0200, 0114, 0033, 0163, 0376, 0324, 0372, 
+  0030, 0074, 0177, 0240, 0330, 0146, 0223, 0026, 0242, 0326, 0123, 0313, 0014, 0174, 0307, 0260, 
+  0124, 0301, 0360, 0255, 0347, 0063, 0217, 0370, 0301, 0002, 0271, 0330, 0041, 0160, 0023, 0273, 
+  0306, 0230, 0231, 0041, 0157, 0015, 0277, 0305, 0066, 0047, 0157, 0157, 0342, 0012, 0053, 0125, 
+  0107, 0314, 0267, 0210, 0157, 0314, 0251, 0025, 0114, 0133, 0303, 0273, 0055, 0065, 0003, 0032, 
+  0330, 0244, 0205, 0002, 0037, 0273, 0334, 0306, 0001, 0036, 0331, 0120, 0270, 0040, 0274, 0205, 
+  0114, 0346, 0070, 0304, 0015, 0240, 0223, 0137, 0104, 0035, 0304, 0306, 0350, 0075, 0163, 0074, 
+  0026, 0272, 0142, 0234, 0320, 0027, 0342, 0073, 0050, 0356, 0352, 0362, 0215, 0055, 0057, 0204, 
+  0361, 0241, 0077, 0212, 0327, 0344, 0177, 0005, 0065, 0231, 0153, 0210, 0313, 0326, 0020, 0233, 
+  0046, 0341, 0234, 0371, 0224, 0360, 0266, 0211, 0155, 0063, 0204, 0276, 0062, 0177, 0333, 0167, 
+  0055, 0074, 0142, 0114, 0201, 0070, 0255, 0241, 0352, 0144, 0272, 0056, 0247, 0023, 0027, 0333, 
+  0257, 0035, 0362, 0230, 0313, 0141, 0020, 0246, 0330, 0265, 0154, 0342, 0077, 0265, 0306, 0324, 
+  0065, 0215, 0270, 0334, 0060, 0107, 0055, 0304, 0347, 0330, 0363, 0010, 0120, 0310, 0145, 0202, 
+  0210, 0346, 0224, 0332, 0026, 0274, 0323, 0006, 0272, 0117, 0231, 0015, 0143, 0015, 0205, 0067, 
+  0121, 0251, 0374, 0203, 0044, 0137, 0300, 0133, 0332, 0362, 0347, 0123, 0153, 0066, 0142, 0057, 
+  0255, 0065, 0344, 0377, 0035, 0024, 0113, 0332, 0253, 0156, 0266, 0105, 0275, 0316, 0052, 0361, 
+  0147, 0224, 0123, 0071, 0150, 0137, 0374, 0160, 0333, 0230, 0355, 0301, 0044, 0142, 0064, 0335, 
+  0000, 0007, 0300, 0236, 0255, 0041, 0360, 0151, 0100, 0141, 0144, 0323, 0365, 0327, 0177, 0010, 
+  0066, 0105, 0013, 0003, 0373, 0004, 0257, 0375, 0236, 0060, 0010, 0230, 0273, 0374, 0125, 0251, 
+  0106, 0347, 0371, 0070, 0033, 0057, 0130, 0030, 0030, 0074, 0130, 0210, 0347, 0022, 0327, 0132, 
+  0371, 0260, 0215, 0175, 0127, 0035, 0037, 0311, 0353, 0065, 0235, 0265, 0361, 0210, 0330, 0353, 
+  0044, 0146, 0150, 0274, 0307, 0256, 0111, 0354, 0055, 0275, 0072, 0340, 0103, 0167, 0250, 0151, 
+  0221, 0061, 0016, 0355, 0040, 0267, 0256, 0117, 0114, 0102, 0147, 0204, 0277, 0066, 0310, 0033, 
+  0305, 0020, 0330, 0037, 0304, 0232, 0370, 0066, 0165, 0327, 0364, 0372, 0106, 0215, 0040, 0064, 
+  0303, 0346, 0063, 0310, 0376, 0112, 0173, 0362, 0342, 0201, 0114, 0345, 0277, 0147, 0114, 0155, 
+  0073, 0277, 0226, 0307, 0070, 0125, 0334, 0172, 0233, 0351, 0105, 0362, 0366, 0214, 0004, 0356, 
+  0104, 0337, 0356, 0036, 0364, 0115, 0151, 0304, 0025, 0105, 0250, 0224, 0370, 0033, 0364, 0076, 
+  0322, 0115, 0004, 0251, 0347, 0203, 0152, 0064, 0342, 0042, 0315, 0027, 0047, 0347, 0213, 0316, 
+  0166, 0276, 0050, 0270, 0137, 0071, 0303, 0052, 0136, 0142, 0210, 0171, 0150, 0105, 0377, 0024, 
+  0315, 0327, 0037, 0175, 0152, 0051, 0256, 0226, 0354, 0172, 0036, 0015, 0273, 0273, 0215, 0341, 
+  0263, 0271, 0301, 0341, 0143, 0340, 0133, 0266, 0127, 0064, 0231, 0035, 0072, 0356, 0206, 0272, 
+  0233, 0076, 0376, 0033, 0067, 0360, 0027, 0051, 0363, 0311, 0223, 0223, 0376, 0351, 0045, 0214, 
+  0272, 0321, 0063, 0015, 0163, 0212, 0375, 0326, 0360, 0177, 0077, 0375, 0163, 0233, 0075, 0102, 
+  0136, 0202, 0045, 0372, 0056, 0163, 0201, 0117, 0035, 0354, 0057, 0014, 0151, 0365, 0210, 0371, 
+  0162, 0246, 0224, 0117, 0076, 0045, 0070, 0201, 0046, 0326, 0216, 0155, 0063, 0266, 0117, 0124, 
+  0165, 0305, 0366, 0211, 0313, 0327, 0331, 0076, 0271, 0102, 0144, 0223, 0161, 0140, 0340, 0040, 
+  0300, 0346, 0164, 0111, 0042, 0227, 0307, 0204, 0171, 0353, 0353, 0355, 0316, 0371, 0313, 0304, 
+  0037, 0317, 0064, 0351, 0253, 0106, 0372, 0156, 0061, 0244, 0367, 0064, 0351, 0053, 0107, 0372, 
+  0336, 0141, 0244, 0377, 0244, 0114, 0064, 0101, 0172, 0151, 0255, 0075, 0236, 0145, 0302, 0003, 
+  0072, 0115, 0250, 0153, 0100, 0377, 0241, 0343, 0203, 0374, 0212, 0043, 0006, 0026, 0240, 0223, 
+  0123, 0367, 0050, 0153, 0363, 0003, 0341, 0246, 0117, 0075, 0141, 0073, 0210, 0345, 0171, 0274, 
+  0060, 0226, 0246, 0104, 0142, 0211, 0162, 0024, 0114, 0011, 0162, 0103, 0147, 0104, 0174, 0131, 
+  0053, 0365, 0064, 0350, 0011, 0145, 0026, 0107, 0056, 0021, 0313, 0153, 0340, 0045, 0024, 0060, 
+  0130, 0360, 0231, 0260, 0114, 0343, 0004, 0141, 0027, 0256, 0301, 0056, 0014, 0104, 0077, 0104, 
+  0123, 0017, 0326, 0304, 0342, 0162, 0206, 0355, 0220, 0210, 0252, 0030, 0215, 0303, 0040, 0364, 
+  0211, 0052, 0271, 0102, 0070, 0020, 0105, 0364, 0205, 0104, 0313, 0106, 0150, 0213, 0204, 0367, 
+  0104, 0274, 0150, 0315, 0213, 0257, 0267, 0014, 0314, 0334, 0307, 0136, 0056, 0365, 0034, 0374, 
+  0242, 0014, 0020, 0051, 0215, 0100, 0303, 0376, 0355, 0136, 0166, 0150, 0206, 0151, 0157, 0167, 
+  0144, 0332, 0155, 0365, 0042, 0153, 0250, 0133, 0014, 0137, 0337, 0235, 0151, 0251, 0174, 0004, 
+  0013, 0312, 0056, 0243, 0021, 0031, 0063, 0237, 0104, 0124, 0245, 0346, 0022, 0361, 0251, 0353, 
+  0205, 0240, 0006, 0077, 0307, 0167, 0177, 0037, 0337, 0065, 0376, 0004, 0267, 0337, 0034, 0276, 
+  0316, 0130, 0346, 0006, 0227, 0070, 0314, 0245, 0246, 0140, 0211, 0011, 0201, 0067, 0046, 0366, 
+  0340, 0226, 0106, 0057, 0330, 0006, 0335, 0270, 0154, 0172, 0237, 0204, 0161, 0072, 0305, 0160, 
+  0105, 0247, 0152, 0154, 0221, 0326, 0021, 0061, 0063, 0030, 0337, 0252, 0302, 0277, 0210, 0302, 
+  0123, 0263, 0300, 0170, 0126, 0016, 0006, 0050, 0110, 0055, 0014, 0252, 0246, 0026, 0062, 0323, 
+  0106, 0254, 0015, 0242, 0102, 0343, 0054, 0034, 0340, 0225, 0204, 0003, 0172, 0005, 0071, 0050, 
+  0162, 0006, 0141, 0067, 0377, 0304, 0336, 0156, 0223, 0270, 0100, 0171, 0163, 0333, 0152, 0204, 
+  0371, 0322, 0157, 0024, 0073, 0316, 0237, 0132, 0155, 0320, 0124, 0221, 0037, 0365, 0355, 0115, 
+  0246, 0322, 0226, 0066, 0203, 0270, 0115, 0167, 0245, 0315, 0315, 0362, 0213, 0223, 0236, 0155, 
+  0105, 0125, 0054, 0153, 0124, 0142, 0120, 0345, 0003, 0013, 0341, 0176, 0373, 0003, 0061, 0201, 
+  0277, 0205, 0040, 0175, 0040, 0040, 0060, 0046, 0225, 0166, 0134, 0202, 0260, 0154, 0255, 0245, 
+  0341, 0226, 0243, 0340, 0226, 0156, 0235, 0341, 0226, 0156, 0225, 0340, 0226, 0236, 0206, 0133, 
+  0152, 0015, 0267, 0364, 0017, 0203, 0133, 0266, 0253, 0110, 0215, 0275, 0150, 0354, 0245, 0064, 
+  0330, 0113, 0267, 0121, 0330, 0313, 0362, 0312, 0344, 0276, 0336, 0216, 0270, 0335, 0364, 0320, 
+  0036, 0136, 0071, 0053, 0335, 0036, 0333, 0066, 0233, 0213, 0051, 0015, 0211, 0037, 0360, 0237, 
+  0163, 0260, 0214, 0141, 0005, 0205, 0060, 0342, 0036, 0124, 0033, 0123, 0142, 0105, 0076, 0026, 
+  0361, 0340, 0200, 0072, 0344, 0012, 0205, 0134, 0164, 0104, 0076, 0114, 0365, 0316, 0112, 0172, 
+  0067, 0302, 0266, 0174, 0234, 0103, 0202, 0251, 0166, 0266, 0155, 0301, 0017, 0304, 0002, 0301, 
+  0246, 0143, 0242, 0001, 0204, 0346, 0141, 0107, 0202, 0366, 0046, 0343, 0032, 0062, 0156, 0040, 
+  0144, 0054, 0150, 0257, 0364, 0251, 0246, 0176, 0103, 0241, 0303, 0316, 0155, 0151, 0234, 0251, 
+  0273, 0131, 0027, 0031, 0317, 0252, 0230, 0264, 0022, 0217, 0372, 0047, 0370, 0161, 0102, 0077, 
+  0152, 0074, 0111, 0326, 0312, 0225, 0336, 0351, 0124, 0231, 0374, 0221, 0055, 0030, 0063, 0200, 
+  0002, 0330, 0116, 0314, 0002, 0352, 0235, 0225, 0360, 0246, 0357, 0312, 0004, 0017, 0125, 0346, 
+  0001, 0141, 0273, 0304, 0034, 0360, 0336, 0200, 0037, 0047, 0246, 0277, 0170, 0137, 0045, 0340, 
+  0324, 0332, 0142, 0051, 0275, 0003, 0260, 0224, 0176, 0121, 0130, 0312, 0170, 0126, 0142, 0050, 
+  0045, 0215, 0051, 0047, 0310, 0111, 0272, 0120, 0003, 0045, 0107, 0001, 0045, 0275, 0072, 0003, 
+  0045, 0275, 0052, 0001, 0045, 0003, 0015, 0224, 0324, 0032, 0050, 0271, 0073, 0014, 0050, 0311, 
+  0050, 0100, 0215, 0213, 0150, 0134, 0244, 0064, 0270, 0110, 0257, 0251, 0173, 0122, 0300, 0140, 
+  0162, 0265, 0167, 0251, 0041, 0336, 0245, 0054, 0335, 0365, 0116, 0244, 0146, 0102, 0012, 0202, 
+  0364, 0216, 0246, 0174, 0123, 0000, 0205, 0025, 0237, 0142, 0277, 0064, 0376, 0244, 0265, 0366, 
+  0140, 0251, 0103, 0366, 0043, 0265, 0131, 0057, 0047, 0363, 0240, 0102, 0014, 0361, 0272, 0121, 
+  0050, 0336, 0034, 0024, 0273, 0227, 0377, 0220, 0334, 0121, 0154, 0301, 0117, 0313, 0006, 0156, 
+  0255, 0174, 0314, 0235, 0156, 0275, 0103, 0143, 0326, 0062, 0326, 0036, 0221, 0060, 0231, 0075, 
+  0042, 0120, 0067, 0273, 0367, 0154, 0204, 0071, 0261, 0144, 0130, 0014, 0342, 0104, 0070, 0333, 
+  0104, 0025, 0362, 0103, 0010, 0223, 0210, 0207, 0027, 0262, 0013, 0152, 0357, 0331, 0006, 0165, 
+  0306, 0146, 0300, 0270, 0331, 0155, 0160, 0121, 0273, 0024, 0227, 0313, 0012, 0320, 0312, 0321, 
+  0221, 0062, 0071, 0274, 0334, 0253, 0342, 0004, 0027, 0023, 0074, 0213, 0226, 0301, 0215, 0317, 
+  0352, 0306, 0211, 0047, 0065, 0107, 0243, 0046, 0027, 0105, 0115, 0006, 0007, 0240, 0046, 0167, 
+  0105, 0241, 0046, 0023, 0257, 0314, 0151, 0275, 0076, 0372, 0214, 0163, 0364, 0331, 0147, 0143, 
+  0032, 0240, 0357, 0344, 0304, 0220, 0240, 0047, 0153, 0356, 0151, 0020, 0345, 0270, 0344, 0136, 
+  0267, 0265, 0316, 0356, 0165, 0133, 0251, 0364, 0136, 0217, 0032, 0107, 0251, 0167, 0176, 0257, 
+  0333, 0303, 0200, 0224, 0165, 0052, 0121, 0343, 0051, 0032, 0117, 0051, 0117, 0216, 0257, 0333, 
+  0106, 0157, 0064, 0351, 0327, 0174, 0247, 0311, 0066, 0375, 0263, 0307, 0252, 0032, 0314, 0034, 
+  0154, 0213, 0015, 0370, 0324, 0124, 0253, 0152, 0270, 0144, 0126, 0150, 0006, 0127, 0257, 0113, 
+  0152, 0121, 0057, 0052, 0125, 0301, 0144, 0040, 0035, 0262, 0160, 0216, 0135, 0221, 0367, 0166, 
+  0042, 0273, 0342, 0251, 0256, 0250, 0357, 0324, 0013, 0344, 0215, 0276, 0177, 0141, 0351, 0353, 
+  0355, 0004, 0315, 0334, 0116, 0040, 0150, 0257, 0004, 0104, 0123, 0277, 0041, 0250, 0337, 0312, 
+  0274, 0124, 0236, 0130, 0342, 0155, 0123, 0310, 0305, 0042, 0210, 0143, 0365, 0130, 0253, 0204, 
+  0114, 0375, 0307, 0352, 0021, 0135, 0351, 0251, 0304, 0031, 0252, 0252, 0026, 0107, 0370, 0362, 
+  0200, 0164, 0365, 0115, 0251, 0363, 0170, 0110, 0116, 0235, 0333, 0242, 0134, 0232, 0236, 0023, 
+  0224, 0330, 0245, 0271, 0354, 0334, 0117, 0374, 0231, 0313, 0067, 0264, 0063, 0363, 0050, 0147, 
+  0146, 0277, 0316, 0276, 0314, 0176, 0225, 0134, 0231, 0367, 0332, 0223, 0131, 0153, 0117, 0346, 
+  0303, 0141, 0216, 0314, 0025, 0105, 0250, 0275, 0230, 0332, 0213, 0131, 0032, 0057, 0146, 0277, 
+  0321, 0116, 0314, 0116, 0315, 0235, 0230, 0033, 0165, 0317, 0036, 0036, 0114, 0354, 0260, 0120, 
+  0045, 0237, 0226, 0176, 0312, 0345, 0140, 0016, 0351, 0323, 0264, 0031, 0166, 0257, 0320, 0174, 
+  0112, 0104, 0270, 0107, 0022, 0016, 0044, 0027, 0071, 0026, 0021, 0161, 0101, 0242, 0051, 0060, 
+  0266, 0014, 0032, 0202, 0065, 0303, 0122, 0354, 0317, 0065, 0072, 0261, 0073, 0363, 0162, 0153, 
+  0243, 0263, 0270, 0074, 0305, 0112, 0300, 0363, 0265, 0323, 0253, 0211, 0056, 0117, 0111, 0173, 
+  0275, 0315, 0241, 0221, 0333, 0034, 0004, 0355, 0265, 0320, 0067, 0065, 0161, 0116, 0267, 0074, 
+  0231, 0123, 0066, 0332, 0031, 0031, 0217, 0247, 0210, 0354, 0115, 0374, 0235, 0042, 0131, 0371, 
+  0011, 0335, 0334, 0122, 0064, 0352, 0025, 0277, 0376, 0130, 0061, 0162, 0227, 0155, 0143, 0113, 
+  0074, 0123, 0326, 0153, 0147, 0313, 0103, 0325, 0270, 0002, 0354, 0124, 0223, 0172, 0240, 0226, 
+  0223, 0060, 0360, 0270, 0344, 0324, 0264, 0367, 0251, 0253, 0043, 0300, 0057, 0011, 0230, 0334, 
+  0037, 0200, 0227, 0074, 0024, 0006, 0227, 0224, 0071, 0157, 0116, 0174, 0026, 0107, 0066, 0161, 
+  0116, 0246, 0124, 0343, 0044, 0107, 0341, 0044, 0203, 0072, 0343, 0044, 0203, 0052, 0341, 0044, 
+  0072, 0342, 0273, 0336, 0070, 0111, 0347, 0300, 0210, 0357, 0254, 0016, 0324, 0050, 0211, 0106, 
+  0111, 0112, 0203, 0222, 0014, 0032, 0215, 0222, 0364, 0356, 0152, 0216, 0222, 0254, 0125, 0074, 
+  0173, 0100, 0044, 0331, 0343, 0325, 0016, 0332, 0073, 0155, 0121, 0156, 0012, 0234, 0005, 0052, 
+  0026, 0270, 0215, 0132, 0343, 0052, 0307, 0371, 0127, 0165, 0032, 0231, 0246, 0242, 0052, 0072, 
+  0167, 0124, 0143, 0101, 0025, 0235, 0056, 0256, 0301, 0230, 0112, 0171, 0116, 0366, 0135, 0157, 
+  0225, 0224, 0060, 0123, 0220, 0127, 0267, 0114, 0101, 0335, 0101, 0225, 0230, 0240, 0164, 0060, 
+  0113, 0015, 0363, 0207, 0165, 0373, 0225, 0344, 0210, 0013, 0046, 0334, 0361, 0164, 0302, 0235, 
+  0213, 0303, 0055, 0207, 0154, 0117, 0351, 0024, 0266, 0075, 0105, 0150, 0241, 0052, 0354, 0117, 
+  0111, 0024, 0243, 0320, 0213, 0253, 0273, 0124, 0062, 0267, 0065, 0006, 0163, 0024, 0006, 0163, 
+  0127, 0147, 0014, 0346, 0256, 0122, 0151, 0167, 0072, 0032, 0204, 0251, 0067, 0010, 0323, 0075, 
+  0162, 0267, 0112, 0126, 0055, 0152, 0064, 0106, 0243, 0061, 0245, 0101, 0143, 0356, 0032, 0215, 
+  0306, 0164, 0037, 0032, 0262, 0147, 0145, 0275, 0006, 0332, 0007, 0226, 0131, 0131, 0031, 0273, 
+  0104, 0230, 0133, 0330, 0137, 0240, 0200, 0101, 0251, 0011, 0323, 0066, 0047, 0113, 0150, 0015, 
+  0334, 0301, 0231, 0144, 0270, 0127, 0353, 0120, 0027, 0350, 0257, 0307, 0100, 0105, 0210, 0043, 
+  0342, 0042, 0347, 0213, 0106, 0133, 0216, 0163, 0274, 0312, 0005, 0303, 0170, 0246, 0175, 0257, 
+  0315, 0203, 0133, 0044, 0351, 0075, 0115, 0372, 0006, 0302, 0055, 0222, 0364, 0032, 0160, 0151, 
+  0052, 0340, 0322, 0273, 0055, 0137, 0374, 0372, 0172, 0303, 0143, 0051, 0212, 0075, 0035, 0361, 
+  0021, 0373, 0332, 0243, 0102, 0103, 0372, 0146, 0117, 0350, 0134, 0215, 0324, 0145, 0255, 0134, 
+  0354, 0275, 0116, 0045, 0031, 0341, 0234, 0173, 0232, 0224, 0252, 0254, 0027, 0324, 0366, 0130, 
+  0111, 0252, 0147, 0316, 0312, 0210, 0251, 0237, 0076, 0011, 0341, 0324, 0134, 0060, 0236, 0151, 
+  0150, 0345, 0242, 0251, 0277, 0072, 0207, 0140, 0053, 0335, 0242, 0260, 0025, 0156, 0273, 0045, 
+  0206, 0126, 0276, 0207, 0152, 0164, 0062, 0015, 0332, 0237, 0200, 0301, 0263, 0007, 0250, 0307, 
+  0235, 0336, 0134, 0105, 0103, 0054, 0107, 0101, 0054, 0367, 0165, 0206, 0130, 0356, 0053, 0005, 
+  0261, 0364, 0064, 0304, 0122, 0157, 0210, 0245, 0177, 0030, 0304, 0262, 0105, 0075, 0152, 0230, 
+  0105, 0303, 0054, 0245, 0201, 0131, 0356, 0233, 0275, 0351, 0245, 0074, 0107, 0254, 0355, 0240, 
+  0060, 0066, 0246, 0223, 0066, 0336, 0237, 0066, 0235, 0264, 0260, 0104, 0053, 0237, 0116, 0072, 
+  0345, 0216, 0024, 0337, 0303, 0261, 0075, 0303, 0023, 0242, 0175, 0222, 0315, 0363, 0106, 0307, 
+  0354, 0254, 0151, 0337, 0074, 0020, 0112, 0320, 0336, 0246, 0143, 0055, 0367, 0215, 0305, 0042, 
+  0006, 0225, 0235, 0362, 0005, 0337, 0046, 0123, 0376, 0047, 0370, 0161, 0342, 0051, 0137, 0274, 
+  0257, 0126, 0216, 0350, 0136, 0277, 0262, 0264, 0217, 0314, 0225, 0204, 0374, 0337, 0253, 0337, 
+  0047, 0346, 0200, 0350, 0255, 0365, 0302, 0240, 0152, 0176, 0104, 0370, 0016, 0234, 0265, 0107, 
+  0170, 0025, 0217, 0237, 0046, 0230, 0010, 0131, 0351, 0247, 0251, 0055, 0360, 0060, 0314, 0044, 
+  0100, 0300, 0243, 0210, 0271, 0044, 0111, 0365, 0373, 0145, 0245, 0251, 0103, 0202, 0051, 0223, 
+  0271, 0201, 0255, 0254, 0257, 0170, 0106, 0255, 0350, 0135, 0361, 0015, 0370, 0052, 0265, 0274, 
+  0041, 0063, 0342, 0332, 0213, 0327, 0310, 0054, 0340, 0350, 0161, 0150, 0053, 0075, 0230, 0172, 
+  0273, 0172, 0135, 0372, 0046, 0345, 0313, 0373, 0347, 0125, 0364, 0326, 0025, 0202, 0065, 0266, 
+  0160, 0143, 0302, 0123, 0027, 0004, 0373, 0074, 0012, 0373, 0232, 0117, 0251, 0071, 0175, 0375, 
+  0032, 0150, 0236, 0164, 0222, 0350, 0304, 0305, 0315, 0004, 0177, 0172, 0207, 0200, 0077, 0375, 
+  0302, 0300, 0237, 0205, 0125, 0146, 0360, 0047, 0164, 0332, 0154, 0334, 0006, 0031, 0153, 0377, 
+  0115, 0210, 0321, 0257, 0332, 0037, 0350, 0204, 0006, 0174, 0003, 0016, 0264, 0113, 0155, 0015, 
+  0011, 0035, 0005, 0011, 0075, 0324, 0031, 0022, 0172, 0250, 0024, 0044, 0064, 0320, 0220, 0120, 
+  0275, 0041, 0241, 0273, 0003, 0041, 0241, 0235, 0224, 0346, 0052, 0072, 0004, 0132, 0005, 0006, 
+  0136, 0203, 0104, 0032, 0044, 0272, 0024, 0110, 0364, 0320, 0154, 0220, 0350, 0276, 0074, 0136, 
+  0203, 0275, 0124, 0310, 0232, 0174, 0001, 0113, 0131, 0002, 0116, 0351, 0076, 0000, 0003, 0126, 
+  0275, 0263, 0034, 0113, 0235, 0176, 0101, 0336, 0203, 0207, 0072, 0060, 0303, 0131, 0075, 0211, 
+  0300, 0010, 0365, 0363, 0044, 0076, 0326, 0201, 0015, 0056, 0340, 0124, 0004, 0146, 0250, 0243, 
+  0123, 0261, 0177, 0133, 0007, 0176, 0070, 0153, 0114, 0001, 0160, 0102, 0255, 0142, 0012, 0242, 
+  0357, 0321, 0300, 0142, 0003, 0101, 0345, 0127, 0255, 0246, 0311, 0337, 0300, 0170, 0222, 0310, 
+  0302, 0321, 0264, 0157, 0110, 0114, 0301, 0022, 0355, 0325, 0062, 0107, 0123, 0277, 0152, 0324, 
+  0057, 0150, 0111, 0330, 0357, 0324, 0034, 0120, 0336, 0313, 0240, 0334, 0003, 0133, 0316, 0000, 
+  0301, 0330, 0266, 0331, 0134, 0370, 0302, 0145, 0016, 0365, 0064, 0256, 0214, 0021, 0367, 0240, 
+  0332, 0230, 0022, 0053, 0366, 0142, 0210, 0163, 0152, 0251, 0103, 0256, 0120, 0310, 0105, 0156, 
+  0016, 0361, 0260, 0215, 0275, 0124, 0300, 0263, 0300, 0210, 0051, 0337, 0204, 0102, 0013, 0254, 
+  0010, 0070, 0061, 0351, 0231, 0112, 0303, 0236, 0255, 0164, 0205, 0070, 0203, 0233, 0070, 0100, 
+  0216, 0260, 0225, 0063, 0355, 0311, 0213, 0107, 0134, 0016, 0115, 0114, 0063, 0364, 0145, 0166, 
+  0166, 0350, 0202, 0115, 0211, 0237, 0344, 0154, 0205, 0206, 0042, 0001, 0011, 0022, 0137, 0057, 
+  0241, 0162, 0256, 0121, 0153, 0215, 0132, 0027, 0217, 0132, 0017, 0016, 0101, 0255, 0357, 0212, 
+  0102, 0255, 0305, 0106, 0351, 0062, 0247, 0203, 0214, 0122, 0245, 0052, 0347, 0347, 0153, 0032, 
+  0310, 0114, 0261, 0006, 0242, 0217, 0002, 0242, 0037, 0353, 0014, 0104, 0077, 0126, 0012, 0210, 
+  0276, 0327, 0100, 0164, 0275, 0201, 0350, 0207, 0003, 0323, 0077, 0146, 0325, 0140, 0154, 0271, 
+  0251, 0027, 0210, 0324, 0150, 0346, 0022, 0366, 0254, 0101, 0147, 0015, 0072, 0237, 0035, 0164, 
+  0176, 0154, 0024, 0350, 0234, 0162, 0051, 0110, 0043, 0112, 0037, 0114, 0323, 0114, 0177, 0222, 
+  0044, 0276, 0316, 0217, 0330, 0104, 0067, 0262, 0222, 0173, 0175, 0024, 0131, 0143, 0020, 0244, 
+  0025, 0107, 0142, 0211, 0216, 0244, 0131, 0157, 0042, 0226, 0356, 0004, 0222, 0130, 0146, 0052, 
+  0215, 0042, 0257, 0360, 0101, 0277, 0122, 0174, 0260, 0056, 0117, 0132, 0224, 0046, 0355, 0344, 
+  0111, 0022, 0243, 0351, 0262, 0136, 0261, 0044, 0275, 0152, 0252, 0201, 0222, 0034, 0115, 0225, 
+  0230, 0317, 0265, 0012, 0070, 0353, 0327, 0375, 0170, 0336, 0365, 0234, 0266, 0007, 0232, 0264, 
+  0371, 0260, 0134, 0011, 0332, 0140, 0161, 0224, 0136, 0222, 0031, 0336, 0012, 0375, 0030, 0070, 
+  0222, 0311, 0075, 0325, 0156, 0102, 0130, 0013, 0122, 0127, 0334, 0306, 0256, 0033, 0322, 0140, 
+  0161, 0045, 0363, 0304, 0233, 0146, 0350, 0050, 0157, 0310, 0162, 0312, 0370, 0055, 0207, 0370, 
+  0136, 0153, 0364, 0245, 0201, 0350, 0313, 0375, 0041, 0350, 0313, 0303, 0061, 0350, 0313, 0137, 
+  0251, 0153, 0261, 0271, 0122, 0024, 0163, 0171, 0335, 0331, 0017, 0171, 0121, 0216, 0162, 0341, 
+  0340, 0211, 0300, 0224, 0221, 0130, 0017, 0154, 0203, 0007, 0266, 0272, 0156, 0324, 0067, 0031, 
+  0100, 0077, 0020, 0371, 0163, 0150, 0054, 0341, 0226, 0231, 0062, 0207, 0115, 0210, 0113, 0330, 
+  0056, 0056, 0105, 0345, 0235, 0331, 0332, 0144, 0027, 0027, 0254, 0120, 0105, 0206, 0003, 0163, 
+  0017, 0254, 0134, 0342, 0255, 0071, 0247, 0137, 0267, 0311, 0132, 0006, 0014, 0260, 0151, 0123, 
+  0363, 0171, 0207, 0321, 0131, 0161, 0212, 0056, 0277, 0040, 0263, 0244, 0222, 0117, 0045, 0126, 
+  0152, 0105, 0025, 0175, 0341, 0146, 0034, 0151, 0063, 0050, 0064, 0035, 0261, 0227, 0356, 0171, 
+  0342, 0142, 0023, 0137, 0133, 0357, 0240, 0303, 0126, 0312, 0143, 0160, 0211, 0220, 0000, 0131, 
+  0117, 0104, 0101, 0210, 0331, 0111, 0215, 0177, 0262, 0371, 0353, 0045, 0375, 0174, 0320, 0310, 
+  0076, 0205, 0073, 0204, 0247, 0256, 0343, 0021, 0221, 0340, 0221, 0232, 0250, 0140, 0271, 0037, 
+  0300, 0374, 0140, 0312, 0005, 0160, 0272, 0321, 0205, 0024, 0361, 0201, 0376, 0341, 0167, 0276, 
+  0037, 0153, 0072, 0054, 0056, 0073, 0347, 0131, 0046, 0311, 0167, 0105, 0036, 0160, 0120, 0257, 
+  0356, 0011, 0041, 0202, 0223, 0115, 0145, 0233, 0320, 0120, 0141, 0016, 0251, 0361, 0132, 0032, 
+  0356, 0167, 0301, 0363, 0037, 0145, 0301, 0046, 0145, 0327, 0306, 0301, 0263, 0152, 0262, 0112, 
+  0204, 0244, 0361, 0233, 0067, 0257, 0257, 0150, 0113, 0060, 0174, 0073, 0367, 0277, 0113, 0152, 
+  0313, 0047, 0311, 0350, 0237, 0224, 0020, 0250, 0025, 0146, 0054, 0012, 0337, 0311, 0302, 0265, 
+  0324, 0330, 0331, 0320, 0310, 0030, 0100, 0375, 0103, 0226, 0171, 0205, 0236, 0223, 0263, 0062, 
+  0277, 0200, 0015, 0214, 0175, 0032, 0114, 0235, 0215, 0123, 0214, 0122, 0052, 0303, 0245, 0040, 
+  0201, 0372, 0315, 0103, 0221, 0135, 0161, 0264, 0113, 0357, 0356, 0264, 0153, 0371, 0025, 0012, 
+  0076, 0344, 0121, 0356, 0241, 0342, 0164, 0333, 0157, 0361, 0236, 0103, 0145, 0113, 0204, 0354, 
+  0235, 0317, 0157, 0173, 0133, 0020, 0221, 0037, 0363, 0210, 0374, 0250, 0211, 0134, 0070, 0221, 
+  0273, 0147, 0046, 0362, 0040, 0217, 0310, 0003, 0115, 0344, 0213, 0111, 0162, 0247, 0040, 0042, 
+  0337, 0345, 0021, 0371, 0116, 0023, 0371, 0142, 0222, 0134, 0024, 0221, 0125, 0316, 0261, 0074, 
+  0112, 0377, 0367, 0077, 0232, 0324, 0305, 0333, 0137, 0275, 0063, 0153, 0355, 0156, 0036, 0231, 
+  0273, 0232, 0312, 0027, 0323, 0332, 0105, 0031, 0331, 0156, 0350, 0020, 0237, 0232, 0206, 0307, 
+  0140, 0211, 0233, 0103, 0360, 0324, 0162, 0123, 0301, 0130, 0224, 0043, 0271, 0173, 0302, 0105, 
+  0223, 0340, 0371, 0332, 0224, 0361, 0217, 0314, 0361, 0354, 0005, 0232, 0303, 0312, 0013, 0175, 
+  0172, 0217, 0306, 0066, 0236, 0000, 0151, 0257, 0065, 0247, 0274, 0162, 0112, 0166, 0310, 0313, 
+  0036, 0140, 0265, 0302, 0061, 0360, 0004, 0123, 0004, 0220, 0117, 0162, 0247, 0201, 0137, 0150, 
+  0252, 0027, 0077, 0013, 0164, 0317, 0114, 0356, 0136, 0036, 0225, 0173, 0232, 0312, 0027, 0063, 
+  0353, 0212, 0232, 0005, 0034, 0030, 0031, 0012, 0172, 0073, 0327, 0260, 0373, 0111, 0023, 0373, 
+  0162, 0206, 0135, 0121, 0106, 0074, 0017, 0107, 0201, 0217, 0315, 0274, 0351, 0176, 0370, 0277, 
+  0177, 0374, 0113, 0223, 0373, 0225, 0334, 0311, 0260, 0235, 0215, 0340, 0105, 0211, 0067, 0266, 
+  0254, 0074, 0132, 0377, 0132, 0123, 0372, 0162, 0202, 0135, 0324, 0134, 0255, 0266, 0034, 0345, 
+  0131, 0361, 0133, 0161, 0244, 0117, 0151, 0004, 0225, 0063, 0173, 0026, 0243, 0106, 0350, 0053, 
+  0071, 0116, 0052, 0364, 0107, 0030, 0376, 0342, 0136, 0264, 0031, 0235, 0162, 0317, 0306, 0013, 
+  0142, 0245, 0203, 0214, 0276, 0156, 0015, 0237, 0064, 0117, 0245, 0264, 0207, 0030, 0257, 0165, 
+  0054, 0045, 0341, 0146, 0040, 0262, 0040, 0153, 0214, 0100, 0207, 0223, 0011, 0341, 0001, 0261, 
+  0242, 0015, 0224, 0222, 0363, 0242, 0172, 0247, 0001, 0346, 0172, 0347, 0003, 0346, 0170, 0200, 
+  0375, 0300, 0230, 0370, 0054, 0364, 0362, 0224, 0322, 0127, 0232, 0201, 0212, 0127, 0112, 0375, 
+  0063, 0133, 0033, 0304, 0265, 0166, 0243, 0366, 0327, 0232, 0332, 0305, 0123, 0173, 0160, 0146, 
+  0152, 0233, 0066, 0301, 0376, 0376, 0063, 0320, 0360, 0275, 0150, 0127, 0157, 0034, 0136, 0015, 
+  0315, 0156, 0063, 0200, 0005, 0352, 0337, 0017, 0305, 0156, 0034, 0162, 0364, 0034, 0060, 0070, 
+  0263, 0337, 0130, 0356, 0044, 0022, 0176, 0100, 0006, 0354, 0017, 0217, 0060, 0144, 0130, 0371, 
+  0061, 0106, 0311, 0306, 0160, 0345, 0324, 0133, 0222, 0220, 0345, 0327, 0110, 0345, 0200, 0041, 
+  0350, 0212, 0117, 0060, 0047, 0110, 0246, 0220, 0001, 0352, 0005, 0062, 0274, 0131, 0104, 0072, 
+  0203, 0261, 0044, 0056, 0125, 0144, 0214, 0067, 0223, 0361, 0312, 0331, 0015, 0031, 0120, 0153, 
+  0074, 0213, 0102, 0225, 0307, 0364, 0205, 0130, 0113, 0161, 0372, 0160, 0237, 0252, 0130, 0351, 
+  0065, 0035, 0271, 0106, 0337, 0023, 0170, 0255, 0315, 0331, 0033, 0064, 0015, 0002, 0357, 0315, 
+  0315, 0015, 0161, 0257, 0347, 0364, 0231, 0002, 0345, 0051, 0276, 0146, 0376, 0344, 0106, 0374, 
+  0272, 0171, 0037, 0065, 0065, 0342, 0207, 0203, 0060, 0004, 0276, 0243, 0225, 0341, 0322, 0336, 
+  0264, 0243, 0125, 0341, 0375, 0045, 0344, 0300, 0142, 0241, 0330, 0052, 0150, 0021, 0370, 0052, 
+  0127, 0010, 0103, 0072, 0371, 0121, 0221, 0102, 0121, 0150, 0106, 0050, 0325, 0353, 0166, 0322, 
+  0153, 0064, 0302, 0266, 0174, 0134, 0234, 0021, 0152, 0107, 0336, 0116, 0247, 0271, 0152, 0015, 
+  0077, 0130, 0043, 0315, 0325, 0105, 0163, 0365, 0303, 0045, 0270, 0132, 0251, 0111, 0103, 0252, 
+  0311, 0042, 0231, 0170, 0131, 0375, 0146, 0265, 0366, 0010, 0024, 0271, 0045, 0071, 0032, 0161, 
+  0042, 0162, 0002, 0211, 0052, 0344, 0207, 0020, 0306, 0070, 0332, 0267, 0302, 0257, 0020, 0201, 
+  0257, 0225, 0115, 0035, 0120, 0252, 0240, 0234, 0235, 0140, 0353, 0146, 0223, 0110, 0211, 0137, 
+  0275, 0236, 0224, 0265, 0171, 0063, 0014, 0165, 0223, 0135, 0057, 0073, 0113, 0300, 0267, 0251, 
+  0221, 0002, 0016, 0234, 0151, 0001, 0050, 0132, 0000, 0036, 0057, 0041, 0000, 0247, 0063, 0151, 
+  0316, 0264, 0003, 0053, 0143, 0334, 0154, 0025, 0215, 0153, 0364, 0215, 0020, 0251, 0144, 0247, 
+  0062, 0217, 0104, 0116, 0074, 0075, 0221, 0261, 0235, 0345, 0341, 0235, 0352, 0234, 0361, 0025, 
+  0014, 0243, 0230, 0121, 0014, 0370, 0012, 0346, 0057, 0276, 0006, 0346, 0041, 0332, 0350, 0271, 
+  0334, 0364, 0320, 0053, 0122, 0072, 0170, 0350, 0030, 0154, 0054, 0110, 0153, 0310, 0244, 0213, 
+  0206, 0204, 0305, 0170, 0065, 0154, 0037, 0221, 0015, 0363, 0217, 0343, 0366, 0227, 0212, 0145, 
+  0303, 0134, 0071, 0001, 0022, 0072, 0051, 0377, 0266, 0343, 0263, 0012, 0116, 0236, 0065, 0363, 
+  0040, 0243, 0360, 0373, 0205, 0245, 0245, 0376, 0122, 0163, 0142, 0267, 0120, 0251, 0217, 0016, 
+  0055, 0065, 0304, 0207, 0237, 0114, 0326, 0217, 0070, 0125, 0165, 0127, 0021, 0251, 0317, 0351, 
+  0253, 0207, 0111, 0244, 0355, 0152, 0211, 0274, 0324, 0074, 0134, 0250, 0104, 0306, 0166, 0135, 
+  0342, 0132, 0062, 0304, 0174, 0124, 0244, 0064, 0256, 0132, 0216, 0205, 0273, 0337, 0326, 0054, 
+  0314, 0326, 0271, 0375, 0304, 0342, 0154, 0237, 0205, 0131, 0222, 0124, 0143, 0247, 0177, 0255, 
+  0341, 0237, 0316, 0235, 0300, 0121, 0373, 0344, 0116, 0046, 0026, 0212, 0367, 0212, 0167, 0137, 
+  0144, 0231, 0272, 0070, 0377, 0205, 0105, 0271, 0051, 0176, 0101, 0353, 0013, 0272, 0062, 0076, 
+  0247, 0207, 0255, 0065, 0374, 0254, 0175, 0031, 0027, 0263, 0333, 0072, 0047, 0231, 0045, 0042, 
+  0046, 0051, 0122, 0042, 0042, 0056, 0026, 0313, 0254, 0351, 0232, 0264, 0147, 0202, 0317, 0221, 
+  0315, 0060, 0254, 0211, 0346, 0123, 0042, 0062, 0042, 0105, 0162, 0040, 0075, 0036, 0016, 0266, 
+  0210, 0140, 0170, 0321, 0224, 0270, 0322, 0004, 0043, 0151, 0127, 0304, 0236, 0100, 0313, 0073, 
+  0130, 0156, 0005, 0364, 0107, 0145, 0221, 0162, 0163, 0112, 0254, 0120, 0160, 0350, 0347, 0255, 
+  0051, 0320, 0064, 0043, 0237, 0324, 0334, 0051, 0224, 0221, 0047, 0076, 0343, 0034, 0264, 0073, 
+  0033, 0323, 0300, 0210, 0263, 0054, 0025, 0307, 0313, 0240, 0376, 0260, 0055, 0224, 0074, 0065, 
+  0225, 0162, 0207, 0113, 0146, 0205, 0046, 0150, 0334, 0104, 0263, 0253, 0131, 0100, 0226, 0252, 
+  0225, 0000, 0014, 0253, 0054, 0234, 0143, 0251, 0276, 0145, 0027, 0221, 0352, 0042, 0122, 0135, 
+  0334, 0231, 0177, 0077, 0256, 0176, 0136, 0153, 0370, 0321, 0323, 0116, 0263, 0213, 0131, 0045, 
+  0105, 0161, 0357, 0213, 0341, 0261, 0271, 0121, 0353, 0144, 0070, 0233, 0343, 0131, 0166, 0110, 
+  0065, 0023, 0217, 0117, 0024, 0050, 0164, 0266, 0204, 0063, 0303, 0137, 0332, 0301, 0157, 0350, 
+  0057, 0047, 0301, 0157, 0136, 0304, 0325, 0215, 0274, 0024, 0127, 0074, 0364, 0342, 0113, 0131, 
+  0266, 0310, 0336, 0276, 0211, 0356, 0347, 0260, 0071, 0310, 0360, 0163, 0350, 0155, 0311, 0236, 
+  0136, 0150, 0016, 0222, 0054, 0223, 0235, 0065, 0011, 0011, 0171, 0361, 0230, 0013, 0125, 0042, 
+  0327, 0311, 0127, 0057, 0142, 0265, 0047, 0125, 0045, 0233, 0053, 0373, 0164, 0361, 0165, 0222, 
+  0234, 0344, 0233, 0250, 0162, 0201, 0351, 0111, 0356, 0316, 0014, 0021, 0371, 0214, 0355, 0020, 
+  0134, 0377, 0157, 0255, 0270, 0057, 0227, 0244, 0244, 0050, 0325, 0015, 0137, 0314, 0016, 0010, 
+  0167, 0373, 0063, 0064, 0253, 0070, 0371, 0117, 0023, 0165, 0132, 0224, 0010, 0336, 0347, 0311, 
+  0337, 0275, 0226, 0276, 0302, 0267, 0255, 0335, 0236, 0231, 0310, 0375, 0074, 0042, 0367, 0065, 
+  0221, 0057, 0106, 0344, 0242, 0064, 0154, 0047, 0217, 0310, 0035, 0115, 0344, 0213, 0021, 0271, 
+  0050, 0277, 0354, 0155, 0036, 0221, 0163, 0123, 0347, 0032, 0076, 0371, 0041, 0224, 0321, 0263, 
+  0203, 0133, 0315, 0020, 0027, 0143, 0210, 0335, 0342, 0110, 0266, 0246, 0310, 0075, 0340, 0346, 
+  0346, 0365, 0301, 0215, 0134, 0065, 0215, 0241, 0321, 0360, 0147, 0377, 0007, 0226, 0234, 0102, 
+  0101, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0143, 0141, 0154, 0143, 0165, 0154, 0141, 0164, 
+  0157, 0162, 0057, 0000, 0003, 0000, 0000, 0000, 0155, 0141, 0164, 0145, 0055, 0143, 0141, 0154, 
+  0143, 0056, 0141, 0142, 0157, 0165, 0164, 0000, 0106, 0005, 0000, 0000, 0001, 0000, 0000, 0000, 
+  0170, 0332, 0155, 0124, 0075, 0157, 0033, 0071, 0020, 0355, 0363, 0053, 0330, 0260, 0064, 0213, 
+  0340, 0122, 0131, 0147, 0100, 0166, 0022, 0043, 0147, 0307, 0147, 0304, 0076, 0073, 0110, 0220, 
+  0142, 0166, 0167, 0166, 0227, 0342, 0327, 0142, 0110, 0312, 0222, 0372, 0373, 0117, 0051, 0322, 
+  0371, 0176, 0330, 0015, 0271, 0262, 0043, 0003, 0156, 0264, 0174, 0243, 0307, 0231, 0171, 0363, 
+  0301, 0357, 0313, 0046, 0344, 0364, 0343, 0315, 0062, 0247, 0061, 0120, 0374, 0163, 0331, 0240, 
+  0025, 0237, 0333, 0063, 0213, 0276, 0013, 0136, 0054, 0306, 0326, 0071, 0150, 0345, 0030, 0142, 
+  0154, 0203, 0163, 0212, 0177, 0116, 0216, 0227, 0035, 0070, 0361, 0201, 0072, 0007, 0205, 0201, 
+  0006, 0255, 0004, 0152, 0107, 0253, 0175, 0336, 0050, 0355, 0373, 0300, 0024, 0213, 0033, 0360, 
+  0035, 0222, 0130, 0263, 0233, 0163, 0233, 0133, 0043, 0076, 0335, 0211, 0205, 0001, 0153, 0165, 
+  0114, 0372, 0235, 0314, 0136, 0157, 0166, 0350, 0367, 0036, 0231, 0216, 0132, 0334, 0004, 0012, 
+  0106, 0263, 0323, 0030, 0110, 0101, 0265, 0111, 0207, 0341, 0201, 0024, 0345, 0102, 0262, 0034, 
+  0360, 0052, 0120, 0067, 0076, 0376, 0334, 0212, 0005, 0116, 0041, 0046, 0011, 0076, 0244, 0021, 
+  0011, 0006, 0364, 0355, 0126, 0171, 0216, 0175, 0066, 0022, 0207, 0010, 0023, 0133, 0305, 0307, 
+  0274, 0322, 0076, 0210, 0105, 0373, 0333, 0326, 0127, 0223, 0034, 0034, 0150, 0073, 0107, 0147, 
+  0265, 0016, 0175, 0022, 0227, 0330, 0143, 0263, 0046, 0144, 0372, 0154, 0121, 0166, 0157, 0221, 
+  0125, 0233, 0323, 0154, 0252, 0067, 0076, 0222, 0306, 0216, 0053, 0165, 0037, 0154, 0337, 0213, 
+  0105, 0077, 0103, 0231, 0010, 0174, 0264, 0220, 0120, 0005, 0032, 0324, 0016, 0116, 0216, 0377, 
+  0272, 0026, 0147, 0332, 0001, 0047, 0336, 0161, 0026, 0253, 0351, 0250, 0303, 0265, 0324, 0276, 
+  0011, 0233, 0052, 0351, 0302, 0102, 0216, 0342, 0252, 0334, 0046, 0103, 0217, 0277, 0006, 0116, 
+  0171, 0141, 0374, 0214, 0145, 0166, 0023, 0050, 0364, 0361, 0310, 0156, 0203, 0127, 0075, 0235, 
+  0034, 0137, 0102, 0334, 0331, 0040, 0116, 0271, 0116, 0121, 0054, 0064, 0270, 0210, 0316, 0345, 
+  0103, 0055, 0227, 0220, 0251, 0150, 0271, 0202, 0111, 0003, 0163, 0022, 0270, 0211, 0243, 0313, 
+  0236, 0020, 0253, 0213, 0317, 0334, 0052, 0316, 0374, 0275, 0136, 0231, 0310, 0371, 0212, 0205, 
+  0253, 0006, 0325, 0155, 0053, 0076, 0364, 0305, 0124, 0043, 0156, 0307, 0340, 0212, 0043, 0246, 
+  0231, 0046, 0111, 0354, 0201, 0260, 0127, 0036, 0123, 0375, 0077, 0161, 0267, 0356, 0265, 0233, 
+  0010, 0343, 0314, 0141, 0203, 0164, 0134, 0001, 0026, 0032, 0015, 0027, 0274, 0124, 0202, 0231, 
+  0272, 0035, 0201, 0243, 0336, 0042, 0021, 0167, 0316, 0315, 0120, 0245, 0002, 0145, 0313, 0055, 
+  0364, 0272, 0205, 0247, 0250, 0332, 0240, 0070, 0207, 0206, 0153, 0152, 0013, 0325, 0240, 0032, 
+  0146, 0044, 0073, 0210, 0107, 0034, 0171, 0367, 0300, 0325, 0111, 0010, 0116, 0165, 0170, 0162, 
+  0174, 0245, 0115, 0260, 0260, 0025, 0045, 0233, 0255, 0017, 0353, 0232, 0206, 0142, 0333, 0366, 
+  0205, 0230, 0153, 0150, 0112, 0345, 0130, 0054, 0173, 0142, 0331, 0074, 0317, 0017, 0222, 0207, 
+  0002, 0363, 0064, 0253, 0271, 0106, 0152, 0260, 0326, 0165, 0332, 0237, 0136, 0134, 0327, 0041, 
+  0221, 0170, 0117, 0377, 0375, 0073, 0060, 0241, 0200, 0216, 0147, 0356, 0220, 0361, 0205, 0105, 
+  0211, 0323, 0114, 0244, 0273, 0201, 0107, 0210, 0030, 0252, 0146, 0017, 0145, 0314, 0373, 0111, 
+  0377, 0022, 0330, 0165, 0022, 0113, 0317, 0065, 0147, 0171, 0124, 0241, 0202, 0012, 0137, 0170, 
+  0233, 0171, 0247, 0171, 0365, 0114, 0152, 0362, 0352, 0220, 0161, 0063, 0357, 0327, 0315, 0003, 
+  0042, 0225, 0141, 0360, 0275, 0046, 0235, 0136, 0060, 0332, 0220, 0330, 0005, 0130, 0217, 0260, 
+  0106, 0346, 0304, 0146, 0076, 0277, 0322, 0241, 0247, 0325, 0333, 0157, 0342, 0353, 0033, 0170, 
+  0223, 0270, 0375, 0136, 0334, 0102, 0366, 0145, 0120, 0143, 0205, 0052, 0125, 0310, 0201, 0067, 
+  0012, 0322, 0023, 0051, 0210, 0013, 0040, 0230, 0060, 0305, 0062, 0074, 0063, 0063, 0110, 0363, 
+  0154, 0333, 0147, 0230, 0220, 0127, 0322, 0213, 0013, 0002, 0176, 0200, 0230, 0147, 0376, 0170, 
+  0053, 0343, 0154, 0064, 0317, 0224, 0065, 0212, 0157, 0030, 0333, 0261, 0372, 0131, 0343, 0256, 
+  0234, 0337, 0036, 0012, 0275, 0323, 0155, 0012, 0124, 0042, 0042, 0223, 0326, 0246, 0174, 0345, 
+  0374, 0231, 0173, 0173, 0147, 0241, 0023, 0177, 0223, 0255, 0323, 0021, 0174, 0114, 0160, 0260, 
+  0204, 0145, 0211, 0007, 0360, 0203, 0370, 0307, 0066, 0245, 0153, 0145, 0200, 0022, 0112, 0342, 
+  0232, 0351, 0124, 0107, 0354, 0076, 0213, 0257, 0032, 0102, 0322, 0345, 0301, 0333, 0142, 0342, 
+  0247, 0344, 0060, 0374, 0233, 0377, 0001, 0302, 0121, 0356, 0145, 0000, 0050, 0165, 0165, 0141, 
+  0171, 0051
+} };
+
+static GStaticResource static_resource = { calculator_resource_data.data, sizeof (calculator_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
+
+G_MODULE_EXPORT
+GResource *calculator_get_resource (void);
+GResource *calculator_get_resource (void)
+{
+  return g_static_resource_get_resource (&static_resource);
+}
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
+ * file for a list of people on the GLib Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __G_CONSTRUCTOR_H__
+#define __G_CONSTRUCTOR_H__
+
+/*
+  If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
+  destructors, in a usable way, including e.g. on library unload. If not you're on
+  your own.
+
+  Some compilers need #pragma to handle this, which does not work with macros,
+  so the way you need to use this is (for constructors):
+
+  #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+  #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
+  #endif
+  G_DEFINE_CONSTRUCTOR(my_constructor)
+  static void my_constructor(void) {
+   ...
+  }
+
+*/
+
+#ifndef __GTK_DOC_IGNORE__
+
+#if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
+#define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
+
+#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
+/* Visual studio 2008 and later has _Pragma */
+
+/*
+ * Only try to include gslist.h if not already included via glib.h,
+ * so that items using gconstructor.h outside of GLib (such as
+ * GResources) continue to build properly.
+ */
+#ifndef __G_LIB_H__
+#include "gslist.h"
+#endif
+
+#include <stdlib.h>
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* We do some weird things to avoid the constructors being optimized
+ * away on VS2015 if WholeProgramOptimization is enabled. First we
+ * make a reference to the array from the wrapper to make sure its
+ * references. Then we use a pragma to make sure the wrapper function
+ * symbol is always included at the link stage. Also, the symbols
+ * need to be extern (but not dllexport), even though they are not
+ * really used from another object file.
+ */
+
+/* We need to account for differences between the mangling of symbols
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
+ */
+#ifdef _M_IX86
+#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
+#endif
+
+#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
+#define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
+
+#define G_MSVC_CTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _wrapper(void);              \
+  int _func ## _wrapper(void) { _func(); g_slist_find (NULL,  _array ## _func); return 0; } \
+  __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
+
+#define G_MSVC_DTOR(_func,_sym_prefix) \
+  static void _func(void); \
+  extern int (* _array ## _func)(void);              \
+  int _func ## _constructor(void);              \
+  int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL,  _array ## _func); return 0; } \
+   __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
+  __pragma(section(".CRT$XCU",read)) \
+  __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined (_MSC_VER)
+
+#define G_HAS_CONSTRUCTORS 1
+
+/* Pre Visual studio 2008 must use #pragma section */
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _wrapper(void) { _func(); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  section(".CRT$XCU",read)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void); \
+  static int _func ## _constructor(void) { atexit (_func); return 0; } \
+  __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
+
+#elif defined(__SUNPRO_C)
+
+/* This is not tested, but i believe it should work, based on:
+ * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
+ */
+
+#define G_HAS_CONSTRUCTORS 1
+
+#define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
+#define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
+
+#define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
+  init(_func)
+#define G_DEFINE_CONSTRUCTOR(_func) \
+  static void _func(void);
+
+#define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
+  fini(_func)
+#define G_DEFINE_DESTRUCTOR(_func) \
+  static void _func(void);
+
+#else
+
+/* constructors not supported for this compiler */
+
+#endif
+
+#endif /* __GTK_DOC_IGNORE__ */
+#endif /* __G_CONSTRUCTOR_H__ */
+
+#ifdef G_HAS_CONSTRUCTORS
+
+#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(calculatorresource_constructor)
+#endif
+G_DEFINE_CONSTRUCTOR(calculatorresource_constructor)
+#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
+#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(calculatorresource_destructor)
+#endif
+G_DEFINE_DESTRUCTOR(calculatorresource_destructor)
+
+#else
+#warning "Constructor not supported on this compiler, linking in resources will not work"
+#endif
+
+static void calculatorresource_constructor (void)
+{
+  g_static_resource_init (&static_resource);
+}
+
+static void calculatorresource_destructor (void)
+{
+  g_static_resource_fini (&static_resource);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/13.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/13.html new file mode 100644 index 0000000..c84d8d2 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/13.html @@ -0,0 +1,767 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-window.h"
+#include "math-preferences.h"
+#include "mp-equation.h"
+#include "unit-manager.h"
+#include "utility.h"
+
+GSettings *g_settings_var = NULL;
+
+static MathWindow *window;
+
+static void
+version(const gchar *progname)
+{
+    /* NOTE: Is not translated so can be easily parsed */
+    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)
+{
+    MPEquationOptions options;
+    MPErrorCode error;
+    MPNumber result = mp_new();
+    char *result_str;
+
+    memset(&options, 0, sizeof(options));
+    options.base = 10;
+    options.wordlen = 32;
+    options.angle_units = MP_DEGREES;
+    options.convert = do_convert;
+
+    error = mp_equation_parse(equation, &options, &result, NULL);
+    if(error == PARSER_ERR_MP) {
+        fprintf(stderr, "Error: %s\n", mp_get_error());
+        mp_clear(&result);
+        exit(1);
+    }
+    else if(error != 0) {
+        fprintf(stderr, "Error: %s\n", mp_error_code_to_string(error));
+        mp_clear(&result);
+        exit(1);
+    }
+    else {
+        result_str = mp_serializer_to_string(mp_serializer_new(MP_DISPLAY_FORMAT_AUTOMATIC, 10, 9), &result);
+        printf("%s\n", result_str);
+        mp_clear(&result);
+        exit(0);
+    }
+}
+
+static void
+usage(const gchar *progname, gboolean show_application, gboolean show_gtk)
+{
+    fprintf(stderr,
+            /* Description on how to use mate-calc displayed on command-line */
+            _("Usage:\n"
+              "  %s — Perform mathematical calculations"), progname);
+
+    fprintf(stderr,
+            "\n\n");
+
+    fprintf(stderr,
+            /* Description on mate-calc command-line help options displayed on command-line */
+            _("Help Options:\n"
+              "  -v, --version                   Show release version\n"
+              "  -h, -?, --help                  Show help options\n"
+              "  --help-all                      Show all help options\n"
+              "  --help-gtk                      Show GTK+ options"));
+    fprintf(stderr,
+            "\n\n");
+
+    if (show_gtk) {
+        fprintf(stderr,
+                /* Description on mate-calc command-line GTK+ options displayed on command-line */
+                _("GTK+ Options:\n"
+                  "  --class=CLASS                   Program class as used by the window manager\n"
+                  "  --name=NAME                     Program name as used by the window manager\n"
+                  "  --screen=SCREEN                 X screen to use\n"
+                  "  --sync                          Make X calls synchronous\n"
+                  "  --gtk-module=MODULES            Load additional GTK+ modules\n"
+                  "  --g-fatal-warnings              Make all warnings fatal"));
+        fprintf(stderr,
+                "\n\n");
+    }
+
+    if (show_application) {
+        fprintf(stderr,
+                /* Description on mate-calc application options displayed on command-line */
+                _("Application Options:\n"
+                  "  -s, --solve <equation>          Solve the given equation"));
+        fprintf(stderr,
+                "\n\n");
+    }
+}
+
+static void
+get_options(int argc, char *argv[])
+{
+    int i;
+    char *progname, *arg;
+
+    progname = g_path_get_basename(argv[0]);
+
+    for (i = 1; i < argc; i++) {
+        arg = argv[i];
+
+        if (strcmp(arg, "-v") == 0 ||
+            strcmp(arg, "--version") == 0) {
+            version(progname);
+            g_free(progname);
+            exit(0);
+        }
+        else if (strcmp(arg, "-h") == 0 ||
+                 strcmp(arg, "-?") == 0 ||
+                 strcmp(arg, "--help") == 0) {
+            usage(progname, TRUE, FALSE);
+            g_free(progname);
+            exit(0);
+        }
+        else if (strcmp(arg, "--help-all") == 0) {
+            usage(progname, TRUE, TRUE);
+            g_free(progname);
+            exit(0);
+        }
+        else if (strcmp(arg, "--help-gtk") == 0) {
+            usage(progname, FALSE, TRUE);
+            g_free(progname);
+            exit(0);
+        }
+        else if (strcmp(arg, "-s") == 0 ||
+            strcmp(arg, "--solve") == 0) {
+            i++;
+            if (i >= argc) {
+                fprintf(stderr,
+                        /* Error printed to stderr when user uses --solve argument without an equation */
+                        _("Argument --solve requires an equation to solve"));
+                fprintf(stderr, "\n");
+                g_free(progname);
+                exit(1);
+            }
+            else
+                solve(argv[i]);
+        }
+        else {
+            fprintf(stderr,
+                    /* Error printed to stderr when user provides an unknown command-line argument */
+                    _("Unknown argument '%s'"), arg);
+            fprintf(stderr, "\n");
+            usage(progname, TRUE, FALSE);
+            g_free(progname);
+            exit(1);
+        }
+    }
+
+    g_free(progname);
+}
+
+static void
+quit_cb(MathWindow *win)
+{
+    gtk_main_quit();
+}
+
+int main(int argc, char **argv)
+{
+    MathEquation *equation;
+    MathButtons *buttons;
+    int accuracy = 9, word_size = 64, base = 10;
+    gboolean show_tsep = FALSE, show_zeroes = FALSE, show_hist = FALSE;
+    MpDisplayFormat number_format;
+    MPAngleUnit angle_units;
+    ButtonMode button_mode;
+    gchar *source_currency, *target_currency;
+    gchar *source_units, *target_units;
+
+    setlocale(LC_ALL, "");
+    bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
+    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+    textdomain(GETTEXT_PACKAGE);
+
+    /* Seed random number generator. */
+    srand48((long) time((time_t *) 0));
+
+    gtk_init(&argc, &argv);
+
+    g_settings_var = g_settings_new ("org.mate.calc");
+    accuracy = g_settings_get_int(g_settings_var, "accuracy");
+    word_size = g_settings_get_int(g_settings_var, "word-size");
+    base = g_settings_get_int(g_settings_var, "base");
+    show_tsep = g_settings_get_boolean(g_settings_var, "show-thousands");
+    show_zeroes = g_settings_get_boolean(g_settings_var, "show-zeroes");
+    show_hist = g_settings_get_boolean(g_settings_var, "show-history");
+    number_format = g_settings_get_enum(g_settings_var, "number-format");
+    angle_units = g_settings_get_enum(g_settings_var, "angle-units");
+    button_mode = g_settings_get_enum(g_settings_var, "button-mode");
+    source_currency = g_settings_get_string(g_settings_var, "source-currency");
+    target_currency = g_settings_get_string(g_settings_var, "target-currency");
+    source_units = g_settings_get_string(g_settings_var, "source-units");
+    target_units = g_settings_get_string(g_settings_var, "target-units");
+
+    equation = math_equation_new();
+    math_equation_set_accuracy(equation, accuracy);
+    math_equation_set_word_size(equation, word_size);
+    math_equation_set_show_thousands_separators(equation, show_tsep);
+    math_equation_set_show_trailing_zeroes(equation, show_zeroes);
+    math_equation_set_number_format(equation, number_format);
+    math_equation_set_angle_units(equation, angle_units);
+    math_equation_set_source_currency(equation, source_currency);
+    math_equation_set_target_currency(equation, target_currency);
+    math_equation_set_source_units(equation, source_units);
+    math_equation_set_target_units(equation, target_units);
+    g_free(source_currency);
+    g_free(target_currency);
+    g_free(source_units);
+    g_free(target_units);
+
+    get_options(argc, argv);
+
+    //gtk_window_set_default_icon_name("accessories-calculator");
+
+    window = math_window_new(equation);
+    buttons = math_window_get_buttons(window);
+    g_signal_connect(G_OBJECT(window), "quit", G_CALLBACK(quit_cb), NULL);
+    math_window_set_show_history(window, show_hist);
+    math_buttons_set_programming_base(buttons, base);
+    math_buttons_set_mode(buttons, button_mode); // FIXME: We load the basic buttons even if we immediately switch to the next type
+
+    gtk_widget_show(GTK_WIDGET(window));
+    gtk_main();
+
+    return 0;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/14.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/14.html new file mode 100644 index 0000000..ce3cc1c --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/14.html @@ -0,0 +1,357 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MATH_WINDOW_H
+#define MATH_WINDOW_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "math-equation.h"
+#include "math-display.h"
+#include "math-buttons.h"
+#include "math-preferences.h"
+
+G_BEGIN_DECLS
+
+#define MATH_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_window_get_type(), MathWindow))
+
+typedef struct MathWindowPrivate MathWindowPrivate;
+
+typedef struct
+{
+    GtkWindow parent_instance;
+    MathWindowPrivate *priv;
+} MathWindow;
+
+typedef struct
+{
+    GtkWindowClass parent_class;
+
+    void (*quit) (MathWindow *window);
+} MathWindowClass;
+
+GType math_window_get_type(void);
+
+MathWindow *math_window_new(MathEquation *equation);
+
+GtkWidget *math_window_get_menu_bar(MathWindow *window);
+
+MathEquation *math_window_get_equation(MathWindow *window);
+
+MathDisplay *math_window_get_display(MathWindow *window);
+
+MathButtons *math_window_get_buttons(MathWindow *window);
+
+gboolean math_window_get_show_history(MathWindow *window);
+
+void math_window_set_show_history(MathWindow *window, gboolean visible);
+
+void math_window_critical_error(MathWindow *window, const gchar *title, const gchar *contents);
+
+G_END_DECLS
+
+#endif /* MATH_WINDOW_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/15.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/15.html new file mode 100644 index 0000000..4199df3 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/15.html @@ -0,0 +1,329 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MATH_DISPLAY_H
+#define MATH_DISPLAY_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-equation.h"
+
+G_BEGIN_DECLS
+
+#define MATH_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_display_get_type(), MathDisplay))
+
+typedef struct MathDisplayPrivate MathDisplayPrivate;
+
+typedef struct
+{
+    GtkViewport parent_instance;
+    MathDisplayPrivate *priv;
+} MathDisplay;
+
+typedef struct
+{
+    GtkViewportClass parent_class;
+} MathDisplayClass;
+
+GType math_display_get_type(void);
+
+MathDisplay *math_display_new(void);
+
+MathDisplay *math_display_new_with_equation(MathEquation *equation);
+
+MathEquation *math_display_get_equation(MathDisplay *display);
+
+G_END_DECLS
+
+#endif /* MATH_DISPLAY_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/16.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/16.html new file mode 100644 index 0000000..87c9125 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/16.html @@ -0,0 +1,349 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MATH_BUTTONS_H
+#define MATH_BUTTONS_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "math-equation.h"
+
+G_BEGIN_DECLS
+
+#define MATH_BUTTONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_buttons_get_type(), MathButtons))
+
+typedef struct MathButtonsPrivate MathButtonsPrivate;
+
+typedef struct
+{
+    GtkVBox parent_instance;
+    MathButtonsPrivate *priv;
+} MathButtons;
+
+typedef struct
+{
+    GtkVBoxClass parent_class;
+} MathButtonsClass;
+
+typedef enum {
+    BASIC,
+    ADVANCED,
+    FINANCIAL,
+    PROGRAMMING
+} ButtonMode;
+
+GType math_buttons_get_type(void);
+
+MathButtons *math_buttons_new(MathEquation *equation);
+
+void math_buttons_set_mode(MathButtons *buttons, ButtonMode mode);
+
+ButtonMode math_buttons_get_mode(MathButtons *buttons);
+
+void math_buttons_set_programming_base(MathButtons *buttons, gint base);
+
+gint math_buttons_get_programming_base(MathButtons *buttons);
+
+G_END_DECLS
+
+#endif /* MATH_BUTTONS_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/17.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/17.html new file mode 100644 index 0000000..5e4a28a --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/17.html @@ -0,0 +1,319 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MATH_PREFERENCES_H
+#define MATH_PREFERENCES_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "math-equation.h"
+
+G_BEGIN_DECLS
+
+#define MATH_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_preferences_get_type(), MathPreferencesDialog))
+
+typedef struct MathPreferencesDialogPrivate MathPreferencesDialogPrivate;
+
+typedef struct
+{
+    GtkDialog                 parent_instance;
+    MathPreferencesDialogPrivate *priv;
+} MathPreferencesDialog;
+
+typedef struct
+{
+    GtkDialogClass parent_class;
+} MathPreferencesDialogClass;
+
+GType math_preferences_get_type(void);
+
+MathPreferencesDialog *math_preferences_dialog_new(MathEquation *equation);
+
+G_END_DECLS
+
+#endif /* MATH_PREFERENCES_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/18.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/18.html new file mode 100644 index 0000000..79e3de7 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/18.html @@ -0,0 +1,345 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef UNIT_MANAGER_H
+#define UNIT_MANAGER_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "unit-category.h"
+#include "mp.h"
+
+G_BEGIN_DECLS
+
+#define UNIT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), unit_manager_get_type(), UnitManager))
+
+typedef struct UnitManagerPrivate UnitManagerPrivate;
+
+typedef struct
+{
+    GObject parent_instance;
+    UnitManagerPrivate *priv;
+} UnitManager;
+
+typedef struct
+{
+    GObjectClass parent_class;
+} UnitManagerClass;
+
+GType unit_manager_get_type(void);
+
+UnitManager *unit_manager_get_default(void);
+
+UnitCategory *unit_manager_add_category(UnitManager *manager, const gchar *name, const gchar *display_name);
+
+const GList *unit_manager_get_categories(UnitManager *manager);
+
+UnitCategory *unit_manager_get_category(UnitManager *manager, const gchar *category);
+
+Unit *unit_manager_get_unit_by_name(UnitManager *manager, const gchar *name);
+
+Unit *unit_manager_get_unit_by_symbol(UnitManager *manager, const gchar *symbol);
+
+gboolean unit_manager_convert_by_symbol(UnitManager *manager, const MPNumber *x, const char *x_symbol, const char *z_symbol, MPNumber *z);
+
+G_END_DECLS
+
+#endif /* UNIT_MANAGER_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/19.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/19.html new file mode 100644 index 0000000..0550891 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/19.html @@ -0,0 +1,349 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef UNIT_CATEGORY_H
+#define UNIT_CATEGORY_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "unit.h"
+#include "mp.h"
+
+G_BEGIN_DECLS
+
+#define UNIT_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), unit_category_get_type(), UnitCategory))
+
+typedef struct UnitCategoryPrivate UnitCategoryPrivate;
+
+typedef struct
+{
+    GObject parent_instance;
+    UnitCategoryPrivate *priv;
+} UnitCategory;
+
+typedef struct
+{
+    GObjectClass parent_class;
+} UnitCategoryClass;
+
+GType unit_category_get_type(void);
+
+UnitCategory *unit_category_new(const gchar *name, const gchar *display_name);
+
+const gchar *unit_category_get_name(UnitCategory *category);
+
+const gchar *unit_category_get_display_name(UnitCategory *category);
+
+Unit *unit_category_get_unit_by_name(UnitCategory *category, const gchar *name);
+
+Unit *unit_category_get_unit_by_symbol(UnitCategory *category, const gchar *symbol);
+
+void unit_category_add_unit(UnitCategory *category, Unit *unit);
+
+const GList *unit_category_get_units(UnitCategory *category);
+
+gboolean unit_category_convert(const UnitCategory *category, const MPNumber *x, Unit *x_units, Unit *z_units, MPNumber *z);
+
+G_END_DECLS
+
+#endif /* UNIT_CATEGORY_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/2.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/2.html new file mode 100644 index 0000000..d6e21e4 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/2.html @@ -0,0 +1,923 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+/*  This maths library is based on the MP multi-precision floating-point
+ *  arithmetic package originally written in FORTRAN by Richard Brent,
+ *  Computer Centre, Australian National University in the 1970's.
+ *
+ *  It has been converted from FORTRAN into C using the freely available
+ *  f2c translator, available via netlib on research.att.com.
+ *
+ *  The subsequently converted C code has then been tidied up, mainly to
+ *  remove any dependencies on the libI77 and libF77 support libraries.
+ *
+ *  FOR A GENERAL DESCRIPTION OF THE PHILOSOPHY AND DESIGN OF MP,
+ *  SEE - R. P. BRENT, A FORTRAN MULTIPLE-PRECISION ARITHMETIC
+ *  PACKAGE, ACM TRANS. MATH. SOFTWARE 4 (MARCH 1978), 57-70.
+ *  SOME ADDITIONAL DETAILS ARE GIVEN IN THE SAME ISSUE, 71-81.
+ *  FOR DETAILS OF THE IMPLEMENTATION, CALLING SEQUENCES ETC. SEE
+ *  THE MP USERS GUIDE.
+ */
+
+#ifndef MP_H
+#define MP_H
+
+#include <stdbool.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdint.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <mpfr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <mpc.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+/* If we're not using GNU C, elide __attribute__ */
+#ifndef __GNUC__
+#  define  __attribute__(x)  /*NOTHING*/
+#endif
+
+/* Precision of mpfr_t and mpc_t type objects */
+#define PRECISION 1000
+
+typedef struct
+{
+    mpc_t num;
+} MPNumber;
+
+typedef enum
+{
+    MP_RADIANS,
+    MP_DEGREES,
+    MP_GRADIANS
+} MPAngleUnit;
+
+/* Returns error string or NULL if no error */
+// FIXME: Global variable
+const char  *mp_get_error(void);
+
+/* Clear any current error */
+void        mp_clear_error(void);
+
+void        mperr(const char *format, ...) __attribute__((format(printf, 1, 2)));
+
+/* Returns initialized MPNumber object */
+MPNumber    mp_new(void);
+
+MPNumber    mp_new_from_unsigned_integer(ulong x);
+
+MPNumber*   mp_new_ptr(void);
+
+void        mp_clear(MPNumber *z);
+
+void        mp_free(MPNumber *z);
+
+/* Returns:
+ *  0 if x == y
+ * <0 if x < y
+ * >0 if x > y
+ */
+int    mp_compare(const MPNumber *x, const MPNumber *y);
+
+/* Return true if the value is x == 0 */
+bool   mp_is_zero(const MPNumber *x);
+
+/* Return true if x < 0 */
+bool   mp_is_negative(const MPNumber *x);
+
+/* Return true if x is integer */
+bool   mp_is_integer(const MPNumber *x);
+
+/* Return true if x is a positive integer */
+bool   mp_is_positive_integer(const MPNumber *x);
+
+/* Return true if x is a natural number (an integer ≥ 0) */
+bool   mp_is_natural(const MPNumber *x);
+
+/* Return true if x has an imaginary component */
+bool   mp_is_complex(const MPNumber *x);
+
+/* Return true if x == y */
+bool   mp_is_equal(const MPNumber *x, const MPNumber *y);
+
+/* Return true if x ≥ y */
+bool   mp_is_greater_equal(const MPNumber *x, const MPNumber *y);
+
+/* Return true if x > y */
+bool   mp_is_greater_than(const MPNumber *x, const MPNumber *y);
+
+/* Return true if x ≤ y */
+bool   mp_is_less_equal(const MPNumber *x, const MPNumber *y);
+
+/* Return true if x < y */
+bool   mp_is_less_than(const MPNumber *x, const MPNumber *y);
+
+/* Sets z = |x| */
+void   mp_abs(const MPNumber *x, MPNumber *z);
+
+/* Sets z = Arg(x) */
+void   mp_arg(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+/* Sets z = ‾̅x */
+void   mp_conjugate(const MPNumber *x, MPNumber *z);
+
+/* Sets z = Re(x) */
+void   mp_real_component(const MPNumber *x, MPNumber *z);
+
+/* Sets z = Im(x) */
+void   mp_imaginary_component(const MPNumber *x, MPNumber *z);
+
+/* Sets z = −x */
+void   mp_invert_sign(const MPNumber *x, MPNumber *z);
+
+/* Sets z = x + y */
+void   mp_add(const MPNumber *x, const MPNumber *y, MPNumber *z);
+
+/* Sets z = x + y */
+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);
+
+/* Sets z = x × y */
+void   mp_multiply(const MPNumber *x, const MPNumber *y, MPNumber *z);
+
+/* Sets z = x × y */
+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, long y, MPNumber *z);
+
+/* Sets z = 1 ÷ x */
+void   mp_reciprocal(const MPNumber *, MPNumber *);
+
+/* Sets z = sgn(x) */
+void   mp_sgn(const MPNumber *x, MPNumber *z);
+
+void   mp_integer_component(const MPNumber *x, MPNumber *z);
+
+/* Sets z = x mod 1 */
+void   mp_fractional_component(const MPNumber *x, MPNumber *z);
+
+/* Sets z = {x} */
+void   mp_fractional_part(const MPNumber *x, MPNumber *z);
+
+/* Sets z = ⌊x⌋ */
+void   mp_floor(const MPNumber *x, MPNumber *z);
+
+/* Sets z = ⌈x⌉ */
+void   mp_ceiling(const MPNumber *x, MPNumber *z);
+
+/* Sets z = [x] */
+void   mp_round(const MPNumber *x, MPNumber *z);
+
+/* Sets z = ln x */
+void   mp_ln(const MPNumber *x, MPNumber *z);
+
+/* Sets z = log_n x */
+void   mp_logarithm(long n, const MPNumber *x, MPNumber *z);
+
+/* Sets z = π */
+void   mp_get_pi(MPNumber *z);
+
+/* Sets z = e */
+void   mp_get_eulers(MPNumber *z);
+
+/* Sets z = i (√−1) */
+void   mp_get_i(MPNumber *z);
+
+/* Sets z = n√x */
+void   mp_root(const MPNumber *x, long n, MPNumber *z);
+
+/* Sets z = √x */
+void   mp_sqrt(const MPNumber *x, MPNumber *z);
+
+/* Sets z = x! */
+void   mp_factorial(const MPNumber *x, MPNumber *z);
+
+/* Sets z = x mod y */
+void   mp_modulus_divide(const MPNumber *x, const MPNumber *y, MPNumber *z);
+
+/* Sets z = x ^ y mod p */
+void mp_modular_exponentiation(const MPNumber *x, const MPNumber *y, const MPNumber *p, MPNumber *z);
+
+/* Sets z = x^y */
+void   mp_xpowy(const MPNumber *x, const MPNumber *y, MPNumber *z);
+
+/* Sets z = x^y */
+void   mp_xpowy_integer(const MPNumber *x, long y, MPNumber *z);
+
+/* Sets z = e^x */
+void   mp_epowy(const MPNumber *x, MPNumber *z);
+
+/* Returns a list of all prime factors in x as MPNumbers */
+GList* mp_factorize(const MPNumber *x);
+
+GList* mp_factorize_unit64 (uint64_t n);
+
+/* Sets z = x */
+void   mp_set_from_mp(const MPNumber *x, MPNumber *z);
+
+/* Sets z = x */
+void   mp_set_from_float(float x, MPNumber *z);
+
+/* Sets z = x */
+void   mp_set_from_double(double x, MPNumber *z);
+
+/* Sets z = x */
+void   mp_set_from_integer(long x, MPNumber *z);
+
+/* Sets z = x */
+void   mp_set_from_unsigned_integer(ulong x, MPNumber *z);
+
+/* Sets z = numerator ÷ denominator */
+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);
+
+/* Sets z = x + iy */
+void   mp_set_from_complex(const MPNumber *x, const MPNumber *y, MPNumber *z);
+
+/* Sets z to be a uniform random number in the range [0, 1] */
+void   mp_set_from_random(MPNumber *z);
+
+/* Sets z from a string representation in 'text'.
+ * Returns true on success.
+ */
+bool   mp_set_from_string(const char *text, int default_base, MPNumber *z);
+
+/* Returns x as a native single-precision floating point number */
+float  mp_to_float(const MPNumber *x);
+
+/* Returns x as a native double-precision floating point number */
+double mp_to_double(const MPNumber *x);
+
+/* Returns x as a native integer */
+long mp_to_integer(const MPNumber *x);
+
+/* Returns x as a native unsigned integer */
+ulong mp_to_unsigned_integer(const MPNumber *x);
+
+/* Sets z = sin x */
+void   mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+/* Sets z = cos x */
+void   mp_cos(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+/* Sets z = tan x */
+void   mp_tan(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+/* Sets z = sin⁻¹ x */
+void   mp_asin(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+/* Sets z = cos⁻¹ x */
+void   mp_acos(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+/* Sets z = tan⁻¹ x */
+void   mp_atan(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+/* Sets z = sinh x */
+void   mp_sinh(const MPNumber *x, MPNumber *z);
+
+/* Sets z = cosh x */
+void   mp_cosh(const MPNumber *x, MPNumber *z);
+
+/* Sets z = tanh x */
+void   mp_tanh(const MPNumber *x, MPNumber *z);
+
+/* Sets z = sinh⁻¹ x */
+void   mp_asinh(const MPNumber *x, MPNumber *z);
+
+/* Sets z = cosh⁻¹ x */
+void   mp_acosh(const MPNumber *x, MPNumber *z);
+
+/* Sets z = tanh⁻¹ x */
+void   mp_atanh(const MPNumber *x, MPNumber *z);
+
+/* Sets z to the value of the error function of x */
+void   mp_erf(const MPNumber *x, MPNumber *z);
+
+/* Sets z to the value of the Riemann Zeta function of x */
+void   mp_zeta(const MPNumber *x, MPNumber *z);
+
+/* Returns true if x is cannot be represented in a binary word of length 'wordlen' */
+bool   mp_is_overflow(const MPNumber *x, int wordlen);
+
+/* Sets z = boolean AND for each bit in x and z */
+void   mp_and(const MPNumber *x, const MPNumber *y, MPNumber *z);
+
+/* Sets z = boolean OR for each bit in x and z */
+void   mp_or(const MPNumber *x, const MPNumber *y, MPNumber *z);
+
+/* Sets z = boolean XOR for each bit in x and z */
+void   mp_xor(const MPNumber *x, const MPNumber *y, MPNumber *z);
+
+/* Sets z = boolean XNOR for each bit in x and z for word of length 'wordlen' */
+void   mp_xnor(const MPNumber *x, const MPNumber *y, int wordlen, MPNumber *z);
+
+/* Sets z = boolean NOT for each bit in x and z for word of length 'wordlen' */
+void   mp_not(const MPNumber *x, int wordlen, MPNumber *z);
+
+/* Sets z = x shifted by 'count' bits.  Positive shift increases the value, negative decreases */
+void   mp_shift(const MPNumber *x, int count, MPNumber *z);
+
+/* Sets z to be the ones complement of x for word of length 'wordlen' */
+void   mp_ones_complement(const MPNumber *x, int wordlen, MPNumber *z);
+
+/* Sets z to be the twos complement of x for word of length 'wordlen' */
+void   mp_twos_complement(const MPNumber *x, int wordlen, MPNumber *z);
+
+void convert_to_radians(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+void convert_from_radians(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
+
+#endif /* MP_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/20.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/20.html new file mode 100644 index 0000000..c9048b0 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/20.html @@ -0,0 +1,357 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef UNIT_H
+#define UNIT_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "mp.h"
+
+G_BEGIN_DECLS
+
+#define UNIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), unit_get_type(), Unit))
+
+typedef struct UnitPrivate UnitPrivate;
+
+typedef struct
+{
+    GObject parent_instance;
+    UnitPrivate *priv;
+} Unit;
+
+typedef struct
+{
+    GObjectClass parent_class;
+} UnitClass;
+
+GType unit_get_type(void);
+
+Unit *unit_new(const gchar *name,
+               const gchar *display_name,
+               const gchar *format,
+               const gchar *from_function,
+               const gchar *to_function,
+               const gchar *symbols);
+
+const gchar *unit_get_name(Unit *unit);
+
+const gchar *unit_get_display_name(Unit *unit);
+
+gboolean unit_matches_symbol(Unit *unit, const gchar *symbol);
+
+const GList *unit_get_symbols(Unit *unit);
+
+gboolean unit_convert_from(Unit *unit, const MPNumber *x, MPNumber *z);
+
+gboolean unit_convert_to(Unit *unit, const MPNumber *x, MPNumber *z);
+
+gchar *unit_format(Unit *unit, MPNumber *x);
+
+G_END_DECLS
+
+#endif /* UNIT_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/21.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/21.html new file mode 100644 index 0000000..fb3da8c --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/21.html @@ -0,0 +1,255 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
#ifndef UTILITY_H
+#define UTILITY_H
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "config.h"<--- Include file: "config.h" not found.
+
+extern GSettings *g_settings_var;
+
+#endif
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/22.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/22.html new file mode 100644 index 0000000..9fc9352 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/22.html @@ -0,0 +1,3021 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-buttons.h"
+#include "math-converter.h"
+#include "math-variable-popup.h"
+#include "financial.h"
+#include "mp-serializer.h"
+#include "utility.h"
+
+enum {
+    PROP_0,
+    PROP_EQUATION,
+    PROP_MODE,
+    PROP_PROGRAMMING_BASE
+};
+
+static GType button_mode_type;
+
+#define MAXBITS 64      /* Bit panel: number of bit fields. */
+
+struct MathButtonsPrivate
+{
+    MathEquation *equation;
+
+    ButtonMode mode;
+    gint programming_base;
+
+    MathConverter *converter;
+
+    GtkBuilder *basic_ui, *advanced_ui, *financial_ui, *programming_ui;
+
+    GtkWidget *bas_panel, *adv_panel, *fin_panel, *prog_panel;
+    GtkWidget *active_panel;
+
+    GtkWidget *shift_left_menu, *shift_right_menu;
+
+    GtkWidget *function_menu;
+    GtkWidget *const_menu;
+
+    GList *superscript_toggles;
+    GList *subscript_toggles;
+
+    GtkWidget *base_combo;
+    GtkWidget *base_label;
+    GtkWidget *bit_panel;
+    GtkWidget *bit_labels[MAXBITS];
+
+    GtkWidget *character_code_dialog;
+    GtkWidget *character_code_entry;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MathButtons, math_buttons, GTK_TYPE_BOX);
+
+#define UI_BASIC_RESOURCE_PATH       "/org/mate/calculator/ui/buttons-basic.ui"
+#define UI_ADVANCED_RESOURCE_PATH    "/org/mate/calculator/ui/buttons-advanced.ui"
+#define UI_FINANCIAL_RESOURCE_PATH   "/org/mate/calculator/ui/buttons-financial.ui"
+#define UI_PROGRAMMING_RESOURCE_PATH "/org/mate/calculator/ui/buttons-programming.ui"
+
+#define GET_WIDGET(ui, name) \
+          GTK_WIDGET(gtk_builder_get_object((ui), (name)))
+
+typedef enum
+{
+    NUMBER,
+    NUMBER_BOLD,
+    OPERATOR,
+    FUNCTION,
+    MEMORY,
+    GROUP,
+    ACTION
+} ButtonClass;
+
+typedef struct {
+    const char *widget_name;
+    const char *data;
+    ButtonClass class;<--- struct member 'ButtonData::class' is never used.
+    const char *tooltip;
+} ButtonData;
+
+static ButtonData button_data[] = {
+    {"pi",                 "π", NUMBER,
+      /* Tooltip for the Pi button */
+      N_("Pi [Ctrl+P]")},
+    {"eulers_number",      "e", NUMBER,
+      /* Tooltip for the Euler's Number button */
+      N_("Euler’s Number")},
+    {"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]")},
+    {"superscript", NULL, NUMBER_BOLD,
+      /* Tooltip for the superscript button */
+      N_("Superscript mode [Ctrl]")},
+    {"exponential", NULL, NUMBER_BOLD,
+      /* Tooltip for the scientific exponent button */
+      N_("Scientific exponent [Ctrl+E]")},
+    {"add",                "+", OPERATOR,
+      /* Tooltip for the add button */
+      N_("Add [+]")},
+    {"subtract",           "−", OPERATOR,
+      /* Tooltip for the subtract button */
+      N_("Subtract [-]")},
+    {"multiply",           "×", OPERATOR,
+      /* Tooltip for the multiply button */
+      N_("Multiply [*]")},
+    {"divide",             "÷", OPERATOR,
+      /* Tooltip for the divide button */
+      N_("Divide [/]")},
+    {"modulus_divide",     " mod ", OPERATOR,
+      /* Tooltip for the modulus divide button */
+      N_("Modulus divide")},
+    {"function",           NULL, FUNCTION,
+      /* Tooltip for the additional functions button */
+      N_("Additional Functions")},
+    {"const",           NULL, FUNCTION,
+      /* Tooltip for the additional constant button */
+      N_("Additional constants")},
+    {"x_pow_y",            "^", FUNCTION,
+      /* Tooltip for the exponent button */
+      N_("Exponent [^ or **]")},
+    {"x_squared",          "²", FUNCTION,
+      /* Tooltip for the square button */
+      N_("Square [Ctrl+2]")},
+    {"percentage",         "%", NUMBER,
+      /* Tooltip for the percentage button */
+      N_("Percentage [%]")},
+    {"factorial",          "!", FUNCTION,
+      /* Tooltip for the factorial button */
+      N_("Factorial [!]")},
+    {"abs",                "|", FUNCTION,
+      /* Tooltip for the absolute value button */
+      N_("Absolute value [|]")},
+    {"arg",                "Arg ", FUNCTION,
+      /* Tooltip for the complex argument component button */
+      N_("Complex argument")},
+    {"conjugate",          "conj ", FUNCTION,
+      /* Tooltip for the complex conjugate button */
+      N_("Complex conjugate")},
+    {"root",               "√", FUNCTION,
+      /* Tooltip for the root button */
+      N_("Root [Ctrl+R]")},
+    {"square_root",        "√", FUNCTION,
+      /* Tooltip for the square root button */
+      N_("Square root [Ctrl+R]")},
+    {"logarithm",          "log ", FUNCTION,
+      /* Tooltip for the logarithm button */
+      N_("Logarithm")},
+    {"natural_logarithm",  "ln ", FUNCTION,
+      /* Tooltip for the natural logarithm button */
+      N_("Natural Logarithm")},
+    {"sine",               "sin ", FUNCTION,
+      /* Tooltip for the sine button */
+      N_("Sine")},
+    {"cosine",             "cos ", FUNCTION,
+      /* Tooltip for the cosine button */
+      N_("Cosine")},
+    {"tangent",            "tan ", FUNCTION,
+      /* Tooltip for the tangent button */
+      N_("Tangent")},
+    {"hyperbolic_sine",    "sinh ", FUNCTION,
+      /* Tooltip for the hyperbolic sine button */
+      N_("Hyperbolic Sine")},
+    {"hyperbolic_cosine",  "cosh ", FUNCTION,
+      /* Tooltip for the hyperbolic cosine button */
+      N_("Hyperbolic Cosine")},
+    {"hyperbolic_tangent", "tanh ", FUNCTION,
+      /* Tooltip for the hyperbolic tangent button */
+      N_("Hyperbolic Tangent")},
+    {"inverse_sine", "asin ", FUNCTION,
+      /* Tooltip for the inverse sine button */
+      N_("Inverse Sine")},
+    {"inverse_cosine", "acos ", FUNCTION,
+      /* Tooltip for the inverse cosine button */
+      N_("Inverse Cosine")},
+    {"inverse_tangent", "atan ", FUNCTION,
+      /* Tooltip for the inverse tangent button */
+      N_("Inverse Tangent")},
+    {"inverse",            "⁻¹", FUNCTION,
+      /* Tooltip for the inverse button */
+      N_("Inverse [Ctrl+I]")},
+    {"and",                "∧", OPERATOR,
+      /* Tooltip for the boolean AND button */
+      N_("Boolean AND")},
+    {"or",                 "∨", OPERATOR,
+      /* Tooltip for the boolean OR button */
+      N_("Boolean OR")},
+    {"xor",                "⊻", OPERATOR,
+      /* Tooltip for the exclusive OR button */
+      N_("Boolean Exclusive OR")},
+    {"not",                "¬", FUNCTION,
+      /* Tooltip for the boolean NOT button */
+      N_("Boolean NOT")},
+    {"integer_portion",    "int ", FUNCTION,
+      /* Tooltip for the integer component button */
+      N_("Integer Component")},
+    {"fractional_portion", "frac ", FUNCTION,
+      /* Tooltip for the fractional component button */
+      N_("Fractional Component")},
+    {"real_portion",       "Re ", FUNCTION,
+      /* Tooltip for the real component button */
+      N_("Real Component")},
+    {"imaginary_portion",  "Im ", FUNCTION,
+      /* Tooltip for the imaginary component button */
+      N_("Imaginary Component")},
+    {"ones_complement",    "ones ", FUNCTION,
+      /* Tooltip for the ones' complement button */
+      N_("Ones' Complement")},
+    {"twos_complement",    "twos ", FUNCTION,
+      /* Tooltip for the two's complement button */
+      N_("Two's Complement")},
+    {"start_group",        "(", GROUP,
+      /* Tooltip for the start group button */
+      N_("Start Group [(]")},
+    {"end_group",          ")", GROUP,
+      /* Tooltip for the end group button */
+      N_("End Group [)]")},
+    {"memory", NULL, MEMORY,
+      /* Tooltip for the memory button */
+      N_("Memory")},
+    {"character", NULL, MEMORY,
+      /* Tooltip for the insert character code button */
+      N_("Insert Character Code")},
+    {"result", NULL, ACTION,
+      /* Tooltip for the solve button */
+      N_("Calculate Result")},
+    {"factor", NULL, ACTION,
+      /* Tooltip for the factor button */
+      N_("Factorize [Ctrl+F]")},
+    {"clear", NULL, GROUP,
+      /* Tooltip for the clear button */
+      N_("Clear Display [Escape]")},
+    {"undo", NULL, GROUP,
+      /* Tooltip for the undo button */
+      N_("Undo [Ctrl+Z]")},
+    {"shift_left", NULL, ACTION,
+      /* Tooltip for the shift left button */
+      N_("Shift Left [<<]")},
+    {"shift_right", NULL, ACTION,
+      /* Tooltip for the shift right button */
+      N_("Shift Right [>>]")},
+    {"finc_compounding_term", NULL, FUNCTION,
+      /* Tooltip for the compounding term button */
+      N_("Compounding Term")},
+    {"finc_double_declining_depreciation", NULL, FUNCTION,
+      /* Tooltip for the double declining depreciation button */
+      N_("Double Declining Depreciation")},
+    {"finc_future_value", NULL, FUNCTION,
+      /* Tooltip for the future value button */
+      N_("Future Value")},
+    {"finc_term", NULL, FUNCTION,
+      /* Tooltip for the financial term button */
+      N_("Financial Term")},
+    {"finc_sum_of_the_years_digits_depreciation", NULL, FUNCTION,
+      /* Tooltip for the sum of the years digits depreciation button */
+      N_("Sum of the Years Digits Depreciation")},
+    {"finc_straight_line_depreciation", NULL, FUNCTION,
+      /* Tooltip for the straight line depreciation button */
+      N_("Straight Line Depreciation")},
+    {"finc_periodic_interest_rate", NULL, FUNCTION,
+      /* Tooltip for the periodic interest rate button */
+      N_("Periodic Interest Rate")},
+    {"finc_present_value", NULL, FUNCTION,
+      /* Tooltip for the present value button */
+      N_("Present Value")},
+    {"finc_periodic_payment", NULL, FUNCTION,
+      /* Tooltip for the periodic payment button */
+      N_("Periodic Payment")},
+    {"finc_gross_profit_margin", NULL, FUNCTION,
+      /* Tooltip for the gross profit margin button */
+      N_("Gross Profit Margin")},
+    {NULL, NULL, 0, NULL}
+};
+
+/* The names of each field in the dialogs for the financial functions */
+static char *finc_dialog_fields[][5] = {
+    {"ctrm_pint", "ctrm_fv",     "ctrm_pv",    NULL,         NULL},
+    {"ddb_cost",  "ddb_life",    "ddb_period", NULL,         NULL},
+    {"fv_pmt",    "fv_pint",     "fv_n",       NULL,         NULL},
+    {"gpm_cost",  "gpm_margin",  NULL,         NULL,         NULL},
+    {"pmt_prin",  "pmt_pint",    "pmt_n",      NULL,         NULL},
+    {"pv_pmt",    "pv_pint",     "pv_n",       NULL,         NULL},
+    {"rate_fv",   "rate_pv",     "rate_n",     NULL,         NULL},
+    {"sln_cost",  "sln_salvage", "sln_life",   NULL,         NULL},
+    {"syd_cost",  "syd_salvage", "syd_life",   "syd_period", NULL},
+    {"term_pmt",  "term_fv",     "term_pint",  NULL,         NULL},
+    {NULL,        NULL,          NULL,         NULL,         NULL}
+};
+
+MathButtons *
+math_buttons_new(MathEquation *equation)
+{
+    return g_object_new(math_buttons_get_type(), "equation", equation, NULL);
+}
+
+static void
+set_data(GtkBuilder *ui, const gchar *object_name, const gchar *name, const char *value)
+{
+    GObject *object;
+    object = gtk_builder_get_object(ui, object_name);
+    if (object)
+        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)
+{
+    GObject *object;
+    object = gtk_builder_get_object(ui, object_name);
+    if (object)
+        g_object_set_data(object, name, GINT_TO_POINTER(value));
+}
+
+static void
+load_finc_dialogs(MathButtons *buttons)
+{
+    int i, j;
+
+    set_int_data(buttons->priv->financial_ui, "ctrm_dialog", "finc_dialog", FINC_CTRM_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "ddb_dialog", "finc_dialog", FINC_DDB_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "fv_dialog", "finc_dialog", FINC_FV_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "gpm_dialog", "finc_dialog", FINC_GPM_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "pmt_dialog", "finc_dialog", FINC_PMT_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "pv_dialog", "finc_dialog", FINC_PV_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "rate_dialog", "finc_dialog", FINC_RATE_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "sln_dialog", "finc_dialog", FINC_SLN_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "syd_dialog", "finc_dialog", FINC_SYD_DIALOG);
+    set_int_data(buttons->priv->financial_ui, "term_dialog", "finc_dialog", FINC_TERM_DIALOG);
+
+    for (i = 0; finc_dialog_fields[i][0] != NULL; i++) {
+        for (j = 0; finc_dialog_fields[i][j]; j++) {
+            GObject *o;
+            o = gtk_builder_get_object (buttons->priv->financial_ui, finc_dialog_fields[i][j]);
+            g_object_set_data(o, "finc_field", GINT_TO_POINTER(j));
+            g_object_set_data(o, "finc_dialog", GINT_TO_POINTER(i));
+        }
+    }
+}
+
+static void
+update_bit_panel(MathButtons *buttons)
+{
+    MPNumber x;
+    gboolean enabled;
+    guint64 bits;
+    int i;
+    GString *label;
+    gint base;
+
+    if (!buttons->priv->bit_panel)
+        return;
+
+    x = mp_new();
+    enabled = math_equation_get_number(buttons->priv->equation, &x);
+
+    if (enabled) {
+        MPNumber max = mp_new();
+        MPNumber fraction = mp_new();
+
+        mp_set_from_unsigned_integer(G_MAXUINT64, &max);
+        mp_fractional_part(&x, &fraction);
+        if (mp_is_negative(&x) || mp_is_greater_than(&x, &max) || !mp_is_zero(&fraction))
+            enabled = FALSE;
+        else
+            bits = mp_to_unsigned_integer(&x);
+        mp_clear(&max);
+        mp_clear(&fraction);
+    }
+
+    gtk_widget_set_sensitive(buttons->priv->bit_panel, enabled);
+    gtk_widget_set_sensitive(buttons->priv->base_label, enabled);
+
+    if (!enabled)
+    {
+        mp_clear(&x);
+        return;
+    }
+
+    for (i = 0; i < MAXBITS; i++) {
+        const gchar *bin_label;
+
+        if (bits & (1LLU << (MAXBITS-i-1)))
+            bin_label = " 1";
+        else
+            bin_label = " 0";
+        gtk_label_set_text(GTK_LABEL(buttons->priv->bit_labels[i]), bin_label);
+    }
+
+    base = math_equation_get_base(buttons->priv->equation);
+    label = g_string_new("");
+    if (base != 8) {
+        if (label->len != 0)
+            g_string_append(label, " = ");
+        g_string_append_printf(label, "%" G_GINT64_MODIFIER "o", bits);
+        g_string_append(label, "₈");
+    }
+    if (base != 10) {
+        if (label->len != 0)
+            g_string_append(label, " = ");
+        g_string_append_printf(label, "%" G_GINT64_MODIFIER "u", bits);
+        g_string_append(label, "₁₀");
+    }
+    if (base != 16) {
+        if (label->len != 0)
+            g_string_append(label, " = ");
+        g_string_append_printf(label, "%" G_GINT64_MODIFIER "X", bits);
+        g_string_append(label, "₁₆");
+    }
+
+    gtk_label_set_text(GTK_LABEL(buttons->priv->base_label), label->str);
+    g_string_free(label, TRUE);
+    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)
+{
+    gint value;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
+    gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
+    gtk_tree_model_get(model, &iter, 1, &value, -1);
+
+    math_buttons_set_programming_base(buttons, value);
+}
+
+static void
+base_changed_cb(MathEquation *equation, GParamSpec *spec, MathButtons *buttons)
+{
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gboolean valid;
+
+    if (buttons->priv->mode != PROGRAMMING)
+        return;
+
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(buttons->priv->base_combo));
+    valid = gtk_tree_model_get_iter_first(model, &iter);
+    buttons->priv->programming_base = math_equation_get_base(buttons->priv->equation);
+
+    while (valid) {
+        gint v;
+
+        gtk_tree_model_get(model, &iter, 1, &v, -1);
+        if (v == buttons->priv->programming_base)
+            break;
+        valid = gtk_tree_model_iter_next(model, &iter);
+    }
+    if (!valid)
+        valid = gtk_tree_model_get_iter_first(model, &iter);<--- Variable 'valid' is assigned a value that is never used.
+
+    gtk_combo_box_set_active_iter(GTK_COMBO_BOX(buttons->priv->base_combo), &iter);
+}
+
+static GtkWidget *
+load_mode(MathButtons *buttons, ButtonMode mode)
+{
+    GtkBuilder *builder, **builder_ptr;
+    gint i;
+    gchar *name;
+    const gchar *path;
+    static gchar *objects[] = { "button_panel", "character_code_dialog", "currency_dialog",
+                                "ctrm_dialog", "ddb_dialog", "fv_dialog", "gpm_dialog",
+                                "pmt_dialog", "pv_dialog", "rate_dialog", "sln_dialog",
+                                "syd_dialog", "term_dialog", "adjustment1", "adjustment2", NULL };
+    GtkWidget *widget, **panel;
+    GError *error = NULL;
+
+    switch (mode) {
+    default:
+    case BASIC:
+        builder_ptr = &buttons->priv->basic_ui;
+        path = UI_BASIC_RESOURCE_PATH;
+        panel = &buttons->priv->bas_panel;
+        break;
+    case ADVANCED:
+        builder_ptr = &buttons->priv->advanced_ui;
+        path = UI_ADVANCED_RESOURCE_PATH;
+        panel = &buttons->priv->adv_panel;
+        break;
+    case FINANCIAL:
+        builder_ptr = &buttons->priv->financial_ui;
+        path = UI_FINANCIAL_RESOURCE_PATH;
+        panel = &buttons->priv->fin_panel;
+        break;
+    case PROGRAMMING:
+        builder_ptr = &buttons->priv->programming_ui;
+        path = UI_PROGRAMMING_RESOURCE_PATH;
+        panel = &buttons->priv->prog_panel;
+        break;
+    }
+
+    if (*panel)
+        goto out;
+
+    builder = *builder_ptr = gtk_builder_new();
+    // FIXME: Show dialog if failed to load
+    gtk_builder_add_objects_from_resource(builder, path, objects, &error);
+    if (error) {
+        g_warning("Error loading button UI: %s", error->message);
+        g_clear_error(&error);
+    }
+    *panel = GET_WIDGET(builder, "button_panel");
+    gtk_box_pack_end(GTK_BOX(buttons), *panel, TRUE, TRUE, 0);
+
+    /* Configure buttons */
+    for (i = 0; button_data[i].widget_name != NULL; i++) {
+        GObject *object;
+        GtkWidget *button;
+
+        name = g_strdup_printf("calc_%s_button", button_data[i].widget_name);
+        object = gtk_builder_get_object(*builder_ptr, name);
+        g_free(name);
+
+        if (!object)
+            continue;
+        button = GTK_WIDGET(object);
+        if (button_data[i].data)
+            g_object_set_data(object, "calc_text", (gpointer) button_data[i].data);
+
+        if (button_data[i].tooltip)
+            gtk_widget_set_tooltip_text(button, _(button_data[i].tooltip));
+    }
+
+    /* Set special button data */
+    for (i = 0; i < 16; i++) {
+        GtkWidget *button;
+
+        name = g_strdup_printf("calc_%d_button", i);
+        button = GET_WIDGET(builder, name);
+        if (button) {
+            gchar buffer[7];
+            gint len;
+
+            g_object_set_data(G_OBJECT(button), "calc_digit", GINT_TO_POINTER(i));
+            len = g_unichar_to_utf8(math_equation_get_digit_text(buttons->priv->equation, i), buffer);
+            buffer[len] = '\0';
+            gtk_button_set_label(GTK_BUTTON(button), buffer);
+        }
+        g_free(name);
+    }
+    widget = GET_WIDGET(builder, "calc_numeric_point_button");
+    if (widget) {
+        MpSerializer *serializer = math_equation_get_serializer(buttons->priv->equation);
+        gchar buffer[7];
+        gint len;
+        len = g_unichar_to_utf8(mp_serializer_get_radix(serializer), buffer);
+        buffer[len] = '\0';
+        gtk_button_set_label(GTK_BUTTON(widget), buffer);
+    }
+
+    widget = GET_WIDGET(builder, "calc_superscript_button");
+    if (widget) {
+        buttons->priv->superscript_toggles = g_list_append(buttons->priv->superscript_toggles, widget);
+        if (math_equation_get_number_mode(buttons->priv->equation) == SUPERSCRIPT)
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
+    }
+    widget = GET_WIDGET(builder, "calc_subscript_button");
+    if (widget) {
+        buttons->priv->subscript_toggles = g_list_append(buttons->priv->subscript_toggles, widget);
+        if (math_equation_get_number_mode(buttons->priv->equation) == SUBSCRIPT)
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
+    }
+
+    /* put the icon name "process-stop" in the buttons
+       button1, button3, button5, button7, button9,
+       button11, button13, button15, button17, button19
+       taken from buttons-financial.ui */
+    for (i = 1; i < 20; i++) {
+        if (i % 2) {
+            widget = GET_WIDGET (builder, g_strdup_printf ("button%d",i));
+            if (GTK_IS_BUTTON(widget))
+                gtk_button_set_image (GTK_BUTTON (widget),
+                                      gtk_image_new_from_icon_name ("process-stop", GTK_ICON_SIZE_BUTTON));
+        }
+    }
+
+    if (mode == PROGRAMMING) {
+        GtkListStore *model;
+        GtkTreeIter iter;
+        GtkCellRenderer *renderer;
+
+        buttons->priv->base_label = GET_WIDGET(builder, "base_label");
+        buttons->priv->character_code_dialog = GET_WIDGET(builder, "character_code_dialog");
+        buttons->priv->character_code_entry = GET_WIDGET(builder, "character_code_entry");
+
+        buttons->priv->bit_panel = GET_WIDGET(builder, "bit_table");
+        for (i = 0; i < MAXBITS; i++) {
+            name = g_strdup_printf("bit_label_%d", i);
+            buttons->priv->bit_labels[i] = GET_WIDGET(builder, name);
+            g_free(name);
+            name = g_strdup_printf("bit_eventbox_%d", i);
+            set_int_data(builder, name, "bit_index", i);
+        }
+
+        buttons->priv->base_combo = GET_WIDGET(builder, "base_combo");
+        model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT);
+        gtk_combo_box_set_model(GTK_COMBO_BOX(buttons->priv->base_combo), GTK_TREE_MODEL(model));
+        gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                           /* Number display mode combo: Binary, e.g. 10011010010₂ */
+                           _("Binary"), 1, 2, -1);
+        gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                           /* Number display mode combo: Octal, e.g. 2322₈ */
+                           _("Octal"), 1, 8, -1);
+        gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                           /* Number display mode combo: Decimal, e.g. 1234 */
+                           _("Decimal"), 1, 10, -1);
+        gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                           /* Number display mode combo: Hexadecimal, e.g. 4D2₁₆ */
+                           _("Hexadecimal"), 1, 16, -1);
+        renderer = gtk_cell_renderer_text_new();
+        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(buttons->priv->base_combo), renderer, TRUE);
+        gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(buttons->priv->base_combo), renderer, "text", 0);
+
+        g_signal_connect(buttons->priv->base_combo, "changed", G_CALLBACK(base_combobox_changed_cb), buttons);
+        g_signal_connect(buttons->priv->equation, "notify::base", G_CALLBACK(base_changed_cb), buttons);
+        base_changed_cb(buttons->priv->equation, NULL, buttons);
+    }
+
+    /* Setup financial functions */
+    if (mode == FINANCIAL) {
+        load_finc_dialogs(buttons);
+
+        set_data(builder, "calc_finc_compounding_term_button", "finc_dialog", "ctrm_dialog");
+        set_data(builder, "calc_finc_double_declining_depreciation_button", "finc_dialog", "ddb_dialog");
+        set_data(builder, "calc_finc_future_value_button", "finc_dialog", "fv_dialog");
+        set_data(builder, "calc_finc_gross_profit_margin_button", "finc_dialog", "gpm_dialog");
+        set_data(builder, "calc_finc_periodic_payment_button", "finc_dialog", "pmt_dialog");
+        set_data(builder, "calc_finc_present_value_button", "finc_dialog", "pv_dialog");
+        set_data(builder, "calc_finc_periodic_interest_rate_button", "finc_dialog", "rate_dialog");
+        set_data(builder, "calc_finc_straight_line_depreciation_button", "finc_dialog", "sln_dialog");
+        set_data(builder, "calc_finc_sum_of_the_years_digits_depreciation_button", "finc_dialog", "syd_dialog");
+        set_data(builder, "calc_finc_term_button", "finc_dialog", "term_dialog");
+    }
+
+    gtk_builder_connect_signals(builder, buttons);
+
+    display_changed_cb(buttons->priv->equation, NULL, buttons);
+
+out:
+    return *panel;
+}
+
+static void
+converter_changed_cb(MathConverter *converter, MathButtons *buttons)
+{
+    Unit *from_unit, *to_unit;
+
+    math_converter_get_conversion(converter, &from_unit, &to_unit);
+    if (buttons->priv->mode == FINANCIAL) {
+        math_equation_set_source_currency(buttons->priv->equation, unit_get_name(from_unit));
+        math_equation_set_target_currency(buttons->priv->equation, unit_get_name(to_unit));
+    }
+    else {
+        math_equation_set_source_units(buttons->priv->equation, unit_get_name(from_unit));
+        math_equation_set_target_units(buttons->priv->equation, unit_get_name(to_unit));
+    }
+
+    g_object_unref(from_unit);
+    g_object_unref(to_unit);
+}
+
+static void
+load_buttons(MathButtons *buttons)
+{
+    GtkWidget *panel;
+
+    if (!gtk_widget_get_visible(GTK_WIDGET(buttons)))
+        return;
+
+    if (!buttons->priv->converter) {
+        buttons->priv->converter = math_converter_new(buttons->priv->equation);
+        g_signal_connect(buttons->priv->converter, "changed", G_CALLBACK(converter_changed_cb), buttons);
+        gtk_box_pack_start(GTK_BOX(buttons), GTK_WIDGET(buttons->priv->converter), FALSE, TRUE, 0);
+    }
+
+    panel = load_mode(buttons, buttons->priv->mode);
+    if (buttons->priv->active_panel == panel)
+        return;
+
+    /* Hide old buttons */
+    if (buttons->priv->active_panel)
+        gtk_widget_hide(buttons->priv->active_panel);
+
+    /* Load and display new buttons */
+    buttons->priv->active_panel = panel;
+    if (panel)
+        gtk_widget_show(panel);
+}
+
+void
+math_buttons_set_mode(MathButtons *buttons, ButtonMode mode)
+{
+    g_return_if_fail(buttons != NULL);
+
+    if (buttons->priv->mode == mode)
+        return;
+
+    buttons->priv->mode = mode;
+
+    if (mode == PROGRAMMING)
+        math_equation_set_base(buttons->priv->equation, buttons->priv->programming_base);
+    else
+        math_equation_set_base(buttons->priv->equation, 10);
+
+    load_buttons(buttons);
+
+    gtk_widget_set_visible(GTK_WIDGET(buttons->priv->converter), mode == ADVANCED || mode == FINANCIAL);
+    if (mode == ADVANCED) {
+        math_converter_set_category(buttons->priv->converter, NULL);
+        math_converter_set_conversion(buttons->priv->converter,
+                                      math_equation_get_source_units(buttons->priv->equation),
+                                      math_equation_get_target_units(buttons->priv->equation));
+    }
+    else if (mode == FINANCIAL) {
+        math_converter_set_category(buttons->priv->converter, "currency");
+        math_converter_set_conversion(buttons->priv->converter,
+                                      math_equation_get_source_currency(buttons->priv->equation),
+                                      math_equation_get_target_currency(buttons->priv->equation));
+    }
+
+    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)
+{
+    g_return_if_fail(buttons != NULL);
+
+    if (base == buttons->priv->programming_base)
+        return;
+
+    buttons->priv->programming_base = base;
+
+    g_settings_set_int(g_settings_var, "base", math_buttons_get_programming_base(buttons));
+
+    if (buttons->priv->mode == PROGRAMMING)
+        math_equation_set_base(buttons->priv->equation, base);
+}
+
+gint
+math_buttons_get_programming_base(MathButtons *buttons)
+{
+    g_return_val_if_fail(buttons != NULL, 10);
+    return buttons->priv->programming_base;
+}
+
+void exponent_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+exponent_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    math_equation_insert_exponent(buttons->priv->equation);
+}
+
+void subtract_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+subtract_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    math_equation_insert_subtract(buttons->priv->equation);
+}
+
+void button_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+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
+solve_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    math_equation_solve(buttons->priv->equation);
+}
+
+void clear_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+clear_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    math_equation_clear(buttons->priv->equation);
+}
+
+void delete_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+delete_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    math_equation_delete(buttons->priv->equation);
+}
+
+void undo_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+undo_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    math_equation_undo(buttons->priv->equation);
+}
+
+static void
+shift_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    math_equation_shift(buttons->priv->equation, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "shiftcount")));
+}
+
+static void
+popup_button_menu(GtkWidget *widget, GtkMenu *menu)
+{
+    gtk_menu_popup_at_widget (menu,
+                              widget,
+                              GDK_GRAVITY_SOUTH_WEST,
+                              GDK_GRAVITY_NORTH_WEST,
+                              NULL);
+}
+
+void memory_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+memory_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    MathVariablePopup *popup;
+    GtkAllocation allocation;
+    gint x, y;
+
+    popup = math_variable_popup_new(buttons->priv->equation);
+    gtk_window_set_transient_for(GTK_WINDOW(popup), GTK_WINDOW(gtk_widget_get_toplevel(widget)));
+
+    gtk_widget_get_allocation(widget, &allocation);
+    gdk_window_get_root_coords(gtk_widget_get_window(widget), allocation.x, allocation.y, &x, &y);
+    gtk_window_move(GTK_WINDOW(popup), x, y);
+    gtk_widget_show(GTK_WIDGET(popup));
+}
+
+void shift_left_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+shift_left_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    if (!buttons->priv->shift_left_menu) {
+        gint i;
+        GtkWidget *menu;
+
+        menu = buttons->priv->shift_left_menu = gtk_menu_new();
+        gtk_menu_set_reserve_toggle_size(GTK_MENU(menu), FALSE);
+
+        for (i = 1; i < 16; i++) {
+            GtkWidget *item, *label;
+            gchar *text;
+
+            if (i < 10) {
+                /* Left Shift Popup: Menu item to shift left by n places (n < 10) */
+                text = g_strdup_printf(ngettext("_%d place", "_%d places", i), i);
+            }
+            else {
+                /* Left Shift Popup: Menu item to shift left by n places (n >= 10) */
+                text = g_strdup_printf(ngettext("%d place", "%d places", i), i);
+            }
+            label = gtk_label_new_with_mnemonic(text);
+
+            item = gtk_menu_item_new();
+            g_object_set_data(G_OBJECT(item), "shiftcount", GINT_TO_POINTER(i));
+            gtk_container_add(GTK_CONTAINER(item), label);
+            gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+            g_signal_connect(item, "activate", G_CALLBACK(shift_cb), buttons);
+
+            gtk_widget_show(label);
+            gtk_widget_show(item);
+            g_free(text);
+        }
+    }
+
+    popup_button_menu(widget, GTK_MENU(buttons->priv->shift_left_menu));
+}
+
+void shift_right_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+shift_right_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    if (!buttons->priv->shift_right_menu) {
+        gint i;
+        GtkWidget *menu;
+
+        menu = buttons->priv->shift_right_menu = gtk_menu_new();
+        gtk_menu_set_reserve_toggle_size(GTK_MENU(menu), FALSE);
+
+        for (i = 1; i < 16; i++) {
+            GtkWidget *item, *label;
+            gchar *text;
+
+            if (i < 10) {
+                /* Right Shift Popup: Menu item to shift right by n places (n < 10) */
+                text = g_strdup_printf(ngettext("_%d place", "_%d places", i), i);
+            }
+            else {
+                /* Right Shift Popup: Menu item to shift right by n places (n >= 10) */
+                text = g_strdup_printf(ngettext("%d place", "%d places", i), i);
+            }
+            label = gtk_label_new_with_mnemonic(text);
+
+            item = gtk_menu_item_new();
+            g_object_set_data(G_OBJECT(item), "shiftcount", GINT_TO_POINTER(-i));
+            gtk_container_add(GTK_CONTAINER(item), label);
+            gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+            g_signal_connect(item, "activate", G_CALLBACK(shift_cb), buttons);
+
+            gtk_widget_show(label);
+            gtk_widget_show(item);
+            g_free(text);
+        }
+    }
+
+    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
+function_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    if (!buttons->priv->function_menu) {
+        gint i;
+        GtkWidget *menu;
+        struct
+        {
+            gchar *name, *function;
+        } functions[] =
+        {
+            { /* Tooltip for the integer component button */
+              N_("Integer Component"), "int " },
+            { /* Tooltip for the fractional component button */
+              N_("Fractional Component"), "frac " },
+            { /* Tooltip for the round button */
+              N_("Round"), "round " },
+            { /* Tooltip for the floor button */
+              N_("Floor"), "floor " },
+            { /* Tooltip for the ceiling button */
+              N_("Ceiling"), "ceil " },
+            { /* Tooltip for the ceiling button */
+              N_("Sign"), "sgn " },
+            { NULL, NULL }
+        };
+
+        menu = buttons->priv->function_menu = gtk_menu_new();
+        gtk_menu_set_reserve_toggle_size(GTK_MENU(menu), FALSE);
+
+        for (i = 0; functions[i].name != NULL; i++) {
+            GtkWidget *item;
+
+            item = gtk_menu_item_new_with_label(_(functions[i].name));
+            g_object_set_data(G_OBJECT(item), "function", g_strdup(functions[i].function));
+            gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+            g_signal_connect(item, "activate", G_CALLBACK(insert_function_cb), buttons);
+            gtk_widget_show(item);
+        }
+    }
+
+    popup_button_menu(widget, GTK_MENU(buttons->priv->function_menu));
+}
+
+static void
+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
+const_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    if (!buttons->priv->const_menu) {
+        gint i;
+        GtkWidget *menu;
+        struct
+        {
+            gchar *name, *constant, *tooltip;
+        } constants[] =
+        {
+            { /* Tooltip for the c₀ component button */
+              N_("Velocity of Light"), "c₀", N_("299,792,458 m/s") },
+            { /* Tooltip for the μ₀ component button */
+              N_("Magnetic constant"), "μ₀", N_("1.2566370614×10⁻⁶ N/A²") },
+            { /* Tooltip for the ε₀ button */
+              N_("Electric constant"), "ε₀", N_("8.85418782×10⁻¹² s⁴A²/m³kg") },
+            { /* Tooltip for the G button */
+              N_("Newtonian constant of gravitation"), "G",  N_("6.67408×10⁻¹¹ m³/(s²kg)") },
+            { /* Tooltip for the h button */
+              N_("Planck constant"), "h", N_("6.62607004×10⁻³⁴ m²kg/s") },
+            { /* Tooltip for the e button */
+              N_("Elementary charge"), "e", N_("1.6021766208(98)×10⁻¹⁹ C") },
+            { /* Tooltip for the mₑ button */
+              N_("Electron mass"), "mₑ", N_("9.10938356×10⁻³¹ kg") },
+            { /* Tooltip for the mₚ button */
+              N_("Proton mass"), "mₚ", N_("1.672621898(21)×10⁻²⁷ kg") },
+            { /* Tooltip for the Nₐ button */
+              N_("Avogadro constant"), "Nₐ", N_("6.02214086×10²³ mol⁻¹") },
+            { NULL, NULL, NULL }
+        };
+
+        menu = buttons->priv->const_menu = gtk_menu_new();
+        gtk_menu_set_reserve_toggle_size(GTK_MENU(menu), FALSE);
+
+        for (i = 0; constants[i].name != NULL; i++) {
+            GtkWidget *item;
+
+            item = gtk_menu_item_new_with_label(_(constants[i].name));
+            gtk_widget_set_tooltip_text(item, _(constants[i].tooltip));
+            g_object_set_data(G_OBJECT(item), "const", g_strdup(constants[i].constant));
+            gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+            g_signal_connect(item, "activate", G_CALLBACK(insert_const_cb), buttons);
+            gtk_widget_show(item);
+        }
+    }
+
+    popup_button_menu(widget, GTK_MENU(buttons->priv->const_menu));
+}
+
+void factorize_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+factorize_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    math_equation_factorize(buttons->priv->equation);
+}
+
+void digit_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+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
+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
+finc_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    gchar *name;
+
+    name = g_object_get_data(G_OBJECT(widget), "finc_dialog");
+    gtk_dialog_run(GTK_DIALOG(GET_WIDGET(buttons->priv->financial_ui, name)));
+    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
+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
+finc_activate_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    gint dialog, field;
+
+    dialog = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "finc_dialog"));
+    field = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "finc_field"));
+
+    if (finc_dialog_fields[dialog][field+1] == NULL) {
+        GtkWidget *dialog_widget;
+        dialog_widget = gtk_widget_get_toplevel(widget);
+        if (gtk_widget_is_toplevel(dialog_widget)) {
+            gtk_dialog_response(GTK_DIALOG(dialog_widget),
+                                GTK_RESPONSE_OK);
+            return;
+        }
+    }
+    else {
+        GtkWidget *next_widget;
+        next_widget = GET_WIDGET(buttons->priv->financial_ui, finc_dialog_fields[dialog][field+1]);
+        gtk_widget_grab_focus(next_widget);
+    }
+}
+
+void finc_response_cb(GtkWidget *widget, gint response_id, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+finc_response_cb(GtkWidget *widget, gint response_id, MathButtons *buttons)
+{
+    int dialog;
+    int i;
+    MPNumber arg[4];
+    GtkWidget *entry;
+
+    if (response_id != GTK_RESPONSE_OK)
+        return;
+
+    dialog = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "finc_dialog"));
+
+    for (i = 0; i < 4; i++) {
+        arg[i] = mp_new();
+        if (finc_dialog_fields[dialog][i] == NULL) {
+            continue;
+        }
+        entry = GET_WIDGET(buttons->priv->financial_ui, finc_dialog_fields[dialog][i]);
+        mp_set_from_string(gtk_entry_get_text(GTK_ENTRY(entry)), 10, &arg[i]);
+        gtk_entry_set_text(GTK_ENTRY(entry), "0");
+    }
+    gtk_widget_grab_focus(GET_WIDGET(buttons->priv->financial_ui, finc_dialog_fields[dialog][0]));
+
+    do_finc_expression(buttons->priv->equation, dialog, &arg[0], &arg[1], &arg[2], &arg[3]);
+
+    for (i = 0; i < 4; i++) {
+        mp_clear(&arg[i]);
+    }
+}
+
+void character_code_dialog_response_cb(GtkWidget *dialog, gint response_id, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+character_code_dialog_response_cb(GtkWidget *dialog, gint response_id, MathButtons *buttons)
+{
+    const gchar *text;
+
+    text = gtk_entry_get_text(GTK_ENTRY(buttons->priv->character_code_entry));
+
+    if (response_id == GTK_RESPONSE_OK) {
+        MPNumber x = mp_new();
+        int i = 0;
+
+        mp_set_from_integer(0, &x);
+        while (TRUE) {
+            mp_add_integer(&x, text[i], &x);
+            if (text[i+1]) {
+                 mp_shift(&x, 8, &x);
+                 i++;
+            }
+            else
+                break;
+        }
+        math_equation_insert_number(buttons->priv->equation, &x);
+        mp_clear(&x);
+    }
+    gtk_widget_hide(dialog);
+}
+
+void character_code_dialog_activate_cb(GtkWidget *entry, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+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
+character_code_dialog_delete_cb(GtkWidget *dialog, GdkEvent *event, MathButtons *buttons)
+{
+    character_code_dialog_response_cb(dialog, GTK_RESPONSE_CANCEL, buttons);
+    return TRUE;
+}
+
+gboolean bit_toggle_cb(GtkWidget *event_box, GdkEventButton *event, MathButtons *buttons);
+G_MODULE_EXPORT
+gboolean
+bit_toggle_cb(GtkWidget *event_box, GdkEventButton *event, MathButtons *buttons)
+{
+    math_equation_toggle_bit(buttons->priv->equation, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(event_box), "bit_index")));
+    return TRUE;
+}
+
+static void
+remove_trailing_spaces(MathButtons *buttons)
+{
+    GtkTextMark *insert_mark;
+    GtkTextIter start, end;
+    insert_mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER(buttons->priv->equation));
+    gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(buttons->priv->equation), &end, insert_mark);
+    start = end;
+    while (gtk_text_iter_backward_char(&start)) {
+        if (!g_unichar_isspace(gtk_text_iter_get_char(&start)))
+            break;
+        gtk_text_buffer_delete(GTK_TEXT_BUFFER(buttons->priv->equation), &start, &end);
+    }
+}
+
+void set_superscript_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+set_superscript_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
+        math_equation_set_number_mode(buttons->priv->equation, SUPERSCRIPT);
+        if (!gtk_text_buffer_get_has_selection(GTK_TEXT_BUFFER(buttons->priv->equation))) {
+            remove_trailing_spaces(buttons);
+        }
+    }
+    else if (math_equation_get_number_mode(buttons->priv->equation) == SUPERSCRIPT)
+        math_equation_set_number_mode(buttons->priv->equation, NORMAL);
+}
+
+void set_subscript_cb(GtkWidget *widget, MathButtons *buttons);
+G_MODULE_EXPORT
+void
+set_subscript_cb(GtkWidget *widget, MathButtons *buttons)
+{
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
+        math_equation_set_number_mode(buttons->priv->equation, SUBSCRIPT);
+        if (!gtk_text_buffer_get_has_selection(GTK_TEXT_BUFFER(buttons->priv->equation))) {
+            remove_trailing_spaces(buttons);
+        }
+    }
+    else if (math_equation_get_number_mode(buttons->priv->equation) == SUBSCRIPT)
+        math_equation_set_number_mode(buttons->priv->equation, NORMAL);
+}
+
+static void
+number_mode_changed_cb(MathEquation *equation, GParamSpec *spec, MathButtons *buttons)
+{
+    GList *i;
+    NumberMode mode;
+
+    mode = math_equation_get_number_mode(equation);
+
+    for (i = buttons->priv->superscript_toggles; i; i = i->next) {
+        GtkWidget *widget = i->data;
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), mode == SUPERSCRIPT);
+    }
+    for (i = buttons->priv->subscript_toggles; i; i = i->next) {
+        GtkWidget *widget = i->data;
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), mode == SUBSCRIPT);
+    }
+}
+
+static void
+math_buttons_set_property(GObject      *object,
+                          guint         prop_id,
+                          const GValue *value,
+                          GParamSpec   *pspec)
+{
+    MathButtons *self;
+
+    self = MATH_BUTTONS(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        self->priv->equation = g_value_get_object(value);
+        math_buttons_set_mode(self, self->priv->mode);
+        g_signal_connect(self->priv->equation, "notify::display", G_CALLBACK(display_changed_cb), self);
+        g_signal_connect(self->priv->equation, "notify::number-mode", G_CALLBACK(number_mode_changed_cb), self);
+        g_signal_connect(self->priv->equation, "notify::angle-units", G_CALLBACK(display_changed_cb), self);
+        g_signal_connect(self->priv->equation, "notify::number-format", G_CALLBACK(display_changed_cb), self);
+        number_mode_changed_cb(self->priv->equation, NULL, self);
+        display_changed_cb(self->priv->equation, NULL, self);
+        break;
+    case PROP_MODE:
+        math_buttons_set_mode(self, g_value_get_int(value));
+        break;
+    case PROP_PROGRAMMING_BASE:
+        math_buttons_set_programming_base(self, g_value_get_int(value));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_buttons_get_property(GObject    *object,
+                          guint       prop_id,
+                          GValue     *value,
+                          GParamSpec *pspec)
+{
+    MathButtons *self;
+
+    self = MATH_BUTTONS(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        g_value_set_object(value, self->priv->equation);
+        break;
+    case PROP_MODE:
+        g_value_set_int(value, self->priv->mode);
+        break;
+    case PROP_PROGRAMMING_BASE:
+        g_value_set_int(value, math_buttons_get_programming_base(self));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_buttons_class_init(MathButtonsClass *klass)
+{
+    static GEnumValue button_mode_values[] =
+    {
+      {BASIC,       "basic",       "basic"},
+      {ADVANCED,    "advanced",    "advanced"},
+      {FINANCIAL,   "financial",   "financial"},
+      {PROGRAMMING, "programming", "programming"},
+      {0, NULL, NULL}
+    };
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    object_class->get_property = math_buttons_get_property;
+    object_class->set_property = math_buttons_set_property;
+
+    button_mode_type = g_enum_register_static("ButtonMode", button_mode_values);
+
+    g_object_class_install_property(object_class,
+                                    PROP_EQUATION,
+                                    g_param_spec_object("equation",
+                                                        "equation",
+                                                        "Equation being controlled",
+                                                        math_equation_get_type(),
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+    g_object_class_install_property(object_class,
+                                    PROP_MODE,
+                                    g_param_spec_enum("mode",
+                                                      "mode",
+                                                      "Button mode",
+                                                      button_mode_type,
+                                                      BASIC,
+                                                      G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_PROGRAMMING_BASE,
+                                    g_param_spec_int("programming-base",
+                                                     "programming-base",
+                                                     "Base to use in programming mode",
+                                                     2, 16, 10,
+                                                     G_PARAM_READWRITE));
+}
+
+static void
+math_buttons_init(MathButtons *buttons)
+{
+    buttons->priv = math_buttons_get_instance_private (buttons);
+    gtk_box_set_spacing(GTK_BOX(buttons), 6);
+    gtk_orientable_set_orientation (GTK_ORIENTABLE (buttons),
+                                    GTK_ORIENTATION_VERTICAL);
+    buttons->priv->programming_base = 10;
+    g_signal_connect(G_OBJECT(buttons), "show", G_CALLBACK(load_buttons), NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/23.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/23.html new file mode 100644 index 0000000..9d47ad8 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/23.html @@ -0,0 +1,343 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MATH_CONVERTER_H
+#define MATH_CONVERTER_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-equation.h"
+#include "unit.h"
+
+G_BEGIN_DECLS
+
+#define MATH_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_converter_get_type(), MathConverter))
+
+typedef struct MathConverterPrivate MathConverterPrivate;
+
+typedef struct
+{
+    GtkHBox parent_instance;
+    MathConverterPrivate *priv;
+} MathConverter;
+
+typedef struct
+{
+    GtkHBoxClass parent_class;
+
+    void (*changed)(MathConverter *converter);
+} MathConverterClass;
+
+GType math_converter_get_type(void);
+
+MathConverter *math_converter_new(MathEquation *equation);
+
+void math_converter_set_category(MathConverter *converter, const gchar *category);
+
+const gchar *math_converter_get_category(MathConverter *converter);
+
+void math_converter_set_conversion(MathConverter *converter, /*const gchar *category,*/ const gchar *unit_a, const gchar *unit_b);
+
+void math_converter_get_conversion(MathConverter *converter, Unit **from_unit, Unit **to_unit);
+
+G_END_DECLS
+
+#endif /* MATH_CONVERTER_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/24.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/24.html new file mode 100644 index 0000000..d9d2a49 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/24.html @@ -0,0 +1,317 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MATH_VARIABLE_POPUP_H
+#define MATH_VARIABLE_POPUP_H
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "math-equation.h"
+
+G_BEGIN_DECLS
+
+#define MATH_VARIABLE_POPUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_variable_popup_get_type(), MathVariablePopup))
+
+typedef struct MathVariablePopupPrivate MathVariablePopupPrivate;
+
+typedef struct
+{
+    GtkWindow parent_instance;
+    MathVariablePopupPrivate *priv;
+} MathVariablePopup;
+
+typedef struct
+{
+    GtkWindowClass parent_class;
+} MathVariablePopupClass;
+
+GType math_variable_popup_get_type(void);
+
+MathVariablePopup *math_variable_popup_new(MathEquation *equation);
+
+G_END_DECLS
+
+#endif /* MATH_VARIABLE_POPUP_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/25.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/25.html new file mode 100644 index 0000000..38c8c2c --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/25.html @@ -0,0 +1,1095 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-converter.h"
+#include "unit-manager.h"
+#include "currency-manager.h"
+
+enum {
+    CHANGED,
+    LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0, };
+
+struct MathConverterPrivate
+{
+    MathEquation *equation;
+
+    gchar *category;
+
+    GtkWidget *from_combo;
+    GtkWidget *to_combo;
+
+    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)
+{
+    MathConverter *converter = g_object_new(math_converter_get_type(), NULL);
+    converter->priv->equation = g_object_ref(equation);
+    g_signal_connect(converter->priv->equation, "notify::display", G_CALLBACK(display_changed_cb), converter);
+    update_from_model(converter);
+    return converter;
+}
+
+static gboolean
+convert_equation(MathConverter *converter, const MPNumber *x, MPNumber *z)
+{
+    GtkTreeIter from_iter, to_iter;
+    UnitCategory *category = NULL;
+    Unit *source_unit = NULL, *target_unit = NULL;
+    gboolean result;
+
+    if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(converter->priv->from_combo), &from_iter) ||
+        !gtk_combo_box_get_active_iter(GTK_COMBO_BOX(converter->priv->to_combo), &to_iter))
+        return FALSE;
+
+    gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(converter->priv->from_combo)), &from_iter, 1, &category, 2, &source_unit, -1);
+    gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(converter->priv->to_combo)), &to_iter, 2, &target_unit, -1);
+
+    result = unit_category_convert(category, x, source_unit, target_unit, z);
+
+    if (category)
+        g_object_unref(category);
+    if (source_unit)
+        g_object_unref(source_unit);
+    if (target_unit)
+        g_object_unref(target_unit);
+
+    return result;
+}
+
+static void
+update_result_label(MathConverter *converter)
+{
+    MPNumber x = mp_new();
+    MPNumber z = mp_new();
+    gboolean enabled;
+
+    if (!converter->priv->result_label)
+        return;
+
+    if (math_equation_get_number(converter->priv->equation, &x))
+        enabled = convert_equation(converter, &x, &z);
+    else
+        enabled = FALSE;
+
+    gtk_widget_set_sensitive(converter->priv->result_label, enabled);
+    if (enabled) {
+        gchar *source_text, *target_text, *label;
+        Unit *source_unit, *target_unit;
+
+        math_converter_get_conversion(converter, &source_unit, &target_unit);
+
+        source_text = unit_format(source_unit, &x);
+        target_text = unit_format(target_unit, &z);
+        label = g_strdup_printf("%s = %s", source_text, target_text);
+        gtk_label_set_text(GTK_LABEL(converter->priv->result_label), label);
+
+        g_free(source_text);
+        g_free(target_text);
+        g_free(label);
+
+        g_object_unref(source_unit);
+        g_object_unref(target_unit);
+    }
+    mp_clear(&x);
+    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)
+{
+    GtkTreeStore *from_model;
+
+    from_model = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_OBJECT);
+
+    if (converter->priv->category == NULL) {
+        const GList *categories, *iter;
+
+        categories = unit_manager_get_categories(unit_manager_get_default());
+        for (iter = categories; iter; iter = iter->next) {
+            UnitCategory *category = iter->data;
+            GtkTreeIter parent;
+            const GList *unit_iter;
+
+            gtk_tree_store_append(from_model, &parent, NULL);
+            gtk_tree_store_set(from_model, &parent, 0, unit_category_get_display_name(category), 1, category, -1);
+
+            for (unit_iter = unit_category_get_units(category); unit_iter; unit_iter = unit_iter->next) {
+                Unit *unit = unit_iter->data;
+                GtkTreeIter iter_new_row;
+
+                gtk_tree_store_append(from_model, &iter_new_row, &parent);
+                gtk_tree_store_set(from_model, &iter_new_row, 0, unit_get_display_name(unit), 1, category, 2, unit, -1);
+            }
+        }
+    }
+    else {
+        UnitCategory *category;
+        const GList *unit_iter;
+
+        category = unit_manager_get_category(unit_manager_get_default(), converter->priv->category);
+        for (unit_iter = unit_category_get_units(category); unit_iter; unit_iter = unit_iter->next) {
+            Unit *unit = unit_iter->data;
+            GtkTreeIter iter;
+
+            gtk_tree_store_append(from_model, &iter, NULL);
+            gtk_tree_store_set(from_model, &iter, 0, unit_get_display_name(unit), 1, category, 2, unit, -1);
+        }
+    }
+
+    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)
+{
+    g_return_if_fail (converter != NULL);
+
+    if (category == NULL && converter->priv->category == NULL)
+        return;
+    if (category != NULL && converter->priv->category != NULL && strcmp(category, converter->priv->category) == 0)
+        return;
+
+    g_free(converter->priv->category);
+    converter->priv->category = g_strdup(category);
+
+    update_from_model(converter);
+}
+
+const gchar *
+math_converter_get_category(MathConverter *converter)
+{
+    g_return_val_if_fail (converter != NULL, NULL);
+    return converter->priv->category;
+}
+
+static gboolean
+iter_is_unit(GtkTreeModel *model, GtkTreeIter *iter, const Unit *unit)
+{
+    Unit *u;
+
+    gtk_tree_model_get(model, iter, 2, &u, -1);
+
+    if (!u)
+        return FALSE;
+
+    g_object_unref(u);
+    if (u == unit)
+        return TRUE;
+
+    return FALSE;
+}
+
+static gboolean
+set_active_unit(GtkComboBox *combo, GtkTreeIter *iter, Unit *unit)
+{
+    GtkTreeModel *model;
+    GtkTreeIter child_iter;
+
+    model = gtk_combo_box_get_model(combo);
+
+    if (iter && iter_is_unit(model, iter, unit)) {
+        gtk_combo_box_set_active_iter(combo, iter);
+        return TRUE;
+    }
+
+    if (!gtk_tree_model_iter_children(model, &child_iter, iter))
+        return FALSE;
+
+    do {
+        if (set_active_unit(combo, &child_iter, unit))
+            return TRUE;
+    } while (gtk_tree_model_iter_next(model, &child_iter));
+
+    return FALSE;
+}
+
+void
+math_converter_set_conversion(MathConverter *converter, /*const gchar *category,*/ const gchar *unit_a, const gchar *unit_b)
+{
+    Unit *ua;
+    Unit *ub;
+
+    g_return_if_fail (converter != NULL);
+    g_return_if_fail (unit_a != NULL);
+    g_return_if_fail (unit_b != NULL);
+
+    ua = unit_manager_get_unit_by_name(unit_manager_get_default(), unit_a);
+    ub = unit_manager_get_unit_by_name(unit_manager_get_default(), unit_b);
+    if (!ua || !ub)
+    {
+        GtkTreeModel *model;
+        GtkTreeIter iter;
+
+        /* Select the first unit */
+        model = gtk_combo_box_get_model(GTK_COMBO_BOX(converter->priv->from_combo));
+        if (gtk_tree_model_get_iter_first(model, &iter)) {
+            GtkTreeIter child_iter;
+            while (gtk_tree_model_iter_children(model, &child_iter, &iter))
+                iter = child_iter;
+            gtk_combo_box_set_active_iter(GTK_COMBO_BOX(converter->priv->from_combo), &iter);
+        }
+        return;
+    }
+
+    set_active_unit(GTK_COMBO_BOX(converter->priv->from_combo), NULL, ua);
+    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)
+{
+    GtkTreeIter from_iter, to_iter;
+
+    g_return_if_fail (converter != NULL);
+    g_return_if_fail (from_unit != NULL);
+    g_return_if_fail (to_unit != NULL);
+
+    gtk_combo_box_get_active_iter(GTK_COMBO_BOX(converter->priv->from_combo), &from_iter);
+    gtk_combo_box_get_active_iter(GTK_COMBO_BOX(converter->priv->to_combo), &to_iter);
+
+    gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(converter->priv->from_combo)), &from_iter, 2, from_unit, -1);
+    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)
+{
+    signals[CHANGED] =
+        g_signal_new("changed",
+                     G_TYPE_FROM_CLASS (klass),
+                     G_SIGNAL_RUN_LAST,
+                     G_STRUCT_OFFSET (MathConverterClass, changed),
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE, 0);
+}
+
+static void
+from_combobox_changed_cb(GtkWidget *combo, MathConverter *converter)
+{
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    UnitCategory *category;
+    Unit *unit;
+    const GList *unit_iter;
+
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
+    if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter))
+        return;
+    gtk_tree_model_get(model, &iter, 1, &category, 2, &unit, -1);
+
+    /* Set the to combobox to be the list of units can be converted to */
+    model = GTK_TREE_MODEL(gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_OBJECT));
+    for (unit_iter = unit_category_get_units(category); unit_iter; unit_iter = unit_iter->next) {
+        Unit *u = unit_iter->data;
+        if (u == unit)
+            continue;
+        gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+        gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, unit_get_display_name(u), 1, category, 2, u, -1);
+    }
+    gtk_combo_box_set_model(GTK_COMBO_BOX(converter->priv->to_combo), model);
+
+    /* Select the first possible unit */
+    gtk_combo_box_set_active(GTK_COMBO_BOX(converter->priv->to_combo), 0);
+
+    g_object_unref(category);
+    g_object_unref(unit);
+}
+
+static void
+to_combobox_changed_cb(GtkWidget *combo, MathConverter *converter)
+{
+    /* Conversion must have changed */
+    update_result_label(converter);
+
+    g_signal_emit(converter, signals[CHANGED], 0);
+}
+
+static void
+from_cell_data_func(GtkCellLayout   *cell_layout,
+                    GtkCellRenderer *cell,
+                    GtkTreeModel    *tree_model,
+                    GtkTreeIter     *iter,
+                    gpointer         data)
+{
+    g_object_set(cell, "sensitive", !gtk_tree_model_iter_has_child(tree_model, iter), NULL);
+}
+
+static void
+currency_updated_cb(CurrencyManager *manager, MathConverter *converter)
+{
+    update_result_label(converter);
+}
+
+static void
+swap_button_clicked_cb(GtkButton *button, MathConverter *converter)
+{
+    Unit *from_unit, *to_unit;
+    MPNumber x = mp_new();
+    MPNumber z = mp_new();
+
+    if (math_equation_get_number(converter->priv->equation, &x) &&
+        convert_equation(converter, &x, &z))
+        math_equation_set_number(converter->priv->equation, &z);
+
+    math_converter_get_conversion(converter, &from_unit, &to_unit);
+    set_active_unit(GTK_COMBO_BOX(converter->priv->from_combo), NULL, to_unit);
+    set_active_unit(GTK_COMBO_BOX(converter->priv->to_combo), NULL, from_unit);
+
+    update_result_label(converter);
+
+    g_object_unref(from_unit);
+    g_object_unref(to_unit);
+    mp_clear(&x);
+    mp_clear(&z);
+}
+
+static void
+math_converter_init(MathConverter *converter)
+{
+    GtkWidget *hbox, *label, *swap_button;
+    GtkCellRenderer *renderer;
+
+    converter->priv = math_converter_get_instance_private (converter);
+
+    gtk_box_set_spacing(GTK_BOX(converter), 6);
+    gtk_orientable_set_orientation (GTK_ORIENTABLE (converter),
+                                    GTK_ORIENTATION_HORIZONTAL);
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+    gtk_widget_show(hbox);
+    gtk_box_pack_start(GTK_BOX(converter), hbox, FALSE, TRUE, 0);
+
+    converter->priv->from_combo = gtk_combo_box_new ();
+
+    renderer = gtk_cell_renderer_text_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(converter->priv->from_combo), renderer, TRUE);
+    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(converter->priv->from_combo), renderer, "text", 0);
+    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(converter->priv->from_combo),
+                                       renderer,
+                                       from_cell_data_func,
+                                       NULL, NULL);
+    g_signal_connect(converter->priv->from_combo, "changed", G_CALLBACK(from_combobox_changed_cb), converter);
+    gtk_widget_show(converter->priv->from_combo);
+    gtk_box_pack_start(GTK_BOX(hbox), converter->priv->from_combo, FALSE, TRUE, 0);
+
+    label = gtk_label_new(/* Label that is displayed between the two conversion combo boxes, e.g. "[degrees] in [radians]" */
+                          _(" in "));
+    gtk_widget_show(label);
+    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 5);
+
+    converter->priv->to_combo = gtk_combo_box_new();
+    renderer = gtk_cell_renderer_text_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(converter->priv->to_combo), renderer, TRUE);
+    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(converter->priv->to_combo), renderer, "text", 0);
+    g_signal_connect(converter->priv->to_combo, "changed", G_CALLBACK(to_combobox_changed_cb), converter);
+    gtk_widget_show(converter->priv->to_combo);
+    gtk_box_pack_start(GTK_BOX(hbox), converter->priv->to_combo, FALSE, TRUE, 0);
+
+    swap_button = gtk_button_new_with_label ("⇆");
+    gtk_widget_set_tooltip_text (swap_button,
+                                 /* Tooltip for swap conversion button */
+                                 _("Switch conversion units"));
+    gtk_button_set_relief (GTK_BUTTON (swap_button), GTK_RELIEF_NONE);
+    g_signal_connect (swap_button, "clicked", G_CALLBACK (swap_button_clicked_cb), converter);
+    gtk_widget_show(swap_button);
+    gtk_box_pack_start(GTK_BOX(hbox), swap_button, FALSE, TRUE, 0);
+
+    converter->priv->result_label = gtk_label_new("");
+    gtk_widget_set_halign (converter->priv->result_label, GTK_ALIGN_END);
+    gtk_widget_set_sensitive(converter->priv->result_label, FALSE);
+    gtk_widget_show(converter->priv->result_label);
+    gtk_box_pack_start(GTK_BOX(converter), converter->priv->result_label, TRUE, TRUE, 0);
+
+    g_signal_connect(currency_manager_get_default(), "updated", G_CALLBACK(currency_updated_cb), converter);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/26.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/26.html new file mode 100644 index 0000000..1045189 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/26.html @@ -0,0 +1,1185 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-display.h"
+
+enum {
+    PROP_0,
+    PROP_EQUATION
+};
+
+struct MathDisplayPrivate
+{
+    /* Equation being displayed */
+    MathEquation *equation;
+
+    /* Display widget */
+    GtkWidget *text_view;
+
+    /* Buffer that shows errors etc */
+    GtkTextBuffer *info_buffer;
+
+    /* Spinner widget that shows if we're calculating a response */
+    GtkWidget *spinner;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MathDisplay, math_display, GTK_TYPE_VIEWPORT);
+
+MathDisplay *
+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)
+{
+    int state;
+    guint32 c;
+    guint new_keyval = 0;
+
+    /* Treat keypad keys as numbers even when numlock is off */
+    switch(event->keyval)
+    {
+    case GDK_KEY_KP_Delete: /* Period without numlock */
+        new_keyval = GDK_KEY_KP_Decimal;
+        break;
+    case GDK_KEY_KP_Insert:
+        new_keyval = GDK_KEY_0;
+        break;
+    case GDK_KEY_KP_End:
+        new_keyval = GDK_KEY_1;
+        break;
+    case GDK_KEY_KP_Down:
+        new_keyval = GDK_KEY_2;
+        break;
+    case GDK_KEY_KP_Page_Down:
+        new_keyval = GDK_KEY_3;
+        break;
+    case GDK_KEY_KP_Left:
+        new_keyval = GDK_KEY_4;
+        break;
+    case GDK_KEY_KP_Begin: /* This is apparently what "5" does when numlock is off. */
+        new_keyval = GDK_KEY_5;
+        break;
+    case GDK_KEY_KP_Right:
+        new_keyval = GDK_KEY_6;
+        break;
+    case GDK_KEY_KP_Home:
+        new_keyval = GDK_KEY_7;
+        break;
+    case GDK_KEY_KP_Up:
+        new_keyval = GDK_KEY_8;
+        break;
+    case GDK_KEY_KP_Page_Up:
+        new_keyval = GDK_KEY_9;
+        break;
+    }
+
+    if (new_keyval) {
+        gboolean result;
+        GdkEvent *new_event;
+
+        new_event = gdk_event_copy((GdkEvent *)event);
+        ((GdkEventKey *)new_event)->keyval = new_keyval;
+        g_signal_emit_by_name(widget, "key-press-event", new_event, &result);
+        gdk_event_free(new_event);
+        return result;
+    }
+
+    state = event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK);
+    c = gdk_keyval_to_unicode(event->keyval);
+
+    /* Solve on enter */
+    if (event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter) {
+        math_equation_solve(display->priv->equation);
+        return TRUE;
+    }
+
+    /* Clear on escape */
+    if ((event->keyval == GDK_KEY_Escape && state == 0) ||
+        (event->keyval == GDK_KEY_BackSpace && state == GDK_CONTROL_MASK) ||
+        (event->keyval == GDK_KEY_Delete && state == GDK_SHIFT_MASK)) {
+        math_equation_clear(display->priv->equation);
+        return TRUE;
+    }
+
+    /* Numeric keypad will often insert '.' regardless of locale */
+    if (event->keyval == GDK_KEY_KP_Decimal) {
+        math_equation_insert_numeric_point(display->priv->equation);
+        return TRUE;
+    }
+
+    /* Substitute */
+    if (state == 0) {
+        if (c == '*') {
+            math_equation_insert(display->priv->equation, "×");
+            return TRUE;
+        }
+        if (c == '/') {
+            math_equation_insert(display->priv->equation, "÷");
+            return TRUE;
+        }
+        if (c == '-') {
+            math_equation_insert_subtract(display->priv->equation);
+            return TRUE;
+        }
+    }
+
+    /* Shortcuts */
+    if (state == GDK_CONTROL_MASK) {
+        switch(event->keyval)
+        {
+        case GDK_KEY_bracketleft:
+            math_equation_insert(display->priv->equation, "⌈");
+            return TRUE;
+        case GDK_KEY_bracketright:
+            math_equation_insert(display->priv->equation, "⌉");
+            return TRUE;
+        case GDK_KEY_e:
+            math_equation_insert_exponent(display->priv->equation);
+            return TRUE;
+        case GDK_KEY_f:
+            math_equation_factorize(display->priv->equation);
+            return TRUE;
+        case GDK_KEY_i:
+            math_equation_insert(display->priv->equation, "⁻¹");
+            return TRUE;
+        case GDK_KEY_p:
+            math_equation_insert(display->priv->equation, "π");
+            return TRUE;
+        case GDK_KEY_r:
+            math_equation_insert(display->priv->equation, "√");
+            return TRUE;
+        case GDK_KEY_u:
+            math_equation_insert(display->priv->equation, "µ");
+            return TRUE;
+        case GDK_KEY_minus:
+             math_equation_insert(display->priv->equation, "⁻");
+             return TRUE;
+        case GDK_KEY_apostrophe:
+             math_equation_insert(display->priv->equation, "°");
+             return TRUE;
+        }
+    }
+    if (state == GDK_MOD1_MASK) {
+        switch(event->keyval)
+        {
+        case GDK_KEY_bracketleft:
+            math_equation_insert(display->priv->equation, "⌊");
+            return TRUE;
+        case GDK_KEY_bracketright:
+            math_equation_insert(display->priv->equation, "⌋");
+            return TRUE;
+        }
+    }
+
+    if (state == GDK_CONTROL_MASK || math_equation_get_number_mode(display->priv->equation) == SUPERSCRIPT) {
+        switch(event->keyval)
+        {
+        case GDK_KEY_0:
+        case GDK_KEY_KP_0:
+            math_equation_insert(display->priv->equation, "⁰");
+            return TRUE;
+        case GDK_KEY_1:
+        case GDK_KEY_KP_1:
+            math_equation_insert(display->priv->equation, "¹");
+            return TRUE;
+        case GDK_KEY_2:
+        case GDK_KEY_KP_2:
+            math_equation_insert(display->priv->equation, "²");
+            return TRUE;
+        case GDK_KEY_3:
+        case GDK_KEY_KP_3:
+            math_equation_insert(display->priv->equation, "³");
+            return TRUE;
+        case GDK_KEY_4:
+        case GDK_KEY_KP_4:
+            math_equation_insert(display->priv->equation, "⁴");
+            return TRUE;
+        case GDK_KEY_5:
+        case GDK_KEY_KP_5:
+            math_equation_insert(display->priv->equation, "⁵");
+            return TRUE;
+        case GDK_KEY_6:
+        case GDK_KEY_KP_6:
+            math_equation_insert(display->priv->equation, "⁶");
+            return TRUE;
+        case GDK_KEY_7:
+        case GDK_KEY_KP_7:
+            math_equation_insert(display->priv->equation, "⁷");
+            return TRUE;
+        case GDK_KEY_8:
+        case GDK_KEY_KP_8:
+            math_equation_insert(display->priv->equation, "⁸");
+            return TRUE;
+        case GDK_KEY_9:
+        case GDK_KEY_KP_9:
+            math_equation_insert(display->priv->equation, "⁹");
+            return TRUE;
+        }
+    }
+    else if (state == GDK_MOD1_MASK || math_equation_get_number_mode(display->priv->equation) == SUBSCRIPT) {
+        switch(event->keyval)
+        {
+        case GDK_KEY_0:
+        case GDK_KEY_KP_0:
+            math_equation_insert(display->priv->equation, "₀");
+            return TRUE;
+        case GDK_KEY_1:
+        case GDK_KEY_KP_1:
+            math_equation_insert(display->priv->equation, "₁");
+            return TRUE;
+        case GDK_KEY_2:
+        case GDK_KEY_KP_2:
+            math_equation_insert(display->priv->equation, "₂");
+            return TRUE;
+        case GDK_KEY_3:
+        case GDK_KEY_KP_3:
+            math_equation_insert(display->priv->equation, "₃");
+            return TRUE;
+        case GDK_KEY_4:
+        case GDK_KEY_KP_4:
+            math_equation_insert(display->priv->equation, "₄");
+            return TRUE;
+        case GDK_KEY_5:
+        case GDK_KEY_KP_5:
+            math_equation_insert(display->priv->equation, "₅");
+            return TRUE;
+        case GDK_KEY_6:
+        case GDK_KEY_KP_6:
+            math_equation_insert(display->priv->equation, "₆");
+            return TRUE;
+        case GDK_KEY_7:
+        case GDK_KEY_KP_7:
+            math_equation_insert(display->priv->equation, "₇");
+            return TRUE;
+        case GDK_KEY_8:
+        case GDK_KEY_KP_8:
+            math_equation_insert(display->priv->equation, "₈");
+            return TRUE;
+        case GDK_KEY_9:
+        case GDK_KEY_KP_9:
+            math_equation_insert(display->priv->equation, "₉");
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+static gboolean
+key_press_cb(MathDisplay *display, GdkEventKey *event)
+{
+    gboolean result;
+    g_signal_emit_by_name(display->priv->text_view, "key-press-event", event, &result);
+    return result;
+}
+
+static void
+status_changed_cb(MathEquation *equation, GParamSpec *spec, MathDisplay *display)
+{
+    gtk_text_buffer_set_text(display->priv->info_buffer, math_equation_get_status(equation), -1);
+    if (math_equation_in_solve(equation) && !gtk_widget_get_visible(display->priv->spinner)) {
+        gtk_widget_show(display->priv->spinner);
+        gtk_spinner_start(GTK_SPINNER(display->priv->spinner));
+    }
+    else if (!math_equation_in_solve(equation) && gtk_widget_get_visible(display->priv->spinner)) {
+        gtk_widget_hide(display->priv->spinner);
+        gtk_spinner_stop(GTK_SPINNER(display->priv->spinner));
+    }
+}
+
+static void _text_view_override_font (GtkWidget *widget, PangoFontDescription *font)
+{
+    GtkCssProvider *provider;
+    gchar          *css;
+    gchar          *family;
+    gchar          *weight;
+    gchar          *size;
+    const gchar    *style;
+
+    family = g_strdup_printf ("font-family: %s;", pango_font_description_get_family (font));
+    weight = g_strdup_printf ("font-weight: %d;", pango_font_description_get_weight (font));
+    if (pango_font_description_get_style (font) == PANGO_STYLE_NORMAL)
+        style = "font-style: normal;";
+    else if (pango_font_description_get_style (font) == PANGO_STYLE_ITALIC)
+        style = "font-style: italic;";
+    else
+        style = "font-style: oblique;";
+
+    size = g_strdup_printf ("font-size: %d%s;",
+                             pango_font_description_get_size (font) / PANGO_SCALE,
+                             pango_font_description_get_size_is_absolute (font) ? "px" : "pt");
+    css = g_strdup_printf ("textview { %s %s %s %s }", family, weight, style, size);
+
+    provider = gtk_css_provider_new ();
+    gtk_css_provider_load_from_data (provider, css, -1, NULL);
+    g_free (css);
+    g_free (family);
+    g_free (weight);
+    g_free (size);
+
+    gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+                                    GTK_STYLE_PROVIDER (provider),
+                                    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    g_object_unref (provider);
+}
+
+static void
+create_gui(MathDisplay *display)
+{
+    GtkWidget *info_view, *info_box, *main_box;
+    PangoFontDescription *font_desc;
+    GtkStyleContext *context;
+    GtkStateFlags state;
+
+    main_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+    gtk_container_add(GTK_CONTAINER(display), main_box);
+
+    g_signal_connect(display, "key-press-event", G_CALLBACK(key_press_cb), display);
+
+    display->priv->text_view = gtk_text_view_new_with_buffer(GTK_TEXT_BUFFER(display->priv->equation));
+    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(display->priv->text_view), GTK_WRAP_WORD);
+    gtk_text_view_set_accepts_tab(GTK_TEXT_VIEW(display->priv->text_view), FALSE);
+    gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(display->priv->text_view), 8);
+    gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(display->priv->text_view), 2);
+    /* TEMP: Disabled for now as GTK+ doesn't properly render a right aligned right margin, see bug #482688 */
+    /*gtk_text_view_set_right_margin(GTK_TEXT_VIEW(display->priv->text_view), 6);*/
+    gtk_text_view_set_justification(GTK_TEXT_VIEW(display->priv->text_view), GTK_JUSTIFY_RIGHT);
+    context = gtk_widget_get_style_context (display->priv->text_view);
+    state = gtk_widget_get_state_flags (GTK_WIDGET (display->priv->text_view));
+    gtk_style_context_get (context, state, GTK_STYLE_PROPERTY_FONT, &font_desc, NULL);
+    pango_font_description_set_size(font_desc, 16 * PANGO_SCALE);
+    _text_view_override_font (display->priv->text_view, font_desc);
+    pango_font_description_free(font_desc);
+    gtk_widget_set_name(display->priv->text_view, "displayitem");
+    atk_object_set_role(gtk_widget_get_accessible(display->priv->text_view), ATK_ROLE_EDITBAR);
+  //FIXME:<property name="AtkObject::accessible-description" translatable="yes" comments="Accessible description for the area in which results are displayed">Result Region</property>
+    g_signal_connect(display->priv->text_view, "key-press-event", G_CALLBACK(display_key_press_cb), display);
+    gtk_box_pack_start(GTK_BOX(main_box), display->priv->text_view, TRUE, TRUE, 0);
+
+    info_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
+    gtk_box_pack_start(GTK_BOX(main_box), info_box, FALSE, TRUE, 0);
+
+    info_view = gtk_text_view_new();
+    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(info_view), GTK_WRAP_WORD);
+    gtk_widget_set_can_focus(info_view, TRUE); // FIXME: This should be FALSE but it locks the cursor inside the main view for some reason
+    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(info_view), FALSE); // FIXME: Just here so when incorrectly gets focus doesn't look editable
+    gtk_text_view_set_editable(GTK_TEXT_VIEW(info_view), FALSE);
+    gtk_text_view_set_justification(GTK_TEXT_VIEW(info_view), GTK_JUSTIFY_RIGHT);
+    gtk_text_view_set_bottom_margin(GTK_TEXT_VIEW(info_view), 12);
+    /* TEMP: Disabled for now as GTK+ doesn't properly render a right aligned right margin, see bug #482688 */
+    /*gtk_text_view_set_right_margin(GTK_TEXT_VIEW(info_view), 6);*/
+    gtk_box_pack_start(GTK_BOX(info_box), info_view, TRUE, TRUE, 0);
+    display->priv->info_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(info_view));
+
+    display->priv->spinner = gtk_spinner_new();
+    gtk_box_pack_end(GTK_BOX(info_box), display->priv->spinner, FALSE, FALSE, 0);
+
+    gtk_widget_show(info_box);
+    gtk_widget_show(info_view);
+    gtk_widget_show(display->priv->text_view);
+    gtk_widget_show(main_box);
+
+    g_signal_connect(display->priv->equation, "notify::status", G_CALLBACK(status_changed_cb), display);
+    status_changed_cb(display->priv->equation, NULL, display);
+}
+
+static void
+math_display_set_property(GObject      *object,
+                          guint         prop_id,
+                          const GValue *value,
+                          GParamSpec   *pspec)
+{
+    MathDisplay *self;
+
+    self = MATH_DISPLAY(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        self->priv->equation = g_value_get_object(value);
+        create_gui(self);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_display_get_property(GObject    *object,
+                          guint       prop_id,
+                          GValue     *value,
+                          GParamSpec *pspec)
+{
+    MathDisplay *self;
+
+    self = MATH_DISPLAY(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        g_value_set_object(value, self->priv->equation);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_display_class_init(MathDisplayClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    object_class->get_property = math_display_get_property;
+    object_class->set_property = math_display_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_EQUATION,
+                                    g_param_spec_object("equation",
+                                                        "equation",
+                                                        "Equation being displayed",
+                                                        math_equation_get_type(),
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+math_display_init(MathDisplay *display)
+{
+    display->priv = math_display_get_instance_private (display);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/27.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/27.html new file mode 100644 index 0000000..9fff80f --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/27.html @@ -0,0 +1,4173 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <ctype.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-equation.h"
+
+#include "mp.h"
+#include "mp-equation.h"
+#include "mp-serializer.h"
+#include "mp-enums.h"
+#include "unit-manager.h"
+#include "utility.h"
+
+enum {
+    PROP_0,
+    PROP_STATUS,
+    PROP_DISPLAY,
+    PROP_EQUATION,
+    PROP_NUMBER_MODE,
+    PROP_ACCURACY,
+    PROP_SHOW_THOUSANDS_SEPARATORS,
+    PROP_SHOW_TRAILING_ZEROES,
+    PROP_NUMBER_FORMAT,
+    PROP_BASE,
+    PROP_WORD_SIZE,
+    PROP_ANGLE_UNITS,
+    PROP_SOURCE_CURRENCY,
+    PROP_TARGET_CURRENCY,
+    PROP_SOURCE_UNITS,
+    PROP_TARGET_UNITS,
+    PROP_SERIALIZER
+};
+
+static GType number_mode_type, number_format_type, angle_unit_type;
+
+/* Expression mode state */
+typedef struct {
+    MPNumber ans;              /* Previously calculated answer */
+    gchar *expression;         /* Expression entered by user */
+    gint ans_start, ans_end;   /* Start and end characters for ans variable in expression */
+    gint cursor;               /* ??? */
+    NumberMode number_mode;    /* ??? */
+    gboolean can_super_minus;  /* TRUE if entering minus can generate a superscript minus */
+    gboolean entered_multiply; /* Last insert was a multiply character */
+    gchar *status;             /* Equation status */
+} MathEquationState;
+
+struct MathEquationPrivate
+{
+    GtkTextTag *ans_tag;
+
+    gint word_size;           /* Word size in bits */
+    MPAngleUnit angle_units;  /* Units for trigonometric functions */
+    char *source_currency;
+    char *target_currency;
+    char *source_units;
+    char *target_units;
+    NumberMode number_mode;   /* ??? */
+    gboolean can_super_minus; /* TRUE if entering minus can generate a superscript minus */
+
+    gunichar digits[16];      /* Localized digits */
+
+    GtkTextMark *ans_start, *ans_end;
+
+    MathEquationState state;  /* Equation state */
+    GList *undo_stack;        /* History of expression mode states */
+    GList *redo_stack;
+    gboolean in_undo_operation;
+
+    gboolean in_reformat;
+
+    gboolean in_delete;
+
+    gboolean in_solve;
+
+    MathVariables *variables;
+    MpSerializer *serializer;
+
+    GAsyncQueue *queue;
+};
+
+typedef struct {
+    MPNumber *number_result;
+    gchar *text_result;
+    gchar *error;
+} SolveData;
+
+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)
+{
+    GtkTextIter iter;
+
+    if (!equation->priv->ans_start) {
+        *start = *end = -1;
+        return;
+    }
+
+    gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &iter, equation->priv->ans_start);
+    *start = gtk_text_iter_get_offset(&iter);
+    gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &iter, equation->priv->ans_end);
+    *end = gtk_text_iter_get_offset(&iter);
+}
+
+static void
+reformat_ans(MathEquation *equation)
+{
+    if (!equation->priv->ans_start)
+        return;
+
+    gchar *orig_ans_text;
+    gchar *ans_text;
+    GtkTextIter ans_start, ans_end;
+
+    gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &ans_start, equation->priv->ans_start);
+    gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &ans_end, equation->priv->ans_end);
+    orig_ans_text = gtk_text_buffer_get_text(GTK_TEXT_BUFFER(equation), &ans_start, &ans_end, FALSE);
+    ans_text = mp_serializer_to_string(equation->priv->serializer, &equation->priv->state.ans);
+    if (strcmp(orig_ans_text, ans_text) != 0) {
+        gint start;
+
+        equation->priv->in_undo_operation = TRUE;
+        equation->priv->in_reformat = TRUE;
+
+        start = gtk_text_iter_get_offset(&ans_start);
+        gtk_text_buffer_delete(GTK_TEXT_BUFFER(equation), &ans_start, &ans_end);
+        gtk_text_buffer_insert_with_tags(GTK_TEXT_BUFFER(equation), &ans_end, ans_text, -1, equation->priv->ans_tag, NULL);
+
+        /* There seems to be a bug in the marks as they alternate being the correct and incorrect ways.  Reset them */
+        gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &ans_start, start);
+        gtk_text_buffer_move_mark(GTK_TEXT_BUFFER(equation), equation->priv->ans_start, &ans_start);
+        gtk_text_buffer_move_mark(GTK_TEXT_BUFFER(equation), equation->priv->ans_end, &ans_end);
+
+        equation->priv->in_reformat = FALSE;
+        equation->priv->in_undo_operation = FALSE;
+    }
+    gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &ans_start, equation->priv->ans_start);
+    gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &ans_end, equation->priv->ans_end);
+    g_free(orig_ans_text);
+    g_free(ans_text);
+}
+
+static gint
+count_digits(MathEquation *equation, const gchar *text)
+{
+    const gchar *read_iter;
+    gint count = 0;
+
+    read_iter = text;
+    while (*read_iter != '\0') {
+        if (!g_unichar_isdigit(g_utf8_get_char(read_iter)))
+            return count;
+
+        read_iter = g_utf8_next_char(read_iter);
+
+        /* Allow a thousands separator between digits follow a digit */
+        if (g_utf8_get_char(read_iter) == mp_serializer_get_thousands_separator(equation->priv->serializer)) {
+            read_iter = g_utf8_next_char(read_iter);
+            if (!g_unichar_isdigit(g_utf8_get_char(read_iter)))
+                return count;
+        }
+
+        count++;
+    }
+
+    return count;
+}
+
+static void
+reformat_separators(MathEquation *equation)
+{
+    gchar *text, *read_iter;
+    gint ans_start, ans_end;
+    gint offset, digit_offset = 0;
+    gboolean in_number = FALSE, in_radix = FALSE, last_is_tsep = FALSE;
+
+    equation->priv->in_undo_operation = TRUE;
+    equation->priv->in_reformat = TRUE;
+
+    text = math_equation_get_display(equation);
+    get_ans_offsets(equation, &ans_start, &ans_end);
+    for (read_iter = text, offset = 0; *read_iter != '\0'; read_iter = g_utf8_next_char(read_iter), offset++) {
+        gunichar c;
+        gboolean expect_tsep;
+
+        /* See what digit this character is */
+        c = g_utf8_get_char(read_iter);
+
+        expect_tsep = math_equation_get_base(equation) == 10 &&
+                      mp_serializer_get_show_thousands_separators(equation->priv->serializer) &&
+                      in_number && !in_radix && !last_is_tsep &&
+                      digit_offset > 0 && digit_offset % mp_serializer_get_thousands_separator_count(equation->priv->serializer) == 0;
+        last_is_tsep = FALSE;
+
+        /* Don't mess with ans */
+        if (offset >= ans_start && offset <= ans_end) {
+            in_number = in_radix = FALSE;
+            continue;
+        }
+        if (g_unichar_isdigit(c)) {
+            if (!in_number)
+                digit_offset = count_digits(equation, read_iter);
+            in_number = TRUE;
+
+            /* Expected a thousands separator between these digits - insert it */
+            if (expect_tsep) {
+                GtkTextIter iter;
+                gchar buffer[7];
+                gint len;
+
+                gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &iter, offset);
+                len = g_unichar_to_utf8(mp_serializer_get_thousands_separator(equation->priv->serializer), buffer);
+                buffer[len] = '\0';
+                gtk_text_buffer_insert(GTK_TEXT_BUFFER(equation), &iter, buffer, -1);
+                offset++;
+                last_is_tsep = TRUE;
+            }
+
+            digit_offset--;
+        }
+        else if (c == mp_serializer_get_radix(equation->priv->serializer)) {
+            in_number = in_radix = TRUE;
+        }
+        else if (c == mp_serializer_get_thousands_separator(equation->priv->serializer)) {
+            /* Didn't expect thousands separator - delete it */
+            if (!expect_tsep && in_number) {
+                GtkTextIter start, end;
+                gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &start, offset);
+                gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &end, offset + 1);
+                gtk_text_buffer_delete(GTK_TEXT_BUFFER(equation), &start, &end);
+                offset--;
+            }
+            else
+                last_is_tsep = TRUE;
+        }
+        else {
+            in_number = in_radix = FALSE;
+        }
+    }
+
+    g_free(text);
+
+    equation->priv->in_reformat = FALSE;
+    equation->priv->in_undo_operation = FALSE;
+}
+
+static void
+reformat_display(MathEquation *equation)
+{
+    /* Change ans */
+    reformat_ans(equation);
+
+    /* Add/remove thousands separators */
+    reformat_separators(equation);
+
+    g_signal_emit_by_name(equation, "display-changed");
+}
+
+static MathEquationState *
+get_current_state(MathEquation *equation)
+{
+    MathEquationState *state;
+    gint ans_start = -1, ans_end = -1;
+
+    state = g_malloc0(sizeof(MathEquationState));
+    state->ans = mp_new();
+
+    if (equation->priv->ans_start)
+    {
+        GtkTextIter iter;
+        gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &iter, equation->priv->ans_start);
+        ans_start = gtk_text_iter_get_offset(&iter);
+        gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &iter, equation->priv->ans_end);
+        ans_end = gtk_text_iter_get_offset(&iter);
+    }
+
+    mp_set_from_mp(&equation->priv->state.ans, &state->ans);
+    state->expression = math_equation_get_display(equation);
+    state->ans_start = ans_start;
+    state->ans_end = ans_end;
+    g_object_get(G_OBJECT(equation), "cursor-position", &state->cursor, NULL);
+    state->number_mode = equation->priv->number_mode;
+    state->can_super_minus = equation->priv->can_super_minus;
+    state->entered_multiply = equation->priv->state.entered_multiply;
+    state->status = g_strdup(equation->priv->state.status);
+
+    return state;
+}
+
+static void
+free_state(MathEquationState *state)
+{
+    g_free(state->expression);
+    g_free(state->status);
+    g_free(state);
+}
+
+static void
+math_equation_push_undo_stack(MathEquation *equation)
+{
+    GList *link;
+    MathEquationState *state;
+
+    if (equation->priv->in_undo_operation)
+        return;
+
+    math_equation_set_status(equation, "");
+
+    /* Can't redo anymore */
+    for (link = equation->priv->redo_stack; link; link = link->next) {
+        state = link->data;
+        free_state(state);
+    }
+    g_list_free(equation->priv->redo_stack);
+    equation->priv->redo_stack = NULL;
+
+    state = get_current_state(equation);
+    equation->priv->undo_stack = g_list_prepend(equation->priv->undo_stack, state);
+}
+
+static void
+clear_ans(MathEquation *equation, gboolean remove_tag)
+{
+    if (!equation->priv->ans_start)
+        return;
+
+    if (remove_tag) {
+        GtkTextIter start, end;
+
+        gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &start, equation->priv->ans_start);
+        gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &end, equation->priv->ans_end);
+        gtk_text_buffer_remove_tag(GTK_TEXT_BUFFER(equation), equation->priv->ans_tag, &start, &end);
+    }
+
+    gtk_text_buffer_delete_mark(GTK_TEXT_BUFFER(equation), equation->priv->ans_start);
+    gtk_text_buffer_delete_mark(GTK_TEXT_BUFFER(equation), equation->priv->ans_end);
+    equation->priv->ans_start = NULL;
+    equation->priv->ans_end = NULL;
+}
+
+static void
+apply_state(MathEquation *equation, MathEquationState *state)
+{
+    GtkTextIter cursor;
+
+    /* Disable undo detection */
+    equation->priv->in_undo_operation = TRUE;
+
+    mp_set_from_mp(&state->ans, &equation->priv->state.ans);
+
+    gtk_text_buffer_set_text(GTK_TEXT_BUFFER(equation), state->expression, -1);
+    gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &cursor, state->cursor);
+    gtk_text_buffer_place_cursor(GTK_TEXT_BUFFER(equation), &cursor);
+    clear_ans(equation, FALSE);
+    if (state->ans_start >= 0) {
+        GtkTextIter start, end;
+
+        gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &start, state->ans_start);
+        equation->priv->ans_start = gtk_text_buffer_create_mark(GTK_TEXT_BUFFER(equation), NULL, &start, FALSE);
+        gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &end, state->ans_end);
+        equation->priv->ans_end = gtk_text_buffer_create_mark(GTK_TEXT_BUFFER(equation), NULL, &end, TRUE);
+        gtk_text_buffer_apply_tag(GTK_TEXT_BUFFER(equation), equation->priv->ans_tag, &start, &end);
+    }
+
+    math_equation_set_number_mode(equation, state->number_mode);
+    equation->priv->can_super_minus = state->can_super_minus;
+    equation->priv->state.entered_multiply = state->entered_multiply;
+    math_equation_set_status(equation, state->status);
+
+    equation->priv->in_undo_operation = FALSE;
+}
+
+void
+math_equation_copy(MathEquation *equation)
+{
+    GtkTextIter start, end;
+    gchar *text;
+
+    g_return_if_fail(equation != NULL);
+
+    if (!gtk_text_buffer_get_selection_bounds(GTK_TEXT_BUFFER(equation), &start, &end))
+        gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(equation), &start, &end);
+
+    text = gtk_text_buffer_get_text(GTK_TEXT_BUFFER(equation), &start, &end, FALSE);
+    gtk_clipboard_set_text(gtk_clipboard_get(GDK_NONE), g_str_to_ascii (text, "C"), -1);
+    g_free(text);
+}
+
+static void
+on_paste(GtkClipboard *clipboard, const gchar *text, gpointer data)
+{
+    MathEquation *equation = data;
+    if (text != NULL)
+        math_equation_insert(equation, text);
+}
+
+void
+math_equation_paste(MathEquation *equation)
+{
+    g_return_if_fail(equation != NULL);
+    gtk_clipboard_request_text(gtk_clipboard_get(GDK_NONE), on_paste, equation);
+}
+
+void
+math_equation_undo(MathEquation *equation)
+{
+    GList *link;
+    MathEquationState *state;
+
+    g_return_if_fail(equation != NULL);
+
+    if (!equation->priv->undo_stack) {
+        math_equation_set_status(equation,
+                                 /* Error shown when trying to undo with no undo history */
+                                 _("No undo history"));
+        return;
+    }
+
+    link = equation->priv->undo_stack;
+    equation->priv->undo_stack = g_list_remove_link(equation->priv->undo_stack, link);
+    state = link->data;
+    g_list_free(link);
+
+    equation->priv->redo_stack = g_list_prepend(equation->priv->redo_stack, get_current_state(equation));
+
+    apply_state(equation, state);
+    free_state(state);
+}
+
+void
+math_equation_redo(MathEquation *equation)
+{
+    GList *link;
+    MathEquationState *state;
+
+    g_return_if_fail(equation != NULL);
+
+    if (!equation->priv->redo_stack) {
+        math_equation_set_status(equation,
+                                 /* Error shown when trying to redo with no redo history */
+                                 _("No redo history"));
+        return;
+    }
+
+    link = equation->priv->redo_stack;
+    equation->priv->redo_stack = g_list_remove_link(equation->priv->redo_stack, link);
+    state = link->data;
+    g_list_free(link);
+
+    equation->priv->undo_stack = g_list_prepend(equation->priv->undo_stack, get_current_state(equation));
+
+    apply_state(equation, state);
+    free_state(state);
+}
+
+gunichar
+math_equation_get_digit_text(MathEquation *equation, guint digit)
+{
+    g_return_val_if_fail(equation != NULL, '?');
+    g_return_val_if_fail(digit < 16, '?');
+
+    return equation->priv->digits[digit];
+}
+
+void
+math_equation_set_accuracy(MathEquation *equation, gint accuracy)
+{
+    g_return_if_fail(equation != NULL);
+
+    if (mp_serializer_get_trailing_digits(equation->priv->serializer) == accuracy)
+        return;
+    mp_serializer_set_trailing_digits(equation->priv->serializer, accuracy);
+    reformat_display(equation);
+    g_object_notify(G_OBJECT(equation), "accuracy");
+}
+
+gint
+math_equation_get_accuracy(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, 0);
+
+    return mp_serializer_get_trailing_digits(equation->priv->serializer);
+}
+
+void
+math_equation_set_show_thousands_separators(MathEquation *equation, gboolean visible)
+{
+    g_return_if_fail(equation != NULL);
+
+    if (mp_serializer_get_show_thousands_separators(equation->priv->serializer) == visible)
+        return;
+
+    mp_serializer_set_show_thousands_separators(equation->priv->serializer, visible);
+    reformat_display(equation);
+    g_object_notify(G_OBJECT(equation), "show-thousands-separators");
+}
+
+gboolean
+math_equation_get_show_thousands_separators(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, FALSE);
+    return mp_serializer_get_show_thousands_separators(equation->priv->serializer);
+}
+
+void
+math_equation_set_show_trailing_zeroes(MathEquation *equation, gboolean visible)
+{
+    g_return_if_fail(equation != NULL);
+
+    if (mp_serializer_get_show_trailing_zeroes(equation->priv->serializer) == visible)
+        return;
+
+    mp_serializer_set_show_trailing_zeroes(equation->priv->serializer, visible);
+    reformat_display(equation);
+    g_object_notify(G_OBJECT(equation), "show-trailing-zeroes");
+}
+
+gboolean
+math_equation_get_show_trailing_zeroes(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, FALSE);
+    return mp_serializer_get_show_trailing_zeroes(equation->priv->serializer);
+}
+
+void
+math_equation_set_number_format(MathEquation *equation, MpDisplayFormat format)
+{
+    g_return_if_fail(equation != NULL);
+
+    if (mp_serializer_get_number_format(equation->priv->serializer) == format)
+        return;
+
+    mp_serializer_set_number_format(equation->priv->serializer, format);
+    reformat_display(equation);
+    g_object_notify(G_OBJECT(equation), "number-format");
+}
+
+MpDisplayFormat
+math_equation_get_number_format(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, MP_DISPLAY_FORMAT_AUTOMATIC);
+    return mp_serializer_get_number_format(equation->priv->serializer);
+}
+
+void
+math_equation_set_base(MathEquation *equation, gint base)
+{
+    g_return_if_fail(equation != NULL);
+
+    if (mp_serializer_get_base(equation->priv->serializer) == base)
+        return;
+
+    mp_serializer_set_base(equation->priv->serializer, base);
+    reformat_display(equation);
+    g_object_notify(G_OBJECT(equation), "base");
+}
+
+gint
+math_equation_get_base(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, 10);
+    return mp_serializer_get_base(equation->priv->serializer);
+}
+
+void
+math_equation_set_word_size(MathEquation *equation, gint word_size)
+{
+    g_return_if_fail(equation != NULL);
+
+    if (equation->priv->word_size == word_size)
+        return;
+
+    equation->priv->word_size = word_size;
+    g_object_notify(G_OBJECT(equation), "word-size");
+}
+
+gint
+math_equation_get_word_size(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, 64);
+    return equation->priv->word_size;
+}
+
+void
+math_equation_set_angle_units(MathEquation *equation, MPAngleUnit angle_units)
+{
+    g_return_if_fail(equation != NULL);
+
+    if (equation->priv->angle_units == angle_units)
+        return;
+
+    equation->priv->angle_units = angle_units;
+    g_object_notify(G_OBJECT(equation), "angle-units");
+}
+
+MPAngleUnit
+math_equation_get_angle_units(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, MP_DEGREES);
+    return equation->priv->angle_units;
+}
+
+void
+math_equation_set_source_currency(MathEquation *equation, const gchar *currency)
+{
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(currency != NULL);
+
+    if (strcmp(equation->priv->source_currency, currency) == 0)
+        return;
+    g_free(equation->priv->source_currency);
+    equation->priv->source_currency = g_strdup(currency);
+    g_settings_set_string(g_settings_var, "source-currency",
+            math_equation_get_source_currency(equation));
+}
+
+const gchar *
+math_equation_get_source_currency(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, NULL);
+    return equation->priv->source_currency;
+}
+
+void
+math_equation_set_target_currency(MathEquation *equation, const gchar *currency)
+{
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(currency != NULL);
+
+    if (strcmp(equation->priv->target_currency, currency) == 0)
+        return;
+    g_free(equation->priv->target_currency);
+    equation->priv->target_currency = g_strdup(currency);
+    g_settings_set_string(g_settings_var, "target-currency",
+            math_equation_get_target_currency(equation));
+}
+
+const gchar *
+math_equation_get_target_currency(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, NULL);
+    return equation->priv->target_currency;
+}
+
+void
+math_equation_set_source_units(MathEquation *equation, const gchar *units)
+{
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(units != NULL);
+
+    if (strcmp(equation->priv->source_units, units) == 0)
+        return;
+
+    g_free(equation->priv->source_units);
+    equation->priv->source_units = g_strdup(units);
+    g_settings_set_string(g_settings_var, "source-units",
+            math_equation_get_source_units(equation));
+}
+
+const gchar *
+math_equation_get_source_units(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, NULL);
+    return equation->priv->source_units;
+}
+
+void
+math_equation_set_target_units(MathEquation *equation, const gchar *units)
+{
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(units != NULL);
+
+    if (strcmp(equation->priv->target_units, units) == 0)
+        return;
+
+    g_free(equation->priv->target_units);
+    equation->priv->target_units = g_strdup(units);
+    g_settings_set_string(g_settings_var, "target-units",
+            math_equation_get_target_units(equation));
+}
+
+const gchar *
+math_equation_get_target_units(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, NULL);
+    return equation->priv->target_units;
+}
+
+void
+math_equation_set_status(MathEquation *equation, const gchar *status)
+{
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(status != NULL);
+
+    if (strcmp(equation->priv->state.status, status) == 0)
+        return;
+
+    g_free(equation->priv->state.status);
+    equation->priv->state.status = g_strdup(status);
+    g_object_notify(G_OBJECT(equation), "status");
+}
+
+const gchar *
+math_equation_get_status(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, NULL);
+    return equation->priv->state.status;
+}
+
+gboolean
+math_equation_is_empty(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, FALSE);
+    return gtk_text_buffer_get_char_count(GTK_TEXT_BUFFER(equation)) == 0;
+}
+
+gboolean
+math_equation_is_result(MathEquation *equation)
+{
+    char *text;
+    gboolean result;
+
+    g_return_val_if_fail(equation != NULL, FALSE);
+
+    text = math_equation_get_equation(equation);
+    result = strcmp(text, "ans") == 0;
+    g_free(text);
+
+    return result;
+}
+
+gchar *
+math_equation_get_display(MathEquation *equation)
+{
+    GtkTextIter start, end;
+
+    g_return_val_if_fail(equation != NULL, NULL);
+
+    gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(equation), &start, &end);
+    return gtk_text_buffer_get_text(GTK_TEXT_BUFFER(equation), &start, &end, FALSE);
+}
+
+gchar *
+math_equation_get_equation(MathEquation *equation)
+{
+    gchar *text;
+    GString *eq_text;
+    gint ans_start = -1, ans_end = -1, offset;
+    const gchar *read_iter;
+    gboolean last_is_digit = FALSE;
+
+    g_return_val_if_fail(equation != NULL, NULL);
+
+    text = math_equation_get_display(equation);
+    eq_text = g_string_sized_new(strlen(text));
+
+    if (equation->priv->ans_start)
+        get_ans_offsets(equation, &ans_start, &ans_end);
+
+    for (read_iter = text, offset = 0; *read_iter != '\0'; read_iter = g_utf8_next_char(read_iter), offset++) {
+        gunichar c;
+        gboolean is_digit, next_is_digit;
+
+        c = g_utf8_get_char(read_iter);
+        is_digit = g_unichar_isdigit(c);
+        next_is_digit = g_unichar_isdigit(g_utf8_get_char(g_utf8_next_char(read_iter)));
+
+        /* Replace ans text with variable */
+        if (offset == ans_start) {
+             g_string_append(eq_text, "ans");
+             read_iter = g_utf8_offset_to_pointer(read_iter, ans_end - ans_start - 1);
+             offset += ans_end - ans_start - 1;
+             is_digit = FALSE;
+             continue;
+        }
+
+        /* Ignore thousands separators */
+        if (c == mp_serializer_get_thousands_separator(equation->priv->serializer) && last_is_digit && next_is_digit)
+            ;
+        /* Substitute radix character */
+        else if (c == mp_serializer_get_radix(equation->priv->serializer) && (last_is_digit || next_is_digit))
+            g_string_append_unichar(eq_text, '.');
+        else
+            g_string_append_unichar(eq_text, c);
+
+        last_is_digit = is_digit;
+    }
+    g_free(text);
+
+    text = eq_text->str;
+    g_string_free(eq_text, FALSE);
+
+    return text;
+}
+
+gboolean
+math_equation_get_number(MathEquation *equation, MPNumber *z)
+{
+    gchar *text;
+    gboolean result;
+
+    g_return_val_if_fail(equation != NULL, FALSE);
+    g_return_val_if_fail(z != NULL, FALSE);
+
+    if (math_equation_is_result(equation)) {
+        mp_set_from_mp(math_equation_get_answer(equation), z);
+        return TRUE;
+    }
+    else {
+        text = math_equation_get_equation(equation);
+        result = !mp_serializer_from_string(equation->priv->serializer, text, z);
+        g_free(text);
+        return result;
+    }
+}
+
+MpSerializer *
+math_equation_get_serializer(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, NULL);
+    return equation->priv->serializer;
+}
+
+void
+math_equation_set_number_mode(MathEquation *equation, NumberMode mode)
+{
+    g_return_if_fail(equation != NULL);
+
+    if (equation->priv->number_mode == mode)
+        return;
+
+    equation->priv->can_super_minus = mode == SUPERSCRIPT;
+
+    equation->priv->number_mode = mode;
+    g_object_notify(G_OBJECT(equation), "number-mode");
+}
+
+NumberMode
+math_equation_get_number_mode(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, NORMAL);
+    return equation->priv->number_mode;
+}
+
+gboolean
+math_equation_in_solve(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, FALSE);
+    return equation->priv->in_solve;
+}
+
+const MPNumber *
+math_equation_get_answer(MathEquation *equation)
+{
+    g_return_val_if_fail(equation != NULL, FALSE);
+    return &equation->priv->state.ans;
+}
+
+void
+math_equation_store(MathEquation *equation, const gchar *name)
+{
+    MPNumber t = mp_new();
+
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(name != NULL);
+
+    if (!math_equation_get_number(equation, &t))
+        math_equation_set_status(equation, _("No sane value to store"));
+    else
+        math_variables_set(equation->priv->variables, name, &t);
+    mp_clear(&t);
+}
+
+void
+math_equation_recall(MathEquation *equation, const gchar *name)
+{
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(name != NULL);
+    math_equation_insert(equation, name);
+}
+
+void
+math_equation_set(MathEquation *equation, const gchar *text)
+{
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(text != NULL);
+    gtk_text_buffer_set_text(GTK_TEXT_BUFFER(equation), text, -1);
+    clear_ans(equation, FALSE);
+}
+
+static void
+math_equation_set_with_history(MathEquation *equation, const gchar *text)
+{
+    MathEquationState *state;
+    MPNumber x = mp_new();
+
+    math_equation_get_number(equation, &x);
+    math_equation_set(equation, text);
+
+    /* Notify history */
+    state = get_current_state(equation);
+    g_signal_emit_by_name(equation, "history", state->expression, &x);
+
+    free_state(state);
+    mp_clear(&x);
+}
+
+void
+math_equation_set_number(MathEquation *equation, const MPNumber *x)
+{
+    char *text;
+    GtkTextIter start, end;
+    MathEquationState *state;
+
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(x != NULL);
+
+    /* Notify history */
+    state = get_current_state(equation);
+    g_signal_emit_by_name(equation, "history", state->expression, x);
+
+    /* Show the number in the user chosen format */
+    text = mp_serializer_to_string(equation->priv->serializer, x);
+    gtk_text_buffer_set_text(GTK_TEXT_BUFFER(equation), text, -1);
+    mp_set_from_mp(x, &equation->priv->state.ans);
+
+    /* Mark this text as the answer variable */
+    gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(equation), &start, &end);
+    clear_ans(equation, FALSE);
+    equation->priv->ans_start = gtk_text_buffer_create_mark(GTK_TEXT_BUFFER(equation), NULL, &start, FALSE);
+    equation->priv->ans_end = gtk_text_buffer_create_mark(GTK_TEXT_BUFFER(equation), NULL, &end, TRUE);
+    gtk_text_buffer_apply_tag(GTK_TEXT_BUFFER(equation), equation->priv->ans_tag, &start, &end);
+
+    g_object_notify(G_OBJECT(equation), "display");
+
+    g_free(text);
+    free_state(state);
+}
+
+void
+math_equation_insert(MathEquation *equation, const gchar *text)
+{
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(text != NULL);
+
+    /* Replace ** with ^ (not on all keyboards) */
+    if (!gtk_text_buffer_get_has_selection(GTK_TEXT_BUFFER(equation)) &&
+        strcmp(text, "×") == 0 && equation->priv->state.entered_multiply) {
+        GtkTextIter iter;
+
+        gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &iter, gtk_text_buffer_get_insert(GTK_TEXT_BUFFER(equation)));
+        gtk_text_buffer_backspace(GTK_TEXT_BUFFER(equation), &iter, TRUE, TRUE);
+        gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(equation), "^", -1);
+        return;
+    }
+
+    /* Can't enter superscript minus after entering digits */
+    if (strstr("⁰¹²³⁴⁵⁶⁷⁸⁹", text) != NULL || strcmp("⁻", text) == 0)
+        equation->priv->can_super_minus = FALSE;
+
+    /* Disable super/subscript mode when finished entering */
+    if (strstr("⁻⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉", text) == NULL)
+        math_equation_set_number_mode(equation, NORMAL);
+
+    gtk_text_buffer_delete_selection(GTK_TEXT_BUFFER(equation), FALSE, FALSE);
+    gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(equation), text, -1);
+}
+
+void
+math_equation_insert_digit(MathEquation *equation, guint digit)
+{
+    static const char *subscript_digits[] = {"₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉", NULL};
+    static const char *superscript_digits[] = {"⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹", NULL};
+
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(digit < 16);
+
+    if (equation->priv->number_mode == NORMAL || digit >= 10) {
+        gchar buffer[7];
+        gint len;
+        len = g_unichar_to_utf8(math_equation_get_digit_text(equation, digit), buffer);
+        buffer[len] = '\0';
+        math_equation_insert(equation, buffer);
+    }
+    else if (equation->priv->number_mode == SUPERSCRIPT)
+        math_equation_insert(equation, superscript_digits[digit]);
+    else if (equation->priv->number_mode == SUBSCRIPT)
+        math_equation_insert(equation, subscript_digits[digit]);
+}
+
+void
+math_equation_insert_numeric_point(MathEquation *equation)
+{
+    gchar buffer[7];
+    gint len;
+
+    g_return_if_fail(equation != NULL);
+
+    len = g_unichar_to_utf8(mp_serializer_get_radix(equation->priv->serializer), buffer);
+    buffer[len] = '\0';
+    math_equation_insert(equation, buffer);
+}
+
+void
+math_equation_insert_number(MathEquation *equation, const MPNumber *x)
+{
+    char *text;
+
+    g_return_if_fail(equation != NULL);
+    g_return_if_fail(x != NULL);
+
+    text = mp_serializer_to_string(equation->priv->serializer, x);
+    math_equation_insert(equation, text);
+    g_free(text);
+}
+
+void
+math_equation_insert_exponent(MathEquation *equation)
+{
+    g_return_if_fail(equation != NULL);
+    math_equation_insert(equation, "×10");
+    math_equation_set_number_mode(equation, SUPERSCRIPT);
+}
+
+void
+math_equation_insert_subtract(MathEquation *equation)
+{
+    g_return_if_fail(equation != NULL);
+    if (equation->priv->number_mode == SUPERSCRIPT && equation->priv->can_super_minus) {
+        math_equation_insert(equation, "⁻");
+        equation->priv->can_super_minus = FALSE;
+    }
+    else {
+        math_equation_insert(equation, "−");
+        math_equation_set_number_mode(equation, NORMAL);
+    }
+}
+
+static int
+variable_is_defined(const char *name, void *data)
+{
+    MathEquation *equation = data;
+    char *c, *lower_name;
+
+    lower_name = strdup(name);
+    for (c = lower_name; *c; c++)
+        *c = tolower(*c);
+
+    if (strcmp(lower_name, "rand") == 0 ||
+        strcmp(lower_name, "ans") == 0) {
+        g_free(lower_name);
+        return 1;
+    }
+    g_free(lower_name);
+
+    return math_variables_get(equation->priv->variables, name) != NULL;
+}
+
+static int
+get_variable(const char *name, MPNumber *z, void *data)
+{
+    char *c, *lower_name;
+    int result = 1;
+    MathEquation *equation = data;
+    MPNumber *t;
+
+    lower_name = strdup(name);
+    for (c = lower_name; *c; c++)
+        *c = tolower(*c);
+
+    if (strcmp(lower_name, "rand") == 0)
+        mp_set_from_random(z);
+    else if (strcmp(lower_name, "ans") == 0)
+        mp_set_from_mp(&equation->priv->state.ans, z);
+    else {
+        t = math_variables_get(equation->priv->variables, name);
+        if (t)
+            mp_set_from_mp(t, z);
+        else
+            result = 0;
+    }
+    free(lower_name);
+
+    return result;
+}
+
+static void
+set_variable(const char *name, const MPNumber *x, void *data)
+{
+    MathEquation *equation = data;
+    /* FIXME: Don't allow writing to built-in variables, e.g. ans, rand, sin, ... */
+    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)
+{
+    MPEquationOptions options;
+
+    memset(&options, 0, sizeof(options));
+    options.base = mp_serializer_get_base(equation->priv->serializer);
+    options.wordlen = equation->priv->word_size;
+    options.angle_units = equation->priv->angle_units;
+    options.variable_is_defined = variable_is_defined;
+    options.get_variable = get_variable;
+    options.set_variable = set_variable;
+    options.convert = convert;
+    options.callback_data = equation;
+
+    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.
+ */
+static gpointer
+math_equation_solve_real(gpointer data)
+{
+    MathEquation *equation = MATH_EQUATION(data);
+    SolveData *solvedata = g_slice_new0(SolveData);
+
+    gint n_brackets = 0, result;
+    gchar *c, *text, *error_token;
+    GString *equation_text;
+    MPNumber z = mp_new();
+
+    text = math_equation_get_equation(equation);
+    equation_text = g_string_new(text);
+    g_free(text);
+    /* Count the number of brackets and automatically add missing closing brackets */
+    for (c = equation_text->str; *c; c++) {
+        if (*c == '(')
+            n_brackets++;
+        else if (*c == ')')
+            n_brackets--;
+    }
+    while (n_brackets > 0) {
+        g_string_append_c(equation_text, ')');
+        n_brackets--;
+    }
+
+    result = parse(equation, equation_text->str, &z, &error_token);
+    g_string_free(equation_text, TRUE);
+
+    switch (result) {
+        case PARSER_ERR_NONE:
+            solvedata->number_result = g_slice_new(MPNumber);
+            *solvedata->number_result = mp_new();
+            mp_set_from_mp(&z, solvedata->number_result);
+            break;
+
+        case PARSER_ERR_OVERFLOW:
+            solvedata->error = g_strdup(/* Error displayed to user when they perform a bitwise operation on numbers greater than the current word */
+                               _("Overflow. Try a bigger word size"));
+            break;
+
+        case PARSER_ERR_UNKNOWN_VARIABLE:
+            solvedata->error = g_strdup_printf(/* Error displayed to user when they an unknown variable is entered */
+                                      _("Unknown variable '%s'"), error_token);
+            break;
+
+        case PARSER_ERR_UNKNOWN_FUNCTION:
+            solvedata->error = g_strdup_printf(/* Error displayed to user when an unknown function is entered */
+                                      _("Function '%s' is not defined"), error_token);
+            break;
+
+        case PARSER_ERR_UNKNOWN_CONVERSION:
+            solvedata->error = g_strdup(/* Error displayed to user when an conversion with unknown units is attempted */
+                               _("Unknown conversion"));
+            break;
+
+        case PARSER_ERR_MP:
+            if (mp_get_error())
+                solvedata->error = g_strdup(mp_get_error());
+            else if (error_token)
+                solvedata->error = g_strdup_printf(/* Uncategorized error. Show error token to user*/
+                                    _("Malformed expression at token '%s'"), error_token);
+            else
+                solvedata->error = g_strdup (/* Unknown error. */
+                                    _("Malformed expression"));
+            break;
+
+        default:
+            solvedata->error = g_strdup(/* Error displayed to user when they enter an invalid calculation */
+                               _("Malformed expression"));
+            break;
+    }
+    g_async_queue_push(equation->priv->queue, solvedata);
+    mp_clear(&z);
+
+    return NULL;
+}
+
+static gboolean
+math_equation_show_in_progress(gpointer data)
+{
+    MathEquation *equation = MATH_EQUATION(data);
+    if (equation->priv->in_solve)
+        math_equation_set_status(equation, _("Calculating"));
+    return false;
+}
+
+static gboolean
+math_equation_look_for_answer(gpointer data)
+{
+    MathEquation *equation = MATH_EQUATION(data);
+    SolveData *result = g_async_queue_try_pop(equation->priv->queue);
+
+    if (result == NULL)
+        return true;
+
+    equation->priv->in_solve = false;
+
+    if (!result->error)
+        math_equation_set_status(equation, "");
+
+    if (result->error != NULL) {
+        math_equation_set_status(equation, result->error);
+        g_free(result->error);
+    }
+    else if (result->number_result != NULL) {
+        math_equation_set_number(equation, result->number_result);
+        mp_clear(result->number_result);
+        g_slice_free(MPNumber, result->number_result);
+    }
+    else if (result->text_result != NULL) {
+        math_equation_set_with_history(equation, result->text_result);
+        g_free(result->text_result);
+    }
+    g_slice_free(SolveData, result);
+
+    return false;
+}
+
+void
+math_equation_solve(MathEquation *equation)
+{
+    g_return_if_fail(equation != NULL);
+
+    // FIXME: should replace calculation or give error message
+    if (equation->priv->in_solve)
+        return;
+
+    if (math_equation_is_empty(equation))
+        return;
+
+    /* If showing a result return to the equation that caused it */
+    // FIXME: Result may not be here due to solve (i.e. the user may have entered "ans")
+    if (math_equation_is_result(equation)) {
+        math_equation_undo(equation);
+        return;
+    }
+
+    equation->priv->in_solve = true;
+
+    math_equation_set_number_mode(equation, NORMAL);
+    g_thread_new("", math_equation_solve_real, equation);
+
+    g_timeout_add(50, math_equation_look_for_answer, equation);
+    g_timeout_add(100, math_equation_show_in_progress, equation);
+}
+
+static gpointer
+math_equation_factorize_real(gpointer data)
+{
+    GString *text;
+    GList *factors, *factor, *next_factor;
+    MPNumber x = mp_new();
+    MathEquation *equation = MATH_EQUATION(data);
+    SolveData *result = g_slice_new0(SolveData);
+    MpDisplayFormat format = mp_serializer_get_number_format(equation->priv->serializer);
+
+    mp_serializer_set_number_format(equation->priv->serializer, MP_DISPLAY_FORMAT_FIXED);
+    math_equation_get_number(equation, &x);
+    factors = mp_factorize(&x);
+
+    text = g_string_new("");
+
+    int e = 1;
+    for (factor = factors; factor != NULL; factor = factor->next)
+    {
+        gchar *temp;
+        MPNumber *n;
+
+        n = factor->data;
+        next_factor = factor->next;
+        if (next_factor != NULL && mp_compare(n, next_factor->data) == 0)
+        {
+            e++;
+            continue;
+        }
+        temp = mp_serializer_to_string(equation->priv->serializer, n);
+        g_string_append(text, temp);
+
+        if (e > 1)
+        {
+            g_string_append(text, "^");
+            g_string_append_printf(text, "%d", e);
+        }
+        if (factor->next)
+            g_string_append(text, " × ");
+
+        e = 1;
+
+        mp_clear(n);
+        g_slice_free(MPNumber, n);
+        g_free(temp);
+    }
+    g_list_free(factors);
+
+    result->text_result = g_strndup(text->str, text->len);
+    g_async_queue_push(equation->priv->queue, result);
+    g_string_free(text, TRUE);
+    mp_clear(&x);
+
+    mp_serializer_set_number_format(equation->priv->serializer, format);
+
+    return NULL;
+}
+
+void
+math_equation_factorize(MathEquation *equation)
+{
+    MPNumber x = mp_new();
+
+    g_return_if_fail(equation != NULL);
+
+    // FIXME: should replace calculation or give error message
+    if (equation->priv->in_solve)
+        return;
+
+    if (!math_equation_get_number(equation, &x) || !mp_is_integer(&x)) {
+        /* Error displayed when trying to factorize a non-integer value */
+        math_equation_set_status(equation, _("Need an integer to factorize"));
+        mp_clear(&x);
+        return;
+    }
+    mp_clear(&x);
+    equation->priv->in_solve = true;
+
+    g_thread_new("", math_equation_factorize_real, equation);
+
+    g_timeout_add(50, math_equation_look_for_answer, equation);
+    g_timeout_add(100, math_equation_show_in_progress, equation);
+}
+
+void
+math_equation_delete(MathEquation *equation)
+{
+    gint cursor;
+    GtkTextIter start, end;
+
+    g_return_if_fail(equation != NULL);
+
+    g_object_get(G_OBJECT(equation), "cursor-position", &cursor, NULL);
+    if (cursor >= gtk_text_buffer_get_char_count(GTK_TEXT_BUFFER(equation)))
+        return;
+
+    gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &start, cursor);
+    gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(equation), &end, cursor+1);
+    gtk_text_buffer_delete(GTK_TEXT_BUFFER(equation), &start, &end);
+}
+
+void
+math_equation_backspace(MathEquation *equation)
+{
+    g_return_if_fail(equation != NULL);
+
+    /* Can't delete empty display */
+    if (math_equation_is_empty(equation))
+        return;
+
+    if (gtk_text_buffer_get_has_selection(GTK_TEXT_BUFFER(equation)))
+        gtk_text_buffer_delete_selection(GTK_TEXT_BUFFER(equation), FALSE, FALSE);
+    else {
+        GtkTextIter iter;
+        gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(equation), &iter, gtk_text_buffer_get_insert(GTK_TEXT_BUFFER(equation)));
+        gtk_text_buffer_backspace(GTK_TEXT_BUFFER(equation), &iter, TRUE, TRUE);
+    }
+}
+
+void
+math_equation_clear(MathEquation *equation)
+{
+    g_return_if_fail(equation != NULL);
+
+    math_equation_set_number_mode(equation, NORMAL);
+    gtk_text_buffer_set_text(GTK_TEXT_BUFFER(equation), "", -1);
+    clear_ans(equation, FALSE);
+}
+
+void
+math_equation_shift(MathEquation *equation, gint count)
+{
+    MPNumber z = mp_new();
+
+    g_return_if_fail(equation != NULL);
+
+    if (!math_equation_get_number(equation, &z)) {
+        math_equation_set_status(equation,
+                                 /* This message is displayed in the status bar when a bit
+                                  shift operation is performed and the display does not contain a number */
+                                 _("No sane value to bitwise shift"));
+        return;
+    }
+
+    mp_shift(&z, count, &z);
+    math_equation_set_number(equation, &z);
+    mp_clear(&z);
+}
+
+void
+math_equation_toggle_bit(MathEquation *equation, guint bit)
+{
+    MPNumber x = mp_new();
+    guint64 bits;
+    gboolean result;
+
+    g_return_if_fail(equation != NULL);
+
+    result = math_equation_get_number(equation, &x);
+    if (result) {
+        MPNumber max = mp_new();
+        mp_set_from_unsigned_integer(G_MAXUINT64, &max);
+        if (mp_is_negative(&x) || mp_is_greater_than(&x, &max))
+            result = FALSE;
+        else
+            bits = mp_to_unsigned_integer(&x);
+        mp_clear(&max);
+    }
+
+    if (!result) {
+        math_equation_set_status(equation,
+                                 /* Message displayed when cannot toggle bit in display*/
+                                 _("Displayed value not an integer"));
+        mp_clear(&x);
+        return;
+    }
+
+    bits ^= (1LL << (63 - bit));
+
+    mp_set_from_unsigned_integer(bits, &x);
+
+    // FIXME: Only do this if in ans format, otherwise set text in same format as previous number
+    math_equation_set_number(equation, &x);
+    mp_clear(&x);
+}
+
+static void
+math_equation_set_property(GObject      *object,
+                           guint         prop_id,
+                           const GValue *value,
+                           GParamSpec   *pspec)
+{
+    MathEquation *self;
+
+    self = MATH_EQUATION(object);
+
+    switch (prop_id) {
+    case PROP_STATUS:
+        math_equation_set_status(self, g_value_get_string(value));
+        break;
+    case PROP_DISPLAY:
+        math_equation_set(self, g_value_get_string(value));
+        break;
+    case PROP_NUMBER_MODE:
+        math_equation_set_number_mode(self, g_value_get_int(value));
+        break;
+    case PROP_ACCURACY:
+        math_equation_set_accuracy(self, g_value_get_int(value));
+        break;
+    case PROP_SHOW_THOUSANDS_SEPARATORS:
+        math_equation_set_show_thousands_separators(self, g_value_get_boolean(value));
+        break;
+    case PROP_SHOW_TRAILING_ZEROES:
+        math_equation_set_show_trailing_zeroes(self, g_value_get_boolean(value));
+        break;
+    case PROP_NUMBER_FORMAT:
+        math_equation_set_number_format(self, g_value_get_int(value));
+        break;
+    case PROP_BASE:
+        math_equation_set_base(self, g_value_get_int(value));
+        break;
+    case PROP_WORD_SIZE:
+        math_equation_set_word_size(self, g_value_get_int(value));
+        break;
+    case PROP_ANGLE_UNITS:
+        math_equation_set_angle_units(self, g_value_get_int(value));
+        break;
+    case PROP_SOURCE_CURRENCY:
+        math_equation_set_source_currency(self, g_value_get_string(value));
+        break;
+    case PROP_TARGET_CURRENCY:
+        math_equation_set_target_currency(self, g_value_get_string(value));
+        break;
+    case PROP_SOURCE_UNITS:
+        math_equation_set_source_units(self, g_value_get_string(value));
+        break;
+    case PROP_TARGET_UNITS:
+        math_equation_set_target_units(self, g_value_get_string(value));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_equation_get_property(GObject    *object,
+                           guint       prop_id,
+                           GValue     *value,
+                           GParamSpec *pspec)
+{
+    MathEquation *self;
+    gchar *text;
+
+    self = MATH_EQUATION(object);
+
+    switch (prop_id) {
+    case PROP_STATUS:
+        g_value_set_string(value, self->priv->state.status);
+        break;
+    case PROP_DISPLAY:
+        text = math_equation_get_display(self);
+        g_value_set_string(value, text);
+        g_free(text);
+        break;
+    case PROP_EQUATION:
+        text = math_equation_get_equation(self);
+        g_value_set_string(value, text);
+        g_free(text);
+        break;
+    case PROP_NUMBER_MODE:
+        g_value_set_enum(value, self->priv->number_mode);
+        break;
+    case PROP_ACCURACY:
+        g_value_set_int(value, mp_serializer_get_trailing_digits(self->priv->serializer));
+        break;
+    case PROP_SHOW_THOUSANDS_SEPARATORS:
+        g_value_set_boolean(value, mp_serializer_get_show_thousands_separators(self->priv->serializer));
+        break;
+    case PROP_SHOW_TRAILING_ZEROES:
+        g_value_set_boolean(value, mp_serializer_get_show_trailing_zeroes(self->priv->serializer));
+        break;
+    case PROP_NUMBER_FORMAT:
+        g_value_set_enum(value, mp_serializer_get_number_format(self->priv->serializer));
+        break;
+    case PROP_BASE:
+        g_value_set_int(value, math_equation_get_base(self));
+        break;
+    case PROP_WORD_SIZE:
+        g_value_set_int(value, self->priv->word_size);
+        break;
+    case PROP_ANGLE_UNITS:
+        g_value_set_enum(value, self->priv->angle_units);
+        break;
+    case PROP_SOURCE_CURRENCY:
+        g_value_set_string(value, self->priv->source_currency);
+        break;
+    case PROP_TARGET_CURRENCY:
+        g_value_set_string(value, self->priv->target_currency);
+        break;
+    case PROP_SOURCE_UNITS:
+        g_value_set_string(value, self->priv->source_units);
+        break;
+    case PROP_TARGET_UNITS:
+        g_value_set_string(value, self->priv->target_units);
+        break;
+    case PROP_SERIALIZER:
+        g_value_set_object(value, self->priv->serializer);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_equation_constructed(GObject *object)
+{
+    GtkTextBuffer *parent_class;
+    parent_class = g_type_class_peek_parent(MATH_EQUATION_GET_CLASS(object));
+    if (G_OBJECT_CLASS(parent_class)->constructed)
+        G_OBJECT_CLASS(parent_class)->constructed(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)
+{
+    static GEnumValue number_mode_values[] =
+    {
+      {NORMAL,      "normal",      "normal"},
+      {SUPERSCRIPT, "superscript", "superscript"},
+      {SUBSCRIPT,   "subscript",   "subscript"},
+      {0, NULL, NULL}
+    };
+    static GEnumValue angle_unit_values[] =
+    {
+      {MP_RADIANS,  "radians",  "radians"},
+      {MP_DEGREES,  "degrees",  "degrees"},
+      {MP_GRADIANS, "gradians", "gradians"},
+      {0, NULL, NULL}
+    };
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    object_class->get_property = math_equation_get_property;
+    object_class->set_property = math_equation_set_property;
+    object_class->constructed = math_equation_constructed;
+
+    number_mode_type = g_enum_register_static("NumberMode", number_mode_values);
+    number_format_type = math_mp_display_format_get_type();
+    angle_unit_type = g_enum_register_static("AngleUnit", angle_unit_values);
+
+    g_object_class_install_property(object_class,
+                                    PROP_STATUS,
+                                    g_param_spec_string("status",
+                                                        "status",
+                                                        "Equation status",
+                                                        "",
+                                                        G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_DISPLAY,
+                                    g_param_spec_string("display",
+                                                        "display",
+                                                        "Displayed equation text",
+                                                        "",
+                                                        G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_EQUATION,
+                                    g_param_spec_string("equation",
+                                                        "equation",
+                                                        "Equation text",
+                                                        "",
+                                                        G_PARAM_READABLE));
+    g_object_class_install_property(object_class,
+                                    PROP_NUMBER_MODE,
+                                    g_param_spec_enum("number-mode",
+                                                      "number-mode",
+                                                      "Input number mode",
+                                                      number_mode_type,
+                                                      NORMAL,
+                                                      G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_ACCURACY,
+                                    g_param_spec_int("accuracy",
+                                                     "accuracy",
+                                                     "Display accuracy",
+                                                     0, 20, 9,
+                                                     G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_SHOW_THOUSANDS_SEPARATORS,
+                                    g_param_spec_boolean("show-thousands-separators",
+                                                         "show-thousands-separators",
+                                                         "Show thousands separators",
+                                                         TRUE,
+                                                         G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_SHOW_TRAILING_ZEROES,
+                                    g_param_spec_boolean("show-trailing-zeroes",
+                                                         "show-trailing-zeroes",
+                                                         "Show trailing zeroes",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_NUMBER_FORMAT,
+                                    g_param_spec_enum("number-format",
+                                                      "number-format",
+                                                      "Display format",
+                                                      number_format_type,
+                                                      MP_DISPLAY_FORMAT_FIXED,
+                                                      G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_BASE,
+                                    g_param_spec_int("base",
+                                                     "base",
+                                                     "Default number base (derived from number-format)",
+                                                     2, 16, 10,
+                                                     G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_WORD_SIZE,
+                                    g_param_spec_int("word-size",
+                                                     "word-size",
+                                                     "Word size in bits",
+                                                     8, 64, 64,
+                                                     G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_ANGLE_UNITS,
+                                    g_param_spec_enum("angle-units",
+                                                      "angle-units",
+                                                      "Angle units",
+                                                      angle_unit_type,
+                                                      MP_DEGREES,
+                                                      G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_SOURCE_CURRENCY,
+                                    g_param_spec_string("source-currency",
+                                                        "source-currency",
+                                                        "Source Currency",
+                                                        "",
+                                                        G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_TARGET_CURRENCY,
+                                    g_param_spec_string("target-currency",
+                                                        "target-currency",
+                                                        "target Currency",
+                                                        "",
+                                                        G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_SOURCE_UNITS,
+                                    g_param_spec_string("source-units",
+                                                        "source-units",
+                                                        "Source Units",
+                                                        "",
+                                                        G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_TARGET_UNITS,
+                                    g_param_spec_string("target-units",
+                                                        "target-units",
+                                                        "target Units",
+                                                        "",
+                                                        G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_SERIALIZER,
+                                    g_param_spec_object("serializer",
+                                                        "serializer",
+                                                        "Serializer",
+                                                        MP_TYPE_SERIALIZER,
+                                                        G_PARAM_READABLE));
+
+    GType param_types[2] = {G_TYPE_STRING, G_TYPE_POINTER};
+    g_signal_newv("history",
+                  G_TYPE_FROM_CLASS(klass),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL,
+                  NULL,
+                  NULL,
+                  G_TYPE_NONE,
+                  2,
+                  param_types);
+
+    g_signal_new ("display-changed",
+                  G_TYPE_FROM_CLASS(klass),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL,
+                  NULL,
+                  NULL,
+                  G_TYPE_NONE,
+                  0,
+                  NULL);
+}
+
+static void
+pre_insert_text_cb(MathEquation  *equation,
+                   GtkTextIter   *location,
+                   gchar         *text,
+                   gint           len,
+                   gpointer       user_data)
+{
+    gunichar c;
+    gint cursor;
+
+    if (equation->priv->in_reformat)
+        return;
+
+    /* If following a delete then have already pushed undo stack (GtkTextBuffer
+       doesn't indicate replace operations so we have to infer them) */
+    if (!equation->priv->in_delete)
+        math_equation_push_undo_stack(equation);
+
+    /* Clear result on next digit entered if cursor at end of line */
+    c = g_utf8_get_char(text);
+    g_object_get(G_OBJECT(equation), "cursor-position", &cursor, NULL);
+    if ((g_unichar_isdigit(c) || c == mp_serializer_get_radix(equation->priv->serializer)) &&
+         math_equation_is_result(equation) &&
+         cursor >= gtk_text_buffer_get_char_count(GTK_TEXT_BUFFER(equation))) {
+        gtk_text_buffer_set_text(GTK_TEXT_BUFFER(equation), "", -1);
+        clear_ans(equation, FALSE);
+        gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(equation), location);
+    }
+
+    if (equation->priv->ans_start) {
+        gint ans_start, ans_end;
+        gint offset;
+
+        offset = gtk_text_iter_get_offset(location);
+        get_ans_offsets(equation, &ans_start, &ans_end);
+
+        /* Inserted inside or right before ans */
+        if (offset >= ans_start && offset < ans_end)
+            clear_ans(equation, TRUE);
+    }
+}
+
+static gboolean
+on_delete(MathEquation *equation)
+{
+    equation->priv->in_delete = FALSE;
+    return FALSE;
+}
+
+static void
+pre_delete_range_cb(MathEquation  *equation,
+                    GtkTextIter   *start,
+                    GtkTextIter   *end,
+                    gpointer       user_data)
+{
+    if (equation->priv->in_reformat)
+        return;
+
+    math_equation_push_undo_stack(equation);
+
+    equation->priv->in_delete = TRUE;
+    g_idle_add((GSourceFunc)on_delete, equation);
+
+    if (equation->priv->ans_start) {
+        gint ans_start, ans_end;
+        gint start_offset, end_offset;
+
+        start_offset = gtk_text_iter_get_offset(start);
+        end_offset = gtk_text_iter_get_offset(end);
+        get_ans_offsets(equation, &ans_start, &ans_end);
+
+        /* Deleted part of ans */
+        if (start_offset < ans_end && end_offset > ans_start)
+            clear_ans(equation, TRUE);
+    }
+}
+
+static void
+insert_text_cb(MathEquation  *equation,
+               GtkTextIter   *location,
+               gchar         *text,<--- Parameter 'text' can be declared as pointer to const
+               gint           len,
+               gpointer       user_data)
+{
+    if (equation->priv->in_reformat)
+        return;
+
+    equation->priv->state.entered_multiply = strcmp(text, "×") == 0;
+
+    /* Update thousands separators */
+    reformat_separators(equation);
+
+    g_object_notify(G_OBJECT(equation), "display");
+}
+
+static void
+delete_range_cb(MathEquation  *equation,
+                GtkTextIter   *start,
+                GtkTextIter   *end,
+                gpointer       user_data)
+{
+    if (equation->priv->in_reformat)
+        return;
+
+    equation->priv->state.entered_multiply = FALSE;
+
+    /* Update thousands separators */
+    reformat_separators(equation);
+
+    // FIXME: A replace will emit this both for delete-range and insert-text, can it be avoided?
+    g_object_notify(G_OBJECT(equation), "display");
+}
+
+static void
+math_equation_init(MathEquation *equation)
+{
+    /* Digits localized for the given language */
+    const char *digit_values = _("0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F");
+    const char *default_digits[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
+    gchar **digits;
+    /* Default to using untranslated digits, this is because it doesn't make sense in most languages and we need to make this optional.
+     * See https://bugzilla.gnome.org/show_bug.cgi?id=632661 */
+    gboolean use_default_digits = TRUE;
+    int i;
+
+    equation->priv = math_equation_get_instance_private (equation);
+
+    g_signal_connect(equation, "insert-text", G_CALLBACK(pre_insert_text_cb), equation);
+    g_signal_connect(equation, "delete-range", G_CALLBACK(pre_delete_range_cb), equation);
+    g_signal_connect_after(equation, "insert-text", G_CALLBACK(insert_text_cb), equation);<--- You might need to cast the function pointer here
+    g_signal_connect_after(equation, "delete-range", G_CALLBACK(delete_range_cb), equation);
+
+    digits = g_strsplit(digit_values, ",", -1);
+    for (i = 0; i < 16; i++) {
+        if (use_default_digits || digits[i] == NULL) {
+            use_default_digits = TRUE;
+            equation->priv->digits[i] = g_utf8_get_char(default_digits[i]);
+        }
+        else
+            equation->priv->digits[i] = g_utf8_get_char(digits[i]);
+    }
+    g_strfreev(digits);
+
+    equation->priv->variables = math_variables_new();
+
+    equation->priv->state.ans = mp_new();
+    equation->priv->state.status = g_strdup("");
+    equation->priv->word_size = 32;
+    equation->priv->angle_units = MP_DEGREES;
+    // FIXME: Pick based on locale
+    equation->priv->source_currency = g_strdup("");
+    equation->priv->target_currency = g_strdup("");
+    equation->priv->source_units = g_strdup("");
+    equation->priv->target_units = g_strdup("");
+    equation->priv->serializer = mp_serializer_new(MP_DISPLAY_FORMAT_AUTOMATIC, 10, 9);
+    equation->priv->queue = g_async_queue_new();
+
+    mp_set_from_integer(0, &equation->priv->state.ans);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/28.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/28.html new file mode 100644 index 0000000..b25e6be --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/28.html @@ -0,0 +1,277 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20

+/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+
+
+#ifndef __MATH_ENUMS_H__
+#define __MATH_ENUMS_H__
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* enumerations from "./mp-serializer.h" */
+GType math_mp_display_format_get_type (void) G_GNUC_CONST;
+#define MP_TYPE_DISPLAY_FORMAT (math_mp_display_format_get_type ())
+G_END_DECLS
+
+#endif /* __MATH_ENUMS_H__ */
+
+/* Generated data ends here */
+
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/29.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/29.html new file mode 100644 index 0000000..19439ce --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/29.html @@ -0,0 +1,491 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
/*
+ * 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
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ *
+ *
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-history-entry.h"
+
+struct MathHistoryEntryPrivate
+{
+    MathEquation *equation;
+
+    MPNumber *number;
+    GtkWidget *equation_label;
+    GtkWidget *answer_label;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MathHistoryEntry, math_history_entry, GTK_TYPE_LIST_BOX_ROW);
+
+#define UI_HISTORY_ENTRY_RESOURCE_PATH "/org/mate/calculator/ui/history-entry.ui"
+
+MathHistoryEntry *
+math_history_entry_new(MathEquation *equation)
+{
+    MathHistoryEntry *history_entry = g_object_new(math_history_entry_get_type(), NULL);
+    history_entry->priv->equation = g_object_ref(equation);
+    return history_entry;
+}
+
+void answer_clicked_cb(GtkWidget *widget, GdkEventButton *eventbutton, MathHistoryEntry *history_entry);
+G_MODULE_EXPORT
+void
+answer_clicked_cb (GtkWidget *widget, GdkEventButton *eventbutton, MathHistoryEntry *history_entry)
+{
+    const gchar *answer = gtk_widget_get_tooltip_text(history_entry->priv->answer_label);
+
+    if (answer != NULL)
+        math_equation_insert(history_entry->priv->equation, answer);
+}
+
+void equation_clicked_cb(GtkWidget *widget, GdkEventButton *eventbutton, MathHistoryEntry *history_entry);
+G_MODULE_EXPORT
+void
+equation_clicked_cb (GtkWidget *widget, GdkEventButton *eventbutton, MathHistoryEntry *history_entry)
+{
+    const gchar *equation = gtk_label_get_text(GTK_LABEL(history_entry->priv->equation_label));
+
+    if (equation != NULL)
+        math_equation_set(history_entry->priv->equation, equation);
+}
+
+void
+math_history_entry_insert_entry(MathHistoryEntry *history_entry, const gchar *equation, MPNumber *answer, MpSerializer *serializer)<--- Parameter 'answer' can be declared as pointer to const
+{
+    #define get_widget(x) GTK_WIDGET(gtk_builder_get_object(builder, x))
+
+    GtkBuilder *builder;
+    GtkWidget *grid;
+
+    mp_set_from_mp(answer, history_entry->priv->number);
+
+    builder = gtk_builder_new_from_resource(UI_HISTORY_ENTRY_RESOURCE_PATH);
+    grid = get_widget("grid");
+    gtk_container_add(GTK_CONTAINER(history_entry), grid);
+    history_entry->priv->equation_label = get_widget("equation_label");
+    history_entry->priv->answer_label = get_widget("answer_label");
+    gtk_widget_set_tooltip_text(history_entry->priv->equation_label, equation);
+    gtk_label_set_text(GTK_LABEL(history_entry->priv->equation_label), equation);
+    gtk_builder_connect_signals(builder, history_entry);
+    g_object_unref(builder);
+
+    #undef get_widget
+
+    math_history_entry_redisplay(history_entry, serializer);
+}
+
+void
+math_history_entry_redisplay(MathHistoryEntry *history_entry, MpSerializer *serializer)
+{
+    gchar *answer = mp_serializer_to_string(serializer, history_entry->priv->number);
+
+    gtk_widget_set_tooltip_text(history_entry->priv->answer_label, answer);
+    gtk_label_set_text(GTK_LABEL(history_entry->priv->answer_label), answer);
+
+    g_free(answer);
+}
+
+gchar *
+math_history_entry_get_equation(MathHistoryEntry *history_entry)
+{
+    return gtk_widget_get_tooltip_text(history_entry->priv->equation_label);
+}
+
+static void
+math_history_entry_finalize(GObject *object)
+{
+    MathHistoryEntry *self = MATH_HISTORY_ENTRY (object);
+
+    mp_free(self->priv->number);
+
+    G_OBJECT_CLASS (math_history_entry_parent_class)->finalize (object);
+}
+
+static void
+math_history_entry_class_init(MathHistoryEntryClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    object_class->finalize = math_history_entry_finalize;
+}
+
+static void
+math_history_entry_init(MathHistoryEntry *history_entry)
+{
+    history_entry->priv = math_history_entry_get_instance_private(history_entry);
+    history_entry->priv->number = mp_new_ptr();
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/3.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/3.html new file mode 100644 index 0000000..cf9c9ba --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/3.html @@ -0,0 +1,413 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdarg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "currency.h"
+#include "mp-serializer.h"
+#include "currency-manager.h" // FIXME: Move out of here
+
+struct CurrencyPrivate
+{
+    gchar *name;
+    gchar *display_name;
+    gchar *symbol;
+    MPNumber value;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (Currency, currency, G_TYPE_OBJECT);
+
+Currency *
+currency_new(const gchar *name,
+             const gchar *display_name,
+             const gchar *symbol)
+{
+    Currency *currency = g_object_new(currency_get_type(), NULL);
+
+    currency->priv->name = g_strdup(name);
+    currency->priv->display_name = g_strdup(display_name);
+    currency->priv->symbol = g_strdup(symbol);
+    currency->priv->value = mp_new();
+
+    return currency;
+}
+
+const gchar *
+currency_get_name(Currency *currency)
+{
+    g_return_val_if_fail (currency != NULL, NULL);
+    return currency->priv->name;
+}
+
+const gchar *
+currency_get_display_name(Currency *currency)
+{
+    g_return_val_if_fail (currency != NULL, NULL);
+    return currency->priv->display_name;
+}
+
+const gchar *
+currency_get_symbol(Currency *currency)
+{
+    g_return_val_if_fail (currency != NULL, NULL);
+    return currency->priv->symbol;
+}
+
+void
+currency_set_value(Currency *currency, MPNumber *value)<--- Parameter 'value' can be declared as pointer to const
+{
+    g_return_if_fail (currency != NULL);
+    g_return_if_fail (value != NULL);
+    mp_set_from_mp (value, &currency->priv->value);
+}
+
+const MPNumber *
+currency_get_value(Currency *currency)
+{
+    g_return_val_if_fail (currency != NULL, NULL);
+    return &currency->priv->value;
+}
+
+static void
+currency_class_init(CurrencyClass *klass)
+{
+}
+
+static void
+currency_init(Currency *currency)
+{
+    currency->priv = currency_get_instance_private (currency);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/30.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/30.html new file mode 100644 index 0000000..b376211 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/30.html @@ -0,0 +1,347 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
/*
+ * 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
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ *
+ *
+ */
+
+#ifndef MATH_HISTORY_ENTRY_VIEW_H
+#define MATH_HISTORY_ENTRY_VIEW_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-display.h"
+#include "math-history.h"
+
+G_BEGIN_DECLS
+
+#define MATH_HISTORY_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_history_entry_get_type(), MathHistoryEntry))
+
+typedef struct MathHistoryEntryPrivate MathHistoryEntryPrivate;
+
+typedef struct
+{
+    GtkListBoxRow parent_instance;
+    MathHistoryEntryPrivate *priv;
+} MathHistoryEntry;
+
+typedef struct
+{
+    GtkListBoxRowClass parent_class;
+} MathHistoryEntryClass;
+
+GType math_history_entry_get_type(void);
+
+MathHistoryEntry *
+math_history_entry_new(MathEquation *equation);
+
+void
+math_history_entry_insert_entry(MathHistoryEntry *history_entry, const gchar *equation, MPNumber *answer, MpSerializer *serializer);
+
+void 
+math_history_entry_redisplay(MathHistoryEntry *history_entry, MpSerializer *serializer);
+
+gchar *
+math_history_entry_get_equation(MathHistoryEntry *history_entry);
+
+G_END_DECLS
+
+#endif /* MATH_HISTORY_ENTRY_VIEW_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/31.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/31.html new file mode 100644 index 0000000..1522415 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/31.html @@ -0,0 +1,367 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
/*
+ * 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
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ *
+ *
+ */
+
+#ifndef MATH_HISTORY_VIEW_H
+#define MATH_HISTORY_VIEW_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-history-entry.h"
+#include "math-display.h"
+#include "math-equation.h"
+
+G_BEGIN_DECLS
+
+#define MATH_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_history_get_type(), MathHistory))
+
+typedef struct MathHistoryPrivate MathHistoryPrivate;
+
+typedef struct
+{
+    GtkScrolledWindow parent_instance;
+    MathHistoryPrivate *priv;
+} MathHistory;
+
+typedef struct
+{
+    GtkScrolledWindowClass parent_class;
+} MathHistoryClass;
+
+GType math_history_get_type(void);
+
+MathHistory *
+math_history_new(MathEquation *equation);
+
+void
+math_history_insert_entry(MathHistory *history, char *equation, MPNumber *answer);
+
+gpointer
+math_history_get_entry_at(MathHistory *history, int index);
+
+void
+math_history_set_current(MathHistory *history, int value);
+
+int
+math_history_get_current(MathHistory *history);
+
+void
+math_history_clear(MathHistory *history);
+
+void
+math_history_set_serializer(MathHistory *history, MpSerializer *serializer);
+
+G_END_DECLS
+
+#endif /* MATH_HISTORY_VIEW_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/32.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/32.html new file mode 100644 index 0000000..483c35f --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/32.html @@ -0,0 +1,561 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
/*
+ * 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
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ *
+ *
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-history.h"
+
+struct MathHistoryPrivate
+{
+    MathEquation *equation;
+
+    MpSerializer *serializer;
+    gchar *last_equation;
+    int current; /* 0 is the first entry, rows-1 the most recent entry */
+    int rows;
+    GtkWidget *listbox;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(MathHistory, math_history, GTK_TYPE_SCROLLED_WINDOW);
+
+MathHistory *
+math_history_new(MathEquation *equation)
+{
+    MathHistory *history = g_object_new(math_history_get_type(), NULL);
+    history->priv->equation = g_object_ref(equation);
+    return history;
+}
+
+static void
+scroll_bottom_cb(MathHistory *history, gpointer data)
+{
+    GtkAdjustment *adjustment;
+    // TODO make this dynamic, do not hardcode listbox_height_request/number_of_rows
+    int width, height;
+
+    adjustment = gtk_list_box_get_adjustment(GTK_LIST_BOX(history->priv->listbox));
+    gtk_widget_get_size_request(GTK_WIDGET(history), &width, &height);
+    gtk_adjustment_set_page_size(adjustment, height / 3);
+    gtk_adjustment_set_value (adjustment, gtk_adjustment_get_upper (adjustment)
+                                          - gtk_adjustment_get_page_size (adjustment));
+}
+
+void
+math_history_insert_entry (MathHistory *history, char *equation, MPNumber *answer)
+{
+    if (g_strcmp0(history->priv->last_equation, equation) == 0 && history->priv->rows >= 1)
+    {
+        return;
+    }
+
+    MathHistoryEntry *entry = math_history_entry_new(history->priv->equation);
+
+    math_history_entry_insert_entry(entry, equation, answer, history->priv->serializer);
+
+    gtk_list_box_insert(GTK_LIST_BOX(history->priv->listbox), GTK_WIDGET(entry), -1);
+    gtk_widget_set_can_focus(GTK_WIDGET(entry), FALSE);
+    gtk_widget_show(GTK_WIDGET(entry));
+
+    g_free(history->priv->last_equation);
+
+    history->priv->last_equation = g_strdup(equation);
+    history->priv->rows++;
+    history->priv->current = history->priv->rows;
+    g_signal_emit_by_name(history, "row-added");
+}
+
+void
+math_history_clear(MathHistory *history)
+{
+    GList *children, *iter;
+
+    history->priv->rows = 0;
+    history->priv->current = 0;
+    children = gtk_container_get_children(GTK_CONTAINER(history->priv->listbox));
+    for (iter = children; iter != NULL; iter = g_list_next(iter))
+          gtk_widget_destroy(GTK_WIDGET(iter->data));
+    g_list_free(children);
+}
+
+gpointer
+math_history_get_entry_at(MathHistory *history, int index)
+{
+    if (index >= 0 && index < history->priv->rows)
+        return MATH_HISTORY_ENTRY(gtk_list_box_get_row_at_index(GTK_LIST_BOX(history->priv->listbox), index));
+    return NULL;
+}
+
+void
+math_history_set_current(MathHistory *history, int value)
+{
+    history->priv->current = CLAMP (history->priv->current + value, 0, history->priv->rows - 1);
+}
+
+int
+math_history_get_current(MathHistory *history)
+{
+    return history->priv->current;
+}
+
+void
+math_history_set_serializer(MathHistory *history, MpSerializer *serializer)
+{
+    history->priv->serializer = serializer;
+
+    GList *children, *iter;
+    children = gtk_container_get_children(GTK_CONTAINER(history->priv->listbox));
+    for (iter = children; iter != NULL; iter = g_list_next(iter))
+          math_history_entry_redisplay(MATH_HISTORY_ENTRY(iter->data), serializer);
+    g_list_free(children);
+}
+
+static void
+math_history_class_init(MathHistoryClass *klass)
+{
+    g_signal_new("row-added",
+                 G_TYPE_FROM_CLASS(klass),
+                 G_SIGNAL_RUN_FIRST,
+                 0,
+                 NULL,
+                 NULL,
+                 NULL,
+                 G_TYPE_NONE,
+                 0,
+                 NULL);
+}
+
+static void
+math_history_init(MathHistory *history)
+{
+    history->priv = math_history_get_instance_private(history);
+
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(history), GTK_SHADOW_IN);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(history), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(history), GTK_CORNER_TOP_LEFT);
+
+    history->priv->serializer = NULL;
+    history->priv->current = 0;
+    history->priv->rows = 0;
+    history->priv->last_equation = g_strdup("");
+    history->priv->listbox = gtk_list_box_new();
+
+    gtk_list_box_set_selection_mode(GTK_LIST_BOX(history->priv->listbox), GTK_SELECTION_NONE);
+    gtk_widget_show(GTK_WIDGET(history->priv->listbox));
+
+    gtk_container_add(GTK_CONTAINER(history), history->priv->listbox);
+    gtk_widget_set_valign(GTK_WIDGET(history->priv->listbox), GTK_ALIGN_END);
+    gtk_widget_set_size_request(GTK_WIDGET(history), 100, 100);
+    gtk_widget_set_can_focus(GTK_WIDGET(history), FALSE);
+
+    g_signal_connect(history, "row-added", G_CALLBACK(scroll_bottom_cb), NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/33.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/33.html new file mode 100644 index 0000000..1be29e5 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/33.html @@ -0,0 +1,1001 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-preferences.h"
+#include "utility.h"
+
+enum {
+    PROP_0,
+    PROP_EQUATION
+};
+
+struct MathPreferencesDialogPrivate
+{
+    MathEquation *equation;
+    GtkBuilder *ui;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MathPreferencesDialog, math_preferences, GTK_TYPE_DIALOG);
+
+#define UI_DIALOGS_RESOURCE_PATH "/org/mate/calculator/ui/preferences.ui"
+#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)
+{
+    preferences_response_cb(widget, 0);
+    return TRUE;
+}
+
+void number_format_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog);
+G_MODULE_EXPORT
+void
+number_format_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
+{
+    MpDisplayFormat value;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
+    gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
+    gtk_tree_model_get(model, &iter, 1, &value, -1);
+    math_equation_set_number_format(dialog->priv->equation, value);
+}
+
+void angle_unit_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog);
+G_MODULE_EXPORT
+void
+angle_unit_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
+{
+    MPAngleUnit value;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
+    gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
+    gtk_tree_model_get(model, &iter, 1, &value, -1);
+    math_equation_set_angle_units(dialog->priv->equation, value);
+}
+
+void word_size_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog);
+G_MODULE_EXPORT
+void
+word_size_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
+{
+    gint value;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
+    gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
+    gtk_tree_model_get(model, &iter, 1, &value, -1);
+    math_equation_set_word_size(dialog->priv->equation, value);
+}
+
+void decimal_places_spin_change_value_cb(GtkWidget *spin, MathPreferencesDialog *dialog);
+G_MODULE_EXPORT
+void
+decimal_places_spin_change_value_cb(GtkWidget *spin, MathPreferencesDialog *dialog)
+{
+    gint value = 0;
+
+    value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
+    math_equation_set_accuracy(dialog->priv->equation, value);
+}
+
+void thousands_separator_check_toggled_cb(GtkWidget *check, MathPreferencesDialog *dialog);
+G_MODULE_EXPORT
+void
+thousands_separator_check_toggled_cb(GtkWidget *check, MathPreferencesDialog *dialog)
+{
+    gboolean value;
+
+    value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check));
+    math_equation_set_show_thousands_separators(dialog->priv->equation, value);
+}
+
+void trailing_zeroes_check_toggled_cb(GtkWidget *check, MathPreferencesDialog *dialog);
+G_MODULE_EXPORT
+void
+trailing_zeroes_check_toggled_cb(GtkWidget *check, MathPreferencesDialog *dialog)
+{
+    gboolean value;
+
+    value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check));
+    math_equation_set_show_trailing_zeroes(dialog->priv->equation, value);
+}
+
+static void
+set_combo_box_from_int(GtkWidget *combo, int value)
+{
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gboolean valid;
+
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
+    valid = gtk_tree_model_get_iter_first(model, &iter);
+
+    while (valid) {
+        gint v;
+
+        gtk_tree_model_get(model, &iter, 1, &v, -1);
+        if (v == value)
+            break;
+        valid = gtk_tree_model_iter_next(model, &iter);
+    }
+    if (!valid)
+        valid = gtk_tree_model_get_iter_first(model, &iter);<--- Variable 'valid' is assigned a value that is never used.
+
+    gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
+}
+
+static void
+accuracy_cb(MathEquation *equation, GParamSpec *spec, MathPreferencesDialog *dialog)
+{
+    gtk_spin_button_set_value(GTK_SPIN_BUTTON(gtk_builder_get_object(dialog->priv->ui, "decimal_places_spin")),
+                              math_equation_get_accuracy(equation));
+    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)
+{
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(dialog->priv->ui, "thousands_separator_check")),
+                                 math_equation_get_show_thousands_separators(equation));
+    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)
+{
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(dialog->priv->ui, "trailing_zeroes_check")),
+                                 math_equation_get_show_trailing_zeroes(equation));
+    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)
+{
+    set_combo_box_from_int(GET_WIDGET(dialog->priv->ui, "number_format_combobox"), math_equation_get_number_format(equation));
+    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)
+{
+    set_combo_box_from_int(GET_WIDGET(dialog->priv->ui, "word_size_combobox"), math_equation_get_word_size(equation));
+    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)
+{
+    set_combo_box_from_int(GET_WIDGET(dialog->priv->ui, "angle_unit_combobox"), math_equation_get_angle_units(equation));
+    g_settings_set_enum(g_settings_var, "angle-units", math_equation_get_angle_units(equation));
+}
+
+static void
+create_gui(MathPreferencesDialog *dialog)
+{
+    GtkWidget *widget;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GtkCellRenderer *renderer;
+    gchar *string, **tokens;
+    GError *error = NULL;
+    static gchar *objects[] = { "preferences_table", "angle_unit_model", "number_format_model",
+                                "word_size_model", "decimal_places_adjustment", "number_base_model", NULL };
+
+    // FIXME: Handle errors
+    dialog->priv->ui = gtk_builder_new();
+    gtk_builder_add_objects_from_resource(dialog->priv->ui, UI_DIALOGS_RESOURCE_PATH, objects, &error);
+    if (error)
+        g_warning("Error loading preferences UI: %s", error->message);
+    g_clear_error(&error);
+
+    gtk_window_set_title(GTK_WINDOW(dialog),
+                         /* Title of preferences dialog */
+                         _("Preferences"));
+    gtk_container_set_border_width(GTK_CONTAINER(dialog), 8);
+    gtk_dialog_add_button(GTK_DIALOG(dialog),
+                          /* Icon name on close button in preferences dialog */
+                          "gtk-close", GTK_RESPONSE_CLOSE);
+
+    gtk_window_set_icon_name (GTK_WINDOW(dialog), "accessories-calculator");
+
+    g_signal_connect(dialog, "response", G_CALLBACK(preferences_response_cb), NULL);
+    g_signal_connect(dialog, "delete-event", G_CALLBACK(preferences_dialog_delete_cb), NULL);
+    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), GET_WIDGET(dialog->priv->ui, "preferences_table"), TRUE, TRUE, 0);
+
+    widget = GET_WIDGET(dialog->priv->ui, "angle_unit_combobox");
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
+    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                       /* Preferences dialog: Angle unit combo box: Use degrees for trigonometric calculations */
+                       _("Degrees"), 1, MP_DEGREES, -1);
+    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                       /* Preferences dialog: Angle unit combo box: Use radians for trigonometric calculations */
+                       _("Radians"), 1, MP_RADIANS, -1);
+    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                       /* Preferences dialog: Angle unit combo box: Use gradians for trigonometric calculations */
+                       _("Gradians"), 1, MP_GRADIANS, -1);
+    renderer = gtk_cell_renderer_text_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
+    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
+
+    widget = GET_WIDGET(dialog->priv->ui, "number_format_combobox");
+    model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
+    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                       /* Number display mode combo: Automatic, e.g. 1234 (or scientific for large number 1.234×10^99) */
+                       _("Automatic"), 1, MP_DISPLAY_FORMAT_AUTOMATIC, -1);
+    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                       /* Number display mode combo: Fixed, e.g. 1234 */
+                       _("Fixed"), 1, MP_DISPLAY_FORMAT_FIXED, -1);
+    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                       /* Number display mode combo: Scientific, e.g. 1.234×10^3 */
+                       _("Scientific"), 1, MP_DISPLAY_FORMAT_SCIENTIFIC, -1);
+    gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+    gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
+                       /* Number display mode combo: Engineering, e.g. 1.234k */
+                       _("Engineering"), 1, MP_DISPLAY_FORMAT_ENGINEERING, -1);
+    renderer = gtk_cell_renderer_text_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
+    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
+
+    widget = GET_WIDGET(dialog->priv->ui, "word_size_combobox");
+    renderer = gtk_cell_renderer_text_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
+    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(widget), renderer, "text", 0);
+
+    /* Label used in preferences dialog.  The %d is replaced by a spinbutton */
+    string = _("Show %d decimal _places");
+    tokens = g_strsplit(string, "%d", 2);
+    widget = GET_WIDGET(dialog->priv->ui, "decimal_places_label1");
+    if (tokens[0])
+        string = g_strstrip(tokens[0]);
+    else
+        string = "";
+    if (string[0] != '\0')
+        gtk_label_set_text_with_mnemonic(GTK_LABEL(widget), string);
+    else
+        gtk_widget_hide(widget);
+
+    widget = GET_WIDGET(dialog->priv->ui, "decimal_places_label2");
+    if (tokens[0] && tokens[1])
+        string = g_strstrip(tokens[1]);
+    else
+        string = "";
+    if (string[0] != '\0')
+        gtk_label_set_text_with_mnemonic(GTK_LABEL(widget), string);
+    else
+        gtk_widget_hide(widget);
+
+    g_strfreev(tokens);
+
+    gtk_builder_connect_signals(dialog->priv->ui, dialog);
+
+    g_signal_connect(dialog->priv->equation, "notify::accuracy", G_CALLBACK(accuracy_cb), dialog);
+    g_signal_connect(dialog->priv->equation, "notify::show-thousands-separators", G_CALLBACK(show_thousands_separators_cb), dialog);
+    g_signal_connect(dialog->priv->equation, "notify::show-trailing_zeroes", G_CALLBACK(show_trailing_zeroes_cb), dialog);
+    g_signal_connect(dialog->priv->equation, "notify::number-format", G_CALLBACK(number_format_cb), dialog);
+    g_signal_connect(dialog->priv->equation, "notify::word-size", G_CALLBACK(word_size_cb), dialog);
+    g_signal_connect(dialog->priv->equation, "notify::angle-units", G_CALLBACK(angle_unit_cb), dialog);
+
+    accuracy_cb(dialog->priv->equation, NULL, dialog);
+    show_thousands_separators_cb(dialog->priv->equation, NULL, dialog);
+    show_trailing_zeroes_cb(dialog->priv->equation, NULL, dialog);
+    number_format_cb(dialog->priv->equation, NULL, dialog);
+    word_size_cb(dialog->priv->equation, NULL, dialog);
+    angle_unit_cb(dialog->priv->equation, NULL, dialog);
+}
+
+static void
+math_preferences_set_property(GObject      *object,
+                              guint         prop_id,
+                              const GValue *value,
+                              GParamSpec   *pspec)
+{
+    MathPreferencesDialog *self;
+
+    self = MATH_PREFERENCES(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        self->priv->equation = g_value_get_object(value);
+        create_gui(self);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_preferences_get_property(GObject    *object,
+                              guint       prop_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+    MathPreferencesDialog *self;
+
+    self = MATH_PREFERENCES(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        g_value_set_object(value, self->priv->equation);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_preferences_class_init(MathPreferencesDialogClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    object_class->get_property = math_preferences_get_property;
+    object_class->set_property = math_preferences_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_EQUATION,
+                                    g_param_spec_object("equation",
+                                                        "equation",
+                                                        "Equation being configured",
+                                                        math_equation_get_type(),
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+math_preferences_init(MathPreferencesDialog *dialog)
+{
+    dialog->priv = math_preferences_get_instance_private (dialog);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/34.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/34.html new file mode 100644 index 0000000..f72a03a --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/34.html @@ -0,0 +1,829 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-variable-popup.h"
+
+enum {
+    PROP_0,
+    PROP_EQUATION
+};
+
+struct MathVariablePopupPrivate
+{
+    MathEquation *equation;
+
+    GtkWidget *vbox;
+    GtkWidget *variable_name_entry;
+    GtkWidget *add_variable_button;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MathVariablePopup, math_variable_popup, GTK_TYPE_WINDOW);
+
+MathVariablePopup *
+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)
+{
+    const gchar *name;
+
+    name = g_object_get_data(G_OBJECT(widget), "variable_name");
+    math_equation_insert(popup->priv->equation, name);
+
+    gtk_widget_destroy(gtk_widget_get_toplevel(widget));
+}
+
+static gboolean
+variable_name_key_press_cb(GtkWidget *widget, GdkEventKey *event, MathVariablePopup *popup)
+{
+    /* Can't have whitespace in names, so replace with underscores */
+    if (event->keyval == GDK_KEY_space || event->keyval == GDK_KEY_KP_Space)
+        event->keyval = GDK_KEY_underscore;
+
+    return FALSE;
+}
+
+static void
+variable_name_changed_cb(GtkWidget *widget, MathVariablePopup *popup)
+{
+    const gchar *text = gtk_entry_get_text(GTK_ENTRY(popup->priv->variable_name_entry));
+    gtk_widget_set_sensitive(popup->priv->add_variable_button, text[0] != '\0');
+}
+
+static void
+add_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
+{
+    const gchar *name;
+    MPNumber z = mp_new();
+
+    name = gtk_entry_get_text(GTK_ENTRY(popup->priv->variable_name_entry));
+    if (name[0] == '\0')
+        return;
+
+    if (math_equation_get_number(popup->priv->equation, &z))
+        math_variables_set(math_equation_get_variables(popup->priv->equation), name, &z);
+    else if (math_equation_is_result(popup->priv->equation))
+        math_variables_set(math_equation_get_variables(popup->priv->equation), name, math_equation_get_answer(popup->priv->equation));
+    else
+        g_warning("Can't add variable %s, the display is not a number", name);
+
+    gtk_widget_destroy(gtk_widget_get_toplevel(widget));
+    mp_clear(&z);
+}
+
+static void
+save_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
+{
+    const gchar *name;
+    MPNumber z = mp_new();
+
+    name = g_object_get_data(G_OBJECT(widget), "variable_name");
+    if (math_equation_get_number(popup->priv->equation, &z))
+        math_variables_set(math_equation_get_variables(popup->priv->equation), name, &z);
+    else if (math_equation_is_result(popup->priv->equation))
+        math_variables_set(math_equation_get_variables(popup->priv->equation), name, math_equation_get_answer(popup->priv->equation));
+    else
+        g_warning("Can't save variable %s, the display is not a number", name);
+
+    gtk_widget_destroy(gtk_widget_get_toplevel(widget));
+    mp_clear(&z);
+}
+
+static void
+delete_variable_cb(GtkWidget *widget, MathVariablePopup *popup)
+{
+    const gchar *name;
+
+    name = g_object_get_data(G_OBJECT(widget), "variable_name");
+    math_variables_delete(math_equation_get_variables(popup->priv->equation), name);
+
+    gtk_widget_destroy(gtk_widget_get_toplevel(widget));
+}
+
+static GtkWidget *
+make_variable_entry(MathVariablePopup *popup, const gchar *name, const MPNumber *value, gboolean writable)
+{
+    GtkWidget *hbox, *button, *label;
+    gchar *text;
+
+    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
+
+    if (value)
+    {
+        gchar *value_text = mp_serializer_to_string(math_equation_get_serializer(popup->priv->equation), value);
+        text = g_strdup_printf("<b>%s</b> = %s", name, value_text);
+        g_free (value_text);
+    }
+    else
+        text = g_strdup_printf("<b>%s</b>", name);
+
+    button = gtk_button_new();
+    g_object_set_data(G_OBJECT(button), "variable_name", g_strdup(name)); // FIXME: These will all leak memory
+    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_variable_cb), popup);
+    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+    gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
+    gtk_widget_show(button);
+
+    label = gtk_label_new(text);
+    g_free(text);
+    gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
+    gtk_widget_set_halign (label, GTK_ALIGN_START);
+    gtk_container_add(GTK_CONTAINER(button), label);
+    gtk_widget_show(label);
+
+    if (writable)
+    {
+        GtkWidget *image;
+
+        button = gtk_button_new();
+        g_object_set_data(G_OBJECT(button), "variable_name", g_strdup(name));
+        image = gtk_image_new_from_icon_name("document-save", GTK_ICON_SIZE_BUTTON);
+        gtk_container_add(GTK_CONTAINER(button), image);
+        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0);
+        g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(save_variable_cb), popup);
+        gtk_widget_show(image);
+        gtk_widget_show(button);
+
+        button = gtk_button_new();
+        g_object_set_data(G_OBJECT(button), "variable_name", g_strdup(name));
+        image = gtk_image_new_from_icon_name("edit-delete", GTK_ICON_SIZE_BUTTON);
+        gtk_container_add(GTK_CONTAINER(button), image);
+        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0);
+        g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(delete_variable_cb), popup);
+        gtk_widget_show(image);
+        gtk_widget_show(button);
+    }
+
+    return hbox;
+}
+
+static void
+math_variable_popup_set_property(GObject      *object,
+                                 guint         prop_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
+{
+    MathVariablePopup *self;
+    gchar **names;
+    int i;
+    GtkWidget *entry, *image;
+
+    self = MATH_VARIABLE_POPUP(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        self->priv->equation = g_value_get_object(value);
+
+        names = math_variables_get_names(math_equation_get_variables(self->priv->equation));
+        for (i = 0; names[i]; i++) {
+            MPNumber *aux;
+
+            aux = math_variables_get(math_equation_get_variables(self->priv->equation), names[i]);
+            entry = make_variable_entry(self, names[i], aux, TRUE);
+            gtk_widget_show(entry);
+            gtk_box_pack_start(GTK_BOX(self->priv->vbox), entry, FALSE, TRUE, 0);
+        }
+        g_strfreev(names);
+
+        entry = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
+        gtk_widget_show(entry);
+
+        // TODO: Show greyed "variable name" text to give user a hint how to use
+        self->priv->variable_name_entry = gtk_entry_new();
+        g_signal_connect(G_OBJECT(self->priv->variable_name_entry), "key-press-event", G_CALLBACK(variable_name_key_press_cb), self);
+        g_signal_connect(G_OBJECT(self->priv->variable_name_entry), "changed", G_CALLBACK(variable_name_changed_cb), self);
+        g_signal_connect(G_OBJECT(self->priv->variable_name_entry), "activate", G_CALLBACK(add_variable_cb), self);
+        gtk_box_pack_start(GTK_BOX(entry), self->priv->variable_name_entry, TRUE, TRUE, 0);
+        gtk_widget_show(self->priv->variable_name_entry);
+
+        self->priv->add_variable_button = gtk_button_new();
+        gtk_widget_set_sensitive(self->priv->add_variable_button, FALSE);
+        g_signal_connect(G_OBJECT(self->priv->add_variable_button), "clicked", G_CALLBACK(add_variable_cb), self);
+        image = gtk_image_new_from_icon_name("list-add", GTK_ICON_SIZE_BUTTON);
+        gtk_container_add(GTK_CONTAINER(self->priv->add_variable_button), image);
+        gtk_box_pack_start(GTK_BOX(entry), self->priv->add_variable_button, FALSE, TRUE, 0);
+        gtk_widget_show(image);
+        gtk_widget_show(self->priv->add_variable_button);
+        gtk_box_pack_end(GTK_BOX(self->priv->vbox), entry, FALSE, TRUE, 0);
+
+        entry = make_variable_entry(self, "rand", NULL, FALSE);
+        gtk_widget_show(entry);
+        gtk_box_pack_end(GTK_BOX(self->priv->vbox), entry, FALSE, TRUE, 0);
+
+        entry = make_variable_entry(self, "ans", math_equation_get_answer(self->priv->equation), FALSE);
+        gtk_widget_show(entry);
+        gtk_box_pack_end(GTK_BOX(self->priv->vbox), entry, FALSE, TRUE, 0);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_variable_popup_get_property(GObject    *object,
+                                 guint       prop_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+    MathVariablePopup *self;
+
+    self = MATH_VARIABLE_POPUP(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        g_value_set_object(value, self->priv->equation);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_variable_popup_class_init(MathVariablePopupClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    object_class->get_property = math_variable_popup_get_property;
+    object_class->set_property = math_variable_popup_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_EQUATION,
+                                    g_param_spec_object("equation",
+                                                        "equation",
+                                                        "Equation being controlled",
+                                                        math_equation_get_type(),
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+math_variable_popup_init(MathVariablePopup *popup)
+{
+    popup->priv = math_variable_popup_get_instance_private (popup);
+
+    gtk_window_set_decorated(GTK_WINDOW(popup), FALSE);
+    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(popup), TRUE);
+
+    gtk_container_set_border_width(GTK_CONTAINER(popup), 6);
+
+    /* Destroy this window when it loses focus */
+    g_signal_connect(G_OBJECT(popup), "focus-out-event", G_CALLBACK(variable_focus_out_event_cb), popup);
+
+    popup->priv->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
+    gtk_box_set_homogeneous(GTK_BOX(popup->priv->vbox), TRUE);
+    gtk_container_add(GTK_CONTAINER(popup), popup->priv->vbox);
+    gtk_widget_show(popup->priv->vbox);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/35.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/35.html new file mode 100644 index 0000000..6f611ab --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/35.html @@ -0,0 +1,583 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-variables.h"
+#include "mp-serializer.h"
+
+struct MathVariablesPrivate
+{
+    gchar *file_name;
+    GHashTable *registers;
+    MpSerializer *serializer;
+};
+
+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)
+{
+    FILE *f;
+    char line[1024];
+
+    f = fopen(variables->priv->file_name, "r");
+    if (!f)
+        return;
+
+    g_hash_table_remove_all(variables->priv->registers);
+
+    while (fgets(line, 1024, f) != NULL)
+    {
+        char *name, *value;
+        MPNumber *t;
+
+        value = strchr(line, '=');
+        if (!value)
+            continue;
+        *value = '\0';
+        value = value + 1;
+
+        name = g_strstrip(line);
+        value = g_strstrip(value);
+
+        t = g_malloc(sizeof(MPNumber));
+        *t = mp_new();
+        if (mp_set_from_string(value, 10, t) == 0)
+            g_hash_table_insert(variables->priv->registers, g_strdup(name), t);
+        else
+        {
+            mp_clear(t);
+            g_free(t);
+        }
+    }
+    fclose(f);
+}
+
+static void
+registers_save(MathVariables *variables)
+{
+    gchar *dir;
+    FILE *f;
+    GHashTableIter iter;
+    gpointer key, val;
+
+    dir = g_path_get_dirname(variables->priv->file_name);
+    g_mkdir_with_parents(dir, 0700);
+    g_free(dir);
+
+    f = fopen(variables->priv->file_name, "w");
+    if (!f)
+        return;
+
+    g_hash_table_iter_init(&iter, variables->priv->registers);
+    while (g_hash_table_iter_next(&iter, &key, &val))
+    {
+        gchar *name = key;<--- Variable 'name' can be declared as pointer to const
+        MPNumber *value = val;<--- Variable 'value' can be declared as pointer to const
+        char *number;
+
+        number = mp_serializer_to_string(variables->priv->serializer, value);
+        fprintf(f, "%s=%s\n", name, number);
+        g_free(number);
+    }
+    fclose(f);
+}
+
+// FIXME: Sort
+gchar **
+math_variables_get_names(MathVariables *variables)
+{
+    GHashTableIter iter;
+    gpointer key;
+    gint i = 0;
+    gchar **names;
+
+    g_return_val_if_fail(variables != NULL, NULL);
+
+    names = g_malloc0(sizeof(gchar *) * (g_hash_table_size(variables->priv->registers) + 1));
+
+    g_hash_table_iter_init(&iter, variables->priv->registers);
+    while (g_hash_table_iter_next(&iter, &key, NULL))
+    {
+        gchar *name = key;
+        names[i] = g_strdup(name);
+        i++;
+    }
+    names[i] = NULL;
+
+    return names;
+}
+
+void
+math_variables_set(MathVariables *variables, const char *name, const MPNumber *value)
+{
+    MPNumber *t;
+
+    g_return_if_fail(variables != NULL);
+    g_return_if_fail(name != NULL);
+    g_return_if_fail(value != NULL);
+
+    t = g_malloc(sizeof(MPNumber));
+    *t = mp_new();
+    mp_set_from_mp(value, t);
+    g_hash_table_insert(variables->priv->registers, g_strdup(name), t);
+    registers_save(variables);
+}
+
+MPNumber *
+math_variables_get(MathVariables *variables, const char *name)
+{
+    g_return_val_if_fail(variables != NULL, NULL);
+    g_return_val_if_fail(name != NULL, NULL);
+    return g_hash_table_lookup(variables->priv->registers, name);
+}
+
+void
+math_variables_delete(MathVariables *variables, const char *name)
+{
+    g_return_if_fail(variables != NULL);
+    g_return_if_fail(name != NULL);
+    g_hash_table_remove(variables->priv->registers, name);
+    registers_save(variables);
+}
+
+static void
+math_variables_class_init (MathVariablesClass *klass)
+{
+}
+
+static void
+math_variables_init(MathVariables *variables)
+{
+    variables->priv = math_variables_get_instance_private (variables);
+    variables->priv->registers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+    variables->priv->file_name = g_build_filename(g_get_user_data_dir(), "mate-calc", "registers", NULL);
+    variables->priv->serializer = mp_serializer_new(MP_DISPLAY_FORMAT_SCIENTIFIC, 10, 50);
+    mp_serializer_set_radix(variables->priv->serializer, '.');
+    registers_load(variables);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/36.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/36.html new file mode 100644 index 0000000..1a443d4 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/36.html @@ -0,0 +1,1681 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkkeysyms.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "math-window.h"
+#include "math-history.h"
+#include "utility.h"
+
+// gtk3 hack
+	#ifndef GDK_KEY_F1
+		#define GDK_KEY_F1 GDK_F1
+	#endif
+
+	#ifndef GDK_KEY_W
+		#define GDK_KEY_W GDK_w
+	#endif
+
+	#ifndef GDK_KEY_Z
+		#define GDK_KEY_Z GDK_z
+	#endif
+
+enum {
+    PROP_0,
+    PROP_EQUATION,
+    PROP_SHOW_HISTORY
+};
+
+struct MathWindowPrivate
+{
+    GtkWidget *menu_bar;
+    MathEquation *equation;
+    MathDisplay *display;
+    MathHistory *history;
+    MathButtons *buttons;
+    MathPreferencesDialog *preferences_dialog;
+    gboolean right_aligned;
+    gboolean show_history;
+    GtkWidget *mode_basic_menu_item;
+    GtkWidget *mode_advanced_menu_item;
+    GtkWidget *mode_financial_menu_item;
+    GtkWidget *mode_programming_menu_item;
+    GtkWidget *view_history_menu_item;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MathWindow, math_window, GTK_TYPE_WINDOW);
+
+enum
+{
+    QUIT,
+    LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+MathWindow *
+math_window_new(MathEquation *equation)
+{
+    return g_object_new(math_window_get_type(),
+            "equation", equation, NULL);
+}
+
+GtkWidget *math_window_get_menu_bar(MathWindow *window)
+{
+    return window->priv->menu_bar;
+}
+
+MathEquation *
+math_window_get_equation(MathWindow *window)
+{
+    g_return_val_if_fail(window != NULL, NULL);
+    return window->priv->equation;
+}
+
+MathDisplay *
+math_window_get_display(MathWindow *window)
+{
+    g_return_val_if_fail(window != NULL, NULL);
+    return window->priv->display;
+}
+
+MathButtons *
+math_window_get_buttons(MathWindow *window)
+{
+    g_return_val_if_fail(window != NULL, NULL);
+    return window->priv->buttons;
+}
+
+gboolean
+math_window_get_show_history(MathWindow *window)
+{
+    g_return_val_if_fail(window != NULL, FALSE);
+    return window->priv->show_history;
+}
+
+void
+math_window_set_show_history(MathWindow *window, gboolean visible)
+{
+    g_return_if_fail(window != NULL);
+
+    if (math_window_get_show_history(window) == visible)
+        return;
+
+    window->priv->show_history = visible;
+
+    if (visible)
+    {
+        gtk_widget_show(GTK_WIDGET(window->priv->history));
+        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
+    }
+    else
+    {
+        gtk_widget_hide(GTK_WIDGET(window->priv->history));
+        gtk_window_resize(GTK_WINDOW(window), 1, 1); //FIXME: is there a better way to shrink window size to its children?
+        gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
+    }
+    g_object_notify(G_OBJECT(window), "show-history");
+}
+
+void
+math_window_critical_error(MathWindow *window, const gchar *title, const gchar *contents)
+{
+    GtkWidget *dialog;
+
+    g_return_if_fail(window != NULL);
+    g_return_if_fail(title != NULL);
+    g_return_if_fail(contents != NULL);
+
+    dialog = gtk_message_dialog_new(NULL, 0,
+                                    GTK_MESSAGE_ERROR,
+                                    GTK_BUTTONS_NONE,
+                                    "%s", title);
+    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+                                             "%s", contents);
+    gtk_dialog_add_buttons(GTK_DIALOG(dialog), "gtk-quit", GTK_RESPONSE_ACCEPT, NULL);
+
+    gtk_dialog_run(GTK_DIALOG(dialog));
+
+    g_signal_emit(window, signals[QUIT], 0);
+}
+
+static void mode_changed_cb(GtkWidget *menu, MathWindow *window)
+{
+    int mode;
+
+    if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)))
+    {
+        return;
+    }
+
+    mode = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "calcmode"));
+    math_buttons_set_mode(window->priv->buttons, mode);
+}
+
+static void history_check_toggled_cb(GtkWidget *menu, MathWindow *window)
+{
+    gboolean value;
+
+    value = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu));
+    math_window_set_show_history(window, value);
+}
+
+static void show_history_cb(MathWindow *window, GParamSpec *spec)
+{
+    GtkWidget *menu = window->priv->view_history_menu_item;
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu),
+                                   math_window_get_show_history(window));
+    g_settings_set_boolean(g_settings_var, "show-history", math_window_get_show_history(window));
+}
+
+static void clear_history_cb(GtkMenuItem *menu, MathWindow *window)
+{
+    math_history_clear(window->priv->history);
+}
+
+static void show_preferences_cb(GtkMenuItem *menu, MathWindow *window)
+{
+    if (!window->priv->preferences_dialog)
+    {
+        window->priv->preferences_dialog = math_preferences_dialog_new(window->priv->equation);
+        gtk_window_set_transient_for(GTK_WINDOW(window->priv->preferences_dialog), GTK_WINDOW(window));
+    }
+
+    gtk_window_present(GTK_WINDOW(window->priv->preferences_dialog));
+}
+
+static gboolean
+key_press_cb(MathWindow *window, GdkEventKey *event)
+{
+    gboolean result;
+    g_signal_emit_by_name(window->priv->display, "key-press-event", event, &result);
+
+    /* Keyboard navigation for history */
+    if ((event->state & GDK_MOD1_MASK) == GDK_MOD1_MASK && (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_Down))
+    {
+        switch (event->keyval)
+        {
+            case GDK_KEY_Up:
+                math_history_set_current(window->priv->history, -1);
+                break;
+            case GDK_KEY_Down:
+                math_history_set_current(window->priv->history, 1);
+                break;
+        }
+
+        MathHistoryEntry *entry = math_history_get_entry_at(window->priv->history, math_history_get_current(window->priv->history));
+        if (entry)
+        {
+            gchar *equation_string = math_history_entry_get_equation(entry);
+            math_equation_set(window->priv->equation, equation_string);
+            g_free(equation_string);
+        }
+        return TRUE;
+    }
+    else if (math_buttons_get_mode (window->priv->buttons) == PROGRAMMING && (event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) {
+        switch(event->keyval)
+        {
+        /* Binary */
+        case GDK_KEY_b:
+            math_equation_set_base (window->priv->equation, 2);
+            return TRUE;
+        /* Octal */
+        case GDK_KEY_o:
+            math_equation_set_base (window->priv->equation, 8);
+            return TRUE;
+        /* Decimal */
+        case GDK_KEY_d:
+            math_equation_set_base (window->priv->equation, 10);
+            return TRUE;
+        /* Hexdecimal */
+        case GDK_KEY_h:
+            math_equation_set_base (window->priv->equation, 16);
+            return TRUE;
+        }
+    }
+
+    return result;
+}
+
+static void delete_cb(MathWindow *window, GdkEvent *event)
+{
+    g_signal_emit(window, signals[QUIT], 0);
+}
+
+static void copy_cb(GtkWidget *widget, MathWindow *window)
+{
+    math_equation_copy(window->priv->equation);
+}
+
+static void paste_cb(GtkWidget *widget, MathWindow *window)
+{
+    math_equation_paste(window->priv->equation);
+}
+
+static void undo_cb(GtkWidget *widget, MathWindow *window)
+{
+    math_equation_undo(window->priv->equation);
+}
+
+static void redo_cb(GtkWidget *widget, MathWindow *window)
+{
+    math_equation_redo(window->priv->equation);
+}
+
+static void help_cb(GtkWidget *widget, MathWindow *window)
+{
+    GError *error = NULL;
+
+    gtk_show_uri_on_window(GTK_WINDOW(window),
+                           "help:mate-calc",
+                           gtk_get_current_event_time(),
+                           &error);
+
+    if (error != NULL)
+    {
+        GtkWidget *d;
+        /* Translators: Error message displayed when unable to launch help browser */
+        const char *message = _("Unable to open help file");
+
+        d = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message);
+        gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(d), "%s", error->message);
+        g_signal_connect(d, "response", G_CALLBACK(gtk_widget_destroy), NULL);
+        gtk_window_present(GTK_WINDOW (d));
+
+        g_error_free(error);
+    }
+}
+
+#define ABOUT_GROUP "About"
+#define EMAILIFY(string) (g_strdelimit ((string), "%", '@'))
+
+static void about_cb(GtkWidget* widget, MathWindow* window)
+{
+    const char* documenters[] = {
+        N_("Sun Microsystems"),
+        N_("MATE Documentation Team"),
+        NULL
+    };
+
+    /* The license this software is under (GPL2+) */
+    const char* license[] = {
+        N_("MATE Calculator 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 of the License, or "
+           "(at your option) any later version."),
+        N_("MATE Calculator 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."),
+        N_("You should have received a copy of the GNU General Public License "
+           "along with MATE Calculator; if not, write to the Free Software Foundation, Inc., "
+           "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
+    };
+
+    char *license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
+
+    GKeyFile *key_file;
+    GBytes *bytes;
+    const guint8 *data;
+    gsize data_len;
+    GError *error = NULL;
+    char **authors;
+    gsize n_authors = 0, i;
+    gchar *comments = NULL;
+
+    bytes = g_resources_lookup_data ("/org/mate/calculator/ui/mate-calc.about", G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
+    g_assert_no_error (error);
+
+    data = g_bytes_get_data (bytes, &data_len);
+    key_file = g_key_file_new ();
+    g_key_file_load_from_data (key_file, (const char *) data, data_len, 0, &error);
+    g_assert_no_error (error);
+
+    authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors", &n_authors, NULL);
+
+    g_key_file_free (key_file);
+    g_bytes_unref (bytes);
+
+    for (i = 0; i < n_authors; ++i)
+        authors[i] = EMAILIFY (authors[i]);
+
+    const char **p;
+
+    for (p = documenters; *p; ++p)
+        *p = _(*p);
+
+    comments = g_strdup_printf (_("Calculator with financial and scientific modes.\nUsing GNU MPFR %s and GNU MPC %s"),
+                                mpfr_get_version (), mpc_get_version ());
+
+    gtk_show_about_dialog(GTK_WINDOW(window),
+        "program-name", _("MATE Calculator"),
+        "version", VERSION,
+        "title", _("About MATE Calculator"),
+        "copyright", _("Copyright \xc2\xa9 1986–2010 The GCalctool authors\n"
+                       "Copyright \xc2\xa9 2011-2021 MATE developers"),
+        "license", license_trans,
+        "comments", comments,
+        "authors", authors,
+        "documenters", documenters,
+        "translator_credits", _("translator-credits"),
+        "wrap-license", TRUE,
+        "website", PACKAGE_URL,
+        "icon-name", "accessories-calculator",
+        "logo-icon-name", "accessories-calculator",
+        NULL);
+
+    g_free (comments);
+    g_strfreev (authors);
+    g_free (license_trans);
+}
+
+static void
+scroll_changed_cb(GtkAdjustment *adjustment, MathWindow *window)
+{
+    if (window->priv->right_aligned)
+        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)
+{
+    if (gtk_adjustment_get_value(adjustment) == gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment))
+        window->priv->right_aligned = TRUE;
+    else
+        window->priv->right_aligned = FALSE;
+}
+
+static void button_mode_changed_cb(MathButtons *buttons, GParamSpec *spec, MathWindow *window)
+{
+    GtkWidget *menu;
+
+    switch (math_buttons_get_mode(buttons))
+    {
+        default:
+        case BASIC:
+            menu = window->priv->mode_basic_menu_item;
+            break;
+        case ADVANCED:
+            menu = window->priv->mode_advanced_menu_item;
+            break;
+        case FINANCIAL:
+            menu = window->priv->mode_financial_menu_item;
+            break;
+        case PROGRAMMING:
+            menu = window->priv->mode_programming_menu_item;
+            break;
+    }
+
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu), TRUE);
+    g_settings_set_enum(g_settings_var, "button-mode", math_buttons_get_mode(buttons));
+}
+
+static GtkWidget *add_menu(GtkWidget *menu_bar, const gchar *name)
+{
+    GtkWidget *menu_item;
+    GtkWidget *menu;
+
+    menu_item = gtk_menu_item_new_with_mnemonic(name);
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), menu_item);
+    gtk_widget_show(menu_item);
+    menu = gtk_menu_new();
+    gtk_menu_set_reserve_toggle_size(GTK_MENU(menu),FALSE);
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu);
+
+    return menu;
+}
+
+static void
+update_history_cb (MathEquation *equation, char *equation_string, MPNumber *answer, MathWindow *window)
+{   /* Recieves signal emitted by a MathEquation object for updating history */
+    math_history_insert_entry (window->priv->history, equation_string, answer); /* Sends current equation string and answer for updating History-View */
+}
+
+static void
+history_set_serializer_cb(MathEquation *equation, MathWindow *window)
+{
+    MpSerializer *serializer = math_equation_get_serializer(equation);
+
+    math_history_set_serializer(window->priv->history, serializer);
+}
+
+static void quit_cb(GtkWidget* widget, MathWindow* window)
+{
+    g_signal_emit(window, signals[QUIT], 0);
+}
+
+static GtkWidget *add_menu_item(GtkWidget *menu, GtkWidget *menu_item, GCallback callback, gpointer callback_data)
+{
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
+    gtk_widget_show(menu_item);
+
+    if (callback)
+    {
+        g_signal_connect(G_OBJECT(menu_item), "activate", callback, callback_data);
+    }
+
+    return menu_item;
+}
+
+static GtkWidget *radio_menu_item_new(GSList **group, const gchar *name)
+{
+    GtkWidget *menu_item = gtk_radio_menu_item_new_with_mnemonic(*group, name);
+
+    *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menu_item));
+
+    return menu_item;
+}
+
+static GtkWidget *gtk_image_menu_item_new_from_icon (const gchar   *icon_name,
+                                                     const gchar   *label_name,
+                                                     GtkAccelGroup *accel_group)
+{
+    gchar *concat = g_strconcat (label_name, "     ", NULL);
+    GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+    GtkWidget *icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+    GtkWidget *label = gtk_accel_label_new (concat);
+    GtkWidget *menu_item = gtk_menu_item_new ();
+
+    g_free (concat);
+
+    gtk_container_add (GTK_CONTAINER (box), icon);
+
+    gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+
+    gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menu_item);
+
+    gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
+
+    gtk_container_add (GTK_CONTAINER (menu_item), box);
+
+    gtk_widget_show_all (menu_item);
+
+    return menu_item;
+}
+
+static void create_menu(MathWindow* window)
+{
+    GtkAccelGroup* accel_group;
+    GtkWidget* menu;
+    GtkWidget* menu_item;
+    GSList* group = NULL;
+
+    accel_group = gtk_accel_group_new();
+    gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
+
+    /* Calculator menu */
+    #define CALCULATOR_MENU_LABEL _("_Calculator")
+    /* Mode menu */
+    #define MODE_MENU_LABEL _("_Mode")
+    /* View menu */
+    #define VIEW_MENU_LABEL _("_View")
+    /* Help menu label */
+    #define HELP_MENU_LABEL _("_Help")
+    /* Basic menu label */
+    #define MODE_BASIC_LABEL _("_Basic")
+    /* Advanced menu label */
+    #define MODE_ADVANCED_LABEL _("_Advanced")
+    /* Financial menu label */
+    #define MODE_FINANCIAL_LABEL _("_Financial")
+    /* Programming menu label */
+    #define MODE_PROGRAMMING_LABEL _("_Programming")
+    /* History menu label */
+    #define VIEW_HISTORY_LABEL _("_History")
+    /* Help>Contents menu label */
+    #define HELP_CONTENTS_LABEL _("_Contents")
+
+    menu = add_menu(window->priv->menu_bar, CALCULATOR_MENU_LABEL);
+    menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_icon("edit-copy",_("_Copy"), accel_group), G_CALLBACK(copy_cb), window);
+    gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_KEY_C, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+    menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_icon("edit-paste",_("_Paste"), accel_group), G_CALLBACK(paste_cb), window);
+    gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_KEY_V, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+    menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_icon("edit-undo",_("_Undo"), accel_group), G_CALLBACK(undo_cb), window);
+    gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_KEY_Z, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+    menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_icon("edit-redo",_("_Redo"), accel_group), G_CALLBACK(redo_cb), window);
+    gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_KEY_Z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+    menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_icon("edit-clear",_("_Clear History"), accel_group), G_CALLBACK(clear_history_cb), window);
+    gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_KEY_Delete, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+    add_menu_item(menu, gtk_separator_menu_item_new(), NULL, NULL);
+    add_menu_item(menu, gtk_image_menu_item_new_from_icon("preferences-desktop",_("_Preferences"), accel_group), G_CALLBACK(show_preferences_cb), window);
+    add_menu_item(menu, gtk_separator_menu_item_new(), NULL, NULL);
+    menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_icon("application-exit",_("_Quit"), accel_group), G_CALLBACK(quit_cb), window);
+    gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_KEY_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+    gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_KEY_W, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+
+    menu = add_menu(window->priv->menu_bar, MODE_MENU_LABEL);
+    window->priv->mode_basic_menu_item = add_menu_item(menu, radio_menu_item_new(&group, MODE_BASIC_LABEL), G_CALLBACK(mode_changed_cb), window);
+    g_object_set_data(G_OBJECT(window->priv->mode_basic_menu_item), "calcmode", GINT_TO_POINTER(BASIC));
+    window->priv->mode_advanced_menu_item = add_menu_item(menu, radio_menu_item_new(&group, MODE_ADVANCED_LABEL), G_CALLBACK(mode_changed_cb), window);
+    g_object_set_data(G_OBJECT(window->priv->mode_advanced_menu_item), "calcmode", GINT_TO_POINTER(ADVANCED));
+    window->priv->mode_financial_menu_item = add_menu_item(menu, radio_menu_item_new(&group, MODE_FINANCIAL_LABEL), G_CALLBACK(mode_changed_cb), window);
+    g_object_set_data(G_OBJECT(window->priv->mode_financial_menu_item), "calcmode", GINT_TO_POINTER(FINANCIAL));
+    window->priv->mode_programming_menu_item = add_menu_item(menu, radio_menu_item_new(&group, MODE_PROGRAMMING_LABEL), G_CALLBACK(mode_changed_cb), window);
+    g_object_set_data(G_OBJECT(window->priv->mode_programming_menu_item), "calcmode", GINT_TO_POINTER(PROGRAMMING));
+
+    menu = add_menu(window->priv->menu_bar, VIEW_MENU_LABEL);
+    window->priv->view_history_menu_item = add_menu_item(menu, gtk_check_menu_item_new_with_mnemonic(VIEW_HISTORY_LABEL), G_CALLBACK(history_check_toggled_cb), window);
+    gtk_widget_add_accelerator(window->priv->view_history_menu_item, "activate", accel_group, GDK_KEY_H, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+
+    menu = add_menu(window->priv->menu_bar, HELP_MENU_LABEL);
+    menu_item = add_menu_item(menu, gtk_image_menu_item_new_from_icon("help-browser", HELP_CONTENTS_LABEL, accel_group), G_CALLBACK(help_cb), window);
+    gtk_widget_add_accelerator(menu_item, "activate", accel_group, GDK_KEY_F1, 0, GTK_ACCEL_VISIBLE);
+    add_menu_item(menu, gtk_image_menu_item_new_from_icon("help-about",_("_About"), accel_group), G_CALLBACK(about_cb), window);
+}
+
+static void
+create_gui(MathWindow *window)
+{
+    GtkWidget *main_vbox, *vbox;
+    GtkWidget *scrolled_window;
+
+    main_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+    gtk_container_add(GTK_CONTAINER(window), main_vbox);
+    gtk_widget_show(main_vbox);
+
+    window->priv->menu_bar = gtk_menu_bar_new();
+    gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->menu_bar, FALSE, FALSE, 0);
+    gtk_widget_show(window->priv->menu_bar);
+
+    create_menu(window);
+
+    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
+    gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
+    gtk_box_pack_start(GTK_BOX(main_vbox), vbox, TRUE, TRUE, 0);
+    gtk_widget_show(vbox);
+
+    window->priv->history = math_history_new(window->priv->equation);
+    g_signal_connect(window->priv->equation, "history", G_CALLBACK(update_history_cb), window);
+    g_signal_connect(window, "notify::show-history", G_CALLBACK(show_history_cb), NULL);
+    show_history_cb(window, NULL);
+    g_signal_connect(window->priv->equation, "display-changed", G_CALLBACK(history_set_serializer_cb), window);
+    history_set_serializer_cb(window->priv->equation, window);
+    gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(window->priv->history), TRUE, TRUE, 0);
+
+    scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN);
+    gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scrolled_window), FALSE, FALSE, 0);
+    g_signal_connect(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window)), "changed", G_CALLBACK(scroll_changed_cb), window);
+    g_signal_connect(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window)), "value-changed", G_CALLBACK(scroll_value_changed_cb), window);
+    window->priv->right_aligned = TRUE;
+    gtk_widget_show(scrolled_window);
+
+    window->priv->display = math_display_new_with_equation(window->priv->equation);
+    gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(window->priv->display));
+    gtk_widget_show(GTK_WIDGET(window->priv->display));
+
+    window->priv->buttons = math_buttons_new(window->priv->equation);
+    g_signal_connect(window->priv->buttons, "notify::mode", G_CALLBACK(button_mode_changed_cb), window);
+    button_mode_changed_cb(window->priv->buttons, NULL, window);
+    gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(window->priv->buttons), FALSE, FALSE, 0);
+    gtk_widget_show(GTK_WIDGET(window->priv->buttons));
+}
+
+static void
+math_window_set_property(GObject      *object,
+                         guint         prop_id,
+                         const GValue *value,
+                         GParamSpec   *pspec)
+{
+    MathWindow *self;
+
+    self = MATH_WINDOW(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        self->priv->equation = g_value_get_object(value);
+        create_gui(self);
+        break;
+    case PROP_SHOW_HISTORY:
+        math_window_set_show_history(self, g_value_get_boolean(value));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_window_get_property(GObject    *object,
+                         guint       prop_id,
+                         GValue     *value,
+                         GParamSpec *pspec)
+{
+    MathWindow *self;
+
+    self = MATH_WINDOW(object);
+
+    switch (prop_id) {
+    case PROP_EQUATION:
+        g_value_set_object(value, self->priv->equation);
+        break;
+    case PROP_SHOW_HISTORY:
+        g_value_set_boolean(value, math_window_get_show_history(self));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+math_window_class_init(MathWindowClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    object_class->get_property = math_window_get_property;
+    object_class->set_property = math_window_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_EQUATION,
+                                    g_param_spec_object("equation",
+                                                        "equation",
+                                                        "Equation being calculated",
+                                                        math_equation_get_type(),
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+    g_object_class_install_property(object_class,
+                                    PROP_EQUATION,
+                                    g_param_spec_boolean("show-history",
+                                                         "show-history",
+                                                         "Show-history",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE));
+
+    signals[QUIT] = g_signal_new("quit",
+                                 G_TYPE_FROM_CLASS (klass),
+                                 G_SIGNAL_RUN_LAST,
+                                 G_STRUCT_OFFSET (MathWindowClass, quit),
+                                 NULL, NULL,
+                                 g_cclosure_marshal_VOID__VOID,
+                                 G_TYPE_NONE, 0);
+}
+
+static void
+math_window_init(MathWindow *window)
+{
+    window->priv = math_window_get_instance_private (window);
+    gtk_window_set_title(GTK_WINDOW(window),
+                         /* Title of main window */
+                         _("Calculator"));
+    gtk_window_set_icon_name(GTK_WINDOW(window), "accessories-calculator");
+    gtk_window_set_role(GTK_WINDOW(window), "mate-calc");
+    gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
+    g_signal_connect_after(G_OBJECT(window), "key-press-event", G_CALLBACK(key_press_cb), NULL);
+    g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(delete_cb), NULL);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/37.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/37.html new file mode 100644 index 0000000..9d03500 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/37.html @@ -0,0 +1,639 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp.h"
+#include "mp-serializer.h"
+
+// FIXME: Make dynamic
+#define MAX_DIGITS 1000
+
+static char digits[] = "0123456789ABCDEF";
+
+static int hex_to_int(char digit)
+{
+    if (digit >= '0' && digit <= '9')
+        return digit - '0';
+    if (digit >= 'A' && digit <= 'F')
+        return digit - 'A' + 10;
+    if (digit >= 'a' && digit <= 'f')
+        return digit - 'a' + 10;
+    return 0;
+}
+
+static gchar *
+to_hex_string(const MPNumber *x)
+{
+    MpSerializer *serializer;
+    gchar *result;
+
+    serializer = mp_serializer_new(MP_DISPLAY_FORMAT_FIXED, 16, 0);
+    result = mp_serializer_to_string(serializer, x);
+    g_object_unref(serializer);
+
+    return result;
+}
+
+static void
+mp_bitwise(const MPNumber *x, const MPNumber *y, int (*bitwise_operator)(int, int), MPNumber *z, int wordlen)
+{
+    char *text1, *text2, text_out[MAX_DIGITS], text_out2[MAX_DIGITS];
+    int offset1, offset2, offset_out;
+
+    text1 = to_hex_string(x);
+    text2 = to_hex_string(y);
+    offset1 = strlen(text1) - 1;
+    offset2 = strlen(text2) - 1;
+    offset_out = wordlen / 4 - 1;
+    if (offset_out <= 0) {
+        offset_out = offset1 > offset2 ? offset1 : offset2;
+    }
+    if (offset_out > 0 && (offset_out < offset1 || offset_out < offset2)) {
+        g_free(text1);
+        g_free(text2);
+        mp_set_from_integer(0, z);
+        mperr("Overflow. Try a bigger word size");
+        return;
+    }
+
+    /* Perform bitwise operator on each character from right to left */
+    for (text_out[offset_out+1] = '\0'; offset_out >= 0; offset_out--) {<--- Uninitialized variable: text_out
+        int v1 = 0, v2 = 0;
+
+        if (offset1 >= 0) {
+            v1 = hex_to_int(text1[offset1]);
+            offset1--;
+        }
+        if (offset2 >= 0) {
+            v2 = hex_to_int(text2[offset2]);
+            offset2--;
+        }
+        text_out[offset_out] = digits[bitwise_operator(v1, v2)];
+    }
+
+    snprintf(text_out2, MAX_DIGITS, "%s", text_out);
+    mp_set_from_string(text_out2, 16, z);
+    g_free(text1);
+    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)
+{
+    bool is_overflow;
+    MPNumber tmp1 = mp_new();
+    MPNumber tmp2 = mp_new();
+    mp_set_from_integer(2, &tmp1);
+    mp_xpowy_integer(&tmp1, wordlen, &tmp2);
+    is_overflow = mp_is_greater_than (&tmp2, x);
+    mp_clear(&tmp1);
+    mp_clear(&tmp2);
+    return is_overflow;
+}
+
+void
+mp_and(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    if (!mp_is_positive_integer(x) || !mp_is_positive_integer(y))
+    {
+        /* Translators: Error displayed when boolean AND attempted on non-integer values */
+        mperr(_("Boolean AND is only defined for positive integers"));
+    }
+
+    mp_bitwise(x, y, mp_bitwise_and, z, 0);
+}
+
+void
+mp_or(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    if (!mp_is_positive_integer(x) || !mp_is_positive_integer(y))
+    {
+        /* Translators: Error displayed when boolean OR attempted on non-integer values */
+        mperr(_("Boolean OR is only defined for positive integers"));
+    }
+
+    mp_bitwise(x, y, mp_bitwise_or, z, 0);
+}
+
+void
+mp_xor(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    if (!mp_is_positive_integer(x) || !mp_is_positive_integer(y))
+    {
+        /* Translators: Error displayed when boolean XOR attempted on non-integer values */
+        mperr(_("Boolean XOR is only defined for positive integers"));
+    }
+
+    mp_bitwise(x, y, mp_bitwise_xor, z, 0);
+}
+
+void
+mp_not(const MPNumber *x, int wordlen, MPNumber *z)
+{
+    MPNumber temp = mp_new();
+
+    mp_set_from_integer(0, &temp);
+
+    if (!mp_is_positive_integer(x))
+    {
+        /* Translators: Error displayed when boolean NOT attempted on non-integer values */
+        mperr(_("Boolean NOT is only defined for positive integers"));
+    }
+
+    mp_bitwise(x, &temp, mp_bitwise_not, z, wordlen);
+    mp_clear(&temp);
+}
+
+void
+mp_shift(const MPNumber *x, int count, MPNumber *z)
+{
+    if (!mp_is_integer(x)) {
+        /* Translators: Error displayed when bit shift attempted on non-integer values */
+        mperr(_("Shift is only possible on integer values"));
+        return;
+    }
+
+    MPNumber multiplier = mp_new();
+    mp_set_from_integer(1, &multiplier);
+    if (count >= 0) {
+        for (int i = 0; i < count; i++)
+            mp_multiply_integer(&multiplier, 2, &multiplier);
+        mp_multiply(x, &multiplier, z);
+    }
+    else {
+        for (int i = 0; i < -count; i++)
+            mp_multiply_integer(&multiplier, 2, &multiplier);
+        mp_divide(x, &multiplier, z);
+        mp_floor(z, z);
+    }
+    mp_clear(&multiplier);
+}
+
+void
+mp_ones_complement(const MPNumber *x, int wordlen, MPNumber *z)
+{
+    MPNumber t = mp_new();
+    mp_set_from_integer(0, &t);
+    mp_bitwise(x, &t, mp_bitwise_xor, z, wordlen);
+    mp_not(z, wordlen, z);
+    mp_clear(&t);
+}
+
+void
+mp_twos_complement(const MPNumber *x, int wordlen, MPNumber *z)
+{
+    mp_ones_complement (x, wordlen, z);
+    mp_add_integer (z, 1, z);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/38.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/38.html new file mode 100644 index 0000000..0047ef2 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/38.html @@ -0,0 +1,933 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <ctype.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <langinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp.h"
+
+void
+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)
+{
+    if (denominator < 0) {
+        numerator = -numerator;
+        denominator = -denominator;
+    }
+
+    mp_set_from_integer(numerator, z);
+    if (denominator != 1)
+        mp_divide_integer(z, denominator, z);
+}
+
+void
+mp_set_from_polar(const MPNumber *r, MPAngleUnit unit, const MPNumber *theta, MPNumber *z)
+{
+    MPNumber x = mp_new();
+    MPNumber y = mp_new();
+
+    mp_cos(theta, unit, &x);
+    mp_multiply(&x, r, &x);
+    mp_sin(theta, unit, &y);
+    mp_multiply(&y, r, &y);
+    mp_set_from_complex(&x, &y, z);
+
+    mp_clear(&x);
+    mp_clear(&y);
+}
+
+void
+mp_set_from_complex(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    mpc_set_fr_fr(z->num, mpc_realref(x->num), mpc_realref(y->num), MPC_RNDNN);
+}
+
+void
+mp_set_from_random(MPNumber *z)
+{
+    mp_set_from_double(drand48(), z);
+}
+
+long
+mp_to_integer(const MPNumber *x)
+{
+    return mpfr_get_si(mpc_realref(x->num), MPFR_RNDN);
+}
+
+ulong
+mp_to_unsigned_integer(const MPNumber *x)
+{
+    return mpfr_get_ui(mpc_realref(x->num), MPFR_RNDN);
+}
+
+float
+mp_to_float(const MPNumber *x)
+{
+    return mpfr_get_flt(mpc_realref(x->num), MPFR_RNDN);
+}
+
+double
+mp_to_double(const MPNumber *x)
+{
+    return mpfr_get_d(mpc_realref(x->num), MPFR_RNDN);
+}
+
+static int
+char_val(char **c, int base)
+{
+    int i, j, value;
+    size_t offset;
+    const char *digits[][10] = {{"٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"},
+                                {"〇", "〡", "〢", "〣", "〤", "〥", "〦", "〧", "〨", "〩"},
+                                {"۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"},
+                                {"߀", "߁", "߂", "߃", "߄", "߅", "߆", "߇", "߈", "߉"},
+                                {"०", "१", "२", "३", "४", "५", "६", "७", "८", "९"},
+                                {"০", "১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯"},
+                                {"੦", "੧", "੨", "੩", "੪", "੫", "੬", "੭", "੮", "੯"},
+                                {"૦", "૧", "૨", "૩", "૪", "૫", "૬", "૭", "૮", "૯"},
+                                {"୦", "୧", "୨", "୩", "୪", "୫", "୬", "୭", "୮", "୯"},
+                                {"௦", "௧", "௨", "௩", "௪", "௫", "௬", "௭", "௮", "௯"},
+                                {"౦", "౧", "౨", "౩", "౪", "౫", "౬", "౭", "౮", "౯"},
+                                {"೦", "೧", "೨", "೩", "೪", "೫", "೬", "೭", "೮", "೯"},
+                                {"൦", "൧", "൨", "൩", "൪", "൫", "൬", "൭", "൮", "൯"},
+                                {"๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙"},
+                                {"໐", "໑", "໒", "໓", "໔", "໕", "໖", "໗", "໘", "໙"},
+                                {"༠", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩"},
+                                {"၀", "၁", "၂", "၃", "၄", "၅", "၆", "၇", "၈", "၉"},
+                                {"႐", "႑", "႒", "႓", "႔", "႕", "႖", "႗", "႘", "႙"},
+                                {"០", "១", "២", "៣", "៤", "៥", "៦", "៧", "៨", "៩"},
+                                {"᠐", "᠑", "᠒", "᠓", "᠔", "᠕", "᠖", "᠗", "᠘", "᠙"},
+                                {"᥆", "᥇", "᥈", "᥉", "᥊", "᥋", "᥌", "᥍", "᥎", "᥏"},
+                                {"᧐", "᧑", "᧒", "᧓", "᧔", "᧕", "᧖", "᧗", "᧘", "᧙"},
+                                {"᭐", "᭑", "᭒", "᭓", "᭔", "᭕", "᭖", "᭗", "᭘", "᭙"},
+                                {"᮰", "᮱", "᮲", "᮳", "᮴", "᮵", "᮶", "᮷", "᮸", "᮹"},
+                                {"᱀", "᱁", "᱂", "᱃", "᱄", "᱅", "᱆", "᱇", "᱈", "᱉"},
+                                {"᱐", "᱑", "᱒", "᱓", "᱔", "᱕", "᱖", "᱗", "᱘", "᱙"},
+                                {"꘠", "꘡", "꘢", "꘣", "꘤", "꘥", "꘦", "꘧", "꘨", "꘩"},
+                                {"꣐", "꣑", "꣒", "꣓", "꣔", "꣕", "꣖", "꣗", "꣘", "꣙"},
+                                {"꤀", "꤁", "꤂", "꤃", "꤄", "꤅", "꤆", "꤇", "꤈", "꤉"},
+                                {"꩐", "꩑", "꩒", "꩓", "꩔", "꩕", "꩖", "꩗", "꩘", "꩙"},
+                                {"𐒠", "𐒡", "𐒢", "𐒣", "𐒤", "𐒥", "𐒦", "𐒧", "𐒨", "𐒩"},
+                                {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}};
+
+    if (**c >= '0' && **c <= '9') {
+        value = **c - '0';
+        offset = 1;
+    } else if (**c >= 'a' && **c <= 'f') {
+        value = **c - 'a' + 10;
+        offset = 1;
+    } else if (**c >= 'A' && **c <= 'F') {
+        value = **c - 'A' + 10;
+        offset = 1;
+    } else {
+        for (i = 0; digits[i][0]; i++) {<--- Assuming condition is false
+            for (j = 0; j < 10; j++) {<--- After for loop, j has value 10
+                if (strncmp(*c, digits[i][j], strlen(digits[i][j])) == 0)
+                    break;
+            }
+            if (j != 10)
+                break;
+        }
+        if (digits[i][0] == NULL)
+            return -1;
+        value = j;
+        offset = strlen(digits[i][j]);<--- Array index out of bounds
+    }
+    if (value >= base)
+       return -1;
+
+    *c += offset;
+
+    return value;
+}
+
+static int
+ends_with(const char *start, const char *end, const char *word)
+{
+    size_t word_len = strlen(word);
+
+    if (word_len > end - start)
+        return 0;
+
+    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)
+{
+    int degrees = 0, minutes = 0;
+    char seconds[length+1];
+    int n_matched;
+
+    seconds[0] = '\0';
+    n_matched = sscanf(str, "%d°%d'%s\"", &degrees, &minutes, seconds);
+
+    if (n_matched < 1)
+        return true;
+    MPNumber t = mp_new();
+    mp_set_from_integer(degrees, z);
+    if (n_matched > 1) {
+        mp_set_from_integer(minutes, &t);
+        mp_divide_integer(&t, 60, &t);
+        mp_add(z, &t, z);
+    }
+    if (n_matched > 2) {
+        mp_set_from_string(seconds, 10, &t);
+        mp_divide_integer(&t, 3600, &t);
+        mp_add(z, &t, z);
+    }
+    mp_clear(&t);
+
+    return false;
+}
+
+bool
+mp_set_from_string(const char *str, int default_base, MPNumber *z)
+{
+    int i, base, negate = 0, multiplier = 0, base_multiplier = 1;<--- 'multiplier' is assigned value '0' here.
+    const char *c, *end;
+    gboolean has_fraction = FALSE;
+
+    const char *base_digits[]   = {"₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉", NULL};
+    const char *fractions[]     = {"½", "⅓", "⅔", "¼", "¾", "⅕", "⅖", "⅗", "⅘", "⅙", "⅚", "⅛", "⅜", "⅝", "⅞", NULL};
+    int numerators[]            = { 1,   1,   2,   1,   3,   1,   2,   3,   4,   1,   5,   1,   3,   5,   7};<--- Variable 'numerators' can be declared as const array
+    int denominators[]          = { 2,   3,   3,   4,   4,   5,   5,   5,   5,   6,   6,   8,   8,   8,   8};<--- Variable 'denominators' can be declared as const array
+
+    if (strstr(str, "°"))
+        return set_from_sexagesimal(str, strlen(str), z);
+
+    /* Find the base */
+    end = str;
+    while (*end != '\0')
+        end++;
+    base = 0;
+    while (1) {
+        for (i = 0; base_digits[i] != NULL; i++) {
+            if (ends_with(str, end, base_digits[i])) {
+                base += i * base_multiplier;
+                end -= strlen(base_digits[i]);
+                base_multiplier *= 10;
+                break;
+            }
+        }
+        if (base_digits[i] == NULL)
+            break;
+    }
+    if (base_multiplier == 1)
+        base = default_base;
+
+    /* Check if this has a sign */
+    c = str;
+    if (*c == '+') {
+        c++;
+    } else if (*c == '-') {
+        negate = 1;
+        c++;
+    } else if (strncmp(c, "−", strlen("−")) == 0) {
+        negate = 1;
+        c += strlen("−");
+    }
+
+    /* Convert integer part */
+    mp_set_from_integer(0, z);
+    while ((i = char_val((char **)&c, base)) >= 0) {
+        if (i > base)
+            return true;
+        mp_multiply_integer(z, base, z);
+        mp_add_integer(z, i, z);
+    }
+
+    /* Look for fraction characters, e.g. ⅚ */
+    for (i = 0; fractions[i] != NULL; i++) {
+        if (ends_with(str, end, fractions[i])) {
+            end -= strlen(fractions[i]);
+            break;
+        }
+    }
+    if (fractions[i] != NULL) {
+        MPNumber fraction = mp_new();
+        mp_set_from_fraction(numerators[i], denominators[i], &fraction);
+        mp_add(z, &fraction, z);
+        mp_clear(&fraction);
+    }
+
+    if (*c == '.') {
+        has_fraction = TRUE;
+        c++;
+    }
+
+    /* Convert fractional part */
+    if (has_fraction) {
+        MPNumber numerator = mp_new();
+        MPNumber denominator = mp_new();
+
+        mp_set_from_integer(0, &numerator);
+        mp_set_from_integer(1, &denominator);
+        while ((i = char_val((char **)&c, base)) >= 0) {
+            mp_multiply_integer(&denominator, base, &denominator);
+            mp_multiply_integer(&numerator, base, &numerator);
+            mp_add_integer(&numerator, i, &numerator);
+        }
+        mp_divide(&numerator, &denominator, &numerator);
+        mp_add(z, &numerator, z);
+        mp_clear(&numerator);
+        mp_clear(&denominator);
+    }
+
+    if (c != end) {
+        return true;
+    }
+
+    if (multiplier != 0) {
+        MPNumber t = mp_new();
+        mp_set_from_integer(10, &t);
+        mp_xpowy_integer(&t, multiplier, &t);
+        mp_multiply(z, &t, z);
+        mp_clear(&t);
+    }
+
+    if (negate == 1)
+        mp_invert_sign(z, z);
+
+    return false;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/39.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/39.html new file mode 100644 index 0000000..f61d272 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/39.html @@ -0,0 +1,959 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
/*
+ * Copyright (C) 2004-2008 Sami Pietila
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <ctype.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "parser.h"
+
+static int
+variable_is_defined(ParserState *state, const char *name)
+{
+    /* FIXME: Make more generic */
+    if (strcmp(name, "e") == 0 ||
+        strcmp(name, "i") == 0 ||
+        strcmp(name, "π") == 0 ||
+        strcmp(name, "pi") == 0 ||
+        strcmp(name, "c₀") == 0 ||
+        strcmp(name, "μ₀") == 0 ||
+        strcmp(name, "ε₀") == 0 ||
+        strcmp(name, "G") == 0 ||
+        strcmp(name, "h") == 0 ||
+        strcmp(name, "e") == 0 ||
+        strcmp(name, "mₑ") == 0 ||
+        strcmp(name, "mₚ") == 0 ||
+        strcmp(name, "Nₐ") == 0)
+        return 1;
+    if (state->options->variable_is_defined)
+        return state->options->variable_is_defined(name, state->options->callback_data);
+    return 0;
+}
+
+static int
+get_variable(ParserState *state, const char *name, MPNumber *z)
+{
+    int result = 1;
+
+    if (strcmp(name, "e") == 0)
+        mp_get_eulers(z);
+    else if (strcmp(name, "i") == 0)
+        mp_get_i(z);
+    else if (strcmp(name, "π") == 0 || strcmp(name, "pi") == 0)
+        mp_get_pi(z);
+    else if (strcmp(name, "c₀") == 0)
+        mp_set_from_string("299792458", 10, z); /* velocity of light */
+    else if (strcmp(name, "μ₀") == 0)
+        mp_set_from_string("0.0000012566370614", 10, z); /* magnetic constant */
+    else if (strcmp(name, "ε₀") == 0)
+        mp_set_from_string("0.00000000000885418782", 10, z); /* electric constant */
+    else if (strcmp(name, "G") == 0)
+        mp_set_from_string("0.0000000000667408", 10, z); /* Newtonian constant of gravitation */
+    else if (strcmp(name, "h") == 0)
+        mp_set_from_string("0.000000000000000000000000000000000662607004", 10, z); /* Planck constant */
+    else if (strcmp(name, "e") == 0)
+        mp_set_from_string("0.00000000000000000016021766208", 10, z); /* elementary charge */
+    else if (strcmp(name, "mₑ") == 0)
+        mp_set_from_string("0.000000000000000000000000000000910938356", 10, z); /* electron mass */
+    else if (strcmp(name, "mₚ") == 0)
+        mp_set_from_string("0.000000000000000000000000001672621898", 10, z); /* proton mass */
+    else if (strcmp(name, "Nₐ") == 0)
+        mp_set_from_string("602214086000000000000000", 10, z); /* Avogadro constant */
+    else if (state->options->get_variable)
+        result = state->options->get_variable(name, z, state->options->callback_data);
+    else
+        result = 0;
+
+    return result;
+}
+
+static void
+set_variable(ParserState *state, const char *name, const MPNumber *x)
+{
+    // Reserved words, e, π, mod, and, or, xor, not, abs, log, ln, sqrt, int, frac, sin, cos, ...
+    if (strcmp(name, "e") == 0 ||
+        strcmp(name, "i") == 0 ||
+        strcmp(name, "π") == 0 ||
+        strcmp(name, "pi") == 0 ||
+        strcmp(name, "c₀") == 0 ||
+        strcmp(name, "μ₀") == 0 ||
+        strcmp(name, "ε₀") == 0 ||
+        strcmp(name, "G") == 0 ||
+        strcmp(name, "h") == 0 ||
+        strcmp(name, "e") == 0 ||
+        strcmp(name, "mₑ") == 0 ||
+        strcmp(name, "mₚ") == 0 ||
+        strcmp(name, "Nₐ") == 0)
+        return; // FALSE
+
+    if (state->options->set_variable)
+        state->options->set_variable(name, x, state->options->callback_data);
+}
+
+// FIXME: Accept "2sin" not "2 sin", i.e. let the tokenizer collect the multiple
+// Parser then distinguishes between "sin"="s*i*n" or "sin5" = "sin 5" = "sin(5)"
+// i.e. numbers+letters = variable or function depending on following arg
+// letters+numbers = numbers+letters+numbers = function
+
+int
+sub_atoi(const char *data)
+{
+    int i, value = 0;
+    const char *digits[] = {"₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉", NULL};
+
+    do {
+        for(i = 0; digits[i] != NULL && strncmp(data, digits[i], strlen(digits[i])) != 0; i++);
+        if(digits[i] == NULL)
+            return -1;
+        data += strlen(digits[i]);
+        value = value * 10 + i;
+    } while(*data != '\0');
+
+    return value;
+}
+
+int
+super_atoi(const char *data)
+{
+   int i, sign = 1, value = 0;
+   const char *digits[11] = {"⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹", NULL};
+
+   if(strncmp(data, "⁻", strlen("⁻")) == 0) {
+      sign = -1;
+      data += strlen("⁻");
+   }
+
+   do {
+      for(i = 0; digits[i] != NULL && strncmp(data, digits[i], strlen(digits[i])) != 0; i++);
+      if(digits[i] == NULL)
+         return 0;
+      value = value * 10 + i;
+      data += strlen(digits[i]);
+   } while(*data != '\0');
+
+   return sign * value;
+}
+
+static int
+function_is_defined(ParserState *state, const char *name)
+{
+    char *c, *lower_name;
+
+    lower_name = strdup(name);
+    for (c = lower_name; *c; c++)
+        *c = tolower(*c);
+
+    /* FIXME: Make more generic */
+    if (strcmp(lower_name, "log") == 0 ||
+        (strncmp(lower_name, "log", 3) == 0 && sub_atoi(lower_name + 3) >= 0) ||
+        strcmp(lower_name, "ln") == 0 ||
+        strcmp(lower_name, "sqrt") == 0 ||
+        strcmp(lower_name, "abs") == 0 ||
+        strcmp(lower_name, "sgn") == 0 ||
+        strcmp(lower_name, "arg") == 0 ||
+        strcmp(lower_name, "conj") == 0 ||
+        strcmp(lower_name, "int") == 0 ||
+        strcmp(lower_name, "frac") == 0 ||
+        strcmp(lower_name, "floor") == 0 ||
+        strcmp(lower_name, "ceil") == 0 ||
+        strcmp(lower_name, "round") == 0 ||
+        strcmp(lower_name, "re") == 0 ||
+        strcmp(lower_name, "im") == 0 ||
+        strcmp(lower_name, "sin") == 0 || strcmp(lower_name, "cos") == 0 || strcmp(lower_name, "tan") == 0 ||
+        strcmp(lower_name, "asin") == 0 || strcmp(lower_name, "acos") == 0 || strcmp(lower_name, "atan") == 0 ||
+        strcmp(lower_name, "sin⁻¹") == 0 || strcmp(lower_name, "cos⁻¹") == 0 || strcmp(lower_name, "tan⁻¹") == 0 ||
+        strcmp(lower_name, "sinh") == 0 || strcmp(lower_name, "cosh") == 0 || strcmp(lower_name, "tanh") == 0 ||
+        strcmp(lower_name, "sinh⁻¹") == 0 || strcmp(lower_name, "cosh⁻¹") == 0 || strcmp(lower_name, "tanh⁻¹") == 0 ||
+        strcmp(lower_name, "erf") == 0 || strcmp(lower_name, "zeta") == 0 ||
+        strcmp(lower_name, "asinh") == 0 || strcmp(lower_name, "acosh") == 0 || strcmp(lower_name, "atanh") == 0 ||
+        strcmp(lower_name, "ones") == 0 ||
+        strcmp(lower_name, "twos") == 0) {
+        g_free (lower_name);
+        return 1;
+    }
+    g_free (lower_name);
+
+    if (state->options->function_is_defined)
+        return state->options->function_is_defined(name, state->options->callback_data);
+    return 0;
+}
+
+static int
+get_function(ParserState *state, const char *name, const MPNumber *x, MPNumber *z)
+{
+    char *c, *lower_name;
+    int result = 1;
+
+    lower_name = strdup(name);
+    for (c = lower_name; *c; c++)
+        *c = tolower(*c);
+
+    // FIXME: Re Im ?
+
+    if (strcmp(lower_name, "log") == 0)
+        mp_logarithm(10, x, z); // FIXME: Default to ln
+    else if (strncmp(lower_name, "log", 3) == 0) {
+        int base;
+
+        base = sub_atoi(lower_name + 3);
+        if (base < 0)
+            result = 0;
+        else
+            mp_logarithm(base, x, z);
+    }
+    else if (strcmp(lower_name, "ln") == 0)
+        mp_ln(x, z);
+    else if (strcmp(lower_name, "sqrt") == 0) // √x
+        mp_sqrt(x, z);
+    else if (strcmp(lower_name, "abs") == 0) // |x|
+        mp_abs(x, z);
+    else if (strcmp(lower_name, "sgn") == 0)
+        mp_sgn(x, z);
+    else if (strcmp(lower_name, "arg") == 0)
+        mp_arg(x, state->options->angle_units, z);
+    else if (strcmp(lower_name, "conj") == 0)
+        mp_conjugate(x, z);
+    else if (strcmp(lower_name, "int") == 0)
+        mp_integer_component(x, z);
+    else if (strcmp(lower_name, "frac") == 0)
+        mp_fractional_component(x, z);
+    else if (strcmp(lower_name, "floor") == 0)
+        mp_floor(x, z);
+    else if (strcmp(lower_name, "ceil") == 0)
+        mp_ceiling(x, z);
+    else if (strcmp(lower_name, "round") == 0)
+        mp_round(x, z);
+    else if (strcmp(lower_name, "re") == 0)
+        mp_real_component(x, z);
+    else if (strcmp(lower_name, "im") == 0)
+        mp_imaginary_component(x, z);
+    else if (strcmp(lower_name, "sin") == 0)
+        mp_sin(x, state->options->angle_units, z);
+    else if (strcmp(lower_name, "cos") == 0)
+        mp_cos(x, state->options->angle_units, z);
+    else if (strcmp(lower_name, "tan") == 0)
+        mp_tan(x, state->options->angle_units, z);
+    else if (strcmp(lower_name, "sin⁻¹") == 0 || strcmp(lower_name, "asin") == 0)
+        mp_asin(x, state->options->angle_units, z);
+    else if (strcmp(lower_name, "cos⁻¹") == 0 || strcmp(lower_name, "acos") == 0)
+        mp_acos(x, state->options->angle_units, z);
+    else if (strcmp(lower_name, "tan⁻¹") == 0 || strcmp(lower_name, "atan") == 0)
+        mp_atan(x, state->options->angle_units, z);
+    else if (strcmp(lower_name, "sinh") == 0)
+        mp_sinh(x, z);
+    else if (strcmp(lower_name, "cosh") == 0)
+        mp_cosh(x, z);
+    else if (strcmp(lower_name, "tanh") == 0)
+        mp_tanh(x, z);
+    else if (strcmp(lower_name, "sinh⁻¹") == 0 || strcmp(lower_name, "asinh") == 0)
+        mp_asinh(x, z);
+    else if (strcmp(lower_name, "cosh⁻¹") == 0 || strcmp(lower_name, "acosh") == 0)
+        mp_acosh(x, z);
+    else if (strcmp(lower_name, "tanh⁻¹") == 0 || strcmp(lower_name, "atanh") == 0)
+        mp_atanh(x, z);
+    else if (strcmp(lower_name, "erf") == 0)
+        mp_erf(x, z);
+    else if (strcmp(lower_name, "zeta") == 0)
+        mp_zeta(x, z);
+    else if (strcmp(lower_name, "ones") == 0)
+        mp_ones_complement(x, state->options->wordlen, z);
+    else if (strcmp(lower_name, "twos") == 0)
+        mp_twos_complement(x, state->options->wordlen, z);
+    else if (state->options->get_function)
+        result = state->options->get_function(name, x, z, state->options->callback_data);
+    else
+        result = 0;
+
+    free(lower_name);
+
+    return result;
+}
+
+static int
+convert(ParserState *state, const MPNumber *x, const char *x_units, const char *z_units, MPNumber *z)
+{
+    if (state->options->convert)
+        return state->options->convert(x, x_units, z_units, z, state->options->callback_data);
+    else
+        return 0;
+}
+
+MPErrorCode
+mp_equation_parse(const char *expression, MPEquationOptions *options, MPNumber *result, char **error_token)
+{
+    int ret;
+    int err;
+    ParserState* state;
+    state = p_create_parser (expression, options);
+
+    if (!(expression && result) || strlen(expression) == 0)
+        return PARSER_ERR_INVALID;
+
+    state->variable_is_defined = variable_is_defined;
+    state->get_variable = get_variable;
+    state->set_variable = set_variable;
+    state->function_is_defined = function_is_defined;
+    state->get_function = get_function;
+    state->convert = convert;
+    state->error = 0;
+    mp_clear_error();
+    ret = p_parse (state);
+    if (state->error_token != NULL && error_token != NULL) {
+        *error_token = state->error_token;
+    }
+    /* Error during parsing */
+    if (state->error) {
+	err = state->error;
+        p_destroy_parser (state);
+        return err;
+    }
+
+    if (mp_get_error()) {
+        p_destroy_parser (state);
+        return PARSER_ERR_MP;
+    }
+
+    /* Failed to parse */
+    if (ret) {
+        p_destroy_parser (state);
+        return PARSER_ERR_INVALID;
+    }
+    mp_set_from_mp(&state->ret, result);
+    p_destroy_parser (state);
+    return PARSER_ERR_NONE;
+}
+
+const char *
+mp_error_code_to_string(MPErrorCode error_code)
+{
+    switch(error_code)
+    {
+    case PARSER_ERR_NONE:
+        return "PARSER_ERR_NONE";
+    case PARSER_ERR_INVALID:
+        return "PARSER_ERR_INVALID";
+    case PARSER_ERR_OVERFLOW:
+        return "PARSER_ERR_OVERFLOW";
+    case PARSER_ERR_UNKNOWN_VARIABLE:
+        return "PARSER_ERR_UNKNOWN_VARIABLE";
+    case PARSER_ERR_UNKNOWN_FUNCTION:
+        return "PARSER_ERR_UNKNOWN_FUNCTION";
+    case PARSER_ERR_UNKNOWN_CONVERSION:
+        return "PARSER_ERR_UNKNOWN_CONVERSION";
+    case PARSER_ERR_MP:
+        return "PARSER_ERR_MP";
+    default:
+        return "Unknown parser error";
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/4.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/4.html new file mode 100644 index 0000000..09a3914 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/4.html @@ -0,0 +1,395 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
/*
+ * Copyright (C) 2010 Robin Sonefors
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MP_SERIALIZER_H
+#define MP_SERIALIZER_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp.h"
+
+G_BEGIN_DECLS
+
+#define MP_TYPE_SERIALIZER (mp_serializer_get_type())
+#define MP_SERIALIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), mp_serializer_get_type(), MpSerializer))
+
+typedef struct MpSerializerPrivate MpSerializerPrivate;
+
+typedef struct {
+    GObject parent;
+    MpSerializerPrivate *priv;
+} MpSerializer;
+
+typedef struct {
+    GObjectClass parent;
+} MpSerializerClass;
+
+/* Number display mode. */
+typedef enum {
+    MP_DISPLAY_FORMAT_AUTOMATIC,
+    MP_DISPLAY_FORMAT_FIXED,
+    MP_DISPLAY_FORMAT_SCIENTIFIC,
+    MP_DISPLAY_FORMAT_ENGINEERING
+} MpDisplayFormat;
+
+GType mp_serializer_get_type(void);
+
+MpSerializer *mp_serializer_new(MpDisplayFormat format, int base, int trailing_digits);
+
+gchar *mp_serializer_to_string(MpSerializer *serializer, const MPNumber *z);
+gboolean mp_serializer_from_string(MpSerializer *serializer, const gchar *str, MPNumber *z);
+
+void mp_serializer_set_number_format(MpSerializer *serializer, MpDisplayFormat format);
+MpDisplayFormat mp_serializer_get_number_format(MpSerializer *serializer);
+
+void mp_serializer_set_base(MpSerializer *serializer, int base);
+int mp_serializer_get_base(MpSerializer *serializer);
+
+void mp_serializer_set_leading_digits(MpSerializer *serializer, int leading_digits);
+int mp_serializer_get_leading_digits(MpSerializer *serializer);
+
+void mp_serializer_set_trailing_digits(MpSerializer *serializer, int trailing_digits);
+int mp_serializer_get_trailing_digits(MpSerializer *serializer);
+
+void mp_serializer_set_radix(MpSerializer *serializer, gunichar radix);
+gunichar mp_serializer_get_radix(MpSerializer *serializer);
+
+void mp_serializer_set_thousands_separator(MpSerializer *serializer, gunichar separator);
+gunichar mp_serializer_get_thousands_separator(MpSerializer *serializer);
+
+gint mp_serializer_get_thousands_separator_count(MpSerializer *serializer);
+
+void mp_serializer_set_show_trailing_zeroes(MpSerializer *serializer, gboolean visible);
+gboolean mp_serializer_get_show_trailing_zeroes(MpSerializer *serializer);
+
+void mp_serializer_set_show_thousands_separators(MpSerializer *serializer, gboolean visible);
+gboolean mp_serializer_get_show_thousands_separators(MpSerializer *serializer);
+
+G_END_DECLS
+
+#endif /* MP_SERIALIZER_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/40.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/40.html new file mode 100644 index 0000000..74534e3 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/40.html @@ -0,0 +1,1507 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
/*
+ * Copyright (C) 2010 Robin Sonefors
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <langinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp-serializer.h"
+#include "mp-enums.h"
+
+enum {
+    PROP_0,
+    PROP_SHOW_THOUSANDS_SEPARATORS,
+    PROP_SHOW_TRAILING_ZEROES,
+    PROP_NUMBER_FORMAT,
+    PROP_BASE,
+};
+
+struct MpSerializerPrivate
+{
+    gint leading_digits;      /* Number of digits to show before radix */
+    gint trailing_digits;     /* Number of digits to show after radix */
+    MpDisplayFormat format;   /* Number display mode. */
+    gint show_tsep;           /* Set if the thousands separator should be shown. */
+    gint show_zeroes;         /* Set if trailing zeroes should be shown. */
+
+    gint base;                /* Numeric base */
+
+    gunichar tsep;            /* Locale specific thousands separator. */
+    gunichar radix;           /* Locale specific radix string. */
+    gint tsep_count;          /* Number of digits between separator. */
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (MpSerializer, mp_serializer, G_TYPE_OBJECT);
+
+MpSerializer *
+mp_serializer_new(MpDisplayFormat format, int base, int trailing_digits)
+{
+    MpSerializer *serializer = g_object_new(mp_serializer_get_type(), /*"number-format", format,*/ NULL);
+    mp_serializer_set_number_format(serializer, format);
+    mp_serializer_set_base(serializer, base);
+    mp_serializer_set_trailing_digits(serializer, 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)
+{
+    static gchar digits[] = "0123456789ABCDEF";
+    MPNumber number = mp_new();
+    MPNumber integer_component = mp_new();
+    MPNumber fractional_component = mp_new();
+    MPNumber temp = mp_new();
+    int i;
+    gsize last_non_zero;
+
+    if (mp_is_negative(x))
+        mp_abs(x, &number);
+    else
+        mp_set_from_mp(x, &number);
+
+    /* Add rounding factor */
+    mp_set_from_integer(base, &temp);
+    mp_xpowy_integer(&temp, -(serializer->priv->trailing_digits+1), &temp);
+    mp_multiply_integer(&temp, base, &temp);
+    mp_divide_integer(&temp, 2, &temp);
+    mp_add(&number, &temp, &temp);
+
+    /* If trying to add rounding factor causes overflow, don't add it */
+    if (!mp_get_error())
+        mp_set_from_mp(&temp, &number);
+
+    /* Split into integer and fractional component */
+    mp_floor(&number, &integer_component);
+    mp_fractional_component(&number, &fractional_component);
+
+    /* Write out the integer component least significant digit to most */
+    mp_set_from_mp(&integer_component, &temp);
+    i = 0;
+    MPNumber t = mp_new();
+    MPNumber t2 = mp_new();
+    MPNumber t3 = mp_new();
+    do {
+        long d;
+
+        if (serializer->priv->base == 10 && serializer->priv->show_tsep && i == serializer->priv->tsep_count) {
+            g_string_prepend_unichar(string, serializer->priv->tsep);
+            i = 0;
+        }
+        i++;
+
+        mp_divide_integer(&temp, base, &t);
+        mp_floor(&t, &t);
+        mp_multiply_integer(&t, base, &t2);
+
+        mp_subtract(&temp, &t2, &t3);
+
+        d = mp_to_integer(&t3);
+        if (d < 16 && d >= 0)
+            g_string_prepend_c(string, digits[d]);
+        else
+        {   /* FIXME: Should show an overflow error message in fixed mode */
+            g_string_assign(string, "0");
+            *n_digits = serializer->priv->leading_digits+1;
+            break;
+        }
+        (*n_digits)++;
+
+        mp_set_from_mp(&t, &temp);
+    } while (!mp_is_zero(&temp));
+    mp_clear(&t);
+    mp_clear(&t2);
+    mp_clear(&t3);
+
+    last_non_zero = string->len;
+
+    g_string_append_unichar(string, serializer->priv->radix);
+
+    /* Write out the fractional component */
+    mp_set_from_mp(&fractional_component, &temp);
+    MPNumber digit = mp_new();
+    for (i = serializer->priv->trailing_digits; i > 0 && !mp_is_zero(&temp); i--) {
+        int d;
+
+        mp_multiply_integer(&temp, base, &temp);
+        mp_floor(&temp, &digit);
+        d = mp_to_integer(&digit);
+
+        g_string_append_c(string, digits[d]);
+
+        if(d != 0)
+            last_non_zero = string->len;
+        mp_subtract(&temp, &digit, &temp);
+    }
+    mp_clear(&digit);
+
+    /* Strip trailing zeroes */
+    if (!serializer->priv->show_zeroes || serializer->priv->trailing_digits == 0)
+        g_string_truncate(string, last_non_zero);
+
+    /* Add sign on non-zero values */
+    if (strcmp(string->str, "0") != 0 || force_sign) {
+        if (mp_is_negative(x))
+            g_string_prepend(string, "−");
+        else if (force_sign)
+            g_string_prepend(string, "+");
+    }
+
+    /* Append base suffix if not in default base */
+    if (base != serializer->priv->base) {
+        const gchar *base_digits[] = {"₀", "₁", "₂", "₃", "₄", "₅", "₆", "₇", "₈", "₉"};
+        int multiplier = 1;
+        int b = base;
+
+        while (base / multiplier != 0)
+            multiplier *= 10;
+        while (multiplier != 1) {
+            int d;
+            multiplier /= 10;
+            d = b / multiplier;
+            g_string_append(string, base_digits[d]);
+            b -= d * multiplier;
+        }
+    }
+    mp_clear(&number);
+    mp_clear(&integer_component);
+    mp_clear(&fractional_component);
+    mp_clear(&temp);
+}
+
+static gchar *
+mp_to_string(MpSerializer *serializer, const MPNumber *x, int *n_digits)
+{
+    GString *string;
+    MPNumber x_real = mp_new();
+    gchar *result;
+
+    string = g_string_sized_new(1024);
+
+    mp_real_component(x, &x_real);
+    mp_to_string_real(serializer, &x_real, serializer->priv->base, FALSE, n_digits, string);
+    if (mp_is_complex(x)) {
+        GString *s;
+        gboolean force_sign = TRUE;
+        MPNumber x_im = mp_new();
+        int n_complex_digits = 0;
+
+        mp_imaginary_component(x, &x_im);
+
+        if (strcmp(string->str, "0") == 0) {
+            g_string_assign(string, "");
+            force_sign = FALSE;
+        }
+
+        s = g_string_sized_new(1024);
+        mp_to_string_real(serializer, &x_im, 10, force_sign, &n_complex_digits, s);
+        if (n_complex_digits > *n_digits)
+            *n_digits = n_complex_digits;
+        if (strcmp(s->str, "0") == 0 || strcmp(s->str, "+0") == 0 || strcmp(s->str, "−0") == 0) {
+            /* Ignore unless the real part was also zero and string was cleared*/
+            if (string->len == 0) {
+                g_string_append(string, "0");
+            }
+        }
+        else if (strcmp(s->str, "1") == 0) {
+            g_string_append(string, "i");
+        }
+        else if (strcmp(s->str, "+1") == 0) {
+            g_string_append(string, "+i");
+        }
+        else if (strcmp(s->str, "−1") == 0) {
+            g_string_append(string, "−i");
+        }
+        else {
+            if (strcmp(s->str, "+0") == 0)<--- Condition 'strcmp(s->str,"+0")==0' is always false
+                g_string_append(string, "+");
+            else if (strcmp(s->str, "0") != 0)<--- Condition 'strcmp(s->str,"0")!=0' is always true
+                g_string_append(string, s->str);
+
+            g_string_append(string, "i");
+        }
+        g_string_free(s, TRUE);
+        mp_clear(&x_im);
+    }
+
+    result = g_strndup(string->str, string->len + 1);
+    g_string_free(string, TRUE);
+    mp_clear(&x_real);
+
+    return result;
+}
+
+static int
+mp_to_exponential_string_real(MpSerializer *serializer, const MPNumber *x, GString *string, gboolean eng_format, int *n_digits)
+{
+    gchar *fixed;
+    MPNumber t = mp_new();
+    MPNumber z = mp_new();
+    MPNumber base = mp_new();
+    MPNumber base3 = mp_new();
+    MPNumber base10 = mp_new();
+    MPNumber base10inv = mp_new();
+    MPNumber mantissa = mp_new();
+    int exponent = 0;
+
+    mp_abs(x, &z);
+    if (mp_is_negative(x))
+        g_string_append(string, "−");
+    mp_set_from_mp(&z, &mantissa);
+
+    mp_set_from_integer(serializer->priv->base, &base);
+    mp_xpowy_integer(&base, 3, &base3);
+    mp_xpowy_integer(&base, 10, &base10);
+    mp_set_from_integer(1, &t);
+    mp_divide(&t, &base10, &base10inv);
+
+    if (!mp_is_zero(&mantissa)) {
+        while (!eng_format && mp_is_greater_equal(&mantissa, &base10)) {
+            exponent += 10;
+            mp_multiply(&mantissa, &base10inv, &mantissa);
+        }
+
+        while ((!eng_format &&  mp_is_greater_equal(&mantissa, &base)) ||
+                (eng_format && (mp_is_greater_equal(&mantissa, &base3) || exponent % 3 != 0))) {
+            exponent += 1;
+            mp_divide(&mantissa, &base, &mantissa);
+        }
+
+        while (!eng_format && mp_is_less_than(&mantissa, &base10inv)) {
+            exponent -= 10;
+            mp_multiply(&mantissa, &base10, &mantissa);
+        }
+
+        mp_set_from_integer(1, &t);
+        while (mp_is_less_than(&mantissa, &t) || (eng_format && exponent % 3 != 0)) {
+            exponent -= 1;
+            mp_multiply(&mantissa, &base, &mantissa);
+        }
+    }
+
+    fixed = mp_to_string(serializer, &mantissa, n_digits);
+    g_string_append(string, fixed);
+    g_free(fixed);
+
+    mp_clear(&t);
+    mp_clear(&z);
+    mp_clear(&base);
+    mp_clear(&base3);
+    mp_clear(&base10);
+    mp_clear(&base10inv);
+    mp_clear(&mantissa);
+
+    return exponent;
+}
+
+static void
+append_exponent(GString *string, int exponent)
+{
+    const gchar *super_digits[] = {"⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"};
+    gchar *super_value, *c;
+
+    if (exponent == 0)
+        return;
+
+    g_string_append_printf(string, "×10"); // FIXME: Use the current base
+    if (exponent < 0) {
+        exponent = -exponent;
+        g_string_append(string, "⁻");
+    }
+
+    super_value = g_strdup_printf("%d", exponent);
+    for (c = super_value; *c; c++)
+        g_string_append(string, super_digits[*c - '0']);
+    g_free (super_value);
+}
+
+static gchar *
+mp_to_exponential_string(MpSerializer *serializer, const MPNumber *x, gboolean eng_format, int *n_digits)
+{
+    GString *string;
+    MPNumber x_real = mp_new();
+    gchar *result;
+    int exponent;
+
+    string = g_string_sized_new(1024);
+
+    mp_real_component(x, &x_real);
+    exponent = mp_to_exponential_string_real(serializer, &x_real, string, eng_format, n_digits);
+    append_exponent(string, exponent);
+
+    if (mp_is_complex(x)) {
+        GString *s;
+        MPNumber x_im = mp_new();
+        int n_complex_digits = 0;
+
+        mp_imaginary_component(x, &x_im);
+
+        if (strcmp(string->str, "0") == 0)
+            g_string_assign(string, "");
+        else if (!mp_is_negative(&x_im))
+            g_string_append(string, "+");
+
+        s = g_string_sized_new(1024);
+        exponent = mp_to_exponential_string_real(serializer, &x_im, s, eng_format, &n_complex_digits);
+        if (n_complex_digits > *n_digits)
+            *n_digits = n_complex_digits;
+        if (strcmp(s->str, "0") == 0 || strcmp(s->str, "+0") == 0 || strcmp(s->str, "−0") == 0) {
+            /* Ignore */
+        }
+        else if (strcmp(s->str, "1") == 0) {
+            g_string_append(string, "i");
+        }
+        else if (strcmp(s->str, "+1") == 0) {
+            g_string_append(string, "+i");
+        }
+        else if (strcmp(s->str, "−1") == 0) {
+            g_string_append(string, "−i");
+        }
+        else {
+            if (strcmp(s->str, "+0") == 0)<--- Condition 'strcmp(s->str,"+0")==0' is always false
+                g_string_append(string, "+");
+            else if (strcmp(s->str, "0") != 0)<--- Condition 'strcmp(s->str,"0")!=0' is always true
+                g_string_append(string, s->str);
+
+            g_string_append(string, "i");
+        }
+        g_string_free(s, TRUE);
+        mp_clear(&x_im);
+        append_exponent(string, exponent);
+    }
+
+    result = g_strndup(string->str, string->len + 1);
+    g_string_free(string, TRUE);
+    mp_clear(&x_real);
+
+    return result;
+}
+
+gchar *
+mp_serializer_to_string(MpSerializer *serializer, const MPNumber *x)
+{
+    gchar *s0;
+    int n_digits = 0;
+    switch(serializer->priv->format) {
+    default:
+    case MP_DISPLAY_FORMAT_AUTOMATIC:
+        s0 = mp_to_string(serializer, x, &n_digits);
+        if (n_digits <= serializer->priv->leading_digits)
+            return s0;
+        else {
+            g_free (s0);
+            return mp_to_exponential_string(serializer, x, FALSE, &n_digits);
+        }
+        break;
+    case MP_DISPLAY_FORMAT_FIXED:
+        return mp_to_string(serializer, x, &n_digits);
+    case MP_DISPLAY_FORMAT_SCIENTIFIC:
+        return mp_to_exponential_string(serializer, x, FALSE, &n_digits);
+    case MP_DISPLAY_FORMAT_ENGINEERING:
+        return mp_to_exponential_string(serializer, x, TRUE, &n_digits);
+    }
+}
+
+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,
+                           const GValue *value,
+                           GParamSpec *pspec)
+{
+    MpSerializer *self = MP_SERIALIZER(object);
+
+    switch (prop_id) {
+    case PROP_SHOW_THOUSANDS_SEPARATORS:
+        mp_serializer_set_show_thousands_separators(self, g_value_get_boolean(value));
+        break;
+    case PROP_SHOW_TRAILING_ZEROES:
+        mp_serializer_set_show_trailing_zeroes(self, g_value_get_boolean(value));
+        break;
+    case PROP_BASE:
+        mp_serializer_set_base(self, g_value_get_int(value));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+mp_serializer_get_property(GObject *object,
+                           guint prop_id,
+                           GValue *value,
+                           GParamSpec *pspec)
+{
+    MpSerializer *self = MP_SERIALIZER(object);
+
+    switch (prop_id) {
+    case PROP_SHOW_THOUSANDS_SEPARATORS:
+        g_value_set_boolean(value, mp_serializer_get_show_thousands_separators(self));
+        break;
+    case PROP_SHOW_TRAILING_ZEROES:
+        g_value_set_boolean(value, mp_serializer_get_show_trailing_zeroes(self));
+        break;
+    case PROP_BASE:
+        g_value_set_int(value, mp_serializer_get_base(self));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void
+mp_serializer_class_init(MpSerializerClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+    object_class->get_property = mp_serializer_get_property;
+    object_class->set_property = mp_serializer_set_property;
+
+    g_object_class_install_property(object_class,
+                                    PROP_SHOW_THOUSANDS_SEPARATORS,
+                                    g_param_spec_boolean("show-thousands-separators",
+                                                         "show-thousands-separators",
+                                                         "Show thousands separators",
+                                                         TRUE,
+                                                         G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_SHOW_TRAILING_ZEROES,
+                                    g_param_spec_boolean("show-trailing-zeroes",
+                                                         "show-trailing-zeroes",
+                                                         "Show trailing zeroes",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_NUMBER_FORMAT,
+                                    g_param_spec_enum("number-format",
+                                                      "number-format",
+                                                      "Display format",
+                                                      math_mp_display_format_get_type(),
+                                                      MP_DISPLAY_FORMAT_AUTOMATIC,
+                                                      G_PARAM_READWRITE));
+    g_object_class_install_property(object_class,
+                                    PROP_BASE,
+                                    g_param_spec_int("base",
+                                                     "base",
+                                                     "Default number base",
+                                                     2, 16, 10,
+                                                     G_PARAM_READWRITE));
+}
+
+static void
+mp_serializer_init(MpSerializer *serializer)
+{
+    gchar *radix, *utf8_radix, *tsep;
+    serializer->priv = mp_serializer_get_instance_private (serializer);
+
+    radix = nl_langinfo(RADIXCHAR);
+    utf8_radix = g_locale_to_utf8(radix, -1, NULL, NULL, NULL);
+    serializer->priv->radix = radix ? g_utf8_get_char(utf8_radix) : '.';
+    g_free(utf8_radix);
+    tsep = nl_langinfo(THOUSEP);
+    if (tsep && tsep[0] != '\0')
+    {
+        gchar *utf8_tsep = g_locale_to_utf8(tsep, -1, NULL, NULL, NULL);
+        serializer->priv->tsep = g_utf8_get_char(utf8_tsep);
+        g_free(utf8_tsep);
+    }
+    else
+        serializer->priv->tsep = ' ';
+    serializer->priv->tsep_count = 3;
+
+    serializer->priv->base = 10;
+    serializer->priv->leading_digits = 12;
+    serializer->priv->trailing_digits = 9;
+    serializer->priv->show_zeroes = FALSE;
+    serializer->priv->show_tsep = FALSE;
+    serializer->priv->format = MP_DISPLAY_FORMAT_AUTOMATIC;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/41.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/41.html new file mode 100644 index 0000000..d954528 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/41.html @@ -0,0 +1,779 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libintl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp.h"
+
+/* Convert x to radians */
+void
+convert_to_radians(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    int i;
+
+    switch(unit) {
+    default:
+    case MP_RADIANS:
+        mp_set_from_mp(x, z);
+        return;
+
+    case MP_DEGREES:
+        i = 180;
+        break;
+
+    case MP_GRADIANS:
+        i = 200;
+        break;
+    }
+    mpfr_t scale;
+    mpfr_init2(scale, PRECISION);
+    mpfr_const_pi(scale, MPFR_RNDN);
+    mpfr_div_si(scale, scale, i, MPFR_RNDN);
+    mpc_mul_fr(z->num, x->num, scale, MPC_RNDNN);
+    mpfr_clear(scale);
+}
+
+void
+convert_from_radians(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    int i;
+
+    switch(unit) {
+    default:
+    case MP_RADIANS:
+        mp_set_from_mp(x, z);
+        return;
+
+    case MP_DEGREES:
+        i = 180;
+        break;
+
+    case MP_GRADIANS:
+        i = 200;
+        break;
+    }
+    mpfr_t scale;
+    mpfr_init2(scale, PRECISION);
+    mpfr_const_pi(scale, MPFR_RNDN);
+    mpfr_si_div(scale, i, scale, MPFR_RNDN);
+    mpc_mul_fr(z->num, x->num, scale, MPC_RNDNN);
+    mpfr_clear(scale);
+}
+
+void
+mp_get_pi (MPNumber *z)
+{
+    mpfr_const_pi(mpc_realref(z->num), MPFR_RNDN);
+    mpfr_set_zero(mpc_imagref(z->num), 0);
+}
+
+void
+mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    if (mp_is_complex(x))
+        mp_set_from_mp(x, z);
+    else
+        convert_to_radians(x, unit, z);
+    mpc_sin(z->num, z->num, MPC_RNDNN);
+}
+
+void
+mp_cos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    if (mp_is_complex(x))
+        mp_set_from_mp(x, z);
+    else
+        convert_to_radians(x, unit, z);
+    mpc_cos(z->num, z->num, MPC_RNDNN);
+}
+
+void
+mp_tan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    MPNumber x_radians = mp_new();
+    MPNumber pi = mp_new();
+    MPNumber t1 = mp_new();
+
+    convert_to_radians(x, unit, &x_radians);
+    mp_get_pi(&pi);
+    mp_divide_integer(&pi, 2, &t1);
+    mp_subtract(&x_radians, &t1, &t1);
+    mp_divide(&t1, &pi, &t1);
+
+    if (mp_is_integer(&t1)) {
+        /* Translators: Error displayed when tangent value is undefined */
+        mperr(_("Tangent is undefined for angles that are multiples of π (180°) from π∕2 (90°)"));
+        mp_set_from_integer(0, z);
+        mp_clear(&x_radians);
+        mp_clear(&pi);
+        mp_clear(&t1);
+        return;
+    }
+
+    if (mp_is_complex(x))
+        mp_set_from_mp(x, z);
+    else
+        mp_set_from_mp(&x_radians, z);
+    mpc_tan(z->num, z->num, MPC_RNDNN);
+    mp_clear(&x_radians);
+    mp_clear(&pi);
+    mp_clear(&t1);
+}
+
+void
+mp_asin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    MPNumber x_max = mp_new();
+    MPNumber x_min = mp_new();
+    mp_set_from_integer(1, &x_max);
+    mp_set_from_integer(-1, &x_min);
+
+    if (mp_compare(x, &x_max) > 0 || mp_compare(x, &x_min) < 0)
+    {
+        /* Translators: Error displayed when inverse sine value is undefined */
+        mperr(_("Inverse sine is undefined for values outside [-1, 1]"));
+        mp_set_from_integer(0, z);
+        mp_clear(&x_max);
+        mp_clear(&x_min);
+        return;
+    }
+    mpc_asin(z->num, x->num, MPC_RNDNN);
+    if (!mp_is_complex(z))
+        convert_from_radians(z, unit, z);
+    mp_clear(&x_max);
+    mp_clear(&x_min);
+}
+
+void
+mp_acos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    MPNumber x_max = mp_new();
+    MPNumber x_min = mp_new();
+    mp_set_from_integer(1, &x_max);
+    mp_set_from_integer(-1, &x_min);
+
+    if (mp_compare(x, &x_max) > 0 || mp_compare(x, &x_min) < 0)
+    {
+        /* Translators: Error displayed when inverse sine value is undefined */
+        mperr(_("Inverse cosine is undefined for values outside [-1, 1]"));
+        mp_set_from_integer(0, z);
+        mp_clear(&x_max);
+        mp_clear(&x_min);
+        return;
+    }
+    mpc_acos(z->num, x->num, MPC_RNDNN);
+    if (!mp_is_complex(z))
+        convert_from_radians(z, unit, z);
+    mp_clear(&x_max);
+    mp_clear(&x_min);
+}
+
+void
+mp_atan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    MPNumber i = mp_new();
+    MPNumber minus_i = mp_new();
+    mpc_set_si_si(i.num, 0, 1, MPC_RNDNN);
+    mpc_set_si_si(minus_i.num, 0, -1, MPC_RNDNN);
+
+    /* Check x != i and x != -i */
+    if (mp_is_equal(x, &i) || mp_is_equal(x, &minus_i))
+    {
+        /* Translators: Error displayed when inverse sine value is undefined */
+        mperr(_("Arctangent function is undefined for values i and -i"));
+        mp_set_from_integer(0, z);
+        mp_clear(&i);
+        mp_clear(&minus_i);
+        return;
+    }
+    mpc_atan(z->num, x->num, MPC_RNDNN);
+    if (!mp_is_complex(z))
+        convert_from_radians(z, unit, z);
+    mp_clear(&i);
+    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)
+{
+    MPNumber t = mp_new();
+
+    /* Check x >= 1 */
+    mp_set_from_integer(1, &t);
+    if (mp_is_less_than(x, &t))
+    {
+        /* Translators: Error displayed when inverse hyperbolic cosine value is undefined */
+        mperr(_("Inverse hyperbolic cosine is undefined for values less than one"));
+        mp_set_from_integer(0, z);
+        mp_clear(&t);
+        return;
+    }
+
+    mpc_acosh(z->num, x->num, MPC_RNDNN);
+    mp_clear(&t);
+}
+
+void
+mp_atanh(const MPNumber *x, MPNumber *z)
+{
+    MPNumber x_max = mp_new();
+    MPNumber x_min = mp_new();
+    mp_set_from_integer(1, &x_max);
+    mp_set_from_integer(-1, &x_min);
+
+    if (mp_compare(x, &x_max) >= 0 || mp_compare(x, &x_min) <= 0)
+    {
+         /* Translators: Error displayed when inverse hyperbolic tangent value is undefined */
+        mperr(_("Inverse hyperbolic tangent is undefined for values outside (-1, 1)"));
+        mp_set_from_integer(0, z);
+        mp_clear(&x_max);
+        mp_clear(&x_min);
+        return;
+    }
+    mpc_atanh(z->num, x->num, MPC_RNDNN);
+    mp_clear(&x_max);
+    mp_clear(&x_min);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/42.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/42.html new file mode 100644 index 0000000..208bd7b --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/42.html @@ -0,0 +1,2255 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdint.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <math.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp.h"
+
+char *mp_error = NULL;
+
+/*  THIS ROUTINE IS CALLED WHEN AN ERROR CONDITION IS ENCOUNTERED, AND
+ *  AFTER A MESSAGE HAS BEEN WRITTEN TO STDERR.
+ */
+void
+mperr(const char *format, ...)
+{
+    char text[1024];
+    va_list args;
+
+    va_start(args, format);
+    vsnprintf(text, 1024, format, args);
+    va_end(args);
+
+    if (mp_error)
+        free(mp_error);
+    mp_error = strdup(text);
+}
+
+const char *
+mp_get_error()
+{
+    return mp_error;
+}
+
+void mp_clear_error()
+{
+    if (mp_error)
+        free(mp_error);
+    mp_error = NULL;
+}
+
+MPNumber
+mp_new(void)
+{
+    MPNumber z;
+    mpc_init2(z.num, PRECISION);
+    return z;
+}
+
+MPNumber
+mp_new_from_unsigned_integer(ulong x)
+{
+    MPNumber z;
+    mpc_init2(z.num, PRECISION);
+    mpc_set_ui(z.num, x, MPC_RNDNN);
+    return z;
+}
+
+MPNumber *
+mp_new_ptr(void)
+{
+    MPNumber *z = malloc(sizeof(MPNumber));
+    mpc_init2(z->num, PRECISION);
+    return z;
+}
+
+void
+mp_clear(MPNumber *z)
+{
+    if (z != NULL)
+        mpc_clear(z->num);
+}
+
+void
+mp_free(MPNumber *z)
+{
+    if (z != NULL)
+    {
+        mpc_clear(z->num);
+        free(z);
+    }
+}
+
+void
+mp_get_eulers(MPNumber *z)
+{
+    /* e^1, since mpfr doesn't have a function to return e */
+    mpfr_set_ui(mpc_realref(z->num), 1, MPFR_RNDN);
+    mpfr_exp(mpc_realref(z->num), mpc_realref(z->num), MPFR_RNDN);
+    mpfr_set_zero(mpc_imagref(z->num), 0);
+}
+
+void
+mp_get_i(MPNumber *z)
+{
+    mpc_set_si_si(z->num, 0, 1, MPC_RNDNN);
+}
+
+void
+mp_abs(const MPNumber *x, MPNumber *z)
+{
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpc_abs(mpc_realref(z->num), x->num, MPC_RNDNN);
+}
+
+void
+mp_arg(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
+{
+    if (mp_is_zero(x))
+    {
+        /* Translators: Error display when attempting to take argument of zero */
+        mperr(_("Argument not defined for zero"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpc_arg(mpc_realref(z->num), x->num, MPC_RNDNN);
+    convert_from_radians(z, unit, z);
+    // MPC returns -π for the argument of negative real numbers if
+    // their imaginary part is -0, we want +π for all real negative
+    // numbers
+    if (!mp_is_complex (x) && mp_is_negative (x))
+        mpfr_abs(mpc_realref(z->num), mpc_realref(z->num), MPFR_RNDN);
+}
+
+void
+mp_conjugate(const MPNumber *x, MPNumber *z)
+{
+    mpc_conj(z->num, x->num, MPC_RNDNN);
+}
+
+void
+mp_real_component(const MPNumber *x, MPNumber *z)
+{
+    mpc_set_fr(z->num, mpc_realref(x->num), MPC_RNDNN);
+}
+
+void
+mp_imaginary_component(const MPNumber *x, MPNumber *z)
+{
+    mpc_set_fr(z->num, mpc_imagref(x->num), MPC_RNDNN);
+}
+
+void
+mp_add(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    mpc_add(z->num, x->num, y->num, MPC_RNDNN);
+}
+
+void
+mp_add_integer(const MPNumber *x, long y, MPNumber *z)
+{
+    mpc_add_si(z->num, x->num, y, MPC_RNDNN);
+}
+
+void
+mp_subtract(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    mpc_sub(z->num, x->num, y->num, MPC_RNDNN);
+}
+
+void
+mp_sgn(const MPNumber *x, MPNumber *z)
+{
+    mpc_set_si(z->num, mpfr_sgn(mpc_realref(x->num)), MPC_RNDNN);
+}
+
+void
+mp_integer_component(const MPNumber *x, MPNumber *z)
+{
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpfr_trunc(mpc_realref(z->num), mpc_realref(x->num));
+}
+
+void
+mp_fractional_component(const MPNumber *x, MPNumber *z)
+{
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpfr_frac(mpc_realref(z->num), mpc_realref(x->num), MPFR_RNDN);
+}
+
+void
+mp_fractional_part(const MPNumber *x, MPNumber *z)
+{
+    MPNumber f = mp_new();
+    mp_floor(x, &f);
+    mp_subtract(x, &f, z);
+    mp_clear(&f);
+}
+
+void
+mp_floor(const MPNumber *x, MPNumber *z)
+{
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpfr_floor(mpc_realref(z->num), mpc_realref(x->num));
+}
+
+void
+mp_ceiling(const MPNumber *x, MPNumber *z)
+{
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpfr_ceil(mpc_realref(z->num), mpc_realref(x->num));
+}
+
+void
+mp_round(const MPNumber *x, MPNumber *z)
+{
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpfr_round(mpc_realref(z->num), mpc_realref(x->num));
+}
+
+int
+mp_compare(const MPNumber *x, const MPNumber *y)
+{
+    return mpfr_cmp(mpc_realref(x->num), mpc_realref(y->num));
+}
+
+void
+mp_divide(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    if (mp_is_zero(y))
+    {
+        /* Translators: Error displayed attempted to divide by zero */
+        mperr(_("Division by zero is undefined"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+    mpc_div(z->num, x->num, y->num, MPC_RNDNN);
+}
+
+void
+mp_divide_integer(const MPNumber *x, long y, MPNumber *z)
+{
+    MPNumber t1 = mp_new();
+
+    mp_set_from_integer(y, &t1);
+    mp_divide(x, &t1, z);
+    mp_clear(&t1);
+}
+
+bool
+mp_is_integer(const MPNumber *x)
+{
+    if (mp_is_complex(x))
+        return false;
+
+    return mpfr_integer_p(mpc_realref(x->num)) != 0;
+}
+
+bool
+mp_is_positive_integer(const MPNumber *x)
+{
+    if (mp_is_complex(x))
+        return false;
+    else
+        return mpfr_sgn(mpc_realref(x->num)) >= 0 && mp_is_integer(x);
+}
+
+bool
+mp_is_natural(const MPNumber *x)
+{
+    if (mp_is_complex(x))
+        return false;
+    else
+        return mpfr_sgn(mpc_realref(x->num)) > 0 && mp_is_integer(x);
+}
+
+bool
+mp_is_complex(const MPNumber *x)
+{
+    return !mpfr_zero_p(mpc_imagref(x->num));
+}
+
+bool
+mp_is_equal(const MPNumber *x, const MPNumber *y)
+{
+    int res = mpc_cmp(x->num, y->num);
+    return MPC_INEX_RE(res) == 0 && MPC_INEX_IM(res) == 0;
+}
+
+void
+mp_epowy(const MPNumber *x, MPNumber *z)
+{
+    mpc_exp(z->num, x->num, MPC_RNDNN);
+}
+
+bool
+mp_is_zero (const MPNumber *x)
+{
+    int res = mpc_cmp_si_si(x->num, 0, 0);
+    return MPC_INEX_RE(res) == 0 && MPC_INEX_IM(res) == 0;
+}
+
+bool
+mp_is_negative(const MPNumber *x)
+{
+    return mpfr_sgn(mpc_realref(x->num)) < 0;
+}
+
+bool
+mp_is_greater_equal(const MPNumber *x, const MPNumber *y)
+{
+    return mp_compare(x, y) >= 0;
+}
+
+bool
+mp_is_greater_than(const MPNumber *x, const MPNumber *y)
+{
+    return mp_compare(x, y) > 0;
+}
+
+bool
+mp_is_less_equal(const MPNumber *x, const MPNumber *y)
+{
+    return mp_compare(x, y) <= 0;
+}
+
+bool
+mp_is_less_than(const MPNumber *x, const MPNumber *y)
+{
+    return mp_compare(x, y) < 0;
+}
+
+void
+mp_ln(const MPNumber *x, MPNumber *z)
+{
+    /* ln(0) undefined */
+    if (mp_is_zero(x))
+    {
+        /* Translators: Error displayed when attempting to take logarithm of zero */
+        mperr(_("Logarithm of zero is undefined"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+
+    /* ln(-x) complex */
+    /* FIXME: Make complex numbers optional */
+    /*if (mp_is_negative(x)) {
+        // Translators: Error displayed attempted to take logarithm of negative value
+        mperr(_("Logarithm of negative values is undefined"));
+        mp_set_from_integer(0, z);
+        return;
+    }*/
+
+    mpc_log(z->num, x->num, MPC_RNDNN);
+    // MPC returns -π for the imaginary part of the log of
+    // negative real numbers if their imaginary part is -0, we want +π
+    if (!mp_is_complex (x) && mp_is_negative (x))
+        mpfr_abs(mpc_imagref(z->num), mpc_imagref(z->num), MPFR_RNDN);
+}
+
+void
+mp_logarithm(long n, const MPNumber *x, MPNumber *z)
+{
+    /* log(0) undefined */
+    if (mp_is_zero(x))
+    {
+        /* Translators: Error displayed when attempting to take logarithm of zero */
+        mperr(_("Logarithm of zero is undefined"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+
+    /* logn(x) = ln(x) / ln(n) */
+    MPNumber t1 = mp_new();
+    mp_set_from_integer(n, &t1);
+    mp_ln(&t1, &t1);
+    mp_ln(x, z);
+    mp_divide(z, &t1, z);
+    mp_clear(&t1);
+}
+
+void
+mp_multiply(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    mpc_mul(z->num, x->num, y->num, MPC_RNDNN);
+}
+
+void
+mp_multiply_integer(const MPNumber *x, long y, MPNumber *z)
+{
+    mpc_mul_si(z->num, x->num, y, MPC_RNDNN);
+}
+
+void
+mp_invert_sign(const MPNumber *x, MPNumber *z)
+{
+    mpc_neg(z->num, x->num, MPC_RNDNN);
+}
+
+void
+mp_reciprocal(const MPNumber *x, MPNumber *z)
+{
+    mpc_t temp;
+    mpc_init2(temp, PRECISION);
+    mpc_set_ui(temp, 1, MPC_RNDNN);
+    mpc_fr_div(z->num, mpc_realref(temp), x->num, MPC_RNDNN);
+    mpc_clear(temp);
+}
+
+void
+mp_root(const MPNumber *x, long n, MPNumber *z)
+{
+    ulong p;
+
+    if (n < 0)
+    {
+        mpc_ui_div(z->num, 1, x->num, MPC_RNDNN);
+
+        if (n == LONG_MIN)
+            p = (ulong) LONG_MAX + 1;
+        else
+            p = (ulong) -n;
+    }
+    else if (n > 0)
+    {
+        mp_set_from_mp(x, z);
+        p = n;
+    }
+    else
+    {   /* Translators: Error displayed when attempting to take zeroth root */
+        mperr(_("The zeroth root of a number is undefined"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+    if (!mp_is_complex(x) && (!mp_is_negative(x) || (p & 1) == 1))
+    {
+        mpfr_rootn_ui(mpc_realref(z->num), mpc_realref(z->num), p, MPFR_RNDN);
+        mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    }
+    else
+    {
+        mpfr_t tmp;
+        mpfr_init2(tmp, PRECISION);
+        mpfr_set_ui(tmp, p, MPFR_RNDN);
+        mpfr_ui_div(tmp, 1, tmp, MPFR_RNDN);
+        mpc_pow_fr(z->num, z->num, tmp, MPC_RNDNN);
+        mpfr_clear(tmp);
+    }
+}
+
+void
+mp_sqrt(const MPNumber *x, MPNumber *z)
+{
+    mp_root(x, 2, z);
+}
+
+void
+mp_factorial(const MPNumber *x, MPNumber *z)
+{
+    /* 0! == 1 */
+    if (mp_is_zero(x))
+    {
+        mpc_set_si(z->num, 1, MPC_RNDNN);
+        return;
+    }
+    if (!mp_is_natural(x))
+    {
+        /* Factorial Not defined for Complex or for negative numbers */
+        if (mp_is_negative(x) || mp_is_complex(x))
+        {  /* Translators: Error displayed when attempted take the factorial of a negative or complex number */
+            mperr(_("Factorial is only defined for non-negative real numbers"));
+            mp_set_from_integer(0, z);
+            return;
+        }
+        MPNumber tmp = mp_new();
+        mpfr_t tmp2;
+        mpfr_init2(tmp2, PRECISION);
+        mp_set_from_integer(1, &tmp);
+        mp_add(&tmp, x, &tmp);
+
+        /* Factorial(x) = Gamma(x+1) - This is the formula used to calculate Factorial of positive real numbers.*/
+        mpfr_gamma(tmp2, mpc_realref(tmp.num), MPFR_RNDN);
+        mpc_set_fr(z->num, tmp2, MPC_RNDNN);
+        mp_clear(&tmp);
+        mpfr_clear(tmp2);
+    }
+    else
+    {
+        /* Convert to integer - if couldn't be converted then the factorial would be too big anyway */
+        ulong value = mp_to_unsigned_integer(x);
+        mpfr_fac_ui(mpc_realref(z->num), value, MPFR_RNDN);
+        mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    }
+}
+
+void
+mp_modulus_divide(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    if (!mp_is_integer(x) || !mp_is_integer(y))
+    {  /* Translators: Error displayed when attemping to do a modulus division on non-integer numbers */
+        mperr(_("Modulus division is only defined for integers"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+
+    MPNumber t1 = mp_new();
+    MPNumber t2 = mp_new();
+
+    mp_divide(x, y, &t1);
+    mp_floor(&t1, &t1);
+    mp_multiply(&t1, y, &t2);
+    mp_subtract(x, &t2, z);
+
+    mp_set_from_integer(0, &t1);
+    if ((mp_compare(y, &t1) < 0 && mp_compare(z, &t1) > 0) ||
+        (mp_compare(y, &t1) > 0 && mp_compare(z, &t1) < 0))
+        mp_add(z, y, z);
+
+    mp_clear(&t1);
+    mp_clear(&t2);
+}
+
+void
+mp_modular_exponentiation(const MPNumber *x, const MPNumber *y, const MPNumber *p, MPNumber *z)
+{
+    MPNumber base_value = mp_new();
+    MPNumber exp_value = mp_new();
+    MPNumber ans = mp_new();
+    MPNumber two = mp_new();
+    MPNumber tmp = mp_new();
+
+    mp_set_from_integer(1, &ans);
+    mp_set_from_integer(2, &two);
+    mp_abs(y, &exp_value);
+
+    if (mp_is_negative(y))
+        mp_reciprocal(x, &base_value);
+    else
+        mp_set_from_mp(x, &base_value);
+
+    while (!mp_is_zero(&exp_value))
+    {
+        mp_modulus_divide(&exp_value, &two, &tmp);
+
+        bool is_even = mp_is_zero(&tmp);
+        if (!is_even)
+        {
+            mp_multiply(&ans, &base_value, &ans);
+            mp_modulus_divide(&ans, p, &ans);
+        }
+        mp_multiply(&base_value, &base_value, &base_value);
+        mp_modulus_divide(&base_value, p, &base_value);
+        mp_divide_integer(&exp_value, 2, &exp_value);
+        mp_floor(&exp_value, &exp_value);
+    }
+
+    mp_modulus_divide(&ans, p, z);
+
+    mp_clear(&base_value);
+    mp_clear(&exp_value);
+    mp_clear(&ans);
+    mp_clear(&two);
+    mp_clear(&tmp);
+}
+
+void
+mp_xpowy(const MPNumber *x, const MPNumber *y, MPNumber *z)
+{
+    /* 0^-n invalid */
+    if (mp_is_zero(x) && mp_is_negative(y))
+    {   /* Translators: Error displayed when attempted to raise 0 to a negative exponent */
+        mperr(_("The power of zero is undefined for a negative exponent"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+
+    if (!mp_is_complex(x) && !mp_is_complex(y) && !mp_is_integer(y))
+    {
+        MPNumber reciprocal = mp_new();
+        mp_reciprocal(y, &reciprocal);
+        if (mp_is_integer(&reciprocal))
+        {
+            mp_root(x, mp_to_integer(&reciprocal), z);
+            mp_clear(&reciprocal);
+            return;
+        }
+        mp_clear(&reciprocal);
+    }
+
+    mpc_pow(z->num, x->num, y->num, MPC_RNDNN);
+}
+
+void
+mp_xpowy_integer(const MPNumber *x, long n, MPNumber *z)
+{
+    /* 0^-n invalid */
+    if (mp_is_zero(x) && n < 0)
+    {   /* Translators: Error displayed when attempted to raise 0 to a negative re_exponent */
+        mperr(_("The power of zero is undefined for a negative exponent"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+
+    mpc_pow_si(z->num, x->num, n, MPC_RNDNN);
+}
+
+void
+mp_erf(const MPNumber *x, MPNumber *z)
+{
+    if (mp_is_complex(x))
+    {   /* Translators: Error displayed when error function (erf) value is undefined */
+        mperr(_("The error function is only defined for real numbers"));
+        mp_set_from_integer(0, z);
+        return;
+    }
+
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpfr_erf(mpc_realref(z->num), mpc_realref(x->num), MPFR_RNDN);
+}
+
+void
+mp_zeta(const MPNumber *x, MPNumber *z)
+{
+    MPNumber one = mp_new();
+
+    mp_set_from_integer(1, &one);
+    if (mp_is_complex(x) || mp_compare(x, &one) == 0)
+    {   /* Translators: Error displayed when zeta function value is undefined */
+        mperr(_("The Riemann zeta function is only defined for real numbers ≠1"));
+        mp_set_from_integer(0, z);
+        mp_clear(&one);
+        return;
+    }
+
+    mpfr_set_zero(mpc_imagref(z->num), MPFR_RNDN);
+    mpfr_zeta(mpc_realref(z->num), mpc_realref(x->num), MPFR_RNDN);
+
+    mp_clear(&one);
+}
+
+/***********************************************************************/
+/**                          FACTORIZATION                            **/
+/***********************************************************************/
+
+/**
+ * mp_is_pprime uses the Miller-Rabin primality test to decide
+ * whether or not a number is probable prime.
+ * For special values of @n and @rounds it can be deterministic,
+ * but in general the probability of declaring @n as prime if it
+ * is not is at most 4^(-@rounds).
+ * @n has to be odd.
+ * Returns TRUE if @n is probable prime and FALSE otherwise.
+ */
+static bool
+mp_is_pprime(MPNumber *n, ulong rounds)<--- Parameter 'n' can be declared as pointer to const
+{
+    MPNumber tmp = mp_new();
+    MPNumber two = mp_new_from_unsigned_integer(2);
+    ulong l = 0;
+    bool is_pprime = TRUE;
+
+    /* Write t := n-1 = 2^l * q with q odd */
+    MPNumber q = mp_new();
+    MPNumber t = mp_new();
+    mp_add_integer(n, -1, &t);
+    mp_set_from_mp(&t, &q);
+    do
+    {
+        mp_divide_integer(&q, 2, &q);
+        mp_modulus_divide(&q, &two, &tmp);
+        l++;
+    } while (mp_is_zero(&tmp));
+
+    /* @rounds Miller-Rabin tests to bases a = 2,3,...,@rounds+1 */
+    MPNumber one = mp_new_from_unsigned_integer(1);
+    MPNumber a = mp_new_from_unsigned_integer(1);
+    MPNumber b = mp_new();
+
+    for (ulong i = 1; (i < mp_to_integer(&t)) && (i <= rounds+1); i++)
+    {
+        mp_add_integer(&a, 1, &a);
+        mp_modular_exponentiation(&a, &q, n, &b);
+        if (mp_compare(&one, &b) == 0 || mp_compare(&t, &b) == 0)
+        {
+            continue;
+        }
+
+        bool is_witness = FALSE;
+        for (long j = 1; j < l; j++)
+        {
+            mp_modular_exponentiation(&b, &two, n, &b);
+            if (mp_compare(&b, &t) == 0)
+            {
+                is_witness = TRUE;
+                break;
+            }
+        }
+
+        if (!is_witness)
+        {
+            is_pprime = FALSE;
+            break;
+        }
+    }
+
+    mp_clear(&t);
+    mp_clear(&q);
+    mp_clear(&a);
+    mp_clear(&b);
+    mp_clear(&one);
+    mp_clear(&two);
+    mp_clear(&tmp);
+
+    return is_pprime;
+}
+
+/**
+ * Sets z = gcd(a,b) where gcd(a,b) is the greatest common divisor of @a and @b.
+ */
+static void
+mp_gcd (const MPNumber *a, const MPNumber *b, MPNumber *z)
+{
+    MPNumber null = mp_new_from_unsigned_integer(0);
+    MPNumber t1 = mp_new();
+    MPNumber t2 = mp_new();
+
+    mp_set_from_mp(a, z);
+    mp_set_from_mp(b, &t2);
+
+    while (mp_compare(&t2, &null) != 0)
+    {
+        mp_set_from_mp(&t2, &t1);
+        mp_modulus_divide(z, &t2, &t2);
+        mp_set_from_mp(&t1, z);
+    }
+
+    mp_clear(&null);
+    mp_clear(&t1);
+    mp_clear(&t2);
+}
+
+/**
+ * mp_pollard_rho searches a divisor of @n using Pollard's rho algorithm.
+ * @i is the start value of the pseudorandom sequence which is generated
+ * by the polynomial x^2+1 mod n.
+ *
+ * Returns TRUE if a divisor was found and stores the divisor in z.
+ * Returns FALSE otherwise.
+ */
+static bool
+mp_pollard_rho (const MPNumber *n, ulong i, MPNumber *z)
+{
+    MPNumber one = mp_new_from_unsigned_integer(1);
+    MPNumber two = mp_new_from_unsigned_integer(2);
+    MPNumber x = mp_new_from_unsigned_integer(i);
+    MPNumber y = mp_new_from_unsigned_integer(2);
+    MPNumber d = mp_new_from_unsigned_integer(1);
+
+    while (mp_compare(&d, &one) == 0)
+    {
+        mp_modular_exponentiation(&x, &two, n, &x);
+        mp_add(&x, &one, &x);
+
+        mp_modular_exponentiation(&y, &two, n, &y);
+        mp_add(&y, &one, &y);
+
+        mp_modular_exponentiation(&y, &two, n, &y);
+        mp_add(&y, &one, &y);
+
+        mp_subtract(&x, &y,z);
+        mp_abs(z, z);
+        mp_gcd(z, n, &d);
+    }
+
+    if (mp_compare(&d, n) == 0)
+    {
+        mp_clear(&one);
+        mp_clear(&two);
+        mp_clear(&x);
+        mp_clear(&y);
+        mp_clear(&d);
+
+        return FALSE;
+    }
+    else
+    {
+        mp_set_from_mp(&d, z);
+
+        mp_clear(&one);
+        mp_clear(&two);
+        mp_clear(&x);
+        mp_clear(&y);
+        mp_clear(&d);
+
+        return TRUE;
+    }
+}
+
+/**
+ * find_big_prime_factor acts as driver function for mp_pollard_rho which
+ * is run as long as a prime factor is found.
+ * On success sets @z to a prime factor of @n.
+ */
+static void
+find_big_prime_factor (const MPNumber *n, MPNumber *z)
+{
+    MPNumber tmp = mp_new();
+    ulong i = 2;
+
+    while (TRUE)
+    {
+        while (mp_pollard_rho (n, i, &tmp) == FALSE)
+        {
+            i++;
+        }
+
+        if (!mp_is_pprime(&tmp, 50))
+        {
+            mp_divide(n, &tmp, &tmp);
+        }
+        else
+            break;
+    }
+
+    mp_set_from_mp(&tmp, z);
+    mp_clear(&tmp);
+}
+
+/**
+ * mp_factorize tries to factorize the value of @x.
+ * If @x < 2^64 it calls mp_factorize_unit64 which deals in integers
+ * and should be fast enough for most values.
+ * If @x > 2^64 the approach to find factors of @x is as follows:
+ *   - Try to divide @x by prime numbers 2,3,5,7,.. up to min(2^13, sqrt(x))
+ *   - Use Pollard rho to find prime factors > 2^13.
+ * Returns a pointer to a GList with all prime factors of @x which needs to
+ * be freed.
+ */
+GList*
+mp_factorize(const MPNumber *x)
+{
+    GList *list = NULL;
+    MPNumber *factor = g_slice_alloc0(sizeof(MPNumber));
+    mpc_init2(factor->num, PRECISION);
+
+    MPNumber value = mp_new();
+    mp_abs(x, &value);
+
+    if (mp_is_zero(&value))
+    {
+        mp_set_from_mp(&value, factor);
+        list = g_list_append(list, factor);
+        mp_clear(&value);
+        return list;
+    }
+
+    MPNumber tmp = mp_new();
+    mp_set_from_integer(1, &tmp);
+    if (mp_is_equal(&value, &tmp))
+    {
+        mp_set_from_mp(x, factor);
+        list = g_list_append(list, factor);
+        mp_clear(&value);
+        mp_clear(&tmp);
+        return list;
+    }
+
+    /* If value < 2^64-1, call for factorize_uint64 function which deals in integers */
+    uint64_t num = 1;
+    num = num << 63;
+    num += (num - 1);
+    MPNumber int_max = mp_new();
+    mp_set_from_unsigned_integer(num, &int_max);
+    if (mp_is_less_equal(x, &int_max))
+    {
+        list = mp_factorize_unit64(mp_to_unsigned_integer(&value));
+        if (mp_is_negative(x))
+            mp_invert_sign(list->data, list->data);
+        mp_clear(&value);
+        mp_clear(&tmp);
+        mp_clear(&int_max);
+        return list;
+    }
+
+    MPNumber divisor = mp_new_from_unsigned_integer(2);
+    while (TRUE)
+    {
+        mp_divide(&value, &divisor, &tmp);
+        if (mp_is_integer(&tmp))
+        {
+            mp_set_from_mp(&tmp, &value);
+            mp_set_from_mp(&divisor, factor);
+            list = g_list_append(list, factor);
+            factor = g_slice_alloc0(sizeof(MPNumber));
+            mpc_init2(factor->num, PRECISION);
+        }
+        else
+            break;
+    }
+
+    mp_set_from_integer(3, &divisor);
+
+    MPNumber root = mp_new();
+    mp_sqrt(&value, &root);
+    uint64_t max_trial_division = (uint64_t) (1 << 10);
+    uint64_t iter = 0;
+    while (mp_is_less_equal(&divisor, &root) && (iter++ < max_trial_division))
+    {
+        mp_divide(&value, &divisor, &tmp);
+        if (mp_is_integer(&tmp))
+        {
+            mp_set_from_mp(&tmp, &value);
+            mp_sqrt(&value, &root);
+            mp_set_from_mp(&divisor, factor);
+            list = g_list_append(list, factor);
+            factor = g_slice_alloc0(sizeof(MPNumber));
+            mpc_init2(factor->num, PRECISION);
+        }
+        else
+        {
+            mp_add_integer(&divisor, 2, &divisor);
+        }
+    }
+
+    while (!mp_is_pprime(&value, 50))
+    {
+        find_big_prime_factor (&value, &divisor);
+
+        mp_divide(&value, &divisor, &tmp);
+        if (mp_is_integer(&tmp))
+        {
+            mp_set_from_mp(&tmp, &value);
+            mp_set_from_mp(&divisor, factor);
+            list = g_list_append(list, factor);
+            factor = g_slice_alloc0(sizeof(MPNumber));
+            mpc_init2(factor->num, PRECISION);
+        }
+    }
+
+    mp_set_from_integer(1, &tmp);
+    if (mp_is_greater_than(&value, &tmp))
+    {
+        mp_set_from_mp(&value, factor);
+        list = g_list_append(list, factor);
+    }
+    else
+    {
+        mpc_clear(factor->num);
+        g_slice_free(MPNumber, factor);
+    }
+
+    if (mp_is_negative(x))
+        mp_invert_sign(list->data, list->data);
+
+    mp_clear(&value);
+    mp_clear(&tmp);
+    mp_clear(&divisor);
+    mp_clear(&root);
+
+    return list;
+}
+
+GList*
+mp_factorize_unit64(uint64_t n)
+{
+    GList *list = NULL;
+    MPNumber *factor = g_slice_alloc0(sizeof(MPNumber));
+    mpc_init2(factor->num, PRECISION);
+
+    MPNumber tmp = mp_new();
+    mp_set_from_unsigned_integer(2, &tmp);
+    while (n % 2 == 0)
+    {
+        n /= 2;
+        mp_set_from_mp(&tmp, factor);
+        list = g_list_append(list, factor);
+        factor = g_slice_alloc0(sizeof(MPNumber));
+        mpc_init2(factor->num, PRECISION);
+    }
+
+    for (uint64_t divisor = 3; divisor <= n / divisor; divisor +=2)
+    {
+        while (n % divisor == 0)
+        {
+            n /= divisor;
+            mp_set_from_unsigned_integer(divisor, factor);
+            list = g_list_append(list, factor);
+            factor = g_slice_alloc0(sizeof(MPNumber));
+            mpc_init2(factor->num, PRECISION);
+        }
+    }
+
+    if (n > 1)
+    {
+        mp_set_from_unsigned_integer(n, factor);
+        list = g_list_append(list, factor);
+    }
+    else
+    {
+        mpc_clear(factor->num);
+        g_slice_free(MPNumber, factor);
+    }
+    mp_clear(&tmp);
+
+    return list;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/43.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/43.html new file mode 100644 index 0000000..be08d9e --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/43.html @@ -0,0 +1,2749 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <assert.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "parser.h"
+#include "parserfunc.h"
+#include "mp-equation.h"
+
+/* Converts LexerTokenType to Precedence value. */
+static guint
+p_get_precedence(LexerTokenType type)
+{
+    /* WARNING: This function doesn't work for Unary Plus and Unary Minus. Use their precedence directly while inserting them in tree. */
+    if(type == T_ADD
+     ||type == T_SUBTRACT)
+        return P_AddSubtract;
+    if(type == T_MULTIPLY)
+        return P_Multiply;
+    if(type == T_MOD)
+        return P_Mod;
+    if(type == T_DIV)
+        return P_Divide;
+    if(type == T_NOT)
+        return P_Not;
+    if(type == T_ROOT
+     ||type == T_ROOT_3
+     ||type == T_ROOT_4)
+        return P_Root;
+    if(type == T_FUNCTION)
+        return P_Function;
+    if(type == T_AND
+     ||type == T_OR
+     ||type == T_XOR)
+        return P_Boolean;
+    if(type == T_PERCENTAGE)
+        return P_Percentage;
+    if(type == T_POWER)
+        return P_Power;
+    if(type == T_FACTORIAL)
+        return P_Factorial;
+    if(type == T_NUMBER
+     ||type == T_VARIABLE)
+        return P_NumberVariable;
+    return P_Unknown;
+}
+
+/* Return associativity of specific token type from precedence. */
+static Associativity
+p_get_associativity_p(Precedence type)
+{
+    if(type == P_Boolean
+     ||type == P_Divide
+     ||type == P_Mod
+     ||type == P_Multiply
+     ||type == P_AddSubtract)
+        return LEFT_ASSOCIATIVE;
+    if(type == P_Power)
+        return RIGHT_ASSOCIATIVE;
+    /* For all remaining / non-associative operators, return Left Associativity. */
+    return LEFT_ASSOCIATIVE;
+}
+
+/* Return associativity of specific token by converting it to precedence first. */
+static Associativity
+p_get_associativity(LexerToken* token)
+{
+    return p_get_associativity_p(p_get_precedence(token->token_type));
+}
+
+/* Generate precedence for a node from precedence value. Includes depth_level. */
+static guint
+p_make_precedence_p(ParserState* state, Precedence p)<--- Parameter 'state' can be declared as pointer to const
+{
+    return (p + (state->depth_level * P_Depth));
+}
+
+/* Generate precedence for a node from lexer token type. Includes depth_level. */
+static guint
+p_make_precedence_t(ParserState* state, LexerTokenType type)<--- Parameter 'state' can be declared as pointer to const
+{
+    return (p_get_precedence(type) + (state->depth_level * P_Depth));
+}
+
+/* Allocate and create a new node. */
+static ParseNode*
+p_create_node(ParserState* state, LexerToken* token, guint precedence, Associativity associativity, void* value, void* (*function)(ParseNode*))
+{
+    ParseNode* new;
+    new = (ParseNode*) malloc(sizeof(ParseNode));
+    assert(new != NULL);
+    new->parent = NULL;
+    new->left = NULL;
+    new->right = NULL;
+    new->token = token;
+    new->precedence = precedence;
+    new->associativity = associativity;
+    new->value = value;
+    new->state = state;
+    new->evaluate = function;
+    return new;
+}
+
+/* Compares two nodes to decide, which will be parent and which willbe child. */
+static gint
+p_cmp_nodes(ParseNode* left, ParseNode* right)<--- Parameter 'left' can be declared as pointer to const<--- Parameter 'right' can be declared as pointer to const
+{
+    /* Return values.
+       1 = right goes up (near root) in parse tree.
+       0 = left  goes up (near root) in parse tree.
+    */
+    if(left == NULL)
+        return 0;
+    if(left->precedence > right->precedence)
+    {
+        return 1;
+    }
+    else if(left->precedence < right->precedence)
+    {
+        return 0;
+    }
+    else
+    {
+        if(right->associativity == RIGHT_ASSOCIATIVE)
+        {
+            return 0;
+        }
+        else
+        {
+            return 1;
+        }
+    }
+}
+
+/* Unified interface (unary and binary nodes) to insert node into parse tree. */
+static void
+p_insert_into_tree_all(ParserState* state, ParseNode* node, guint unary_function)
+{
+    if(state->root == NULL)
+    {
+        state->root = node;
+        state->right_most = state->root;
+        return;
+    }
+    ParseNode* tmp = state->right_most;
+    while(p_cmp_nodes(tmp, node))
+        tmp = tmp->parent;
+    if(unary_function)
+    {
+        /* If tmp is null, that means, we have to insert new node at root. */
+        if(tmp == NULL)
+        {
+            node->right = state->root;
+            node->right->parent = node;
+
+            state->root = node;
+        }
+        else
+        {
+            node->right = tmp->right;
+            if(node->right)
+                node->right->parent = node;
+
+            tmp->right = node;
+            if(tmp->right)
+                tmp->right->parent = tmp;
+
+        }
+        state->right_most = node;
+        while(state->right_most->right != NULL)
+            state->right_most = state->right_most->right;
+    }
+    else
+    {
+        /* If tmp is null, that means, we have to insert new node at root. */
+        if(tmp == NULL)
+        {
+            node->left = state->root;
+            node->left->parent = node;
+
+            state->root = node;
+        }
+        else
+        {
+            node->left = tmp->right;
+            if(node->left)
+                node->left->parent = node;
+
+            tmp->right = node;
+            if(tmp->right)
+                tmp->right->parent = tmp;
+
+        }
+        state->right_most = node;
+    }
+}
+
+/* Insert binary node into the parse tree. */
+static void
+p_insert_into_tree(ParserState* state, ParseNode* node)
+{
+    p_insert_into_tree_all(state, node, 0);
+}
+
+/* Insert unary node into the parse tree. */
+static void
+p_insert_into_tree_unary(ParserState* state, ParseNode* node)
+{
+    p_insert_into_tree_all(state, node, 1);
+}
+
+/* Recursive call to free every node of parse-tree. */
+static void
+p_destroy_all_nodes(ParseNode* node)
+{
+    if(node == NULL)
+        return;
+    p_destroy_all_nodes(node->left);
+    p_destroy_all_nodes(node->right);
+    /* Don't call free for tokens, as they are allocated and freed in lexer. */
+    /* WARNING: If node->value is freed elsewhere, please assign it NULL before calling p_destroy_all_nodes(). */
+    if(node->value)
+        free(node->value);
+    free(node);
+}
+
+/* Create parser state. */
+ParserState*
+p_create_parser(const gchar* input, MPEquationOptions* options)
+{
+    ParserState* state;
+    state = (ParserState*) malloc(sizeof(ParserState));
+    assert(state != NULL);
+    state->lexer = l_create_lexer(input, state);
+    state->root = NULL;
+    state->depth_level = 0;
+    state->right_most = NULL;
+    state->options = options;
+    state->error = 0;
+    state->error_token = NULL;
+    return state;
+}
+
+static guint statement (ParserState*);
+/* Start parsing input string. And call evaluate on success. */
+guint
+p_parse(ParserState* state)
+{
+    guint ret;
+    LexerToken* token;
+    MPNumber* ans;
+    l_insert_all_tokens(state->lexer);
+    ret = statement(state);
+    token = l_get_next_token(state->lexer);
+    if(token->token_type == T_ASSIGN)
+    {
+        token = l_get_next_token(state->lexer);
+        if(token->token_type != PL_EOS)
+        {
+        /* Full string is not parsed. */
+            if(!state->error)
+                set_error(state, PARSER_ERR_INVALID, token->string);
+            return PARSER_ERR_INVALID;
+        }
+    }
+    if(token->token_type != PL_EOS)
+    {
+        /* Full string is not parsed. */
+        if(!state->error)
+            set_error(state, PARSER_ERR_INVALID, token->string);
+        return PARSER_ERR_INVALID;
+    }
+    if(ret == 0)
+        /* Input can't be parsed with grammar. */
+        return PARSER_ERR_INVALID;
+    ans = (MPNumber *) (*(state->root->evaluate))(state->root);
+    if(ans)
+    {
+        state->ret = mp_new();
+        mp_set_from_mp(ans, &state->ret);
+        mp_free(ans);
+        return PARSER_ERR_NONE;
+    }
+    return PARSER_ERR_INVALID;
+}
+
+/* Destroy parser state. */
+void
+p_destroy_parser(ParserState* state)
+{
+    /* If state has a parse tree, destroy it first. */
+    if(state->root)
+    {
+        p_destroy_all_nodes(state->root);
+    }
+    l_destroy_lexer(state->lexer);
+    free(state);
+}
+
+/* LL (*) parser. Lookahead count depends on tokens. Handle with care. :P */
+
+static guint expression(ParserState* state);
+static guint expression_1(ParserState* state);
+static guint expression_2(ParserState* state);
+static guint unit(ParserState* state);
+static guint variable(ParserState* state);
+static guint term(ParserState* state);
+static guint term_2(ParserState* state);
+
+/* Helping function to p_check_variable. */
+static gchar*
+utf8_next_char(const gchar* c)
+{
+    c++;
+    while((*c & 0xC0) == 0x80)
+        c++;
+    return (gchar *)c;
+}
+
+/* Check if string "name" is a valid variable for given ParserState. It is the same code, used to get the value of variable in parserfunc.c. */
+static gboolean
+p_check_variable(ParserState* state, gchar* name)
+{
+    gint result = 0;
+
+    const gchar *c, *next;
+    gchar *buffer;
+    MPNumber temp;
+
+    if(!(state->get_variable))
+    {
+        return FALSE;
+    }
+    temp = mp_new();
+    /* If defined, then get the variable */
+    if((*(state->get_variable))(state, name, &temp))
+    {
+        mp_clear(&temp);
+        return TRUE;
+    }
+
+    /* If has more than one character then assume a multiplication of variables */
+    if(utf8_next_char(name)[0] != '\0')
+    {
+        result = 1;
+        buffer = (gchar*) malloc(sizeof(gchar) * strlen(name));
+        for(c = name; *c != '\0'; c = next)
+        {
+            next = utf8_next_char(c);
+            snprintf(buffer, (size_t) (next - c + 1), "%s", c);
+            if(!(*(state->get_variable))(state, buffer, &temp))
+            {
+                result = 0;
+                break;
+            }
+        }
+        free(buffer);
+    }
+    mp_clear(&temp);
+    if(!result)
+    {
+        return FALSE;
+    }
+    return TRUE;
+}
+
+static guint
+statement(ParserState* state)
+{
+    LexerToken* token;
+    LexerToken* token_old;
+    ParseNode* node;
+    token = l_get_next_token(state->lexer);
+    if(token->token_type == T_VARIABLE)
+    {
+        token_old = token;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_ASSIGN)
+        {
+            /* VARIABLE = expression. */
+
+            node = p_create_node(state, token_old, p_make_precedence_p(state, P_NumberVariable), p_get_associativity(token_old), NULL, pf_none);
+            p_insert_into_tree(state, node);
+
+            node = p_create_node(state, token, 0, p_get_associativity(token), NULL, pf_set_var);
+            p_insert_into_tree(state, node);
+
+            if(!expression(state))
+                return 0;
+            return 1;
+        }
+        else if(token->token_type == T_IN)
+        {
+            /* UNIT in UNIT. */
+            l_roll_back(state->lexer);
+            l_roll_back(state->lexer);
+            if(!unit(state))
+                return 0;
+            l_get_next_token(state->lexer);
+
+            node = p_create_node(state, token, 0, p_get_associativity(token), NULL, pf_convert_1);
+            p_insert_into_tree(state, node);
+
+            if(!unit(state))
+                return 0;
+            return 1;
+        }
+        else if(token->token_type == T_SUP_NUMBER)
+        {
+            token = l_get_next_token(state->lexer);
+            if(token->token_type == T_IN)
+            {
+                /* UNIT in UNIT */
+                l_roll_back(state->lexer);
+                l_roll_back(state->lexer);
+                l_roll_back(state->lexer);
+                if(!unit(state))
+                    return 0;
+                l_get_next_token(state->lexer);
+
+                node = p_create_node(state, token, 0, p_get_associativity(token), NULL, pf_convert_1);
+                p_insert_into_tree(state, node);
+
+                if(!unit(state))
+                    return 0;
+                return 1;
+            }
+            else
+            {
+                l_roll_back(state->lexer);
+                l_roll_back(state->lexer);
+                l_roll_back(state->lexer);
+                if(!expression(state))
+                    return 0;
+                return 1;
+            }
+        }
+        else
+        {
+            l_roll_back(state->lexer);
+            l_roll_back(state->lexer);
+            if(!expression(state))
+                return 0;
+            return 1;
+        }
+    }
+    else if(token->token_type == T_NUMBER)
+    {
+        token_old = token;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_VARIABLE)
+        {
+            token = l_get_next_token(state->lexer);
+            if(token->token_type == T_IN)
+            {
+                /* NUMBER UNIT in UNIT */
+                l_roll_back(state->lexer);
+                l_roll_back(state->lexer);
+
+                node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token), NULL, pf_constant);
+                p_insert_into_tree(state, node);
+
+                if(!unit(state))
+                    return 0;
+                token = l_get_next_token(state->lexer);
+
+                node = p_create_node(state, token, 0, p_get_associativity(token), NULL, pf_convert_number);
+                p_insert_into_tree(state, node);
+
+                if(!unit(state))
+                    return 0;
+                return 1;
+            }
+            else if(token->token_type == T_SUP_NUMBER)
+            {
+                token = l_get_next_token(state->lexer);
+                if(token->token_type == T_IN)
+                {
+                    /* NUMBER UNIT in UNIT */
+                    l_roll_back(state->lexer);
+                    l_roll_back(state->lexer);
+                    l_roll_back(state->lexer);
+
+                    node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token), NULL, pf_constant);
+                    p_insert_into_tree(state, node);
+
+                    if(!unit(state))
+                        return 0;
+                    token = l_get_next_token(state->lexer);
+
+                    node = p_create_node(state, token, 0, p_get_associativity(token), NULL, pf_convert_number);
+                    p_insert_into_tree(state, node);
+
+                    if(!unit(state))
+                        return 0;
+                    return 1;
+                }
+                else
+                {
+                    l_roll_back(state->lexer);
+                    l_roll_back(state->lexer);
+                    l_roll_back(state->lexer);
+                    l_roll_back(state->lexer);
+                    if(!expression(state))
+                        return 0;
+                    return 1;
+                }
+            }
+            else
+            {
+                l_roll_back(state->lexer);
+                l_roll_back(state->lexer);
+                l_roll_back(state->lexer);
+                if(!expression(state))
+                    return 0;
+                return 1;
+            }
+        }
+        else
+        {
+            l_roll_back(state->lexer);
+            l_roll_back(state->lexer);
+            if(!expression(state))
+                return 0;
+            return 1;
+        }
+    }
+    else
+    {
+        l_roll_back(state->lexer);
+        if(!expression(state))
+            return 0;
+        return 1;
+    }
+}
+
+static guint
+unit(ParserState* state)
+{
+    LexerToken* token;
+    LexerToken* token_old;
+    ParseNode* node;
+    token = l_get_next_token(state->lexer);
+    if(token->token_type == T_VARIABLE)
+    {
+        token_old = token;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_SUP_NUMBER)
+        {
+            /* VARIABLE POWER */
+
+            node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token_old), pf_make_unit(token_old->string, token->string), pf_none);
+            p_insert_into_tree(state, node);
+
+            return 1;
+        }
+        else
+        {
+            l_roll_back(state->lexer);
+            /* VARIABLE */
+
+            node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token_old), NULL, pf_none);
+            p_insert_into_tree(state, node);
+
+            return 1;
+        }
+    }
+    else
+    {
+        l_roll_back(state->lexer);
+        return 0;
+    }
+}
+
+static guint
+expression(ParserState* state)
+{
+    if(!expression_1(state))
+        return 0;
+    if(!expression_2(state))
+        return 0;
+    return 1;
+}
+
+static guint
+expression_1(ParserState* state)
+{
+    LexerToken* token;
+    ParseNode* node;
+    token = l_get_next_token(state->lexer);
+    if(token->token_type == PL_EOS
+     ||token->token_type == T_ASSIGN)
+    {
+        l_roll_back(state->lexer);
+        return 0;
+    }
+    if(token->token_type == T_L_R_BRACKET)
+    {
+        state->depth_level++;
+        if(!expression(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_R_R_BRACKET)
+        {
+            state->depth_level--;
+            return 1;
+        }
+        else
+        //Expected ")" here...
+            return 0;
+    }
+    else if(token->token_type == T_L_S_BRACKET)
+    {
+        state->depth_level++;
+
+        /* Give round, preference of P_Unknown aka 0, to keep it on the top of expression. */
+
+        node = p_create_node(state, token, p_make_precedence_p(state, P_Unknown), p_get_associativity(token), NULL, pf_do_round);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_R_S_BRACKET)
+        {
+            state->depth_level--;
+            return 1;
+        }
+        else
+        //Expected "]" here...
+            return 0;
+    }
+    else if(token->token_type == T_L_C_BRACKET)
+    {
+        state->depth_level++;
+
+        /* Give fraction, preference of P_Unknown aka 0, to keep it on the top of expression. */
+
+        node = p_create_node(state, token, p_make_precedence_p(state, P_Unknown), p_get_associativity(token), NULL, pf_do_fraction);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_R_C_BRACKET)
+        {
+            state->depth_level--;
+            return 1;
+        }
+        else
+        //Expected "}" here...
+            return 0;
+    }
+    else if(token->token_type == T_ABS)
+    {
+        state->depth_level++;
+
+        /* Give abs, preference of P_Unknown aka 0, to keep it on the top of expression. */
+
+        node = p_create_node(state, token, p_make_precedence_p(state, P_Unknown), p_get_associativity(token), NULL, pf_do_abs);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_ABS)
+        {
+            state->depth_level--;
+            return 1;
+        }
+        else
+        //Expected "|" here...
+            return 0;
+    }
+    else if(token->token_type == T_NOT)
+    {
+        /* NOT expression */
+
+        node = p_create_node(state, token, p_make_precedence_p(state, P_Not), p_get_associativity(token), NULL, pf_do_not);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_NUMBER)
+    {
+        /* NUMBER */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_constant);
+        p_insert_into_tree(state, node);
+
+        token = l_get_next_token(state->lexer);
+        l_roll_back(state->lexer);
+
+        if(token->token_type == T_FUNCTION
+         ||token->token_type == T_VARIABLE
+         ||token->token_type == T_SUB_NUMBER
+         ||token->token_type == T_ROOT
+         ||token->token_type == T_ROOT_3
+         ||token->token_type == T_ROOT_4)
+        {
+            /* NUMBER variable. */
+
+            node = p_create_node(state, NULL, p_make_precedence_p(state, P_Multiply), p_get_associativity_p(P_Multiply), NULL, pf_do_multiply);
+            p_insert_into_tree(state, node);
+
+            if(!variable(state))
+                return 0;
+            else
+                return 1;
+        }
+        else
+        {
+            return 1;
+        }
+    }
+    else if(token->token_type == T_L_FLOOR)
+    {
+        state->depth_level++;
+        /* Give floor, preference of P_Unknown aka 0, to keep it on the top of expression. */
+
+        node = p_create_node(state, NULL, p_make_precedence_p(state, P_Unknown), p_get_associativity_p(P_Unknown), NULL, pf_do_floor);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_R_FLOOR)
+        {
+            state->depth_level--;
+            return 1;
+        }
+        else
+        //Expected ⌋ here...
+            return 0;
+    }
+    else if(token->token_type == T_L_CEILING)
+    {
+        state->depth_level++;
+        /* Give ceiling, preference of P_Unknown aka 0, to keep it on the top of expression. */
+
+        node = p_create_node(state, NULL, p_make_precedence_p(state, P_Unknown), p_get_associativity_p(P_Unknown), NULL, pf_do_ceiling);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_R_CEILING)
+        {
+            state->depth_level--;
+            return 1;
+        }
+        else
+        //Expected ⌉ here...
+            return 0;
+    }
+    else if(token->token_type == T_SUBTRACT)
+    {
+        /* UnaryMinus expression */
+
+        node = p_create_node(state, token, p_make_precedence_p(state, P_UnaryMinus), p_get_associativity_p(P_UnaryMinus), NULL, pf_unary_minus);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_ADD)
+    {
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_NUMBER)
+        {
+            /* UnaryPlus expression */
+            /* Ignore T_ADD. It is not required. */
+
+            node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_constant);
+            p_insert_into_tree(state, node);
+            return 1;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+    else
+    {
+        l_roll_back(state->lexer);
+        if(!variable(state))
+            return 0;
+        else
+            return 1;
+    }
+}
+
+static guint
+expression_2(ParserState* state)
+{
+    LexerToken* token;
+    ParseNode* node;
+    token = l_get_next_token(state->lexer);
+    if(token->token_type == T_L_R_BRACKET)
+    {
+        /* expression "(" expression ")" */
+
+        node = p_create_node(state, NULL, p_make_precedence_p(state, P_Multiply), p_get_associativity_p(P_Multiply), NULL, pf_do_multiply);
+        p_insert_into_tree(state, node);
+
+        state->depth_level++;
+        if(!expression(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_R_R_BRACKET)
+        {
+            state->depth_level--;
+            if(!expression_2(state))
+                return 0;
+            return 1;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+    else if(token->token_type == T_POWER)
+    {
+        /* expression "^" expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_x_pow_y);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_SUP_NUMBER)
+    {
+        /* expression T_SUP_NUMBER */
+
+        node = p_create_node(state, NULL, p_make_precedence_p(state, P_Power), p_get_associativity_p(P_Power), NULL, pf_do_x_pow_y_int);
+        p_insert_into_tree(state, node);
+
+        node = p_create_node(state, token, p_make_precedence_p(state, P_NumberVariable), p_get_associativity_p(P_NumberVariable), NULL, pf_none);
+        p_insert_into_tree(state, node);
+
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_NSUP_NUMBER)
+    {
+        /* expression T_NSUP_NUMBER */
+
+        node = p_create_node(state, NULL, p_make_precedence_p(state, P_Power), p_get_associativity_p(P_Power), NULL, pf_do_x_pow_y_int);
+        p_insert_into_tree(state, node);
+
+        node = p_create_node(state, token, p_make_precedence_p(state, P_NumberVariable), p_get_associativity_p(P_NumberVariable), NULL, pf_none);
+        p_insert_into_tree(state, node);
+
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_FACTORIAL)
+    {
+        /* expression T_FACTORIAL */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_factorial);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_MULTIPLY)
+    {
+        /* expression T_MULTIPLY expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_multiply);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_PERCENTAGE)
+    {
+        /* expression % */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_percent);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_AND)
+    {
+        /* expression T_AND expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_and);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_OR)
+    {
+        /* expression T_OR expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_or);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_XOR)
+    {
+        /* expression T_XOR expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_xor);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_DIV)
+    {
+        /* expression T_DIV expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_divide);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_MOD)
+    {
+        /* expression T_MOD expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_mod);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_ADD)
+    {
+        /* expression T_ADD expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_add);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_PERCENTAGE)
+        {
+            //FIXME: This condition needs to be verified for all cases.. :(
+            if(node->right->precedence > P_Percentage)
+            {
+                node->precedence = P_Percentage;
+                node->evaluate = pf_do_add_percent;
+                return 1;
+            }
+            else
+            {
+                /* Assume '%' to be part of 'expression T_PERCENTAGE' statement. */
+                l_roll_back(state->lexer);
+                if(!expression_2(state))
+                    return 1;
+            }
+        }
+        else
+        {
+            l_roll_back(state->lexer);
+        }
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_SUBTRACT)
+    {
+        /* expression T_SUBTRACT expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_subtract);
+        p_insert_into_tree(state, node);
+
+        if(!expression_1(state))
+            return 0;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_PERCENTAGE)
+        {
+            //FIXME: This condition needs to be verified for all cases.. :(
+            if(node->right->precedence > P_Percentage)
+            {
+                node->precedence = P_Percentage;
+                node->evaluate = pf_do_subtract_percent;
+                return 1;
+            }
+            else
+            {
+                /* Assume '%' to be part of 'expression T_PERCENTAGE' statement. */
+                l_roll_back(state->lexer);
+                if(!expression_2 (state))
+                    return 1;
+            }
+        }
+        else
+        {
+            l_roll_back(state->lexer);
+        }
+        if(!expression_2(state))
+            return 0;
+        return 1;
+    }
+    else
+    {
+        l_roll_back(state->lexer);
+        return 1;
+    }
+}
+
+static guint
+variable(ParserState* state)
+{
+    LexerToken* token;
+    LexerToken* token_old;
+    ParseNode* node;
+    token = l_get_next_token(state->lexer);
+
+    if(token->token_type == T_FUNCTION)
+    {
+        token_old = token;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_SUP_NUMBER)
+        {
+            /* FUNCTION SUP_NUMBER expression */
+            /* Pass power as void * value. That will be taken care in pf_apply_func_with_powre. */
+
+            node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token_old), token, pf_apply_func_with_power);
+            p_insert_into_tree_unary(state, node);
+
+            if(!expression(state))
+                return 0;
+            return 1;
+        }
+        else if(token->token_type == T_NSUP_NUMBER)
+        {
+            /* FUNCTION NSUP_NUMBER expression */
+            /* Pass power as void * value. That will be taken care in pf_apply_func_with_npowre. */
+
+            node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token_old), token, pf_apply_func_with_npower);
+            p_insert_into_tree_unary(state, node);
+
+            if(!expression(state))
+                return 0;
+            return 1;
+        }
+        else
+        {
+            l_roll_back(state->lexer);
+            /* FUNCTION expression */
+
+            node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token_old), NULL, pf_apply_func);
+            p_insert_into_tree_unary(state, node);
+
+            if(!expression(state))
+                return 0;
+            return 1;
+        }
+    }
+    else if(token->token_type == T_SUB_NUMBER)
+    {
+        token_old = token;
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_ROOT)
+        {
+            /* SUB_NUM ROOT expression */
+            /* Pass SUB_NUM as void* value in node. pf_do_nth_root will take care of it. */
+
+            node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), token_old, pf_do_nth_root);
+            p_insert_into_tree_unary(state, node);
+
+            if(!expression (state))
+                return 0;
+            return 1;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+    else if(token->token_type == T_ROOT)
+    {
+        /* ROOT expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_sqrt);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_ROOT_3)
+    {
+        /* ROOT_3 expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_root_3);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_ROOT_4)
+    {
+        /* ROOT_4 expression */
+
+        node = p_create_node(state, token, p_make_precedence_t(state, token->token_type), p_get_associativity(token), NULL, pf_do_root_4);
+        p_insert_into_tree_unary(state, node);
+
+        if(!expression(state))
+            return 0;
+        return 1;
+    }
+    else if(token->token_type == T_VARIABLE)
+    {
+        l_roll_back(state->lexer);
+        //TODO: unknown function ERROR for (T_VARIABLE T_SUP_NUMBER expression).
+        if(!term(state))
+            return 0;
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+static guint
+term(ParserState* state)
+{
+    LexerToken* token;
+    LexerToken* token_old;
+    ParseNode* node;
+    token = l_get_next_token(state->lexer);
+    if(token->token_type == T_VARIABLE)
+    {
+        token_old = token;
+        /* Check if the token is a valid variable or not. */
+        if(!p_check_variable(state, token->string))
+        {
+            set_error(state, PARSER_ERR_UNKNOWN_VARIABLE, token->string);
+            return 0;
+        }
+        token = l_get_next_token(state->lexer);
+        if(token->token_type == T_SUP_NUMBER)
+        {
+            /* VARIABLE SUP_NUMBER */
+            /* Pass power as void* value. pf_get_variable_with_power will take care of it. */
+
+            node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token_old), token, pf_get_variable_with_power);
+            p_insert_into_tree(state, node);
+
+        }
+        else
+        {
+            l_roll_back(state->lexer);
+            /* VARIABLE */
+
+            node = p_create_node(state, token_old, p_make_precedence_t(state, token_old->token_type), p_get_associativity(token_old), NULL, pf_get_variable);
+            p_insert_into_tree(state, node);
+
+        }
+        if(!term_2(state))
+            return 0;
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+static guint
+term_2(ParserState* state)
+{
+    LexerToken* token;
+    ParseNode* node;
+    token = l_get_next_token(state->lexer);
+    l_roll_back(state->lexer);
+    if(token->token_type == PL_EOS
+     ||token->token_type == T_ASSIGN)
+    {
+        return 1;
+    }
+    if(token->token_type == T_VARIABLE)
+    {
+        /* Insert multiply in between two distinct (variable). */
+
+        node = p_create_node(state, NULL, p_make_precedence_p(state, P_Multiply), p_get_associativity_p(P_Multiply), NULL, pf_do_multiply);
+        p_insert_into_tree(state, node);
+
+        if(!term(state))
+            return 0;
+        return 1;
+    }
+    else
+    {
+        return 1;
+    }
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/44.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/44.html new file mode 100644 index 0000000..1569463 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/44.html @@ -0,0 +1,2203 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
+925
+926
+927
+928
+929
+930
+931
+932
+933
+934
+935
+936
+937
+938
+939
+940
+941
+942
+943
+944
+945
+946
+947
+948
+949
+950
+951
+952
+953
+954
+955
+956
+957
+958
+959
+960
+961
+962
+963
+964
+965
+966
+967
+968
+969
+970
+971
#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "parser.h"
+#include "parserfunc.h"
+
+/* Register error variables in ParserState structure. */
+void
+set_error(ParserState* state, gint errorno, const gchar *token)
+{
+    state->error = errorno;
+    if(token)
+        state->error_token = strdup(token);
+}
+
+/* Unused function pointer. This won't be called anytime. */
+void*
+pf_none(ParseNode* self)
+{
+    return NULL;
+}
+
+/* Set variable. */
+void*
+pf_set_var(ParseNode* self)
+{
+    MPNumber* val;
+    val = (MPNumber *) (*(self->right->evaluate))(self->right);
+    if(!val || !(self->state->set_variable))
+    {
+        if(val)
+            mp_free(val);
+        return NULL;
+    }
+    (*(self->state->set_variable))(self->state, self->left->token->string, val);
+    return val;
+}
+
+/* Converts Number from one unit to other. */
+void*
+pf_convert_number(ParseNode* self)
+{
+    gchar* from;
+    gchar* to;
+    gint free_from = 0;
+    gint free_to = 0;
+    MPNumber tmp = mp_new();
+    MPNumber* ans = mp_new_ptr();
+    if(self->left->value)
+    {
+        from = (gchar*) self->left->value;
+        free_from = 1;
+    }
+    else
+        from = self->left->token->string;
+    if(self->right->value)
+    {
+        to = (gchar*) self->right->value;
+        free_to = 1;
+    }
+    else
+        to = self->right->token->string;
+
+    if(mp_set_from_string(self->left->left->token->string, self->state->options->base, &tmp) != 0)
+    {
+        mp_free(ans);
+        ans = NULL;
+        goto END_PF_CONVERT_NUMBER;
+    }
+    if(!(self->state->convert))
+    {
+        mp_free(ans);
+        ans = NULL;
+        goto END_PF_CONVERT_NUMBER;
+    }
+    if(!(*(self->state->convert))(self->state, &tmp, from, to, ans))
+    {
+        set_error(self->state, PARSER_ERR_UNKNOWN_CONVERSION, NULL);
+        mp_free(ans);
+        ans = NULL;
+    }
+END_PF_CONVERT_NUMBER:
+    if(free_from)
+    {
+        g_free(self->left->value);
+        self->left->value = NULL;
+    }
+    if(free_to)
+    {
+        g_free(self->right->value);
+        self->right->value = NULL;
+    }
+    mp_clear(&tmp);
+    return ans;
+}
+
+/* Conversion rate. */
+void*
+pf_convert_1(ParseNode* self )
+{
+    gchar* from;
+    gchar* to;
+    gint free_from = 0;
+    gint free_to = 0;
+    MPNumber tmp = mp_new();
+    MPNumber* ans = mp_new_ptr();
+    if(self->left->value)
+    {
+        from = (gchar*) self->left->value;
+        free_from = 1;
+    }
+    else
+        from = self->left->token->string;
+    if(self->right->value)
+    {
+        to = (gchar*) self->right->value;
+        free_to = 1;
+    }
+    else
+        to = self->right->token->string;
+    mp_set_from_integer(1, &tmp);
+    if(!(self->state->convert))
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    if(!(*(self->state->convert))(self->state, &tmp, from, to, ans))
+    {
+        set_error(self->state, PARSER_ERR_UNKNOWN_CONVERSION, NULL);
+        mp_free(ans);
+        ans = NULL;
+    }
+    if(free_from)
+    {
+        g_free(self->left->value);
+        self->left->value = NULL;
+    }
+    if(free_to)
+    {
+        g_free(self->right->value);
+        self->right->value = NULL;
+    }
+    mp_clear(&tmp);
+    return ans;
+}
+
+/* Join source unit and power. */
+gchar*
+pf_make_unit(gchar* source, gchar* power)
+{
+    return g_strjoin(NULL, source, power, NULL);
+}
+
+static gchar *
+utf8_next_char(const gchar *c)
+{
+    c++;
+    while((*c & 0xC0) == 0x80)
+        c++;
+    return(gchar *) c;
+}
+
+/* Get value of variable. */
+void*
+pf_get_variable(ParseNode* self)
+{
+    gint result = 0;
+
+    const gchar *c, *next;
+    gchar *buffer;
+    MPNumber value = mp_new();
+
+    MPNumber t = mp_new();
+    MPNumber* ans = mp_new_ptr();
+
+    if(!(self->state->get_variable))
+    {
+        free(ans);
+        return NULL;
+    }
+
+    /* If defined, then get the variable */
+    if((*(self->state->get_variable))(self->state, self->token->string, ans))
+    {
+        return ans;
+    }
+
+    /* If has more than one character then assume a multiplication of variables */
+    if(utf8_next_char(self->token->string)[0] != '\0')
+    {
+        result = 1;
+        buffer = (gchar*) malloc(sizeof(gchar) * strlen(self->token->string));
+        mp_set_from_integer(1, &value);
+        for(c = self->token->string; *c != '\0'; c = next)
+        {
+            next = utf8_next_char(c);
+            snprintf(buffer, next - c + 1, "%s", c);
+            if(!(*(self->state->get_variable))(self->state, buffer, &t))
+            {
+                result = 0;
+                break;
+            }
+            mp_multiply(&value, &t, &value);
+        }
+        free(buffer);
+        if(result)
+            mp_set_from_mp(&value, ans);
+    }
+    if(!result)
+    {
+        free (ans);
+        ans = NULL;
+        set_error(self->state, PARSER_ERR_UNKNOWN_VARIABLE, self->token->string);
+    }
+    return ans;
+}
+
+/* Get value of variable with power. */
+void*
+pf_get_variable_with_power(ParseNode* self)
+{
+    gint result = 0;
+    gint pow;
+
+    const gchar *c, *next;
+    gchar *buffer;
+    MPNumber value = mp_new();
+
+    MPNumber t = mp_new();
+    MPNumber* ans = mp_new_ptr();
+    pow = super_atoi(((LexerToken*) self->value)->string);
+
+    /* No need to free the memory. It is allocated and freed somewhere else. */
+    self->value = NULL;
+
+    if(!(self->state->get_variable))
+    {
+        free(ans);
+        return NULL;
+    }
+
+    /* If defined, then get the variable */
+    if((*(self->state->get_variable))(self->state, self->token->string, ans))
+    {
+        mp_xpowy_integer(ans, pow, ans);
+        return ans;
+    }
+
+    /* If has more than one character then assume a multiplication of variables */
+    if(utf8_next_char(self->token->string)[0] != '\0')
+    {
+        result = 1;
+        buffer = (gchar*) malloc(sizeof(gchar) * strlen(self->token->string));
+        mp_set_from_integer(1, &value);
+        for(c = self->token->string; *c != '\0'; c = next)
+        {
+            next = utf8_next_char(c);
+            snprintf(buffer, next - c + 1, "%s", c);
+            if(!(*(self->state->get_variable))(self->state, buffer, &t))
+            {
+                result = 0;
+                break;
+            }
+
+            /* If last term do power */
+            if(*next == '\0')
+                mp_xpowy_integer(&t, pow, &t);
+            mp_multiply(&value, &t, &value);
+        }
+        free(buffer);
+        if(result)
+            mp_set_from_mp(&value, ans);
+    }
+    if(!result)
+    {
+        free(ans);
+        ans = NULL;
+        set_error(self->state, PARSER_ERR_UNKNOWN_VARIABLE, self->token->string);
+    }
+    return ans;
+}
+
+/* Apply function on child. */
+void*
+pf_apply_func(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!(self->state->get_function))
+    {
+        free(val);
+        free(ans);
+        return NULL;
+    }
+    if(!val)
+    {
+        free(ans);
+        return NULL;
+    }
+    if(!(*(self->state->get_function))(self->state, self->token->string, val, ans))
+    {
+        free(val);
+        free(ans);
+        set_error(self->state, PARSER_ERR_UNKNOWN_FUNCTION, self->token->string);
+        return NULL;
+    }
+    free(val);
+    return ans;
+}
+
+/* Apply function with +ve power. */
+void*
+pf_apply_func_with_power(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* tmp = mp_new_ptr();
+    MPNumber* ans = mp_new_ptr();
+    gint pow;
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!(self->state->get_function))
+    {
+        mp_free(tmp);
+        mp_free(ans);
+        mp_free(val);
+        self->value = NULL;
+        return NULL;
+    }
+    if(!val)
+    {
+        mp_free(tmp);
+        mp_free(ans);
+        self->value = NULL;
+        return NULL;
+    }
+    if(!(*(self->state->get_function))(self->state, self->token->string, val, tmp))
+    {
+        mp_free(tmp);
+        mp_free(ans);
+        mp_free(val);
+        self->value = NULL;
+        set_error(self->state, PARSER_ERR_UNKNOWN_FUNCTION, self->token->string);
+        return NULL;
+    }
+    pow = super_atoi(((LexerToken*) self->value)->string);
+    mp_xpowy_integer(tmp, pow, ans);
+    mp_free(val);
+    mp_free(tmp);
+    self->value = NULL;
+    return ans;
+}
+
+/* Apply function with -ve power. */
+void*
+pf_apply_func_with_npower(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* tmp = mp_new_ptr();
+    MPNumber* ans = mp_new_ptr();
+    gint pow;
+    gchar* inv_name;
+    inv_name = (gchar*) malloc(sizeof(gchar) * strlen(self->token->string) + strlen("⁻¹") + 1);
+    strcpy(inv_name, self->token->string);
+    strcat(inv_name, "⁻¹");
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(tmp);
+        free(inv_name);
+        mp_free(ans);
+        self->value = NULL;
+        return NULL;
+    }
+    if(!(self->state->get_function))
+    {
+        mp_free(tmp);
+        mp_free(ans);
+        free(inv_name);
+        self->value = NULL;
+        return NULL;
+    }
+    if(!(*(self->state->get_function))(self->state, inv_name, val, tmp))
+    {
+        mp_free(tmp);
+        mp_free(ans);
+        mp_free(val);
+        free(inv_name);
+        self->value = NULL;
+        set_error(self->state, PARSER_ERR_UNKNOWN_FUNCTION, self->token->string);
+        return NULL;
+    }
+    pow = super_atoi(((LexerToken*) self->value)->string);
+    mp_xpowy_integer(tmp, -pow, ans);
+    mp_free(val);
+    mp_free(tmp);
+    free(inv_name);
+    self->value = NULL;
+    return ans;
+}
+
+/* Find nth root of child. */
+void*
+pf_do_nth_root(ParseNode* self)
+{
+    MPNumber* val;
+    gint pow;
+    MPNumber* ans = mp_new_ptr();
+    pow = sub_atoi(((LexerToken*) self->value)->string);
+    self->value = NULL;
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_root(val, pow, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Find sqrt of child. */
+void*
+pf_do_sqrt(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        free(ans);
+        return NULL;
+    }
+    mp_sqrt(val, ans);
+    free(val);
+    return ans;
+}
+
+/* Find 3rd root of child. */
+void*
+pf_do_root_3(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_root(val, 3, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Find 4th root of child. */
+void*
+pf_do_root_4(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_root(val, 4, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Apply floor function. */
+void*
+pf_do_floor(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_floor(val, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Apply ceiling function. */
+void* pf_do_ceiling (ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_ceiling(val, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Round off. */
+void*
+pf_do_round(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_round(val, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Fraction. */
+void*
+pf_do_fraction(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_fractional_part(val, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Absolute value. */
+void*
+pf_do_abs(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_abs(val, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Find x^y for x and y being MPNumber. */
+void*
+pf_do_x_pow_y(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* pow;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->left->evaluate))(self->left);
+    pow = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val || !pow)
+    {
+        if(val)
+            mp_free(val);
+        if(pow)
+            mp_free(pow);
+        mp_free(ans);
+        return NULL;
+    }
+    mp_xpowy(val, pow, ans);
+    mp_free(val);
+    mp_free(pow);
+    return ans;
+}
+
+/* Find x^y for MPNumber x and integer y. */
+void*
+pf_do_x_pow_y_int(ParseNode* self)
+{
+    MPNumber* val;
+    long pow;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->left->evaluate))(self->left);
+
+    if(!val)
+    {
+        val = mp_new_ptr();
+        mp_set_from_integer(super_atoi(self->left->token->string), val);
+    }
+
+    if (self->right->token != NULL)
+    {
+        pow = super_atoi(self->right->token->string);
+    }
+    else
+    {
+        MPNumber* aux = (MPNumber*) (*(self->right->evaluate))(self->right);
+        pow = mp_to_integer(aux);
+        mp_free(aux);
+    }
+
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_xpowy_integer(val, pow, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Find factorial. */
+void*
+pf_do_factorial(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_factorial(val, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Apply unary minus. */
+void*
+pf_unary_minus(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_invert_sign(val, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* Divide. */
+void*
+pf_do_divide(ParseNode* self)
+{
+    MPNumber* left;
+    MPNumber* right;
+    MPNumber* ans = mp_new_ptr();
+    left = (MPNumber*) (*(self->left->evaluate))(self->left);
+    right = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!left || !right)
+    {
+        if(left)
+            mp_free(left);
+        if(right)
+            mp_free(right);
+        mp_free(ans);
+        return NULL;
+    }
+    mp_divide(left, right, ans);
+    mp_free(left);
+    mp_free(right);
+    return ans;
+}
+
+/* Modulus. */
+void*
+pf_do_mod(ParseNode* self)
+{
+    MPNumber* left;
+    MPNumber* right;
+    MPNumber* ans = mp_new_ptr();
+    left = (MPNumber*) (*(self->left->evaluate))(self->left);
+    right = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!left || !right)
+    {
+        if(left)
+            mp_free(left);
+        if(right)
+            mp_free(right);
+        mp_free(ans);
+        return NULL;
+    }
+    if (self->left->evaluate == pf_do_x_pow_y)
+    {
+        MPNumber* base_value = (MPNumber*) (*(self->left->left->evaluate))(self->left->left);
+        MPNumber* exponent = (MPNumber*) (*(self->left->right->evaluate))(self->left->right);
+        if(!base_value || !exponent)
+        {
+            if(base_value)
+                mp_free(base_value);
+            if(exponent)
+                mp_free(exponent);
+            mp_free(ans);
+            return NULL;
+        }
+        mp_modular_exponentiation(base_value, exponent, right, ans);
+        mp_free(base_value);
+        mp_free(exponent);
+    }
+    else
+        mp_modulus_divide(left, right, ans);
+
+    mp_free(left);
+    mp_free(right);
+    return ans;
+}
+
+/* Multiply two numbers. */
+void*
+pf_do_multiply(ParseNode* self)
+{
+    MPNumber* left;
+    MPNumber* right;
+    MPNumber* ans = mp_new_ptr();
+    left = (MPNumber*) (*(self->left->evaluate))(self->left);
+    right = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!left || !right)
+    {
+        if(left)
+            mp_free(left);
+        if(right)
+            mp_free(right);
+        mp_free(ans);
+        return NULL;
+    }
+    mp_multiply(left, right, ans);
+    mp_free(left);
+    mp_free(right);
+    return ans;
+}
+
+/* Subtract two numbers. */
+void*
+pf_do_subtract(ParseNode* self)
+{
+    MPNumber* left;
+    MPNumber* right;
+    MPNumber* ans = mp_new_ptr();
+    left = (MPNumber*) (*(self->left->evaluate))(self->left);
+    right = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!left || !right)
+    {
+        if(left)
+            mp_free(left);
+        if(right)
+            mp_free(right);
+        free(ans);
+        return NULL;
+    }
+    mp_subtract(left, right, ans);
+    mp_free(left);
+    mp_free(right);
+    return ans;
+}
+
+/* Add two numbers. */
+void*
+pf_do_add(ParseNode* self)
+{
+    MPNumber* left;
+    MPNumber* right;
+    MPNumber* ans = mp_new_ptr();
+    left = (MPNumber*) (*(self->left->evaluate))(self->left);
+    right = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!left || !right)
+    {
+        if(left)
+            mp_free(left);
+        if(right)
+            mp_free(right);
+        free(ans);
+        return NULL;
+    }
+    mp_add(left, right, ans);
+    mp_free(left);
+    mp_free(right);
+    return ans;
+}
+
+/* Add (x) Percentage to value. */
+void*
+pf_do_add_percent(ParseNode* self)
+{
+    MPNumber* ans = mp_new_ptr();
+    MPNumber* val;
+    MPNumber* per;
+    val = (MPNumber*) (*(self->left->evaluate))(self->left);
+    per = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val || !per)
+    {
+        if(val)
+            mp_free(val);
+        if(per)
+            mp_free(per);
+        mp_free(ans);
+        return NULL;
+    }
+    mp_add_integer(per, 100, per);
+    mp_divide_integer(per, 100, per);
+    mp_multiply(val, per, ans);
+    mp_free(val);
+    mp_free(per);
+    return ans;
+}
+
+/* Subtract (x) Percentage to value. */
+void*
+pf_do_subtract_percent(ParseNode* self)
+{
+    MPNumber* ans = mp_new_ptr();
+    MPNumber* val;
+    MPNumber* per;
+    val = (MPNumber*) (*(self->left->evaluate))(self->left);
+    per = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val || !per)
+    {
+        if(val)
+            mp_free(val);
+        if(per)
+            mp_free(per);
+        free(ans);
+        return NULL;
+    }
+    mp_add_integer(per, -100, per);
+    mp_divide_integer(per, -100, per);
+    mp_multiply(val, per, ans);
+    mp_free(val);
+    mp_free(per);
+    return ans;
+}
+
+/* Converts a constant into percentage. */
+void*
+pf_do_percent(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    mp_divide_integer(val, 100, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* NOT. */
+void*
+pf_do_not(ParseNode* self)
+{
+    MPNumber* val;
+    MPNumber* ans = mp_new_ptr();
+    val = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!val)
+    {
+        mp_free(ans);
+        return NULL;
+    }
+    if(!mp_is_overflow(val, self->state->options->wordlen))
+    {
+        set_error(self->state, PARSER_ERR_OVERFLOW, NULL);
+        mp_free(ans);
+        mp_free(val);
+        return NULL;
+    }
+    mp_not(val, self->state->options->wordlen, ans);
+    mp_free(val);
+    return ans;
+}
+
+/* AND. */
+void*
+pf_do_and(ParseNode* self)
+{
+    MPNumber* left;
+    MPNumber* right;
+    MPNumber* ans = mp_new_ptr();
+    left = (MPNumber*) (*(self->left->evaluate))(self->left);
+    right = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!left || !right)
+    {
+        if(left)
+            mp_free(left);
+        if(right)
+            mp_free(right);
+        mp_free(ans);
+        return NULL;
+    }
+    mp_and(left, right, ans);
+    mp_free(left);
+    mp_free(right);
+    return ans;
+}
+
+/* OR. */
+void*
+pf_do_or(ParseNode* self)
+{
+    MPNumber* left;
+    MPNumber* right;
+    MPNumber* ans = mp_new_ptr();
+    left = (MPNumber*) (*(self->left->evaluate))(self->left);
+    right = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!left || !right)
+    {
+        if(left)
+            mp_free(left);
+        if(right)
+            mp_free(right);
+        mp_free(ans);
+        return NULL;
+    }
+    mp_or(left, right, ans);
+    mp_free(left);
+    mp_free(right);
+    return ans;
+}
+
+/* XOR. */
+void*
+pf_do_xor(ParseNode* self)
+{
+    MPNumber* left;
+    MPNumber* right;
+    MPNumber* ans = mp_new_ptr();
+    left = (MPNumber*) (*(self->left->evaluate))(self->left);
+    right = (MPNumber*) (*(self->right->evaluate))(self->right);
+    if(!left || !right)
+    {
+        if(left)
+            mp_free(left);
+        if(right)
+            mp_free(right);
+        free(ans);
+        return NULL;
+    }
+    mp_xor(left, right, ans);
+    mp_free(left);
+    mp_free(right);
+    return ans;
+}
+
+/* Constant value. Convert into MPNumber and return. */
+void*
+pf_constant(ParseNode* self)
+{
+    MPNumber* ans = mp_new_ptr();
+    if(mp_set_from_string(self->token->string, self->state->options->base, ans) != 0)
+    {
+        /* This should never happen, as l_check_if_number() has already passed the string once. */
+        /* If the code reaches this point, something is really wrong. X( */
+        mp_free(ans);
+        set_error(self->state, PARSER_ERR_INVALID, self->token->string);
+        return NULL;
+    }
+    return ans;
+}
+
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/45.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/45.html new file mode 100644 index 0000000..2fa10f4 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/45.html @@ -0,0 +1,665 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <assert.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "prelexer.h"
+
+/* Creates a scanner state which will be useful for accessing the lexer later. */
+PreLexerState*
+pl_create_scanner(const gchar* input)
+{
+    PreLexerState* state;
+    assert(input != NULL);
+    assert(g_utf8_validate(input, -1, NULL));
+    state = (PreLexerState *) malloc(sizeof(PreLexerState));
+    assert(state != NULL);
+    state->stream = g_strdup(input);
+    state->length = strlen(state->stream);    /* Can't find a GLib replacement of strlen. The mailing list discussion says, it is not implemented because strlen is perfectly capable. :) */
+    state->next_index = 0;
+    state->mark_index = 0;
+    return state;
+}
+
+/* Destroy and free memory used by LexerState object. */
+void
+pl_destroy_scanner(PreLexerState* state)
+{
+    free(state->stream);
+    free(state);
+}
+
+/* Roll back last scanned unichar. */
+void
+pl_roll_back(PreLexerState* state)
+{
+    gchar* tmp;
+    tmp = g_utf8_find_prev_char(state->stream, state->stream + state->next_index);
+    if(tmp == NULL)
+        /* Already at the beginning of the stram. Reset index. */
+        state->next_index = 0;
+    else
+        state->next_index = tmp - state->stream;
+}
+
+/* Get validated gunichar from input stream. */
+gunichar
+pl_get_next_gunichar(PreLexerState* state)
+{
+    gunichar ret;
+    if(state->next_index >= state->length)
+    {
+        /* To prevent scanning last letter multiple times, when a single unconditional rollback is used. */
+        if(state->next_index == state->length)
+            state->next_index++;
+        return 0;
+    }
+    ret = g_utf8_get_char_validated(state->stream + state->next_index, -1);
+    state->next_index = g_utf8_next_char(state->stream + state->next_index) - state->stream;
+    return ret;
+}
+
+/* Set marker index. To be used for highlighting and error reporting. */
+void
+pl_set_marker(PreLexerState* state)
+{
+    state->mark_index = state->next_index;
+}
+
+/* Get marked substring. To be used for error reporting. */
+gchar*
+pl_get_marked_substring(const PreLexerState* state)
+{
+    return g_strndup(state->stream + state->mark_index, state->next_index - state->mark_index);
+}
+
+/* Compares a list of strings with given unichar. To be used by pl_get_next_token() only. */
+static gboolean
+pl_compare_all(const gunichar ch, const gint count, gchar *arr[])
+{
+    gint l;
+    for(l = 0; l < count; l++)
+    {
+        if(ch == g_utf8_get_char_validated(arr[l], -1))
+            return TRUE;
+    }
+    return FALSE;
+}
+
+/* Pre-Lexer tokanizer. To be called only by Lexer. */
+LexerTokenType
+pl_get_next_token(PreLexerState* state)
+{
+    gunichar ch = pl_get_next_gunichar(state);
+    if(pl_compare_all(ch, 2, (gchar*[]){",","."}))
+        return PL_DECIMAL;
+
+    if(g_unichar_isdigit(ch) || pl_compare_all(ch, 10, (gchar*[]){"〇","〡","〢","〣","〤","〥","〦","〧","〨","〩"}))
+        return PL_DIGIT;    /* 0-9 */
+
+    if(g_unichar_isxdigit(ch))
+        return PL_HEX;        /* This is supposed to report just the A-F. */
+
+    if(pl_compare_all(ch, 10, (gchar*[]){"⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹"}))
+        return PL_SUPER_DIGIT;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"⁻"}))
+        return PL_SUPER_MINUS;
+
+    if(pl_compare_all(ch, 10, (gchar*[]){"₀","₁","₂","₃","₄","₅","₆","₇","₈","₉"}))
+        return PL_SUB_DIGIT;
+
+    if(pl_compare_all(ch, 15, (gchar*[]){"½","⅓","⅔","¼","¾","⅕","⅖","⅗","⅘","⅙","⅚","⅛","⅜","⅝","⅞"}))
+        return PL_FRACTION;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"°"}))
+        return PL_DEGREE;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"'"}))
+        return PL_MINUTE;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"\""}))
+        return PL_SECOND;
+
+    if(g_unichar_isalpha(ch))
+        return PL_LETTER;    /* All alphabets excluding A-F. [a-fA-F] are reported as PL_HEX. */
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"∧"}))
+        return T_AND;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"∨"}))
+        return T_OR;
+
+    if(pl_compare_all(ch, 2, (gchar*[]){"⊻","⊕"}))
+        return T_XOR;
+
+    if(pl_compare_all(ch, 2, (gchar*[]){"¬","~"}))
+        return T_NOT;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"+"}))
+        return T_ADD;
+
+    if(pl_compare_all(ch, 3, (gchar*[]){"-","−","–"}))
+        return T_SUBTRACT;
+
+    if(pl_compare_all(ch, 2, (gchar*[]){"*","×"}))
+        return T_MULTIPLY;
+
+    if(pl_compare_all(ch, 3, (gchar*[]){"/","∕","÷"}))
+        return T_DIV;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"⌊"}))
+        return T_L_FLOOR;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"⌋"}))
+        return T_R_FLOOR;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"⌈"}))
+        return T_L_CEILING;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"⌉"}))
+        return T_R_CEILING;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"√"}))
+        return T_ROOT;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"∛"}))
+        return T_ROOT_3;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"∜"}))
+        return T_ROOT_4;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"="}))
+        return T_ASSIGN;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"("}))
+        return T_L_R_BRACKET;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){")"}))
+        return T_R_R_BRACKET;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"["}))
+        return T_L_S_BRACKET;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"]"}))
+        return T_R_S_BRACKET;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"{"}))
+        return T_L_C_BRACKET;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"}"}))
+        return T_R_C_BRACKET;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"|"}))
+        return T_ABS;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"^"}))
+        return T_POWER;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"!"}))
+        return T_FACTORIAL;
+
+    if(pl_compare_all(ch, 1, (gchar*[]){"%"}))
+        return T_PERCENTAGE;
+
+    if(pl_compare_all(ch, 4, (gchar*[]){" ","\r","\t","\n"}))
+    /* Gotta ignore'Em all!!! ;) */
+        return PL_SKIP;
+
+    if(ch == 0)
+        return PL_EOS;
+
+    /* There is no spoon. */
+    return T_UNKNOWN;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/46.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/46.html new file mode 100644 index 0000000..9115568 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/46.html @@ -0,0 +1,1813 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdarg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp-equation.h"
+#include "mp-serializer.h"
+#include "unit-manager.h"
+
+static MPEquationOptions options;
+
+static int fails = 0;
+static int passes = 0;
+
+/* If we're not using GNU C, elide __attribute__ */
+#ifndef __GNUC__
+#  define  __attribute__(x)  /*NOTHING*/
+#endif
+
+#define test(X, Y, Z) Test(X, Y, Z, 9)
+
+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");
+*/
+    passes += 1;
+}
+
+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, int trailing_digits)
+{
+    MPErrorCode error;
+    char *error_token = NULL;
+    MPNumber result = mp_new();
+
+    error = mp_equation_parse(expression, &options, &result, &error_token);
+    if (error_token)
+        g_free (error_token);
+
+    if (error == 0) {
+        char *result_str;
+        MpSerializer *serializer;
+
+        serializer = mp_serializer_new(MP_DISPLAY_FORMAT_FIXED, options.base, trailing_digits);
+        result_str = mp_serializer_to_string(serializer, &result);
+        g_object_unref(serializer);
+
+        if(expected_error != PARSER_ERR_NONE)
+            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);
+        g_free(result_str);
+    }
+    else {
+        if(error == expected_error)
+            pass("'%s' -> error %s", expression, error_code_to_string(error));
+        else if(expected_error == PARSER_ERR_NONE)
+            fail("'%s' -> error %s, expected result %s", expression,
+                 error_code_to_string(error), expected);
+        else
+            fail("'%s' -> error %s, expected error %s", expression,
+                 error_code_to_string(error), error_code_to_string(expected_error));
+    }
+    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)
+{
+    memset(&options, 0, sizeof(options));
+    options.base = 10;
+    options.wordlen = 32;
+    options.angle_units = MP_DEGREES;
+    options.convert = do_convert;
+
+    /* Angle units */
+    //test("π radians in degrees", "180", 0);
+    test("100 gradians in degrees", "90", 0);
+
+    /* 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);
+
+    /* Duration */
+    test("1 minute in seconds", "60", 0);
+    test("1s in ms", "1000", 0);
+
+    /* Temperature */
+    //test("100˚C in ˚F", "", 0);
+    //test("0˚C in ˚F", "32", 0);
+    //test("0˚K in ˚C", "−273.15", 0);
+    test("100degC in degF", "212", 0);
+    test("0degC in degF", "32", 0);
+    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)
+{
+    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)
+{
+}
+
+static void
+test_equations(void)
+{
+    memset(&options, 0, sizeof(options));
+    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("pi", "3.141592654", 0);
+    test("e", "2.718281828", 0);
+
+    /* Physical constants */
+
+    test("c₀", "299792458", 0);
+    Test("μ₀", "0.0000012566370614", 0, 16);
+    Test("ε₀", "0.00000000000885418782", 0, 20);
+    Test("G",  "0.0000000000667408", 0, 16);
+    Test("h",  "0.000000000000000000000000000000000662607004", 0, 42);
+    Test("e", "0.00000000000000000016021766208", 0, 29);
+    Test("mₑ", "0.000000000000000000000000000000910938356", 0, 39);
+    Test("mₚ", "0.000000000000000000000000001672621898", 0, 36);
+    test("Nₐ", "602214086000000000000000", 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);
+    test("2(1+1)", "4", 0);
+    test("4÷2(1+1)", "4", 0);
+    test ("1 + 2 - 3 * 4 / 5", "0.6", 0);
+    test ("20 / 10 mod 3", "2", 0);
+    test ("12 / 3 √4", "8", 0);
+    test ("√5!", "10.95445115", 0);
+    //test ("4 ^ sin 30", "2", 0);
+    test ("4 ^ (sin 30)", "2", 0);
+    //test ("4 ^ sin (30)", "2", 0);
+    //test ("sin (30) ^ 4", "0.0625", 0);
+    //test ("sin 30 ^ 4", "0.0625", 0);
+    test ("sin (30 ^ 4)", "0", 0);
+    //test ("-ln(1)", "0", 0);
+    test ("ln(-1)", "3.141592654i", 0);
+    test ("2.33*sqrt(2.5)+6", "9.684053474", 0);
+
+    test ("10 / - 2", "−5", 0);
+    test ("10 * - 2", "−20", 0);
+    test ("10 ^ -2", "0.01", 0);
+    test ("-10 ^ 2", "−100", 0);
+    test ("sin (-30)", "−0.5", 0);
+    test ("sin - 30", "−0.5", 0);
+
+    test ("6 + 3!", "12", 0);
+    test ("4 * 3!", "24", 0);
+    test ("100 mod 3!", "4", 0);
+    test ("5! mod 7", "1", 0);
+    test ("24 / 3!", "4", 0);
+    test ("4! / 6", "4", 0);
+    test ("cos 5!", "−0.5", 0);
+    test ("sin 6!", "0", 0);
+    test ("- 4!", "−24", 0);
+    test ("3! ^ 3", "216", 0);
+    test ("3 ^ 3!", "729", 0);
+    //test ("(−√3)^2", "3", 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!", "0.95135077", 0);
+    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("2³ ²", "512", 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("0^0.5", "0", 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);
+    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("e^-2^-5", "0.969233234", 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("123^456 mod 78", "27", 0);
+    test("2^2 mod 2", "0", 0);
+    test("1^0 mod 2", "1", 0);
+    test("2^1 mod 1", "0", 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("acos 0", "90", 0);
+    test("acos 1", "0", 0);
+
+    test("sin⁻¹ 0", "0", 0);
+    test("sin⁻¹ 1", "90", 0);
+    test("sin⁻¹ (−1)", "−90", 0);
+    test("sin⁻¹ (1÷√2)", "45", 0);
+    test("asin 0", "0", 0);
+    test("asin 1", "90", 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);
+
+    test("zeta 0", "−0.5", 0);
+    test("zeta 2", "1.644934067", 0);
+    test("zeta −2", "0", 0);
+
+    test("erf 0", "0", 0);
+    test("erf 1", "0.842700793", 0);
+    test("erf −1", "−0.842700793", 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("ln (e^iπ)", "3.141592654i", 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);
+}
+
+int
+main (void)
+{
+    setlocale(LC_ALL, "C");
+
+    test_mp();
+    test_conversions();
+    test_equations();
+    if (fails == 0)
+        printf("Passed all %i tests\n", passes);
+
+    return fails;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/47.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/47.html new file mode 100644 index 0000000..0d865c7 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/47.html @@ -0,0 +1,693 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdarg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp.h"
+
+static int fails = 0;
+static int passes = 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");
+*/
+    passes += 1;
+}
+
+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 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(void)
+{
+    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(void)
+{
+    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);
+}
+
+int
+main (void)
+{
+    setlocale(LC_ALL, "C");
+
+    test_mp();
+    test_numbers();
+    if (fails == 0)
+        printf("Passed all %i tests\n", passes);
+
+    return fails;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/48.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/48.html new file mode 100644 index 0000000..2940532 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/48.html @@ -0,0 +1,497 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "unit-category.h"
+
+struct UnitCategoryPrivate
+{
+    gchar *name;
+    gchar *display_name;
+    GList *units;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (UnitCategory, unit_category, G_TYPE_OBJECT);
+
+UnitCategory *
+unit_category_new(const gchar *name, const gchar *display_name)
+{
+    UnitCategory *category = g_object_new(unit_category_get_type(), NULL);
+    category->priv->name = g_strdup(name);
+    category->priv->display_name = g_strdup(display_name);
+    return category;
+}
+
+const gchar *
+unit_category_get_name(UnitCategory *category)
+{
+    g_return_val_if_fail (category != NULL, NULL);
+    return category->priv->name;
+}
+
+const gchar *
+unit_category_get_display_name(UnitCategory *category)
+{
+    g_return_val_if_fail (category != NULL, NULL);
+    return category->priv->display_name;
+}
+
+void
+unit_category_add_unit(UnitCategory *category, Unit *unit)
+{
+    g_return_if_fail (category != NULL);
+    g_return_if_fail (unit != NULL);
+    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)
+{
+    GList *iter;
+
+    g_return_val_if_fail (category != NULL, NULL);
+    g_return_val_if_fail (name != NULL, NULL);
+
+    for (iter = category->priv->units; iter; iter = iter->next)
+    {
+        Unit *unit = iter->data;
+        if (strcmp(unit_get_name(unit), name) == 0)
+            return unit;
+    }
+
+    return NULL;
+}
+
+Unit *
+unit_category_get_unit_by_symbol(UnitCategory *category, const gchar *symbol)
+{
+    GList *iter;
+
+    g_return_val_if_fail (category != NULL, NULL);
+    g_return_val_if_fail (symbol != NULL, NULL);
+
+    for (iter = category->priv->units; iter; iter = iter->next) {
+        Unit *unit = iter->data;
+        if (unit_matches_symbol(unit, symbol))
+            return unit;
+    }
+
+    return NULL;
+}
+
+const GList *
+unit_category_get_units(UnitCategory *category)
+{
+    g_return_val_if_fail (category != NULL, NULL);
+    return category->priv->units;
+}
+
+gboolean
+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);
+    g_return_val_if_fail (z_units != NULL, FALSE);
+    g_return_val_if_fail (z != NULL, FALSE);
+
+    MPNumber t = mp_new();
+    if (!unit_convert_from(x_units, x, &t))
+    {
+        mp_clear(&t);
+        return FALSE;
+    }
+    if (!unit_convert_to(z_units, &t, z))
+    {
+        mp_clear(&t);
+        return FALSE;
+    }
+    mp_clear(&t);
+    return TRUE;
+}
+
+static void
+unit_category_class_init(UnitCategoryClass *klass)
+{
+}
+
+static void
+unit_category_init(UnitCategory *category)
+{
+    category->priv = unit_category_get_instance_private (category);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/49.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/49.html new file mode 100644 index 0000000..edb6dbf --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/49.html @@ -0,0 +1,773 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h> // FIXME: Move out of here<--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "unit-manager.h"
+#include "currency-manager.h" // FIXME: Move out of here
+
+struct UnitManagerPrivate
+{
+    GList *categories;
+};
+
+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)
+{
+    UnitCategory *category = NULL;
+    GList *currencies, *iter;
+    int i;
+    const struct
+    {
+        gchar *category;
+        gchar *name;
+        gchar *display_name;
+        gchar *format;
+        gchar *from_function;
+        gchar *to_function;
+        gchar *symbols;
+    } units[] =
+    {
+        /* FIXME: Approximations of 1/(units in a circle), therefore, 360 deg != 400 grads */
+        {"angle",    "degree",              N_("Degrees"),           NC_("unit-format", "%s degrees"),  "π*x/180",            "180x/π",         NC_("unit-symbols", "degree,degrees,deg")},
+        {NULL,       "radian",              N_("Radians"),           NC_("unit-format", "%s radians"),  "x",                  "x",              NC_("unit-symbols", "radian,radians,rad")},
+        {NULL,       "gradian",             N_("Gradians"),          NC_("unit-format", "%s gradians"), "π*x/200",            "200x/π",         NC_("unit-symbols", "gradian,gradians,grad")},
+        {"length",   "parsec",              N_("Parsecs"),           NC_("unit-format", "%s pc"),       "30857000000000000x", "x/30857000000000000", NC_("unit-symbols", "parsec,parsecs,pc")},
+        {NULL,       "lightyear",           N_("Light Years"),       NC_("unit-format", "%s ly"),       "9460730472580800x",  "x/9460730472580800",  NC_("unit-symbols", "lightyear,lightyears,ly")},
+        {NULL,       "astronomical-unit",   N_("Astronomical Units"), NC_("unit-format", "%s au"),      "149597870700x",      "x/149597870700", NC_("unit-symbols", "au")},
+        {NULL,       "nautical-mile",       N_("Nautical Miles"),    NC_("unit-format", "%s nmi"),      "1852x",              "x/1852",         NC_("unit-symbols", "nmi")},
+        {NULL,       "mile",                N_("Miles"),             NC_("unit-format", "%s mi"),       "1609.344x",          "x/1609.344",     NC_("unit-symbols", "mile,miles,mi")},
+        {NULL,       "kilometer",           N_("Kilometers"),        NC_("unit-format", "%s km"),       "1000x",              "x/1000",         NC_("unit-symbols", "kilometer,kilometers,km,kms")},
+        {NULL,       "cable",               N_("Cables"),            NC_("unit-format", "%s cb"),       "219.456x",           "x/219.456",      NC_("unit-symbols", "cable,cables,cb")},
+        {NULL,       "fathom",              N_("Fathoms"),           NC_("unit-format", "%s ftm"),      "1.8288x",            "x/1.8288",       NC_("unit-symbols", "fathom,fathoms,ftm")},
+        {NULL,       "meter",               N_("Meters"),            NC_("unit-format", "%s m"),        "x",                  "x",              NC_("unit-symbols", "meter,meters,m")},
+        {NULL,       "yard",                N_("Yards"),             NC_("unit-format", "%s yd"),       "0.9144x",            "x/0.9144",       NC_("unit-symbols", "yard,yards,yd")},
+        {NULL,       "foot",                N_("Feet"),              NC_("unit-format", "%s ft"),       "0.3048x",            "x/0.3048",       NC_("unit-symbols", "foot,feet,ft")},
+        {NULL,       "inch",                N_("Inches"),            NC_("unit-format", "%s in"),       "0.0254x",            "x/0.0254",       NC_("unit-symbols", "inch,inches,in")},
+        {NULL,       "centimeter",          N_("Centimeters"),       NC_("unit-format", "%s cm"),       "x/100",              "100x",           NC_("unit-symbols", "centimeter,centimeters,cm,cms")},
+        {NULL,       "millimeter",          N_("Millimeters"),       NC_("unit-format", "%s mm"),       "x/1000",             "1000x",          NC_("unit-symbols", "millimeter,millimeters,mm")},
+        {NULL,       "micrometer",          N_("Micrometers"),       NC_("unit-format", "%s μm"),       "x/1000000",          "1000000x",       NC_("unit-symbols", "micrometer,micrometers,um")},
+        {NULL,       "nanometer",           N_("Nanometers"),        NC_("unit-format", "%s nm"),       "x/1000000000",       "1000000000x",    NC_("unit-symbols", "nanometer,nanometers,nm")},
+        {"area",     "hectare",             N_("Hectares"),          NC_("unit-format", "%s ha"),       "10000x",             "x/10000",        NC_("unit-symbols", "hectare,hectares,ha")},
+        {NULL,       "acre",                N_("Acres"),             NC_("unit-format", "%s acres"),    "4046.8564224x",      "x/4046.8564224", NC_("unit-symbols", "acre,acres")},
+        {NULL,       "square-meter",        N_("Square Meters"),      NC_("unit-format", "%s m²"),       "x",                  "x",              NC_("unit-symbols", "m²")},
+        {NULL,       "square-centimeter",   N_("Square Centimeters"), NC_("unit-format", "%s cm²"),      "0.0001x",            "10000x",         NC_("unit-symbols", "cm²")},
+        {NULL,       "square-millimeter",   N_("Square Millimeters"), NC_("unit-format", "%s mm²"),      "0.000001x",          "1000000x",       NC_("unit-symbols", "mm²")},
+        {"volume",   "cubic-meter",         N_("Cubic Meters"),      NC_("unit-format", "%s m³"),       "1000x",              "x/1000",         NC_("unit-symbols", "m³")},
+        {NULL,       "gallon",              N_("Gallons"),           NC_("unit-format", "%s gal"),      "3.785412x",          "x/3.785412",     NC_("unit-symbols", "gallon,gallons,gal")},
+        {NULL,       "litre",               N_("Litres"),            NC_("unit-format", "%s L"),        "x",                  "x",              NC_("unit-symbols", "litre,litres,liter,liters,L")},
+        {NULL,       "quart",               N_("Quarts"),            NC_("unit-format", "%s qt"),       "0.9463529x",         "x/0.9463529",    NC_("unit-symbols", "quart,quarts,qt")},
+        {NULL,       "pint",                N_("Pints"),             NC_("unit-format", "%s pt"),       "0.4731765x",         "x/0.4731765",    NC_("unit-symbols", "pint,pints,pt")},
+        {NULL,       "millilitre",          N_("Millilitres"),       NC_("unit-format", "%s mL"),       "0.001x",             "1000x",          NC_("unit-symbols", "millilitre,millilitres,milliliter,milliliters,mL,cm³")},
+        {NULL,       "microlitre",          N_("Microlitres"),       NC_("unit-format", "%s μL"),       "0.000001x",          "1000000x",       NC_("unit-symbols", "mm³,μL,uL")},
+        {"weight",   "tonne",               N_("Tonnes"),            NC_("unit-format", "%s T"),        "1000x",             "x/1000",          NC_("unit-symbols", "tonne,tonnes")},
+        {NULL,       "kilograms",           N_("Kilograms"),         NC_("unit-format", "%s kg"),       "x",                  "x",              NC_("unit-symbols", "kilogram,kilograms,kilogramme,kilogrammes,kg,kgs")},
+        {NULL,       "pound",               N_("Pounds"),            NC_("unit-format", "%s lb"),       "0.45359237x",        "x/0.45359237",   NC_("unit-symbols", "pound,pounds,lb")},
+        {NULL,       "ounce",               N_("Ounces"),            NC_("unit-format", "%s oz"),       "0.02834952x",        "x/0.02834952",   NC_("unit-symbols", "ounce,ounces,oz")},
+        {NULL,       "gram",                N_("Grams"),             NC_("unit-format", "%s g"),        "0.001x",             "1000x",          NC_("unit-symbols", "gram,grams,gramme,grammes,g")},
+        {"duration", "year",                N_("Years"),             NC_("unit-format", "%s years"),    "31557600x",          "x/31557600",     NC_("unit-symbols", "year,years")},
+        {NULL,       "day",                 N_("Days"),              NC_("unit-format", "%s days"),     "86400x",             "x/86400",        NC_("unit-symbols", "day,days")},
+        {NULL,       "hour",                N_("Hours"),             NC_("unit-format", "%s hours"),    "3600x",              "x/3600",         NC_("unit-symbols", "hour,hours")},
+        {NULL,       "minute",              N_("Minutes"),           NC_("unit-format", "%s minutes"),  "60x",                "x/60",           NC_("unit-symbols", "minute,minutes")},
+        {NULL,       "second",              N_("Seconds"),           NC_("unit-format", "%s s"),        "x",                  "x",              NC_("unit-symbols", "second,seconds,s")},
+        {NULL,       "millisecond",         N_("Milliseconds"),      NC_("unit-format", "%s ms"),       "0.001x",             "1000x",          NC_("unit-symbols", "millisecond,milliseconds,ms")},
+        {NULL,       "microsecond",         N_("Microseconds"),      NC_("unit-format", "%s μs"),       "0.000001x",          "1000000x",       NC_("unit-symbols", "microsecond,microseconds,us,μs")},
+        {"temperature", "degree-celcius",   N_("Celsius"),           NC_("unit-format", "%s ˚C"),       "x+273.15",           "x-273.15",       NC_("unit-symbols", "degC,˚C")},
+        {NULL,          "degree-farenheit", N_("Farenheit"),         NC_("unit-format", "%s ˚F"),       "(x+459.67)*5/9",     "x*9/5-459.67",   NC_("unit-symbols", "degF,˚F")},
+        {NULL,          "degree-kelvin",    N_("Kelvin"),            NC_("unit-format", "%s K"),        "x",                  "x",              NC_("unit-symbols", "K")},
+        {NULL,          "degree-rankine",   N_("Rankine"),           NC_("unit-format", "%s ˚R"),       "x*5/9",              "x*9/5",          NC_("unit-symbols", "degR,˚R,˚Ra")},
+        { NULL, NULL, NULL, NULL, NULL, NULL }
+    };
+
+    if (default_unit_manager)
+        return default_unit_manager;
+
+    default_unit_manager = g_object_new(unit_manager_get_type(), NULL);
+
+    unit_manager_add_category(default_unit_manager, "angle",    _("Angle"));
+    unit_manager_add_category(default_unit_manager, "length",   _("Length"));
+    unit_manager_add_category(default_unit_manager, "area",     _("Area"));
+    unit_manager_add_category(default_unit_manager, "volume",   _("Volume"));
+    unit_manager_add_category(default_unit_manager, "weight",   _("Weight"));
+    unit_manager_add_category(default_unit_manager, "duration", _("Duration"));
+    unit_manager_add_category(default_unit_manager, "temperature", _("Temperature"));
+
+    for (i = 0; units[i].name; i++) {
+        if (units[i].category)
+            category = unit_manager_get_category(default_unit_manager, units[i].category);
+        unit_category_add_unit(category, unit_new(units[i].name,
+                                                  _(units[i].display_name),
+                                                  g_dpgettext2(NULL, "unit-format", units[i].format),
+                                                  units[i].from_function, units[i].to_function,
+                                                  g_dpgettext2(NULL, "unit-symbols", units[i].symbols)));
+    }
+
+    category = unit_manager_add_category(default_unit_manager, "currency", _("Currency"));
+    currencies = g_list_copy(currency_manager_get_currencies(currency_manager_get_default()));
+    currencies = g_list_sort(currencies, compare_currencies);
+    for (iter = currencies; iter; iter = iter->next)
+    {
+        Currency *currency = iter->data;
+        gchar *format;
+        Unit *unit;
+
+        /* Translators: result of currency conversion, %s is the symbol, %%s is the placeholder for amount, i.e.: USD100 */
+        format = g_strdup_printf(_("%s%%s"), currency_get_symbol(currency));
+        unit = unit_new(currency_get_name(currency), currency_get_display_name(currency), format, NULL, NULL, currency_get_name(currency));
+        g_free(format);
+
+        unit_category_add_unit(category, unit);
+    }
+    g_list_free(currencies);
+
+    return default_unit_manager;
+}
+
+UnitCategory *
+unit_manager_add_category(UnitManager *manager, const gchar *name, const gchar *display_name)
+{
+    UnitCategory *category;
+
+    g_return_val_if_fail(manager != NULL, NULL);
+    g_return_val_if_fail(name != NULL, NULL);
+    g_return_val_if_fail(display_name != NULL, NULL);
+    g_return_val_if_fail(unit_manager_get_category(manager, name) == NULL, NULL);
+
+    category = unit_category_new(name, display_name);
+    manager->priv->categories = g_list_append(manager->priv->categories, category);
+
+    return category;
+}
+
+const GList *
+unit_manager_get_categories(UnitManager *manager)
+{
+    g_return_val_if_fail(manager != NULL, NULL);
+    return manager->priv->categories;
+}
+
+UnitCategory *
+unit_manager_get_category(UnitManager *manager, const gchar *category)
+{
+    GList *iter;
+
+    g_return_val_if_fail(manager != NULL, NULL);
+    g_return_val_if_fail(category != NULL, NULL);
+
+    for (iter = manager->priv->categories; iter; iter = iter->next) {
+        UnitCategory *c = iter->data;
+        if (strcmp(unit_category_get_name(c), category) == 0)
+            return c;
+    }
+
+    return NULL;
+}
+
+Unit *
+unit_manager_get_unit_by_name(UnitManager *manager, const gchar *name)
+{
+    GList *iter;
+    Unit *u;
+
+    g_return_val_if_fail(manager != NULL, NULL);
+    g_return_val_if_fail(name != NULL, NULL);
+
+    for (iter = manager->priv->categories; iter; iter = iter->next) {
+        UnitCategory *c = iter->data;
+        u = unit_category_get_unit_by_name(c, name);
+        if (u)
+            return u;
+    }
+
+    return NULL;
+}
+
+Unit *
+unit_manager_get_unit_by_symbol(UnitManager *manager, const gchar *symbol)
+{
+    GList *iter;
+    Unit *u;
+
+    g_return_val_if_fail(manager != NULL, NULL);
+    g_return_val_if_fail(symbol != NULL, NULL);
+
+    for (iter = manager->priv->categories; iter; iter = iter->next) {
+        UnitCategory *c = iter->data;
+        u = unit_category_get_unit_by_symbol(c, symbol);
+        if (u)
+            return u;
+    }
+
+    return NULL;
+}
+
+gboolean
+unit_manager_convert_by_symbol(UnitManager *manager, const MPNumber *x, const char *x_symbol, const char *z_symbol, MPNumber *z)
+{
+    GList *iter;
+
+    g_return_val_if_fail(manager != NULL, FALSE);
+    g_return_val_if_fail(x != NULL, FALSE);
+    g_return_val_if_fail(x_symbol != NULL, FALSE);
+    g_return_val_if_fail(z_symbol != NULL, FALSE);
+    g_return_val_if_fail(z != NULL, FALSE);
+
+    for (iter = manager->priv->categories; iter; iter = iter->next) {
+        UnitCategory *c = iter->data;
+        Unit *x_units, *z_units;
+
+        x_units = unit_category_get_unit_by_symbol(c, x_symbol);
+        z_units = unit_category_get_unit_by_symbol(c, z_symbol);
+        if (x_units && z_units && unit_category_convert(c, x, x_units, z_units, z))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+static void
+unit_manager_class_init(UnitManagerClass *klass)
+{
+}
+
+static void
+unit_manager_init(UnitManager *manager)
+{
+    manager->priv = unit_manager_get_instance_private (manager);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/5.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/5.html new file mode 100644 index 0000000..d3203c3 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/5.html @@ -0,0 +1,923 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "financial.h"
+#include "mp.h"
+
+static void
+calc_ctrm(MPNumber *t, MPNumber *pint, MPNumber *fv, MPNumber *pv)<--- Parameter 'fv' can be declared as pointer to const<--- Parameter 'pv' can be declared as pointer to const<--- Parameter 'pint' can be declared as pointer to const
+{
+
+/*  Cterm - pint (periodic interest rate).
+ *          fv  (future value).
+ *          pv  (present value).
+ *
+ *          RESULT = log(fv / pv) / log(1 + pint)
+ */
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+    MPNumber MP3 = mp_new();
+    MPNumber MP4 = mp_new();
+
+    mp_divide(fv, pv, &MP1);
+    mp_ln(&MP1, &MP2);
+    mp_add_integer(pint, 1, &MP3);
+    mp_ln(&MP3, &MP4);
+    mp_divide(&MP2, &MP4, t);
+
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+    mp_clear(&MP3);
+    mp_clear(&MP4);
+}
+
+static void
+calc_ddb(MathEquation *equation, MPNumber *t, MPNumber *cost, MPNumber *life, MPNumber *period)<--- Parameter 'period' can be declared as pointer to const<--- Parameter 'cost' can be declared as pointer to const<--- Parameter 'life' can be declared as pointer to const
+{
+
+/*  Ddb   - cost    (amount paid for asset).
+ *          life    (useful life of the asset).
+ *          period  (time period for depreciation allowance).
+ *
+ *          bv = 0.0;
+ *          for (i = 0; i < life; i++)
+ *            {
+ *              VAL = ((cost - bv) * 2) / life
+ *              bv += VAL
+ *            }
+ *          RESULT = VAL
+ *
+ */
+
+    long len;
+    MPNumber MPbv = mp_new();
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+
+    mp_set_from_integer(0, &MPbv);
+    len = mp_to_integer(period);
+    for (long i = 0; i < len; i++) {
+        mp_subtract(cost, &MPbv, &MP1);
+        mp_multiply_integer(&MP1, 2, &MP2);
+        mp_divide(&MP2, life, t);
+        mp_set_from_mp(&MPbv, &MP1);
+        mp_add(&MP1, t, &MPbv); /* TODO: why result is MPbv, for next loop? */
+    }
+
+    if (len >= 0) {
+        math_equation_set_status (equation, _("Error: the number of periods must be positive"));
+        mp_set_from_integer(0, t);
+    }
+
+    mp_clear(&MPbv);
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+}
+
+static void
+calc_fv(MPNumber *t, MPNumber *pmt, MPNumber *pint, MPNumber *n)<--- Parameter 'pint' can be declared as pointer to const<--- Parameter 'n' can be declared as pointer to const<--- Parameter 'pmt' can be declared as pointer to const
+{
+
+/*  Fv    - pmt (periodic payment).
+ *          pint (periodic interest rate).
+ *          n   (number of periods).
+ *
+ *          RESULT = pmt * (pow(1 + pint, n) - 1) / pint
+ */
+
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+    MPNumber MP3 = mp_new();
+    MPNumber MP4 = mp_new();
+
+    mp_add_integer(pint, 1, &MP1);
+    mp_xpowy(&MP1, n, &MP2);
+    mp_add_integer(&MP2, -1, &MP3);
+    mp_multiply(pmt, &MP3, &MP4);
+    mp_divide(&MP4, pint, t);
+
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+    mp_clear(&MP3);
+    mp_clear(&MP4);
+}
+
+static void
+calc_gpm(MPNumber *t, MPNumber *cost, MPNumber *margin)<--- Parameter 'margin' can be declared as pointer to const<--- Parameter 'cost' can be declared as pointer to const
+{
+
+/*  Gpm   - cost (cost of sale).
+ *          margin (gross profit margin.
+ *
+ *          RESULT = cost / (1 - margin)
+ */
+
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+
+    mp_set_from_integer(1, &MP1);
+    mp_subtract(&MP1, margin, &MP2);
+    mp_divide(cost, &MP2, t);
+
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+}
+
+static void
+calc_pmt(MPNumber *t, MPNumber *prin, MPNumber *pint, MPNumber *n)<--- Parameter 'pint' can be declared as pointer to const<--- Parameter 'n' can be declared as pointer to const<--- Parameter 'prin' can be declared as pointer to const
+{
+
+/*  Pmt   - prin (principal).
+ *          pint  (periodic interest rate).
+ *          n    (term).
+ *
+ *          RESULT = prin * (pint / (1 - pow(pint + 1, -1 * n)))
+ */
+
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+    MPNumber MP3 = mp_new();
+    MPNumber MP4 = mp_new();
+
+    mp_add_integer(pint, 1, &MP1);
+    mp_multiply_integer(n, -1, &MP2);
+    mp_xpowy(&MP1, &MP2, &MP3);
+    mp_multiply_integer(&MP3, -1, &MP4);
+    mp_add_integer(&MP4, 1, &MP1);
+    mp_divide(pint, &MP1, &MP2);
+    mp_multiply(prin, &MP2, t);
+
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+    mp_clear(&MP3);
+    mp_clear(&MP4);
+}
+
+static void
+calc_pv(MPNumber *t, MPNumber *pmt, MPNumber *pint, MPNumber *n)<--- Parameter 'pint' can be declared as pointer to const<--- Parameter 'n' can be declared as pointer to const<--- Parameter 'pmt' can be declared as pointer to const
+{
+
+/*  Pv    - pmt (periodic payment).
+ *          pint (periodic interest rate).
+ *          n   (term).
+ *
+ *          RESULT = pmt * (1 - pow(1 + pint, -1 * n)) / pint
+ */
+
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+    MPNumber MP3 = mp_new();
+    MPNumber MP4 = mp_new();
+
+    mp_add_integer(pint, 1, &MP1);
+    mp_multiply_integer(n, -1, &MP2);
+    mp_xpowy(&MP1, &MP2, &MP3);
+    mp_multiply_integer(&MP3, -1, &MP4);
+    mp_add_integer(&MP4, 1, &MP1);
+    mp_divide(&MP1, pint, &MP2);
+    mp_multiply(pmt, &MP2, t);
+
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+    mp_clear(&MP3);
+    mp_clear(&MP4);
+}
+
+static void
+calc_rate(MPNumber *t, MPNumber *fv, MPNumber *pv, MPNumber *n)<--- Parameter 'fv' can be declared as pointer to const<--- Parameter 'pv' can be declared as pointer to const<--- Parameter 'n' can be declared as pointer to const
+{
+
+/*  Rate  - fv (future value).
+ *          pv (present value).
+ *          n  (term).
+ *
+ *          RESULT = pow(fv / pv, 1 / n) - 1
+ */
+
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+    MPNumber MP3 = mp_new();
+    MPNumber MP4 = mp_new();
+
+    mp_divide(fv, pv, &MP1);
+    mp_set_from_integer(1, &MP2);
+    mp_divide(&MP2, n, &MP3);
+    mp_xpowy(&MP1, &MP3, &MP4);
+    mp_add_integer(&MP4, -1, t);
+
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+    mp_clear(&MP3);
+    mp_clear(&MP4);
+}
+
+static void
+calc_sln(MPNumber *t, MPNumber *cost, MPNumber *salvage, MPNumber *life)<--- Parameter 'cost' can be declared as pointer to const<--- Parameter 'salvage' can be declared as pointer to const<--- Parameter 'life' can be declared as pointer to const
+{
+
+/*  Sln   - cost    (cost of the asset).
+ *          salvage (salvage value of the asset).
+ *          life    (useful life of the asset).
+ *
+ *          RESULT = (cost - salvage) / life
+ */
+
+    MPNumber MP1 = mp_new();
+    mp_subtract(cost, salvage, &MP1);
+    mp_divide(&MP1, life, t);
+    mp_clear(&MP1);
+}
+
+static void
+calc_syd(MPNumber *t, MPNumber *cost, MPNumber *salvage, MPNumber *life, MPNumber *period)<--- Parameter 'life' can be declared as pointer to const<--- Parameter 'period' can be declared as pointer to const<--- Parameter 'cost' can be declared as pointer to const<--- Parameter 'salvage' can be declared as pointer to const
+{
+
+/*  Syd   - cost    (cost of the asset).
+ *          salvage (salvage value of the asset).
+ *          life    (useful life of the asset).
+ *          period  (period for which depreciation is computed).
+ *
+ *          RESULT = (cost - salvage) * (life - period + 1) /
+ *                   (life * (life + 1)) / 2
+ */
+
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+    MPNumber MP3 = mp_new();
+    MPNumber MP4 = mp_new();
+
+    mp_subtract(life, period, &MP2);
+    mp_add_integer(&MP2, 1, &MP3);
+    mp_add_integer(life, 1, &MP2);
+    mp_multiply(life, &MP2, &MP4);
+    mp_set_from_integer(2, &MP2);
+    mp_divide(&MP4, &MP2, &MP1);
+    mp_divide(&MP3, &MP1, &MP2);
+    mp_subtract(cost, salvage, &MP1);
+    mp_multiply(&MP1, &MP2, t);
+
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+    mp_clear(&MP3);
+    mp_clear(&MP4);
+}
+
+static void
+calc_term(MPNumber *t, MPNumber *pmt, MPNumber *fv, MPNumber *pint)<--- Parameter 'pint' can be declared as pointer to const<--- Parameter 'fv' can be declared as pointer to const<--- Parameter 'pmt' can be declared as pointer to const
+{
+
+/*  Term  - pmt (periodic payment).
+ *          fv  (future value).
+ *          pint (periodic interest rate).
+ *
+ *          RESULT = log(1 + (fv * pint / pmt)) / log(1 + pint)
+ */
+
+    MPNumber MP1 = mp_new();
+    MPNumber MP2 = mp_new();
+    MPNumber MP3 = mp_new();
+    MPNumber MP4 = mp_new();
+
+    mp_add_integer(pint, 1, &MP1);
+    mp_ln(&MP1, &MP2);
+    mp_multiply(fv, pint, &MP1);
+    mp_divide(&MP1, pmt, &MP3);
+    mp_add_integer(&MP3, 1, &MP4);
+    mp_ln(&MP4, &MP1);
+    mp_divide(&MP1, &MP2, t);
+
+    mp_clear(&MP1);
+    mp_clear(&MP2);
+    mp_clear(&MP3);
+    mp_clear(&MP4);
+}
+
+void
+do_finc_expression(MathEquation *equation, int function, MPNumber *arg1, MPNumber *arg2, MPNumber *arg3, MPNumber *arg4)
+{
+    MPNumber result = mp_new();
+    switch (function) {
+     case FINC_CTRM_DIALOG:
+       calc_ctrm(&result, arg1, arg2, arg3);
+       break;
+     case FINC_DDB_DIALOG:
+       calc_ddb(equation, &result, arg1, arg2, arg3);
+       break;
+     case FINC_FV_DIALOG:
+       calc_fv(&result, arg1, arg2, arg3);
+       break;
+     case FINC_GPM_DIALOG:
+       calc_gpm(&result, arg1, arg2);
+       break;
+     case FINC_PMT_DIALOG:
+       calc_pmt(&result, arg1, arg2, arg3);
+       break;
+     case FINC_PV_DIALOG:
+       calc_pv(&result, arg1, arg2, arg3);
+       break;
+     case FINC_RATE_DIALOG:
+       calc_rate(&result, arg1, arg2, arg3);
+       break;
+     case FINC_SLN_DIALOG:
+       calc_sln(&result, arg1, arg2, arg3);
+       break;
+     case FINC_SYD_DIALOG:
+       calc_syd(&result, arg1, arg2, arg3, arg4);
+       break;
+     case FINC_TERM_DIALOG:
+       calc_term(&result, arg1, arg2, arg3);
+       break;
+    }
+    math_equation_set_number(equation, &result);
+    mp_clear(&result);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/50.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/50.html new file mode 100644 index 0000000..b313303 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/50.html @@ -0,0 +1,633 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "unit.h"
+#include "mp-serializer.h"
+#include "mp-equation.h"
+#include "currency-manager.h" // FIXME: Move out of here
+
+struct UnitPrivate
+{
+    gchar *name;
+    gchar *display_name;
+    gchar *format;
+    GList *symbols;
+    gchar *from_function;
+    gchar *to_function;
+    MpSerializer *serializer;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (Unit, unit, G_TYPE_OBJECT);
+
+Unit *
+unit_new(const gchar *name,
+         const gchar *display_name,
+         const gchar *format,
+         const gchar *from_function,
+         const gchar *to_function,
+         const gchar *symbols)
+{
+    Unit *unit = g_object_new(unit_get_type(), NULL);
+    gchar **symbol_names;
+    int i;
+
+    unit->priv->name = g_strdup(name);
+    unit->priv->display_name = g_strdup(display_name);
+    unit->priv->format = g_strdup(format);
+    unit->priv->from_function = g_strdup(from_function);
+    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, symbol_names[i]);
+    g_free(symbol_names);
+
+    return unit;
+}
+
+const gchar *
+unit_get_name(Unit *unit)
+{
+    g_return_val_if_fail (unit != NULL, NULL);
+    return unit->priv->name;
+}
+
+const gchar *
+unit_get_display_name(Unit *unit)
+{
+    g_return_val_if_fail (unit != NULL, NULL);
+    return unit->priv->display_name;
+}
+
+gboolean
+unit_matches_symbol(Unit *unit, const gchar *symbol)
+{
+    GList *iter;
+
+    g_return_val_if_fail (unit != NULL, FALSE);
+    g_return_val_if_fail (symbol != NULL, FALSE);
+
+    for (iter = unit->priv->symbols; iter; iter = iter->next) {
+        gchar *s = iter->data;<--- Variable 's' can be declared as pointer to const
+        if (strcmp(s, symbol) == 0)
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+const GList *
+unit_get_symbols(Unit *unit)
+{
+    g_return_val_if_fail (unit != NULL, NULL);
+    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)
+{
+    MPNumber *x = data;<--- Variable 'x' can be declared as pointer to const
+    mp_set_from_mp(x, z);
+    return TRUE;
+}
+
+static gboolean
+solve_function(const gchar *function, const MPNumber *x, MPNumber *z)
+{
+    MPEquationOptions options;
+    int ret;
+
+    memset(&options, 0, sizeof(options));
+    options.base = 10;
+    options.wordlen = 32;
+    options.variable_is_defined = variable_is_defined;
+    options.get_variable = get_variable;
+    options.callback_data = (void *)x;
+    ret = mp_equation_parse(function, &options, z, NULL);
+    if (ret) {
+        g_warning("Failed to convert value: %s", function);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+gboolean
+unit_convert_from(Unit *unit, const MPNumber *x, MPNumber *z)
+{
+    g_return_val_if_fail(unit != NULL, FALSE);
+    g_return_val_if_fail(x != NULL, FALSE);
+    g_return_val_if_fail(z != NULL, FALSE);
+
+    if (unit->priv->from_function)
+        return solve_function(unit->priv->from_function, x, z);
+    else {
+        // FIXME: Hack to make currency work
+        const MPNumber *r;
+        r = currency_manager_get_value(currency_manager_get_default(), unit->priv->name);
+        if (!r)
+            return FALSE;
+        mp_divide(x, r, z);
+
+        return TRUE;
+    }
+}
+
+gboolean
+unit_convert_to(Unit *unit, const MPNumber *x, MPNumber *z)
+{
+    g_return_val_if_fail(unit != NULL, FALSE);
+    g_return_val_if_fail(x != NULL, FALSE);
+    g_return_val_if_fail(x != NULL, FALSE);
+
+    if (unit->priv->from_function)
+        return solve_function(unit->priv->to_function, x, z);
+    else {
+        // FIXME: Hack to make currency work
+        const MPNumber *r;
+        r = currency_manager_get_value(currency_manager_get_default(), unit->priv->name);
+        if (!r)
+            return FALSE;
+        mp_multiply(x, r, z);
+
+        return TRUE;
+    }
+}
+
+gchar *
+unit_format(Unit *unit, MPNumber *x)<--- Parameter 'x' can be declared as pointer to const
+{
+    gchar *number_text, *text;
+
+    g_return_val_if_fail(unit != NULL, FALSE);
+    g_return_val_if_fail(x != NULL, FALSE);
+
+    number_text = mp_serializer_to_string(unit->priv->serializer, x);
+    text = g_strdup_printf(unit->priv->format, number_text);
+    g_free(number_text);
+
+    return text;
+}
+
+static void
+unit_class_init(UnitClass *klass)
+{
+}
+
+static void
+unit_init(Unit *unit)
+{
+    unit->priv = unit_get_instance_private (unit);
+    unit->priv->serializer = mp_serializer_new(MP_DISPLAY_FORMAT_AUTOMATIC, 10, 2);
+    mp_serializer_set_leading_digits(unit->priv->serializer, 6);
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/6.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/6.html new file mode 100644 index 0000000..b6a2d97 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/6.html @@ -0,0 +1,493 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
/*
+ * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MATH_EQUATION_H
+#define MATH_EQUATION_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mp.h"
+#include "math-variables.h"
+#include "mp-serializer.h"
+
+G_BEGIN_DECLS
+
+#define MATH_TYPE_EQUATION (math_equation_get_type ())
+#define MATH_EQUATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_equation_get_type(), MathEquation))
+#define MATH_EQUATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MATH_TYPE_EQUATION, MathEquationClass))
+
+typedef struct MathEquationPrivate MathEquationPrivate;
+
+typedef struct
+{
+    GtkTextBuffer parent_instance;
+    MathEquationPrivate *priv;
+} MathEquation;
+
+typedef struct
+{
+    GtkTextBufferClass parent_class;
+} MathEquationClass;
+
+typedef enum {
+    NORMAL,
+    SUPERSCRIPT,
+    SUBSCRIPT
+} NumberMode;
+
+GType math_equation_get_type(void);
+MathEquation *math_equation_new(void);
+
+MathVariables *math_equation_get_variables(MathEquation *equation);
+
+gunichar math_equation_get_digit_text(MathEquation *equation, guint digit);
+
+void math_equation_set_status(MathEquation *equation, const gchar *status);
+const gchar *math_equation_get_status(MathEquation *equation);
+
+gboolean math_equation_is_empty(MathEquation *equation);
+gboolean math_equation_is_result(MathEquation *equation);
+gchar *math_equation_get_display(MathEquation *equation);
+gchar *math_equation_get_equation(MathEquation *equation);
+gboolean math_equation_get_number(MathEquation *equation, MPNumber *z);
+
+void math_equation_set_number_mode(MathEquation *equation, NumberMode mode);
+NumberMode math_equation_get_number_mode(MathEquation *equation);
+
+void math_equation_set_accuracy(MathEquation *equation, gint accuracy);
+gint math_equation_get_accuracy(MathEquation *equation);
+
+void math_equation_set_show_thousands_separators(MathEquation *equation, gboolean visible);
+gboolean math_equation_get_show_thousands_separators(MathEquation *equation);
+
+void math_equation_set_show_trailing_zeroes(MathEquation *equation, gboolean visible);
+gboolean math_equation_get_show_trailing_zeroes(MathEquation *equation);
+
+void math_equation_set_number_format(MathEquation *equation, MpDisplayFormat format);
+MpDisplayFormat math_equation_get_number_format(MathEquation *equation);
+
+void math_equation_set_base(MathEquation *equation, gint base);
+gint math_equation_get_base(MathEquation *equation);
+
+void math_equation_set_word_size(MathEquation *equation, gint word_size);
+gint math_equation_get_word_size(MathEquation *equation);
+
+void math_equation_set_angle_units(MathEquation *equation, MPAngleUnit angle_unit);
+MPAngleUnit math_equation_get_angle_units(MathEquation *equation);
+
+void math_equation_set_source_currency(MathEquation *equation, const gchar *currency);
+const gchar *math_equation_get_source_currency(MathEquation *equation);
+
+void math_equation_set_target_currency(MathEquation *equation, const gchar *currency);
+const gchar *math_equation_get_target_currency(MathEquation *equation);
+
+void math_equation_set_source_units(MathEquation *equation, const gchar *units);
+const gchar *math_equation_get_source_units(MathEquation *equation);
+
+void math_equation_set_target_units(MathEquation *equation, const gchar *units);
+const gchar *math_equation_get_target_units(MathEquation *equation);
+
+gboolean math_equation_in_solve(MathEquation *equation);
+
+const MPNumber *math_equation_get_answer(MathEquation *equation);
+MpSerializer *math_equation_get_serializer(MathEquation *equation);
+
+void math_equation_copy(MathEquation *equation);
+void math_equation_paste(MathEquation *equation);
+void math_equation_undo(MathEquation *equation);
+void math_equation_redo(MathEquation *equation);
+void math_equation_store(MathEquation *equation, const gchar *name);
+void math_equation_recall(MathEquation *equation, const gchar *name);
+void math_equation_set(MathEquation *equation, const gchar *text);
+void math_equation_set_number(MathEquation *equation, const MPNumber *x);
+void math_equation_insert(MathEquation *equation, const gchar *text);
+void math_equation_insert_digit(MathEquation *equation, guint digit);
+void math_equation_insert_numeric_point(MathEquation *equation);
+void math_equation_insert_number(MathEquation *equation, const MPNumber *x);
+void math_equation_insert_subtract(MathEquation *equation);
+void math_equation_insert_exponent(MathEquation *equation);
+void math_equation_solve(MathEquation *equation);
+void math_equation_factorize(MathEquation *equation);
+void math_equation_delete(MathEquation *equation);
+void math_equation_backspace(MathEquation *equation);
+void math_equation_clear(MathEquation *equation);
+void math_equation_shift(MathEquation *equation, gint count);
+void math_equation_toggle_bit(MathEquation *equation, guint bit);
+
+G_END_DECLS
+
+#endif /* MATH_EQUATION_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/7.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/7.html new file mode 100644 index 0000000..57d23d6 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/7.html @@ -0,0 +1,333 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
/*
+ * Copyright (C) 2008-2011 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 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+#ifndef MATH_VARIABLES_H
+#define MATH_VARIABLES_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "mp.h"
+
+G_BEGIN_DECLS
+
+#define MATH_VARIABLES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_equation_get_type(), MathVariables))
+
+typedef struct MathVariablesPrivate MathVariablesPrivate;
+
+typedef struct
+{
+    GObject parent_instance;
+    MathVariablesPrivate *priv;
+} MathVariables;
+
+typedef struct
+{
+    GObjectClass parent_class;
+} MathVariablesClass;
+
+GType math_variables_get_type(void);
+
+MathVariables *math_variables_new(void);
+
+gchar **math_variables_get_names(MathVariables *variables);
+
+void math_variables_set(MathVariables *variables, const char *name, const MPNumber *value);
+
+MPNumber *math_variables_get(MathVariables *variables, const char *name);
+
+void math_variables_delete(MathVariables *variables, const char *name);
+
+G_END_DECLS
+
+#endif /* MATH_VARIABLES_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/8.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/8.html new file mode 100644 index 0000000..082b8ec --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/8.html @@ -0,0 +1,1441 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <assert.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "lexer.h"
+#include "parserfunc.h"
+#include "mp-equation.h"
+
+static gboolean
+l_check_if_function(LexerState* state)
+{
+    gchar* name = pl_get_marked_substring(state->prelexer);
+    if(!state->parent->function_is_defined)
+    {
+        free(name);
+        return FALSE;
+    }
+    if ((*(state->parent->function_is_defined))(state->parent, name))
+    {
+        free(name);
+        return TRUE;
+    }
+    else
+    {
+        free(name);
+        return FALSE;
+    }
+}
+
+static gboolean
+l_check_if_number(LexerState* state)
+{
+    MPNumber tmp = mp_new();
+    int count = 0;
+    gchar* text = pl_get_marked_substring(state->prelexer);
+    if(mp_set_from_string(text, state->parent->options->base, &tmp) == 0)
+    {
+        free(text);
+        mp_clear(&tmp);
+        return TRUE;
+    }
+    else
+    {
+        /* Try to rollback several characters to see, if that yeilds any number. */
+        while(strlen (text) > 0)
+        {
+            if(mp_set_from_string(text, state->parent->options->base, &tmp) == 0)
+            {
+                free(text);
+                mp_clear(&tmp);
+                return TRUE;
+            }
+            free(text);
+            count++;
+            pl_roll_back(state->prelexer);
+            text = pl_get_marked_substring(state->prelexer);
+        }
+        /* Undo all rollbacks. */
+        while(count--)
+            pl_get_next_token (state->prelexer);
+        free(text);
+        mp_clear(&tmp);
+        return FALSE;
+    }
+}
+
+/* Insert generated token to the LexerState structure. */
+static LexerToken*
+l_insert_token(LexerState* state, const LexerTokenType type)
+{
+    state->tokens = (LexerToken *) realloc(state->tokens, (state->token_count + 1) * sizeof(LexerToken));
+    assert(state->tokens != NULL);
+    state->tokens[state->token_count].string = pl_get_marked_substring(state->prelexer);
+    state->tokens[state->token_count].start_index = state->prelexer->mark_index;
+    state->tokens[state->token_count].end_index = state->prelexer->next_index;
+    state->tokens[state->token_count].token_type = type;
+    state->token_count++;
+    return &state->tokens[state->token_count - 1];
+}
+
+/* Generates next token from pre-lexer stream and call l_insert_token() to insert it at the end. */
+static LexerToken*
+l_insert_next_token(LexerState* lstate)
+{
+    PreLexerState* state = lstate->prelexer;
+    LexerTokenType type;
+    gchar* tmp;
+    pl_set_marker(state);
+    /* Ignore all blank spaces. :) */
+    while((type = pl_get_next_token(state)) == PL_SKIP)
+        /* Set marker. Beginning of new token. */
+        pl_set_marker(state);
+    if(type == T_AND
+     ||type == T_OR
+     ||type == T_XOR
+     ||type == T_NOT
+     ||type == T_ADD
+     ||type == T_SUBTRACT
+     ||type == T_MULTIPLY
+     ||type == T_DIV
+     ||type == T_L_FLOOR
+     ||type == T_R_FLOOR
+     ||type == T_L_CEILING
+     ||type == T_R_CEILING
+     ||type == T_ROOT
+     ||type == T_ROOT_3
+     ||type == T_ROOT_4
+     ||type == T_ASSIGN
+     ||type == T_L_R_BRACKET
+     ||type == T_R_R_BRACKET
+     ||type == T_L_S_BRACKET
+     ||type == T_R_S_BRACKET
+     ||type == T_L_C_BRACKET
+     ||type == T_R_C_BRACKET
+     ||type == T_ABS
+     ||type == T_POWER
+     ||type == T_FACTORIAL
+     ||type == T_PERCENTAGE)
+    {
+        return l_insert_token(lstate, type);
+    }
+    /* [PL_SUPER_MINUS][PL_SUPER_DIGIT]+ */
+    if(type == PL_SUPER_MINUS)
+    {
+        if((type = pl_get_next_token(state)) != PL_SUPER_DIGIT)<--- Variable 'type' is assigned a value that is never used.
+        {
+            /* ERROR: expected PL_SUP_DIGIT */
+            set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring (state));
+            free(tmp);
+            return l_insert_token(lstate, T_UNKNOWN);
+        }
+        /* Get all PL_SUPER_DIGITs. */
+        while (pl_get_next_token(state) == PL_SUPER_DIGIT);
+        pl_roll_back(state);
+        return l_insert_token(lstate, T_NSUP_NUMBER);
+    }
+    /* [PL_SUPER_DIGIT]+ */
+    if(type == PL_SUPER_DIGIT)
+    {
+        while(pl_get_next_token(state) == PL_SUPER_DIGIT);
+        pl_roll_back(state);
+        return l_insert_token(lstate, T_SUP_NUMBER);
+    }
+    /* [PL_SUB_DIGIT]+ */
+    if(type == PL_SUB_DIGIT)
+    {
+        while(pl_get_next_token(state) == PL_SUB_DIGIT);
+        pl_roll_back(state);
+        return l_insert_token(lstate, T_SUB_NUMBER);
+    }
+    /* [PL_FRACTION] */
+    if(type == PL_FRACTION)
+    {
+        return l_insert_token(lstate, T_NUMBER);
+    }
+    if(type == PL_DIGIT)
+    {
+        while((type = pl_get_next_token(state)) == PL_DIGIT);
+        if(type == PL_FRACTION)
+        {
+            return l_insert_token(lstate, T_NUMBER);
+        }
+        else if(type == PL_SUB_DIGIT)
+        {
+            while(pl_get_next_token(state) == PL_SUB_DIGIT);
+            pl_roll_back(state);
+            return l_insert_token(lstate, T_NUMBER);
+        }
+        else if(type == PL_DEGREE)
+        {
+            type = pl_get_next_token(state);
+            if(type == PL_DIGIT)
+            {
+                while((type = pl_get_next_token(state)) == PL_DIGIT);
+                if(type == PL_DECIMAL)
+                {
+                    goto ANGLE_NUM_DM_STATE;
+                }
+                else if(type == PL_MINUTE)
+                {
+                    type = pl_get_next_token(state);
+                    if(type == PL_DIGIT)
+                    {
+                        while((type = pl_get_next_token(state)) == PL_DIGIT);
+                        if(type == PL_DECIMAL)
+                        {
+                            goto ANGLE_NUM_DMS_STATE;
+                        }
+                        else if(type == PL_SECOND)
+                        {
+                            return l_insert_token(lstate, T_NUMBER);
+                        }
+                        else
+                        {
+                            /* ERROR: expected PL_SECOND */
+                            set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring (state));
+                            free(tmp);
+                            return l_insert_token(lstate, T_UNKNOWN);
+                        }
+                    }
+                    else if(type == PL_DECIMAL)
+                    {
+ANGLE_NUM_DMS_STATE:
+                        if((type = pl_get_next_token (state)) != PL_DIGIT)
+                        {
+                            /* ERROR: expected PL_DIGIT */
+                            set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring(state));
+                            free(tmp);
+                            return l_insert_token(lstate, T_UNKNOWN);
+                        }
+                        while((type = pl_get_next_token(state)) == PL_DIGIT);
+                        if(type == PL_SECOND)
+                        {
+                            return l_insert_token(lstate, T_NUMBER);
+                        }
+                        else
+                        {
+                            /* ERROR: expected PL_SECOND */
+                            set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring(state));
+                            free(tmp);
+                            return l_insert_token(lstate, T_UNKNOWN);
+                        }
+                    }
+                    else
+                    {
+                        pl_roll_back(state);
+                        return l_insert_token(lstate, T_NUMBER);
+                    }
+                }
+                else
+                {
+                    /* ERROR: expected PL_MINUTE | PL_DIGIT */
+                    set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring(state));
+                    free(tmp);
+                    return l_insert_token(lstate, T_UNKNOWN);
+                }
+            }
+            else if(type == PL_DECIMAL)
+            {
+ANGLE_NUM_DM_STATE:
+                if((type = pl_get_next_token(state)) != PL_DIGIT)
+                {
+                    /* ERROR: expected PL_DIGIT */
+                    set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring(state));
+                    free(tmp);
+                    return l_insert_token(lstate, T_UNKNOWN);
+                }
+                while((type = pl_get_next_token(state)) == PL_DIGIT);
+                if(type == PL_MINUTE)
+                {
+                    return l_insert_token(lstate, T_NUMBER);
+                }
+                else
+                {
+                    /* ERROR: expected PL_MINUTE */
+                    set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring(state));
+                    free(tmp);
+                    return l_insert_token(lstate, T_UNKNOWN);
+                }
+            }
+            else
+            {
+                return l_insert_token(lstate, T_NUMBER);
+            }
+        }
+        else if(type == PL_DECIMAL)
+        {
+            goto DECIMAL_STATE;
+        }
+        else if(type == PL_HEX)
+        {
+            goto HEX_DEC_STATE;
+        }
+        else
+        {
+            pl_roll_back(state);
+            return l_insert_token(lstate, T_NUMBER);
+        }
+    }
+    if(type == PL_DECIMAL)
+    {
+DECIMAL_STATE:
+        type = pl_get_next_token(state);
+        if(type == PL_DIGIT)
+        {
+            while((type = pl_get_next_token(state)) == PL_DIGIT);
+            if(type == PL_DEGREE)
+            {
+                return l_insert_token(lstate, T_NUMBER);
+            }
+            else if(type == PL_HEX)
+            {
+                goto DECIMAL_HEX_STATE;
+            }
+            else if(type == PL_SUB_DIGIT)
+            {
+                while(pl_get_next_token(state) == PL_SUB_DIGIT);
+                pl_roll_back(state);
+                return l_insert_token(lstate, T_NUMBER);
+            }
+            else
+            {
+                pl_roll_back(state);
+                return l_insert_token(lstate, T_NUMBER);
+            }
+        }
+        else if(type == PL_HEX)
+        {
+            goto DECIMAL_HEX_STATE;
+        }
+        else
+        {
+            /* ERROR: expected PL_DIGIT | PL_HEX */
+            set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring(state));
+            free(tmp);
+            return l_insert_token(lstate, T_UNKNOWN);
+        }
+    }
+    if(type == PL_HEX)
+    {
+        while((type = pl_get_next_token(state)) == PL_HEX);
+        if(type == PL_DIGIT)
+        {
+HEX_DEC_STATE:
+            while(1)
+            {
+                type = pl_get_next_token(state);
+                if(type == PL_DIGIT || type == PL_HEX)
+                {
+                    continue;
+                }
+                else if(type == PL_DECIMAL)
+                {
+                    goto DECIMAL_HEX_STATE;
+                }
+                else if(type == PL_SUB_DIGIT)
+                {
+                    while(pl_get_next_token(state) == PL_SUB_DIGIT);
+                    pl_roll_back(state);
+                    return l_insert_token(lstate, T_NUMBER);
+                }
+                else
+                {
+                    if(l_check_if_number(lstate))
+                        return l_insert_token(lstate, T_NUMBER);
+                    /* ERROR: expected PL_DECIMAL | PL_DIGIT | PL_HEX */
+                    set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring(state));
+                    free(tmp);
+                    return l_insert_token(lstate, T_UNKNOWN);
+                }
+            }
+        }
+        else if(type == PL_DECIMAL)
+        {
+DECIMAL_HEX_STATE:
+            type = pl_get_next_token(state);
+            if(!(type == PL_DIGIT || type == PL_HEX))
+            {
+                /* ERROR: expected PL_DIGIT | PL_HEX */
+                set_error(lstate->parent, PARSER_ERR_MP, tmp = pl_get_marked_substring(state));
+                free(tmp);
+                return l_insert_token(lstate, T_UNKNOWN);
+            }
+            while(1)
+            {
+                type = pl_get_next_token(state);
+                if(type == PL_DIGIT || type == PL_HEX)
+                {
+                    continue;
+                }
+                else if(type == PL_SUB_DIGIT)
+                {
+                    while(pl_get_next_token(state) == PL_SUB_DIGIT);
+                    pl_roll_back(state);
+                    return l_insert_token(lstate, T_NUMBER);
+                }
+                else
+                {
+                    pl_roll_back(state);
+                    return l_insert_token(lstate, T_NUMBER);
+                }
+            }
+        }
+        else if(type == PL_SUB_DIGIT)
+        {
+            while(pl_get_next_token(state) == PL_SUB_DIGIT);
+            pl_roll_back(state);
+            if(l_check_if_number(lstate))
+            {
+                /* NUMBER */
+                return l_insert_token(lstate, T_NUMBER);
+            }
+            else
+            {
+                /* VARIABLE */
+                if(l_check_if_function(lstate))
+                {
+                    return l_insert_token(lstate, T_FUNCTION);
+                }
+                else
+                {
+                    return l_insert_token(lstate, T_VARIABLE);
+                }
+            }
+        }
+        else if(type == PL_LETTER)
+        {
+            goto LETTER_STATE;
+        }
+        else
+        {
+            pl_roll_back(state);
+            if(l_check_if_number(lstate))
+            {
+                /* NUMBER */
+                return l_insert_token(lstate, T_NUMBER);
+            }
+            else
+            {
+                /* VARIABLE */
+                if(l_check_if_function(lstate))
+                {
+                    return l_insert_token(lstate, T_FUNCTION);
+                }
+                else
+                {
+                    return l_insert_token(lstate, T_VARIABLE);
+                }
+            }
+        }
+    }
+    if(type == PL_LETTER)
+    {
+LETTER_STATE:
+        while(1)
+        {
+            type = pl_get_next_token(state);
+            if(type == PL_LETTER || type == PL_HEX)
+            {
+                continue;
+            }
+            else if(type == PL_SUB_DIGIT)
+            {
+                while(pl_get_next_token(state) == PL_SUB_DIGIT);
+                pl_roll_back(state);
+                tmp = g_ascii_strdown(pl_get_marked_substring(state), -1);
+                if(g_strcmp0(tmp, "mod") == 0)
+                {
+                    return l_insert_token(lstate, T_MOD);
+                }
+                if(g_strcmp0(tmp, "and") == 0)
+                {
+                    return l_insert_token(lstate, T_AND);
+                }
+                if(g_strcmp0(tmp, "or") == 0)
+                {
+                    return l_insert_token(lstate, T_OR);
+                }
+                if(g_strcmp0(tmp, "xor") == 0)
+                {
+                    return l_insert_token(lstate, T_XOR);
+                }
+                if(g_strcmp0(tmp, "not") == 0)
+                {
+                    return l_insert_token(lstate, T_NOT);
+                }
+                if(g_strcmp0(tmp, "in") == 0)
+                {
+                    return l_insert_token(lstate, T_IN);
+                }
+                if(l_check_if_function(lstate))
+                {
+                    return l_insert_token(lstate, T_FUNCTION);
+                }
+                else
+                {
+                    return l_insert_token(lstate, T_VARIABLE);
+                }
+            }
+            else
+            {
+                pl_roll_back(state);
+                tmp = g_ascii_strdown(pl_get_marked_substring(state), -1);
+                if(g_strcmp0(tmp, "mod") == 0)
+                {
+                    return l_insert_token(lstate, T_MOD);
+                }
+                if(g_strcmp0(tmp, "and") == 0)
+                {
+                    return l_insert_token(lstate, T_AND);
+                }
+                if(g_strcmp0(tmp, "or") == 0)
+                {
+                    return l_insert_token(lstate, T_OR);
+                }
+                if(g_strcmp0(tmp, "xor") == 0)
+                {
+                    return l_insert_token(lstate, T_XOR);
+                }
+                if(g_strcmp0(tmp, "not") == 0)
+                {
+                    return l_insert_token(lstate, T_NOT);
+                }
+                if(g_strcmp0(tmp, "in") == 0)
+                {
+                    return l_insert_token(lstate, T_IN);
+                }
+                if(l_check_if_function(lstate))
+                {
+                    return l_insert_token(lstate, T_FUNCTION);
+                }
+                else
+                {
+                    return l_insert_token(lstate, T_VARIABLE);
+                }
+            }
+        }
+    }
+    if(type == PL_EOS)
+    {
+        return l_insert_token(lstate, PL_EOS);
+    }
+    /* ERROR: Unexpected token.. X( */
+    set_error(lstate->parent, PARSER_ERR_INVALID, tmp = pl_get_marked_substring(state));
+    free(tmp);
+    return l_insert_token(lstate, T_UNKNOWN);
+}
+
+/* Call l_insert_next_token() as many times as needed to completely tokenize the string. */
+void
+l_insert_all_tokens(LexerState* state)
+{
+    LexerToken* token;
+    while(1)
+    {
+        token = l_insert_next_token(state);
+        assert(token != NULL);
+        if(token->token_type == PL_EOS)
+        {
+            break;
+        }
+    }
+}
+
+/* Create a lexer state from given input string. This will take care of pre-lexer state. */
+LexerState*
+l_create_lexer(const gchar* input, struct parser_state* parent)
+{
+    LexerState* ret;
+    ret = (LexerState *) malloc(sizeof(LexerState));
+    assert(ret != NULL);
+    ret->prelexer = pl_create_scanner(input);
+    ret->tokens = NULL;
+    ret->token_count = 0;
+    ret->next_token = 0;
+    ret->parent = parent;
+    return ret;
+}
+
+/* Destroy lexer state and free memory. */
+void
+l_destroy_lexer(LexerState* state)
+{
+    int l;
+    pl_destroy_scanner(state->prelexer);
+    for(l = 0; l < state->token_count; l++)
+    {
+        free(state->tokens[l].string);
+    }
+    free(state->tokens);
+    free(state);
+}
+
+/* Get next token interface. Will be called by parser to get pointer to next token in token stream. */
+LexerToken*
+l_get_next_token(LexerState* state)
+{
+    /* Return PL_EOS token after token stream reaches to its end. */
+    if(state->next_token >= state->token_count)
+        return &state->tokens[state->token_count - 1];
+    return &state->tokens[state->next_token++];
+}
+
+/* Roll back one lexer token. */
+void
+l_roll_back(LexerState* state)
+{
+    if(state->next_token > 0)
+        state->next_token--;
+}
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/9.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/9.html new file mode 100644 index 0000000..33bd2b6 --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/9.html @@ -0,0 +1,423 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
#ifndef PRE_LEXER_H
+#define PRE_LEXER_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+/* Structure to store lexer state. */
+typedef struct
+{
+    gchar* stream;		/* Pointer to the local copy of input string. */
+    guint length;		/* Length of input string; stored to reduce calls to strlen(). */
+    guint next_index;		/* Index of next (to be read) character from input. */
+    guint mark_index;		/* Location, last marked. Useful for getting substrings as part of highlighting */
+} PreLexerState;
+
+/* Enum for tokens generated by pre-lexer and lexer. */
+typedef enum
+{
+    T_UNKNOWN=0,		//Unknown
+
+    /* These are all Pre-Lexer tokens, returned by pre-lexer */
+    PL_DECIMAL,			//Decimal saperator
+    PL_DIGIT,			//Decimal digit
+    PL_HEX,			//A-F of Hex digits
+    PL_SUPER_DIGIT,		//Super digits
+    PL_SUPER_MINUS,		//Super minus
+    PL_SUB_DIGIT,		//Sub digits
+    PL_FRACTION,		//Fractions
+    PL_DEGREE,			//Degree
+    PL_MINUTE,			//Minutes
+    PL_SECOND,		//10	//Seconds
+    PL_LETTER,			//Alphabets
+    PL_EOS,			//End of stream. Yay!!
+    PL_SKIP,			//Skip this symbol (whitespace or newline).
+
+    /* These are all tokens, returned by Lexer. */
+    T_ADD,			//Plus
+    T_SUBTRACT,			//Minus
+    T_MULTIPLY,			//Multiply
+    T_DIV,			//Divide (note can't use T_DIVIDE as it is defined in *BSD as an "integer divide fault" trap type value)
+    T_MOD,			//Modulus
+    T_L_FLOOR,			//Floor ( Left )
+    T_R_FLOOR,		//20	//Floor ( Right )
+    T_L_CEILING,		//Ceiling ( Left )
+    T_R_CEILING,		//Ceiling ( Right )
+    T_ROOT,			//Square root
+    T_ROOT_3,			//Cube root
+    T_ROOT_4,			//Fourth root
+    T_NOT,			//Bitwise NOT
+    T_AND,			//Bitwise AND
+    T_OR,			//Bitwise OR
+    T_XOR,			//Bitwise XOR
+    T_IN,		//30	//IN ( for converter )
+    T_NUMBER,			//Number
+    T_SUP_NUMBER,		//Super Number
+    T_NSUP_NUMBER,		//Negative Super Number
+    T_SUB_NUMBER,		//Sub Number
+    T_FUNCTION,			//Function
+    T_VARIABLE,			//Variable name
+    T_ASSIGN,			//=
+    T_L_R_BRACKET,	//40	//(
+    T_R_R_BRACKET,		//)
+    T_L_S_BRACKET,		//[
+    T_R_S_BRACKET,		//]
+    T_L_C_BRACKET,		//{
+    T_R_C_BRACKET,		//}
+    T_ABS,			//|
+    T_POWER,			//^
+    T_FACTORIAL,		//!
+    T_PERCENTAGE	//49	//%
+} LexerTokenType;
+
+/* Creates a scanner state. Useful when multiple scanners are in action. */
+PreLexerState* pl_create_scanner(const gchar*);
+
+/* Destroy and free memory used by LexerState object. */
+void pl_destroy_scanner(PreLexerState*);
+
+/* Roll back last scanned unichar. */
+void pl_roll_back(PreLexerState*);
+
+/* Get validated gunichar from input stream. */
+gunichar pl_get_next_gunichar(PreLexerState*);
+
+/* Set marker index. To be used for highlighting and error reporting. */
+void pl_set_marker(PreLexerState*);
+
+/* Get marked substring. To be used for error reporting. */
+gchar* pl_get_marked_substring(const PreLexerState*);
+
+/* Get next Pre-Lexer token from stream. */
+LexerTokenType pl_get_next_token(PreLexerState*);
+
+#endif /* PRE_LEXER_H */
+
+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/index.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/index.html new file mode 100644 index 0000000..69abb4a --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/index.html @@ -0,0 +1,523 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
src/currency-manager.c
11missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <libxml/tree.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <libxml/parser.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <libxml/xpath.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <libxml/xpathInternals.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
375constVariablePointer398styleVariable 'value' can be declared as pointer to const
src/currency.c
11missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
65constParameterPointer398styleParameter 'value' can be declared as pointer to const
src/currency.h
14missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/financial.c
12missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18constParameterPointer398styleParameter 'fv' can be declared as pointer to const
18constParameterPointer398styleParameter 'pv' can be declared as pointer to const
18constParameterPointer398styleParameter 'pint' can be declared as pointer to const
45constParameterPointer398styleParameter 'period' can be declared as pointer to const
45constParameterPointer398styleParameter 'cost' can be declared as pointer to const
45constParameterPointer398styleParameter 'life' can be declared as pointer to const
88constParameterPointer398styleParameter 'pint' can be declared as pointer to const
88constParameterPointer398styleParameter 'n' can be declared as pointer to const
88constParameterPointer398styleParameter 'pmt' can be declared as pointer to const
116constParameterPointer398styleParameter 'margin' can be declared as pointer to const
116constParameterPointer398styleParameter 'cost' can be declared as pointer to const
137constParameterPointer398styleParameter 'pint' can be declared as pointer to const
137constParameterPointer398styleParameter 'n' can be declared as pointer to const
137constParameterPointer398styleParameter 'prin' can be declared as pointer to const
167constParameterPointer398styleParameter 'pint' can be declared as pointer to const
167constParameterPointer398styleParameter 'n' can be declared as pointer to const
167constParameterPointer398styleParameter 'pmt' can be declared as pointer to const
197constParameterPointer398styleParameter 'fv' can be declared as pointer to const
197constParameterPointer398styleParameter 'pv' can be declared as pointer to const
197constParameterPointer398styleParameter 'n' can be declared as pointer to const
225constParameterPointer398styleParameter 'cost' can be declared as pointer to const
225constParameterPointer398styleParameter 'salvage' can be declared as pointer to const
225constParameterPointer398styleParameter 'life' can be declared as pointer to const
242constParameterPointer398styleParameter 'life' can be declared as pointer to const
242constParameterPointer398styleParameter 'period' can be declared as pointer to const
242constParameterPointer398styleParameter 'cost' can be declared as pointer to const
242constParameterPointer398styleParameter 'salvage' can be declared as pointer to const
276constParameterPointer398styleParameter 'pint' can be declared as pointer to const
276constParameterPointer398styleParameter 'fv' can be declared as pointer to const
276constParameterPointer398styleParameter 'pmt' can be declared as pointer to const
src/lexer.c
1missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <assert.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34variableScope398styleThe scope of the variable 'count' can be reduced.
125unreadVariable563styleVariable 'type' is assigned a value that is never used.
533variableScope398styleThe scope of the variable 'token' can be reduced.
src/mate-calc-cmd.c
11missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
71variableScope398styleThe scope of the variable 'line' can be reduced.
src/mate-calc-resources.c
1missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
9unusedStructMember563styleunion member 'Anonymous0::alignment' is never used.
9unusedStructMember563styleunion member 'Anonymous0::ptr' is never used.
src/mate-calc.c
13missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
20missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
127variableScope398styleThe scope of the variable 'arg' can be reduced.
src/math-buttons.c
11missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
86unusedStructMember563stylestruct member 'ButtonData::class' is never used.
472unreadVariable563styleVariable 'valid' is assigned a value that is never used.
src/math-buttons.h
14missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-converter.c
11missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-converter.h
14missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-display.c
11missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-display.h
14missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-equation.c
12missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <ctype.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
19missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
421variableScope398styleThe scope of the variable 'equation' can be reduced.
828variableScope398styleThe scope of the variable 'text' can be reduced.
1303variableScope398styleThe scope of the variable 'next_factor' can be reduced.
1872constParameterCallback398styleParameter 'text' can be declared as pointer to const. However it seems that 'insert_text_cb' is a callback function, if 'text' is declared with const you might also need to cast function pointer(s).
src/math-equation.h
15missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-history-entry.c
13missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
63constParameterPointer398styleParameter 'answer' can be declared as pointer to const
src/math-history-entry.h
16missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-history.c
13missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-history.h
16missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-preferences.c
11missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
150unreadVariable563styleVariable 'valid' is assigned a value that is never used.
src/math-preferences.h
14missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-variable-popup.c
11missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-variable-popup.h
14missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-variables.c
11missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
90constVariablePointer398styleVariable 'name' can be declared as pointer to const
91constVariablePointer398styleVariable 'value' can be declared as pointer to const
src/math-variables.h
14missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-window.c
13missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
18missingIncludeSysteminformationInclude file: <gdk/gdkkeysyms.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/math-window.h
15missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/mp-binary.c
12missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
69uninitvar457errorUninitialized variable: text_out
src/mp-convert.c
12missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <ctype.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
17missingIncludeSysteminformationInclude file: <langinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
169arrayIndexOutOfBounds788errorArray 'digits[0][10]' accessed at index digits[*][10], which is out of bounds.
199invalidscanf119warningsscanf() without field width limits can crash with huge input data.
229variableScope398styleThe scope of the variable 'numerators' can be reduced.
229constVariable398styleVariable 'numerators' can be declared as const array
230variableScope398styleThe scope of the variable 'denominators' can be reduced.
230constVariable398styleVariable 'denominators' can be declared as const array
317knownConditionTrueFalse398styleThe comparison 'multiplier != 0' is always false.
src/mp-enums.h
8missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/mp-equation.c
12missingIncludeSysteminformationInclude file: <ctype.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
292variableScope398styleThe scope of the variable 'err' can be reduced.
src/mp-serializer.c
12missingIncludeSysteminformationInclude file: <langinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
225knownConditionTrueFalse570styleCondition 'strcmp(s->str,"+0")==0' is always false
227knownConditionTrueFalse571styleCondition 'strcmp(s->str,"0")!=0' is always true
370knownConditionTrueFalse570styleCondition 'strcmp(s->str,"+0")==0' is always false
372knownConditionTrueFalse571styleCondition 'strcmp(s->str,"0")!=0' is always true
src/mp-serializer.h
15missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/mp-trigonometric.c
12missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <libintl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/mp.c
12missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <stdint.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <math.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
16missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
658constParameterPointer398styleParameter 'n' can be declared as pointer to const
src/mp.h
33missingIncludeSysteminformationInclude file: <stdbool.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdint.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <mpfr.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <mpc.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/parser.c
1missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <assert.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
73constParameterPointer398styleParameter 'state' can be declared as pointer to const
80constParameterPointer398styleParameter 'state' can be declared as pointer to const
106constParameterPointer398styleParameter 'left' can be declared as pointer to const
106constParameterPointer398styleParameter 'right' can be declared as pointer to const
327variableScope398styleThe scope of the variable 'buffer' can be reduced.
542variableScope398styleThe scope of the variable 'node' can be reduced.
1165variableScope398styleThe scope of the variable 'node' can be reduced.
1209variableScope398styleThe scope of the variable 'node' can be reduced.
src/parser.h
4missingIncludeSysteminformationInclude file: <lexer.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/parserfunc.c
1missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
172variableScope398styleThe scope of the variable 'buffer' can be reduced.
228variableScope398styleThe scope of the variable 'buffer' can be reduced.
src/prelexer.c
1missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
2missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
4missingIncludeSysteminformationInclude file: <assert.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/prelexer.h
4missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/test-mp-equation.c
11missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/test-mp.c
11missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
12missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
14missingIncludeSysteminformationInclude file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/unit-category.c
12missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/unit-category.h
15missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/unit-manager.c
12missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
13missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
189variableScope398styleThe scope of the variable 'u' can be reduced.
208variableScope398styleThe scope of the variable 'u' can be reduced.
src/unit-manager.h
15missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/unit.c
12missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
80constVariablePointer398styleVariable 's' can be declared as pointer to const
104constVariablePointer398styleVariable 'x' can be declared as pointer to const
173constParameterPointer398styleParameter 'x' can be declared as pointer to const
src/unit.h
15missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/utility.h
4missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeinformationInclude file: "config.h" not found.
+
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/stats.html b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/stats.html new file mode 100644 index 0000000..645f71d --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/stats.html @@ -0,0 +1,195 @@ + + + + + + Cppcheck - HTML report - mate-calc + + + + + +
+ + + +
+

Top 10 files for error severity, total findings: 2
+   1  src/mp-convert.c
+   1  src/mp-binary.c
+

+

Top 10 files for warning severity, total findings: 1
+   1  src/mp-convert.c
+

+

Top 10 files for style severity, total findings: 75
+   30  src/financial.c
+   8   src/parser.c
+   5   src/mp-convert.c
+   4   src/mp-serializer.c
+   4   src/math-equation.c
+   3   src/unit.c
+   3   src/lexer.c
+   2   src/unit-manager.c
+   2   src/parserfunc.c
+   2   src/math-variables.c
+

+

Top 10 files for information severity, total findings: 141
+   9  src/currency-manager.c
+   8  src/math-equation.c
+   6  src/mp.h
+   6  src/mp-convert.c
+   6  src/mate-calc.c
+   6  src/mate-calc-cmd.c
+   5  src/test-mp.c
+   5  src/test-mp-equation.c
+   5  src/mp.c
+   5  src/mp-serializer.c
+

+ +
+ +
+ + diff --git a/2023-11-25-191150-4354-cppcheck@be25688b3305_master/style.css b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-11-25-191150-4354-cppcheck@be25688b3305_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} -- cgit v1.2.1