fixed bug with trimming string with all space characters

This commit is contained in:
Daniel Holden
2019-09-01 16:21:11 -04:00
parent e1038bc376
commit 5120609e6e

2
mpc.c
View File

@@ -2470,7 +2470,7 @@ mpc_val_t *mpcf_strtriml(mpc_val_t *x) {
mpc_val_t *mpcf_strtrimr(mpc_val_t *x) { mpc_val_t *mpcf_strtrimr(mpc_val_t *x) {
char *s = x; char *s = x;
size_t l = strlen(s); size_t l = strlen(s);
while (isspace((unsigned char)s[l-1])) { while (l > 0 && isspace((unsigned char)s[l-1])) {
s[l-1] = '\0'; l--; s[l-1] = '\0'; l--;
} }
return s; return s;