Revision: 77188
          http://sourceforge.net/p/brlcad/code/77188
Author:   starseeker
Date:     2020-09-21 23:37:41 +0000 (Mon, 21 Sep 2020)
Log Message:
-----------
Checkpoint

Modified Paths:
--------------
    brlcad/trunk/src/libged/CMakeLists.txt
    brlcad/trunk/src/libged/exec_mapping.cpp
    brlcad/trunk/src/libged/ged_private.h
    brlcad/trunk/src/libged/ged_util.c
    brlcad/trunk/src/libged/tests/plugins.cpp

Modified: brlcad/trunk/src/libged/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libged/CMakeLists.txt      2020-09-21 13:15:01 UTC (rev 
77187)
+++ brlcad/trunk/src/libged/CMakeLists.txt      2020-09-21 23:37:41 UTC (rev 
77188)
@@ -325,6 +325,7 @@
 add_subdirectory(solid_report)
 add_subdirectory(solids_on_ray)
 add_subdirectory(sphgroup)
+add_subdirectory(stat)
 add_subdirectory(summary)
 add_subdirectory(sync)
 add_subdirectory(tables)

Modified: brlcad/trunk/src/libged/exec_mapping.cpp
===================================================================
--- brlcad/trunk/src/libged/exec_mapping.cpp    2020-09-21 13:15:01 UTC (rev 
77187)
+++ brlcad/trunk/src/libged/exec_mapping.cpp    2020-09-21 23:37:41 UTC (rev 
77188)
@@ -320,6 +320,7 @@
 GED_CMD(solids)
 GED_CMD(solids_on_ray)
 GED_CMD(sphgroup)
+GED_CMD(stat)
 GED_CMD(summary)
 GED_CMD(sv)
 GED_CMD(sync)

Modified: brlcad/trunk/src/libged/ged_private.h
===================================================================
--- brlcad/trunk/src/libged/ged_private.h       2020-09-21 13:15:01 UTC (rev 
77187)
+++ brlcad/trunk/src/libged/ged_private.h       2020-09-21 23:37:41 UTC (rev 
77188)
@@ -554,7 +554,23 @@
 GED_EXPORT extern struct directory ** _ged_getspace(struct db_i *dbip,
                                         size_t num_entries);
 
+
 /**
+ * Characterize a path specification (search command style).
+ *
+ * Return flags characterizing the path specifier, as defined below:
+ */
+#define GED_PATHSPEC_INVALID   1ULL << 1
+#define GED_PATHSPEC_SPECIFIC  1ULL << 2
+#define GED_PATHSPEC_LOCAL     1ULL << 3
+#define GED_PATHSPEC_FLAT      1ULL << 4
+
+GED_EXPORT extern unsigned long long
+_ged_characterize_path_spec(struct bu_vls *normalized,
+       struct ged *gedp, const char *pathspec
+       );
+
+/**
  * Routine for generic command help printing.
  */
 GED_EXPORT extern void _ged_cmd_help(struct ged *gedp, const char *usage, 
struct bu_opt_desc *d);

Modified: brlcad/trunk/src/libged/ged_util.c
===================================================================
--- brlcad/trunk/src/libged/ged_util.c  2020-09-21 13:15:01 UTC (rev 77187)
+++ brlcad/trunk/src/libged/ged_util.c  2020-09-21 23:37:41 UTC (rev 77188)
@@ -2036,8 +2036,100 @@
     return GED_OK;
 }
 
+#if 0
 
+// TODO - need to generalize the path specifier parsing per notes in TODO.  
This is a first
+// cut at recasting what search is using now, which doesn't implement the full 
resolving logic.
 
+int
+_ged_characterize_pathspec(struct bu_vls *normalized, struct ged *gedp, const 
char *pathspec)
+{
+    struct bu_vls np = BU_VLS_INIT_ZERO;
+    int flags = 0;
+
+    // Start with nothing - if we get a valid answer we'll print it
+    if (normalized) {
+       bu_vls_trunc(normalized, 0);
+    }
+
+    if (!pathspec)
+               return GED_PATHSPEC_INVALID;
+
+    if (BU_STR_EQUAL(pathspec, "/"))
+       return flags;
+
+    if (BU_STR_EQUAL(pathspec, ".")) {
+       flags |= GED_PATHSPEC_LOCAL;
+       return flags;
+    }
+
+    if (BU_STR_EQUAL(pathspec, "|")) {
+       flags |= GED_PATHSPEC_FLAT;
+       return flags;
+    }
+
+    bu_vls_sprintf(&np, "%s", pathspec);
+    if (bu_vls_cstr(&np)[0] == '|') {
+       flags |= GED_PATHSPEC_FLAT;
+       bu_vls_nibble(&np, 1);
+    }
+    if (BU_STR_EQUAL(bu_vls_cstr(&np), "/")) {
+       bu_vls_free(&np);
+       return flags;
+    }
+
+    if (BU_STR_EQUAL(bu_vls_cstr(&np), ".")) {
+       flags |= GED_PATHSPEC_LOCAL;
+       bu_vls_free(&np);
+       return flags;
+    }
+
+    if (bu_vls_cstr(&np)[0] != '/')
+       flags |= GED_PATHSPEC_LOCAL;
+
+    const char *bu_norm = bu_path_normalize(bu_vls_cstr(&np));
+
+    if (bu_norm && !BU_STR_EQUAL(bu_norm , "/")) {
+       struct bu_vls tmp = BU_VLS_INIT_ZERO;
+       char *tbasename = bu_path_basename(bu_vls_cstr(&np), NULL);
+       bu_vls_sprintf(&tmp, "%s", tbasename);
+       bu_free(tbasename, "free bu_path_basename string (caller's 
responsibility per bu/log.h)");
+       bu_vls_sprintf(&np, "%s", bu_vls_cstr(&tmp));
+       bu_vls_free(&tmp);
+    } else {
+       bu_vls_sprintf(&np, "%s", "/");
+    }
+
+    // If we've gotten this far, normalizing to nothing is considered invalid.
+    if (!bu_vls_strlen(&np)) {
+       bu_vls_free(&np);
+       return GED_PATHSPEC_INVALID;
+    }
+
+    // If we reduced to the root fullpath, we're done
+    if (BU_STR_EQUAL(bu_vls_cstr(&np), "/")) {
+       bu_vls_free(&np);
+       return flags;
+    }
+
+    /* We've handled the toplevel special cases.  If we got here, we have a 
specific
+     * path - now the only question is whether that path is valid */
+    flags |= GED_PATHSPEC_SPECIFIC;
+    struct directory *path_dp = db_lookup(gedp->ged_wdbp->dbip, 
bu_vls_cstr(&np), LOOKUP_QUIET);
+    if (path_dp == RT_DIR_NULL) {
+       flags = GED_PATHSPEC_INVALID;
+    } else {
+       if (normalized)
+           bu_vls_sprintf(normalized, "%s", bu_vls_cstr(&np));
+    }
+    bu_vls_free(&np);
+
+    return flags;
+}
+
+#endif
+
+
 /*
  * Local Variables:
  * mode: C

Modified: brlcad/trunk/src/libged/tests/plugins.cpp
===================================================================
--- brlcad/trunk/src/libged/tests/plugins.cpp   2020-09-21 13:15:01 UTC (rev 
77187)
+++ brlcad/trunk/src/libged/tests/plugins.cpp   2020-09-21 23:37:41 UTC (rev 
77188)
@@ -47,6 +47,8 @@
     const char * const *ged_cmds = NULL;
     size_t ged_cmd_cnt = ged_cmd_list(&ged_cmds);
 
+    bu_log("%s\n", ged_init_msgs());
+
     for (size_t i = 0; i < ged_cmd_cnt; i++) {
        bu_log("%s\n", ged_cmds[i]);
     }

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