r19563 - gnucash/trunk/src - Eliminate *-vicinity functions from e-guile reports.

Geert Janssens gjanssens at code.gnucash.org
Wed Sep 8 03:14:05 EDT 2010


Author: gjanssens
Date: 2010-09-08 03:14:05 -0400 (Wed, 08 Sep 2010)
New Revision: 19563
Trac: http://svn.gnucash.org/trac/changeset/19563

Modified:
   gnucash/trunk/src/core-utils/core-utils.i
   gnucash/trunk/src/core-utils/core-utils.scm
   gnucash/trunk/src/core-utils/gnc-filepath-utils.c
   gnucash/trunk/src/core-utils/gnc-filepath-utils.h
   gnucash/trunk/src/core-utils/gnc-path.c
   gnucash/trunk/src/core-utils/gnc-path.h
   gnucash/trunk/src/report/report-system/eguile-utilities.scm
   gnucash/trunk/src/report/standard-reports/balsheet-eg.scm
Log:
Eliminate *-vicinity functions from e-guile reports.

Modified: gnucash/trunk/src/core-utils/core-utils.i
===================================================================
--- gnucash/trunk/src/core-utils/core-utils.i	2010-09-07 22:14:04 UTC (rev 19562)
+++ gnucash/trunk/src/core-utils/core-utils.i	2010-09-08 07:14:05 UTC (rev 19563)
@@ -4,6 +4,7 @@
 #include <gnc-glib-utils.h>
 #include <gnc-main.h>
 #include <gnc-path.h>
+#include <gnc-filepath-utils.h>
 #include <glib.h>
 
 SCM scm_init_sw_core_utils_module (void);
@@ -17,6 +18,9 @@
 gboolean gnc_is_debugging(void);
 
 gchar * gnc_path_get_stdreportsdir(void);
+gchar * gnc_build_dotgnucash_path(const gchar *);
+gchar * gnc_build_report_path(const gchar *);
+gchar * gnc_build_stdreports_path(const gchar *);
 
 void gnc_scm_log_warn(const gchar *);
 void gnc_scm_log_error(const gchar *);

Modified: gnucash/trunk/src/core-utils/core-utils.scm
===================================================================
--- gnucash/trunk/src/core-utils/core-utils.scm	2010-09-07 22:14:04 UTC (rev 19562)
+++ gnucash/trunk/src/core-utils/core-utils.scm	2010-09-08 07:14:05 UTC (rev 19563)
@@ -11,6 +11,9 @@
 
 (re-export gnc-is-debugging)
 (re-export gnc-path-get-stdreportsdir)
+(re-export gnc-build-dotgnucash-path)
+(re-export gnc-build-report-path)
+(re-export gnc-build-stdreports-path)
 (re-export g-find-program-in-path)
 (re-export gnc-utf8?)
 (re-export gnc-utf8-strip-invalid-strdup)

Modified: gnucash/trunk/src/core-utils/gnc-filepath-utils.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-filepath-utils.c	2010-09-07 22:14:04 UTC (rev 19562)
+++ gnucash/trunk/src/core-utils/gnc-filepath-utils.c	2010-09-08 07:14:05 UTC (rev 19563)
@@ -369,4 +369,35 @@
     return result;
 }
 
+/** @fn gchar * gnc_build_report_path (const gchar *filename)
+ *  @brief Make a path to filename in the report directory.
+ *
+ * @param filename The name of the file
+ *
+ *  @return An absolute path.
+ */
+
+gchar *
+gnc_build_report_path (const gchar *filename)
+{
+    gchar *result = g_build_filename(gnc_path_get_reportdir(), filename, (gchar *)NULL);
+    return result;
+}
+
+/** @fn gchar * gnc_build_stdreports_path (const gchar *filename)
+ *  @brief Make a path to filename in the standard reports directory.
+ *
+ * @param filename The name of the file
+ *
+ *  @return An absolute path.
+ */
+
+gchar *
+gnc_build_stdreports_path (const gchar *filename)
+{
+    gchar *result = g_build_filename(gnc_path_get_stdreportsdir(), filename, (gchar *)NULL);
+    return result;
+}
+
+
 /* =============================== END OF FILE ========================== */

Modified: gnucash/trunk/src/core-utils/gnc-filepath-utils.h
===================================================================
--- gnucash/trunk/src/core-utils/gnc-filepath-utils.h	2010-09-07 22:14:04 UTC (rev 19562)
+++ gnucash/trunk/src/core-utils/gnc-filepath-utils.h	2010-09-08 07:14:05 UTC (rev 19563)
@@ -29,7 +29,7 @@
 #ifndef GNC_FILEPATH_UTILS_H
 #define GNC_FILEPATH_UTILS_H
 
-/** The xaccResolveFilePath() routine is a utility that will accept
+/** The gnc_resolve_file_path() routine is a utility that will accept
  *    a fragmentary filename as input, and resolve it into a fully
  *    qualified path in the file system, i.e. a path that begins with
  *    a leading slash.  First, the current working directory is
@@ -45,5 +45,7 @@
 gchar *gnc_build_dotgnucash_path (const gchar *filename);
 gchar *gnc_build_book_path (const gchar *filename);
 gchar *gnc_build_data_path (const gchar *filename);
+gchar *gnc_build_report_path (const gchar *filename);
+gchar *gnc_build_stdreports_path (const gchar *filename);
 
 #endif /* GNC_FILEPATH_UTILS_H */

Modified: gnucash/trunk/src/core-utils/gnc-path.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-path.c	2010-09-07 22:14:04 UTC (rev 19562)
+++ gnucash/trunk/src/core-utils/gnc-path.c	2010-09-08 07:14:05 UTC (rev 19563)
@@ -125,6 +125,20 @@
     return result;
 }
 
+/** Returns the file path to the report directory, usually
+ * "$prefix/share/gnucash/guile-modules/gnucash/report".
+ *
+ * @returns A newly allocated string. */
+gchar *gnc_path_get_reportdir()
+{
+    gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
+    gchar *result = g_build_filename (pkgdatadir, "guile-modules",
+            "gnucash", "report", (char*)NULL);
+    g_free (pkgdatadir);
+    //printf("Returning stdreportsdir %s\n", result);
+    return result;
+}
+
 /** Returns the file path to the standard
  * reports, usually
  * "$prefix/share/gnucash/guile-modules/gnucash/report/standard-reports".
@@ -132,10 +146,9 @@
  * @returns A newly allocated string. */
 gchar *gnc_path_get_stdreportsdir()
 {
-    gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
-    gchar *result = g_build_filename (pkgdatadir, "guile-modules",
-            "gnucash", "report", "standard-reports", (char*)NULL);
-    g_free (pkgdatadir);
+    gchar *reportdir = gnc_path_get_reportdir ();
+    gchar *result = g_build_filename (reportdir, "standard-reports", (char*)NULL);
+    g_free (reportdir);
     //printf("Returning stdreportsdir %s\n", result);
     return result;
 }

Modified: gnucash/trunk/src/core-utils/gnc-path.h
===================================================================
--- gnucash/trunk/src/core-utils/gnc-path.h	2010-09-07 22:14:04 UTC (rev 19562)
+++ gnucash/trunk/src/core-utils/gnc-path.h	2010-09-08 07:14:05 UTC (rev 19563)
@@ -74,6 +74,12 @@
  * @returns A newly allocated string. */
 gchar *gnc_path_get_accountsdir(void);
 
+/** Returns the file path to the report directory, usually
+ * "$prefix/share/gnucash/guile-modules/gnucash/report".
+ *
+ * @returns A newly allocated string. */
+gchar *gnc_path_get_reportdir(void);
+
 /** Returns the file path to the standard
  * reports, usually
  * "$prefix/share/gnucash/guile-modules/gnucash/report/standard-reports".

Modified: gnucash/trunk/src/report/report-system/eguile-utilities.scm
===================================================================
--- gnucash/trunk/src/report/report-system/eguile-utilities.scm	2010-09-07 22:14:04 UTC (rev 19562)
+++ gnucash/trunk/src/report/report-system/eguile-utilities.scm	2010-09-08 07:14:05 UTC (rev 19563)
@@ -27,8 +27,9 @@
 ; using all of these seems like overkill -- 
 ; not sure which are really required
 (use-modules (gnucash main))
-(use-modules (gnucash gnc-module))        
+(use-modules (gnucash gnc-module))
 (use-modules (gnucash app-utils))
+(use-modules (gnucash core-utils))
 (use-modules (gnucash business-utils))
 (gnc:module-load "gnucash/report/report-system" 0)
 (gnc:module-load "gnucash/business-utils" 0)
@@ -77,22 +78,14 @@
   ;; Find the file 'fname', and return its full path.
   ;; First look in the user's .gnucash directory.
   ;; Then look in Gnucash's standard report directory.
-  ;; This is complicated because of the need to cater for
-  ;; various operating systems; so it takes a fairly heuristic,
-  ;; 'best guess' approach.
   ;; If no file is found, returns just 'fname' for use in error messages.
   ;; Note: this has been tested on Linux and Windows Vista so far...
-  (let* ((userdir (sub-vicinity (user-vicinity) ".gnucash"))
-         (sysdir  (sub-vicinity (sub-vicinity (user-vicinity) "gnucash") "report"))
-         (home (or (home-vicinity)
-                   (getenv "USERPROFILE")
-                   (user-vicinity)
-                   "")))
+  (let* ((userpath (gnc-build-dotgnucash-path fname))
+         (syspath  (gnc-build-report-path fname)))
     ; make sure there's a trailing delimiter
-    (set! home (sub-vicinity (user-vicinity) home))
-    (let ((home-template (in-vicinity (in-vicinity home userdir) fname)))
-      (if (access? home-template R_OK)
-        home-template
-        (or (%search-load-path (in-vicinity sysdir fname))
-            fname)))))
+      (if (access? userpath R_OK)
+        userpath
+        (if (access? syspath R_OK)
+          syspath
+          fname))))
   

Modified: gnucash/trunk/src/report/standard-reports/balsheet-eg.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/balsheet-eg.scm	2010-09-07 22:14:04 UTC (rev 19562)
+++ gnucash/trunk/src/report/standard-reports/balsheet-eg.scm	2010-09-08 07:14:05 UTC (rev 19563)
@@ -36,9 +36,9 @@
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash business-utils))
 (use-modules (gnucash report eguile-gnc))
+(use-modules (gnucash report eguile-utilities))
 
 (use-modules (ice-9 regex))  ; for regular expressions
-(use-modules (ice-9 slib))   ; for 'vicinity' functions
 (use-modules (srfi srfi-13)) ; for extra string functions
 
 (gnc:module-load "gnucash/report/report-system" 0)
@@ -127,29 +127,6 @@
     (cc 'add com (gnc-numeric-neg num))
     (cc 'add com num)))
 
-(define (find-file fname)
-  ;; Find the file 'fname', and return its full path.
-  ;; First look in the user's .gnucash directory.
-  ;; Then look in Gnucash's standard report directory.
-  ;; This is complicated because of the need to cater for
-  ;; various operating systems; so it takes a fairly heuristic,
-  ;; 'best guess' approach.
-  ;; If no file is found, returns just 'fname' for use in error messages.
-  ;; Note: this has been tested on Linux and Windows Vista so far...
-  (let* ((userdir (sub-vicinity (user-vicinity) ".gnucash"))
-         (sysdir  (sub-vicinity (sub-vicinity (user-vicinity) "gnucash") "report"))
-         (home (or (home-vicinity)
-                   (getenv "USERPROFILE")
-                   (user-vicinity)
-                   "")))
-    ; make sure there's a trailing delimiter
-    (set! home (sub-vicinity (user-vicinity) home))
-    (let ((home-template (in-vicinity (in-vicinity home userdir) fname)))
-      (if (access? home-template R_OK)
-        home-template
-        (or (%search-load-path (in-vicinity sysdir fname))
-            fname)))))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
 ;; Define an account record for cacheing information about all the accounts



More information about the gnucash-changes mailing list