diff options
author | Doohwan Kim <dh8210.kim@samsung.com> | 2015-02-26 17:39:16 +0900 |
---|---|---|
committer | Doohwan Kim <dh8210.kim@samsung.com> | 2015-02-26 17:39:45 +0900 |
commit | da07ee69267b4557028357eae802d2a7a57c34e7 (patch) | |
tree | 02a5d7590fc35cd3ad08aa8894ca5f32947a1da1 /scripts | |
parent | 34c41c0eecd122a3dd92b30f30267ea4d951343a (diff) | |
download | murphy-tizen_3.0.2015.q2_common.tar.gz murphy-tizen_3.0.2015.q2_common.tar.bz2 murphy-tizen_3.0.2015.q2_common.zip |
Initialize Tizen 3.0submit/tizen_3.0.2015.q1_common/20150320.000000submit/tizen/20150313.025220accepted/tizen/wearable/20150313.084641accepted/tizen/tv/20150313.084515accepted/tizen/mobile/20150313.084815accepted/tizen/common/20150313.083743accepted/tizen/3.0.2015.q1/common/20150323.084221tizen_3.0.2015.q2_commontizen_3.0.2015.q1_commonaccepted/tizen_3.0.2015.q1_common
Signed-off-by: Doohwan Kim <dh8210.kim@samsung.com>
Change-Id: I2ad7e23e121506673a724f512fea429489928451
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/cleanup-whitespace.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/cleanup-whitespace.sh b/scripts/cleanup-whitespace.sh new file mode 100755 index 0000000..bfab741 --- /dev/null +++ b/scripts/cleanup-whitespace.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Replace TABs with sequences of 8 spaces in all given files. +replace_tabs() { + local _file _tmp + + for _file in $*; do + _tmp=$_file.tabs + cp $_file $_tmp && \ + cat $_tmp | \ + sed 's/\t/ /g' > $_file && \ + rm -f $_tmp + done +} + + +# Replaces lines containing only spaces with empty lines in all given files. +strip_empty_lines() { + local _file _tmp + + for _file in $*; do + _tmp=$_file.spaces + cp $_file $_tmp && \ + cat $_tmp | \ + sed 's/^ [ ]*$//g' > $_file && \ + rm -f $_tmp + done +} + + +# Strip trailing white space from all the given files. +strip_trailing_ws() { + local _file _tmp + + for _file in $*; do + _tmp=$_file.spaces + cp $_file $_tmp && \ + cat $_tmp | \ + sed 's/ *$//g' > $_file && \ + rm -f $_tmp + done +} + + +# Clean up TABS and empty lines in all given or found files. +if [ -n "$*" ]; then + replace_tabs $* && \ + strip_empty_lines $* && \ + strip_trailing_ws $* +else + files=$(find . -name \*.h -o -name \*.c) + replace_tabs $files && \ + strip_empty_lines $files && \ + strip_trailing_ws $files +fi |