autogenerate zip_err_str from zip.h --HG-- branch : HEAD
diff --git a/lib/Makefile.am b/lib/Makefile.am index 0d9ec57..55a6e03 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am
@@ -6,3 +6,7 @@ zip_fopen.c zip_fopen_index.c zip_fclose.c zip_fread.c \ zf_new_free.c +BUILT_SOURCES=zip_err_str.c + +zip_err_str.c: zip.h + make_zip_err_str.sh zip.h zip_err_str.c \ No newline at end of file
diff --git a/lib/make_zip_err_str.sh b/lib/make_zip_err_str.sh new file mode 100755 index 0000000..98cf429 --- /dev/null +++ b/lib/make_zip_err_str.sh
@@ -0,0 +1,23 @@ +#!/bin/sh + +if [ "$#" -ne 2 ] +then + echo Usage: $0 in_file out_file >&2 + echo e.g. $0 zip.h zip_err_str.c >&2 + exit 1 +fi + +if [ "$1" = "$2" ] +then + echo $0: error: output file = input file >&2 + exit 1 +fi + +echo "/* This file was autogenerated by $0 from $1" > "$2.$$" +echo " -- don't change here */" >> "$2.$$" +echo '#include "zip.h"' >> "$2.$$" +echo 'char *zip_err_str[] = {' >> "$2.$$" +sed -n '/^#define ZERR_/ s/.*\/\* \([^*]*\) \*\// "\1",/p' "$1" >> "$2.$$" +echo '}' >> "$2.$$" + +mv "$2.$$" "$2"
diff --git a/zip_err_str.c b/zip_err_str.c deleted file mode 100644 index fda6ac7..0000000 --- a/zip_err_str.c +++ /dev/null
@@ -1,23 +0,0 @@ -#include "zip.h" - - - -char * zip_err_str[]={ - "no error", - "multi-disk zip-files not supported", - "replacing zipfile with tempfile failed", - "closing zipfile failed", - "seek error", - "read error", - "write error", - "CRC error", - "zip file closed without closing this file", - "file does already exist", - "file doesn't exist", - "can't open file", - "error creating temp file", - "zlib error", - "malloc failure", - "entry has been changed", - "compression method not supported" -};