]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
command_util: Output array members with backslashes.
authorAndre Noll <maan@systemlinux.org>
Thu, 28 Jun 2012 01:08:00 +0000 (03:08 +0200)
committerAndre Noll <maan@systemlinux.org>
Fri, 29 Jun 2012 19:36:30 +0000 (21:36 +0200)
This makes sure that the generated code for the definition of the
command array has backslashes at the end of each line.  Currently
this does not matter because make_array_member() is only called when
generating C code where new lines don't matter.

However, ending each line with a backslash allows to use the same
output for a cpp #define which can go into the header file.

command_util.sh

index b3b8804c28f4bce50398ebdde5d4c32809a05bc4..875b5e6957f7509a15352cdfc6a9c7239402a448 100755 (executable)
@@ -206,24 +206,18 @@ make_proto()
 
 make_array_member()
 {
-       local TAB='     '
+       local TAB='     ' CR='
+'
        local tmp
 
-       result="
-       {
-       .name = \"$name_txt\",
-       .handler = com_$name_txt,
-       "
+       result="{.name = \"$name_txt\", .handler = com_$name_txt, "
        if test -n "$perms_txt"; then
                result="$result .perms = $perms_txt,"
        fi
-       result="$result
-       .description = \"$desc_txt\",
-       .usage = \"$usage_txt\",
-       .help = "
+       result="$result.description = \"$desc_txt\", .usage = \"$usage_txt\", \\$CR .help = "
        tmp="$(printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
-               -e "s/$TAB/\\\t/g")"
-       result="$result $tmp },"
+               -e "s/$TAB/\\\t/g" -e's/$/\\/g')"
+       result="$result$tmp$CR}, \\$CR"
 }
 
 make_completion()