1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-15 03:41:20 +03:00

These small utilities are for generating internal tables from

rcode encoding tables.
This commit is contained in:
Tatsuo Ishii
1999-03-24 07:01:37 +00:00
parent e1a22d5e84
commit eb42c1c762
3 changed files with 198 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
/*
* make KOI8->CP866(ALT) and CP866(ALT)->KOI8 translation table
* from koi-alt.tab.
*
* Tatsuo Ishii
*
* $Id: alt.c,v 1.1 1999/03/24 07:01:36 ishii Exp $
*/
#include <stdio.h>
main()
{
int i;
char koitab[128],alttab[128];
char buf[4096];
int koi,alt;
for (i=0;i<128;i++) {
koitab[i] = alttab[i] = 0;
}
while (fgets(buf,sizeof(buf),stdin) != NULL) {
if (*buf == '#') {
continue;
}
sscanf(buf,"%d %d",&koi,&alt);
if (koi < 128 || koi > 255 || alt < 128 || alt > 255) {
fprintf(stderr,"invalid value %d\n",koi);
exit(1);
}
koitab[koi-128] = alt;
alttab[alt-128] = koi;
}
i = 0;
printf("static char koi2alt[] = {\n");
while (i < 128) {
int j = 0;
while (j < 8) {
printf("0x%02x",koitab[i++]);
j++;
if (i >= 128) {
break;
}
printf(", ");
}
printf("\n");
}
printf("};\n");
i = 0;
printf("static char alt2koi[] = {\n");
while (i < 128) {
int j = 0;
while (j < 8) {
printf("0x%02x",alttab[i++]);
j++;
if (i >= 128) {
break;
}
printf(", ");
}
printf("\n");
}
printf("};\n");
}