Revision: 75956
          http://sourceforge.net/p/brlcad/code/75956
Author:   starseeker
Date:     2020-05-28 00:36:01 +0000 (Thu, 28 May 2020)
Log Message:
-----------
Don't use -1 as a magic number, as there isn't anything preventing it being 
supplied in a range to whichid

Modified Paths:
--------------
    brlcad/trunk/src/libged/which.cpp

Modified: brlcad/trunk/src/libged/which.cpp
===================================================================
--- brlcad/trunk/src/libged/which.cpp   2020-05-28 00:11:41 UTC (rev 75955)
+++ brlcad/trunk/src/libged/which.cpp   2020-05-28 00:36:01 UTC (rev 75956)
@@ -225,21 +225,25 @@
        } else {
            // To reduce verbosity, assemble and print ranges of unused numbers 
rather
            // that just dumping all of them
-           int rstart = -1;
-           int rend = -1;
-           int rprev = -1;
+           bool have_rstart = false;
+           bool have_rend = false;
+           int rstart = -INT_MAX;
+           int rend = -INT_MAX;
+           int rprev = -INT_MAX;
            for (i_it = unused_ids.begin(); i_it != unused_ids.end(); i_it++) {
-               if (rstart == -1 || (*i_it != rprev+1)) {
+               if (!have_rstart || (*i_it != rprev+1)) {
                    // Print intermediate results, if we find a sequence within
                    // the overall results.
-                   if (rstart != -1) {
-                       if (rend != -1) {
+                   if (have_rstart) {
+                       if (have_rend) {
                            bu_vls_printf(gedp->ged_result_str, "   %d-%d\n", 
rstart, rend);
                        } else {
                            bu_vls_printf(gedp->ged_result_str, "   %d\n", 
rstart);
                        }
-                       rend = -1;
+                       have_rend = false;
+                       rend = -INT_MAX;
                    }
+                   have_rstart = true;
                    rstart = *i_it;
                    rprev = *i_it;
                    continue;
@@ -246,15 +250,15 @@
                }
                rprev = *i_it;
                rend = *i_it;
+               have_rend = true;
                continue;
            }
            // Print the last results
-           if (rend != -1) {
+           if (have_rend) {
                bu_vls_printf(gedp->ged_result_str, "   %d-%d\n", rstart, rend);
            } else {
                bu_vls_printf(gedp->ged_result_str, "   %d\n", rstart);
            }
-
        }
        bu_vls_free(&root);
        return GED_OK;

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