projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
audiod: Fix a memory leak.
[paraslash.git]
/
command_util.sh
diff --git
a/command_util.sh
b/command_util.sh
index b757b2e0d29741097e649aeca38bd889b7541e70..4a9a03cc77f9637e20fc797d99f655ca3ce90a30 100755
(executable)
--- a/
command_util.sh
+++ b/
command_util.sh
@@
-8,13
+8,14
@@
dump_array_member()
if test $line_handler -eq 0; then
echo ".handler = com_$name_txt,"
else
if test $line_handler -eq 0; then
echo ".handler = com_$name_txt,"
else
+ echo ".handler = NULL,"
echo ".line_handler = com_$name_txt,"
fi
if test -n "$perms_txt"; then
echo ".perms = $perms_txt,"
fi
echo ".description = \"$desc_txt\","
echo ".line_handler = com_$name_txt,"
fi
if test -n "$perms_txt"; then
echo ".perms = $perms_txt,"
fi
echo ".description = \"$desc_txt\","
- echo ".
synopsis = \"$syn
_txt\","
+ echo ".
usage = \"$usage
_txt\","
echo ".help = "
echo "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g'
echo '},'
echo ".help = "
echo "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g'
echo '},'
@@
-35,27
+36,30
@@
read_header()
CC:)
c_file_comment="$value"
;;
CC:)
c_file_comment="$value"
;;
- FN:)
- file_name="$value"
+ OF:)
+ output_file="$value"
+ array_name=${value%command_list}cmds
+ ;;
+ SF:)
+ source_file="$value"
;;
AT:)
array_type="$value"
;;
;;
AT:)
array_type="$value"
;;
- AN:)
- array_name="$value"
- ;;
IN:)
for i in $value; do
includes="$includes
#include \"$i.h\""
done
includes="$includes
IN:)
for i in $value; do
includes="$includes
#include \"$i.h\""
done
includes="$includes
-#include \"$
file_nam
e.h\""
+#include \"$
output_fil
e.h\""
;;
;;
+ SN:)
+ section_name="$value"
esac
done
if test -z "$header_comment" -o -z "$c_file_comment" \
esac
done
if test -z "$header_comment" -o -z "$c_file_comment" \
- -o -z "$
file_nam
e"; then
+ -o -z "$
output_fil
e"; then
echo "header error" 1&>2
exit 1
fi
echo "header error" 1&>2
exit 1
fi
@@
-67,7
+71,7
@@
read_one_command()
name_txt=""
desc_txt=""
name_txt=""
desc_txt=""
-
syn
_txt=""
+
usage
_txt=""
help_txt=""
perms_txt=""
line_handler=0
help_txt=""
perms_txt=""
line_handler=0
@@
-89,8
+93,8
@@
read_one_command()
L:)
line_handler=1
;;
L:)
line_handler=1
;;
-
S
:)
-
syn
_txt="$value"
+
U
:)
+
usage
_txt="$value"
;;
H:)
help_txt="${value}"
;;
H:)
help_txt="${value}"
@@
-106,12
+110,12
@@
${line# }"
;;
esac
done
;;
esac
done
- if test -n "$name_txt" -a -n "$desc_txt" -a -n "$
syn
_txt" \
+ if test -n "$name_txt" -a -n "$desc_txt" -a -n "$
usage
_txt" \
-a -n "$help_txt"; then
ret=1
return
fi
-a -n "$help_txt"; then
ret=1
return
fi
- if test -z "$name_txt" -a -z "$desc_txt" -a -z "$
syn
_txt" \
+ if test -z "$name_txt" -a -z "$desc_txt" -a -z "$
usage
_txt" \
-a -z "$help_txt"; then
ret=0
return
-a -z "$help_txt"; then
ret=0
return
@@
-121,46
+125,36
@@
${line# }"
echo "!ERROR!"
echo "N: $name_txt"
echo "D: $desc_txt"
echo "!ERROR!"
echo "N: $name_txt"
echo "D: $desc_txt"
- echo "S: $
syn
_txt"
+ echo "S: $
usage
_txt"
echo "P: $perms_txt"
echo "H: $help_txt"
}
dump_man()
{
echo "P: $perms_txt"
echo "H: $help_txt"
}
dump_man()
{
- echo "
NAME
"
-
printf "\t$name_txt - $desc_txt\n
"
- echo
"SYNOPSIS"
-
printf "\t$syn_txt\n
"
- echo
"DESCRIPTION"
+ echo "
.SS \"$name_txt\"
"
+
echo "$desc_txt
"
+ echo
+
echo "\\fBusage: \\fP$usage_txt
"
+ echo
echo "$help_txt"
echo "$help_txt"
+ echo
if test -n "$perms_txt"; then
if test -n "$perms_txt"; then
- echo
"PERMISSIONS
"
+ echo
-n "\\fBpermissions:\\fP
"
if test "$perms_txt" = "0"; then
if test "$perms_txt" = "0"; then
-
printf "\t(none)\n
"
+
echo "(none)
"
else
else
-
printf "\t$perms_txt\n
"
+
echo "$perms_txt
"
fi
fi
fi
fi
-
+ echo
}
com_man()
{
}
com_man()
{
- local cn="$(grep ^codename Makefile.in)"
- local ver="$(grep ^AC_INIT configure.ac \
- | cut -f 2 -d ',')"
- cn=${cn#*=}
- ver=${ver# *[}
- ver=${ver%]}
- echo "r=paraslash-$ver (cn: $cn)"
- local n
- local txtdir=txt
- local mandir=man/man1
- local htmldir=html
- local pfx="$1"
- mkdir -p $txtdir $mandir $htmldir || exit 1
+ echo "[$section_name]"
+ echo
while : ; do
read_one_command
if test $ret -lt 0; then
while : ; do
read_one_command
if test $ret -lt 0; then
@@
-169,18
+163,13
@@
com_man()
if test $ret -eq 0; then
break
fi
if test $ret -eq 0; then
break
fi
- n=$pfx-$name_txt
- echo "pfx: $pfx, name: $n"
- dump_man > $txtdir/$n.txt
- txt2man -t "$n" -r "$r" < $txtdir/$n.txt \
- | sed -e 1d > $mandir/$n.1
- man2html $mandir/$n.1 > $htmldir/$n.html
+ dump_man
done
}
done
}
-com_
array
()
+com_
c_file
()
{
{
- echo "/** \file $
file_nam
e.c $c_file_comment */"
+ echo "/** \file $
output_fil
e.c $c_file_comment */"
echo "$includes"
echo "struct $array_type $array_name[] = {"
while : ; do
echo "$includes"
echo "struct $array_type $array_name[] = {"
while : ; do
@@
-209,21
+198,17
@@
dump_proto()
echo ' * \param cmdline the full command line'
fi
echo ' * '
echo ' * \param cmdline the full command line'
fi
echo ' * '
- echo " *
synopsis: $syn
_txt"
+ echo " *
usage: $usage
_txt"
echo ' * '
echo "$help_txt" | sed -e 's/^/ * /g'
echo ' */'
echo ' * '
echo "$help_txt" | sed -e 's/^/ * /g'
echo ' */'
- if test $line_handler -eq 0; then
- echo "int com_$name_txt(int fd, int argc, char **argv);"
- else
- echo "int com_$name_txt(int fd, char *cmdline);"
- fi
+ grep "^\(__noreturn \)*int com_$name_txt(" $source_file | sed -e 's/$/;/1'
echo
}
echo
}
-com_
proto
()
+com_
header
()
{
{
- echo "/** \file $
file_nam
e.h $header_comment */"
+ echo "/** \file $
output_fil
e.h $header_comment */"
echo
echo "extern struct $array_type $array_name[];"
while : ; do
echo
echo "extern struct $array_type $array_name[];"
while : ; do
@@
-242,11
+227,11
@@
read_header
arg="$1"
shift
case "$arg" in
arg="$1"
shift
case "$arg" in
- "
array
")
- com_
array
+ "
c
")
+ com_
c_file
;;
;;
- "
proto
")
- com_
proto
+ "
h
")
+ com_
header
;;
"man")
com_man $*
;;
"man")
com_man $*