Revision: 57835
          http://sourceforge.net/p/brlcad/code/57835
Author:   brlcad
Date:     2013-09-23 16:48:06 +0000 (Mon, 23 Sep 2013)
Log Message:
-----------
fix the fixme's, no worse for the wear, by removing progname_ipwd()

Modified Paths:
--------------
    brlcad/branches/RELEASE/src/libbu/progname.c

Modified: brlcad/branches/RELEASE/src/libbu/progname.c
===================================================================
--- brlcad/branches/RELEASE/src/libbu/progname.c        2013-09-23 16:31:56 UTC 
(rev 57834)
+++ brlcad/branches/RELEASE/src/libbu/progname.c        2013-09-23 16:48:06 UTC 
(rev 57835)
@@ -35,84 +35,12 @@
 static char bu_progname[MAXPATHLEN] = {0};
 
 
-/**
- * b u _ i p w d
- *
- * set/return the path to the initial working directory.
- * bu_setprogname() must be called on app startup for the correct pwd to
- * be acquired/set.
- */
 HIDDEN const char *
-progname_ipwd()
-{
-    /* private stash */
-    static const char *ipwd = NULL;
-    static char buffer[MAXPATHLEN] = {0};
-    const char *pwd = NULL;
-
-    /* already found the path before */
-    if (ipwd) {
-       return ipwd;
-    }
-
-    /* FIRST: try environment */
-    pwd = getenv("PWD"); /* not our memory to free */
-    if (pwd && strlen(pwd) > 0) {
-#ifdef HAVE_REALPATH
-       ipwd = realpath(pwd, buffer);
-       if (ipwd) {
-           return ipwd;
-       }
-#endif
-       ipwd = pwd;
-       return ipwd;
-    }
-
-    /* SECOND: try to query path */
-#ifdef HAVE_REALPATH
-    ipwd = realpath(".", buffer);
-    if (ipwd && strlen(ipwd) > 0) {
-       return ipwd;
-    }
-#endif
-
-    /* THIRD: try calling the 'pwd' command */
-    ipwd = bu_which("pwd");
-    if (ipwd) {
-#if defined(HAVE_POPEN) && !defined(STRICT_FLAGS)
-       FILE *fp = NULL;
-
-       fp = popen(ipwd, "r");
-       if (LIKELY(fp != NULL)) {
-           if (bu_fgets(buffer, MAXPATHLEN, fp)) {
-               ipwd = buffer;
-           } else {
-               ipwd = ".";
-           }
-       } else {
-           ipwd = ".";
-       }
-#else
-       memset(buffer, 0, MAXPATHLEN); /* quellage */
-       ipwd = ".";
-#endif
-    }
-
-    /* LAST: punt (but do not return NULL) */
-    ipwd = ".";
-    return ipwd;
-}
-
-
-HIDDEN const char *
 progname_argv0(void)
 {
     /* private stash */
     static const char *argv0 = NULL;
 
-    /* FIXME: this is temporary until bu_getcwd() is working. */
-    (void)progname_ipwd();
-
     if (bu_argv0_buffer[0] != '\0') {
        argv0 = bu_argv0_buffer;
     }
@@ -139,9 +67,6 @@
 
     const char *argv0 = progname_argv0();
 
-    /* FIXME: this is temporary until bu_getcwd() is working. */
-    const char *ipwd = progname_ipwd();
-
     const char *which = bu_which(argv0);
 
     if (argv0[0] == BU_DIR_SEPARATOR) {
@@ -162,7 +87,8 @@
     }
 
     /* running from relative dir */
-    snprintf(buffer, MAXPATHLEN, "%s%c%s", ipwd, BU_DIR_SEPARATOR, argv0);
+    bu_getcwd(buffer, MAXPATHLEN);
+    snprintf(buffer+strlen(buffer), MAXPATHLEN-strlen(buffer), "%c%s", 
BU_DIR_SEPARATOR, argv0);
     if (bu_file_exists(buffer, NULL)) {
        return buffer;
     }
@@ -174,7 +100,8 @@
 
 
 const char *
-bu_getprogname(void) {
+bu_getprogname(void)
+{
     const char *name = NULL;
     char *tmp_basename = NULL;
 
@@ -214,9 +141,6 @@
        bu_progname[0] = '\0';
     }
 
-    /* FIXME: this is temporary until bu_getcwd() is working. */
-    (void)progname_ipwd();
-
     return;
 }
 

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


------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to