zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <schizo@debian.org>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: math i18n
Date: Wed, 10 Nov 1999 12:11:35 -0500	[thread overview]
Message-ID: <19991110121135.A19502@dman.com> (raw)

% export LC_ALL=pl_PL

% typeset -F a; ((a=1.1))
zsh: bad floating point constant

% ((a=1,1)) ; echo $a
1,0000000000

% LANG=C; ((a=1.1)) ; echo $a
1.1000000000

You can't make a floating point assignment if your locale's
decimal point is a comma.

The problem here is that strtod is using the locale yet zsh is
ignoring it.

This patch fixes the problem basically by allowing locale
to switch the meanings of '.' and ','.  Because I'm an
ignorant American, I have no idea what this breaks.

--- Src/math.c	1999/11/10 08:23:22	1.1.1.18
+++ Src/math.c	1999/11/10 17:03:30
@@ -184,9 +184,20 @@
 static int
 zzlex(void)
 {
+    char decimal = '.', thousands = ',';
     int cct = 0;
+#ifdef USE_LOCALE
+    struct lconv *lc;
+#endif
 
     yyval.type = MN_INTEGER;
+
+#ifdef USE_LOCALE
+    lc = localeconv();
+    decimal = *(lc->decimal_point);
+    thousands = *(lc->thousands_sep);
+#endif
+
     for (;; cct = 0)
 	switch (*ptr++) {
 	case '+':
@@ -324,7 +335,9 @@
 	case ':':
 	    return COLON;
 	case ',':
-	    return COMMA;
+	case '.':
+	    if (*(ptr-1) == thousands) return COMMA;
+	    else break;
 	case '\0':
 	    ptr--;
 	    return EOI;
@@ -349,15 +362,15 @@
 	    }
 	/* Fall through! */
 	default:
-	    if (idigit(*--ptr) || *ptr == '.') {
+	    if (idigit(*--ptr) || *ptr == decimal) {
 		char *nptr;
 		for (nptr = ptr; idigit(*nptr); nptr++);
 
-		if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
+		if (*nptr == decimal || *nptr == 'e' || *nptr == 'E') {
 		    /* it's a float */
 		    yyval.type = MN_FLOAT;
 		    yyval.u.d = strtod(ptr, &nptr);
-		    if (ptr == nptr || *nptr == '.') {
+		    if (ptr == nptr || *nptr == decimal ) {
 			zerr("bad floating point constant", NULL, 0);
 			return EOI;
 		    }


             reply	other threads:[~1999-11-10 17:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-10 17:11 Clint Adams [this message]
1999-11-10 17:31 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19991110121135.A19502@dman.com \
    --to=schizo@debian.org \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).