From: Clint Adams <schizo@debian.org>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: math and locale
Date: Sat, 20 Nov 1999 15:18:07 -0500 [thread overview]
Message-ID: <19991120151807.A22546@dman.com> (raw)
This alleviates the decimal point problem by making it
locale-independent. This reverses the previous fix
which introduced new problems.
--- Src/math.c 1999/11/10 19:13:33 1.1.1.19
+++ Src/math.c 1999/11/20 20:07:47
@@ -184,20 +184,12 @@
static int
zzlex(void)
{
- char decimal = '.', thousands = ',';
- int cct = 0;
#ifdef USE_LOCALE
- struct lconv *lc;
+ char *prev_locale;
#endif
-
+ int cct = 0;
yyval.type = MN_INTEGER;
-#ifdef USE_LOCALE
- lc = localeconv();
- decimal = *(lc->decimal_point);
- thousands = *(lc->thousands_sep);
-#endif
-
for (;; cct = 0)
switch (*ptr++) {
case '+':
@@ -335,9 +327,7 @@
case ':':
return COLON;
case ',':
- case '.':
- if (*(ptr-1) == thousands) return COMMA;
- else break;
+ return COMMA;
case '\0':
ptr--;
return EOI;
@@ -362,15 +352,22 @@
}
/* Fall through! */
default:
- if (idigit(*--ptr) || *ptr == decimal) {
+ if (idigit(*--ptr) || *ptr == '.') {
char *nptr;
for (nptr = ptr; idigit(*nptr); nptr++);
- if (*nptr == decimal || *nptr == 'e' || *nptr == 'E') {
+ if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
/* it's a float */
yyval.type = MN_FLOAT;
+#ifdef USE_LOCALE
+ prev_locale = setlocale(LC_NUMERIC, NULL);
+ setlocale(LC_NUMERIC, "POSIX");
+#endif
yyval.u.d = strtod(ptr, &nptr);
- if (ptr == nptr || *nptr == decimal ) {
+#ifdef USE_LOCALE
+ setlocale(LC_NUMERIC, prev_locale);
+#endif
+ if (ptr == nptr || *nptr == '.' ) {
zerr("bad floating point constant", NULL, 0);
return EOI;
}
next reply other threads:[~1999-11-20 20:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-11-20 20:18 Clint Adams [this message]
1999-11-20 20:53 ` Bart Schaefer
1999-11-21 18:14 ` Clint Adams
1999-11-22 8:17 ` Bart Schaefer
1999-11-22 14:42 ` Clint Adams
1999-11-22 18:23 ` Bart Schaefer
1999-11-22 19:36 ` Clint Adams
1999-11-22 20:03 ` Zefram
1999-11-23 18:18 ` Bart Schaefer
1999-11-26 22:08 ` Peter Stephenson
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=19991120151807.A22546@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).