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

gEDA-cvs: gaf.git: branch: master updated (1.6.1-20100214-212-g571bcba)



The branch, master has been updated
       via  571bcba5610c9002efd69a0cb7f2729e8ac71767 (commit)
       via  8029e76df046b392876f1997960fd7fd7d293bc2 (commit)
       via  f6d5b71a26b2f6877d9daffbe150f41d233e501a (commit)
       via  b2f24756d4d53df1cc73e1588b592d0c4c4f8166 (commit)
       via  19dcc79af1e7a43e1b28e8378a5c1cd4392137f2 (commit)
       via  cb47d3a0c3a5ac2b5b6ea9f94b66a2b5735de7e0 (commit)
       via  d56ec6d94b1ecd8e08a8ee9beb56b3b8dd9eb01f (commit)
       via  0f9554ec1bcb37dba92a09f1b69680ca8cd3366f (commit)
       via  e54ba540a83520c7f55f13aa9300789659272dda (commit)
       via  7a3e9f294d12732cd6fb043412c1bf92eaf5b268 (commit)
       via  258eb0591088a064631c1736b2c3f86aa9e07856 (commit)
      from  3f8480f6a2b9674e904d1f50c1788bdf79b539bc (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
=========

 NEWS                                               |   16 +-
 gnetlist/docs/gnetlist.1                           |  418 +++++++++++---------
 gnetlist/scheme/Makefile.am                        |    2 +-
 gnetlist/scheme/gnet-partslist1.scm                |    2 +-
 gnetlist/scheme/gnet-partslist2.scm                |    2 +-
 gnetlist/scheme/gnet-partslist3.scm                |    2 +-
 ...t-partslist-common.scm => partslist-common.scm} |    0 
 gnetlist/src/gnetlist.c                            |  132 ++++---
 gnetlist/src/i_vars.c                              |    1 -
 gnetlist/src/parsecmd.c                            |  283 ++++++++------
 gschem/docs/gschem.1                               |   52 ++--
 gschem/include/prototype.h                         |    1 -
 gschem/src/gschem.c                                |    5 -
 gschem/src/parsecmd.c                              |  112 ++++--
 libgeda/include/i_vars_priv.h                      |    1 -
 libgeda/include/libgeda/struct.h                   |    1 -
 libgeda/lib/system-gafrc                           |    3 -
 libgeda/src/g_rc.c                                 |   40 +-
 libgeda/src/i_vars.c                               |    4 -
 libgeda/src/s_toplevel.c                           |    2 -
 20 files changed, 614 insertions(+), 465 deletions(-)
 rename gnetlist/scheme/{gnet-partslist-common.scm => partslist-common.scm} (100%)


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

commit 571bcba5610c9002efd69a0cb7f2729e8ac71767
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Behave more usefully with bad arguments.
    
    At the moment gnetlist exits with status 0 (success) when it receives
    bad command line arguments.  Correct this, and make it more obvious
    why things have failed.

:100644 100644 ae355c0... d63d240... M	NEWS
:100644 100644 fe1cb1b... 0fef29d... M	gnetlist/src/parsecmd.c

commit 8029e76df046b392876f1997960fd7fd7d293bc2
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Clean up formatting of `parsecmd.c'.

:100644 100644 53767cb... fe1cb1b... M	gnetlist/src/parsecmd.c

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

    gnetlist: Add `-V', `--version' argument.

:100644 100644 020b04c... ae355c0... M	NEWS
:100644 100644 17b4a20... 48ce082... M	gnetlist/docs/gnetlist.1
:100644 100644 3cc7720... 53767cb... M	gnetlist/src/parsecmd.c

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

    gnetlist: Improve `--help' usage message.

:100644 100644 9d48849... 3cc7720... M	gnetlist/src/parsecmd.c

commit 19dcc79af1e7a43e1b28e8378a5c1cd4392137f2
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Update man page.

:100644 100644 6eeacd5... 17b4a20... M	gnetlist/docs/gnetlist.1

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

    gnetlist: Rename partslist backends' common functions file.
    
    Rename partslist backend common functions file so it doesn't show up
    in the output of `gnetlist -ghelp'.

:100644 100644 dcbc582... 66a1cd8... M	gnetlist/scheme/Makefile.am
:100644 000000 eac539e... 0000000... D	gnetlist/scheme/gnet-partslist-common.scm
:100644 100644 a8a21cf... 172fbcc... M	gnetlist/scheme/gnet-partslist1.scm
:100644 100644 10a54f5... ca54119... M	gnetlist/scheme/gnet-partslist2.scm
:100644 100644 8b450f9... 14f25dd... M	gnetlist/scheme/gnet-partslist3.scm
:000000 100644 0000000... eac539e... A	gnetlist/scheme/partslist-common.scm

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

    gschem: Provide long-form options and update man page.
    
    Make gschem support long-form alternatives for several command-line
    options.  Additionally, make some further improvements to the gschem man page.

:100644 100644 9cd263d... 020b04c... M	NEWS
:100644 100644 1412c42... 9c4d184... M	gschem/docs/gschem.1
:100644 100644 9b56955... 0fd4df2... M	gschem/include/prototype.h
:100644 100644 5613dbd... d5c765b... M	gschem/src/parsecmd.c

commit 0f9554ec1bcb37dba92a09f1b69680ca8cd3366f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Remove `-t' option from usage message.
    
    The `-t' option was removed in commit 65b79e360357, but was not
    removed from the usage message at the that time.

:100644 100644 f948e1d... 5613dbd... M	gschem/src/parsecmd.c

commit 7a3e9f294d12732cd6fb043412c1bf92eaf5b268
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    Make `scheme-directory' rc function prepend to Guile load path.
    
    Guile already provides infrastructure for loading Scheme files from a
    library, so this patch makes gEDA use it properly.  With this (fully
    backward-compatible) patch it's now possible to load Scheme files,
    including gnetlist backends, from more than one directory.
    
    Note: This commit makes the gnetlist test suite pass again.

:100644 100644 5acf9df... b6ced88... M	gnetlist/src/i_vars.c
:100644 100644 9efb61d... 8af89b8... M	gschem/src/gschem.c
:100644 100644 f660115... a1a4d4c... M	libgeda/include/i_vars_priv.h
:100644 100644 2a5961e... aed0ffc... M	libgeda/include/libgeda/struct.h
:100644 100644 f238fb1... cff8371... M	libgeda/lib/system-gafrc
:100644 100644 5e0bc46... 75112e9... M	libgeda/src/g_rc.c
:100644 100644 c1c6897... 8603e44... M	libgeda/src/i_vars.c
:100644 100644 60356f0... 27e03b5... M	libgeda/src/s_toplevel.c

commit 258eb0591088a064631c1736b2c3f86aa9e07856
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Load Scheme from Guile load path, not `scheme-directory'.
    
    gnetlist now searches for Scheme files to load using the Guile load
    path, rather than TOPLEVEL.scheme_directory.
    
    Additionally, the `-g help' option now outputs the list of know
    backends in a single column rather than in three columns.
    
    Note: in this commit the gnetlist testsuite does not pass.

:100644 100644 72680cc... 56cf008... M	gnetlist/src/gnetlist.c

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

commit 571bcba5610c9002efd69a0cb7f2729e8ac71767
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Behave more usefully with bad arguments.
    
    At the moment gnetlist exits with status 0 (success) when it receives
    bad command line arguments.  Correct this, and make it more obvious
    why things have failed.

diff --git a/NEWS b/NEWS
index ae355c0..d63d240 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,9 @@ Notable changes in gEDA/gaf 1.7.0
 * `gnetlist' now provides a `-V' or `--version' option, which displays
   version information.
 
+* When run with invalid command-line arguments, `gnetlist' now exits
+  with non-zero exit status.
+
 * Several `gnetlist' backends have now been fixed so that it should no
   longer be necessary to set an expanded Guile stack in gEDA's config
   files.
diff --git a/gnetlist/src/parsecmd.c b/gnetlist/src/parsecmd.c
index fe1cb1b..0fef29d 100644
--- a/gnetlist/src/parsecmd.c
+++ b/gnetlist/src/parsecmd.c
@@ -219,9 +219,24 @@ parse_commandline (int argc, char *argv[])
       break;
 
     case '?':
+#ifndef HAVE_GETOPT_LONG
+        if ((optopt != ':') && (strchr (GETOPT_OPTIONS, optopt) != NULL)) {
+          fprintf (stderr,
+                   "ERROR: -%c option requires an argument.\n\n",
+                   optopt);
+        } else if (isprint (optopt)) {
+          fprintf (stderr, "ERROR: Unknown option -%c.\n\n", optopt);
+        } else {
+          fprintf (stderr, "ERROR: Unknown option character `\\x%x'.\n\n",
+                   optopt);
+        }
+#endif
+        fprintf (stderr, "\nRun `%s --help' for more information.\n", argv[0]);
+        exit (1);
+        break;
+
     default:
-      usage(argv[0]);
-      break;
+      g_assert_not_reached ();
     }
   }
 

commit 8029e76df046b392876f1997960fd7fd7d293bc2
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Clean up formatting of `parsecmd.c'.

diff --git a/gnetlist/src/parsecmd.c b/gnetlist/src/parsecmd.c
index 53767cb..fe1cb1b 100644
--- a/gnetlist/src/parsecmd.c
+++ b/gnetlist/src/parsecmd.c
@@ -1,5 +1,5 @@
 /* gEDA - GPL Electronic Design Automation
- * gnetlist - gEDA Netlist 
+ * gnetlist - gEDA Netlist
  * Copyright (C) 1998-2010 Ales Hvezda
  * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
  *
@@ -53,16 +53,16 @@ extern int optind;
 /* Added by SDB 3.3.2006.  */
 #ifdef HAVE_GETOPT_LONG
 struct option long_options[] =
-{
-  {"help", 0, 0, 'h'},
-  {"nomunge", 0, 0, 'n'},
-  {"verbose", 0, 0, 'v'},
-  {"version", 0, 0, 'V'},
-  {"sort", 0, 0, 's'},
-  {"embedd", 0, 0, 'e'},
-  {"include", 0, 0, 'I'},
-  {0, 0, 0, 0}
-};
+  {
+    {"help", 0, 0, 'h'},
+    {"nomunge", 0, 0, 'n'},
+    {"verbose", 0, 0, 'v'},
+    {"version", 0, 0, 'V'},
+    {"sort", 0, 0, 's'},
+    {"embedd", 0, 0, 'e'},
+    {"include", 0, 0, 'I'},
+    {0, 0, 0, 0}
+  };
 #endif
 
 
@@ -96,7 +96,7 @@ void usage(char *cmd)
 "\n"
 "Report bugs to <geda-bug@xxxxxxxx>.\n"
 "gEDA/gaf homepage: <http://gpleda.org>\n",
-           cmd);
+          cmd);
   exit (0);
 }
 
@@ -131,104 +131,103 @@ catch_handler (void *data, SCM tag, SCM throw_args)
 }
 
 
-int parse_commandline(int argc, char *argv[])
+int
+parse_commandline (int argc, char *argv[])
 {
-    int ch;
+  int ch;
 
-    /* Converted to getopt_long by SDB 3.3.2006 */
+  /* Converted to getopt_long by SDB 3.3.2006 */
 #ifdef HAVE_GETOPT_LONG
-    /* int option_index = 0; */
+  /* int option_index = 0; */
 
-    while ((ch = getopt_long(argc, argv, OPTIONS, long_options, NULL /* &option_index */)) != -1) {
+  while ((ch = getopt_long(argc, argv, OPTIONS, long_options, NULL /* &option_index */)) != -1) {
 #else
-    while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
+  while ((ch = getopt(argc, argv, OPTIONS)) != -1) {
 #endif
-	switch (ch) {
-
-	case 'v':
-	    backend_params = g_slist_append(backend_params, "verbose_mode");
-	    verbose_mode = TRUE;
-	    break;
-
-	case 'i':
-	    backend_params = g_slist_append(backend_params, "interactive_mode");
-	    interactive_mode = TRUE;
-	    break;
-
-        case 'I':
-	    backend_params = g_slist_append(backend_params, "include_mode");
-            include_mode = TRUE;
-            break;
-
-        case 'e':
-	    backend_params = g_slist_append(backend_params, "embedd_mode");
-            embedd_mode = TRUE;
-            break;
-
-	case 'q':
-	    backend_params = g_slist_append(backend_params, "quiet_mode");
-	    quiet_mode = TRUE;
-	    break;
-
-	case 'g':
-	    guile_proc = g_strdup(optarg);
-
-	    break;
-
-        case 'l':        
-           pre_backend_list = g_slist_append(pre_backend_list, optarg);
-           break;
-
-        case 'm':        
-           post_backend_list = g_slist_append(post_backend_list, optarg);
-           break;
-
-        case 'n':
-	   backend_params = g_slist_append(backend_params, "nomunge_mode");
-	   nomunge_mode = TRUE;
-           break;
-
-	case 'o':
-	    g_free(output_filename);
-	    output_filename = g_strdup(optarg);
-	    break;
-
-	case 'O':        
-	  backend_params = g_slist_append(backend_params, optarg);
-	  break;
-
-	case 'c':
-        scm_internal_stack_catch (SCM_BOOL_T,
-                                  (scm_t_catch_body) scm_c_eval_string,
-                                  (void *) optarg,
-                                  (scm_t_catch_handler) catch_handler,
-                                  (void *) optarg);
-	    break;
-
-        case 's':
- 	    backend_params = g_slist_append(backend_params, "sort_mode");
-            sort_mode = TRUE;
-            break;
-
-
-	case 'h':
-	    usage(argv[0]);
-	    break;
-
-	case 'V':
-          version();
-          break;
-
-	case '?':
-	default:
-	    usage(argv[0]);
-	    break;
-	}
+    switch (ch) {
+
+    case 'v':
+      backend_params = g_slist_append(backend_params, "verbose_mode");
+      verbose_mode = TRUE;
+      break;
+
+    case 'i':
+      backend_params = g_slist_append(backend_params, "interactive_mode");
+      interactive_mode = TRUE;
+      break;
+
+    case 'I':
+      backend_params = g_slist_append(backend_params, "include_mode");
+      include_mode = TRUE;
+      break;
+
+    case 'e':
+      backend_params = g_slist_append(backend_params, "embedd_mode");
+      embedd_mode = TRUE;
+      break;
+
+    case 'q':
+      backend_params = g_slist_append(backend_params, "quiet_mode");
+      quiet_mode = TRUE;
+      break;
+
+    case 'g':
+      guile_proc = g_strdup(optarg);
+      break;
+
+    case 'l':
+      pre_backend_list = g_slist_append(pre_backend_list, optarg);
+      break;
+
+    case 'm':
+      post_backend_list = g_slist_append(post_backend_list, optarg);
+      break;
+
+    case 'n':
+      backend_params = g_slist_append(backend_params, "nomunge_mode");
+      nomunge_mode = TRUE;
+      break;
+
+    case 'o':
+      g_free(output_filename);
+      output_filename = g_strdup(optarg);
+      break;
+
+    case 'O':
+      backend_params = g_slist_append(backend_params, optarg);
+      break;
+
+    case 'c':
+      scm_internal_stack_catch (SCM_BOOL_T,
+                                (scm_t_catch_body) scm_c_eval_string,
+                                (void *) optarg,
+                                (scm_t_catch_handler) catch_handler,
+                                (void *) optarg);
+      break;
+
+    case 's':
+      backend_params = g_slist_append(backend_params, "sort_mode");
+      sort_mode = TRUE;
+      break;
+
+    case 'h':
+      usage(argv[0]);
+      break;
+
+    case 'V':
+      version();
+      break;
+
+    case '?':
+    default:
+      usage(argv[0]);
+      break;
     }
+  }
 
-    if (quiet_mode) {
-	verbose_mode = FALSE;
-    }
+  if (quiet_mode) {
+    verbose_mode = FALSE;
+  }
 
-    return (optind);
+  return (optind);
 }

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

    gnetlist: Add `-V', `--version' argument.

diff --git a/NEWS b/NEWS
index 020b04c..ae355c0 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,9 @@ Notable changes in gEDA/gaf 1.7.0
 * Special characters, including commas, are now escaped or quoted
   appropriately in `gattrib' CSV output.
 
+* `gnetlist' now provides a `-V' or `--version' option, which displays
+  version information.
+
 * Several `gnetlist' backends have now been fixed so that it should no
   longer be necessary to set an expanded Guile stack in gEDA's config
   files.
diff --git a/gnetlist/docs/gnetlist.1 b/gnetlist/docs/gnetlist.1
index 17b4a20..48ce082 100644
--- a/gnetlist/docs/gnetlist.1
+++ b/gnetlist/docs/gnetlist.1
@@ -63,6 +63,9 @@ Scheme read-eval-print loop.
 \fB-h\fR, \fB--help\fR
 Print a help message.
 .TP 8
+\fB-V\fR, \fB--version\fR
+Print \fBgnetlist\fR version information.
+.TP 8
 \fB--\fR
 Treat all remaining arguments as schematic filenames.  Use this if you
 have a schematic filename which begins with `-'.
diff --git a/gnetlist/src/parsecmd.c b/gnetlist/src/parsecmd.c
index 3cc7720..53767cb 100644
--- a/gnetlist/src/parsecmd.c
+++ b/gnetlist/src/parsecmd.c
@@ -19,6 +19,7 @@
  */
 
 #include <config.h>
+#include <version.h>
 
 #include <stdio.h>
 #ifdef HAVE_STRING_H
@@ -41,7 +42,7 @@
 #include <dmalloc.h>
 #endif
 
-#define OPTIONS "o:qieIhvsg:c:l:m:O:n"
+#define OPTIONS "o:qieIhvsg:c:l:m:O:nV"
 
 #ifndef OPTARG_IN_UNISTD
 extern char *optarg;
@@ -56,6 +57,7 @@ struct option long_options[] =
   {"help", 0, 0, 'h'},
   {"nomunge", 0, 0, 'n'},
   {"verbose", 0, 0, 'v'},
+  {"version", 0, 0, 'V'},
   {"sort", 0, 0, 's'},
   {"embedd", 0, 0, 'e'},
   {"include", 0, 0, 'I'},
@@ -82,6 +84,7 @@ void usage(char *cmd)
 "  -c EXPR         Evaluate Scheme expression at startup.\n"
 "  -i              Enter interactive Scheme REPL after loading.\n"
 "  -h, --help      Help; this message.\n"
+"  -V, --version   Show version information.\n"
 "  --              Treat all remaining arguments as filenames.\n"
 "\n"
 "A list of available backends can be obtained using `-g help'.\n"
@@ -97,6 +100,24 @@ void usage(char *cmd)
   exit (0);
 }
 
+/*! \brief Print version info and exit.
+ * \par Function Description
+ * Print gEDA version, and copyright/warranty notices, and exit with
+ * exit status 0.
+ */
+static void
+version ()
+{
+  printf(
+"gEDA %s (g%.7s)\n"
+"Copyright (C) 1998-2011 gEDA developers\n"
+"This is free software, and you are welcome to redistribute it under\n"
+"certain conditions. For details, see the file `COPYING', which is\n"
+"included in the gEDA distribution.\n"
+"There is NO WARRANTY, to the extent permitted by law.\n",
+         PACKAGE_DOTTED_VERSION, PACKAGE_GIT_COMMIT);
+  exit (0);
+}
 
 /* from guile (libguile/gh_init.c) */
 static SCM
@@ -194,6 +215,10 @@ int parse_commandline(int argc, char *argv[])
 	    usage(argv[0]);
 	    break;
 
+	case 'V':
+          version();
+          break;
+
 	case '?':
 	default:
 	    usage(argv[0]);

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

    gnetlist: Improve `--help' usage message.

diff --git a/gnetlist/src/parsecmd.c b/gnetlist/src/parsecmd.c
index 9d48849..3cc7720 100644
--- a/gnetlist/src/parsecmd.c
+++ b/gnetlist/src/parsecmd.c
@@ -67,26 +67,34 @@ struct option long_options[] =
 
 void usage(char *cmd)
 {
-    printf("Usage: %s [OPTIONS] filename1 ... filenameN\n", cmd);
-    printf("  -e  --embedd       Force embedding contents of .include file (spice-sdb)\n");
-    printf("  -h  --help         Print this help string\n");
-    printf("  -i                 Interactive scheme mode\n");
-    printf("  -I  --include      Put .INCLUDE <filename> in output file instead\n");
-    printf("                     of model file's contents (spice-sdb)\n");
-    printf("  -q                 Quiet mode\n");
-    printf("  -l  filename       Load scheme file before loading backend\n");
-    printf("  -m  filename       Load scheme file after loading backend,\n");
-    printf("                     but still before executing procedure\n");
-    printf("  -n  --nomunge      Don't autocorrect refdeses (spice-sdb)\n");
-    printf("  -g  proc           Scheme procedure (netlister backend) to execute.\n");
-    printf("                     Use '-g help' to list available backends.\n");
-    printf("  -o  filename       Output netlist filename\n");
-    printf("  -c  string         Execute string as a scheme script\n");
-    printf("  -O  option         Pass the given option to the backend\n");
-    printf("  -v  --verbose      Verbose mode on\n");
-    printf("  -s  --sort         Sort output netlist (spice-sdb)\n");
-    printf("\n");
-    exit(0);
+  printf (
+"Usage: %s [OPTION ...] [-g BACKEND] [--] FILE ...\n"
+"\n"
+"Generate a netlist from one or more gEDA schematic FILEs.\n"
+"\n"
+"General options:\n"
+"  -q              Quiet mode.\n"
+"  -v, --verbose   Verbose mode.\n"
+"  -g BACKEND      Specify netlist backend to use.\n"
+"  -O STRING       Pass an option string to backend.\n"
+"  -l FILE         Load Scheme file before loading backend.\n"
+"  -m FILE         Load Scheme file after loading backend.\n"
+"  -c EXPR         Evaluate Scheme expression at startup.\n"
+"  -i              Enter interactive Scheme REPL after loading.\n"
+"  -h, --help      Help; this message.\n"
+"  --              Treat all remaining arguments as filenames.\n"
+"\n"
+"A list of available backends can be obtained using `-g help'.\n"
+"\n"
+"Backend-specific options:\n"
+"  -e, --embedd    Force embedding of .include file contents (spice-sdb).\n"
+"  -n, --nomunge   Do not autocorrect component refdes (spice-sdb).\n"
+"  -s, --sort      Sort output netlist (spice-sdb).\n"
+"\n"
+"Report bugs to <geda-bug@xxxxxxxx>.\n"
+"gEDA/gaf homepage: <http://gpleda.org>\n",
+           cmd);
+  exit (0);
 }
 
 

commit 19dcc79af1e7a43e1b28e8378a5c1cd4392137f2
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Update man page.

diff --git a/gnetlist/docs/gnetlist.1 b/gnetlist/docs/gnetlist.1
index 6eeacd5..17b4a20 100644
--- a/gnetlist/docs/gnetlist.1
+++ b/gnetlist/docs/gnetlist.1
@@ -1,223 +1,260 @@
-.TH gnetlist 1 "February 14th, 2010" Version 1.6.1.20100214
+.TH gnetlist 1 "January 5th, 2011" "gEDA Project" 1.6.1.20100214
 .SH NAME
-gnetlist - gEDA/gaf Netlist extraction/generation
+gnetlist - gEDA/gaf Netlist Extraction and Generation
 .SH SYNOPSIS
 .B gnetlist
-[\-e] [\-i] [\-I] [\-q] [\-s] [\-v] [\-l schem_file] [\-m schem_file ] [\-n] [ \-O option ] [\-h | \-\-help] [\-g guile_procedure] [\-c scheme_string ] [\-o output_filename] schematic1 [... schematicN]
+[\fIOPTION\fR ...] [\fB-g\fR \fIBACKEND\fR] [\fI--\fR] \fIFILE\fR ...
+
 .SH DESCRIPTION
 .PP
-\fIgnetlist\fP is the netlist extraction/generation program which is part gEDA 
-(GPL Electronic Design Automation) toolset.  This program takes a schematic
-for its input and outputs a netlist.  
-
-gnetlist depends heavily on guile (a scheme based scripting language).  It 
-uses guile to define the output format.  Basically gnetlist reads a schematic,
-creates an internal representation of the various connections, and then a
-guile script extracts the connections into some netlist format.  
-
-gnetlist is very much so a work in progress.  Currently it supports the
-following backends: 
-
-.IP \[bu] 2 
-Allegro netlist format (\-g allegro)
-.IP \[bu]
-BOM / BOM2 - Bill of Materials (\-g bom and \-g bom2)
-.IP \[bu]
-Partslist 1,2,3 - More Bill of Materials (\-g partslist[1-3])
-.IP \[bu]
-DRC - Start of a design rule checker (\-g drc)
-.IP \[bu]
-DRC2 - A second design rule checker (\-g drc2)
-.IP \[bu]
-gEDA - native format, mainly used for testing (\-g geda)
-.IP \[bu]
-Gossip netlist format (\-g gossip)
-.IP \[bu]
-PADS netlist format (\-g pads)
-.IP \[bu]
-PCB / PCBboard (\-g PCB and \-g PCBboard)
-.IP \[bu]
-PCB actions file for forward annotating pin/pad names from
-schematic to layout (\-g pcbpins)
-.IP \[bu]
-gsch2pcb backend (\-g gsch2pcb)
-.IP \[bu]
-ProtelII netlist format (\-g protelII)
-.IP \[bu]
-Spice compatible netlist format (\-g spice)
-.IP \[bu]
-Enhanced spice compatible netlist format (\-g spice-sdb)
-.IP \[bu]
-Tango netlist format (\-g tango)
-.IP \[bu]
-Verilog code (\-g verilog)
-.IP \[bu]
-VHDL code (\-g vhdl)
-.IP \[bu]
-VIPEC netlist format (\-g vipec)
-.IP \[bu]
-Bartels Autoengineer netlist format (\-g bae)
-.IP \[bu]
-GOSSIP system simulation system netlist format (\-g gossip)
-.IP \[bu]
-MAXASCII netlist format (\-g maxascii)
-.IP \[bu]
-VHDL-AMS netlist format (\-g vams)
-.IP \[bu]
-Futurenet2 netlist format (\-g futurenet2)
-.IP \[bu]
-SWITCAP switched capacitor simulator netlist format (\-g switcap)
-.IP \[bu]
-RF Cascade netlist format (\-g cascade)
-.IP \[bu]
-RACAL-REDAC netlist format (\-g redac)
-.IP \[bu]
-SystemC netlist backend (\-g systemc)
-.IP \[bu]
-Calay format netlist backend (\-g calay)
-.IP \[bu]
-Osmond format netlist backend (\-g osmond)
-.IP \[bu]
-Eagle netlist format (\-g eagle)
-.IP \[bu]
-Netlister for symbolic circuit analysis using Mathematica (\-g mathematica)
-.IP \[bu]
-LiquidPCB format netlist backend (\-g liquidpcb)
-
-For more info on these formats please look at the README.*
-
-Please read the official documentation on how to use
-gnetlist, since this man page just describes the command line arguments
-and a few examples on how to run gnetlist.
-
-.SH OPTIONS
-\fIgnelist\fP accepts the following options:
-.TP 8
-.B -q
-Quiet mode on.  This mode turns off all warnings/notes/messages. (optional)
-.TP 8
-.B -v 
-Verbose mode on.  This mode gives as much feedback to the user as possible. (optional)
-.TP 8
-.B -g guile_procedure
-Specify the guile procedure which is executed to create the netlist. Use "\-g help" to display a list of available backends.
-.TP 8
-.B -o output_filename
-Specify the filename which will contain the netlist generated by gnetlist.  If this option is not specified the default filename is "output.net".
-.TP 8
-.B -l scheme_file
-Specify a filename which contains scheme code to be loaded and
-execute before any backend is loaded or any guile procedure (using \-g flag) 
-is executed.  This flag can be specified multiple times and can be used to 
-pass information to backends.
-.TP 8
-.B -e, --embed 
-Force embedding contents of .include file when using the spice-sdb backend.
-.TP 8
-.B -O string
-Pass the given option to the specified backend.
-.TP 8
-.B -m scheme_file
-Specify a filename which contains scheme code to be loaded and
-execute after the backend is loaded but still before any guile procedure 
-(using \-g flag) is executed.  This flag can be specified multiple times 
-and can be used to pass information to backends.  This flag, for example, 
-allows the user to override variables inside of the backends (such as paths).
-.TP 8
-.B -n, --nomunge
-Do not autocorrect the refdes attributes.  Only applies to the spice-sdb backend.
-.TP 8
-.B -c string
-Pass the specified string to the guile interpreter.  This allows you to 
-execute arbitrary guile scripts from the command line.  Be sure to surround
-the string with either single or double quotes to satisfy your shell.  The
-string is execute before any init or netlist backend scheme code is
-loaded or executed.
-.TP 8
-.B -I, --include 
-Put .INCLUDE <filename> in output file instead of model file's contents.
+
+\fBgnetlist\fR is a netlist extraction and generation tool, and is
+part of the gEDA (GPL Electronic Design Automation) toolset.  It takes
+one or electronic schematics as input, and outputs a netlist.  A
+netlist is a machine-interpretable description of the way that
+components in an electronic circuit are connected together, and is
+commonly used as the input to a PCB layout program such as
+\fBpcb\fR(1) or to a simulator such as \fBgnucap\fR(1).
+
+A normal \fBgnetlist\fR run is carried out in two steps.  First, the
+\fBgnetlist\fR frontend loads the specified human-readable schematic
+\fIFILE\fRs, and compiles them to an in-memory netlist description.
+Next, a `backend' is used to export the connection and component data
+to one of many supported netlist formats.
+
+\fBgnetlist\fR is extensible, using the Scheme programming language.
+
+.SH GENERAL OPTIONS
+.TP 8
+\fB-q\fR
+Quiet mode. Turns off all warnings/notes/messages.
+.TP 8
+\fB-v\fR, \fB--verbose\fR
+Verbose mode.  Output all diagnostic information.
+.TP 8
+\fB-g\fR \fIBACKEND\fR
+Specify the backend to be used. Use `\-g help' to display a list of
+available backends.
 .TP 8
-.B -h, --help
-Print out short command line help.
+\fB-O\fR \fISTRING\fR
+Pass an option string to the backend.
 .TP 8
-.B -i 
-Interactive mode.  After the schematic is read in and parsed then go into 
-interactive mode.  Interactive mode allows the user to execute guile 
-procedures directly. 
+\fB-o\fR \fIFILE\fR
+Specify the filename for the generated netlist.  By default, output is
+directed to `output.net'.
 .TP 8
-.B -s 
-Sort output netlist (for Gnucap)
+\fB-l\fR \fIFILE\fR
+Specify a Scheme file to be loaded before the backend is loaded or
+executed.  This option can be specified multiple times.
 .TP 8
-schematic1 [... schematicN]
-At least one schematic file must be specified.  If multiple schematics are 
-specified then they are sequentially read in and parsed with the assumption 
-that they are all part of the same design.  It is important that the 
-schematic(s) follow all the options (ie last).
+\fB-m\fR \fIFILE\fR
+Specify a Scheme file to be loaded between loading the backend and
+executing it.  This option can be specified multiple times.
+.TP 8
+\fB-c\fR \fIEXPR\fR
+Specify a Scheme expression to be executed during \fBgnetlist\fR
+startup.  This option can be specified multiple times.
+.TP 8
+\fB-i\fR
+After the schematic files have been loaded and compiled, and after all
+Scheme files have been loaded, but before running the backend, enter a
+Scheme read-eval-print loop.
+.TP 8
+\fB-h\fR, \fB--help\fR
+Print a help message.
+.TP 8
+\fB--\fR
+Treat all remaining arguments as schematic filenames.  Use this if you
+have a schematic filename which begins with `-'.
 
-.SH EXAMPLES 
-These examples assume that you have a stack_1.sch in the current directory.
+.SH BACKEND-SPECIFIC OPTIONS
+.PP
+The following options are ignored unless using the `spice-sdb' backend:
+.TP 8
+\fB-e\fR, \fB--embedd\fR
+Force embedding contents of `.include' files.
+.TP 8
+\fB-n\fR, \fB--nomunge\fR
+Do not autocorrect the refdes attributes.
+.TP 8
+\fB-I\fR, \fB--include\fR
+Put .INCLUDE <filename> in output file instead of model file's contents.
+.TP 8
+\fB-s\fR
+Sorts netlist output for better compatibility with \fBgnucap\fR(1).
+Equivalent to `-O sort_mode'.
 
-gnetlist requires that at least one schematic to be specified on the command line:
+.SH BACKENDS
+.PP
+Currently, \fBgnetlist\fR includes the following backends:
 
-.nf
-	./gnetlist stack_1.sch 
-.ad b 
+.TP 8
+\fBallegro\fR
+Allegro netlist format.
+.TP 8
+\fBbae\fR
+Bartels Autoengineer netlist format.
+.TP 8
+\fBbom\fR, \fBbom2\fR
+Bill of materials generation.
+.TP 8
+\fBcalay\fR
+Calay netlist format.
+.TP 8
+\fBcascade\fR
+RF Cascade netlist format
+.TP 8
+\fBdrc\fR, \fBdrc2\fR
+Design rule checkers (\fBdrc2\fR is recommended).
+.TP 8
+\fBeagle\fR
+Eagle netlist format.
+.TP 8
+\fBfuturenet2\fR
+Futurenet2 netlist format.
+.TP 8
+\fBgeda\fR
+Native gEDA netlist format (mainly used for testing and diagnostics).
+.TP 8
+\fBgossip\fR
+Gossip netlist format.
+.TP 8
+\fBgsch2pcb\fR
+Backend used for \fBpcb\fR(1) file layout generation by
+\fBgsch2pcb\fR(1).  It is not recommended to use this backend
+directly.
+.TP 8
+\fBliquidpcb\fR
+LiquidPCB netlist format.
+.TP 8
+\fBmathematica\fR
+Netlister for analytical circuit solving using Mathematica.
+.TP 8
+\fBmaxascii\fR
+MAXASCII netlist format.
+.TP 8
+\fBosmond\fR
+Osmond netlist format.
+.TP 8
+\fBpads\fR
+PADS netlist format.
+.TP 8
+\fBpartslist1\fR, \fBpartslist2\fR, \fBpartslist3\fR
+Bill of materials generation backends (alternatives to \fBbom\fR and
+\fBbom2\fR).
+.TP 8
+\fBPCB\fR
+\fBpcb\fR(1) netlist format.
+.TP 8
+\fBpcbpins\fR
+Generates a \fBpcb\fR(1) action file for forward annotating pin/pad
+names from schematic to layout.
+.TP 8
+\fBprotelII\fR
+Protel II netlist format.
+.TP 8
+\fBredac\fR
+RACAL-REDAC netlist format.
+.TP 8
+\fBspice\fR, \fBspice-sdb\fR
+SPICE-compatible netlist format (\fBspice-sdb\fR is recommended).
+Suitable for use with \fBgnucap\fR(1).
+.TP 8
+\fBswitcap\fR
+SWITCAP switched capacitor simulator netlist format.
+.TP 8
+\fBsystemc\fR
+Structural SystemC code generation.
+.TP 8
+\fBtango\fR
+Tango netlist format.
+.TP 8
+\fBvams\fR
+VHDL-AMS code generation.
+.TP 8
+\fBverilog\fR
+Verilog code generation.
+.TP 8
+\fBvhdl\fR
+VHDL code generation.
+.TP 8
+\fBvipec\fR
+ViPEC Network Analyser netlist format.
 
-This is not very useful since it does not direct gnetlist to do 
-anything.  
 
-Specify a guile procedure name to get gnetlist to output a netlist:
+.SH EXAMPLES
+.PP
+These examples assume that you have a `stack_1.sch' in the current directory.
+.PP
+\fBgnetlist\fR requires that at least one schematic to be specified on the
+command line:
 
 .nf
-	./gnetlist \-g geda stack_1.sch 
-.ad b 
+	./gnetlist stack_1.sch
+.ad b
 
-The netlist output will be written to a file called "output.net" 
-in the current working directory.
-
-You can specify the output filename by using the \-o flag:
+.PP
+This is not very useful since it does not direct \fBgnetlist\fR to do
+anything.
+.PP
+Specify a backend name with `\-g' to get \fBgnetlist\fR to output a
+netlist:
 
 .nf
-	./gnetlist \-g geda stack_1.sch \-o stack.netlist
-.ad b 
+	./gnetlist \-g geda stack_1.sch
+.ad b
 
-The spice backend is run against the schematic(s) if you specify 
-\-g spice and the tango backend is run if you specify \-g tango.
+.PP
+The netlist output will be written to a file called `output.net'
+in the current working directory.
 
-To interact with the guile interpreter:
+.PP
+You can specify the output filename by using the `\-o' option:
 
 .nf
-	./gnetlist \-i stack_1.sch 
-.ad b 
+	./gnetlist \-g geda stack_1.sch \-o /tmp/stack.netlist
+.ad b
 
-You will get a prompt where you can execute guile procedures.
+.PP
+Output will now be directed to `/tmp/stack.netlist'.
 
-To get a more verbose feedback as to what gnetlist is doing run 
-with the \-v flag:
+.PP
+You could run (for example) the `spice-sdb' backend against the
+schematic if you specified `\-g spice-sdb', or you could generate a
+bill of materials for the schematic using `\-g partslist1'.
+
+.PP
+To obtain a Scheme prompt to run Scheme expressions directly, you can
+use the `\-i' option.
 
 .nf
-	./gnetlist \-v \-g geda stack_1.sch 
-.ad b 
+	./gnetlist \-i stack_1.sch
+.ad b
 
-.SH "ENVIRONMENT"
-\fIgnetlist\fP respects the following environment variable:
 .PP
+\fBgnetlist\fR will load `stack_1.sh', and then enter an interactive
+Scheme read-eval-print loop.
+
+.SH ENVIRONMENT
 .TP 8
-.B GEDADATA 
-Specifies where the various required scheme and rc files are located
-(the default is ${prefix}/share/gEDA).  This environment variables does
-not need to be set by the end user unless they are moving the executables
-to a new install ${prefix}.
+.B GEDADATA
+specifies the search directory for Scheme and rc files.  The default
+is `${prefix}/share/gEDA'.
+.TP 8
+.B GEDADATARC
+specifies the search directory for rc files.  The default is `$GEDADATA'.
 
-.SH "AUTHOR"
-Ales Hvezda and many others
+.SH AUTHORS
+See the `AUTHORS' file included with this program.
 
-.SH SEE ALSO
-.BR gschem (1),
-.BR gsymcheck (1)
 .SH COPYRIGHT
-Copyright \(co  1999-2008 Ales Hvezda
-
-This document can be freely redistributed according to the terms of the 
-GNU General Public License version 2.0.
+.nf
+Copyright \(co 1999-2011 gEDA Contributors.  License GPLv2+: GNU GPL
+version 2 or later.  Please see the `COPYING' file included with this
+program for full details.
+.PP
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
 
+.SH SEE ALSO
+\fBgschem\fR(1), \fBgsymcheck\fR(1), \fBpcb\fR(1), \fBgnucap\fR(1)

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

    gnetlist: Rename partslist backends' common functions file.
    
    Rename partslist backend common functions file so it doesn't show up
    in the output of `gnetlist -ghelp'.

diff --git a/gnetlist/scheme/Makefile.am b/gnetlist/scheme/Makefile.am
index dcbc582..66a1cd8 100644
--- a/gnetlist/scheme/Makefile.am
+++ b/gnetlist/scheme/Makefile.am
@@ -14,7 +14,7 @@ DIST_SCM = gnet-PCB.scm gnet-allegro.scm gnet-bom.scm gnet-geda.scm \
            gnet-pads.scm gnetlist.scm gnetlist-post.scm \
            gnet-bae.scm gnet-protelII.scm \
            gnet-bom2.scm gnet-gossip.scm gnet-drc.scm gnet-vams.scm \
-	   gnet-partslist-common.scm gnet-partslist1.scm \
+	   partslist-common.scm gnet-partslist1.scm \
 	   gnet-partslist2.scm gnet-partslist3.scm gnet-maxascii.scm \
 	   gnet-switcap.scm gnet-spice-sdb.scm gnet-drc2.scm \
 	   gnet-futurenet2.scm gnet-cascade.scm \
diff --git a/gnetlist/scheme/gnet-partslist-common.scm b/gnetlist/scheme/gnet-partslist-common.scm
deleted file mode 100644
index eac539e..0000000
--- a/gnetlist/scheme/gnet-partslist-common.scm
+++ /dev/null
@@ -1,73 +0,0 @@
-; Copyright (C) 2001-2010 MIYAMOTO Takanori
-; gnet-partslist-common.scm
-; 
-; This program is free software; you can redistribute it and/or modify
-; it under the terms of the GNU General Public License as published by
-; the Free Software Foundation; either version 2 of the License, or
-; (at your option) any later version.
-; 
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-; GNU General Public License for more details.
-; 
-; You should have received a copy of the GNU General Public License
-; along with this program; if not, write to the Free Software
-; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
-
-(define (get-parts-table packages)
-  (if (null? packages)
-      '()
-      (let ((package (car packages)))
-	(if (string=? (get-device package) "include")
-	    (get-parts-table (cdr packages))
-	    (cons (list package
-			(get-device package)
-			(get-value package)  
-			(gnetlist:get-package-attribute package "footprint")) ;; sdb change
-		  (get-parts-table (cdr packages)))))))
-
-(define (write-one-row ls separator end-char port)
-  (if (null? ls)
-      '()
-      (begin (display (car ls) port)
-	     (for-each (lambda (st) (display separator port)(display st port)) (cdr ls))
-	     (display end-char port))))
-
-(define (get-sortkey-value ls key-column)
-  (list-ref (car ls) key-column))
-
-(define (marge-sort-sub ls1 ls2 key-column)
-  (if (or (null? ls1) (null? ls2))
-      (append ls1 ls2)
-      (if (string-ci<=? (get-sortkey-value ls1  key-column) (get-sortkey-value ls2 key-column))
-	  (cons (car ls1) (marge-sort-sub (cdr ls1) ls2 key-column))
-	  (cons (car ls2) (marge-sort-sub ls1 (cdr ls2) key-column)))))
-
-(define (marge-sort ls key-column)
-  (let ((midpoint (inexact->exact (floor (/ (length ls) 2)))))
-    (if (<= (length ls) 1)
-	(append ls)
-	(let ((top-half (reverse (list-tail (reverse ls) midpoint)))
-	      (bottom-half (list-tail ls (- (length ls) midpoint))))
-	  (set! top-half (marge-sort top-half key-column))
-	  (set! bottom-half (marge-sort bottom-half key-column))
-	  (marge-sort-sub top-half bottom-half key-column)))))
-
-(define (marge-sort-with-multikey ls key-columns)
-  (if (or (<= (length ls) 1) (null? key-columns))
-      (append ls)
-      (let* ((key-column (car key-columns))
-	     (sorted-ls (marge-sort ls key-column))
-	     (key-column-only-ls 
-	      ((lambda (ls) (let loop ((l ls))
-			      (if (null? l)
-				  '()
-				  (cons (get-sortkey-value l key-column) (loop (cdr l))))))
-	       sorted-ls))
-	     (first-value (get-sortkey-value sorted-ls key-column))
-	     (match-length (length (member first-value (reverse key-column-only-ls))))
-	     (first-ls (list-tail (reverse sorted-ls) (- (length sorted-ls) match-length)))
-	     (rest-ls (list-tail sorted-ls match-length)))
-	(append (marge-sort-with-multikey first-ls (cdr key-columns))
-		(marge-sort-with-multikey rest-ls key-columns)))))
diff --git a/gnetlist/scheme/gnet-partslist1.scm b/gnetlist/scheme/gnet-partslist1.scm
index a8a21cf..172fbcc 100644
--- a/gnetlist/scheme/gnet-partslist1.scm
+++ b/gnetlist/scheme/gnet-partslist1.scm
@@ -16,7 +16,7 @@
 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
 
 ; The /'s may not work on win32
-(load (string-append gedadata "/scheme/gnet-partslist-common.scm"))
+(load (string-append gedadata "/scheme/partslist-common.scm"))
 
 (define partslist1:write-top-header
   (lambda (port)
diff --git a/gnetlist/scheme/gnet-partslist2.scm b/gnetlist/scheme/gnet-partslist2.scm
index 10a54f5..ca54119 100644
--- a/gnetlist/scheme/gnet-partslist2.scm
+++ b/gnetlist/scheme/gnet-partslist2.scm
@@ -16,7 +16,7 @@
 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
 
 ; The /'s may not work on win32
-(load (string-append gedadata "/scheme/gnet-partslist-common.scm"))
+(load (string-append gedadata "/scheme/partslist-common.scm"))
 
 (define partslist2:write-top-header
   (lambda (port)
diff --git a/gnetlist/scheme/gnet-partslist3.scm b/gnetlist/scheme/gnet-partslist3.scm
index 8b450f9..14f25dd 100644
--- a/gnetlist/scheme/gnet-partslist3.scm
+++ b/gnetlist/scheme/gnet-partslist3.scm
@@ -16,7 +16,7 @@
 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
 
 ; The /'s may not work on win32
-(load (string-append gedadata "/scheme/gnet-partslist-common.scm"))
+(load (string-append gedadata "/scheme/partslist-common.scm"))
 
 (define partslist3:write-top-header
   (lambda (port)
diff --git a/gnetlist/scheme/partslist-common.scm b/gnetlist/scheme/partslist-common.scm
new file mode 100644
index 0000000..eac539e
--- /dev/null
+++ b/gnetlist/scheme/partslist-common.scm
@@ -0,0 +1,73 @@
+; Copyright (C) 2001-2010 MIYAMOTO Takanori
+; gnet-partslist-common.scm
+; 
+; This program is free software; you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation; either version 2 of the License, or
+; (at your option) any later version.
+; 
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+; GNU General Public License for more details.
+; 
+; You should have received a copy of the GNU General Public License
+; along with this program; if not, write to the Free Software
+; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+
+(define (get-parts-table packages)
+  (if (null? packages)
+      '()
+      (let ((package (car packages)))
+	(if (string=? (get-device package) "include")
+	    (get-parts-table (cdr packages))
+	    (cons (list package
+			(get-device package)
+			(get-value package)  
+			(gnetlist:get-package-attribute package "footprint")) ;; sdb change
+		  (get-parts-table (cdr packages)))))))
+
+(define (write-one-row ls separator end-char port)
+  (if (null? ls)
+      '()
+      (begin (display (car ls) port)
+	     (for-each (lambda (st) (display separator port)(display st port)) (cdr ls))
+	     (display end-char port))))
+
+(define (get-sortkey-value ls key-column)
+  (list-ref (car ls) key-column))
+
+(define (marge-sort-sub ls1 ls2 key-column)
+  (if (or (null? ls1) (null? ls2))
+      (append ls1 ls2)
+      (if (string-ci<=? (get-sortkey-value ls1  key-column) (get-sortkey-value ls2 key-column))
+	  (cons (car ls1) (marge-sort-sub (cdr ls1) ls2 key-column))
+	  (cons (car ls2) (marge-sort-sub ls1 (cdr ls2) key-column)))))
+
+(define (marge-sort ls key-column)
+  (let ((midpoint (inexact->exact (floor (/ (length ls) 2)))))
+    (if (<= (length ls) 1)
+	(append ls)
+	(let ((top-half (reverse (list-tail (reverse ls) midpoint)))
+	      (bottom-half (list-tail ls (- (length ls) midpoint))))
+	  (set! top-half (marge-sort top-half key-column))
+	  (set! bottom-half (marge-sort bottom-half key-column))
+	  (marge-sort-sub top-half bottom-half key-column)))))
+
+(define (marge-sort-with-multikey ls key-columns)
+  (if (or (<= (length ls) 1) (null? key-columns))
+      (append ls)
+      (let* ((key-column (car key-columns))
+	     (sorted-ls (marge-sort ls key-column))
+	     (key-column-only-ls 
+	      ((lambda (ls) (let loop ((l ls))
+			      (if (null? l)
+				  '()
+				  (cons (get-sortkey-value l key-column) (loop (cdr l))))))
+	       sorted-ls))
+	     (first-value (get-sortkey-value sorted-ls key-column))
+	     (match-length (length (member first-value (reverse key-column-only-ls))))
+	     (first-ls (list-tail (reverse sorted-ls) (- (length sorted-ls) match-length)))
+	     (rest-ls (list-tail sorted-ls match-length)))
+	(append (marge-sort-with-multikey first-ls (cdr key-columns))
+		(marge-sort-with-multikey rest-ls key-columns)))))

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

    gschem: Provide long-form options and update man page.
    
    Make gschem support long-form alternatives for several command-line
    options.  Additionally, make some further improvements to the gschem man page.

diff --git a/NEWS b/NEWS
index 9cd263d..020b04c 100644
--- a/NEWS
+++ b/NEWS
@@ -10,8 +10,14 @@ more information, please consult the `ChangeLog' file.
 Notable changes in gEDA/gaf 1.7.0
 =================================
 
-* `gschem' no longer supports the `-t' option. It supports a new `-V'
-  option to display version information.
+* Several changes to `gschem' command-line options:
+
+  - The `-t' option is no longer supported.
+
+  - Several command-line options now support a long-form alternative.
+
+  - A new `-V' or `--version' option is available, which displays
+    version information.
 
 * `gschem' now provides a "Select All" function, which is bound to
   <Control a> by default.
diff --git a/gschem/docs/gschem.1 b/gschem/docs/gschem.1
index 1412c42..9c4d184 100644
--- a/gschem/docs/gschem.1
+++ b/gschem/docs/gschem.1
@@ -1,9 +1,9 @@
-.TH gschem 1 "February 14th, 2010" "gEDA Project" 1.6.1.20100214
+.TH gschem 1 "January 5th, 2010" "gEDA Project" 1.6.1.20100214
 .SH NAME
 gschem - gEDA/gaf Schematic Capture
 .SH SYNOPSIS
 .B gschem
-[\fIOPTION\fR ...] [\fIFILE\fR ...]
+[\fIOPTION\fR ...] [\fI--\fR] [\fIFILE\fR ...]
 .SH DESCRIPTION
 .PP
 .B gschem
@@ -23,53 +23,56 @@ schematics.
 
 .SH OPTIONS
 .TP 8
-.B -q
+\fB-q\fR, \fB--quiet\fR
 Quiet mode. Turn off all warnings/notes/messages.
 .TP 8
-.B -v
+\fB-v\fR, \fB--verbose\fR
 Verbose mode.  Output all diagnostic information.
 .TP 8
-.B -r filename
-Specify a rc filename.  Normally
-.B gschem
+\fB-r\fR, \fB--config-file\fR=\fIFILE\fR
+Specify an additional configuration file.  Normally \fBgschem\fR
 searches for the system configuration file, then
 `$HOME/.gEDA/gschemrc', and finally for a `gschemrc' file in the
 current working directory.  This option allows the user to specify an
 additional rc file which is read after all the other rc files have
 been are read.
 .TP 8
-.B -s filename
+\fB-s\fR \fIFILE\fR
 Specify a Scheme script to be executed at startup.
 .TP 8
-.B -o filename
+\fB-o\fR, \fB--output\fR=\fIFILE\fR
 Specify a filename for PostScript output.  This command line argument
-is useful when running
-.B gschem
-from a shell script and with a Scheme script.  The filename can be
-changed through the print dialog box.
+is useful when running \fBgschem\fR from a shell script and with a
+Scheme script.  The filename can be changed through the print dialog
+box.
 .TP 8
-.B -p
-Automatically place the window. This may be useful if running gschem
+\fB-p\fR
+Automatically place the window. This may be useful if running \fBgschem\fR
 from the command line and generating output.
 .TP 8
-.B -h
+\fB-h\fR, \fB--help\fR
 Print a help message.
 .TP 8
-.B -V
-Print
-.B gschem
-version information.
+\fB-V\fR, \fB--version\fR
+Print \fBgschem\fR version information.
+.TP 8
+\fB--\fR
+Treat all remaining arguments as schematic or symbol filenames.  Use
+this if you have a schematic or symbol filename which begins with `-'.
 
 .SH SCHEMATIC AND SYMBOL FILES
-Optionally, schematic or symbol filenames may be specified on the
+Optionally, schematic or symbol \fIFILE\fRs may be specified on the
 command line.  Any schematic or symbols specified are loaded at
 startup as separate documents in the schematic editor.
+.PP
+If no \fIFILE\fRs are specified, a blank schematic is created for
+editing.
 
 .SH ENVIRONMENT
 .TP 8
 .B GEDADATA
 specifies the search directory for Scheme and rc files.  The default
-is `${prefix}/share/gEDA').
+is `${prefix}/share/gEDA'.
 .TP 8
 .B GEDADATARC
 specifies the search directory for rc files.  The default is `$GEDADATA'.
@@ -79,7 +82,7 @@ See the `AUTHORS' file included with this program.
 
 .SH COPYRIGHT
 .nf
-Copyright \(co 1999-2010 gEDA Contributors.  License GPLv2+: GNU GPL
+Copyright \(co 1999-2011 gEDA Contributors.  License GPLv2+: GNU GPL
 version 2 or later.  Please see the `COPYING' file included with this
 program for full details.
 .PP
@@ -87,8 +90,7 @@ This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
 
 .SH SEE ALSO
-.BR gnetlist (1)
-.BR gsymcheck (1)
+\fBgnetlist\fR(1), \fBgsymcheck\fR(1)
 .PP
 The full documentation for
 .B gschem
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 9b56955..0fd4df2 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -713,7 +713,6 @@ void o_undo_callback(GSCHEM_TOPLEVEL *w_current, int type);
 void o_undo_cleanup(void);
 void o_undo_remove_last_undo(GSCHEM_TOPLEVEL *w_current);
 /* parsecmd.c */
-void usage(char *cmd);
 int parse_commandline(int argc, char *argv[]);
 /* s_stretch.c */
 GList *s_stretch_add(GList *list, OBJECT *object, int whichone);
diff --git a/gschem/src/parsecmd.c b/gschem/src/parsecmd.c
index 5613dbd..d5c765b 100644
--- a/gschem/src/parsecmd.c
+++ b/gschem/src/parsecmd.c
@@ -21,6 +21,7 @@
 #include <version.h>
 
 #include <stdio.h>
+#include <ctype.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -31,39 +32,75 @@
 #include <dmalloc.h>
 #endif
 
-#define OPTIONS "hqvr:s:o:pV"
+#define GETOPT_OPTIONS "hqvr:s:o:pV"
 
 #ifndef OPTARG_IN_UNISTD
 extern char *optarg;
 extern int optind;
 #endif
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- * 
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+
+#ifdef HAVE_GETOPT_LONG
+struct option long_options[] =
+  {
+    {"help", 0, 0, 'h'},
+    {"version", 0, 0, 'V'},
+    {"quiet", 0, 0, 'q'},
+    {"verbose", 0, 0, 'v'},
+    {"config-file", 0, 0, 'r'},
+    {"output", 0, 0, 'o'},
+    {0, 0, 0, 0}
+  };
+#endif
+
+/*! \brief Print brief help message and exit.
+ * \par Function Description
+ * Print brief help message describing gschem usage & command-line
+ * options, then exit with \a exit_status.
+ *
+ * \param cmd         First element of argv (name of program as run).
  */
-void usage(char *cmd)
+static void
+usage(char *cmd)
 {
-  printf(_("Usage: %s [OPTIONS] schematic_filename1 ... schematic_filenameN\n"
-         "  -q            Quiet mode\n"
-         "  -v            Verbose mode on\n"
-         "  -r filename   Rc filename\n"
-         "  -s filename   Script (guile) filename\n"
-         "  -o filename   Output filename (for printing)\n"
-         "  -p            Automatically place the window\n"
-         "  -V            Show version information\n"
-         "  -h            Help; this message\n"
-         "\n"), cmd);
+  printf(_(
+"Usage: %s [OPTION ...] [--] [FILE ...]\n"
+"\n"
+"Interactively edit gEDA schematics or symbols.  If one or more FILEs\n"
+"are specified, open them for editing; otherwise, create a new, empty\n"
+"schematic.\n"
+"\n"
+"Options:\n"
+"  -q, --quiet              Quiet mode.\n"
+"  -v, --verbose            Verbose mode.\n"
+"  -r, --config-file=FILE   Additional configuration file to load.\n"
+"  -s FILE                  Scheme script to run at startup.\n"
+"  -o, --output=FILE        Output filename (for printing).\n"
+"  -p                       Automatically place the window.\n"
+"  -V, --version            Show version information.\n"
+"  -h, --help               Help; this message.\n"
+"  --                       Treat all remaining arguments as filenames.\n"
+"\n"
+"Report bugs to <geda-bug@xxxxxxxx>\n"
+"gEDA/gaf homepage: <http://gpleda.org>\n"),
+         cmd);
   exit(0);
 }
 
+/*! \brief Print version info and exit.
+ * \par Function Description
+ * Print gEDA version, and copyright/warranty notices, and exit with
+ * exit status 0.
+ */
 static void
 version ()
 {
   printf(_(
 "gEDA %s (g%.7s)\n"
-"Copyright (C) 1998-2010 gEDA developers\n"
+"Copyright (C) 1998-2011 gEDA developers\n"
 "This is free software, and you are welcome to redistribute it under\n"
 "certain conditions. For details, see the file `COPYING', which is\n"
 "included in the gEDA distribution.\n"
@@ -72,16 +109,24 @@ version ()
   exit (0);
 }
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- * 
+/*! \brief Parse gschem command-line options.
+ * \par Function Description
+ * Parse command line options, displaying usage message or version
+ * information as required.
+ *
+ * \param argc Number of command-line arguments.
+ * \param argv Array of command-line arguments.
+ * \return index into \a argv of first non-option argument.
  */
-int parse_commandline(int argc, char *argv[])
+int
+parse_commandline(int argc, char *argv[])
 {
   int ch;
-
-  while ((ch = getopt (argc, argv, OPTIONS)) != -1) {
+#ifdef HAVE_GETOPT_LONG
+  while ((ch = getopt_long (argc, argv, GETOPT_OPTIONS, long_options, NULL)) != -1) {
+#else
+  while ((ch = getopt (argc, argv, GETOPT_OPTIONS)) != -1) {
+#endif
     switch (ch) {
       case 'v':
         verbose_mode = TRUE;
@@ -116,9 +161,23 @@ int parse_commandline(int argc, char *argv[])
         break;
 
       case '?':
-      default:
-        usage(argv[0]);
+#ifndef HAVE_GETOPT_LONG
+        if ((optopt != ':') && (strchr (GETOPT_OPTIONS, optopt) != NULL)) {
+          fprintf (stderr,
+                   "ERROR: -%c option requires an argument.\n\n",
+                   optopt);
+        } else if (isprint (optopt)) {
+          fprintf (stderr, "ERROR: Unknown option -%c.\n\n", optopt);
+        } else {
+          fprintf (stderr, "ERROR: Unknown option character `\\x%x'.\n\n",
+                   optopt);
+        }
+#endif
+        fprintf (stderr, "\nRun `%s --help' for more information.\n", argv[0]);
+        exit (1);
         break;
+      default:
+        g_assert_not_reached ();
     }
   }
 

commit 0f9554ec1bcb37dba92a09f1b69680ca8cd3366f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gschem: Remove `-t' option from usage message.
    
    The `-t' option was removed in commit 65b79e360357, but was not
    removed from the usage message at the that time.

diff --git a/gschem/src/parsecmd.c b/gschem/src/parsecmd.c
index f948e1d..5613dbd 100644
--- a/gschem/src/parsecmd.c
+++ b/gschem/src/parsecmd.c
@@ -52,7 +52,6 @@ void usage(char *cmd)
          "  -s filename   Script (guile) filename\n"
          "  -o filename   Output filename (for printing)\n"
          "  -p            Automatically place the window\n"
-         "  -t            Print stroke information\n"
          "  -V            Show version information\n"
          "  -h            Help; this message\n"
          "\n"), cmd);

commit 7a3e9f294d12732cd6fb043412c1bf92eaf5b268
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    Make `scheme-directory' rc function prepend to Guile load path.
    
    Guile already provides infrastructure for loading Scheme files from a
    library, so this patch makes gEDA use it properly.  With this (fully
    backward-compatible) patch it's now possible to load Scheme files,
    including gnetlist backends, from more than one directory.
    
    Note: This commit makes the gnetlist test suite pass again.

diff --git a/gnetlist/src/i_vars.c b/gnetlist/src/i_vars.c
index 5acf9df..b6ced88 100644
--- a/gnetlist/src/i_vars.c
+++ b/gnetlist/src/i_vars.c
@@ -36,7 +36,6 @@
 #endif
 
 #define DEFAULT_UNTITLED_NAME    "untitled"
-#define DEFAULT_SCHEME_DIRECTORY "./"
 #define DEFAULT_BITMAP_DIRECTORY   "non-existant"
 #define DEFAULT_HIERARCHY_NETNAME_SEPARATOR "/"
 #define DEFAULT_HIERARCHY_NETATTRIB_SEPARATOR "/"
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index 9efb61d..8af89b8 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -308,11 +308,6 @@ void main_prog(void *closure, int argc, char *argv[])
   scm_c_eval_string ("(display \"hello guile\n\")");
 #endif
 
-  if (w_current->toplevel->scheme_directory == NULL) {
-    fprintf(stderr, _("Scheme directory NOT set!\n"));
-    exit(-1);
-  }
-
 
   /* Execute a script if it exists */
   if (script_filename) {
diff --git a/libgeda/include/i_vars_priv.h b/libgeda/include/i_vars_priv.h
index f660115..a1a4d4c 100644
--- a/libgeda/include/i_vars_priv.h
+++ b/libgeda/include/i_vars_priv.h
@@ -3,7 +3,6 @@ extern int default_init_right;
 extern int default_init_bottom;
 
 extern char *default_untitled_name;
-extern char *default_scheme_directory;
 extern char *default_bitmap_directory;
 extern char *default_bus_ripper_symname;
 extern char *default_postscript_prolog;
diff --git a/libgeda/include/libgeda/struct.h b/libgeda/include/libgeda/struct.h
index 2a5961e..aed0ffc 100644
--- a/libgeda/include/libgeda/struct.h
+++ b/libgeda/include/libgeda/struct.h
@@ -436,7 +436,6 @@ struct st_toplevel {
   GList *RC_list;                       /* List of RC files which have been read in. */
 
   char *untitled_name;			/* untitled sch basename */
-  char *scheme_directory; 		/* path of the scheme scripts */
   char *bitmap_directory; 		/* path of the bitmaps */
 
   int init_left, init_right; 		/* Starting values for above */
diff --git a/libgeda/lib/system-gafrc b/libgeda/lib/system-gafrc
index f238fb1..cff8371 100644
--- a/libgeda/lib/system-gafrc
+++ b/libgeda/lib/system-gafrc
@@ -17,9 +17,6 @@
 ;; The directory containing gaf Scheme code.
 (define geda-scheme-path (string-append geda-data-path path-sep "scheme"))
 ; We need to add gaf's scheme library to the Guile load path.
-(set! %load-path (append (list geda-scheme-path) %load-path))
-; This is used in some places for error messages/listing gnetlist
-; backends
 (scheme-directory geda-scheme-path)
 
 ; The libgeda Scheme library provides a number of useful functions for
diff --git a/libgeda/src/g_rc.c b/libgeda/src/g_rc.c
index 5e0bc46..75112e9 100644
--- a/libgeda/src/g_rc.c
+++ b/libgeda/src/g_rc.c
@@ -734,37 +734,37 @@ SCM g_rc_untitled_name(SCM name)
 }
 
 
-/*! \todo Finish function description!!!
- *  \brief
- *  \par Function Description
+/*! \brief Add a directory to the Guile load path.
+ * \par Function Description
+ * Prepends \a s_path to the Guile system '%load-path', after
+ * expanding environment variables.
  *
- *  \param [in] path  
- *  \return SCM_BOOL_T on success, SCM_BOOL_F otherwise.
+ *  \param [in] s_path  Path to be added.
+ *  \return SCM_BOOL_T.
  */
-SCM g_rc_scheme_directory(SCM path)
+SCM g_rc_scheme_directory(SCM s_path)
 {
-  gchar *string;
   char *temp;
+  gchar *expanded;
+  SCM s_load_path_var;
+  SCM s_load_path;
 
-  SCM_ASSERT (scm_is_string (path), path,
+  SCM_ASSERT (scm_is_string (s_path), s_path,
               SCM_ARG1, "scheme-directory");
 
   /* take care of any shell variables */
-  temp = scm_to_locale_string (path);
-  string = s_expand_env_variables (temp);
+  temp = scm_to_locale_string (s_path);
+  expanded = s_expand_env_variables (temp);
+  s_path = scm_from_locale_string (expanded);
   free (temp);
+  g_free (expanded);
 
-  /* invalid path? */
-  if (!g_file_test (string, G_FILE_TEST_IS_DIR)) {
-    fprintf (stderr,
-             "Invalid path [%s] passed to scheme-directory\n",
-             string);
-    g_free(string);
-    return SCM_BOOL_F;
-  }
+  s_load_path_var = scm_c_lookup ("%load-path");
+  s_load_path = scm_variable_ref (s_load_path_var);
+  scm_variable_set_x (s_load_path_var, scm_cons (s_path, s_load_path));
 
-  g_free(default_scheme_directory);
-  default_scheme_directory = string;
+  scm_remember_upto_here_2 (s_load_path_var, s_load_path);
+  scm_remember_upto_here_1 (s_path);
 
   return SCM_BOOL_T;
 }
diff --git a/libgeda/src/i_vars.c b/libgeda/src/i_vars.c
index c1c6897..8603e44 100644
--- a/libgeda/src/i_vars.c
+++ b/libgeda/src/i_vars.c
@@ -38,7 +38,6 @@
  * defaults used when default_... is NULL.
  */
 #define DEFAULT_UNTITLED_NAME    "untitled"
-#define DEFAULT_SCHEME_DIRECTORY "./"
 #define DEFAULT_BITMAP_DIRECTORY "../lib/bitmaps"
 #define DEFAULT_BUS_RIPPER_SYMNAME "busripper-1.sym"
 #define DEFAULT_POSTSCRIPT_PROLOG  "prolog.ps"
@@ -46,7 +45,6 @@
 int   default_init_right = WIDTH_C;
 int   default_init_bottom = HEIGHT_C;
 char *default_untitled_name = NULL;
-char *default_scheme_directory = NULL;
 char *default_bitmap_directory = NULL;
 char *default_bus_ripper_symname = NULL;
 char *default_postscript_prolog = NULL;
@@ -85,7 +83,6 @@ void i_vars_libgeda_set(TOPLEVEL *toplevel)
   /* you cannot free the default* strings here since new windows */
   /* need them */
   INIT_STR(toplevel, untitled_name   , DEFAULT_UNTITLED_NAME   );
-  INIT_STR(toplevel, scheme_directory, DEFAULT_SCHEME_DIRECTORY);
   INIT_STR(toplevel, bitmap_directory, DEFAULT_BITMAP_DIRECTORY);
   INIT_STR(toplevel, bus_ripper_symname, DEFAULT_BUS_RIPPER_SYMNAME);
   INIT_STR(toplevel, postscript_prolog,  DEFAULT_POSTSCRIPT_PROLOG);
@@ -100,7 +97,6 @@ void i_vars_libgeda_set(TOPLEVEL *toplevel)
 void i_vars_libgeda_freenames()
 {
   g_free(default_untitled_name);
-  g_free(default_scheme_directory);
   g_free(default_bitmap_directory);
   g_free(default_bus_ripper_symname);
   g_free(default_postscript_prolog);
diff --git a/libgeda/src/s_toplevel.c b/libgeda/src/s_toplevel.c
index 60356f0..27e03b5 100644
--- a/libgeda/src/s_toplevel.c
+++ b/libgeda/src/s_toplevel.c
@@ -48,7 +48,6 @@ TOPLEVEL *s_toplevel_new (void)
   toplevel->RC_list = NULL;
 
   toplevel->untitled_name      = NULL;
-  toplevel->scheme_directory   = NULL;
   toplevel->bitmap_directory   = NULL;
 
   toplevel->init_left = 0;
@@ -160,7 +159,6 @@ void s_toplevel_delete (TOPLEVEL *toplevel)
   }
 
   g_free (toplevel->untitled_name);
-  g_free (toplevel->scheme_directory);
   g_free (toplevel->bitmap_directory);
   g_free (toplevel->bus_ripper_symname);
   

commit 258eb0591088a064631c1736b2c3f86aa9e07856
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    gnetlist: Load Scheme from Guile load path, not `scheme-directory'.
    
    gnetlist now searches for Scheme files to load using the Guile load
    path, rather than TOPLEVEL.scheme_directory.
    
    Additionally, the `-g help' option now outputs the list of know
    backends in a single column rather than in three columns.
    
    Note: in this commit the gnetlist testsuite does not pass.

diff --git a/gnetlist/src/gnetlist.c b/gnetlist/src/gnetlist.c
index 72680cc..56cf008 100644
--- a/gnetlist/src/gnetlist.c
+++ b/gnetlist/src/gnetlist.c
@@ -45,8 +45,6 @@
 #include <dmalloc.h>
 #endif
 
-#define BACKEND_LIST_COLS      3
-
 void gnetlist_quit(void)
 {
     s_clib_free();
@@ -58,53 +56,82 @@ void gnetlist_quit(void)
     g_slist_free (backend_params);
 }
 
-/** @brief Prints a list of all installed gnetlist backends to standard output.
+
+/* \brief Print a list of available backends.
+ * \par Function Description
+ * Prints a list of available gnetlist backends by searching for files
+ * in each of the directories in the current Guile %load-path.  A file
+ * is considered to be a gnetlist backend if its basename begins with
+ * "gnet-" and ends with ".scm".
  *
- * @param current Pointer to the toplevel struct.
+ * \param pr_current  Current #TOPLEVEL structure.
  */
-void gnetlist_backends(TOPLEVEL *current)
+void
+gnetlist_backends (TOPLEVEL *pr_current)
 {
-    DIR *schemedir;
-    struct dirent *entry;
-    char *filename;
-    int n;
-
-    schemedir=opendir(current->scheme_directory);
-    if(schemedir==NULL) {
-        fprintf(stderr, "\nERROR! Can't open directory %s: %s\n",
-                        current->scheme_directory,
-                        strerror(errno));
-        return;
+  SCM s_load_path;
+  GList *backend_names = NULL, *iter = NULL;
+
+  /* Look up the current Guile %load-path */
+  s_load_path = scm_variable_ref (scm_c_lookup ("%load-path"));
+
+  for ( ; s_load_path != SCM_EOL; s_load_path = scm_cdr (s_load_path)) {
+    SCM s_dir_name = scm_car (s_load_path);
+    char *dir_name;
+    DIR *dptr;
+    struct dirent *dentry;
+
+    /* Get directory name from Scheme */
+    g_assert (scm_is_true (scm_list_p (s_load_path))); /* Sanity check */
+    g_assert (scm_is_string (scm_car (s_load_path))); /* Sanity check */
+    dir_name = scm_to_locale_string (s_dir_name);
+
+    /* Open directory */
+    dptr = opendir (dir_name);
+    if (dptr == NULL) {
+      g_warning ("Can't open directory %s: %s\n",
+                 dir_name, strerror (errno));
+      continue;
     }
+    free (dir_name);
 
-    printf("List of available backends:\n\n");
+    while (1) {
+      char *name;
 
-    n=1;
-    while(1) {
-        entry=readdir(schemedir);
-        if(entry==NULL) break;
+      dentry = readdir (dptr);
+      if (dentry == NULL) break;
 
-        filename=strdup(entry->d_name);
+      /* Check that filename has the right format to be a gnetlist
+       * backend */
+      if (!(g_str_has_prefix (dentry->d_name, "gnet-")
+            && g_str_has_suffix (dentry->d_name, ".scm")))
+        continue;
 
-        if(g_str_has_prefix(filename, "gnet-")&&
-           g_str_has_suffix(filename, ".scm")) {
+      /* Copy filename and remove prefix & suffix.  Add to list of
+       * backend names. */
+      name = g_strdup (dentry->d_name + 5);
+      name[strlen(name)-4] = '\0';
+      backend_names = g_list_prepend (backend_names, name);
+    }
 
-            /* strip the suffix */
-            filename[strlen(filename)-4]='\0';
-            /* and skip the prefix */
-            printf("%-25s", &filename[5]);
-            if(n>=BACKEND_LIST_COLS) {
-                printf("\n");
-                n=0;
-            }
-            n++;
-        }
+    /* Close directory */
+    closedir (dptr);
+  }
 
-        free(filename);
-    }
-    printf("\n");
+  /* Sort the list of backends */
+  backend_names = g_list_sort (backend_names, (GCompareFunc) strcmp);
+
+  printf ("List of available backends: \n\n");
+
+  for (iter = backend_names; iter != NULL; iter = g_list_next (iter)) {
+    printf ("%s\n", (char *) iter->data);
+  }
+  printf ("\n");
+
+  scm_remember_upto_here_1 (s_load_path);
 }
 
+
 void main_prog(void *closure, int argc, char *argv[])
 {
     int i;
@@ -237,27 +264,14 @@ void main_prog(void *closure, int argc, char *argv[])
     s_page_print_all(pr_current);
 #endif
 
-    filename = g_build_filename (pr_current->scheme_directory, "gnetlist.scm", NULL);
-    if (g_read_file (pr_current, filename) != -1) {
-      s_log_message ("Read init scm file [%s]\n", filename);
-    } else {
-      s_log_message ("Failed to read init scm file [%s]\n", filename);
-      fprintf (stderr, "Failed to read init scm file [%s]\n", filename);
-    }
-    g_free (filename);
+    /* Load basic gnetlist functions */
+    scm_primitive_load_path (scm_from_locale_string ("gnetlist.scm"));
 
     if (guile_proc) {
-        /* load the appropriate scm file */
+        /* Load the backend scm file */
         str = g_strdup_printf("gnet-%s.scm", guile_proc);
-        filename = g_build_filename (pr_current->scheme_directory, str, NULL);
+        scm_primitive_load_path (scm_from_locale_string (str));
         g_free (str);
-        if (g_read_file (pr_current, filename) != -1) {
-          s_log_message ("Read %s scm file [%s]\n", guile_proc, filename);
-        } else {
-          s_log_message ("Failed to read %s scm file [%s]\n", guile_proc, filename);
-          fprintf (stderr, "Failed to read %s scm file [%s]\n", guile_proc, filename);
-        }
-        g_free (filename);
 
         /* Load second set of scm files */
         list_pnt = post_backend_list;
@@ -288,14 +302,8 @@ void main_prog(void *closure, int argc, char *argv[])
     }
     g_free(cwd);
 
-    filename = g_build_filename (pr_current->scheme_directory, "gnetlist-post.scm", NULL);
-    if (g_read_file (pr_current, filename) != -1) {
-      s_log_message ("Read post traversal scm file [%s]\n", filename);
-    } else {
-      s_log_message ("Failed to read post traversal scm file [%s]\n", filename);
-      fprintf (stderr, "Failed to read post traversal scm file [%s]\n", filename);
-    }
-    g_free (filename);
+    /* Run post-traverse code. */
+    scm_primitive_load_path (scm_from_locale_string ("gnetlist-post.scm"));
 
     if (guile_proc) {
         /* check size here hack */




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