From dc0db62312a9818b9ddeba5dbe1633e776e7a729 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Sat, 25 Mar 2017 18:13:32 +0000 Subject: [PATCH] utilities: sundries --- charsetjis.def | 1 + charsetmore.c | 2 +- cptoqe.c | 46 ++++++++++++++++++++++++---------------------- fbftoqe.c | 2 +- jistoqe.c | 16 ++++++++-------- kmap.c | 2 +- kmaptoqe.c | 2 +- ligtoqe.c | 2 +- 8 files changed, 38 insertions(+), 35 deletions(-) diff --git a/charsetjis.def b/charsetjis.def index 5ac347b..520c819 100644 --- a/charsetjis.def +++ b/charsetjis.def @@ -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 diff --git a/charsetmore.c b/charsetmore.c index d99f2ea..82764be 100644 --- a/charsetmore.c +++ b/charsetmore.c @@ -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 diff --git a/cptoqe.c b/cptoqe.c index e334a5e..5eec782 100644 --- a/cptoqe.c +++ b/cptoqe.c @@ -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" diff --git a/fbftoqe.c b/fbftoqe.c index dc41c87..5de49e0 100644 --- a/fbftoqe.c +++ b/fbftoqe.c @@ -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 diff --git a/jistoqe.c b/jistoqe.c index 334fddc..f7a4680 100644 --- a/jistoqe.c +++ b/jistoqe.c @@ -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); } diff --git a/kmap.c b/kmap.c index 6008c35..2dbc376 100644 --- a/kmap.c +++ b/kmap.c @@ -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 diff --git a/kmaptoqe.c b/kmaptoqe.c index bdf1f19..6fc469c 100644 --- a/kmaptoqe.c +++ b/kmaptoqe.c @@ -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 diff --git a/ligtoqe.c b/ligtoqe.c index a924044..e4f3bf9 100644 --- a/ligtoqe.c +++ b/ligtoqe.c @@ -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