From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: util-linux-owner@vger.kernel.org Received: from mout.gmx.net ([212.227.15.19]:64072 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751595AbdF2Khc (ORCPT ); Thu, 29 Jun 2017 06:37:32 -0400 From: Ruediger Meier To: Karel Zak Subject: Re: fputs() vs puts() (was: [PATCH] hwclock: remove unused usage() FILE argument) Date: Thu, 29 Jun 2017 12:37:19 +0200 Cc: J William Piggott , util-linux@vger.kernel.org References: <011634ef-e5e7-354e-6064-3191450b4fc8@gmx.com> <201706282129.41161.sweet_f_a@gmx.de> <20170629085114.66lbbszwxnooszbb@ws.net.home> In-Reply-To: <20170629085114.66lbbszwxnooszbb@ws.net.home> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Message-Id: <201706291237.19507.sweet_f_a@gmx.de> Sender: util-linux-owner@vger.kernel.org List-ID: On Thursday 29 June 2017, Karel Zak wrote: > On Wed, Jun 28, 2017 at 09:29:40PM +0200, Ruediger Meier wrote: > > On Tuesday 20 June 2017, Karel Zak wrote: > > > On Sun, Jun 18, 2017 at 08:49:49PM -0400, J William Piggott wrote: > > > > sys-utils/hwclock.c | 74 > > > > ++++++++++++++++++++++++++--------------------------- 1 file > > > > changed, 37 insertions(+), 37 deletions(-) > > > > > > It would be better to remove this patch from the pull-request; > > > let's keep fputs() in the code and wait for any solution from > > > Rudi :-) > > > > I have now finished my cleanup regarding stdout only. To make the > > diffs small I have left a useless definition "FILE *out = stdout;" > > in almost any usage function. > > > > We can remove this "out" variable now everwhere using a sed or awk. > > But a few questions about what would be the best end state. > > > > 1. fputs vs puts?: > > > > Is it a problem for translators if we remove a newline from > > almost any string? And, does puts() look more nice at all? I mean > > many usage functions have to use printf too, so does it look good > > if some strings are '\n' terminated and others not? > > Frankly, I prefer to have \n in the string, because in this case you > have full control on the output. And it also means all the strings > modification... for me fputs() is the winner :-) > > > 2. Alignment for better readabilty in the code. > > > > I would prefer leading spaces before the first string argument > > to match the longest possible prefix 'printf(_("'. Is that ok?: > > > > puts( _(" -q quiet mode")); > > fputs( _(" -v, --verbose verbose mode"), stdout); > > printf(_(" -f, --rtc use alternate to %1$s\n"), _BLA); > > printf( " --help %s\n", USAGE_OPTSTR_HELP); > > Yes, good idea. > > > 3. Maybe we should always decouple options and descriptions? > > > > Introducing a macro like: > > > > #define prnt_opt(opt, marg_dsc, dsc) \ > > printf( "%-" #marg_dsc "s%s\n", opt, dscr) > > > > /* the magic margin number for the whole function */ > > int m = 16; > > prnt_opt(" -q", m, _("quiet mode"); > > prnt_opt(" -v, --verbose", m, _("verbose mode"); > > prnt_opt(" --help", m, USAGE_OPTSTR_HELP); > > /* or standard help, as exist already */ > > print_usage_help_options(m); > > Hmm... now translator can also translate option arguments > > --something