blob: 477535354b539a78db5bc732caafc1a04932f026 (
plain) (
blame)
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
83
84
85
86
|
#! /bin/sh
# $Id$
# strings.sh [-o output] name input
#
# Generate the file of strings. This will contain the following
# function:
#
# const char *
# mdoc_a2NAME(const char *);
#
# The input file must be tab-delimited as follows:
#
# attnam0 A longer description
# attnam1 Another longer description
input=
output=
args=`getopt o: $*`
if [ $? -ne 0 ]; then
echo "usage: $0 [-o output] name input" 1>&2
exit 1
fi
set -- $args
while [ $# -ge 0 ]
do
case "$1" in
-o)
output="$2" ; shift; shift ;;
--)
shift ; break ;;
esac
done
name=$1
if [ -z "$name" ]; then
echo "usage: $0 [-o output] name input" 1>&2
exit 1
fi
input=$2
if [ "$output" ]; then
exec 1<>$output
fi
if [ "$input" ]; then
exec 0<>$input
fi
cat <<!
/*
* DO NOT EDIT! Automatically generated by $0.
*/
#include <stdlib.h>
#include "private.h"
const char *
mdoc_a2${name}(const char *p)
{
!
while read in ; do
[ -z "$in" ] && continue;
[ "#" == `echo "$in" | cut -c1` ] && continue;
key=`printf "%s\n" "$in" | cut -f 1`
val=`printf "%s\n" "$in" | cut -f 2- | sed 's!^[ ]*!!'`
cat <<!
if (xstrcmp(p, "$key"))
return("$val");
!
done
cat <<!
/* No keys found. */
return(NULL);
}
!
|