Adds error messages, checks type and ignores the second argument.
Currently utf_char2bytes is able to handle any 31-bit character, not
limited by a unicode range. So checking for INT_MAX and not for
something else: function yet uses `int`.
With has_mbyte equal to 1 and &encoding always UTF-8 second argument is no
longer useful: utf_ptr2char is the same as mb_ptr2char.
Also changes function behaviour a bit: now if second argument is not a number it
immediately returns with error, without bothering to get a character.
Based on the flow it looks like ptr could not be NULL here: if ptr_arg is NULL
ptr is compl_leader, if compl_leader is NULL function exits. This also applies
to Vim as far as I see.
Allocated dict points to previously allocated dict.
Queue in allocated dict points to itself.
Hashtab in allocated dict points to inside itself.
Allocated dict is saved to gc_first_dict.
Not using enum{} because SIZE_MAX exceeds integer and I do not really like how
enum definition is described in C99:
1. Even though all values must fit into the chosen type (6.7.2.2, p 4) the type
to choose is still implementation-defined.
2. 6.4.4.3 explicitly states that “an identifier declared as an enumeration
constant has type `int`”. So it looks like “no matter what type was chosen
for enumeration, constants will be integers”. Yet the following simple
program:
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
enum { X=SIZE_MAX };
int main(int argc, char **argv)
{
printf("x:%zu m:%zu t:%zu v:%zu",
sizeof(X), sizeof(SIZE_MAX), sizeof(size_t), (size_t)X);
}
yields one of the following using different compilers:
- clang/gcc/pathcc: `x:8 m:8 t:8 v:18446744073709551615`
- pcc/tcc: `x:4 m:8 t:8 v:1844674407370955161`
If I remove the cast of X to size_t then pcc/tcc both yield `x:4 m:8 t:8
v:4294967295`, other compilers’ output does not change.
All compilers were called with `$compiler -std=c99 -xc -` (feeding program
from echo), except for `tcc` which has missing `-std=c99`. `pcc` seems to
ignore the argument though: it is perfectly fine with `-std=c1000`.