Fix parsing of timestamp options

This commit is contained in:
Martin Lund 2025-02-15 19:50:52 +01:00
parent 8f7bf2fd2c
commit 6831ad0eae
2 changed files with 14 additions and 12 deletions

View file

@ -31,6 +31,7 @@
#include <regex.h>
#include <glib.h>
#include "configfile.h"
#include "timestamp.h"
#include "print.h"
#include "rs485.h"
#include "misc.h"
@ -148,7 +149,6 @@ static void config_get_bool(GKeyFile *key_file, gchar *group, gchar *key, bool *
static void config_parse_keys(GKeyFile *key_file, char *group)
{
char *string = NULL;
bool boolean = false;
config_get_string(key_file, group, "device", &config.device, NULL);
config_get_integer(key_file, group, "baudrate", &option.baudrate, 0, INT_MAX);
@ -204,11 +204,9 @@ static void config_parse_keys(GKeyFile *key_file, char *group)
g_free((void *)string);
string = NULL;
}
config_get_bool(key_file, group, "timestamp", &boolean);
if (boolean == true)
config_get_bool(key_file, group, "timestamp", (bool*) &option.timestamp);
if (option.timestamp != TIMESTAMP_NONE)
{
option.timestamp = TIMESTAMP_24HOUR;
}
config_get_string(key_file, group, "timestamp-format", &string, "24hour", "24hour-start", "24hour-delta", "iso8601", "epoch", NULL);
if (string != NULL)
{
@ -216,6 +214,7 @@ static void config_parse_keys(GKeyFile *key_file, char *group)
g_free((void *)string);
string = NULL;
}
}
config_get_integer(key_file, group, "timestamp-timeout", &option.timestamp_timeout, 0, INT_MAX);
config_get_bool(key_file, group, "log", &option.log);
config_get_string(key_file, group, "log-file", &option.log_filename, NULL);

View file

@ -998,7 +998,10 @@ void options_parse(int argc, char *argv[])
break;
case 't':
if (option.timestamp == TIMESTAMP_NONE)
{
option.timestamp = TIMESTAMP_24HOUR;
}
break;
case OPT_TIMESTAMP_FORMAT: