mount.nfs: Support double-wide characters in printed strings
Subsystems (2)
PATCH 1/23 mount.nfs: Support double-wide characters in printed strings
NLS changes missed a spot or two.
---
utils/mount/error.c | 19 ++++++++++--------- utils/mount/mount.c | 32 ++++++++++++++++---------------- utils/mount/nfs4mount.c | 10 +++++----- utils/mount/nfsmount.c | 7 +++---- utils/mount/nfsumount.c | 18 +++++++++--------- 5 files changed, 43 insertions(+), 43 deletions(-)
utils/mount/error.c +10 -9
@@ -67,9 +67,10 @@ static int rpc_strerror(int spos) tmp = &errbuf[spos];if (cf_stat ==RPC_SYSTEMERROR ) pos =snprintf (tmp, (erreob - tmp), -"System Error: %s" ,strerror (cf_errno)); +_ ("System Error: %s" ),strerror (cf_errno));else - pos =snprintf (tmp, (erreob - tmp),"RPC Error:%s" , estr); + pos =snprintf (tmp, (erreob - tmp), +_ ("RPC Error: %s" ), estr); }return pos; }
@@ -83,21 +84,21 @@ void mount_errors(char *server, int will_retry, int bg) tmp = &errbuf[pos];if (bg) pos =snprintf (tmp, (erreob - tmp), -"mount to NFS server '%s' failed: " , server); +_ ("mount to NFS server '%s' failed: " ), server);else pos =snprintf (tmp, (erreob - tmp), -"mount: mount to NFS server '%s' failed: " , server); +_ ("mount: mount to NFS server '%s' failed: " ), server); tmp = &errbuf[pos];if (rpc_createerr.cf_stat ==RPC_TIMEDOUT ) { - pos =snprintf (tmp, (erreob - tmp),"timed out %s" , - will_retry ?"(retrying)" :"(giving up)" ); + pos =snprintf (tmp, (erreob - tmp),_ ("timed out %s" ), + will_retry ?_ ("(retrying)" ) :_ ("(giving up)" )); }else { pos +=rpc_strerror (pos); tmp = &errbuf[pos];if (bg) { - pos =snprintf (tmp, (erreob - tmp)," %s" , - will_retry ?"(retrying)" :"(giving up)" ); + pos =snprintf (tmp, (erreob - tmp),_ (" %s" ), + will_retry ?_ ("(retrying)" ) :_ ("(giving up)" )); } }if (bg) {
@@ -105,7 +106,7 @@ void mount_errors(char *server, int will_retry, int bg)openlog ("mount" ,LOG_CONS |LOG_PID ,LOG_AUTH );syslog (LOG_ERR ,"%s." , errbuf); }else -fprintf (stderr,"%s.\n" , errbuf); +fprintf (stderr,_ ("%s.\n" ), errbuf); }void mount_error (const char *spec,const char *mount_point,int error)
utils/mount/mount.c +16 -16
@@ -176,12 +176,12 @@ static void discover_nfs_mount_data_version(void)static void print_one (char *spec,char *node,char *type,char *opts) {if (verbose) { -printf ("%s on %s type %s" , spec, node, type); +printf (_ ("%s on %s type %s" ), spec, node, type);if (opts !=NULL ) -printf (" (%s)" , opts); +printf (_ (" (%s)" ), opts); -printf ("\n" ); +printf (_ ("\n" )); } }
@@ -269,18 +269,18 @@ fail_unlock:void mount_usage () { -printf ("usage: %s remotetarget dir [-rvVwfnh] [-o nfsoptions]\n" , +printf (_ ("usage: %s remotetarget dir [-rvVwfnh] [-o nfsoptions]\n" ), progname); -printf ("options:\n" ); -printf ("\t-r\t\tMount file system readonly\n" ); -printf ("\t-v\t\tVerbose\n" ); -printf ("\t-V\t\tPrint version\n" ); -printf ("\t-w\t\tMount file system read-write\n" ); -printf ("\t-f\t\tFake mount, do not actually mount\n" ); -printf ("\t-n\t\tDo not update /etc/mtab\n" ); -printf ("\t-s\t\tTolerate sloppy mount options rather than failing.\n" ); -printf ("\t-h\t\tPrint this help\n" ); -printf ("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n" ); +printf (_ ("options:\n" )); +printf (_ ("\t-r\t\tMount file system readonly\n" )); +printf (_ ("\t-v\t\tVerbose\n" )); +printf (_ ("\t-V\t\tPrint version\n" )); +printf (_ ("\t-w\t\tMount file system read-write\n" )); +printf (_ ("\t-f\t\tFake mount, do not actually mount\n" )); +printf (_ ("\t-n\t\tDo not update /etc/mtab\n" )); +printf (_ ("\t-s\t\tTolerate sloppy mount options rather than failing.\n" )); +printf (_ ("\t-h\t\tPrint this help\n" )); +printf (_ ("\tnfsoptions\tRefer to mount.nfs(8) or nfs(5)\n\n" )); }static void parse_opt (const char *opt,int *mask,char *extra_opts,int len)
@@ -384,7 +384,7 @@ int main(int argc, char *argv[])if (argv[1 ] && argv[1 ][0 ] =='-' ) {if (argv[1 ][1 ] =='V' ) -printf ("%s (" PACKAGE_STRING ")\n" , progname); +printf (_ ("%s (" PACKAGE_STRING ")\n" ), progname);else mount_usage ();exit (0 );
@@ -409,7 +409,7 @@ int main(int argc, char *argv[]) ++verbose;break ;case 'V' : -printf ("%s: (" PACKAGE_STRING ")\n" , progname); +printf (_ ("%s: (" PACKAGE_STRING ")\n" ), progname);return 0 ;case 'w' : flags &= ~MS_RDONLY ;
utils/mount/nfs4mount.c +5 -5
@@ -160,7 +160,7 @@ static int get_my_ipv4addr(char *ip_addr, int len) }if (fill_ipv4_sockaddr (myname, &myaddr))return -1 ; -snprintf (ip_addr, len,"%s" ,inet_ntoa (myaddr.sin_addr)); +snprintf (ip_addr, len,_ ("%s" ),inet_ntoa (myaddr.sin_addr)); ip_addr[len-1 ] ='\0' ;return 0 ; }
@@ -212,8 +212,8 @@ int nfs4mount(const char *spec, const char *node, int flags, progname); goto fail; } -snprintf (new_opts,sizeof (new_opts),"%s%saddr=%s" , - old_opts, *old_opts ?"," :"" , s); +snprintf (new_opts,sizeof (new_opts),_ ("%s%saddr=%s" ), + old_opts, *old_opts ?_ ("," ) :_ ("" ), s); *extra_opts =xstrdup (new_opts);/* Set default options.
@@ -322,7 +322,7 @@ int nfs4mount(const char *spec, const char *node, int flags, unshared = !val; else if (!sloppy) {printf (_ ("unknown nfs mount option: " -"%s%s\n" ), val ?"" :"no" , opt); +"%s%s\n" ), val ?_ ("" ) :_ ("no" ), opt); goto fail; } }
@@ -414,7 +414,7 @@ int nfs4mount(const char *spec, const char *node, int flags,if (!ip_addr_in_opts && client_addr.sin_family !=0 && client_addr.sin_addr.s_addr !=0 ) { -snprintf (ip_addr,sizeof (ip_addr),"%s" , +snprintf (ip_addr,sizeof (ip_addr),_ ("%s" ),inet_ntoa (client_addr.sin_addr)); data.client_addr.len =strlen (ip_addr); }
utils/mount/nfsmount.c +3 -4
@@ -192,7 +192,6 @@ parse_options(char *old_opts, struct nfs_mount_data *data,if ((opteq =strchr (opt,'=' )) &&isdigit (opteq[1 ])) {int val =atoi (opteq +1 ); *opteq ='\0' ; -/* printf("opt=%s\n", opt); */ if (!strcmp (opt,"rsize" )) data->rsize = val;else if (!strcmp (opt,"wsize" ))
@@ -249,7 +248,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data,continue ; else goto bad_parameter; -sprintf (cbuf,"%s=%s," , opt, opteq+1 ); +sprintf (cbuf,_ ("%s=%s," ), opt, opteq+1 ); }else if (opteq) { *opteq ='\0' ;if (!strcmp (opt,"proto" )) {
@@ -332,7 +331,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data,continue ; else goto bad_parameter; -sprintf (cbuf,"%s=%s," , opt, opteq+1 ); +sprintf (cbuf,_ ("%s=%s," ), opt, opteq+1 ); }else {int val =1 ;if (!strncmp (opt,"no" ,2 )) {
@@ -431,7 +430,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data, "%s%s\n"), val ? "" : "no", opt); goto out_bad; } -sprintf (cbuf, val ?"%s," :"no%s," , opt); +sprintf (cbuf, val ?_ ("%s," ) :_ ("no%s," ), opt); } len +=strlen (cbuf);if (len >= opt_size) {
utils/mount/nfsumount.c +9 -9
@@ -141,7 +141,7 @@ int del_mtab(const char *spec, const char *node)if (res >=0 ) {/* Umount succeeded */ if (verbose) -printf (_ ("%s umounted\n" ), spec ? spec : node); +printf (_ ("%s umounted\n" ), spec ? spec : node); } writemtab:
@@ -238,13 +238,13 @@ static struct option umount_longopts[] =void umount_usage () { -printf ("usage: %s dir [-fvnrlh]\n" , progname); -printf ("options:\n\t-f\t\tforce unmount\n" ); -printf ("\t-v\t\tverbose\n" ); -printf ("\t-n\t\tDo not update /etc/mtab\n" ); -printf ("\t-r\t\tremount\n" ); -printf ("\t-l\t\tlazy unmount\n" ); -printf ("\t-h\t\tprint this help\n\n" ); +printf (_ ("usage: %s dir [-fvnrlh]\n" ), progname); +printf (_ ("options:\n\t-f\t\tforce unmount\n" )); +printf (_ ("\t-v\tverbose\n" )); +printf (_ ("\t-n\tDo not update /etc/mtab\n" )); +printf (_ ("\t-r\tremount\n" )); +printf (_ ("\t-l\tlazy unmount\n" )); +printf (_ ("\t-h\tprint this help\n\n" )); }int nfsumount (int argc,char *argv[])
@@ -303,7 +303,7 @@ int nfsumount(int argc, char *argv[])if (mc &&strcmp (mc->m.mnt_type,"nfs" ) !=0 &&strcmp (mc->m.mnt_type,"nfs4" ) !=0 ) { -nfs_error (_ ("%s: %s on %s it not an nfs filesystem" ), +nfs_error (_ ("%s: %s on %s is not an nfs filesystem" ), progname, mc->m.mnt_fsname, mc->m.mnt_dir);return EX_USAGE ; }
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
utils/mount/error.c void mount_errors(char *server, int will_retry, int bg) · line 110
Quoted 9 lines · On Saturday July 28, [email protected] wrote:
NLS changes missed a spot or two.
utils/mount/error.c +1
-1@@ -105,7 +106,7 @@ void mount_errors(char *server, int will_retry, int bg)openlog ("mount" ,LOG_CONS |LOG_PID ,LOG_AUTH );syslog (LOG_ERR ,"%s." , errbuf); }else -fprintf (stderr,"%s.\n" , errbuf); +fprintf (stderr,_ ("%s.\n" ), errbuf); }
Do we really want NLS support for putting a full stop at the end of a line?
utils/mount/mount.c static void discover_nfs_mount_data_version(void) · line 182
Quoted 3 lines
utils/mount/mount.c +1
-1if (opts !=NULL ) -printf (" (%s)" , opts); +printf (_ (" (%s)" ), opts);
and putting something in parentheses
utils/mount/mount.c static void discover_nfs_mount_data_version(void) · line 184
Quoted 3 lines
utils/mount/mount.c +1
-1-printf ("\n" ); +printf (_ ("\n" ));
and for a single newline?
utils/mount/nfs4mount.c static int get_my_ipv4addr(char *ip_addr, int len) · line 163
Quoted 9 lines
index 26a6896..bd20864 100644
utils/mount/nfs4mount.c +1
-1@@ -160,7 +160,7 @@ static int get_my_ipv4addr(char *ip_addr, int len) }if (fill_ipv4_sockaddr (myname, &myaddr))return -1 ; -snprintf (ip_addr, len,"%s" ,inet_ntoa (myaddr.sin_addr)); +snprintf (ip_addr, len,_ ("%s" ),inet_ntoa (myaddr.sin_addr));
Why this change? Does it achieve anything?
Quoted 6 lines
utils/mount/nfs4mount.c +2
-2} -snprintf (new_opts,sizeof (new_opts),"%s%saddr=%s" , - old_opts, *old_opts ?"," :"" , s); +snprintf (new_opts,sizeof (new_opts),_ ("%s%saddr=%s" ), + old_opts, *old_opts ?_ ("," ) :_ ("" ), s);
*extra_opts=xstrdup(new_opts);
????
utils/mount/nfs4mount.c int nfs4mount(const char *spec, const char *node, int flags, · line 417
Quoted 2 lines
utils/mount/nfs4mount.c +1
-1- snprintf(ip_addr, sizeof(ip_addr), "%s", + snprintf(ip_addr, sizeof(ip_addr), _("%s"),
???
Maybe I'm mistaken, but I thought _(xxx) was just to allow localisations to provide different translations of xxx. When it is something like punctuation - particularly an end-of-line character - I don't think I see the point.
Also you seem to have added it when building up option lists, and I don't think it makes sense to translate those.
So please either show me the error of my thinking, or stick to adding _() to translatable strings.
Much of this patch is good and wanted, I'm not sure about the whole. Similarly for patch 2.
I only got 12 of the 23 patches??
NeilBrown
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 5 lines
So please either show me the error of my thinking, or stick to adding
_()to translatable strings.Much of this patch is good and wanted, I'm not sure about the whole. Similarly for patch 2.
Yeah, the options stuff was a mistake which I thought I had avoided. Will fix all this up and post a fresh patch set.
But my impression was a double-byte "." is not the same as a single-byte ".". I'm not an expert, and would be happy if someone (like a distributor) had an internationalization expert they could loan us.
Quoted 1 line
I only got 12 of the 23 patches??
The list didn't see half of these either. Will investigate. I probably shut down my laptop before it was done relaying the patches.
begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel
version:2.1
end:vcard
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 6 lines · On Sunday July 29, [email protected] wrote:
Quoted 5 lines
So please either show me the error of my thinking, or stick to adding
_()to translatable strings.Much of this patch is good and wanted, I'm not sure about the whole. Similarly for patch 2.
Quoted 6 lines
Yeah, the options stuff was a mistake which I thought I had avoided. Will fix all this up and post a fresh patch set.
But my impression was a double-byte "." is not the same as a single-byte ".". I'm not an expert, and would be happy if someone (like a distributor) had an internationalization expert they could loan us.
I think you are confusing two things (that are easily confused). With some loss of generality, I will call them unicode and utf, the Unicode Transport Format(??)
Unicode uses wide characters, 16bits each. 'wchar'. The unicode '.' is different from the ASCII '.' simply because they have different numbers of bits (though I think the low order bits are the same, and the high order bits in unicode are all zero).
Code which wants to process international character sets a character at a time needs handle the text as wchars, typically arrays of wchars. They are two bytes each.
However code that just wants to work with known strings and doesn't really care about the content can use UTF instead. UTF encodes a Unicode string using 1, 2 or 3 bytes for each character. All 7-bit ASCII symbols have their standard 1byte encoding. Other symbols are 2 or 3 bytes.
So if you just want to print a message, you can use an array of 'char' and store any international text in there. No need to explicitly use wchar.
If you want to use a string value that can be localised, you use
_("string")
and the NLS tools will allow that to be swapped for a localised version, possibly using UTF to represent unicode characters, at runtime.
So you only need _(xxx) for translatable strings. Things like " " (a space), "\n" definitely don't need translation. Things like ":" could conceivably benefit from translation, but I doubt that it really makes sense to translate them in isolation. Places where punctuation has a strong meaning like in dates, times, currency etc have separate functionality for doing localisation (strftime, strfmon) so for normal usage, I don't think it is appropriate to translate individual punctuation characters.
Does that make sense?
Quoted 5 lines
Quoted 2 lines
I only got 12 of the 23 patches??
The list didn't see half of these either. Will investigate. I probably shut down my laptop before it was done relaying the patches.
Grin...
I seem to have them now. Thanks.
NeilBrown
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs