ap

An audio player suited to my tastes
Log | Files | Refs | README | LICENSE

commit 051cf87fe748082f0ef0eed06baeba12d4bf0708
parent e157546ebfbc00c5320cb7733aee7d04ac825761
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Wed, 25 Aug 2021 22:55:28 -0700

Fix and improve unquote function

It is now a half decent function and also fix bug where **sp was
tested against nul instead of **sp.

Diffstat:
Maps/split.c | 24+++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/aps/split.c b/aps/split.c @@ -24,30 +24,24 @@ char * unquote(char **sp, char quote, char *delim) { char *start; - int quoted; - while (**sp && strchr(delim, **sp)) - ++*sp; - if (!**sp) + start = *sp + strspn(*sp, delim); + if (*start == '\0') return NULL; - if (**sp != quote) { - quoted = 0; - } else { - quoted = 1; - ++*sp; - } - start = *sp; - - if (!quoted) { - *sp += strcspn(*sp, delim); - if (*sp) { + if (*start != quote) { + *sp = start + strcspn(start, delim); + if (**sp != '\0') { **sp = 0; ++*sp; } return start; } + *sp = ++start; + if (*start == '\0') + return NULL; + for (; **sp; ++*sp) { if (**sp == quote) { if ((*sp)[1] != quote) {