scanner: error when element names will not compile
authorManuel Stoeckl <code@mstoeckl.com>
Sat, 13 Apr 2019 21:30:46 +0000 (17:30 -0400)
committerSimon Ser <contact@emersion.fr>
Thu, 2 May 2019 17:42:59 +0000 (17:42 +0000)
commit6ce4bbb3dd86f8526331aa42916a120e39069bf1
treec0bb622c9189c92ca624db49469cfc060070eae6
parent3ab56ef8fa5aa64c07ad10fbaeb09b0c3b708ccf
scanner: error when element names will not compile

This change checks that the "name" fields of the various structures in
a Wayland protocol XML file will be converted into C identifiers that
can be successfully compiled.

For names which will be inserted as the prefix of an identifier
enforce a match with [_a-zA-Z][_0-9a-zA-Z]* . For types only inserted
as the suffix of an identifier (enum, entry), enforce a format of
[_0-9a-zA-Z]+ .

Unicode characters (and escape sequences like \u0394) are not allowed,
because most older and some newer C compilers do not support them by
default.

For sake of simplicity, this patch does not check for collisions
with reserved words or standard library names.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
src/scanner.c