File: libfuncs.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 (82 lines) | stat: -rw-r--r-- 2,024 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
77
78
79
80
81
82
#!/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 descriptions from processed C source.
#

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

	GLOBALTYPE_TAG		= "GT"
	GLOBALSPECIFICATION_TAG	= "GS"
	GLOBALDOCUMENTATION_TAG	= "GD"
	GLOBALEND_TAG		= "GE"
    }

# Find a global type tag; start of a function description.
$1 == GLOBALTYPE_TAG {
	sub (GLOBALTYPE_TAG, "")
	sub (/^ */, "")
	gsub (/\t/, " ")
	printf (".nf\n")
	printf (".sp\n")
	printf (".sp\n")
	printf (".BI \"%s ", $0)
	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
    }

# Handle all documentation entries.
$1 == GLOBALDOCUMENTATION_TAG {
	if (state == SPECIFICATION || state == TYPE)
	    {
		printf (".sp\n");
		printf (".fi\n")
	    }
	sub (GLOBALDOCUMENTATION_TAG, "")
	sub (/^ */, "")
	printf ("%s\n", $0)
	state = DESCRIPTION
	next
    }

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