summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2023-04-03 15:01:00 +0200
committerDenys Vlasenko2023-04-03 15:01:00 +0200
commit94780e3e8e926e7e9f384c4b70310b3e7e79abce (patch)
tree69a75378d348c249f8ee66f3a0c97bb6051ea4da /shell
parent7ababc3e3cd44cb51ad1b0183f7fe30df0fb3cbf (diff)
downloadbusybox-94780e3e8e926e7e9f384c4b70310b3e7e79abce.zip
busybox-94780e3e8e926e7e9f384c4b70310b3e7e79abce.tar.gz
ash: get rid of separate mail_var_path_changed flag variable
We can just clear mailtime_hash to zero and have the same effect. function old new delta changemail 8 11 +3 mail_var_path_changed 1 - -1 cmdloop 398 382 -16 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 3/-17) Total: -14 bytes text data bss dec hex filename 1054786 559 5020 1060365 102e0d busybox_old 1054773 559 5020 1060352 102e00 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/shell/ash.c b/shell/ash.c
index f057b89..bd3afc0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -2110,10 +2110,7 @@ change_lc_ctype(const char *value)
}
#endif
#if ENABLE_ASH_MAIL
-static void chkmail(void);
static void changemail(const char *var_value) FAST_FUNC;
-#else
-# define chkmail() ((void)0)
#endif
static void changepath(const char *) FAST_FUNC;
#if ENABLE_ASH_RANDOM_SUPPORT
@@ -11258,13 +11255,12 @@ setinputstring(char *string)
#if ENABLE_ASH_MAIL
/* Hash of mtimes of mailboxes */
+/* Cleared to 0 if MAIL or MAILPATH is changed */
static unsigned mailtime_hash;
-/* Set if MAIL or MAILPATH is changed. */
-static smallint mail_var_path_changed;
/*
* Print appropriate message(s) if mail has arrived.
- * If mail_var_path_changed is set,
+ * If mailtime_hash is zero,
* then the value of MAIL has changed,
* so we just update the hash value.
*/
@@ -11303,21 +11299,24 @@ chkmail(void)
/* Very simplistic "hash": just a sum of all mtimes */
new_hash += (unsigned)statb.st_mtime;
}
- if (!mail_var_path_changed && mailtime_hash != new_hash) {
+ if (mailtime_hash != new_hash) {
if (mailtime_hash != 0)
out2str("you have mail\n");
+ mailtime_hash = new_hash;
}
- mailtime_hash = new_hash;
- mail_var_path_changed = 0;
popstackmark(&smark);
}
static void FAST_FUNC
changemail(const char *val UNUSED_PARAM)
{
- mail_var_path_changed = 1;
+ mailtime_hash = 0;
}
+#else
+
+# define chkmail() ((void)0)
+
#endif /* ASH_MAIL */