Stefan Hajnoczi | 9737383 | 2012-01-04 22:23:32 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # This script verifies that qerror definitions and table entries are |
| 3 | # alphabetically ordered. |
| 4 | |
| 5 | check_order() { |
| 6 | errmsg=$1 |
| 7 | shift |
| 8 | |
| 9 | # sort -C verifies order but does not print a message. sort -c does print a |
| 10 | # message. These options are both in POSIX. |
| 11 | if ! "$@" | sort -C; then |
| 12 | echo "$errmsg" |
| 13 | "$@" | sort -c |
| 14 | exit 1 |
| 15 | fi |
| 16 | return 0 |
| 17 | } |
| 18 | |
| 19 | check_order 'Definitions in qerror.h must be in alphabetical order:' \ |
| 20 | grep '^#define QERR_' qerror.h |
| 21 | check_order 'Entries in qerror.c:qerror_table must be in alphabetical order:' \ |
| 22 | sed -n '/^static.*qerror_table\[\]/,/^};/s/QERR_/&/gp' qerror.c |