emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/src ChangeLog data.c lisp.h lread.c


From: Juanma Barranquero
Subject: [Emacs-diffs] emacs/src ChangeLog data.c lisp.h lread.c
Date: Fri, 04 Dec 2009 16:16:29 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Juanma Barranquero <lektu>      09/12/04 16:16:29

Modified files:
        src            : ChangeLog data.c lisp.h lread.c 

Log message:
        Fix `string-to-number' to deal consistently with integers and floats.
        * lread.c (isfloat_string): New argument ignore_trailing to accept all
          trailing characters, not just whitespace.
          (read1): Pass new arg 0 to keep old behavior.
        * data.c (Fstring_to_number): Pass 1 to isfloat_string to ignore
          trailing chars, as it is already done for integers.  Doc fixes.
        * lisp.h (isfloat_string): Add new arg to declaration of isfloat_string.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/ChangeLog?cvsroot=emacs&r1=1.7908&r2=1.7909
http://cvs.savannah.gnu.org/viewcvs/emacs/src/data.c?cvsroot=emacs&r1=1.307&r2=1.308
http://cvs.savannah.gnu.org/viewcvs/emacs/src/lisp.h?cvsroot=emacs&r1=1.677&r2=1.678
http://cvs.savannah.gnu.org/viewcvs/emacs/src/lread.c?cvsroot=emacs&r1=1.421&r2=1.422

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/src/ChangeLog,v
retrieving revision 1.7908
retrieving revision 1.7909
diff -u -b -r1.7908 -r1.7909
--- ChangeLog   4 Dec 2009 10:51:37 -0000       1.7908
+++ ChangeLog   4 Dec 2009 16:16:26 -0000       1.7909
@@ -1,3 +1,13 @@
+2009-12-04  Juanma Barranquero  <address@hidden>
+
+       Fix `string-to-number' to deal consistently with integers and floats.
+       * lread.c (isfloat_string): New argument ignore_trailing to accept all
+       trailing characters, not just whitespace.
+       (read1): Pass new arg 0 to keep old behavior.
+       * data.c (Fstring_to_number): Pass 1 to isfloat_string to ignore
+       trailing chars, as it is already done for integers.  Doc fixes.
+       * lisp.h (isfloat_string): Add new arg to declaration of isfloat_string.
+
 2009-12-04  Eli Zaretskii  <address@hidden>
 
        * dispextern.h (enum prop_idx) <AUTO_COMPOSED_PROP_IDX>: Delete

Index: data.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/data.c,v
retrieving revision 1.307
retrieving revision 1.308
diff -u -b -r1.307 -r1.308
--- data.c      21 Nov 2009 11:52:27 -0000      1.307
+++ data.c      4 Dec 2009 16:16:28 -0000       1.308
@@ -2353,11 +2353,11 @@
 DEFUN ("string-to-number", Fstring_to_number, Sstring_to_number, 1, 2, 0,
        doc: /* Parse STRING as a decimal number and return the number.
 This parses both integers and floating point numbers.
-It ignores leading spaces and tabs.
+It ignores leading spaces and tabs, and all trailing chars.
 
 If BASE, interpret STRING as a number in that base.  If BASE isn't
 present, base 10 is used.  BASE must be between 2 and 16 (inclusive).
-If the base used is not 10, floating point is not recognized.  */)
+If the base used is not 10, STRING is always parsed as integer.  */)
      (string, base)
      register Lisp_Object string, base;
 {
@@ -2392,7 +2392,7 @@
   else if (*p == '+')
     p++;
 
-  if (isfloat_string (p) && b == 10)
+  if (isfloat_string (p, 1) && b == 10)
     val = make_float (sign * atof (p));
   else
     {

Index: lisp.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lisp.h,v
retrieving revision 1.677
retrieving revision 1.678
diff -u -b -r1.677 -r1.678
--- lisp.h      17 Nov 2009 21:57:49 -0000      1.677
+++ lisp.h      4 Dec 2009 16:16:28 -0000       1.678
@@ -2795,7 +2795,7 @@
 extern Lisp_Object Vload_history, Vload_suffixes, Vload_file_rep_suffixes;
 extern int openp P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
                      Lisp_Object *, Lisp_Object));
-extern int isfloat_string P_ ((char *));
+extern int isfloat_string P_ ((char *, int));
 extern void map_obarray P_ ((Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
                             Lisp_Object));
 extern void dir_warning P_ ((char *, Lisp_Object));

Index: lread.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lread.c,v
retrieving revision 1.421
retrieving revision 1.422
diff -u -b -r1.421 -r1.422
--- lread.c     21 Nov 2009 11:52:28 -0000      1.421
+++ lread.c     4 Dec 2009 16:16:28 -0000       1.422
@@ -3026,7 +3026,7 @@
                    }
                  }
              }
-           if (isfloat_string (read_buffer))
+           if (isfloat_string (read_buffer, 0))
              {
                /* Compute NaN and infinities using 0.0 in a variable,
                   to cope with compilers that think they are smarter
@@ -3244,8 +3244,9 @@
 #define EXP_INT 16
 
 int
-isfloat_string (cp)
+isfloat_string (cp, ignore_trailing)
      register char *cp;
+     int ignore_trailing;
 {
   register int state;
 
@@ -3299,7 +3300,8 @@
       cp += 3;
     }
 
-  return (((*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || 
(*cp == '\r') || (*cp == '\f'))
+  return ((ignore_trailing
+           || (*cp == 0) || (*cp == ' ') || (*cp == '\t') || (*cp == '\n') || 
(*cp == '\r') || (*cp == '\f'))
          && (state == (LEAD_INT|DOT_CHAR|TRAIL_INT)
              || state == (DOT_CHAR|TRAIL_INT)
              || state == (LEAD_INT|E_CHAR|EXP_INT)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]