Revision: 42454
          http://brlcad.svn.sourceforge.net/brlcad/?rev=42454&view=rev
Author:   brlcad
Date:     2011-01-19 16:36:54 +0000 (Wed, 19 Jan 2011)

Log Message:
-----------
improve consistency on how the version numbers are checked.  avoiding <= and >= 
where unnecessary.

Modified Paths:
--------------
    brlcad/trunk/src/libged/importFg4Section.c
    brlcad/trunk/src/libged/typein.c
    brlcad/trunk/src/libged/wdb_importFg4Section.c
    brlcad/trunk/src/librt/db_io.c
    brlcad/trunk/src/librt/primitives/nmg/nmg_misc.c
    brlcad/trunk/src/librt/wdb.c
    brlcad/trunk/src/libwdb/bot.c
    brlcad/trunk/src/libwdb/mater.c
    brlcad/trunk/src/mged/mater.c
    brlcad/trunk/src/mged/mged.c

Modified: brlcad/trunk/src/libged/importFg4Section.c
===================================================================
--- brlcad/trunk/src/libged/importFg4Section.c  2011-01-19 16:32:26 UTC (rev 
42453)
+++ brlcad/trunk/src/libged/importFg4Section.c  2011-01-19 16:36:54 UTC (rev 
42454)
@@ -162,7 +162,7 @@
        botip->face_mode = (struct bu_bitv *)NULL;
     }
 
-    if ( (num_normals > 0) && (db_version(fp->dbip) >= 5 ) ) {
+    if ( (num_normals > 0) && (db_version(fp->dbip) > 4 ) ) {
        botip->num_normals = num_normals;
        botip->num_face_normals = botip->num_faces;
        botip->normals = (fastf_t *)bu_calloc( botip->num_normals * 3, sizeof( 
fastf_t ), "BOT normals" );

Modified: brlcad/trunk/src/libged/typein.c
===================================================================
--- brlcad/trunk/src/libged/typein.c    2011-01-19 16:32:26 UTC (rev 42453)
+++ brlcad/trunk/src/libged/typein.c    2011-01-19 16:36:54 UTC (rev 42454)
@@ -2819,7 +2819,7 @@
        bu_vls_printf(&gedp->ged_result_str, "%s: %s already exists", argv[0], 
argv[1]);
        return GED_ERROR;
     }
-    if (db_version(gedp->ged_wdbp->dbip) <= 4 && (int)strlen(argv[1]) > 
NAMESIZE) {
+    if (db_version(gedp->ged_wdbp->dbip) < 5 && (int)strlen(argv[1]) > 
NAMESIZE) {
        bu_vls_printf(&gedp->ged_result_str, "%s: ERROR, v4 names are limited 
to %d characters\n", argv[0], NAMESIZE);
        return GED_ERROR;
     }
@@ -2872,7 +2872,7 @@
        menu = p_vol;
        fn_in = vol_in;
     } else if (BU_STR_EQUAL(argv[2], "hf")) {
-       if (db_version(gedp->ged_wdbp->dbip) <= 4) {
+       if (db_version(gedp->ged_wdbp->dbip) < 5) {
            nvals = 19;
            menu = p_hf;
            fn_in = hf_in;
@@ -2886,7 +2886,7 @@
        bu_vls_printf(&gedp->ged_result_str, "%s: the polysolid is deprecated 
and not supported by this command.\nUse the bot primitive.\n", argv[0]);
        return GED_ERROR;
     } else if (BU_STR_EQUAL(argv[2], "dsp")) {
-       if (db_version(gedp->ged_wdbp->dbip) <= 4) {
+       if (db_version(gedp->ged_wdbp->dbip) < 5) {
            nvals = 6;
            menu = p_dsp_v4;
            fn_in = dsp_in_v4;
@@ -3025,7 +3025,7 @@
        menu = p_part;
        fn_in = part_in;
     } else if (BU_STR_EQUAL(argv[2], "binunif")) {
-       if (db_version(gedp->ged_wdbp->dbip) <= 4) {
+       if (db_version(gedp->ged_wdbp->dbip) < 5) {
            bu_vls_printf(&gedp->ged_result_str,
                          "%s: the binunif primitive is not supported by this 
command when using an old style database",
                          argv[0]);

Modified: brlcad/trunk/src/libged/wdb_importFg4Section.c
===================================================================
--- brlcad/trunk/src/libged/wdb_importFg4Section.c      2011-01-19 16:32:26 UTC 
(rev 42453)
+++ brlcad/trunk/src/libged/wdb_importFg4Section.c      2011-01-19 16:36:54 UTC 
(rev 42454)
@@ -150,7 +150,7 @@
        botip->face_mode = (struct bu_bitv *)NULL;
     }
 
-    if ((num_normals > 0) && (db_version(fp->dbip) >= 5)) {
+    if ((num_normals > 0) && (db_version(fp->dbip) > 4)) {
        botip->num_normals = num_normals;
        botip->num_face_normals = botip->num_faces;
        botip->normals = (fastf_t *)bu_calloc(botip->num_normals * 3, 
sizeof(fastf_t), "BOT normals");

Modified: brlcad/trunk/src/librt/db_io.c
===================================================================
--- brlcad/trunk/src/librt/db_io.c      2011-01-19 16:32:26 UTC (rev 42453)
+++ brlcad/trunk/src/librt/db_io.c      2011-01-19 16:36:54 UTC (rev 42454)
@@ -116,7 +116,7 @@
     RT_CK_DBI(dbip);
     RT_CK_DIR(dp);
 
-    if (db_version(dbip) >= 5) {
+    if (db_version(dbip) > 4) {
        /* can't get an mrec on a v5 */
        return (union record *)NULL;
     }
@@ -320,7 +320,7 @@
        return -1;              /* was dummy DB entry */
 
     BU_INIT_EXTERNAL(ep);
-    if (db_version(dbip) <= 4)
+    if (db_version(dbip) < 5)
        ep->ext_nbytes = dp->d_len * sizeof(union record);
     else
        ep->ext_nbytes = dp->d_len;
@@ -381,7 +381,7 @@
     if (db_version(dbip) == 5)
        return db_put_external5(ep, dp, dbip);
 
-    if (db_version(dbip) <= 4) {
+    if (db_version(dbip) < 5) {
        size_t ngran;
 
        ngran = (ep->ext_nbytes+sizeof(union record)-1)/sizeof(union record);

Modified: brlcad/trunk/src/librt/primitives/nmg/nmg_misc.c
===================================================================
--- brlcad/trunk/src/librt/primitives/nmg/nmg_misc.c    2011-01-19 16:32:26 UTC 
(rev 42453)
+++ brlcad/trunk/src/librt/primitives/nmg/nmg_misc.c    2011-01-19 16:36:54 UTC 
(rev 42454)
@@ -4623,7 +4623,7 @@
     intern.idb_meth = &rt_functab[ID_NMG];
     intern.idb_ptr = (genptr_t)m;
 
-    if (db_version(fp->dbip) <= 4) {
+    if (db_version(fp->dbip) < 5) {
        BU_INIT_EXTERNAL(&ext);
        ret = intern.idb_meth->ft_export4(&ext, &intern, 1.0, fp->dbip, 
&rt_uniresource);
        if (ret < 0) {

Modified: brlcad/trunk/src/librt/wdb.c
===================================================================
--- brlcad/trunk/src/librt/wdb.c        2011-01-19 16:32:26 UTC (rev 42453)
+++ brlcad/trunk/src/librt/wdb.c        2011-01-19 16:36:54 UTC (rev 42454)
@@ -157,14 +157,16 @@
     unsigned char type)
 {
     struct directory *dp;
+    int version;
 
     RT_CK_WDB(wdbp);
     BU_CK_EXTERNAL(ep);
 
     /* Stash name into external representation */
-    if (db_version(wdbp->dbip) <= 4) {
+    version = db_version(wdbp->dbip);
+    if (version < 5) {
        db_wrap_v4_external(ep, name);
-    } else if (db_version(wdbp->dbip) == 5) {
+    } else if (version == 5) {
        if (db_wrap_v5_external(ep, name) < 0) {
            bu_log("wdb_export_external(%s): db_wrap_v5_external error\n",
                   name);
@@ -172,7 +174,7 @@
        }
     } else {
        bu_log("wdb_export_external(%s): version %d unsupported\n",
-              name, db_version(wdbp->dbip));
+              name, version);
        return -4;
     }
 
@@ -286,7 +288,7 @@
     RT_CK_WDB(wdbp);
     RT_CK_DB_INTERNAL(ip);
 
-    if (db_version(wdbp->dbip) <= 4) {
+    if (db_version(wdbp->dbip) < 5) {
        BU_INIT_EXTERNAL(&ext);
 
        ret = -1;

Modified: brlcad/trunk/src/libwdb/bot.c
===================================================================
--- brlcad/trunk/src/libwdb/bot.c       2011-01-19 16:32:26 UTC (rev 42453)
+++ brlcad/trunk/src/libwdb/bot.c       2011-01-19 16:36:54 UTC (rev 42454)
@@ -97,7 +97,7 @@
        bot->face_mode = (struct bu_bitv *)NULL;
     }
 
-    if ((num_normals > 0) && (db_version(fp->dbip) >= 5)) {
+    if ((num_normals > 0) && (db_version(fp->dbip) > 4)) {
        bot->num_normals = num_normals;
        bot->num_face_normals = bot->num_faces;
        bot->normals = (fastf_t *)bu_calloc(bot->num_normals * 3, 
sizeof(fastf_t), "BOT normals");

Modified: brlcad/trunk/src/libwdb/mater.c
===================================================================
--- brlcad/trunk/src/libwdb/mater.c     2011-01-19 16:32:26 UTC (rev 42453)
+++ brlcad/trunk/src/libwdb/mater.c     2011-01-19 16:36:54 UTC (rev 42454)
@@ -46,7 +46,7 @@
 mk_write_color_table(struct rt_wdb *ofp)
 {
     RT_CK_WDB(ofp);
-    if (db_version(ofp->dbip) <= 4) {
+    if (db_version(ofp->dbip) < 5) {
        const struct mater *mp;
 
        BU_ASSERT_LONG(mk_version, ==, 4);

Modified: brlcad/trunk/src/mged/mater.c
===================================================================
--- brlcad/trunk/src/mged/mater.c       2011-01-19 16:32:26 UTC (rev 42453)
+++ brlcad/trunk/src/mged/mater.c       2011-01-19 16:36:54 UTC (rev 42454)
@@ -63,7 +63,7 @@
     if (dbip->dbi_read_only)
        return;
 
-    if (db_version(dbip) >= 5) {
+    if (db_version(dbip) > 4) {
        bu_log("color_putrec does not work on db5 or later databases");
        return;
     }

Modified: brlcad/trunk/src/mged/mged.c
===================================================================
--- brlcad/trunk/src/mged/mged.c        2011-01-19 16:32:26 UTC (rev 42453)
+++ brlcad/trunk/src/mged/mged.c        2011-01-19 16:36:54 UTC (rev 42454)
@@ -2852,7 +2852,7 @@
      * We have an old database version AND we're not in the process of
      * creating a new database.
      */
-    if (db_version(dbip) != 5 && !created_new_db) {
+    if (db_version(dbip) < 5 && !created_new_db) {
        if (db_upgrade) {
            if (db_warn)
                bu_vls_printf(&msg, "Warning:\n\tDatabase version is 
old.\n\tConverting to the new format.\n");


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

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to