Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /
Date: Sat, 04 Jan 2020 13:28:58
Message-Id: 1578144505.2742f0e06c9d79af720231968dfd91bad5c69a73.grobian@gentoo
1 commit: 2742f0e06c9d79af720231968dfd91bad5c69a73
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jan 4 13:28:25 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 4 13:28:25 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2742f0e0
7
8 qkeyword/qlist: replace strtok by strtok_r
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 TODO.md | 5 +++--
13 qkeyword.c | 8 +++++---
14 qlist.c | 5 +++--
15 3 files changed, 11 insertions(+), 7 deletions(-)
16
17 diff --git a/TODO.md b/TODO.md
18 index e401123..1de8b5f 100644
19 --- a/TODO.md
20 +++ b/TODO.md
21 @@ -12,8 +12,6 @@
22 - tree\_get\_atoms should return atoms iso string set, needs a rewrite
23 to use foreach\_pkg and get\_atom -- set is ready for storing objects
24 now
25 -- replace all strtok by strtok\_r, because the latter is already used,
26 - so we can
27 - parse package.accept\_keywords such that we can provide the latest
28 "available" version like Portage
29 - check timestamps in libq/tree for choosing which method to take:
30 @@ -78,3 +76,6 @@
31 guestimate alternative to current time jumping
32 - multiple files support -- current opinion: don't do it
33 - compressed file support, use guessing support from qmerge?
34 +
35 +# qfile
36 +- stop searching when absolute path argument was found?
37
38 diff --git a/qkeyword.c b/qkeyword.c
39 index 2121d51..0078fda 100644
40 --- a/qkeyword.c
41 +++ b/qkeyword.c
42 @@ -169,7 +169,9 @@ print_keywords(const char *category, const char *ebuild, int *keywords)
43 static int
44 read_keywords(char *s, int *keywords)
45 {
46 - char *arch, delim[2] = { ' ', '\0' };
47 + char *arch;
48 + char delim[2] = { ' ', '\0' };
49 + char *savep;
50 size_t slen;
51 size_t a;
52 int i;
53 @@ -188,13 +190,13 @@ read_keywords(char *s, int *keywords)
54 if (!slen)
55 return 0;
56
57 - arch = strtok(s, delim);
58 + arch = strtok_r(s, delim, &savep);
59 do {
60 i = decode_arch(arch);
61 if (i == -1)
62 continue;
63 keywords[i] = decode_status(arch[0]);
64 - } while ((arch = strtok(NULL, delim)));
65 + } while ((arch = strtok_r(NULL, delim, &savep)));
66
67 return 0;
68 }
69
70 diff --git a/qlist.c b/qlist.c
71 index 12d63f8..cc4c6be 100644
72 --- a/qlist.c
73 +++ b/qlist.c
74 @@ -334,6 +334,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
75 int i;
76 char *contents;
77 char *line;
78 + char *savep;
79 depend_atom *atom;
80
81 /* see if this cat/pkg is requested */
82 @@ -362,10 +363,10 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
83 if ((contents = tree_pkg_meta_get(pkg_ctx, CONTENTS)) == NULL)
84 return 1;
85
86 - while ((line = strtok(contents, "\n")) != NULL) {
87 + while ((line = strtok_r(contents, "\n", &savep)) != NULL) {
88 contents_entry *e;
89
90 - contents = NULL; /* for strtok */
91 + contents = NULL; /* for strtok_r */
92
93 e = contents_parse_line(line);
94 if (!e)