Merge Richard Cohen's 'cleanup' into master.

This commit is contained in:
John Ralls 2023-01-24 12:05:47 -08:00
commit f6919e60a7
37 changed files with 36 additions and 325 deletions

View File

@ -627,7 +627,7 @@ if (XCODE_VERSION)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${LIBDIR_BUILD}/gnucash)
endif()
# For binarines
# For binaries
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if (XCODE_VERSION)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)

View File

@ -18,19 +18,6 @@
* *
\********************************************************************/
#if defined(SWIGGUILE)
%{
/* Disable -Waddress. GCC 4.2 warns (and fails to compile with -Werror) when
* passing the address of a guid on the stack to QOF_BOOK_LOOKUP_ENTITY via
* gncInvoiceLookup and friends. When the macro gets inlined, the compiler
* emits a warning that the guid null pointer test is always true.
*/
#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2)
# pragma GCC diagnostic warning "-Waddress"
#endif
%}
#endif
%rename(gncOwnerReturnGUID) gncOwnerRetGUID;
%inline %{

View File

@ -103,7 +103,7 @@ gnc_new_tip_number (TotdDialog *totd_dialog, gint offset)
*/
if (tip_list[current_tip_number])
tip_components = g_strsplit(tip_list[current_tip_number], "|", 0);
/* If the tip is empty, g_strisplit will return an empty list. This
/* If the tip is empty, g_strsplit will return an empty list. This
* shouldn't normally happen, but make sure we don't crash just in
* case */
if (tip_components == NULL)

View File

@ -1057,7 +1057,7 @@ gnc_date_edit_get_date_internal (GNCDateEdit *gde)
if (!date_was_valid)
{
/* Hm... no valid date. What should we do not? As a hacky workaround we
/* Hm... no valid date. What should we do now? As a hacky workaround we
revert to today's date. Alternatively we can return some value that
signals that we don't get a valid date, but all callers of this
function will have to check this. Alas, I'm too lazy to do this here. */

View File

@ -1331,7 +1331,7 @@ gnc_main_window_quit(GncMainWindow *window)
GList *w, *next;
/* This is not a typical list iteration. There is a possibility
* that the window maybe removed from the active_windows list so
* that the window may be removed from the active_windows list so
* we have to cache the 'next' pointer before executing any code
* in the loop. */
for (w = active_windows; w; w = next)

View File

@ -1431,6 +1431,9 @@ on_finish (GtkAssistant *gtkassistant,
ENTER (" ");
com = gnc_currency_edit_get_currency (GNC_CURRENCY_EDIT(data->currency_selector));
if (!gnc_using_equity_type_opening_balance_account (gnc_get_current_book()))
gnc_set_use_equity_type_opening_balance_account (gnc_get_current_book());
if (data->our_account_tree)
{
gnc_account_foreach_descendant (data->our_account_tree,

View File

@ -45,15 +45,6 @@
#include "dialog-invoice.h"
#include "dialog-job.h"
/* Disable -Waddress. GCC 4.2 warns (and fails to compile with -Werror) when
* passing the address of a guid on the stack to QOF_BOOK_LOOKUP_ENTITY via
* gncInvoiceLookup and friends. When the macro gets inlined, the compiler
* emits a warning that the guid null pointer test is always true.
*/
#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2)
# pragma GCC diagnostic warning "-Waddress"
#endif
#define HANDLE_TYPE(URL_TYPE_STR,OBJ_TYPE) { \
QofBook *book; \
GncGUID guid; \

View File

@ -80,15 +80,6 @@
#include "dialog-transfer.h"
#include "gnc-uri-utils.h"
/* Disable -Waddress. GCC 4.2 warns (and fails to compile with -Werror) when
* passing the address of a guid on the stack to QOF_BOOK_LOOKUP_ENTITY via
* gncInvoiceLookup and friends. When the macro gets inlined, the compiler
* emits a warning that the guid null pointer test is always true.
*/
#if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2)
# pragma GCC diagnostic warning "-Waddress"
#endif
#define DIALOG_NEW_INVOICE_CM_CLASS "dialog-new-invoice"
#define DIALOG_VIEW_INVOICE_CM_CLASS "dialog-view-invoice"

View File

@ -527,6 +527,10 @@ gnc_plugin_page_register_new_common (GNCLedgerDisplay* ledger)
if (!gnc_features_check_used (gnc_get_current_book(), GNC_FEATURE_REG_SORT_FILTER))
gnc_features_set_used (gnc_get_current_book(), GNC_FEATURE_REG_SORT_FILTER);
// added for version 4.14 onwards
if (!gnc_using_equity_type_opening_balance_account (gnc_get_current_book()))
gnc_set_use_equity_type_opening_balance_account (gnc_get_current_book());
/* Is there an existing page? */
gsr = gnc_ledger_display_get_user_data (ledger);
if (gsr)

View File

@ -280,7 +280,7 @@ Gnucash::Gnucash::start ([[maybe_unused]] int argc, [[maybe_unused]] char **argv
Gnucash::CoreApp::start();
/* Now the module files are looked up, which might cause some library
initialization to be run, hence gtk must be initialized b*eforehand. */
initialization to be run, hence gtk must be initialized beforehand. */
gnc_module_system_init();
gnc_gui_init();

View File

@ -109,9 +109,7 @@ static char *olds;
returning a 0 length valid string between two consecutive ocurence of delim.
It will also return a 0 length string instead of NULL when it reaches the end of s
*/
static char * my_strtok (s, delim)
char *s;
const char *delim;
static char * my_strtok (char *s, const char *delim)
{
char *token;
/*DEBUG("strtok(): Start...");*/

View File

@ -2119,7 +2119,7 @@ gnc_ui_qif_import_account_prepare (GtkAssistant *assistant, gpointer user_data)
if (wind->ask_date_format && wind->date_format)
qif_import_reparse_dates (wind);
/* make sure there is a file selected, may of come back */
/* make sure there is a file selected, may have come back */
if (wind->selected_file == SCM_BOOL_F)
{
GtkAssistant *assistant = GTK_ASSISTANT(wind->window);

View File

@ -229,6 +229,12 @@
(gnc-account-get-descendants-sorted (gnc-get-current-root-account)))
(all-splits (get-all-splits currency-accounts end-date))
(interesting-splits (sort (filter interesting-split? all-splits) date<?))
(commodity-list (sort-and-delete-duplicates
commodity-list
(lambda (a b)
(gnc:string-locale<? (gnc-commodity-get-unique-name a)
(gnc-commodity-get-unique-name b)))
gnc-commodity-equal))
(work-to-do (length commodity-list)))
(map
(lambda (c work-done)

View File

@ -738,12 +738,17 @@ also show overall period profit & loss."))
;; generate an exchange-fn for date, and cache its result.
(get-date-exchange-fn
(let ((h (make-hash-table)))
(let ((h (make-hash-table))
(commodities (sort-and-delete-duplicates
(map xaccAccountGetCommodity accounts)
(lambda (a b)
(gnc:string-locale<? (gnc-commodity-get-unique-name a)
(gnc-commodity-get-unique-name b)))
gnc-commodity-equal)))
(lambda (date)
(or (hashv-ref h date)
(let ((exchangefn (gnc:case-exchange-time-fn
price-source common-currency
(map xaccAccountGetCommodity accounts)
price-source common-currency commodities
date #f #f)))
(hashv-set! h date exchangefn)
exchangefn)))))

View File

@ -75,7 +75,7 @@ void gnc_quickfill_purge (QuickFill *qf);
*/
const char * gnc_quickfill_string (QuickFill *qf);
/** Return the subnode of the tree whose strings all hold 'wc' as
/** Return the subnode of the tree whose strings all hold 'c' as
* the next letter. That is, if 'qf' holds all strings starting
* with the letter 'a', and we ask for the letter 'b', then this
* routine will return the node holding all strings that start

View File

@ -553,7 +553,7 @@ GncDbiSqlConnection::quote_string (const std::string& unquoted_str)
/** Check if the dbi connection is valid. If not attempt to re-establish it
* Returns TRUE is there is a valid connection in the end or FALSE otherwise
* Returns TRUE if there is a valid connection in the end or FALSE otherwise
*/
bool
GncDbiSqlConnection::verify () noexcept

View File

@ -76,7 +76,7 @@ public:
set_error(ERR_BACKEND_NO_ERR, 0, false);
}
/** Check if the dbi connection is valid. If not attempt to re-establish it
* Returns TRUE is there is a valid connection in the end or FALSE otherwise
* Returns TRUE if there is a valid connection in the end or FALSE otherwise
*/
bool verify() noexcept override;
bool retry_connection(const char* msg) noexcept override;

View File

@ -11,7 +11,6 @@ set (core_utils_SOURCES
gnc-filepath-utils.cpp
gnc-gkeyfile-utils.c
gnc-glib-utils.c
gnc-jalali.c
gnc-locale-utils.c
gnc-locale-utils.cpp
gnc-path.c
@ -29,7 +28,6 @@ set(core_utils_noinst_HEADERS
gnc-filepath-utils.h
gnc-gkeyfile-utils.h
gnc-glib-utils.h
gnc-jalali.h
gnc-locale-utils.h
gnc-locale-utils.hpp
gnc-path.h

View File

@ -1,196 +0,0 @@
/* This file is part of:
* Jalali, a Gregorian to Jalali and inverse date converter
* Copyright (C) 2001 Roozbeh Pournader <roozbeh@sharif.edu>
* Copyright (C) 2001 Mohammad Toossi <mohammad@bamdad.org>
*
* This program 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 program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You can receive a copy of GNU Lesser General Public License at the
* World Wide Web address <https://www.gnu.org/licenses/lgpl.html>.
*
* For licensing issues, contact The FarsiWeb Project Group,
* Computing Center, Sharif University of Technology,
* PO Box 11365-8515, Tehran, Iran, or contact us the
* email address <FWPG@sharif.edu>.
*/
/* Changes:
*
* 2005-Sep-06:
* General cleanup --Behdad Esfahbod
*
* 2001-Sep-21:
* Fixed a bug with "30 Esfand" dates, reported by Mahmoud Ghandi
*
* 2001-Sep-20:
* First LGPL release, with both sides of conversions
*/
#include "gnc-jalali.h"
/* implementation */
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
int g_days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int j_days_in_month[12] = {31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29};
const char *j_month_name[12] =
{
"Farvardin", "Ordibehesht", "Khordad",
"Tir", "Mordad", "Shahrivar",
"Mehr", "Aban", "Azar",
"Dey", "Bahman", "Esfand"
};
int gnc_jalali_days_in_month(int month_index)
{
g_assert(month_index < 12);
return j_days_in_month[month_index];
}
const char* gnc_jalali_month_name(int month_index)
{
g_assert(month_index < 12);
return j_month_name[month_index];
}
void gnc_gregorian_to_jalali(int *j_y, int *j_m, int *j_d,
int g_y, int g_m, int g_d)
{
int gy, gm, gd;
int jy, jm, jd;
long g_day_no, j_day_no;
int j_np;
int i;
gy = g_y - 1600;
gm = g_m - 1;
gd = g_d - 1;
g_day_no = 365 * gy + (gy + 3) / 4 - (gy + 99) / 100 + (gy + 399) / 400;
for (i = 0; i < gm; ++i)
g_day_no += g_days_in_month[i];
if (gm > 1 && ((gy % 4 == 0 && gy % 100 != 0) || (gy % 400 == 0)))
/* leap and after Feb */
++g_day_no;
g_day_no += gd;
j_day_no = g_day_no - 79;
j_np = j_day_no / 12053;
j_day_no %= 12053;
jy = 979 + 33 * j_np + 4 * (j_day_no / 1461);
j_day_no %= 1461;
if (j_day_no >= 366)
{
jy += (j_day_no - 1) / 365;
j_day_no = (j_day_no - 1) % 365;
}
for (i = 0; i < 11 && j_day_no >= j_days_in_month[i]; ++i)
{
j_day_no -= j_days_in_month[i];
}
jm = i + 1;
jd = j_day_no + 1;
*j_y = jy;
*j_m = jm;
*j_d = jd;
}
void gnc_jalali_to_gregorian(int *g_y, int *g_m, int *g_d,
int j_y, int j_m, int j_d)
{
int gy, gm, gd;
int jy, jm, jd;
long g_day_no, j_day_no;
int leap;
int i;
jy = j_y - 979;
jm = j_m - 1;
jd = j_d - 1;
j_day_no = 365 * jy + (jy / 33) * 8 + (jy % 33 + 3) / 4;
for (i = 0; i < jm; ++i)
j_day_no += j_days_in_month[i];
j_day_no += jd;
g_day_no = j_day_no + 79;
gy = 1600 + 400 * (g_day_no / 146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
g_day_no = g_day_no % 146097;
leap = 1;
if (g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */
{
g_day_no--;
gy += 100 * (g_day_no / 36524); /* 36524 = 365*100 + 100/4 - 100/100 */
g_day_no = g_day_no % 36524;
if (g_day_no >= 365)
g_day_no++;
else
leap = 0;
}
gy += 4 * (g_day_no / 1461); /* 1461 = 365*4 + 4/4 */
g_day_no %= 1461;
if (g_day_no >= 366)
{
leap = 0;
g_day_no--;
gy += g_day_no / 365;
g_day_no = g_day_no % 365;
}
for (i = 0; g_day_no >= g_days_in_month[i] + (i == 1 && leap); i++)
g_day_no -= g_days_in_month[i] + (i == 1 && leap);
gm = i + 1;
gd = g_day_no + 1;
*g_y = gy;
*g_m = gm;
*g_d = gd;
}
#if 0
int
main(void)
{
int y, m, d;
time64 bin_time;
struct tm br_time;
gnc_time (&bin_time);
gnc_localtime_r (&bin_time, &br_time);
gregorian_to_jalali(&y, &m, &d,
1900 + br_time.tm_year,
1 + br_time.tm_mon,
br_time.tm_mday);
printf("Current Jalali date: %d %s %d\n", d, j_month_name[m-1], y);
return 0;
}
#endif

View File

@ -1,46 +0,0 @@
/*
* jalali.h
* Copyright (C) 2010 Christian Stimming
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, contact:
*
* Free Software Foundation Voice: +1-617-542-5942
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
* Boston, MA 02110-1301, USA gnu@gnu.org
*/
#ifndef GNC_JALALI_H
#define GNC_JALALI_H
/** Convert gregorian year/month/day (arguments 4-6) to jalali
* year/month/day (arguments 1-3) */
void gnc_gregorian_to_jalali(/* output */ int *j_y, int *j_m, int *j_d,
/* input */ int g_y, int g_m, int g_d);
/** Convert jalali year/month/day (arguments 4-6) to gregorian
* year/month/day (arguments 1-3) */
void gnc_jalali_to_gregorian(/* output */ int *g_y, int *g_m, int *g_d,
/* input */ int j_y, int j_m, int j_d);
/** Returns the number of days in month in the Jalali calendar, which
* is different from the Gregorian one. Argument month_index is 0 for
* the first month. */
int gnc_jalali_days_in_month(int month_index);
/** Returns the month name of the Jalali calendar. Argument
* month_index is 0 for the first month. */
const char* gnc_jalali_month_name(int month_index);
#endif

View File

@ -119,8 +119,6 @@ void gncBillTermSetCutoff (GncBillTerm *term, gint cutoff);
/** Return a pointer to the instance gncBillTerm that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncBillTerm * gncBillTermLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncBillTerm * gncBillTermLookup (const QofBook *book, const GncGUID *guid)
{

View File

@ -116,8 +116,6 @@ void gncCustomerRemoveJob (GncCustomer *customer, GncJob *job);
/** Return a pointer to the instance gncCustomer that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncCustomer * gncCustomerLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncCustomer * gncCustomerLookup (const QofBook *book, const GncGUID *guid)
{

View File

@ -112,8 +112,6 @@ Account * gncEmployeeGetCCard (const GncEmployee *employee);
/** Return a pointer to the instance gncEmployee that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncEmployee * gncEmployeeLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncEmployee * gncEmployeeLookup (const QofBook *book, const GncGUID *guid)
{

View File

@ -290,8 +290,6 @@ GncInvoice * gncEntryGetBill (const GncEntry *entry);
/** Return a pointer to the instance gncEntry that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncEntry * gncEntryLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncEntry * gncEntryLookup (const QofBook *book, const GncGUID *guid)
{

View File

@ -272,8 +272,6 @@ GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot);
/** Return a pointer to the instance gncInvoice that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncInvoice * gncInvoiceLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncInvoice * gncInvoiceLookup (const QofBook *book, const GncGUID *guid)
{

View File

@ -93,8 +93,6 @@ gboolean gncJobGetActive (const GncJob *job);
/** Return a pointer to the instance gncJob that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncJob * gncJobLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncJob * gncJobLookup (const QofBook *book, const GncGUID *guid)
{

View File

@ -102,8 +102,6 @@ gboolean gncOrderIsClosed (const GncOrder *order);
/** Return a pointer to the instance gncOrder that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncOrder * gncOrderLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncOrder * gncOrderLookup (const QofBook *book, const GncGUID *guid)
{

View File

@ -146,8 +146,6 @@ gboolean gncTaxTableEqual(const GncTaxTable *a, const GncTaxTable *b);
/** Return a pointer to the instance gncTaxTable that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncTaxTable * gncTaxTableLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GncGUID *guid)
{

View File

@ -112,8 +112,6 @@ int gncVendorCompare (const GncVendor *a, const GncVendor *b);
/** Return a pointer to the instance gncVendor that is identified
* by the guid, and is residing in the book. Returns NULL if the
* instance can't be found.
* Equivalent function prototype is
* GncVendor * gncVendorLookup (QofBook *book, const GncGUID *guid);
*/
static inline GncVendor * gncVendorLookup (const QofBook *book, const GncGUID *guid)
{

View File

@ -233,7 +233,7 @@ qof_log_init_filename(const gchar* log_filename)
g_assert(g_strcmp0(log_filename, "/dev/null") != 0);
/* Windows prevents renaming of open files, so the next command silently fails there
* No problem, the filename on Winows will simply have the random characters */
* No problem, the filename on Windows will simply have the random characters */
g_rename(fname, log_filename);
fout = fdopen(fd, "w");
#endif

View File

@ -43,17 +43,10 @@ static GList *book_list = NULL;
extern "C"
{
gboolean get_object_is_initialized( void );
GList* get_object_modules( void );
GList* get_book_list( void );
}
gboolean
get_object_is_initialized( void )
{
return object_is_initialized;
}
GList*
get_object_modules( void )
{

View File

@ -204,7 +204,6 @@ gnc_add_test(test-qofevent "${test_qofevent_SOURCES}"
set(test_engine_SOURCES_DIST
dummy.cpp
gtest-gnc-euro.cpp
gtest-gnc-int128.cpp
gtest-gnc-rational.cpp

View File

@ -1,2 +0,0 @@
// This is a dummy source file since we need a C++ file in test_engine so
// it will be linked as a C++ program.

View File

@ -82,7 +82,7 @@ TEST (GncGUID, from_string)
fail = true;
}
/* Currently, boost uuid string parsing is mostly very permissive, but it has some
* odd pet peves. See https://svn.boost.org/trac/boost/ticket/12253 for more.*/
* odd pet peeves. See https://svn.boost.org/trac/boost/ticket/12253 for more.*/
if (BOOST_VERSION >= 106600)
EXPECT_TRUE (fail) << "Parsing the bogus string should throw";
else

View File

@ -77,7 +77,6 @@ new_object( QofIdType e_type, const char *type_label, MockFields field)
return object;
}
extern gboolean get_object_is_initialized( void );
extern GList* get_object_modules( void );
extern GList* get_book_list( void );

View File

@ -228,9 +228,9 @@ gnc_module_system_refresh(void)
/* Gotcha: On MacOS, G_MODULE_SUFFIX is defined as "so",
* but if we do not build clean libtool modules with
* "-module", we get dynamic libraries ending on .dylib On
* Windows, all modules will move to bin/, so they will be
* mixed with other libraries, such as gtk+. Adding a
* "-module", we get dynamic libraries ending in .dylib
* On Windows, all modules will move to bin/, so they will
* be mixed with other libraries, such as gtk+. Adding a
* prefix "libgncmod" filter will prevent the module loader
* from loading other libraries. The filter should work on
* other platforms.

View File

@ -616,7 +616,6 @@ libgnucash/core-utils/gnc-environment.c
libgnucash/core-utils/gnc-filepath-utils.cpp
libgnucash/core-utils/gnc-gkeyfile-utils.c
libgnucash/core-utils/gnc-glib-utils.c
libgnucash/core-utils/gnc-jalali.c
libgnucash/core-utils/gnc-locale-utils.c
libgnucash/core-utils/gnc-locale-utils.cpp
libgnucash/core-utils/gnc-path.c