X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command_util.sh;h=abae4ec2b74c84e925c0297900c01c3dfb3c553a;hp=875b5e6957f7509a15352cdfc6a9c7239402a448;hb=c9df5dfaa915915e0717c1992bc8498f6432dba8;hpb=73ca799d08ee415ffb35ecce736b5e7d2abc3c73 diff --git a/command_util.sh b/command_util.sh index 875b5e69..abae4ec2 100755 --- a/command_util.sh +++ b/command_util.sh @@ -10,6 +10,9 @@ read_header() ---) break ;; + BN:) + base_name="$value" + ;; OF:) output_file="$value" array_name=${value%command_list}cmds @@ -248,10 +251,18 @@ 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 loop_result="$loop_result$result" done result="$loop_result" + # reset global variables + name_txt="$t_name" + perms_txt="$t_perms" + desc_txt="$t_desc" + usage_txt="$t_usage" + help_txt="$t_help" + source_files="$t_source_files" } com_c_file() @@ -280,6 +291,9 @@ com_c_file() com_header() { + local array_members CR=' +' + echo "extern struct $array_type $array_name[];" while : ; do read_one_command @@ -292,11 +306,17 @@ com_header() if test $template -eq 0; then make_proto printf "%s" "$result" + make_array_member + array_members="$array_members$result" continue fi template_loop make_proto printf "%s" "$result" + template_loop make_array_member + array_members="$array_members$result" done + array_members="$array_members{.name = NULL} \\$CR" + echo "#define DEFINE_$(tr 'a-z' 'A-Z' <<< "$base_name")_CMD_ARRAY $array_members" } com_completion()