[LTP] [PATCH v1] Complete help message adding option before desc

Cyril Hrubis chrubis@suse.cz
Tue Dec 21 11:38:14 CET 2021


Hi!
>  static void print_help(void)
>  {
>  	unsigned int i;
> +	char msg[1024];
>  
>  	/* see doc/user-guide.txt, which lists also shell API variables */
>  	fprintf(stderr, "Environment Variables\n");
> @@ -498,8 +499,13 @@ static void print_help(void)
>  	if (!tst_test->options)
>  		return;
>  
> -	for (i = 0; tst_test->options[i].optstr; i++)
> -		fprintf(stderr, "%s\n", tst_test->options[i].help);
> +	for (i = 0; tst_test->options[i].optstr; i++) {
> +		snprintf(msg, 1024, "-%c\t %s",
> +			tst_test->options[i].optstr[0],
> +			tst_test->options[i].help);
> +
> +		fprintf(stderr, "%s\n", msg);
> +	}
>  }

I got rid of the useless temporary buffer here and pushed, thanks.

This is actually a step into a right direction and it also makes the
generated documentation a bit better too. Ideally the tst_test structure
could be also improved to include the default value for the option
too...

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list