| echo "Usage: $0 in_file out_file" >&2 |
| echo " e.g. $0 zip.h zip_err_str.c" >&2 |
| echo "$0: error: output file = input file" >&2 |
| cat <<EOF >> "$2.$$" || exit 1 |
| /* This file was generated automatically by $0 |
| from $1; make changes there. */ |
| const char * const _zip_err_str[] = { |
| sed -n '/^#define ZERR_/ s/.*\/\* . \([^*]*\) \*\// "\1",/p' "$1" \ |
| cat <<EOF >> "$2.$$" || exit 1 |
| const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]); |
| const int _zip_err_type[] = { |
| sed -n '/^#define ZERR_/ s/.*\/\* \(.\) \([^*]*\) \*\// \1,/p' "$1" \ |
| echo '};' >> "$2.$$" || exit 1 |
| mv "$2.$$" "$2" || exit 1 |