about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJohn Hernandez <129467592+H3rnand3zzz@users.noreply.github.com>2023-04-18 18:16:57 +0200
committerJohn Hernandez <129467592+H3rnand3zzz@users.noreply.github.com>2023-04-18 18:16:57 +0200
commit5a1f2dedd3e2d8e74aefbfdb51c9af670c0cbbd9 (patch)
tree4842b204b23e2239236be820f5ea51da6e92e4ff /src/command
parent4933d4e4f3d1cc8ee308c1bb6bfc4c13ec64ac57 (diff)
downloadprofani-tty-5a1f2dedd3e2d8e74aefbfdb51c9af670c0cbbd9.tar.gz
Fix `/log level` crash
Fix crash caused by `/log level` command.

Minor refactoring of command function.
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_funcs.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 4a5c7fa1..507a8ccd 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -6516,12 +6516,17 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
     char* subcmd = args[0];
     char* value = args[1];
 
-    if (strcmp(subcmd, "maxsize") == 0) {
-        if (value == NULL) {
-            cons_bad_cmd_usage(command);
-            return TRUE;
-        }
+    if (strcmp(subcmd, "where") == 0) {
+        cons_show("Log file: %s", get_log_file_location());
+        return TRUE;
+    }
 
+    if (value == NULL) {
+        cons_bad_cmd_usage(command);
+        return TRUE;
+    }
+
+    if (strcmp(subcmd, "maxsize") == 0) {
         int intval = 0;
         char* err_msg = NULL;
         gboolean res = strtoi_range(value, &intval, PREFS_MIN_LOG_SIZE, INT_MAX, &err_msg);
@@ -6536,29 +6541,16 @@ cmd_log(ProfWin* window, const char* const command, gchar** args)
     }
 
     if (strcmp(subcmd, "rotate") == 0) {
-        if (value == NULL) {
-            cons_bad_cmd_usage(command);
-            return TRUE;
-        }
         _cmd_set_boolean_preference(value, command, "Log rotate", PREF_LOG_ROTATE);
         return TRUE;
     }
 
     if (strcmp(subcmd, "shared") == 0) {
-        if (value == NULL) {
-            cons_bad_cmd_usage(command);
-            return TRUE;
-        }
         _cmd_set_boolean_preference(value, command, "Shared log", PREF_LOG_SHARED);
         cons_show("Setting only takes effect after saving and restarting Profanity.");
         return TRUE;
     }
 
-    if (strcmp(subcmd, "where") == 0) {
-        cons_show("Log file: %s", get_log_file_location());
-        return TRUE;
-    }
-
     if (strcmp(subcmd, "level") == 0) {
         log_level_t prof_log_level;
         if (log_level_from_string(value, &prof_log_level) == 0) {