manpagez: man pages & more
info gperf
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 Use of NUL bytes

By default, the code generated by gperf operates on zero terminated strings, the usual representation of strings in C. This means that the keywords in the input file must not contain NUL bytes, and the str argument passed to hash or in_word_set must be NUL terminated and have exactly length len.

If option ‘-c’ (or, equivalently, the ‘%compare-strncmp’ declaration) is used, then the str argument does not need to be NUL terminated. The code generated by gperf will only access the first len, not len+1, bytes starting at str. However, the keywords in the input file still must not contain NUL bytes.

If option ‘-l’ (or, equivalently, the ‘%compare-lengths’ declaration) is used, then the hash table performs binary comparison. The keywords in the input file may contain NUL bytes, written in string syntax as \000 or \x00, and the code generated by gperf will treat NUL like any other byte. Also, in this case the ‘-c’ option (or, equivalently, the ‘%compare-strncmp’ declaration) is ignored.


© manpagez.com 2000-2017
Individual documents may contain additional copyright information.