~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/mbstring/libmbfl/filters/mk_sb_tbl.awk

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/awk -f
 
2
#
 
3
# $Id: mk_sb_tbl.awk,v 1.1.2.2 2005/02/21 08:01:03 moriyoshi Exp $
 
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
}