jdict

command line tool for looking up terms in yomidict dictionaries
git clone anongit@rnpnr.xyz:jdict.git
Log | Files | Refs | Feed | README | LICENSE

Commit: f9293fd95f8395fd6295c99cbfe98ed956b48231
Parent: aaf1b2e2ed763d19c6a6aa3d580994034fd45d39
Author: Randy Palamar
Date:   Thu, 25 May 2023 14:42:34 -0600

util: trim(): further simplify by initializing p to the end of s

Diffstat:
Mutil.c | 9++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/util.c b/util.c @@ -26,13 +26,12 @@ die(const char *fmt, ...) char * trim(char *s) { - char *p = s; - size_t len = strlen(s); + char *p = &s[strlen(s)-1]; - for (; isspace(p[len-1]); p[--len] = 0); - for (; *p && isspace(*p); p++); + for (; isspace(*p); *p = 0, p--); + for (; *s && isspace(*s); s++); - return p; + return s; } /* replace embedded escaped newlines with actual newlines */