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

gEDA-dev: Gerbv and strtod



Hallo,

trying to run gerbv on a big panel assembled with a recent CADSOFT EAGLE
(4.16) on Suse 10.2, gerbv 1.0.2 choked on the excellon files. Recent eagle
excellon files include the tool setup, like
%
M48
T01C0.0360
Digging deaper, I noticed that strtod in read_double returned NULL. In the
debugger strtod("0.0360",0) returned 0. Is there any known issue with
strtod? 

I changed drill.c:read_double() like
static double
read_double(gerb_file_t *fd, double scale_factor)
{
    int read;
    char temp[0x20];
    int i = 0;
    double result = 0;
    int decimal_point = FALSE;
    int decimal_digit = 0;

    memset(temp, 0, sizeof(temp));

    read = gerb_fgetc(fd);
    while(read != EOF && i < sizeof(temp) &&
      (isdigit(read) || read == '.' || read == '+' || read == '-')) {
#if 0
    if(read == ',' || read == '.') decimal_point = TRUE;
    temp[i++] = (char)read;
    read = gerb_fgetc(fd);
    }

    gerb_ungetc(fd);
    result = strtod(temp, NULL);
#else
	if(read == ',' || read == '.') decimal_point = TRUE;
	if (decimal_point)
	{
	    if (decimal_digit)
	       result += (read -0x30) *pow(10.0, -decimal_digit);
	           decimal_digit++;
		   }
		   else
		       result = result * 10 + (read -0x30);
		       read = gerb_fgetc(fd);
    }

    gerb_ungetc(fd);
#endif
    if(!decimal_point) result *= scale_factor;

    return result;
} /* read_double */
to assemble the number step by step and not by a strtod() call. Now things
work fine.

What's going on?

(b.t.w.: I will be away for a week now)

Cheers
-- 
Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------


_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev