~ubuntu-branches/ubuntu/natty/ncurses/natty

« back to all changes in this revision

Viewing changes to ncurses/base/MKkeyname.awk

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-05-17 09:00:42 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517090042-86fgxrr6j5jzagot
Tags: 5.6-0ubuntu1
* New upstream version.
  - Remove patches applied upstream: ncurses.upstream, signed-chars.
  - Update patches: debian-backspace.
* Build-depend on g++-multilib instead of lib{32,64}c*-dev-*.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: MKkeyname.awk,v 1.28 2005/04/30 19:26:25 tom Exp $
 
1
# $Id: MKkeyname.awk,v 1.30 2006/05/20 17:35:30 tom Exp $
2
2
##############################################################################
3
 
# Copyright (c) 1999-2002,2005 Free Software Foundation, Inc.                #
 
3
# Copyright (c) 1999-2005,2006 Free Software Foundation, Inc.                #
4
4
#                                                                            #
5
5
# Permission is hereby granted, free of charge, to any person obtaining a    #
6
6
# copy of this software and associated documentation files (the "Software"), #
43
43
END {
44
44
        printf "\t{ 0, 0 }};\n"
45
45
        print ""
 
46
        print "#define SIZEOF_TABLE 256"
 
47
        print "static char **keyname_table;"
 
48
        print ""
46
49
        print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
47
50
        print "{"
48
 
        print " static char **table;"
49
51
        print " int i;"
50
52
        print " char name[20];"
51
53
        print " char *p;"
61
63
        print "                 }"
62
64
        print "         }"
63
65
        print ""
64
 
        print "         if (result == 0 && (c >= 0 && c < 256)) {"
65
 
        print "                 if (table == 0)"
66
 
        print "                         table = typeCalloc(char *, 256);"
67
 
        print "                 if (table != 0) {"
68
 
        print "                         if (table[c] == 0) {"
 
66
        print "         if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) {"
 
67
        print "                 if (keyname_table == 0)"
 
68
        print "                         keyname_table = typeCalloc(char *, SIZEOF_TABLE);"
 
69
        print "                 if (keyname_table != 0) {"
 
70
        print "                         if (keyname_table[c] == 0) {"
 
71
        print "                                 int cc = c;"
69
72
        print "                                 p = name;"
70
 
        print "                                 if (c >= 128) {"
 
73
        print "                                 if (cc >= 128) {"
71
74
        print "                                         strcpy(p, \"M-\");"
72
75
        print "                                         p += 2;"
73
 
        print "                                         c -= 128;"
 
76
        print "                                         cc -= 128;"
74
77
        print "                                 }"
75
 
        print "                                 if (c < 32)"
76
 
        print "                                         sprintf(p, \"^%c\", c + '@');"
77
 
        print "                                 else if (c == 127)"
 
78
        print "                                 if (cc < 32)"
 
79
        print "                                         sprintf(p, \"^%c\", cc + '@');"
 
80
        print "                                 else if (cc == 127)"
78
81
        print "                                         strcpy(p, \"^?\");"
79
82
        print "                                 else"
80
 
        print "                                         sprintf(p, \"%c\", c);"
81
 
        print "                                 table[c] = strdup(name);"
 
83
        print "                                         sprintf(p, \"%c\", cc);"
 
84
        print "                                 keyname_table[c] = strdup(name);"
82
85
        print "                         }"
83
 
        print "                         result = table[c];"
 
86
        print "                         result = keyname_table[c];"
84
87
        print "                 }"
85
88
        print "#if NCURSES_EXT_FUNCS && NCURSES_XNAMES"
86
89
        print "         } else if (result == 0 && cur_term != 0) {"
97
100
        print "                                         break;"
98
101
        print "                                 }"
99
102
        print "                         }"
 
103
        print "                         free(bound);"
100
104
        print "                         if (result != 0)"
101
105
        print "                                 break;"
102
106
        print "                 }"
115
119
        print " return result;"
116
120
        print "}"
117
121
        print "#endif"
 
122
        print ""
 
123
        print "#if NO_LEAKS"
 
124
        print "void _nc_keyname_leaks(void)"
 
125
        print "{"
 
126
        print " int j;"
 
127
        print " if (keyname_table != 0) {"
 
128
        print "         for (j = 0; j < SIZEOF_TABLE; ++j) {"
 
129
        print "                 FreeIfNeeded(keyname_table[j]);"
 
130
        print "         }"
 
131
        print "         FreeAndNull(keyname_table);"
 
132
        print " }"
 
133
        print "}"
 
134
        print "#endif /* NO_LEAKS */"
118
135
}