Annotation of embedaddon/php/ext/mbstring/libmbfl/filters/mk_sb_tbl.awk, revision 1.1
1.1 ! misho 1: #!/usr/bin/awk -f
! 2: #
! 3: # $Id: mk_sb_tbl.awk 180308 2005-02-21 07:57:08Z moriyoshi $
! 4: #
! 5: # Description: a script that generates a single byte code set to Unicode
! 6: # mapping table.
! 7: #
! 8:
! 9: function conv(str) {
! 10: if (!match(str, "^0[xX]")) {
! 11: return 0 + str
! 12: }
! 13:
! 14: retval = 0
! 15:
! 16: for (i = 3; i <= length(str); i++) {
! 17: n = index("0123456789abcdefABCDEF", substr(str, i, 1)) - 1
! 18:
! 19: if (n < 0) {
! 20: return 0 + str;
! 21: } else if (n >= 16) {
! 22: n -= 6;
! 23: }
! 24:
! 25: retval = retval * 16 + n
! 26: }
! 27:
! 28: return retval
! 29: }
! 30:
! 31: BEGIN {
! 32: FS="[ \t#]"
! 33: }
! 34:
! 35: /^#/ {
! 36: # Do nothing
! 37: }
! 38:
! 39: {
! 40: tbl[conv($1)] = conv($2)
! 41: }
! 42:
! 43: END {
! 44: print "/* This file is automatically generated. Do not edit! */"
! 45: if (IFNDEF_NAME) {
! 46: print "#ifndef " IFNDEF_NAME
! 47: }
! 48:
! 49: print "static const int " TABLE_NAME "[] = {"
! 50: i = 160;
! 51: for (;;) {
! 52: printf("\t0x%04x, 0x%04x, 0x%04x, 0x%04x, 0x%04x, 0x%04x, 0x%04x, 0x%04x", tbl[i++], tbl[i++], tbl[i++], tbl[i++], tbl[i++], tbl[i++], tbl[i++], tbl[i++]);
! 53: if (i != 256) {
! 54: printf(",\n");
! 55: } else {
! 56: print ""
! 57: break;
! 58: }
! 59: }
! 60: print "};"
! 61:
! 62: if (IFNDEF_NAME) {
! 63: print "#endif /* " IFNDEF_NAME " */"
! 64: }
! 65: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>