aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-04-03 15:01:00 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-04-03 15:01:00 +0200
commit94780e3e8e926e7e9f384c4b70310b3e7e79abce (patch)
tree69a75378d348c249f8ee66f3a0c97bb6051ea4da /shell
parent7ababc3e3cd44cb51ad1b0183f7fe30df0fb3cbf (diff)
downloadbusybox-w32-94780e3e8e926e7e9f384c4b70310b3e7e79abce.tar.gz
busybox-w32-94780e3e8e926e7e9f384c4b70310b3e7e79abce.tar.bz2
busybox-w32-94780e3e8e926e7e9f384c4b70310b3e7e79abce.zip
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 f057b8963..bd3afc0c8 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -2110,10 +2110,7 @@ change_lc_ctype(const char *value)
2110} 2110}
2111#endif 2111#endif
2112#if ENABLE_ASH_MAIL 2112#if ENABLE_ASH_MAIL
2113static void chkmail(void);
2114static void changemail(const char *var_value) FAST_FUNC; 2113static void changemail(const char *var_value) FAST_FUNC;
2115#else
2116# define chkmail() ((void)0)
2117#endif 2114#endif
2118static void changepath(const char *) FAST_FUNC; 2115static void changepath(const char *) FAST_FUNC;
2119#if ENABLE_ASH_RANDOM_SUPPORT 2116#if ENABLE_ASH_RANDOM_SUPPORT
@@ -11258,13 +11255,12 @@ setinputstring(char *string)
11258#if ENABLE_ASH_MAIL 11255#if ENABLE_ASH_MAIL
11259 11256
11260/* Hash of mtimes of mailboxes */ 11257/* Hash of mtimes of mailboxes */
11258/* Cleared to 0 if MAIL or MAILPATH is changed */
11261static unsigned mailtime_hash; 11259static unsigned mailtime_hash;
11262/* Set if MAIL or MAILPATH is changed. */
11263static smallint mail_var_path_changed;
11264 11260
11265/* 11261/*
11266 * Print appropriate message(s) if mail has arrived. 11262 * Print appropriate message(s) if mail has arrived.
11267 * If mail_var_path_changed is set, 11263 * If mailtime_hash is zero,
11268 * then the value of MAIL has changed, 11264 * then the value of MAIL has changed,
11269 * so we just update the hash value. 11265 * so we just update the hash value.
11270 */ 11266 */
@@ -11303,21 +11299,24 @@ chkmail(void)
11303 /* Very simplistic "hash": just a sum of all mtimes */ 11299 /* Very simplistic "hash": just a sum of all mtimes */
11304 new_hash += (unsigned)statb.st_mtime; 11300 new_hash += (unsigned)statb.st_mtime;
11305 } 11301 }
11306 if (!mail_var_path_changed && mailtime_hash != new_hash) { 11302 if (mailtime_hash != new_hash) {
11307 if (mailtime_hash != 0) 11303 if (mailtime_hash != 0)
11308 out2str("you have mail\n"); 11304 out2str("you have mail\n");
11305 mailtime_hash = new_hash;
11309 } 11306 }
11310 mailtime_hash = new_hash;
11311 mail_var_path_changed = 0;
11312 popstackmark(&smark); 11307 popstackmark(&smark);
11313} 11308}
11314 11309
11315static void FAST_FUNC 11310static void FAST_FUNC
11316changemail(const char *val UNUSED_PARAM) 11311changemail(const char *val UNUSED_PARAM)
11317{ 11312{
11318 mail_var_path_changed = 1; 11313 mailtime_hash = 0;
11319} 11314}
11320 11315
11316#else
11317
11318# define chkmail() ((void)0)
11319
11321#endif /* ASH_MAIL */ 11320#endif /* ASH_MAIL */
11322 11321
11323 11322