Revision: 52650
http://brlcad.svn.sourceforge.net/brlcad/?rev=52650&view=rev
Author: brlcad
Date: 2012-10-02 03:28:54 +0000 (Tue, 02 Oct 2012)
Log Message:
-----------
don't assume fastf_t == double, scan appropriately
Modified Paths:
--------------
brlcad/trunk/src/libbn/tabdata.c
Modified: brlcad/trunk/src/libbn/tabdata.c
===================================================================
--- brlcad/trunk/src/libbn/tabdata.c 2012-10-02 02:56:25 UTC (rev 52649)
+++ brlcad/trunk/src/libbn/tabdata.c 2012-10-02 03:28:54 UTC (rev 52650)
@@ -931,12 +931,13 @@
bu_semaphore_acquire(BU_SEM_SYSCALL);
for (j=0; j <= tabp->nx; j++) {
- /* XXX assumes fastf_t == double */
- ret = fscanf(fp, "%lf", &tabp->x[j]);
+ double val;
+ ret = fscanf(fp, "%lf", &val);
if (ret != 1) {
bu_log("bn_table_read(%s) READ FAILURE. Abort\n", filename);
break;
}
+ tabp->x[j] = val;
}
fclose(fp);
bu_semaphore_release(BU_SEM_SYSCALL);
@@ -1077,12 +1078,21 @@
bu_semaphore_acquire(BU_SEM_SYSCALL);
fp = fopen(filename, "rb");
for (i=0; i < count; i++) {
+ double xval, yval;
+ int ret;
+
buf[0] = '\0';
if (bu_fgets(buf, sizeof(buf), fp) == NULL) {
bu_log("bn_read_table_and_tabdata(%s) unexpected EOF on line
%zu\n", filename, i);
break;
}
- sscanf(buf, "%lf %lf", &tabp->x[i], &data->y[i]);
+ ret = sscanf(buf, "%lf %lf", &xval, &yval);
+ if (ret != 2) {
+ bu_log("Malformatted table data encountered in %s\n", filename);
+ break;
+ }
+ xval = tabp->x[i];
+ yval = data->y[i];
}
fclose(fp);
bu_semaphore_release(BU_SEM_SYSCALL);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits