File: sigconv.awk

package info (click to toggle)
ptop 3.6.2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,356 kB
  • ctags: 2,292
  • sloc: ansic: 18,216; sh: 3,493; makefile: 122; awk: 44
file content (56 lines) | stat: -rw-r--r-- 1,212 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
BEGIN		{
		    nsig = 0;
		    j = 0;
		    print "/* This file was automatically generated */"
		    print "/* by the awk script \"sigconv.awk\".      */\n"
		    print "struct sigdesc {"
		    print "    char *name;"
		    print "    int  number;"
		    print "};\n"
		    print "struct sigdesc sigdesc[] = {"
		}

/^#define[ \t][ \t]*SIG[A-Z]/	{

				    j = sprintf("%d", $3);
				    if (siglist[j] != "") next;
				    str = $2;

				    if (nsig < j) 
					nsig = j;

				    siglist[j] = sprintf("\"%s\",\t%2d", \
						substr(str, 4), j);
				}
/^#[ \t]*define[ \t][ \t]*SIG[A-Z]/	{

				    j = sprintf("%d", $4);
				    if (siglist[j] != "") next;
				    str = $3;

				    if (nsig < j)
					nsig = j;

				    siglist[j] = sprintf("\"%s\",\t%2d", \
						substr(str, 4), j);
				}
/^#[ \t]*define[ \t][ \t]*_SIG[A-Z]/	{

				    j = sprintf("%d", $4);
				    if (siglist[j] != "") next;
				    str = $3;

				    if (nsig < j)
					nsig = j;

				    siglist[j] = sprintf("\"%s\",\t%2d", \
					    substr(str, 5), j);
				}

END				{
				    for (n = 1; n <= nsig; n++) 
					if (siglist[n] != "")
					    printf("    { %s },\n", siglist[n]);

				    printf("    { NULL,\t 0 }\n};\n");
				}