1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00
putty-source/terminal/bidi_gettype.c
Simon Tatham 804f32765f Make bidi type enums into list macros.
This makes it easier to create the matching array of type names in
bidi_gettype.c, and eliminates the need for an assertion to check the
array matched the enum. And I'm about to need to add more types, so
let's start by making that trivially easy.
2021-10-10 14:55:15 +01:00

34 lines
639 B
C

/*
* Standalone test program that exposes the minibidi getType function.
*/
#include <stdio.h>
#include <assert.h>
#include "putty.h"
#include "misc.h"
#include "bidi.h"
void out_of_memory(void)
{
fprintf(stderr, "out of memory!\n");
exit(2);
}
#define TYPETONAME(X) #X,
static const char *const typenames[] = { BIDI_CHAR_TYPE_LIST(TYPETONAME) };
#undef TYPETONAME
int main(int argc, char **argv)
{
int i;
for (i = 1; i < argc; i++) {
unsigned long chr = strtoul(argv[i], NULL, 0);
int type = bidi_getType(chr);
printf("U+%04x: %s\n", (unsigned)chr, typenames[type]);
}
return 0;
}