Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
keywordset: Add keywordset_add
Add function keywordset_add to update a keywordset with names from a
string, not requiring  embedded "+" markers.
  • Loading branch information
donald committed Apr 19, 2020
1 parent dbaa76b commit c083e4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions keywordset.c
Expand Up @@ -115,6 +115,21 @@ void keywordset_update(struct keywordset *kws, char *input) {
keywordset_update_phase(kws, input, PHASE_UPDATE);
}

void keywordset_add(struct keywordset *kws, char *input) {
char *c=input;
char *name_start;
while (*c) {
while (*c && isspace(*c))
c++;
if (*c) {
name_start=c++;
while (*c && !isspace(*c))
c++;
add_name(kws, name_start, c-name_start);
}
}
}

struct keywordset *keywordset_new(char *input) {
struct keywordset *kws = xmalloc(sizeof(*kws));
kws->nr_slots = KEYWORDSET_INITIAL_SLOTS;
Expand Down
1 change: 1 addition & 0 deletions keywordset.h
Expand Up @@ -3,6 +3,7 @@

struct keywordset *keywordset_new(char *input);
void keywordset_update(struct keywordset *kws, char *input);
void keywordset_add(struct keywordset *kws, char *input);
char *keywordset_get(struct keywordset *kws);
int keywordset_ismember(struct keywordset *kws, char *name);
void keywordset_purge(struct keywordset *kws);
Expand Down

0 comments on commit c083e4f

Please sign in to comment.