From: Andre Noll Date: Wed, 27 Jun 2012 23:18:23 +0000 (+0200) Subject: command_util: replace dump_xxx() by make_xxx(). X-Git-Tag: v0.4.11~10^2~7 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=a5158610b0a44f7b0d26c603dc1063dec15d5eb5;hp=6a4f5e85c1e9eb6fd21477438762c4f95c29f30c command_util: replace dump_xxx() by make_xxx(). This replace dump_array_member(), dump_completion() and dump_proto() by their make_xxx counterpart. This allows to iterate over all commands twice. --- diff --git a/command_util.sh b/command_util.sh index a66b56bb..563ab1a2 100755 --- a/command_util.sh +++ b/command_util.sh @@ -186,52 +186,50 @@ com_man() done } -dump_proto() +make_proto() { - local source_file match="" - - echo '/**' - echo " * $desc_txt" - echo ' *' - echo " * Usage: $usage_txt" - echo ' * ' - echo "$help_txt" | sed -e 's/^/ * /g' - echo ' */' + local source_file match="" CR=' +' if test -n "$prototype"; then - echo "$prototype" - echo + result="$prototype$CR" return fi + result= for source_file in $source_files; do match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1') if test -n "$match"; then - echo "$match" + result="$result $match$CR" break fi done echo } -dump_array_member() +make_array_member() { local TAB=' ' - echo '{' - echo ".name = \"$name_txt\"," - echo ".handler = com_$name_txt," + local tmp + + result=" + { + .name = \"$name_txt\", + .handler = com_$name_txt, + " if test -n "$perms_txt"; then - echo ".perms = $perms_txt," + result="$result .perms = $perms_txt," fi - echo ".description = \"$desc_txt\"," - echo ".usage = \"$usage_txt\"," - echo ".help = " - printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \ - -e "s/$TAB/\\\t/g" - echo '},' + result="$result + .description = \"$desc_txt\", + .usage = \"$usage_txt\", + .help = " + tmp="$(printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \ + -e "s/$TAB/\\\t/g")" + result="$result $tmp }," } -dump_completion() +make_completion() { - echo " {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\" + result=" {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\" } template_loop() @@ -253,7 +251,9 @@ template_loop() usage_txt=$(echo "$t_usage" | $sed_cmd) help_txt=$(printf "%s\n" "$t_help" | $sed_cmd) prototype=$(echo "$template_prototype" | $sed_cmd) + result= $1 + echo "$result" done } @@ -272,10 +272,11 @@ com_c_file() break fi if test $template -eq 0; then - dump_array_member + make_array_member + echo "$result" continue fi - template_loop dump_array_member + template_loop make_array_member done echo '{.name = NULL}};' } @@ -292,10 +293,11 @@ com_header() break fi if test $template -eq 0; then - dump_proto + make_proto + echo "$result" continue fi - template_loop dump_proto + template_loop make_proto done } @@ -312,10 +314,11 @@ com_completion() break fi if test $template -eq 0; then - dump_completion + make_completion + echo "$result" continue fi - template_loop dump_completion + template_loop make_completion done echo }