aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-11-27 13:14:14 -0500
committerMike Frysinger <vapier@gentoo.org>2015-11-27 13:14:14 -0500
commit92de436359da8f14b7dbef5f62af959095b79d06 (patch)
tree5936173e0b278b45a58d5ea1601433d7cce1ee81 /qfile.c
parentrmspace: rewrite/optimize a bit (diff)
downloadportage-utils-92de436359da8f14b7dbef5f62af959095b79d06.tar.gz
portage-utils-92de436359da8f14b7dbef5f62af959095b79d06.tar.bz2
portage-utils-92de436359da8f14b7dbef5f62af959095b79d06.zip
use the return value of getline
This allows us to avoid calling strlen to get a value getline already calculated. We can also pass this value on to rmspace to let it trim space for us.
Diffstat (limited to 'qfile.c')
-rw-r--r--qfile.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/qfile.c b/qfile.c
index a32e5128..6d36e968 100644
--- a/qfile.c
+++ b/qfile.c
@@ -513,10 +513,10 @@ int qfile_main(int argc, char **argv)
for (i = 0; i < qargc; ++i)
free(qargv[i]);
qargc = 0;
- while (getline(&state.buf, &state.buflen, args_file) != -1) {
- if ((p = strchr(state.buf, '\n')) != NULL)
- *p = '\0';
- if (state.buf == p)
+ size_t linelen;
+ while ((linelen = getline(&state.buf, &state.buflen, args_file)) != -1) {
+ rmspace_len(state.buf, linelen);
+ if (state.buf[0] == '\0')
continue;
qargv[qargc] = xstrdup(state.buf);
if (++qargc >= max_args)