Revision: 75891
          http://sourceforge.net/p/brlcad/code/75891
Author:   starseeker
Date:     2020-05-23 13:35:38 +0000 (Sat, 23 May 2020)
Log Message:
-----------
Merge changes from trunk through r75890

Modified Paths:
--------------
    brlcad/branches/bioh/src/libbu/whereami.c
    brlcad/branches/bioh/src/libdm/CMakeLists.txt

Property Changed:
----------------
    brlcad/branches/bioh/
    brlcad/branches/bioh/src/libbu/

Index: brlcad/branches/bioh
===================================================================
--- brlcad/branches/bioh        2020-05-22 20:28:05 UTC (rev 75890)
+++ brlcad/branches/bioh        2020-05-23 13:35:38 UTC (rev 75891)

Property changes on: brlcad/branches/bioh
___________________________________________________________________
Modified: svn:mergeinfo
## -7,4 +7,4 ##
 /brlcad/branches/osg:62110-62113
 /brlcad/branches/prep-cache:68236-68933
 /brlcad/branches/tcltk86:68300-75257
-/brlcad/trunk:75720-75878
\ No newline at end of property
+/brlcad/trunk:75720-75890
\ No newline at end of property
Index: brlcad/branches/bioh/src/libbu
===================================================================
--- brlcad/branches/bioh/src/libbu      2020-05-22 20:28:05 UTC (rev 75890)
+++ brlcad/branches/bioh/src/libbu      2020-05-23 13:35:38 UTC (rev 75891)

Property changes on: brlcad/branches/bioh/src/libbu
___________________________________________________________________
Modified: svn:mergeinfo
## -1,4 +1,4 ##
 
/brlcad/branches/RELEASE/src/libbu:70323-70333,71915-71935,72826-72858,74376-74454
 
/brlcad/branches/brep-debug/src/libbu:69168,69927,69995-69996,70148-70149,70347-70349,70377,70526-70527,71006-71007,71009-71022,71046-71047,71049,71096-71100
 /brlcad/branches/tcltk86/src/libbu:68300-75257
-/brlcad/trunk/src/libbu:75720-75834
\ No newline at end of property
+/brlcad/trunk/src/libbu:75720-75834,75879-75890
\ No newline at end of property
Modified: brlcad/branches/bioh/src/libbu/whereami.c
===================================================================
--- brlcad/branches/bioh/src/libbu/whereami.c   2020-05-22 20:28:05 UTC (rev 
75890)
+++ brlcad/branches/bioh/src/libbu/whereami.c   2020-05-23 13:35:38 UTC (rev 
75891)
@@ -89,6 +89,54 @@
 #error unsupported compiler
 #endif
 
+/* LIBBU fallback implementation */
+static
+int _bu_getExecutablePath(char* out, int capacity, int* dirname_length)
+{
+    const char *pname = _bu_progname_raw();
+    struct bu_vls epath = BU_VLS_INIT_ZERO;
+
+    if (pname[0] == '.') {
+        char iwd[MAXPATHLEN];
+        char fullpath[MAXPATHLEN];
+        bu_getiwd(iwd, MAXPATHLEN);
+       // Use a VLS for this, since in principle there's nothing stopping the
+       // iwd and the bu_progname each individually from running right up to
+       // MAXPATHLEN, and if they do a MAXPATHLEN buffer won't hold both of
+       // them for realpath to try and digest down into something sane.
+        bu_vls_sprintf(&epath, "%s%c%s", iwd, BU_DIR_SEPARATOR, pname);
+        if (!bu_file_realpath(bu_vls_cstr(&epath), fullpath)) {
+            /* Unable to resolve initial path concatentation */
+           bu_vls_free(&epath);
+           return -1;
+        }
+       bu_vls_sprintf(&epath, "%s", fullpath);
+    } else {
+       bu_vls_sprintf(&epath, "%s", pname);
+    }
+
+    int length = bu_vls_strlen(&epath);
+    if (length <= capacity) {
+
+       memcpy(out, bu_vls_cstr(&epath), length);
+
+       if (dirname_length) {
+           int i;
+           for (i = length - 1; i >= 0; --i) {
+               if (out[i] == '/') {
+                   *dirname_length = i;
+                   break;
+               }
+           }
+       }
+    }
+
+    bu_vls_free(&epath);
+
+    return length;
+}
+
+
 #if defined(_WIN32)
 
 #define WIN32_LEAN_AND_MEAN
@@ -260,6 +308,10 @@
     break;
   }
 
+  if (length <= 0) {
+    return _bu_getExecutablePath(out, capacity, dirname_length);
+  }
+
   return length;
 }
 
@@ -452,6 +504,10 @@
   if (path != buffer1)
     WAI_FREE(path);
 
+  if (length <= 0) {
+    return _bu_getExecutablePath(out, capacity, dirname_length);
+  }
+
   return length;
 }
 
@@ -558,6 +614,10 @@
 
   fclose(self_exe);
 
+  if (length <= 0) {
+    return _bu_getExecutablePath(out, capacity, dirname_length);
+  }
+
   return length;
 }
 
@@ -666,6 +726,10 @@
   if (path != buffer1)
     WAI_FREE(path);
 
+  if (length <= 0) {
+    return _bu_getExecutablePath(out, capacity, dirname_length);
+  }
+
   return length;
 }
 
@@ -719,47 +783,7 @@
 WAI_FUNCSPEC
 int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
 {
-    const char *pname = _bu_progname_raw();
-    struct bu_vls epath = BU_VLS_INIT_ZERO;
-
-    if (pname[0] == '.') {
-        char iwd[MAXPATHLEN];
-        char fullpath[MAXPATHLEN];
-        bu_getiwd(iwd, MAXPATHLEN);
-       // Use a VLS for this, since in principle there's nothing stopping the
-       // iwd and the bu_progname each individually from running right up to
-       // MAXPATHLEN, and if they do a MAXPATHLEN buffer won't hold both of
-       // them for realpath to try and digest down into something sane.
-        bu_vls_sprintf(&epath, "%s%c%s", iwd, BU_DIR_SEPARATOR, pname);
-        if (!bu_file_realpath(bu_vls_cstr(&epath), fullpath)) {
-            /* Unable to resolve initial path concatentation */
-           bu_vls_free(&epath);
-           return -1;
-        }
-       bu_vls_sprintf(&epath, "%s", fullpath);
-    } else {
-       bu_vls_sprintf(&epath, "%s", pname);
-    }
-
-    int length = bu_vls_strlen(&epath);
-    if (length <= capacity) {
-
-       memcpy(out, bu_vls_cstr(&epath), length);
-
-       if (dirname_length) {
-           int i;
-           for (i = length - 1; i >= 0; --i) {
-               if (out[i] == '/') {
-                   *dirname_length = i;
-                   break;
-               }
-           }
-       }
-    }
-
-    bu_vls_free(&epath);
-
-    return length;
+    return _bu_getExecutablePath(out, capacity, dirname_length);
 }
 
 WAI_NOINLINE WAI_FUNCSPEC

Modified: brlcad/branches/bioh/src/libdm/CMakeLists.txt
===================================================================
--- brlcad/branches/bioh/src/libdm/CMakeLists.txt       2020-05-22 20:28:05 UTC 
(rev 75890)
+++ brlcad/branches/bioh/src/libdm/CMakeLists.txt       2020-05-23 13:35:38 UTC 
(rev 75891)
@@ -49,12 +49,12 @@
   set_property(SOURCE dm-ogl.c APPEND PROPERTY COMPILE_DEFINITIONS 
FB_USE_INTERNAL_API)
 endif(BRLCAD_ENABLE_X11 AND BRLCAD_ENABLE_OPENGL AND BRLCAD_ENABLE_TK)
 
-if(BRLCAD_ENABLE_TK AND NOT WIN32)
+if(BRLCAD_ENABLE_TK AND BRLCAD_ENABLE_DM_TK)
   list(APPEND libdm_DEFINES DM_TK IF_TK)
   set(DM_TKLIB ${TCL_LIBRARY} ${TK_LIBRARY})
   set(dmtk_srcs dm-tk.c)
   set_property(SOURCE dm-tk.c APPEND PROPERTY COMPILE_DEFINITIONS 
FB_USE_INTERNAL_API)
-endif(BRLCAD_ENABLE_TK AND NOT WIN32)
+endif(BRLCAD_ENABLE_TK AND BRLCAD_ENABLE_DM_TK)
 
 if(BRLCAD_ENABLE_QT)
   CHECK_CXX_FLAG(Wno-float-equal)

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