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()
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
}
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}};'
}
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
}
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
}