summary refs log tree commit diff stats
path: root/src/common/cfgfiles.c
diff options
context:
space:
mode:
authorBerke Viktor <bviktor@hexchat.org>2012-10-15 16:01:26 +0200
committerBerke Viktor <bviktor@hexchat.org>2012-10-15 16:01:26 +0200
commitc19fc07b9b99942130159b6ce4860fd775110a18 (patch)
tree671a140d9b3f9707155608d1d2c486631d939ad8 /src/common/cfgfiles.c
parent13449c282af66183646d758178e6862540f31898 (diff)
Print previous value after /SET
Diffstat (limited to 'src/common/cfgfiles.c')
-rw-r--r--src/common/cfgfiles.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
index f60e889c..4ac47f58 100644
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -1034,7 +1034,8 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 	int erase = FALSE;
 	int i = 0, finds = 0, found;
 	int idx = 2;
-	char *var, *val;
+	int prev_numeric;
+	char *var, *val, *prev_string;
 
 	if (g_ascii_strcasecmp (word[2], "-e") == 0)
 	{
@@ -1100,13 +1101,20 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 			case TYPE_STR:
 				if (erase || *val)
 				{
+					/* save the previous value until we print it out */
+					prev_string = (char*) malloc (vars[i].len + 1);
+					strncpy (prev_string, (char *) &prefs + vars[i].offset, vars[i].len);
+
+					/* update the variable */
 					strncpy ((char *) &prefs + vars[i].offset, val, vars[i].len);
 					((char *) &prefs)[vars[i].offset + vars[i].len - 1] = 0;
 
 					if (!quiet)
 					{
-						PrintTextf (sess, "%s set to: %s\n", var, (char *) &prefs + vars[i].offset);
+						PrintTextf (sess, "%s set to: %s (was: %s)\n", var, (char *) &prefs + vars[i].offset, prev_string);
 					}
+
+					free (prev_string);
 				}
 				else
 				{
@@ -1117,6 +1125,7 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 			case TYPE_BOOL:
 				if (*val)
 				{
+					prev_numeric = *((int *) &prefs + vars[i].offset);
 					if (vars[i].type == TYPE_BOOL)
 					{
 						if (atoi (val))
@@ -1153,8 +1162,7 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 					}
 					if (!quiet)
 					{
-						PrintTextf (sess, "%s set to: %d\n", var,
-										*((int *) &prefs + vars[i].offset));
+						PrintTextf (sess, "%s set to: %d (was: %d)\n", var, *((int *) &prefs + vars[i].offset), prev_numeric);
 					}
 				}
 				else