sscanf was not the problem...It's actually something bizzare in that causes
sprintf with more than 2 %f to cause a bus error.
Solaris 2.8, gcc 2.95_3
So can anyone tell me why this would cause a bus error:
sprintf(out, "%f,%f,%f,%f", north, west, south, east);
Ns_ConnPuts(conn, out);
but,
sprintf(out, "%f,%f,", north, west);
Ns_ConnPuts(conn, out);
sprintf(out, "%f,%f", south, east);
Ns_ConnPuts(conn, out);
would not?
code involving the 4 floats, then example dump from
webserver log below:
***********************************************************************
float north, south, west, east;
int lat, lon, wd, ht;
...
sscanf(Ns_SetGet(row, "west_bounding_coor"), "%f", &west);
sscanf(Ns_SetGet(row, "east_bounding_coor"), "%f", &east);
sscanf(Ns_SetGet(row, "north_bounding_coo"), "%f", &north);
sscanf(Ns_SetGet(row, "south_bounding_coo"), "%f", &south);
...
wd = (int) (east - west);
ht = (int) (north - south);
lon = (int)(east+west)/2;
lat = (int)(north+south)/2;
if ((west == east) && (north == south)) {
... sprintf(out, "%f,%f,%f,%f", north, west, south, east);
Ns_ConnPuts(conn, out);
}
*********************************************************************
Dumps from webserver log calls:
[24/Jan/2002:14:29:27][18401.10][-conn2-] Notice: west -124.900002
[24/Jan/2002:14:29:27][18401.10][-conn2-] Notice: east -113.610001
[24/Jan/2002:14:29:27][18401.10][-conn2-] Notice: north 42.509998
[24/Jan/2002:14:29:27][18401.10][-conn2-] Notice: south 32.020000
[24/Jan/2002:14:29:27][18401.10][-conn2-] Notice: scanf|w -124.900002|
e -113.610001
[24/Jan/2002:14:29:27][18401.10][-conn2-] Notice: scanf|n 42.509998| s
32.020000
[24/Jan/2002:14:29:27][18401.10][-conn2-] Notice: width calc|wd 60| ht 30
[24/Jan/2002:14:29:27][18401.10][-conn2-] Notice: lat long|lat 37| long -119
Bus error