MCPcopy Create free account
hub / github.com/RsyncProject/rsync / showShortOptions

Function showShortOptions

popt/popthelp.c:810–847  ·  view source on GitHub ↗

* Return concatenated short options for display. * @todo Sub-tables should be recursed. * @param opt option(s) * @param fp output file handle * @retval str concatenation of short options * @return length of display string */

Source from the content-addressed store, hash-verified

808 * @return length of display string
809 */
810static size_t showShortOptions(const struct poptOption * opt, FILE * fp,
811 char * str)
812{
813 /* bufsize larger then the ascii set, lazy allocation on top level call. */
814 size_t nb = (size_t)300;
815 char * s = (str != NULL ? str : calloc((size_t)1, nb));
816 size_t len = (size_t)0;
817
818 if (s == NULL)
819 return 0;
820
821 if (opt != NULL)
822 for (; (opt->longName || opt->shortName || opt->arg); opt++) {
823 if (!F_ISSET(opt, DOC_HIDDEN) && opt->shortName && !poptArgType(opt))
824 {
825 /* Display shortName iff unique printable non-space. */
826 if (!strchr(s, opt->shortName) && isprint((int)opt->shortName)
827 && opt->shortName != ' ')
828 s[strlen(s)] = opt->shortName;
829 } else if (poptArgType(opt) == POPT_ARG_INCLUDE_TABLE) {
830 void * arg = opt->arg;
831 /* XXX sick hack to preserve pretense of ABI. */
832 if (arg == poptHelpOptions)
833 arg = poptHelpOptionsI18N;
834 if (arg) /* XXX program error */
835 len = showShortOptions(arg, fp, s);
836 }
837 }
838
839 /* On return to top level, print the short options, return print length. */
840 if (s != str && *s != '\0') {
841 fprintf(fp, " [-%s]", s);
842 len = strlen(s) + sizeof(" [-]")-1;
843 }
844 if (s != str)
845 free(s);
846 return len;
847}
848
849void poptPrintUsage(poptContext con, FILE * fp, UNUSED(int flags))
850{

Callers 1

poptPrintUsageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected