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_hasnondigit.c File Reference

Purpose

The hasnondigit linter ensures that the given data contains a non-digit character.

Functional Description

◆ gs1_lint_hasnondigit()

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

Used to validate that an AI component contains a non-digit character.

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_REQUIRES_NON_DIGIT_CHARACTER if the data does not contain a non-digit character.
49{
50
51 const char *p;
52
53 assert(data);
54
55 /*
56 * Data must not be all numeric
57 *
58 */
59 for (p = data; *p; p++)
60 if (*p < '0' || *p > '9')
62
65 0,
66 (size_t)(p - data)
67 );
68
69}
#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:103
#define GS1_LINTER_RETURN_OK
Return from a linter indicating that no problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:88
@ GS1_LINTER_REQUIRES_NON_DIGIT_CHARACTER
A non-digit character is required.
Definition gs1syntaxdictionary.h:191