File: libsigs.awk

package info (click to toggle)
unixcw 2.0-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 764 kB
  • ctags: 645
  • sloc: ansic: 5,693; cpp: 1,736; makefile: 333; sh: 213; awk: 209
file content (76 lines) | stat: -rw-r--r-- 1,816 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/awk -f
#
# UnixCW - Unix CW (Morse code) training program
# Copyright (C) 2001  Simon Baldwin (simonb@caldera.com)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
#
# AWK script to produce function signatures from processed C source.
#

# Initialize the states, arrays, and indices.
BEGIN {
	IDLE			= 0
	TYPE			= 1
	SPECIFICATION		= 2
	state			= IDLE

	GLOBALTYPE_TAG		= "GT"
	GLOBALSPECIFICATION_TAG	= "GS"
	GLOBALEND_TAG		= "GE"
	specifications		= 0
    }

# Find a global type tag.
$1 == GLOBALTYPE_TAG {
	if (specifications > 0)
		printf (".sp\n")
	else
		printf (".nf\n")
	sub (GLOBALTYPE_TAG, "")
	sub (/^ */, "")
	gsub (/\t/, " ")
	printf (".BI \"%s ", $0)
	specifications++
	state = TYPE
	next
    }

# Handle each global specification entry.
$1 == GLOBALSPECIFICATION_TAG {
	sub (GLOBALSPECIFICATION_TAG, "")
	sub (/^ */, "")
	gsub (/\t/, " ")
	if (state == TYPE)
		printf ("%s\"\n", $0)
	else
		printf (".BI \"%s\"\n", $0)
	state = SPECIFICATION
	next
    }

# On end of a function, reset state.
$1 == GLOBALEND_TAG {
	state = IDLE
	next
    }

# Tidy up on end of file.
END {
	if (specifications > 0)
		printf (".sp\n")
	printf (".fi\n")
}