diff options
author | John Koleszar <jkoleszar@google.com> | 2010-05-18 11:58:33 -0400 |
---|---|---|
committer | John Koleszar <jkoleszar@google.com> | 2010-05-18 11:58:33 -0400 |
commit | 0ea50ce9cb4b65eee6afa1d041fe8beb5abda667 (patch) | |
tree | 1f3b9019f28bc56fd3156f96e5a9653a983ee61b /examples/gen_example_text.sh | |
download | libvpx-0ea50ce9cb4b65eee6afa1d041fe8beb5abda667.tar libvpx-0ea50ce9cb4b65eee6afa1d041fe8beb5abda667.tar.gz libvpx-0ea50ce9cb4b65eee6afa1d041fe8beb5abda667.tar.bz2 libvpx-0ea50ce9cb4b65eee6afa1d041fe8beb5abda667.zip |
Initial WebM release
Diffstat (limited to 'examples/gen_example_text.sh')
-rwxr-xr-x | examples/gen_example_text.sh | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/examples/gen_example_text.sh b/examples/gen_example_text.sh new file mode 100755 index 000000000..0e1f796ea --- /dev/null +++ b/examples/gen_example_text.sh @@ -0,0 +1,83 @@ +#!/bin/bash +## +## Copyright (c) 2010 The VP8 project authors. All Rights Reserved. +## +## Use of this source code is governed by a BSD-style license and patent +## grant that can be found in the LICENSE file in the root of the source +## tree. All contributing project authors may be found in the AUTHORS +## file in the root of the source tree. +## + + +# gen_example_text.sh + +self=$0 + +die_usage() { + echo "Usage: $self <example.txt>" + exit 1 +} + +die() { + echo "$@" + exit 1 +} + +include_block() { + local on_block + while IFS=$'\n' read -r t_line; do + case "$t_line" in + \~*\ ${block_name}) + if [ "x$on_block" == "xyes" ]; then + return 0; + else + on_block=yes + fi + ;; + *) + if [ "x$on_block" == "xyes" ]; then + echo "$t_line" + fi + ;; + esac + done + echo "WARNING: failed to find text for block $block_name" >&2 + return 1 +} + +txt=$1 +[ -f "$txt" ] || die_usage +read -r template < "$txt" +case "$template" in + @TEMPLATE*) template=${txt%/*}/${template##@TEMPLATE } ;; + *) die "Failed to parse template name from '$template'" ;; +esac + +fence="~~~~~~~~~" +fence="${fence}${fence}" +fence="${fence}${fence}" +fence="${fence}${fence}" +while IFS=$'\n' read -r line; do + case "$line" in + @TEMPLATE*) + template=${template##@TEMPLATE } + template=${template%.c}.txt + ;; + @DEFAULT) + include_block < "$template" + ;; + ~~~*) + block_name=${line##~* } + [ "$block_name" == "INTRODUCTION" ] || echo "$fence" + ;; + *) echo "$line" + ;; + esac +done < "$txt" + +echo +echo "Putting It All Together" +echo "=======================" +echo "${fence}" +${self%/*}/gen_example_code.sh "${txt}" +echo "${fence}" |