comparison src/lread.c @ 2010:a9cdbfb4716e

[xemacs-hg @ 2004-04-13 15:38:30 by james] Handle leading + signs on numbers correctly.
author james
date Tue, 13 Apr 2004 15:38:42 +0000
parents 4e6a63799f08
children f2fdfc131770
comparison
equal deleted inserted replaced
2009:1388c8b3e663 2010:a9cdbfb4716e
1849 } 1849 }
1850 } 1850 }
1851 #ifdef HAVE_RATIO 1851 #ifdef HAVE_RATIO
1852 if (isratio_string (read_ptr)) 1852 if (isratio_string (read_ptr))
1853 { 1853 {
1854 /* GMP ratio_set_string returns random values with initial + sign */
1855 if (*read_ptr == '+')
1856 read_ptr++;
1854 ratio_set_string (scratch_ratio, read_ptr, 0); 1857 ratio_set_string (scratch_ratio, read_ptr, 0);
1855 ratio_canonicalize (scratch_ratio); 1858 ratio_canonicalize (scratch_ratio);
1856 return Fcanonicalize_number (make_ratio_rt (scratch_ratio)); 1859 return Fcanonicalize_number (make_ratio_rt (scratch_ratio));
1857 } 1860 }
1858 #endif 1861 #endif
2671 2674
2672 #ifdef HAVE_RATIO 2675 #ifdef HAVE_RATIO
2673 int 2676 int
2674 isratio_string (const char *cp) 2677 isratio_string (const char *cp)
2675 { 2678 {
2676 /* Possible minus sign */ 2679 /* Possible minus/plus sign */
2677 if (*cp == '-') 2680 if (*cp == '-' || *cp == '+')
2678 cp++; 2681 cp++;
2679 2682
2680 /* Numerator */ 2683 /* Numerator */
2681 if (*cp < '0' || *cp > '9') 2684 if (*cp < '0' || *cp > '9')
2682 return 0; 2685 return 0;