From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Whitehouse Date: Tue, 06 Sep 2011 20:10:06 +0100 Subject: [Cluster-devel] [PATCH 3/3] mkfs i18n: In-Reply-To: <1315330915-15039-1-git-send-email-cmaiolino@redhat.com> References: <1315330915-15039-1-git-send-email-cmaiolino@redhat.com> Message-ID: <1315336206.2741.28.camel@menhir> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, On Tue, 2011-09-06 at 14:41 -0300, Carlos Maiolino wrote: > Use rpmatch() function to get answer to > yes-or-no questions during mkfs confirmation > > Signed-off-by: Carlos Maiolino > --- > gfs2/mkfs/main_mkfs.c | 30 ++++++++++++++++++++++-------- > 1 files changed, 22 insertions(+), 8 deletions(-) > > diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c > index 4751f19..d68cf98 100644 > --- a/gfs2/mkfs/main_mkfs.c > +++ b/gfs2/mkfs/main_mkfs.c > @@ -456,8 +456,11 @@ fail: > > static void are_you_sure(struct gfs2_sbd *sdp) > { > - char input[32]; > + char *line = NULL; > + size_t len = 0; > int fd; > + int ret = -1; > + int res = 0; > > fd = open(sdp->device_name, O_RDONLY|O_CLOEXEC); > if (fd < 0) > @@ -465,14 +468,25 @@ static void are_you_sure(struct gfs2_sbd *sdp) > printf( _("This will destroy any data on %s.\n"), sdp->device_name); > check_dev_content(sdp->device_name); > close(fd); > - printf( _("\nAre you sure you want to proceed? [y/n] ")); > - if(!fgets(input, 32, stdin)) > - die( _("unable to read from stdin\n")); > + > + do{ > + printf( _("\nAre you sure you want to proceed? [y/n]")); This means that the translator needs to know that rpmatch is being used and to also know how to translate this accordingly. Why not use nl_langinfo() to put the response strings into this message? Also, starting the string with \n is a bit odd too, Steve. > + ret = getline(&line, &len, stdin); > + res = rpmatch(line); > + > + if (res > 0){ > + free(line); > + return; > + } > + if (!res){ > + printf("\n"); > + die( _("aborted\n")); > + } > + > + }while(ret >= 0); > > - if (input[0] != 'y') > - die( _("aborted\n")); > - else > - printf("\n"); > + if(line) > + free(line); > } > > /**