[x264-devel] cltostr.sh: Minor fixes

Henrik Gramner git at videolan.org
Wed Aug 19 21:16:14 CEST 2015


x264 | branch: master | Henrik Gramner <henrik at gramner.com> | Sat Aug  8 18:34:21 2015 +0200| [817a4414b98e8a511c626932e7d433388bc96507] | committer: Anton Mitrofanov

cltostr.sh: Minor fixes

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=817a4414b98e8a511c626932e7d433388bc96507
---

 tools/cltostr.sh |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/cltostr.sh b/tools/cltostr.sh
index 852ba8a..23b6cc7 100755
--- a/tools/cltostr.sh
+++ b/tools/cltostr.sh
@@ -1,8 +1,9 @@
 #!/bin/sh
+
 # Convert standard input to a C char array, write to a file, then create an
 # MD5 sum of that file and append said MD5 sum as char array to the file.
 
-FILE=$1
+[ -n "$1" ] || exit 1
 
 # Filter out whitespace, empty lines, and comments.
 sanitize() {
@@ -11,22 +12,22 @@ sanitize() {
 
 # Convert stdin to a \0-terminated char array.
 dump() {
-    printf 'static const char %s[] = {\n' $1
+    echo "static const char $1[] = {"
     od -v -A n -t x1 | sed 's/[[:space:]]*\([[:alnum:]]\{2\}\)/0x\1, /g'
-    printf '0x00 };\n'
+    echo '0x00 };'
 }
 
 # Print MD5 hash w/o newline character to not embed the character in the array.
 hash() {
     # md5sum is not standard, so try different platform-specific alternatives.
-    { md5sum $1 2> /dev/null || md5 -q $1 || digest -a md5 $1; } |
+    { md5sum "$1" || md5 -q "$1" || digest -a md5 "$1"; } 2>/dev/null |
         cut -b -32 | tr -d '\n\r'
 }
 
-trap "rm -f $FILE.temp" EXIT
+trap 'rm -f "$1.temp"' EXIT
 
-sanitize | tee $FILE.temp |
-    dump x264_opencl_source > $FILE
+sanitize | tee "$1.temp" |
+    dump 'x264_opencl_source' > "$1"
 
-hash $FILE.temp |
-    dump x264_opencl_source_hash >> $FILE
+hash "$1.temp" |
+    dump 'x264_opencl_source_hash' >> "$1"



More information about the x264-devel mailing list