[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.7.1-20110619-297-g07de759)



The branch, master has been updated
       via  07de7591c23c93efdb92012304dc7aaee1c66c04 (commit)
      from  dd18397d667622407f0cf2856c5f407b0c3dca80 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 libgeda/include/prototype_priv.h |    1 -
 libgeda/scheme/geda.scm          |   35 ++++++++++++++++++-
 libgeda/src/g_rc.c               |   70 --------------------------------------
 libgeda/src/g_register.c         |    1 -
 4 files changed, 34 insertions(+), 73 deletions(-)


=================
 Commit Messages
=================

commit 07de7591c23c93efdb92012304dc7aaee1c66c04
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Improvements to 'component-library-search'.
    
    Luigi Palese has supplied an improved Scheme version of the
    'component-library-search' function for searching a directory tree for
    symbol libraries.
    
    The new version:
    
    - Searches for directories recursively, rather than only searching the
      top level of the provided directory.
    - Only considers directories that actually contain symbol files as
      libraries.
    - Optionally adds a prefix to the library names shown in the gschem
      library window.
    
    (I have made some adjustments to Luigi's original version of the
    function).
    
    Closes-bug: lp-901222

:100644 100644 c07bd29... 927f672... M	libgeda/include/prototype_priv.h
:100644 100644 4c6751f... 6f3aa70... M	libgeda/scheme/geda.scm
:100644 100644 c63a5cc... 06bd810... M	libgeda/src/g_rc.c
:100644 100644 497d7b2... 72990c8... M	libgeda/src/g_register.c

=========
 Changes
=========

commit 07de7591c23c93efdb92012304dc7aaee1c66c04
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Improvements to 'component-library-search'.
    
    Luigi Palese has supplied an improved Scheme version of the
    'component-library-search' function for searching a directory tree for
    symbol libraries.
    
    The new version:
    
    - Searches for directories recursively, rather than only searching the
      top level of the provided directory.
    - Only considers directories that actually contain symbol files as
      libraries.
    - Optionally adds a prefix to the library names shown in the gschem
      library window.
    
    (I have made some adjustments to Luigi's original version of the
    function).
    
    Closes-bug: lp-901222

diff --git a/libgeda/include/prototype_priv.h b/libgeda/include/prototype_priv.h
index c07bd29..927f672 100644
--- a/libgeda/include/prototype_priv.h
+++ b/libgeda/include/prototype_priv.h
@@ -15,7 +15,6 @@ int vstbl_get_val(const vstbl_entry *table, int index);
 SCM g_rc_component_library(SCM path, SCM name);
 SCM g_rc_component_library_command (SCM listcmd, SCM getcmd, SCM name);
 SCM g_rc_component_library_funcs (SCM listfunc, SCM getfunc, SCM name);
-SCM g_rc_component_library_search(SCM path);
 SCM g_rc_source_library(SCM path);
 SCM g_rc_source_library_search(SCM path);
 SCM g_rc_world_size(SCM width, SCM height, SCM border);
diff --git a/libgeda/scheme/geda.scm b/libgeda/scheme/geda.scm
index 4c6751f..6f3aa70 100644
--- a/libgeda/scheme/geda.scm
+++ b/libgeda/scheme/geda.scm
@@ -1,5 +1,5 @@
 ; -*-Scheme-*-
-(use-modules (geda os))
+(use-modules (geda os) (ice-9 optargs) (ice-9 ftw))
 (define path-sep separator)
 (define geda-data-path (car (sys-data-dirs)))
 (define geda-rc-path (car (sys-config-dirs)))
@@ -52,3 +52,36 @@
     #f
   )))
 
+;; Add all symbol libraries found below DIR to be searched for
+;; components, naming them with an optional PREFIX.
+(define* (component-library-search rootdir  #:optional prefix)
+  (let ((dht (make-hash-table 31)))
+    ;; Build symbol directory list
+    (ftw rootdir
+         (lambda (filename statinfo flags)
+           (cond
+            ((eq? 'invalid-stat flags)
+             (error "Invalid path ~S." filename))
+            ((or (eq? 'directory-not-readable flags)
+                 (eq? 'symlink flags))
+             (format #t "Warning: Cannot access ~S.\n" filename))
+            (else
+             (and (eq? 'regular flags)
+                  (string-suffix-ci? ".sym" filename)
+                  (hashq-set! dht
+                              (string->symbol (dirname filename))
+                              #t))))
+           #t))
+
+    ; Fill component library tree
+    (for-each
+     (lambda (dir)
+       (let ((name (substring dir (string-length rootdir))))
+         (component-library dir
+                            (if prefix
+                                (string-append prefix name)
+                                name))))
+     (sort-list! (hash-map->list (lambda (key val)
+                                   (symbol->string key))
+                                 dht)
+                 string>?))))
diff --git a/libgeda/src/g_rc.c b/libgeda/src/g_rc.c
index c63a5cc..06bd810 100644
--- a/libgeda/src/g_rc.c
+++ b/libgeda/src/g_rc.c
@@ -543,76 +543,6 @@ SCM g_rc_component_library_funcs (SCM listfunc, SCM getfunc, SCM name)
  *  \param [in] path  
  *  \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
  */
-SCM g_rc_component_library_search(SCM path)
-{
-  gchar *string;
-  char *temp;
-  GDir *dir;
-  const gchar *entry;
-  
-  SCM_ASSERT (scm_is_string (path), path,
-              SCM_ARG1, "component-library-search");
-
-  /* take care of any shell variables */
-  temp = scm_to_utf8_string (path);
-  string = s_expand_env_variables (temp);
-  free (temp);
-
-  /* invalid path? */
-  if (!g_file_test (string, G_FILE_TEST_IS_DIR)) {
-    fprintf (stderr,
-             "Invalid path [%s] passed to component-library-search\n",
-             string);
-    g_free(string);
-    return SCM_BOOL_F;
-  }
-
-  dir = g_dir_open (string, 0, NULL);
-  if (dir == NULL) {
-    fprintf (stderr,
-             "Invalid path [%s] passed to component-library-search\n",
-             string);
-    g_free(string);
-    return SCM_BOOL_F;
-  }
-
-  while ((entry = g_dir_read_name (dir))) {
-    /* don't do . and .. and special case font */
-    if ((g_strcasecmp (entry, ".")    != 0) && 
-        (g_strcasecmp (entry, "..")   != 0) &&
-        (g_strcasecmp (entry, "font") != 0))
-    {
-      gchar *fullpath = g_build_filename (string, entry, NULL);
-
-      if (g_file_test (fullpath, G_FILE_TEST_IS_DIR)) {
-        if (g_path_is_absolute (fullpath)) {
-          s_clib_add_directory (fullpath, NULL);
-        } else {
-          gchar *cwd = g_get_current_dir ();
-          gchar *temp;
-          temp = g_build_filename (cwd, fullpath, NULL);
-          s_clib_add_directory (temp, NULL);
-          g_free(temp);
-          g_free(cwd);
-        }
-      }
-      g_free(fullpath);
-    }
-  }
-
-  g_free(string);
-  g_dir_close(dir);
-
-  return SCM_BOOL_T;
-}
-
-/*! \todo Finish function description!!!
- *  \brief
- *  \par Function Description
- *
- *  \param [in] path  
- *  \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
- */
 SCM g_rc_source_library(SCM path)
 {
   gchar *string;
diff --git a/libgeda/src/g_register.c b/libgeda/src/g_register.c
index 497d7b2..72990c8 100644
--- a/libgeda/src/g_register.c
+++ b/libgeda/src/g_register.c
@@ -53,7 +53,6 @@ static struct gsubr_t libgeda_funcs[] = {
   { "component-library",        1, 1, 0, g_rc_component_library },
   { "component-library-command", 3, 0, 0, g_rc_component_library_command },
   { "component-library-funcs",  3, 0, 0, g_rc_component_library_funcs },
-  { "component-library-search", 1, 0, 0, g_rc_component_library_search },
   { "source-library",           1, 0, 0, g_rc_source_library },
   { "source-library-search",    1, 0, 0, g_rc_source_library_search },
   




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs