Revision: 65281
          http://sourceforge.net/p/brlcad/code/65281
Author:   starseeker
Date:     2015-06-12 15:18:34 +0000 (Fri, 12 Jun 2015)
Log Message:
-----------
improve the g-obj callback functions a bit - use bu_opt_fastf_t to do the 
string->fastf_t assignments.

Modified Paths:
--------------
    brlcad/trunk/src/conv/g-obj.c

Modified: brlcad/trunk/src/conv/g-obj.c
===================================================================
--- brlcad/trunk/src/conv/g-obj.c       2015-06-12 14:56:46 UTC (rev 65280)
+++ brlcad/trunk/src/conv/g-obj.c       2015-06-12 15:18:34 UTC (rev 65281)
@@ -89,40 +89,68 @@
 static int print_help = 0;
 
 static int
-parse_tol_abs(struct bu_vls *UNUSED(error_msg), int UNUSED(argc), const char 
**argv, void *UNUSED(set_var))
+parse_tol_abs(struct bu_vls *error_msg, int argc, const char **argv, void 
*UNUSED(set_var))
 {
-    ttol.abs = atof(argv[0]);
+    int ret;
+    if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc == 0) {
+       if (error_msg) bu_vls_printf(error_msg, "Error - no argument supplied 
to abosolute tolerance option\n");
+       return -1;
+    };
+
+    ret = bu_opt_fastf_t(error_msg, argc, argv, (void *)&(ttol.abs));
     ttol.rel = 0.0;
-    return 1;
+    return ret;
 }
 
 static int
-parse_tol_norm(struct bu_vls *UNUSED(error_msg), int UNUSED(argc), const char 
**argv, void *UNUSED(set_var))
+parse_tol_norm(struct bu_vls *error_msg, int argc, const char **argv, void 
*UNUSED(set_var))
 {
-    ttol.norm = atof(argv[0]);
+    int ret;
+    if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc == 0) {
+       if (error_msg) bu_vls_printf(error_msg, "Error - no argument supplied 
to normal tolerance option\n");
+       return -1;
+    };
+
+    ret = bu_opt_fastf_t(error_msg, argc, argv, (void *)&(ttol.norm));
     ttol.rel = 0.0;
-    return 1;
+    return ret;
 }
 
 static int
-parse_tol_dist(struct bu_vls *UNUSED(error_msg), int UNUSED(argc), const char 
**argv, void *UNUSED(set_var))
+parse_tol_dist(struct bu_vls *error_msg, int argc, const char **argv, void 
*UNUSED(set_var))
 {
-    tol.dist = atof(argv[0]);
+    int ret;
+    if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc == 0) {
+       if (error_msg) bu_vls_printf(error_msg, "Error - no argument supplied 
to distance tolerance option\n");
+       return -1;
+    };
+
+    ret = bu_opt_fastf_t(error_msg, argc, argv, (void *)&(tol.dist));
     tol.dist_sq = tol.dist * tol.dist;
     rt_pr_tol(&tol);
-    return 1;
+    return ret;
 }
 
 static int
-parse_debug_rt(struct bu_vls *UNUSED(error_msg), int UNUSED(argc), const char 
**argv, void *UNUSED(set_var))
+parse_debug_rt(struct bu_vls *error_msg, int argc, const char **argv, void 
*UNUSED(set_var))
 {
+    if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc == 0) {
+       if (error_msg) bu_vls_printf(error_msg, "Error - no argument supplied 
to debug rt option\n");
+       return -1;
+    };
+
     sscanf(argv[0], "%x", (unsigned int *)&RTG.debug);
     return 1;
 }
 
 static int
-parse_debug_nmg(struct bu_vls *UNUSED(error_msg), int UNUSED(argc), const char 
**argv, void *UNUSED(set_var))
+parse_debug_nmg(struct bu_vls *error_msg, int argc, const char **argv, void 
*UNUSED(set_var))
 {
+    if (!argv || !argv[0] || strlen(argv[0]) == 0 || argc == 0) {
+       if (error_msg) bu_vls_printf(error_msg, "Error - no argument supplied 
to debug nmg option\n");
+       return -1;
+    };
+
     sscanf(argv[0], "%x", (unsigned int *)&RTG.NMG_debug);
     NMG_debug = RTG.NMG_debug;
     return 1;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to