Revision: 75731
http://sourceforge.net/p/brlcad/code/75731
Author: starseeker
Date: 2020-05-07 18:30:48 +0000 (Thu, 07 May 2020)
Log Message:
-----------
Testing...
Modified Paths:
--------------
brlcad/branches/bioh/include/bu/app.h
brlcad/branches/bioh/src/libbu/progname.c
brlcad/branches/bioh/src/libbu/tests/app.c
brlcad/branches/bioh/src/libbu/tests/dylib/run.c
brlcad/branches/bioh/src/libbu/whereami.c
Property Changed:
----------------
brlcad/branches/bioh/
brlcad/branches/bioh/include/
brlcad/branches/bioh/src/libbu/
brlcad/branches/bioh/src/other/
brlcad/branches/bioh/src/other/libregex/
Index: brlcad/branches/bioh
===================================================================
--- brlcad/branches/bioh 2020-05-07 17:47:34 UTC (rev 75730)
+++ brlcad/branches/bioh 2020-05-07 18:30:48 UTC (rev 75731)
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-75727
\ No newline at end of property
+/brlcad/trunk:75720-75729
\ No newline at end of property
Index: brlcad/branches/bioh/include
===================================================================
--- brlcad/branches/bioh/include 2020-05-07 17:47:34 UTC (rev 75730)
+++ brlcad/branches/bioh/include 2020-05-07 18:30:48 UTC (rev 75731)
Property changes on: brlcad/branches/bioh/include
___________________________________________________________________
Modified: svn:mergeinfo
## -6,4 +6,5 ##
/brlcad/branches/opencl/include:65867-66137
/brlcad/branches/osg/include:62110-62113
/brlcad/branches/prep-cache/include:68236-68933
-/brlcad/branches/tcltk86/include:68300-75257
\ No newline at end of property
+/brlcad/branches/tcltk86/include:68300-75257
+/brlcad/trunk/include:75728-75729
\ No newline at end of property
Modified: brlcad/branches/bioh/include/bu/app.h
===================================================================
--- brlcad/branches/bioh/include/bu/app.h 2020-05-07 17:47:34 UTC (rev
75730)
+++ brlcad/branches/bioh/include/bu/app.h 2020-05-07 18:30:48 UTC (rev
75731)
@@ -83,6 +83,9 @@
*/
BU_EXPORT extern const char *bu_getprogname(void);
+/* Expose this temporarily for testing - NOT public API!!! */
+BU_EXPORT extern const char *_bu_progname_raw(void);
+
/**
* Set the name of the running application. This isn't strictly
* necessary on platforms that have an intrinsic method for tracking
Index: brlcad/branches/bioh/src/libbu
===================================================================
--- brlcad/branches/bioh/src/libbu 2020-05-07 17:47:34 UTC (rev 75730)
+++ brlcad/branches/bioh/src/libbu 2020-05-07 18:30:48 UTC (rev 75731)
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-75727
\ No newline at end of property
+/brlcad/trunk/src/libbu:75720-75729
\ No newline at end of property
Modified: brlcad/branches/bioh/src/libbu/progname.c
===================================================================
--- brlcad/branches/bioh/src/libbu/progname.c 2020-05-07 17:47:34 UTC (rev
75730)
+++ brlcad/branches/bioh/src/libbu/progname.c 2020-05-07 18:30:48 UTC (rev
75731)
@@ -65,6 +65,11 @@
static char bu_progname[MAXPATHLEN] = {0};
const char *DEFAULT_PROGNAME = "(" PACKAGE_NAME ")";
+const char *
+_bu_progname_raw()
+{
+ return (const char *)bu_progname;
+}
const char *
bu_argv0_full_path(void)
Modified: brlcad/branches/bioh/src/libbu/tests/app.c
===================================================================
--- brlcad/branches/bioh/src/libbu/tests/app.c 2020-05-07 17:47:34 UTC (rev
75730)
+++ brlcad/branches/bioh/src/libbu/tests/app.c 2020-05-07 18:30:48 UTC (rev
75731)
@@ -33,7 +33,7 @@
bu_setprogname(av[0]);
- const char *pname = bu_argv0_full_path();
+ const char *pname = _bu_progname_raw();
if (pname[0] == '.') {
char iwd[MAXPATHLEN];
Modified: brlcad/branches/bioh/src/libbu/tests/dylib/run.c
===================================================================
--- brlcad/branches/bioh/src/libbu/tests/dylib/run.c 2020-05-07 17:47:34 UTC
(rev 75730)
+++ brlcad/branches/bioh/src/libbu/tests/dylib/run.c 2020-05-07 18:30:48 UTC
(rev 75731)
@@ -16,10 +16,13 @@
#include "bu.h"
#include "dylib.h"
-int main() {
+int main(int UNUSED(ac), const char *av[]) {
int expected_plugins = 2;
struct bu_ptbl plugins = BU_PTBL_INIT_ZERO;
struct bu_ptbl handles = BU_PTBL_INIT_ZERO;
+
+ bu_setprogname(av[0]);
+
int pcnt = dylib_load_plugins(&plugins, &handles);
if (pcnt != expected_plugins) {
bu_log("Expected %d plugins, found %d.\n", expected_plugins, pcnt);
Modified: brlcad/branches/bioh/src/libbu/whereami.c
===================================================================
--- brlcad/branches/bioh/src/libbu/whereami.c 2020-05-07 17:47:34 UTC (rev
75730)
+++ brlcad/branches/bioh/src/libbu/whereami.c 2020-05-07 18:30:48 UTC (rev
75731)
@@ -21,7 +21,12 @@
#include "common.h"
+#include <string.h>
+
+#include "bu/app.h"
#include "bu/log.h"
+#include "bu/str.h"
+#include "bu/vls.h"
#include "bu/malloc.h"
#define WAI_MALLOC(size) bu_malloc(size, "WAI_MALLOC")
@@ -707,12 +712,51 @@
#else
-/* On OpenBSD, it apparently isn't possible to get this at all?
https://stackoverflow.com/a/38255753 */
-
+/* LIBBU fallback implementation */
WAI_FUNCSPEC
-int WAI_PREFIX(getExecutablePath)(char* UNUSED(out), int UNUSED(capacity),
int* UNUSED(dirname_length))
+int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
{
- return -1;
+ 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, pname);
+ }
+
+ int length = bu_vls_strlen(&epath);
+ if (length <= capacity) {
+
+ memcpy(out, 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;
}
WAI_NOINLINE WAI_FUNCSPEC
@@ -726,3 +770,13 @@
#ifdef __cplusplus
}
#endif
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Index: brlcad/branches/bioh/src/other
===================================================================
--- brlcad/branches/bioh/src/other 2020-05-07 17:47:34 UTC (rev 75730)
+++ brlcad/branches/bioh/src/other 2020-05-07 18:30:48 UTC (rev 75731)
Property changes on: brlcad/branches/bioh/src/other
___________________________________________________________________
Modified: svn:mergeinfo
## -7,4 +7,4 ##
/brlcad/branches/osg/src/other:62110-62113
/brlcad/branches/prep-cache/src/other:68236-68933
/brlcad/branches/tcltk86/src/other:68300-75257
-/brlcad/trunk/src/other:75720-75727
\ No newline at end of property
+/brlcad/trunk/src/other:75720-75729
\ No newline at end of property
Index: brlcad/branches/bioh/src/other/libregex
===================================================================
--- brlcad/branches/bioh/src/other/libregex 2020-05-07 17:47:34 UTC (rev
75730)
+++ brlcad/branches/bioh/src/other/libregex 2020-05-07 18:30:48 UTC (rev
75731)
Property changes on: brlcad/branches/bioh/src/other/libregex
___________________________________________________________________
Modified: svn:mergeinfo
## -8,4 +8,4 ##
/brlcad/branches/prep-cache/src/other/libregex:68236-68933
/brlcad/branches/tcltk86/src/other/libregex:68300-75257
/brlcad/branches/thirdparty_rework/src/other/libregex:75102-75103
-/brlcad/trunk/src/other/libregex:75720-75727
\ No newline at end of property
+/brlcad/trunk/src/other/libregex:75720-75729
\ No newline at end of property
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