[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: issue report - problem with command line argument parsing using tr_TR locale

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2004-02-18 15:18:13 CET

Ozgur Murat Homurlu wrote:
>
> $ LC_CTYPE=tr_TR svn log -r COMMITTED
> svn: Syntax error in revision argument 'COMMITTED'
[...]
> $ LC_CTYPE=tr_TR svn log -r COMMiTTED
> (works normally)
[...]
> There's a well known cause of problems related to tr_TR locale: lower
> case of the character 'I' is '' with tr_TR locale (not the
> English-usual 'i'). So if you use C library's "tolower" type function
> with tr_TR locale you shouldn't expect i.e. 'COMMITTED' converted to
> 'committed'. Correct programming style is setting the correct locale (
> for the word ) before using case conversions.

We had better fix this as best we can, perhaps by doing the case-insensitive comparison correctly, but...

I would use this as an example of how case-insensitivity leads to problems, and recommend again that, when possible, we allow only one version (e.g. the all-capitals version) of such keywords. The writers of the XML standard decided that it must be case-sensitive, unlike HTML, for this reason that non-English languages do not always have simple one-to-one mappings between upper and lower case.

It's probably too late now to disallow lower case for these keywords, so close to the first release, but perhaps we could get away with explicitly allowing the all-lower and all-upper-case variants, but not arbitrary mixed-case variants. The fewer variations the better.

Patch attached for your consideration.

I understand that this is probably not urgent enough to fix in 1.0.0 and that if we release 1.0.0 allowing mixed case then we shouldn't really retract that afterwards.

- Julian

Allow revision keywords to be upper case or lower case but not mixed case.
This restriction avoids problems in languages that do not have a simple
one-to-one mapping between upper and lower case letters, e.g. in the locale
tr_TR where the normal lower-case version of 'I' is not 'i'.

* subversion/libsvn_subr/opt.c (svn_opt_subcommand_help):
  Allow revision keywords to be upper case or lower case but not mixed case.

Index: subversion/libsvn_subr/opt.c
===================================================================
--- subversion/libsvn_subr/opt.c (revision 8659)
+++ subversion/libsvn_subr/opt.c (working copy)
@@ -248,7 +248,7 @@ svn_opt_subcommand_help (const char *sub
 /** Parsing "X:Y"-style arguments. **/
 
 /* If WORD matches one of the special revision descriptors,
- * case-insensitively, set *REVISION accordingly:
+ * either in upper case or lower case, set *REVISION accordingly:
  *
  * - For "head", set REVISION->kind to svn_opt_revision_head.
  *
@@ -263,19 +263,23 @@ svn_opt_subcommand_help (const char *sub
 static int
 revision_from_word (svn_opt_revision_t *revision, const char *word)
 {
- if (strcasecmp (word, "head") == 0)
+ if ((strcmp (word, "HEAD") == 0)
+ || (strcmp (word, "head") == 0))
     {
       revision->kind = svn_opt_revision_head;
     }
- else if (strcasecmp (word, "prev") == 0)
+ else if ((strcmp (word, "PREV") == 0)
+ || (strcmp (word, "prev") == 0))
     {
       revision->kind = svn_opt_revision_previous;
     }
- else if (strcasecmp (word, "base") == 0)
+ else if ((strcmp (word, "BASE") == 0)
+ || (strcmp (word, "base") == 0))
     {
       revision->kind = svn_opt_revision_base;
     }
- else if (strcasecmp (word, "committed") == 0)
+ else if ((strcmp (word, "COMMITTED") == 0)
+ || (strcmp (word, "committed") == 0))
     {
       revision->kind = svn_opt_revision_committed;
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Feb 18 15:14:32 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.