fixed bug with trimming string with all space characters
This commit is contained in:
2
mpc.c
2
mpc.c
@@ -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;
|
||||||
|
Reference in New Issue
Block a user