utilities: sundries

This commit is contained in:
Charlie Gordon 2017-03-25 18:13:32 +00:00
commit dc0db62312
8 changed files with 39 additions and 36 deletions

View file

@ -3,6 +3,7 @@
/*
* JIS Tables for QEmacs
* Copyright (c) 2002 Fabrice Bellard.
* Copyright (c) 2002-2017 Charlie Gordon.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -4,7 +4,7 @@
* More Charsets and Tables for QEmacs
*
* Copyright (c) 2002 Fabrice Bellard.
* Copyright (c) 2002-2008 Charlie Gordon.
* Copyright (c) 2002-2017 Charlie Gordon.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* Convert Unicode 8-bit code page files to QEmacs format
*
* Copyright (c) 2002 Fabrice Bellard.
* Copyright (c) 2007-2008 Charlie Gordon.
* Copyright (c) 2007-2017 Charlie Gordon.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -114,12 +114,13 @@ static void handle_cp(FILE *f0, const char *name, const char *fname)
base = get_basename_offset(includename);
pstrcpy(includename + base, sizeof(includename) - base,
skipspaces(p + 8));
filename = includename;
f = fopen(includename, "r");
if (f == NULL) {
fprintf(stderr, "%s: cannot open %s\n", name, includename);
f = f0;
filename = fname;
}
filename = includename;
continue;
}
@ -176,9 +177,9 @@ static void handle_cp(FILE *f0, const char *name, const char *fname)
max_code = -1;
for (i = 0; i < 256; i++) {
if (table[i] != i) {
if (i < min_code)
if (min_code > i)
min_code = i;
if (i > max_code)
if (max_code < i)
max_code = i;
}
}
@ -229,24 +230,25 @@ static void handle_cp(FILE *f0, const char *name, const char *fname)
}
}
}
printf("\",\n");
printf("\",");
printf(" NULL,\n"
" decode_8bit_init,\n"
" decode_8bit,\n"
" encode_8bit,\n"
" charset_get_pos_8bit,\n"
" charset_get_chars_8bit,\n"
" charset_goto_char_8bit,\n"
" charset_goto_line_8bit,\n"
" .char_size = 1,\n"
" .variable_size = 0,\n"
" .table_alloc = 1,\n"
" .eol_char = %d,\n"
" .min_char = %d,\n"
" .max_char = %d,\n"
" .private_table = table_%s,\n"
"};\n\n",
printf("\n" " NULL,"
"\n" " decode_8bit_init,"
"\n" " decode_8bit,"
"\n" " encode_8bit,"
"\n" " charset_get_pos_8bit,"
"\n" " charset_get_chars_8bit,"
"\n" " charset_goto_char_8bit,"
"\n" " charset_goto_line_8bit,"
"\n" " .char_size = 1,"
"\n" " .variable_size = 0,"
"\n" " .table_alloc = 1,"
"\n" " .eol_char = %d,"
"\n" " .min_char = %d,"
"\n" " .max_char = %d,"
"\n" " .private_table = table_%s,"
"\n" "};"
"\n\n",
eol_char, min_code, max_code, name_id);
add_init(" qe_register_charset(&charset_");
@ -303,7 +305,7 @@ int main(int argc, char **argv)
"\n" " * More Charsets and Tables for QEmacs"
"\n" " *"
"\n" " * Copyright (c) 2002 Fabrice Bellard."
"\n" " * Copyright (c) 2002-2008 Charlie Gordon."
"\n" " * Copyright (c) 2002-2017 Charlie Gordon."
"\n" " *"
"\n" " * This library is free software; you can redistribute it and/or"
"\n" " * modify it under the terms of the GNU Lesser General Public"

View file

@ -2,7 +2,7 @@
* Convert FBF fonts into source code to link them in QEmacs.
*
* Copyright (c) 2002 Fabrice Bellard.
* Copyright (c) 2007-2008 Charlie Gordon.
* Copyright (c) 2007-2017 Charlie Gordon.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -2,6 +2,7 @@
* Convert Unicode JIS tables to QEmacs format
*
* Copyright (c) 2002 Fabrice Bellard.
* Copyright (c) 2002-2017 Charlie Gordon.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -51,7 +52,7 @@ static char *getline(char *buf, int buf_size, FILE *f, int strip_comments)
}
/* handle jis208 or jis212 table */
static void handle_jis(FILE **fp, const char *name, const char *filename)
static void handle_jis(FILE *f, const char *name, const char *filename)
{
int c1, c2, b1, b2, b1_max, b2_max, i, j, nb, n;
int table[94*94];
@ -77,9 +78,7 @@ static void handle_jis(FILE **fp, const char *name, const char *filename)
b1_max = 0;
b2_max = 0;
nb = 0;
for (;;) {
if (!getline(line, sizeof(line), *fp, 1))
break;
while (getline(line, sizeof(line), f, 1)) {
p = line;
if (is_jis208)
c1 = strtol(p, (char **)&p, 0);
@ -92,11 +91,11 @@ static void handle_jis(FILE **fp, const char *name, const char *filename)
/* compress the code */
b1 = b1 - 0x21;
b2 = b2 - 0x21;
if (b1 > b1_max)
if (b1_max < b1)
b1_max = b1;
if (b2 > b2_max)
if (b2_max < b2)
b2_max = b2;
if (b2 > table_b2_max[b1])
if (table_b2_max[b1] < b2)
table_b2_max[b1] = b2;
table[b1 * 94 + b2] = c2;
nb++;
@ -143,6 +142,7 @@ int main(int argc, char **argv)
printf("\n" "/*"
"\n" " * JIS Tables for QEmacs"
"\n" " * Copyright (c) 2002 Fabrice Bellard."
"\n" " * Copyright (c) 2002-2017 Charlie Gordon."
"\n" " *"
"\n" " * This library is free software; you can redistribute it and/or"
"\n" " * modify it under the terms of the GNU Lesser General Public"
@ -173,7 +173,7 @@ int main(int argc, char **argv)
exit(1);
}
handle_jis(&f, name, filename);
handle_jis(f, name, filename);
fclose(f);
}

2
kmap.c
View file

@ -2,7 +2,7 @@
* Kmap file based input method handling for QEmacs.
*
* Copyright (c) 2000 Fabrice Bellard.
* Copyright (c) 2002-2008 Charlie Gordon.
* Copyright (c) 2002-2017 Charlie Gordon.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* Convert Yudit kmap files to QEmacs binary internal format
*
* Copyright (c) 2002 Fabrice Bellard.
* Copyright (c) 2007-2014 Charlie Gordon.
* Copyright (c) 2007-2017 Charlie Gordon.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* Convert ligature files to QEmacs binary internal format
*
* Copyright (c) 2002 Fabrice Bellard.
* Copyright (c) 2007-2008 Charlie Gordon.
* Copyright (c) 2007-2017 Charlie Gordon.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public