summaryrefslogtreecommitdiff
path: root/source3/script/gaptab.awk
diff options
context:
space:
mode:
authorAlexander Bokovoy <ab@samba.org>2003-08-28 17:16:27 +0000
committerAlexander Bokovoy <ab@samba.org>2003-08-28 17:16:27 +0000
commite83031c84de410cb19c96a4084b95f26619ce5a9 (patch)
tree50b33a3eec293a04bf9b635a097bc15928377e4f /source3/script/gaptab.awk
parenta75430992f6257815219f2301d872c67bcb00d76 (diff)
downloadsamba-e83031c84de410cb19c96a4084b95f26619ce5a9.tar.gz
samba-e83031c84de410cb19c96a4084b95f26619ce5a9.tar.bz2
samba-e83031c84de410cb19c96a4084b95f26619ce5a9.zip
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)
Diffstat (limited to 'source3/script/gaptab.awk')
-rw-r--r--source3/script/gaptab.awk48
1 files changed, 48 insertions, 0 deletions
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 "" }