From 2aa590cb0761818fec9198ba4a1854310e1e0bf1 Mon Sep 17 00:00:00 2001 From: Beat Bolli Date: Fri, 19 Dec 2014 17:24:20 +0100 Subject: [PATCH 1/5] update_unicode.sh: simplify output capture Instead of capturing the output of each echo and uniset invocation, wrap the whole section in a group command and redirect its output all at once. Signed-off-by: Beat Bolli Signed-off-by: Junio C Hamano --- update_unicode.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/update_unicode.sh b/update_unicode.sh index 000b937e68..c1c876c940 100755 --- a/update_unicode.sh +++ b/update_unicode.sh @@ -26,12 +26,13 @@ fi && ./configure --enable-warnings=-Werror CFLAGS='-O0 -ggdb' fi && make - ) && - echo "static const struct interval zero_width[] = {" >$UNICODEWIDTH_H && - UNICODE_DIR=. ./uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | - grep -v plane >>$UNICODEWIDTH_H && - echo "};" >>$UNICODEWIDTH_H && - echo "static const struct interval double_width[] = {" >>$UNICODEWIDTH_H && - UNICODE_DIR=. ./uniset/uniset --32 eaw:F,W >>$UNICODEWIDTH_H && - echo "};" >>$UNICODEWIDTH_H + ) && { + echo "static const struct interval zero_width[] = {" && + UNICODE_DIR=. ./uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | + grep -v plane && + echo "};" && + echo "static const struct interval double_width[] = {" && + UNICODE_DIR=. ./uniset/uniset --32 eaw:F,W && + echo "};" + } >$UNICODEWIDTH_H ) From 69d84a3b58464f1a60a1f93642ecd727a26067fa Mon Sep 17 00:00:00 2001 From: Beat Bolli Date: Fri, 19 Dec 2014 17:24:21 +0100 Subject: [PATCH 2/5] update_unicode.sh: set UNICODE_DIR only once The value is the same on both uniset invocations, so "Don't Repeat Yourself" applies. Since this is done as the last command in the sequence, there's no need to unset UNICODE_DIR at the end. Signed-off-by: Beat Bolli Signed-off-by: Junio C Hamano --- update_unicode.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/update_unicode.sh b/update_unicode.sh index c1c876c940..bed8916910 100755 --- a/update_unicode.sh +++ b/update_unicode.sh @@ -27,12 +27,13 @@ fi && fi && make ) && { + UNICODE_DIR=. && export UNICODE_DIR && echo "static const struct interval zero_width[] = {" && - UNICODE_DIR=. ./uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | + ./uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | grep -v plane && echo "};" && echo "static const struct interval double_width[] = {" && - UNICODE_DIR=. ./uniset/uniset --32 eaw:F,W && + ./uniset/uniset --32 eaw:F,W && echo "};" } >$UNICODEWIDTH_H ) From 3a77c2096d102e43afb7a145c938b68c83f065ab Mon Sep 17 00:00:00 2001 From: Beat Bolli Date: Fri, 19 Dec 2014 17:24:22 +0100 Subject: [PATCH 3/5] update_unicode.sh: shorten uniset invocation path "uniset/uniset" is a relative path; there's no need to prefix it with "./". Signed-off-by: Beat Bolli Signed-off-by: Junio C Hamano --- update_unicode.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update_unicode.sh b/update_unicode.sh index bed8916910..f5cc14b338 100755 --- a/update_unicode.sh +++ b/update_unicode.sh @@ -29,11 +29,11 @@ fi && ) && { UNICODE_DIR=. && export UNICODE_DIR && echo "static const struct interval zero_width[] = {" && - ./uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | + uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | grep -v plane && echo "};" && echo "static const struct interval double_width[] = {" && - ./uniset/uniset --32 eaw:F,W && + uniset/uniset --32 eaw:F,W && echo "};" } >$UNICODEWIDTH_H ) From 1679acdbff6443e07cd880048598d8de45663370 Mon Sep 17 00:00:00 2001 From: Beat Bolli Date: Fri, 19 Dec 2014 17:24:23 +0100 Subject: [PATCH 4/5] update_unicode.sh: make the output structure visible By using a here document instead of the echo/uniset sequence, the final structure of the generated file becomes obvious. Signed-off-by: Beat Bolli Signed-off-by: Junio C Hamano --- update_unicode.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/update_unicode.sh b/update_unicode.sh index f5cc14b338..d7343b997d 100755 --- a/update_unicode.sh +++ b/update_unicode.sh @@ -28,12 +28,14 @@ fi && make ) && { UNICODE_DIR=. && export UNICODE_DIR && - echo "static const struct interval zero_width[] = {" && - uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | - grep -v plane && - echo "};" && - echo "static const struct interval double_width[] = {" && - uniset/uniset --32 eaw:F,W && - echo "};" + cat <<-EOF + static const struct interval zero_width[] = { + $(uniset/uniset --32 cat:Me,Mn,Cf \ + + U+1160..U+11FF - U+00AD | grep -v plane) + }; + static const struct interval double_width[] = { + $(uniset/uniset --32 eaw:F,W) + }; + EOF } >$UNICODEWIDTH_H ) From 32c239d1fb23d47aa95cc8a47f99dc25f152021d Mon Sep 17 00:00:00 2001 From: Beat Bolli Date: Fri, 19 Dec 2014 17:24:24 +0100 Subject: [PATCH 5/5] update_unicode.sh: delete the command group Now that the whole file is generated by one single command, the command group is no longer needed. Signed-off-by: Beat Bolli Signed-off-by: Junio C Hamano --- update_unicode.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/update_unicode.sh b/update_unicode.sh index d7343b997d..27af77c7df 100755 --- a/update_unicode.sh +++ b/update_unicode.sh @@ -26,16 +26,15 @@ fi && ./configure --enable-warnings=-Werror CFLAGS='-O0 -ggdb' fi && make - ) && { - UNICODE_DIR=. && export UNICODE_DIR && - cat <<-EOF - static const struct interval zero_width[] = { - $(uniset/uniset --32 cat:Me,Mn,Cf \ - + U+1160..U+11FF - U+00AD | grep -v plane) - }; - static const struct interval double_width[] = { - $(uniset/uniset --32 eaw:F,W) - }; - EOF - } >$UNICODEWIDTH_H + ) && + UNICODE_DIR=. && export UNICODE_DIR && + cat >$UNICODEWIDTH_H <<-EOF + static const struct interval zero_width[] = { + $(uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | + grep -v plane) + }; + static const struct interval double_width[] = { + $(uniset/uniset --32 eaw:F,W) + }; + EOF )