X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command_util.sh;h=a66b56bbdb51940a5aabb50f3e98daeae5d561cd;hp=f388b2cfb152db7cf34e0b2f84313ba26a209903;hb=6a4f5e85c1e9eb6fd21477438762c4f95c29f30c;hpb=5000a12ad288893d494ccd04d061752ed022d1d0 diff --git a/command_util.sh b/command_util.sh index f388b2cf..a66b56bb 100755 --- a/command_util.sh +++ b/command_util.sh @@ -10,12 +10,6 @@ read_header() ---) break ;; - HC:) - header_comment="$value" - ;; - CC:) - c_file_comment="$value" - ;; OF:) output_file="$value" array_name=${value%command_list}cmds @@ -47,8 +41,7 @@ read_header() template_members="$value" esac done - if test -z "$header_comment" -o -z "$c_file_comment" \ - -o -z "$output_file"; then + if test -z "$output_file"; then echo "header error" 1&>2 exit 1 fi @@ -200,14 +193,6 @@ dump_proto() echo '/**' echo " * $desc_txt" echo ' *' - if [[ "$system_includes" =~ openssl/rc4.h ]]; then - echo ' * \param rc4c The rc4 crypt context.' - else - echo ' * \param fd The file descriptor to send output to.' - fi - echo ' * \param argc The number of arguments.' - echo ' * \param argv The argument vector.' - echo ' * ' echo " * Usage: $usage_txt" echo ' * ' echo "$help_txt" | sed -e 's/^/ * /g' @@ -229,6 +214,7 @@ dump_proto() dump_array_member() { + local TAB=' ' echo '{' echo ".name = \"$name_txt\"," echo ".handler = com_$name_txt," @@ -238,10 +224,15 @@ dump_array_member() echo ".description = \"$desc_txt\"," echo ".usage = \"$usage_txt\"," echo ".help = " - printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' + printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \ + -e "s/$TAB/\\\t/g" echo '},' } +dump_completion() +{ + echo " {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\" +} template_loop() { @@ -255,11 +246,11 @@ template_loop() 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=$(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) + 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) $1 @@ -269,7 +260,6 @@ template_loop() com_c_file() { - echo "/** \file $output_file.c $c_file_comment */" echo "$system_includes" echo "$includes" echo "struct $array_type $array_name[] = {" @@ -292,8 +282,6 @@ com_c_file() com_header() { - echo "/** \file $output_file.h $header_comment */" - echo echo "extern struct $array_type $array_name[];" while : ; do read_one_command @@ -311,6 +299,27 @@ com_header() done } +com_completion() +{ + + echo "#define $1 \\" + 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 + dump_completion + continue + fi + template_loop dump_completion + done + echo +} + read_header arg="$1" shift @@ -324,4 +333,7 @@ case "$arg" in "man") com_man $* ;; + "compl") + com_completion $* + ;; esac