~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to tools/mk_event_names.sh

  • Committer: Matthew Fuller
  • Date: 2016-04-04 06:26:38 UTC
  • Revision ID: fullermd@over-yonder.net-20160404062638-rbplil7a0zop0ccc
Generate event_names_table.h rather than event_names.c.

Originally this was so tiny it made more sense to edit on the fly than
to add another file just to hold a table.  But it pretty much
immediately wound up big enough that that's just silly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
 
# $0 event_names.list event_names.c.in > event_names.c
 
2
# $0 event_names.list > event_names_table.h
3
3
 
4
4
enames=$1
5
 
in=$2
 
5
 
 
6
# Header
 
7
echo '/*'
 
8
echo ' * AUTOGENERATED FILE -- DO NOT EDIT'
 
9
echo ' * This file is generated automatically by the build process from'
 
10
echo " * ${enames}"
 
11
echo ' */'
 
12
echo
 
13
echo 'static const char *event_names[] = {'
6
14
 
7
15
# Generate the string of the designated initializer for the array
8
 
ENSTR=""
9
16
for i in `cat $enames`; do
10
 
        ENSTR="$ENSTR [$i] = \"$i\","
 
17
        echo "    [$i] = \"$i\","
11
18
done
12
19
 
13
 
# Now translate
14
 
sed -e "s/%%EVENT_NAMES%%/$ENSTR/" ${in}
 
20
echo '};'