* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "main.h"
#include "debug.h"
+#include <regex.h>
+#include <sys/time.h>
+
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include <config.h>
+
+#if HAVE_EXECINFO_H
+# include <execinfo.h>
+#endif
+
#include "filedata.h"
+#include "intl.h"
#include "logwindow.h"
+#include "main-defines.h"
+#include "main.h"
#include "misc.h"
+#include "options.h"
#include "ui-fileops.h"
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>
-#endif
-
-#include <regex.h>
-
/*
* Logging functions
*/
-static gchar *regexp = NULL;
+static gchar *regexp = nullptr;
static gboolean log_msg_cb(gpointer data)
{
{
gchar *buf_nl;
regex_t regex;
- gint ret_comp, ret_exec;
+ gint ret_comp;
+ gint ret_exec;
buf_nl = g_strconcat(buf, "\n", NULL);
ret_comp = regcomp(®ex, regexp, 0);
if (!ret_comp)
{
- ret_exec = regexec(®ex, buf_nl, 0, NULL, 0);
+ ret_exec = regexec(®ex, buf_nl, 0, nullptr, 0);
if (!ret_exec)
{
g_free(buf);
}
-void log_domain_print_debug(const gchar *domain, const gchar *file_name, const gchar *function_name,
- int line_number, const gchar *format, ...)
+void log_domain_print_debug(const gchar *domain, const gchar *file_name, int line_number, const gchar *function_name, const gchar *format, ...)
{
va_list ap;
gchar *message;
if (options && options->log_window.timer_data)
{
- location = g_strdup_printf("%s:%s:%s:%d:", get_exec_time(), file_name,
- function_name, line_number);
+ location = g_strdup_printf("%s:%s:%d:%s:", get_exec_time(), file_name, line_number, function_name);
}
else
{
- location = g_strdup_printf("%s:%s:%d:", file_name, function_name, line_number);
+ location = g_strdup_printf("%s:%d:%s:", file_name, line_number, function_name);
}
buf = g_strconcat(location, message, NULL);
static gint debug_level = DEBUG_LEVEL_MIN;
-gint get_debug_level(void)
+gint get_debug_level()
{
return debug_level;
}
return x->tv_sec < y->tv_sec;
}
-const gchar *get_exec_time(void)
+const gchar *get_exec_time()
{
static gchar timestr[30];
static struct timeval start_tv = {0, 0};
struct timeval tv = {0, 0};
static struct timeval delta = {0, 0};
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
if (start_tv.tv_sec == 0) start_tv = tv;
return timestr;
}
-void init_exec_time(void)
+void init_exec_time()
{
get_exec_time();
}
regexp = g_strdup(cmd_regexp);
}
-gchar *get_regexp(void)
+gchar *get_regexp()
{
return g_strdup(regexp);
}
-#ifdef HAVE_EXECINFO_H
+#if HAVE_EXECINFO_H
/**
* @brief Backtrace of geeqie files
* @param file
* Format printed is: \n
* <full path to source file>:<line number>
*
- * The log window F1 command and options->log_window.action may be used
- * to open an editor at a backtrace location.
+ * The log window F1 command and Edit/Preferences/Behavior/Log Window F1
+ * Command may be used to open an editor at a backtrace location.
*/
-void log_print_backtrace(const gchar *file, const gchar *function, gint line)
+void log_print_backtrace(const gchar *file, gint line, const gchar *function)
{
FILE *fp;
char **bt_syms;
gchar *address_offset;
gchar *cmd_line;
gchar *exe_path;
- gchar *function_name = NULL;
+ gchar *function_name = nullptr;
gchar *paren_end;
gchar *paren_start;
gint bt_size;
cmd_line = g_strconcat("addr2line -p -f -C -e ", gq_executable_path, " ", address_offset, NULL);
fp = popen(cmd_line, "r");
- if (fp == NULL)
+ if (fp == nullptr)
{
log_printf("Failed to run command: %s", cmd_line);
}
else
{
- while (fgets(path, sizeof(path), fp) != NULL)
+ while (fgets(path, sizeof(path), fp) != nullptr)
{
/* Remove redundant newline */
path[strlen(path) - 1] = '\0';
- if (g_strstr_len(path, strlen(path), "(") != NULL)
+ if (g_strstr_len(path, strlen(path), "(") != nullptr)
{
function_name = g_strndup(path, g_strstr_len(path, strlen(path), "(") - path);
}
}
}
#else
-void log_print_backtrace(const gchar *file, const gchar *function, gint line)
+void log_print_backtrace(const gchar *, gint, const gchar *)
{
}
#endif