Annotation of mandoc/strings.sh, Revision 1.1
1.1 ! kristaps 1: #! /bin/sh
! 2: # $Id$
! 3:
! 4: # strings.sh [-o output] name input
! 5: #
! 6: # Generate the file of strings. This will contain the following
! 7: # function:
! 8: #
! 9: # const char *
! 10: # mdoc_a2NAME(const char *);
! 11: #
! 12: # The input file must be tab-delimited as follows:
! 13: #
! 14: # attnam0 A longer description
! 15: # attnam1 Another longer description
! 16:
! 17: input=
! 18: output=
! 19: args=`getopt o: $*`
! 20:
! 21: if [ $? -ne 0 ]; then
! 22: echo "usage: $0 [-o output] name input" 1>&2
! 23: exit 1
! 24: fi
! 25:
! 26: set -- $args
! 27:
! 28: while [ $# -ge 0 ]
! 29: do
! 30: case "$1" in
! 31: -o)
! 32: output="$2" ; shift; shift ;;
! 33: --)
! 34: shift ; break ;;
! 35: esac
! 36: done
! 37:
! 38: name=$1
! 39:
! 40: if [ -z "$name" ]; then
! 41: echo "usage: $0 [-o output] name input" 1>&2
! 42: exit 1
! 43: fi
! 44:
! 45: input=$2
! 46:
! 47: if [ "$output" ]; then
! 48: exec 1<>$output
! 49: fi
! 50:
! 51: if [ "$input" ]; then
! 52: exec 0<>$input
! 53: fi
! 54:
! 55: cat <<!
! 56: /*
! 57: * DO NOT EDIT! Automatically generated by $0.
! 58: */
! 59: #include <stdlib.h>
! 60:
! 61: #include "private.h"
! 62:
! 63: const char *
! 64: mdoc_a2${name}(const char *p)
! 65: {
! 66:
! 67: !
! 68:
! 69: while read in ; do
! 70: key=`printf "%s\n" "$in" | cut -f 1`
! 71: val=`printf "%s\n" "$in" | cut -f 2- | sed 's!^[ ]*!!'`
! 72: cat <<!
! 73: if (xstrcmp(p, "$key"))
! 74: return("$val");
! 75: !
! 76: done
! 77:
! 78: cat <<!
! 79:
! 80: /* No keys found. */
! 81: return(NULL);
! 82: }
! 83: !
CVSweb