X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command_util.sh;h=e33e0769d9cbc2230bf02b70813d5435f2447430;hp=abae4ec2b74c84e925c0297900c01c3dfb3c553a;hb=b3644a3f5de245609dc608a947ed71e2f75b2fd5;hpb=c9df5dfaa915915e0717c1992bc8498f6432dba8 diff --git a/command_util.sh b/command_util.sh index abae4ec2..e33e0769 100755 --- a/command_util.sh +++ b/command_util.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - read_header() { local key value i @@ -13,30 +12,9 @@ read_header() BN:) base_name="$value" ;; - OF:) - output_file="$value" - array_name=${value%command_list}cmds - ;; SF:) source_files="$value" ;; - AT:) - array_type="$value" - ;; - SI:) - for i in $value; do - system_includes="$system_includes -#include <$i.h>" - done - ;; - IN:) - for i in $value; do - includes="$includes -#include \"$i.h\"" - done - includes="$includes -#include \"$output_file.h\"" - ;; SN:) section_name="$value" ;; @@ -44,10 +22,6 @@ read_header() template_members="$value" esac done - if test -z "$output_file"; then - echo "header error" 1&>2 - exit 1 - fi } read_one_command() @@ -62,7 +36,6 @@ read_one_command() template=0 template_name="" template_prototype="" - mkdir -p man/man1 while read key value; do case "$key" in ---) @@ -191,15 +164,17 @@ com_man() make_proto() { - local source_file match="" CR=' + local regex='\(__noreturn \)*\(static \)*int com_' + local source_file match="" all_commands CR=' ' if test -n "$prototype"; then result="$prototype$CR" return fi + all_commands="$(cat $source_files | grep "$regex")" result= for source_file in $source_files; do - match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1') + match=$(grep "$regex$name_txt(" <<< "$all_commands" | head -n 1 | sed -e 's/$/;/1') if test -n "$match"; then result="$result$match$CR" break @@ -242,15 +217,12 @@ template_loop() local t_source_files="$source_files" local member for member in $template_members; do - local sed_cmd="sed -e s/@member@/$member/g" - #echo "sed_cmd: $sed_cmd" - name_txt=$(echo "$t_name" | $sed_cmd) - #name_txt="$tname" - perms_txt=$(echo "$t_perms" | $sed_cmd) - desc_txt=$(echo "$t_desc" | $sed_cmd) - usage_txt=$(echo "$t_usage" | $sed_cmd) - help_txt=$(printf "%s\n" "$t_help" | $sed_cmd) - prototype=$(echo "$template_prototype" | $sed_cmd) + name_txt="${t_name//@member@/$member}" + perms_txt="${t_perms//@member@/$member}" + desc_txt="${t_desc//@member@/$member}" + usage_txt="${t_usage//@member@/$member}" + help_txt="${t_help//@member@/$member}" + prototype="${template_prototype//@member@/$member}" result= $1 loop_result="$loop_result$result" @@ -265,36 +237,11 @@ template_loop() source_files="$t_source_files" } -com_c_file() -{ - echo "$system_includes" - echo "$includes" - echo "struct $array_type $array_name[] = {" - while : ; do - read_one_command - if test $ret -lt 0; then - exit 1 - fi - if test $ret -eq 0; then - break - fi - if test $template -eq 0; then - make_array_member - printf "%s" "$result" - continue - fi - template_loop make_array_member - printf "%s" "$result" - done - echo '{.name = NULL}};' -} - com_header() { local array_members CR=' ' - echo "extern struct $array_type $array_name[];" while : ; do read_one_command if test $ret -lt 0; then @@ -346,9 +293,6 @@ read_header arg="$1" shift case "$arg" in - "c") - com_c_file - ;; "h") com_header ;;