Revision: 42323
          http://brlcad.svn.sourceforge.net/brlcad/?rev=42323&view=rev
Author:   starseeker
Date:     2011-01-16 17:49:36 +0000 (Sun, 16 Jan 2011)

Log Message:
-----------
Fix the behavior of bu_brlcad_root for run-time path identification - was 
calling bu_getprogname, which no longer returns path information.  Also expand 
header documentation for bu_dirname.

Modified Paths:
--------------
    brlcad/trunk/include/bu.h
    brlcad/trunk/src/libbu/brlcad_path.c

Modified: brlcad/trunk/include/bu.h
===================================================================
--- brlcad/trunk/include/bu.h   2011-01-16 17:35:07 UTC (rev 42322)
+++ brlcad/trunk/include/bu.h   2011-01-16 17:49:36 UTC (rev 42323)
@@ -3337,6 +3337,11 @@
  * @n  a/              .
  * @n  ../a/b          ../a
  *
+ * This routine will return "." if other valid results are not available
+ * but should never return NULL.
+ *
+ * Caller is responsible for freeing memory used by the return.
+ *
  * Warning: don't rely on non-constness of bu_dirname().. will change
  * to const.
  */

Modified: brlcad/trunk/src/libbu/brlcad_path.c
===================================================================
--- brlcad/trunk/src/libbu/brlcad_path.c        2011-01-16 17:35:07 UTC (rev 
42322)
+++ brlcad/trunk/src/libbu/brlcad_path.c        2011-01-16 17:49:36 UTC (rev 
42323)
@@ -436,25 +436,18 @@
 #endif
 
     /* run-time path identification */
-    lhs = bu_getprogname();
+    lhs = bu_argv0_full_path();
     if (lhs) {
-       char argv0[MAX_WHERE_SIZE] = {0};
-       size_t len = strlen(lhs);
-       snprintf(argv0, MAX_WHERE_SIZE, "%s", lhs);
-
-       /* need to trim off the trailing binary */
-       while (len-1 > 0) {
-           if (argv0[len-1] == BU_DIR_SEPARATOR) {
-               argv0[len] = '.';
-               argv0[len+1] = '.';
-               argv0[len+2] = '\0';
-               break;
-           }
-           len--;
-       }
-
-       snprintf(where, MAX_WHERE_SIZE, "\trun-time path identification 
[%s]\n", argv0);
-       if (_bu_find_path(result, argv0, rhs, &searched, where)) {
+       char real_path[MAXPATHLEN] = {0};
+       char *dirpath;
+       realpath(lhs, real_path);
+       dirpath = bu_dirname(real_path);
+       snprintf(real_path, MAXPATHLEN, "%s", dirpath);
+       bu_free(dirpath, "free bu_dirname");
+       dirpath = bu_dirname(real_path);
+       snprintf(real_path, MAXPATHLEN, "%s", dirpath);
+       bu_free(dirpath, "free bu_dirname");
+       if (_bu_find_path(result, real_path, rhs, &searched, where)) {
            if (UNLIKELY(bu_debug & BU_DEBUG_PATHS)) {
                bu_log("Found: Run-time path identification [%s]\n", result);
            }


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