Skip to content

Commit

Permalink
syn: Prepare to accept multiple flags
Browse files Browse the repository at this point in the history
  • Loading branch information
terryburton committed May 17, 2024
1 parent 6da2a76 commit 2fbbf70
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/c-lib/syn.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static int processComponent(gs1_encoder* const ctx, char* const component, struc
int parseSyntaxDictionaryEntry(gs1_encoder* const ctx, const char* const line, const struct aiEntry* const sd, struct aiEntry** const entry, const uint16_t cap) {

const struct aiEntry *lastEntry;
const char *token;
const char *token, *flags = "";
char *saveptr = NULL;
char *p, *q;
size_t len;
Expand Down Expand Up @@ -202,16 +202,17 @@ int parseSyntaxDictionaryEntry(gs1_encoder* const ctx, const char* const line, c
if (!token)
error("Truncated after AI");

// Next token may be a "no FNC1" indicator flag
if (strcmp(token, "*") == 0) {
(*entry)->fnc1 = NO_FNC1;
// Check if we have exclusively flag characters
if (strspn(token, "*?") == strlen(token)) {
flags = token;
token = strtok_r(NULL, " \t", &saveptr);
if (!token)
error("Truncated after flags");
} else {
(*entry)->fnc1 = DO_FNC1;
}

// We may have a '*' (no FNC1) indicator flag
(*entry)->fnc1 = strchr(flags, '*') ? NO_FNC1 : DO_FNC1;

// Read and process the AI components
numparts = 0;
while (token && ((*token >= 'A' && *token <= 'Z') || *token == '[')) {
Expand Down

0 comments on commit 2fbbf70

Please sign in to comment.