tFix regression from 3d2081c, correctly handle '\n' ending lines (bis) - sacc -… | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 1f25175ac21819a702f38edaf034a16825cd5c07 | |
parent 3399f31a720905a2ebd03191945307b9aafb0ad4 | |
Author: Quentin Rameau <[email protected]> | |
Date: Fri, 24 Aug 2018 18:21:44 +0200 | |
Fix regression from 3d2081c, correctly handle '\n' ending lines (bis) | |
This is a followup to 43803be, the patch was not finished. | |
Diffstat: | |
sacc.c | 13 ++++++++----- | |
1 file changed, 8 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/sacc.c b/sacc.c | |
t@@ -298,13 +298,16 @@ displaytextitem(Item *item) | |
static char * | |
pickfield(char **raw, const char *sep) | |
{ | |
- char *c, *f = *raw; | |
+ char c, *r, *f = *raw; | |
- for (c = *raw; *c && !strchr(sep, *c); ++c) | |
- ; | |
+ for (r = *raw; (c = *r) && !strchr(sep, c); ++r) { | |
+ if (c == '\n') | |
+ goto skipsep; | |
+ } | |
- *c = '\0'; | |
- *raw = c+1; | |
+ *r++ = '\0'; | |
+skipsep: | |
+ *raw = r; | |
return f; | |
} |