GS1 Barcode Syntax Tests reference
A reference to the AI component "linter" routines referred to by the GS1 Barcode Syntax Dictionary. Copyright (c) 2022-2024 GS1 AISBL.
lint_hyphen.c File Reference

Purpose

The hyphen linter ensures that the given data contains only hyphens.

Functional Description

◆ gs1_lint_hyphen()

GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hyphen ( const char *const  data,
size_t *const  err_pos,
size_t *const  err_len 
)

Used to validate that an AI component contains only hyphens.

Parameters
[in]dataPointer to the null-terminated data to be linted. Must not be NULL.
[out]err_posTo facilitate error highlighting, the start position of the bad data is written to this pointer, if not NULL.
[out]err_lenThe length of the bad data is written to this pointer, if not NULL.
Returns
GS1_LINTER_OK if okay.
GS1_LINTER_NOT_HYPHEN if the data contains a non-hyphen character.
48{
49
50 size_t len;
51
52 assert(data);
53
54 len = strlen(data);
55
56 if (*data == '\0')
58
59 /*
60 * Data must not contain a non-hyphen character
61 *
62 */
63 if (strspn(data, "-") != len)
65
67
68}
#define GS1_LINTER_RETURN_ERROR(error, position, length)
Return from a linter indicating that a problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:77
#define GS1_LINTER_RETURN_OK
Return from a linter indicating that no problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:62
@ GS1_LINTER_NOT_HYPHEN
Only hyphens are permitted.
Definition gs1syntaxdictionary.h:187