1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 06:38:37 -05:00
putty-source/terminal/bidi_gettype.c
Simon Tatham d7548d0449 Move bidi gettype main() into its own file.
That's what I've usually been doing with any main()s I find under
ifdef; there's no reason this should be an exception. If we're keeping
it in the code at all, we should ensure it carries on compiling.

I've also created a new header file bidi.h, containing pieces of the
bidi definitions shared between bidi.c and the new source file.
2021-10-10 14:53:25 +01:00

54 lines
1.1 KiB
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);
}
int main(int argc, char **argv)
{
static const struct { int type; char *name; } typetoname[] = {
#define TYPETONAME(X) { X , #X }
TYPETONAME(L),
TYPETONAME(LRE),
TYPETONAME(LRO),
TYPETONAME(R),
TYPETONAME(AL),
TYPETONAME(RLE),
TYPETONAME(RLO),
TYPETONAME(PDF),
TYPETONAME(EN),
TYPETONAME(ES),
TYPETONAME(ET),
TYPETONAME(AN),
TYPETONAME(CS),
TYPETONAME(NSM),
TYPETONAME(BN),
TYPETONAME(B),
TYPETONAME(S),
TYPETONAME(WS),
TYPETONAME(ON),
#undef TYPETONAME
};
int i;
for (i = 1; i < argc; i++) {
unsigned long chr = strtoul(argv[i], NULL, 0);
int type = bidi_getType(chr);
assert(typetoname[type].type == type);
printf("U+%04x: %s\n", (unsigned)chr, typetoname[type].name);
}
return 0;
}