From: Andre Noll Date: Sun, 28 Aug 2011 04:34:55 +0000 (+0200) Subject: Teach command_util to print also completions. X-Git-Tag: v0.4.9~1^2~8 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=09a69f08d83ad23e806f0412fbc3f98b1410b115;p=paraslash.git Teach command_util to print also completions. This adds completion mode to command_util.sh. When exectuted in this mode, it prints array initializers for all supported commands. This will be used to generate the array of completers for para_client and para_audiod. --- diff --git a/.gitignore b/.gitignore index 91c6f858..d337367b 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ confdefs.h conftest conftest.c git-version.h +*_completion.h diff --git a/Doxyfile b/Doxyfile index 81e414d5..83973cfb 100644 --- a/Doxyfile +++ b/Doxyfile @@ -623,7 +623,8 @@ EXCLUDE_PATTERNS = *.cmdline.* \ gcc-compat.h \ fade.c \ config.h \ - *_command_list.[ch] + *_command_list.[ch] \ + *_completion.h # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/Makefile.in b/Makefile.in index 23ceda47..cf9598f7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -109,6 +109,15 @@ tarball: $(tarball) -include $(ggo_dir)/makefile +# When in doubt, use brute force (Ken Thompson) +TOUPPER = \ +$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\ +$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\ +$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\ +$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\ +$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\ +$(subst z,Z,$1)))))))))))))))))))))))))) + %_command_list.c: %.cmd @[ -z "$(Q)" ] || echo 'GEN $@' $(Q) ./command_util.sh c < $< >$@ @@ -118,6 +127,10 @@ tarball: $(tarball) %_command_list.man: %.cmd @[ -z "$(Q)" ] || echo 'GEN $@' $(Q) ./command_util.sh man < $< > $@ +%_completion.h: %.cmd + @[ -z "$(Q)" ] || echo 'GEN $@' + $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \ + $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@ server_command_lists_man = server_command_list.man afs_command_list.man man/man1/para_server.1: para_server $(server_command_lists_man) | $(man_dir) @@ -283,8 +296,7 @@ clean: clean2: clean @[ -z "$(Q)" ] || echo 'CLEAN2' $(Q) rm -rf man $(object_dir) $(cmdline_dir) - $(Q) rm -f *_command_list.* $(ggo_generated) - + $(Q) rm -f *_command_list.* *_completion.h $(ggo_generated) distclean: clean2 test-clean @[ -z "$(Q)" ] || echo 'DISTCLEAN' $(Q) rm -f Makefile autoscan.log config.status config.log diff --git a/command_util.sh b/command_util.sh index 86e01258..76b3445f 100755 --- a/command_util.sh +++ b/command_util.sh @@ -236,6 +236,10 @@ dump_array_member() echo '},' } +dump_completion() +{ + echo " {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\" +} template_loop() { @@ -305,6 +309,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 @@ -318,4 +343,7 @@ case "$arg" in "man") com_man $* ;; + "compl") + com_completion $* + ;; esac