From e83031c84de410cb19c96a4084b95f26619ce5a9 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Thu, 28 Aug 2003 17:16:27 +0000 Subject: Refactor charset plugins a bit and add CP437 module. Now all 8-bit charsets with gaps (not all symbols defined) could be produced through one macro -- SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CHARSETNAME) within source file with three charset tables. Full source code for such modules can be generated by source/script/gen-8bit-gap.sh script which was taken from GNU libc and changed slightly to follow our data types and structure. (This used to be commit 37042c7bc0f349370e93e4bed37d8fa371013247) --- source3/script/.cvsignore | 1 + source3/script/gap.awk | 39 ++++++++++++++++++++++++++++++ source3/script/gaptab.awk | 48 ++++++++++++++++++++++++++++++++++++ source3/script/gen-8bit-gap.sh.in | 51 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 source3/script/gap.awk create mode 100644 source3/script/gaptab.awk create mode 100755 source3/script/gen-8bit-gap.sh.in (limited to 'source3/script') diff --git a/source3/script/.cvsignore b/source3/script/.cvsignore index 7a8114ecd7..0464ca2335 100644 --- a/source3/script/.cvsignore +++ b/source3/script/.cvsignore @@ -1 +1,2 @@ findsmb +gen-8bit-gap.sh diff --git a/source3/script/gap.awk b/source3/script/gap.awk new file mode 100644 index 0000000000..11680d10f9 --- /dev/null +++ b/source3/script/gap.awk @@ -0,0 +1,39 @@ +BEGIN { hv["0"] = 0; hv["1"] = 1; hv["2"] = 2; hv["3"] = 3; + hv["4"] = 4; hv["5"] = 5; hv["6"] = 6; hv["7"] = 7; + hv["8"] = 8; hv["9"] = 9; hv["A"] = 10; hv["B"] = 11; + hv["C"] = 12; hv["D"] = 13; hv["E"] = 14; hv["F"] = 15; + hv["a"] = 10; hv["b"] = 11; hv["c"] = 12; hv["d"] = 13; + hv["e"] = 14; hv["f"] = 15; + + first = 0; last = 0; idx = 0; +} + +function tonum(str) +{ + num=0; + cnt=1; + while (cnt <= length(str)) { + num *= 16; + num += hv[substr(str,cnt,1)]; + ++cnt; + } + return num; +} + +{ + u = tonum($1); + if (u - last > 6) + { + if (last) + { + printf (" { 0x%04x, 0x%04x, %5d },\n", + first, last, idx); + idx -= u - last - 1; + } + first = u; + } + last = u; +} + +END { printf (" { 0x%04x, 0x%04x, %5d },\n", + first, last, idx); } diff --git a/source3/script/gaptab.awk b/source3/script/gaptab.awk new file mode 100644 index 0000000000..f9d1526361 --- /dev/null +++ b/source3/script/gaptab.awk @@ -0,0 +1,48 @@ +BEGIN { hv["0"] = 0; hv["1"] = 1; hv["2"] = 2; hv["3"] = 3; + hv["4"] = 4; hv["5"] = 5; hv["6"] = 6; hv["7"] = 7; + hv["8"] = 8; hv["9"] = 9; hv["A"] = 10; hv["B"] = 11; + hv["C"] = 12; hv["D"] = 13; hv["E"] = 14; hv["F"] = 15; + hv["a"] = 10; hv["b"] = 11; hv["c"] = 12; hv["d"] = 13; + hv["e"] = 14; hv["f"] = 15; + + first = 0; last = 0; idx = 0; f = 0; +} + +function tonum(str) +{ + num=0; + cnt=1; + while (cnt <= length(str)) { + num *= 16; + num += hv[substr(str,cnt,1)]; + ++cnt; + } + return num; +} + +function fmt(val) +{ + if (f++ % 8 == 0) + { printf ("\n '\\x%02x',", val); } + else + { printf (" '\\x%02x',", val); } +} + +{ + u = tonum($1); c = tonum($2); + + if (u - last > 6) + { + if (last) { idx += last - first + 1; } + first = u; + } + else + { + for (m = last+1; m < u; m++) { fmt(0); } + } + + fmt(c); + last = u; +} + +END { print "" } diff --git a/source3/script/gen-8bit-gap.sh.in b/source3/script/gen-8bit-gap.sh.in new file mode 100755 index 0000000000..e66c654c22 --- /dev/null +++ b/source3/script/gen-8bit-gap.sh.in @@ -0,0 +1,51 @@ +#!/bin/sh +if test $# -ne 2 ; then + echo "Usage: $0 " + exit 1 +fi + +CHARMAP=$1 +CHARSETNAME=$2 + +echo "/* " +echo " * Conversion table for $CHARSETNAME charset " +echo " * " +echo " * Conversion tables are generated using $CHARMAP table " +echo " * and source/script/gen-8bit-gap.sh script " +echo " * " +echo " * This program is free software; you can redistribute it and/or modify " +echo " * it under the terms of the GNU General Public License as published by " +echo " * the Free Software Foundation; either version 2 of the License, or " +echo " * (at your option) any later version. " +echo " * " +echo " * This program is distributed in the hope that it will be useful," +echo " * but WITHOUT ANY WARRANTY; without even the implied warranty of " +echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " +echo " * GNU General Public License for more details. " +echo " * " +echo " * You should have received a copy of the GNU General Public License " +echo " * along with this program; if not, write to the Free Software " +echo " * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. " +echo " */" + +echo '#include "includes.h"' +echo +echo "static const uint16 to_ucs2[256] = {" +sed -ne '/^[^[:space:]]*[[:space:]]*.x00/d' \ + -e 's/^[[:space:]]*.x\(..\).*/ [0x\2] = 0x\1,/p' \ + "$CHARMAP" | sort -u +echo "};" +echo +echo "static const struct charset_gap_table from_idx[] = {" +sed -ne 's/^[[:space:]]*.x\(..\).*/\1 \2/p' \ + "$CHARMAP" | sort -u | @AWK@ -f @srcdir@/script/gaptab.awk +echo "};" +echo +echo "SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP($CHARSETNAME)" +echo -- cgit