Removed redundant explanatory comments in chanopt_command so the control flow reads cleanly without inline narration, while keeping behavior unchanged.

Simplified the chanopt_in_memory struct and helper routines by removing comments that repeated obvious intent (allocation/default initialization/loading notes), with no logic changes.
This commit is contained in:
2026-02-25 01:02:37 -07:00
parent e6311a5fe7
commit 51bf0c3fe0

View File

@@ -99,8 +99,6 @@ str_to_chanopt (const char *str)
return SET_DEFAULT; return SET_DEFAULT;
} }
/* handle the /CHANOPT command */
int int
chanopt_command (session *sess, char *tbuf, char *word[], char *word_eol[]) chanopt_command (session *sess, char *tbuf, char *word[], char *word_eol[])
{ {
@@ -135,13 +133,13 @@ chanopt_command (session *sess, char *tbuf, char *word[], char *word_eol[])
{ {
if (find[0] == 0 || match (find, chanopt[i].name) || (chanopt[i].alias && match (find, chanopt[i].alias))) if (find[0] == 0 || match (find, chanopt[i].name) || (chanopt[i].alias && match (find, chanopt[i].alias)))
{ {
if (newval != -1) /* set new value */ if (newval != -1)
{ {
*(guint8 *)G_STRUCT_MEMBER_P(sess, chanopt[i].offset) = newval; *(guint8 *)G_STRUCT_MEMBER_P(sess, chanopt[i].offset) = newval;
chanopt_changed = TRUE; chanopt_changed = TRUE;
} }
if (!quiet) /* print value */ if (!quiet)
{ {
strcpy (tbuf, chanopt[i].name); strcpy (tbuf, chanopt[i].name);
p = strlen (tbuf); p = strlen (tbuf);
@@ -177,18 +175,13 @@ chanopt_is_set (unsigned int global, guint8 per_chan_setting)
return global; return global;
} }
/* === below is LOADING/SAVING stuff only === */
typedef struct typedef struct
{ {
/* Per-Channel Alerts */
/* use a byte, because we need a pointer to each element */
guint8 alert_balloon; guint8 alert_balloon;
guint8 alert_beep; guint8 alert_beep;
guint8 alert_taskbar; guint8 alert_taskbar;
guint8 alert_tray; guint8 alert_tray;
/* Per-Channel Settings */
guint8 text_hidejoinpart; guint8 text_hidejoinpart;
guint8 text_logging; guint8 text_logging;
guint8 text_scrollback; guint8 text_scrollback;
@@ -218,12 +211,10 @@ chanopt_find (char *network, char *channel, gboolean add_new)
if (!add_new) if (!add_new)
return NULL; return NULL;
/* allocate a new one */
co = g_new0 (chanopt_in_memory, 1); co = g_new0 (chanopt_in_memory, 1);
co->channel = g_strdup (channel); co->channel = g_strdup (channel);
co->network = g_strdup (network); co->network = g_strdup (network);
/* set all values to SET_DEFAULT */
i = 0; i = 0;
while (i < sizeof (chanopt) / sizeof (channel_options)) while (i < sizeof (chanopt) / sizeof (channel_options))
{ {
@@ -254,8 +245,6 @@ chanopt_add_opt (chanopt_in_memory *co, char *var, int new_value)
} }
} }
/* load chanopt.conf from disk into our chanopt_list GSList */
static void static void
chanopt_load_all (void) chanopt_load_all (void)
{ {
@@ -265,7 +254,6 @@ chanopt_load_all (void)
char *network = NULL; char *network = NULL;
chanopt_in_memory *current = NULL; chanopt_in_memory *current = NULL;
/* 1. load the old file into our GSList */
fh = zoitechat_open_file ("chanopt.conf", O_RDONLY, 0, 0); fh = zoitechat_open_file ("chanopt.conf", O_RDONLY, 0, 0);
if (fh != -1) if (fh != -1)
{ {
@@ -326,7 +314,6 @@ chanopt_load (session *sess)
if (!co) if (!co)
return; return;
/* fill in all the sess->xxxxx fields */
i = 0; i = 0;
while (i < sizeof (chanopt) / sizeof (channel_options)) while (i < sizeof (chanopt) / sizeof (channel_options))
{ {
@@ -352,8 +339,6 @@ chanopt_save (session *sess)
if (!network) if (!network)
return; return;
/* 2. reconcile sess with what we loaded from disk */
co = chanopt_find (network, sess->session_name, TRUE); co = chanopt_find (network, sess->session_name, TRUE);
i = 0; i = 0;