commit: 2742f0e06c9d79af720231968dfd91bad5c69a73 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Sat Jan 4 13:28:25 2020 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Sat Jan 4 13:28:25 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2742f0e0
qkeyword/qlist: replace strtok by strtok_r Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> TODO.md | 5 +++-- qkeyword.c | 8 +++++--- qlist.c | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index e401123..1de8b5f 100644 --- a/TODO.md +++ b/TODO.md @@ -12,8 +12,6 @@ - tree\_get\_atoms should return atoms iso string set, needs a rewrite to use foreach\_pkg and get\_atom -- set is ready for storing objects now -- replace all strtok by strtok\_r, because the latter is already used, - so we can - parse package.accept\_keywords such that we can provide the latest "available" version like Portage - check timestamps in libq/tree for choosing which method to take: @@ -78,3 +76,6 @@ guestimate alternative to current time jumping - multiple files support -- current opinion: don't do it - compressed file support, use guessing support from qmerge? + +# qfile +- stop searching when absolute path argument was found? diff --git a/qkeyword.c b/qkeyword.c index 2121d51..0078fda 100644 --- a/qkeyword.c +++ b/qkeyword.c @@ -169,7 +169,9 @@ print_keywords(const char *category, const char *ebuild, int *keywords) static int read_keywords(char *s, int *keywords) { - char *arch, delim[2] = { ' ', '\0' }; + char *arch; + char delim[2] = { ' ', '\0' }; + char *savep; size_t slen; size_t a; int i; @@ -188,13 +190,13 @@ read_keywords(char *s, int *keywords) if (!slen) return 0; - arch = strtok(s, delim); + arch = strtok_r(s, delim, &savep); do { i = decode_arch(arch); if (i == -1) continue; keywords[i] = decode_status(arch[0]); - } while ((arch = strtok(NULL, delim))); + } while ((arch = strtok_r(NULL, delim, &savep))); return 0; } diff --git a/qlist.c b/qlist.c index 12d63f8..cc4c6be 100644 --- a/qlist.c +++ b/qlist.c @@ -334,6 +334,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv) int i; char *contents; char *line; + char *savep; depend_atom *atom; /* see if this cat/pkg is requested */ @@ -362,10 +363,10 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv) if ((contents = tree_pkg_meta_get(pkg_ctx, CONTENTS)) == NULL) return 1; - while ((line = strtok(contents, "\n")) != NULL) { + while ((line = strtok_r(contents, "\n", &savep)) != NULL) { contents_entry *e; - contents = NULL; /* for strtok */ + contents = NULL; /* for strtok_r */ e = contents_parse_line(line); if (!e)