[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.6.1-20100214-260-g27f7a52)
The branch, master has been updated
via 27f7a522a2bb895853697b0013d1344dda3cd5e6 (commit)
via ab3c87c4e1f02f401cab3b4e7a0191e3f39eea25 (commit)
via bbab4c1f8c9fc13ed6276cde8371b77cc9c08342 (commit)
via 8b4f5fc4444c93e922e38e97b3cc9ddbaf1ec7c6 (commit)
via 7ca2b049dbcfb9f0eb8d3dd3fcf21cbd66c0ec95 (commit)
via f82c6d0e497d7d18905d65b8499f33f3e7e3e073 (commit)
via d50f80399fc8de5bcc24723b87f9132324569fb9 (commit)
via 90f0f24ea7cb4c1d3f10f43ea6df813aa71bcde7 (commit)
via 91e8f087d133320cafebd692a2ff0fe7f764fc4b (commit)
via 717b5819e626d0b051ae9ff6bfd657c918b6d338 (commit)
via 2d8cf61e790e6a17cde3b3f16dae205b83e9395f (commit)
via 34290684615f5cf562d3be4f15a3ed2280f99bf1 (commit)
via da0fbc2cc3317e6f5c995385f3986bb2e6689f1b (commit)
from f300ff057ab77b5ac8f1adef6345ffe2279cac63 (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
=========
COPYING.LGPL | 502 ++++++++++++++++++++
Makefile.am | 3 +-
NEWS | 4 +
gattrib/src/gattrib.c | 2 +-
gnetlist/src/gnetlist.c | 2 +-
gschem/include/prototype.h | 2 +
gschem/src/Makefile.am | 1 +
gschem/src/gschem.c | 4 +-
gschem/src/x_rc.c | 89 ++++
gschem/src/x_script.c | 2 +-
gsymcheck/src/gsymcheck.c | 2 +-
libgeda/include/Makefile.am | 2 +
.../include/libgeda/edaerrors.h | 14 +-
libgeda/include/libgeda/libgeda.h | 1 +
libgeda/include/libgeda/prototype.h | 18 +-
libgeda/include/libgeda/struct.h | 3 +
libgeda/include/libgeda_priv.h | 1 +
libgeda/src/Makefile.am | 1 +
utils/include/i_vars.h => libgeda/src/edaerrors.c | 16 +-
libgeda/src/f_basic.c | 7 +-
libgeda/src/g_basic.c | 226 +++++-----
libgeda/src/g_rc.c | 426 +++++++++--------
utils/gschlas/gschlas.c | 2 +-
23 files changed, 1000 insertions(+), 330 deletions(-)
create mode 100644 COPYING.LGPL
create mode 100644 gschem/src/x_rc.c
copy utils/include/i_vars.h => libgeda/include/libgeda/edaerrors.h (62%)
copy utils/include/i_vars.h => libgeda/src/edaerrors.c (67%)
=================
Commit Messages
=================
commit ab3c87c4e1f02f401cab3b4e7a0191e3f39eea25
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Update NEWS re changes to rc file error handling.
:100644 100644 d4c4817... 0bccb9d... M NEWS
commit bbab4c1f8c9fc13ed6276cde8371b77cc9c08342
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gschem: Warning dialogs when rc file load fails.
When loading configuration files at gschem startup, display
informative dialog boxes if an error occurs.
This still does not apply to configuration files loaded "on-the-fly"
when loading new pages from disk.
Affects-bug: lp-698578
:100644 100644 a4c1a94... 211d07d... M gschem/include/prototype.h
:100644 100644 d033bef... 3dc4854... M gschem/src/Makefile.am
:100644 100644 4e5fc18... 2d204ba... M gschem/src/gschem.c
:000000 100644 0000000... 283e409... A gschem/src/x_rc.c
commit 8b4f5fc4444c93e922e38e97b3cc9ddbaf1ec7c6
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Add g_rc_parse_handler().
Add an alternative to g_rc_parse() which accepts an optional error
handler function.
:100644 100644 a3cc9e9... 1dee3cb... M libgeda/include/libgeda/prototype.h
:100644 100644 aed0ffc... 06faf2b... M libgeda/include/libgeda/struct.h
:100644 100644 dc55f8b... 0f96715... M libgeda/src/g_rc.c
commit 7ca2b049dbcfb9f0eb8d3dd3fcf21cbd66c0ec95
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Print message and exit if rc file load fails.
Modifies g_rc_parse() to print useful messages to standard error and
exit with non-zero status if an error other than ENOENT occurs while
attempting to parse any configuration file.
N.b. only copes with rc files loaded at startup; rc files loaded later
(e.g. a gafrc auto-loaded while loading a schematic using gschem
"File->Open") can't cause the application to die.
Since this means that under some circumstances gschem and gattrib can
appear to do nothing silently (e.g. when launched from via a .desktop
file) subsequent patches need to make gschem and gattrib generate
appropriate warning and/or error message dialogs.
Affects-bug: lp-698578
:100644 100644 03626f8... c844ab8... M gattrib/src/gattrib.c
:100644 100644 fb89d63... 02ab15e... M gnetlist/src/gnetlist.c
:100644 100644 da934d6... 4e5fc18... M gschem/src/gschem.c
:100644 100644 da8b2d2... 83bd862... M gsymcheck/src/gsymcheck.c
:100644 100644 cf2a372... a3cc9e9... M libgeda/include/libgeda/prototype.h
:100644 100644 62b2088... dc55f8b... M libgeda/src/g_rc.c
:100644 100644 507cfc6... 506dccb... M utils/gschlas/gschlas.c
commit f82c6d0e497d7d18905d65b8499f33f3e7e3e073
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Upgrade g_read_file() to support GError.
Allow g_read_file() to return error information in a GError if an
error occurs while loading the requested rc file or Scheme script.
:100644 100644 781d3e2... da934d6... M gschem/src/gschem.c
:100644 100644 9d5e00e... 33473f5... M gschem/src/x_script.c
:100644 100644 e2a58d5... cf2a372... M libgeda/include/libgeda/prototype.h
:100644 100644 dd313fd... b331af8... M libgeda/src/g_basic.c
:100644 100644 2edd63e... 62b2088... M libgeda/src/g_rc.c
commit d50f80399fc8de5bcc24723b87f9132324569fb9
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Invert g_read_file() return values.
Make g_read_file() return TRUE on success and FALSE on failure. It
turns out that not only had the return value on success been incorrect
for some time, there was only one use of g_read_file() that cared
about the return value anyway.
:100644 100644 f2150a3... 781d3e2... M gschem/src/gschem.c
:100644 100644 106dec1... e2a58d5... M libgeda/include/libgeda/prototype.h
:100644 100644 34301d8... dd313fd... M libgeda/src/g_basic.c
commit 90f0f24ea7cb4c1d3f10f43ea6df813aa71bcde7
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Whitespace changes to g_read_file().
Redo indentation in g_read_file().
:100644 100644 e9d7327... 34301d8... M libgeda/src/g_basic.c
commit 91e8f087d133320cafebd692a2ff0fe7f764fc4b
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Add a function for turning a Guile error into a GError.
Splits out the backtrace/error logging in g_basic.c into a static
function that can also populate a GError with the error details,
simplifying it greatly in the process by reusing libguile functions to
do most of the hard work.
:100644 100644 f719142... cda48ae... M libgeda/include/libgeda/edaerrors.h
:100644 100644 935ef54... e9d7327... M libgeda/src/g_basic.c
commit 717b5819e626d0b051ae9ff6bfd657c918b6d338
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Rework config file parsing API.
Implement a new libgeda API for loading config files, which has the
following advantages:
1) All error reporting happens via GError, for more informative error
messages. The EDA_ERROR_RC_TWICE error code is added to indicate
that a config file has been prevented from being loaded twice.
2) It is possible to load local config files without chdir() into
their directory, and to specify a target *file* to load
corresponding local config for.
3) As many as possible of the bugs & corner cases that still
need fixing have been documented.
:100644 100644 e97bdea... f719142... M libgeda/include/libgeda/edaerrors.h
:100644 100644 09cf151... 106dec1... M libgeda/include/libgeda/prototype.h
:100644 100644 3c7d16d... e69110c... M libgeda/src/f_basic.c
:100644 100644 75112e9... 2edd63e... M libgeda/src/g_rc.c
commit 2d8cf61e790e6a17cde3b3f16dae205b83e9395f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Distribute a copy of the LGPL v2.1.
Since we have several source files which are LGPL licensed, and they
state that the reader should have received a copy of the LGPL with
this program, distribute a copy of the LGPL with this program.
:000000 100644 0000000... 4362b49... A COPYING.LGPL
:100644 100644 c83837d... 316d6f2... M Makefile.am
commit 34290684615f5cf562d3be4f15a3ed2280f99bf1
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Add a GError domain for libgeda errors.
This patch defines the EDA_ERROR domain for GErrors, and is required
in order to be able to return or handle libgeda-specific GErrors. It
does not define any error codes yet.
:100644 100644 a8bfbef... 6b06666... M libgeda/include/Makefile.am
:000000 100644 0000000... e97bdea... A libgeda/include/libgeda/edaerrors.h
:100644 100644 d8e6e7e... 7dc8608... M libgeda/include/libgeda/libgeda.h
:100644 100644 83f69ff... ccd1731... M libgeda/include/libgeda_priv.h
:100644 100644 ae62fe8... 0a99ce7... M libgeda/src/Makefile.am
:000000 100644 0000000... ceff687... A libgeda/src/edaerrors.c
commit da0fbc2cc3317e6f5c995385f3986bb2e6689f1b
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Simplify g_scm_eval_string_protected().
Instead of defining a body function and calling scm_c_catch()
ourselves, build a Scheme expression and evaluate it using
g_scm_eval_protected().
:100644 100644 15dda39... 935ef54... M libgeda/src/g_basic.c
=========
Changes
=========
commit ab3c87c4e1f02f401cab3b4e7a0191e3f39eea25
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Update NEWS re changes to rc file error handling.
diff --git a/NEWS b/NEWS
index d4c4817..0bccb9d 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ more information, please consult the `ChangeLog' file.
Notable changes in gEDA/gaf 1.7.0
=================================
+* All gEDA/gaf applications now handle configuration files much more
+ strictly, and provide much more useful feedback when an error
+ occurs.
+
* Several changes to `gschem' command-line options:
- The `-t' option is no longer supported.
commit bbab4c1f8c9fc13ed6276cde8371b77cc9c08342
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
gschem: Warning dialogs when rc file load fails.
When loading configuration files at gschem startup, display
informative dialog boxes if an error occurs.
This still does not apply to configuration files loaded "on-the-fly"
when loading new pages from disk.
Affects-bug: lp-698578
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index a4c1a94..211d07d 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -844,6 +844,8 @@ void x_pagesel_update (GSCHEM_TOPLEVEL *w_current);
/* x_preview.c */
/* x_print.c */
void x_print_setup(GSCHEM_TOPLEVEL *w_current, char *filename);
+/* x_rc.c */
+void x_rc_parse_gschem (GSCHEM_TOPLEVEL *w_current, const gchar *rcfile);
/* x_script.c */
void setup_script_selector(GSCHEM_TOPLEVEL *w_current);
/* x_stroke.c */
diff --git a/gschem/src/Makefile.am b/gschem/src/Makefile.am
index d033bef..3dc4854 100644
--- a/gschem/src/Makefile.am
+++ b/gschem/src/Makefile.am
@@ -64,6 +64,7 @@ gschem_SOURCES = \
x_pagesel.c \
x_preview.c \
x_print.c \
+ x_rc.c \
x_script.c \
x_stroke.c \
x_window.c
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index 4e5fc18..2d204ba 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -247,7 +247,7 @@ void main_prog(void *closure, int argc, char *argv[])
/* Now read in RC files. */
g_rc_parse_gtkrc();
- g_rc_parse (w_current->toplevel, argv[0], "gschemrc", rc_filename);
+ x_rc_parse_gschem (w_current, rc_filename);
/* By this point, libgeda should have setup the Guile load path, so
* we can take advantage of that. */
diff --git a/gschem/src/x_rc.c b/gschem/src/x_rc.c
new file mode 100644
index 0000000..283e409
--- /dev/null
+++ b/gschem/src/x_rc.c
@@ -0,0 +1,89 @@
+/* gEDA - GPL Electronic Design Automation
+ * gschem - gEDA Schematic Capture
+ * Copyright (C) 1998-2011 gEDA Contributors (see ChangeLog for details)
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+#include <config.h>
+#include "gschem.h"
+
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+/* Error handler function used by x_rc_parse_gschem(). */
+static void
+x_rc_parse_gschem_error (GError **err, GSCHEM_TOPLEVEL *w_current)
+{
+ char *msg2; /* Secondary text */
+ GtkWidget *dialog;
+
+ g_assert (w_current != NULL);
+ g_assert (err != NULL);
+
+ /* Take no chances; if err was not set for some reason, it's a
+ * problem. */
+ if (*err == NULL) {
+ /* Log message */
+ s_log_message (_("ERROR: An unknown error occurred while parsing"
+ "configuration files.\n"));
+
+ /* Dialog message */
+ msg2 =
+ g_strdup (_("An unknown error occurred while parsing configuration files."
+ "\n\nThe gschem log may contain more information."));
+ } else {
+
+ /* Config files are allowed to be missing; check for this. */
+ if (g_error_matches (*err, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
+ s_log_message ("%s\n", (*err)->message);
+ return;
+ }
+
+ /* Log message */
+ s_log_message (_("ERROR: %s\n"), (*err)->message);
+
+ /* Dialog message */
+ msg2 = g_strdup_printf (_("%s\n\n"
+ "The gschem log may contain more information."),
+ (*err)->message);
+ }
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (w_current->main_window),
+ GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Cannot load gschem configuration."));
+ g_object_set (G_OBJECT (dialog), "secondary-text", msg2, NULL);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (msg2);
+}
+
+/*! \brief Load gschem configuration files and display error dialogs.
+ * \par Function Description
+ * Loads configuration files in a similar manner to g_rc_parse().
+ * Instead of exiting on error, display error dialogs with explanatory
+ * messages.
+ *
+ * \param w_current The current #GSCHEM_TOPLEVEL structure.
+ * \param rcfile Specific config file path, or NULL.
+ */
+void
+x_rc_parse_gschem (GSCHEM_TOPLEVEL *w_current, const gchar *rcfile) {
+ TOPLEVEL *toplevel = w_current->toplevel;
+ g_rc_parse_handler (toplevel, "gschemrc", rcfile,
+ (ConfigParseErrorFunc) x_rc_parse_gschem_error,
+ (void *) w_current);
+}
commit 8b4f5fc4444c93e922e38e97b3cc9ddbaf1ec7c6
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Add g_rc_parse_handler().
Add an alternative to g_rc_parse() which accepts an optional error
handler function.
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index a3cc9e9..1dee3cb 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -38,7 +38,7 @@ gboolean g_rc_parse_user (TOPLEVEL *toplevel, const gchar *rcname, GError **err)
gboolean g_rc_parse_local (TOPLEVEL *toplevel, const gchar *rcname, const gchar *path, GError **err);
gboolean g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err);
void g_rc_parse(TOPLEVEL *toplevel, const gchar* pname, const gchar* rcname, const gchar* rcfile);
-
+void g_rc_parse_handler (TOPLEVEL *toplevel, const gchar *rcname, const gchar *rcfile, ConfigParseErrorFunc handler, void *user_data);
/* g_smob.c */
SCM g_make_attrib_smob(TOPLEVEL *curr_w, OBJECT *curr_attr);
SCM g_set_attrib_value_internal(SCM attrib_smob, SCM scm_value, TOPLEVEL **world, OBJECT **o_attrib, char *new_string[]);
diff --git a/libgeda/include/libgeda/struct.h b/libgeda/include/libgeda/struct.h
index aed0ffc..06faf2b 100644
--- a/libgeda/include/libgeda/struct.h
+++ b/libgeda/include/libgeda/struct.h
@@ -662,4 +662,7 @@ typedef struct {
char *m_str;
} vstbl_entry;
+/* Used by g_rc_parse_handler() */
+typedef void (*ConfigParseErrorFunc)(GError **, void *);
+
#endif
diff --git a/libgeda/src/g_rc.c b/libgeda/src/g_rc.c
index dc55f8b..0f96715 100644
--- a/libgeda/src/g_rc.c
+++ b/libgeda/src/g_rc.c
@@ -280,7 +280,7 @@ g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err)
}
static void
-g_rc_parse__process_error (const gchar *pname, GError **err)
+g_rc_parse__process_error (GError **err, const gchar *pname)
{
char *pbase;
@@ -295,9 +295,6 @@ g_rc_parse__process_error (const gchar *pname, GError **err)
/* Config files are allowed to be missing; check for this. */
if (g_error_matches (*err, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
s_log_message ("%s\n", (*err)->message);
- /* Clear the error */
- g_error_free (*err);
- *err = NULL;
return;
}
@@ -315,13 +312,9 @@ g_rc_parse__process_error (const gchar *pname, GError **err)
/*! \brief General RC file parsing function.
* \par Function Description
- * Attempt to load system, user and local (current working directory)
- * configuration files, first with the default "gafrc" basename and
- * then with the basename \a rcname, if \a rcname is not NULL.
- * Additionally, attempt to load configuration from \a rcfile if \a
- * rcfile is not NULL. If any error other than ENOENT occurs while
- * parsing a configuration file, prints an informative message and
- * calls exit(1).
+ * Calls g_rc_parse_handler() with the default error handler. If any
+ * error other than ENOENT occurs while parsing a configuration file,
+ * prints an informative message and calls exit(1).
*
* \bug libgeda shouldn't call exit().
*
@@ -338,32 +331,61 @@ void
g_rc_parse (TOPLEVEL *toplevel, const gchar *pname,
const gchar *rcname, const gchar *rcfile)
{
+ g_rc_parse_handler (toplevel, rcname, rcfile,
+ (ConfigParseErrorFunc) g_rc_parse__process_error,
+ (void *) pname);
+}
+
+/*! \brief General RC file parsing function.
+ * \par Function Description
+ * Attempt to load system, user and local (current working directory)
+ * configuration files, first with the default "gafrc" basename and
+ * then with the basename \a rcname, if \a rcname is not NULL.
+ * Additionally, attempt to load configuration from \a rcfile if \a
+ * rcfile is not NULL.
+ *
+ * If an error occurs, calls \a handler with the provided \a user_data
+ * and a GError.
+ *
+ * \see g_rc_parse().
+ *
+ * \param toplevel The current #TOPLEVEL structure.
+ * \param rcname Config file basename, or NULL.
+ * \param rcfile Specific config file path, or NULL.
+ * \param handler Handler function for config parse errors.
+ * \param user_data Data to be passed to \a handler.
+ */
+void
+g_rc_parse_handler (TOPLEVEL *toplevel,
+ const gchar *rcname, const gchar *rcfile,
+ ConfigParseErrorFunc handler, void *user_data)
+{
GError *err = NULL;
- /* Load configuration files in order. This might be tidier with a
- * macro. */
+#ifdef HANDLER_DISPATCH
+# error HANDLER_DISPATCH already defined
+#endif
+#define HANDLER_DISPATCH \
+ do { if (err == NULL) break; handler (&err, user_data); \
+ g_error_free (err); err = NULL; } while (0)
+
+ /* Load configuration files in order. */
/* First gafrc files. */
- g_rc_parse_system (toplevel, NULL, &err);
- if (err != NULL) g_rc_parse__process_error (pname, &err);
- g_rc_parse_user (toplevel, NULL, &err);
- if (err != NULL) g_rc_parse__process_error (pname, &err);
- g_rc_parse_local (toplevel, NULL, NULL, &err);
- if (err != NULL) g_rc_parse__process_error (pname, &err);
+ g_rc_parse_system (toplevel, NULL, &err); HANDLER_DISPATCH;
+ g_rc_parse_user (toplevel, NULL, &err); HANDLER_DISPATCH;
+ g_rc_parse_local (toplevel, NULL, NULL, &err); HANDLER_DISPATCH;
/* Next application-specific rcname. */
if (rcname != NULL) {
- g_rc_parse_system (toplevel, rcname, &err);
- if (err != NULL) g_rc_parse__process_error (pname, &err);
- g_rc_parse_user (toplevel, rcname, &err);
- if (err != NULL) g_rc_parse__process_error (pname, &err);
- g_rc_parse_local (toplevel, rcname, NULL, &err);
- if (err != NULL) g_rc_parse__process_error (pname, &err);
+ g_rc_parse_system (toplevel, rcname, &err); HANDLER_DISPATCH;
+ g_rc_parse_user (toplevel, rcname, &err); HANDLER_DISPATCH;
+ g_rc_parse_local (toplevel, rcname, NULL, &err); HANDLER_DISPATCH;
}
- /* Finally, optional additional config file. Note that since this
- * was specially specified, we require it to be present.*/
+ /* Finally, optional additional config file. */
if (rcfile != NULL) {
- g_rc_parse_file (toplevel, rcfile, &err);
- if (err != NULL) g_rc_parse__process_error (pname, &err);
+ g_rc_parse_file (toplevel, rcfile, &err); HANDLER_DISPATCH;
}
+
+#undef HANDLER_DISPATCH
}
/*! \brief
commit 7ca2b049dbcfb9f0eb8d3dd3fcf21cbd66c0ec95
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Print message and exit if rc file load fails.
Modifies g_rc_parse() to print useful messages to standard error and
exit with non-zero status if an error other than ENOENT occurs while
attempting to parse any configuration file.
N.b. only copes with rc files loaded at startup; rc files loaded later
(e.g. a gafrc auto-loaded while loading a schematic using gschem
"File->Open") can't cause the application to die.
Since this means that under some circumstances gschem and gattrib can
appear to do nothing silently (e.g. when launched from via a .desktop
file) subsequent patches need to make gschem and gattrib generate
appropriate warning and/or error message dialogs.
Affects-bug: lp-698578
diff --git a/gattrib/src/gattrib.c b/gattrib/src/gattrib.c
index 03626f8..c844ab8 100644
--- a/gattrib/src/gattrib.c
+++ b/gattrib/src/gattrib.c
@@ -251,7 +251,7 @@ void gattrib_main(void *closure, int argc, char *argv[])
pr_current = s_toplevel_new();
/* ----- Read in RC files. ----- */
- g_rc_parse(pr_current, "gattribrc", NULL);
+ g_rc_parse (pr_current, argv[0], "gattribrc", NULL);
i_vars_set(pr_current);
diff --git a/gnetlist/src/gnetlist.c b/gnetlist/src/gnetlist.c
index fb89d63..02ab15e 100644
--- a/gnetlist/src/gnetlist.c
+++ b/gnetlist/src/gnetlist.c
@@ -189,7 +189,7 @@ void main_prog(void *closure, int argc, char *argv[])
* are loaded. */
scm_eval_x (pre_rc_list, scm_current_module ());
- g_rc_parse(pr_current, "gnetlistrc", rc_filename);
+ g_rc_parse (pr_current, argv[0], "gnetlistrc", rc_filename);
/* immediately setup user params */
i_vars_set (pr_current);
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index da934d6..4e5fc18 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -247,7 +247,7 @@ void main_prog(void *closure, int argc, char *argv[])
/* Now read in RC files. */
g_rc_parse_gtkrc();
- g_rc_parse(w_current->toplevel, "gschemrc", rc_filename);
+ g_rc_parse (w_current->toplevel, argv[0], "gschemrc", rc_filename);
/* By this point, libgeda should have setup the Guile load path, so
* we can take advantage of that. */
diff --git a/gsymcheck/src/gsymcheck.c b/gsymcheck/src/gsymcheck.c
index da8b2d2..83bd862 100644
--- a/gsymcheck/src/gsymcheck.c
+++ b/gsymcheck/src/gsymcheck.c
@@ -77,7 +77,7 @@ main_prog(void *closure, int argc, char *argv[])
g_register_funcs();
pr_current = s_toplevel_new ();
- g_rc_parse(pr_current, "gsymcheckrc", rc_filename);
+ g_rc_parse (pr_current, argv[0], "gsymcheckrc", rc_filename);
i_vars_set(pr_current);
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index cf2a372..a3cc9e9 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -37,7 +37,7 @@ gboolean g_rc_parse_system (TOPLEVEL *toplevel, const gchar *rcname, GError **er
gboolean g_rc_parse_user (TOPLEVEL *toplevel, const gchar *rcname, GError **err);
gboolean g_rc_parse_local (TOPLEVEL *toplevel, const gchar *rcname, const gchar *path, GError **err);
gboolean g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err);
-void g_rc_parse(TOPLEVEL *toplevel, const gchar* rcname, const gchar* rcfile);
+void g_rc_parse(TOPLEVEL *toplevel, const gchar* pname, const gchar* rcname, const gchar* rcfile);
/* g_smob.c */
SCM g_make_attrib_smob(TOPLEVEL *curr_w, OBJECT *curr_attr);
diff --git a/libgeda/src/g_rc.c b/libgeda/src/g_rc.c
index 62b2088..dc55f8b 100644
--- a/libgeda/src/g_rc.c
+++ b/libgeda/src/g_rc.c
@@ -269,8 +269,9 @@ g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err)
g_error_free (tmp_err);
} else {
gchar *orig_msg = tmp_err->message;
- tmp_err->message = g_strdup_printf (_("Unable to parse config from [%s]: %s"),
- rcfile, orig_msg);
+ tmp_err->message =
+ g_strdup_printf (_("Unable to parse config from [%s]: %s"),
+ (name_norm != NULL) ? name_norm : rcfile, orig_msg);
g_free (orig_msg);
*err = tmp_err;
}
@@ -278,21 +279,38 @@ g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err)
return FALSE;
}
-static gboolean
-g_rc_parse__process_error (GError **err)
+static void
+g_rc_parse__process_error (const gchar *pname, GError **err)
{
- g_return_val_if_fail ((err != NULL), FALSE);
+ char *pbase;
- /* For now, just print a log message to say whether or not the RC
- * file loaded okay. */
+ /* Take no chances; if err was not set for some reason, bail out. */
if (*err == NULL) {
- return TRUE;
+ const gchar *msgl =
+ _("ERROR: An unknown error occurred while parsing configuration files.");
+ s_log_message ("%s\n", msgl);
+ fprintf(stderr, "%s\n", msgl);
+
} else {
- s_log_message ("%s\n", (*err)->message);
- g_error_free (*err);
- *err = NULL;
- return FALSE;
+ /* Config files are allowed to be missing; check for this. */
+ if (g_error_matches (*err, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
+ s_log_message ("%s\n", (*err)->message);
+ /* Clear the error */
+ g_error_free (*err);
+ *err = NULL;
+ return;
+ }
+
+ s_log_message (_("ERROR: %s\n"), (*err)->message);
+ fprintf (stderr, _("ERROR: %s\n"), (*err)->message);
}
+
+ /* g_path_get_basename() allocates memory, but we don't care
+ * because we're about to exit. */
+ pbase = g_path_get_basename (pname);
+ fprintf (stderr, _("ERROR: The %s log may contain more information.\n"),
+ pbase);
+ exit (1);
}
/*! \brief General RC file parsing function.
@@ -301,54 +319,50 @@ g_rc_parse__process_error (GError **err)
* configuration files, first with the default "gafrc" basename and
* then with the basename \a rcname, if \a rcname is not NULL.
* Additionally, attempt to load configuration from \a rcfile if \a
- * rcfile is not NULL. If all attempts fail, call exit(1) to
- * terminate the program.
+ * rcfile is not NULL. If any error other than ENOENT occurs while
+ * parsing a configuration file, prints an informative message and
+ * calls exit(1).
*
* \bug libgeda shouldn't call exit().
*
- * \deprecated New code should call the g_rc_parse_system(),
- * g_rc_parse_user(), g_rc_parse_local(), or g_rc_parse_file()
- * functions directly, and use the GError information to determine
- * how to deal with errors (e.g. displaying a dialog box to the
- * user).
+ * \warning Since this function may not return, it should only be used
+ * on application startup or when there is no chance of data loss from
+ * an unexpected exit().
*
* \param [in] toplevel The current #TOPLEVEL structure.
+ * \param [in] pname The name of the application (usually argv[0]).
* \param [in] rcname Config file basename, or NULL.
* \param [in] rcfile Specific config file path, or NULL.
*/
void
-g_rc_parse(TOPLEVEL *toplevel, const gchar *rcname, const gchar *rcfile)
+g_rc_parse (TOPLEVEL *toplevel, const gchar *pname,
+ const gchar *rcname, const gchar *rcfile)
{
- gint found_rc = 0;
GError *err = NULL;
- /* Load configuration files in order. */
+ /* Load configuration files in order. This might be tidier with a
+ * macro. */
/* First gafrc files. */
g_rc_parse_system (toplevel, NULL, &err);
- found_rc |= g_rc_parse__process_error (&err);
+ if (err != NULL) g_rc_parse__process_error (pname, &err);
g_rc_parse_user (toplevel, NULL, &err);
- found_rc |= g_rc_parse__process_error (&err);
+ if (err != NULL) g_rc_parse__process_error (pname, &err);
g_rc_parse_local (toplevel, NULL, NULL, &err);
- found_rc |= g_rc_parse__process_error (&err);
+ if (err != NULL) g_rc_parse__process_error (pname, &err);
/* Next application-specific rcname. */
if (rcname != NULL) {
g_rc_parse_system (toplevel, rcname, &err);
- found_rc |= g_rc_parse__process_error (&err);
+ if (err != NULL) g_rc_parse__process_error (pname, &err);
g_rc_parse_user (toplevel, rcname, &err);
- found_rc |= g_rc_parse__process_error (&err);
+ if (err != NULL) g_rc_parse__process_error (pname, &err);
g_rc_parse_local (toplevel, rcname, NULL, &err);
- found_rc |= g_rc_parse__process_error (&err);
+ if (err != NULL) g_rc_parse__process_error (pname, &err);
}
- /* Finally, optional additional config file. */
+ /* Finally, optional additional config file. Note that since this
+ * was specially specified, we require it to be present.*/
if (rcfile != NULL) {
g_rc_parse_file (toplevel, rcfile, &err);
- found_rc |= g_rc_parse__process_error (&err);
- }
-
- /*! Exit if no config files could be loaded. */
- if (!found_rc) {
- s_log_message (_("ERROR: Could not load any config files."));
- exit (1);
+ if (err != NULL) g_rc_parse__process_error (pname, &err);
}
}
diff --git a/utils/gschlas/gschlas.c b/utils/gschlas/gschlas.c
index 507cfc6..506dccb 100644
--- a/utils/gschlas/gschlas.c
+++ b/utils/gschlas/gschlas.c
@@ -81,7 +81,7 @@ main_prog(void *closure, int argc, char *argv[])
g_register_funcs();
pr_current = s_toplevel_new ();
- g_rc_parse(pr_current, "gschlasrc", rc_filename);
+ g_rc_parse (pr_current, argv[0], "gschlasrc", rc_filename);
i_vars_set(pr_current);
i = argv_index;
commit f82c6d0e497d7d18905d65b8499f33f3e7e3e073
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Upgrade g_read_file() to support GError.
Allow g_read_file() to return error information in a GError if an
error occurs while loading the requested rc file or Scheme script.
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index 781d3e2..da934d6 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -256,7 +256,7 @@ void main_prog(void *closure, int argc, char *argv[])
s_log_message (_("Couldn't find init scm file [%s]\n"), "gschem.scm");
}
input_str = scm_to_locale_string (scm_tmp);
- if (g_read_file(w_current->toplevel, input_str)) {
+ if (g_read_file(w_current->toplevel, input_str, NULL)) {
s_log_message(_("Read init scm file [%s]\n"), input_str);
} else {
/*! \todo These two messages are the same. Should be
diff --git a/gschem/src/x_script.c b/gschem/src/x_script.c
index 9d5e00e..33473f5 100644
--- a/gschem/src/x_script.c
+++ b/gschem/src/x_script.c
@@ -64,7 +64,7 @@ void setup_script_selector (GSCHEM_TOPLEVEL *w_current)
if (!(g_file_test(filename, G_FILE_TEST_IS_DIR))) {
s_log_message(_("Executing guile script [%s]\n"), filename);
- g_read_file(w_current->toplevel, filename);
+ g_read_file(w_current->toplevel, filename, NULL);
}
g_free (filename);
}
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index e2a58d5..cf2a372 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -28,7 +28,7 @@ void f_print_set_type(TOPLEVEL *toplevel, int type);
SCM g_scm_eval_protected (SCM exp, SCM module_or_state);
SCM g_scm_eval_string_protected (SCM str);
SCM g_scm_c_eval_string_protected (const gchar *str);
-gboolean g_read_file(TOPLEVEL *toplevel, const gchar *filename);
+gboolean g_read_file(TOPLEVEL *toplevel, const gchar *filename, GError **err);
/* g_rc.c */
SCM g_rc_mode_general(SCM scmmode, const char *rc_name, int *mode_var,
diff --git a/libgeda/src/g_basic.c b/libgeda/src/g_basic.c
index dd313fd..b331af8 100644
--- a/libgeda/src/g_basic.c
+++ b/libgeda/src/g_basic.c
@@ -156,46 +156,73 @@ SCM g_scm_eval_string_protected (SCM str)
return g_scm_eval_protected (expr, SCM_UNDEFINED);
}
+/* Data to be passed to g_read_file()'s worker functions. */
+struct g_read_file_data_t
+{
+ SCM stack;
+ SCM filename;
+ GError *err;
+};
+
+/* Body function for g_read_file(). Simply loads the specified
+ * file. */
+SCM
+g_read_file__body (struct g_read_file_data_t *data)
+{
+ return scm_primitive_load (data->filename);
+}
-/*! \brief Start reading a scheme file
- * \par Function Description
- * Start reading a scheme file
+/* Post-unwind handler for g_read_file(). Processes the stack captured
+ * in the pre-unwind handler. */
+SCM
+g_read_file__post_handler (struct g_read_file_data_t *data, SCM key, SCM args)
+{
+ process_error_stack (data->stack, key, args, &data->err);
+ return SCM_BOOL_F;
+}
+
+/* Pre-unwind handler for g_read_file(). Captures the Guile stack for
+ * processing in the post-unwind handler. */
+SCM
+g_read_file__pre_handler (struct g_read_file_data_t *data, SCM key, SCM args)
+{
+ data->stack = scm_make_stack (SCM_BOOL_T, SCM_EOL);
+ return SCM_BOOL_F;
+}
+
+/*! \brief Load a Scheme file, catching and logging errors.
+ * \par Function Description
+ * Loads \a filename, catching any uncaught errors and logging them.
+ *
+ * \bug Most other functions in the libgeda API return TRUE on success
+ * and FALSE on failure. g_read_file() shouldn't be an exception.
*
- * \param [in] toplevel The TOPLEVEL structure.
- * \param [in] filename The file name to start reading from.
+ * \param toplevel The TOPLEVEL structure.
+ * \param filename The file name of the Scheme file to load.
+ * \param err Return location for errors, or NULL.
* \return TRUE on success, FALSE on failure.
*/
gboolean
-g_read_file(TOPLEVEL *toplevel, const gchar *filename)
+g_read_file(TOPLEVEL *toplevel, const gchar *filename, GError **err)
{
- SCM eval_result = SCM_BOOL_F;
- SCM expr;
- char * full_filename;
+ struct g_read_file_data_t data;
- if (filename == NULL) {
- return FALSE;
- }
-
- /* get full, absolute path to file */
- full_filename = f_normalize_filename (filename, NULL);
- if (full_filename == NULL) {
- return FALSE;
- }
+ g_return_val_if_fail ((filename != NULL), FALSE);
- if (access(full_filename, R_OK) != 0) {
- s_log_message(_("Could not find [%s] for interpretation\n"),
- full_filename);
- return FALSE;
- }
+ data.stack = SCM_BOOL_F;
+ data.filename = scm_from_locale_string (filename);
+ data.err = NULL;
- expr = scm_list_2 (scm_from_locale_symbol ("load"),
- scm_from_locale_string (full_filename));
- eval_result = g_scm_eval_protected (expr,
- scm_interaction_environment ());
+ scm_c_catch (SCM_BOOL_T,
+ (scm_t_catch_body) g_read_file__body, &data,
+ (scm_t_catch_handler) g_read_file__post_handler, &data,
+ (scm_t_catch_handler) g_read_file__pre_handler, &data);
- g_free(full_filename);
+ /* If no error occurred, indicate success. */
+ if (data.err == NULL) return TRUE;
- return (eval_result != SCM_BOOL_F);
+ g_propagate_error (err, data.err);
+ return FALSE;
}
diff --git a/libgeda/src/g_rc.c b/libgeda/src/g_rc.c
index 2edd63e..62b2088 100644
--- a/libgeda/src/g_rc.c
+++ b/libgeda/src/g_rc.c
@@ -252,35 +252,13 @@ g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err)
name_norm = f_normalize_filename (rcfile, &tmp_err);
if (name_norm == NULL) goto parse_file_error;
- /* Test that we can read the file. */
- /*! \bug This is unsafe; there is a potential race condition between
- * this check and the subsequent call to g_read_file(). This test
- * should be done at the time that the file is opened for
- * reading. See 'man access' for more information on the problems
- * with access(). */
- /*! \bug This reports EACCES if the file does not exist. Testing
- * whether the file exists, is not a directory, and is readable all
- * ought to be done at the same time as actually opening it for
- * loading. */
- if (access (name_norm, R_OK) != 0) {
- g_set_error (&tmp_err, G_FILE_ERROR,
- g_file_error_from_errno (EACCES),
- g_strerror (EACCES));
- goto parse_file_error;
- }
-
/* Attempt to load the rc file, if it hasn't been loaded already.
* If g_rc_try_mark_read() succeeds, it stores name_norm in
* toplevel, so we *don't* free it. */
- if (g_rc_try_mark_read (toplevel, name_norm, &tmp_err)) {
- /*! \bug We should *definitely* populate err if loading the file
- * causes errors. g_read_file() needs an update to support
- * this. */
- g_read_file (toplevel, name_norm);
+ if (g_rc_try_mark_read (toplevel, name_norm, &tmp_err)
+ && g_read_file (toplevel, name_norm, &tmp_err)) {
s_log_message (_("Parsed config from [%s]\n"), name_norm);
return TRUE;
- } else {
- goto parse_file_error;
}
parse_file_error:
commit d50f80399fc8de5bcc24723b87f9132324569fb9
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Invert g_read_file() return values.
Make g_read_file() return TRUE on success and FALSE on failure. It
turns out that not only had the return value on success been incorrect
for some time, there was only one use of g_read_file() that cared
about the return value anyway.
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index f2150a3..781d3e2 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -256,7 +256,7 @@ void main_prog(void *closure, int argc, char *argv[])
s_log_message (_("Couldn't find init scm file [%s]\n"), "gschem.scm");
}
input_str = scm_to_locale_string (scm_tmp);
- if (g_read_file(w_current->toplevel, input_str) != -1) {
+ if (g_read_file(w_current->toplevel, input_str)) {
s_log_message(_("Read init scm file [%s]\n"), input_str);
} else {
/*! \todo These two messages are the same. Should be
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index 106dec1..e2a58d5 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -28,7 +28,7 @@ void f_print_set_type(TOPLEVEL *toplevel, int type);
SCM g_scm_eval_protected (SCM exp, SCM module_or_state);
SCM g_scm_eval_string_protected (SCM str);
SCM g_scm_c_eval_string_protected (const gchar *str);
-int g_read_file(TOPLEVEL *toplevel, const gchar *filename);
+gboolean g_read_file(TOPLEVEL *toplevel, const gchar *filename);
/* g_rc.c */
SCM g_rc_mode_general(SCM scmmode, const char *rc_name, int *mode_var,
diff --git a/libgeda/src/g_basic.c b/libgeda/src/g_basic.c
index 34301d8..dd313fd 100644
--- a/libgeda/src/g_basic.c
+++ b/libgeda/src/g_basic.c
@@ -163,9 +163,9 @@ SCM g_scm_eval_string_protected (SCM str)
*
* \param [in] toplevel The TOPLEVEL structure.
* \param [in] filename The file name to start reading from.
- * \return 0 on success, -1 on failure.
+ * \return TRUE on success, FALSE on failure.
*/
-int
+gboolean
g_read_file(TOPLEVEL *toplevel, const gchar *filename)
{
SCM eval_result = SCM_BOOL_F;
@@ -173,19 +173,19 @@ g_read_file(TOPLEVEL *toplevel, const gchar *filename)
char * full_filename;
if (filename == NULL) {
- return(-1);
+ return FALSE;
}
/* get full, absolute path to file */
full_filename = f_normalize_filename (filename, NULL);
if (full_filename == NULL) {
- return(-1);
+ return FALSE;
}
if (access(full_filename, R_OK) != 0) {
s_log_message(_("Could not find [%s] for interpretation\n"),
full_filename);
- return(-1);
+ return FALSE;
}
expr = scm_list_2 (scm_from_locale_symbol ("load"),
commit 90f0f24ea7cb4c1d3f10f43ea6df813aa71bcde7
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Whitespace changes to g_read_file().
Redo indentation in g_read_file().
diff --git a/libgeda/src/g_basic.c b/libgeda/src/g_basic.c
index e9d7327..34301d8 100644
--- a/libgeda/src/g_basic.c
+++ b/libgeda/src/g_basic.c
@@ -168,34 +168,34 @@ SCM g_scm_eval_string_protected (SCM str)
int
g_read_file(TOPLEVEL *toplevel, const gchar *filename)
{
- SCM eval_result = SCM_BOOL_F;
- SCM expr;
- char * full_filename;
-
- if (filename == NULL) {
- return(-1);
- }
-
- /* get full, absolute path to file */
- full_filename = f_normalize_filename (filename, NULL);
- if (full_filename == NULL) {
- return(-1);
- }
-
- if (access(full_filename, R_OK) != 0) {
- s_log_message(_("Could not find [%s] for interpretation\n"),
- full_filename);
- return(-1);
- }
-
- expr = scm_list_2 (scm_from_locale_symbol ("load"),
- scm_from_locale_string (full_filename));
- eval_result = g_scm_eval_protected (expr,
- scm_interaction_environment ());
-
- g_free(full_filename);
-
- return (eval_result != SCM_BOOL_F);
+ SCM eval_result = SCM_BOOL_F;
+ SCM expr;
+ char * full_filename;
+
+ if (filename == NULL) {
+ return(-1);
+ }
+
+ /* get full, absolute path to file */
+ full_filename = f_normalize_filename (filename, NULL);
+ if (full_filename == NULL) {
+ return(-1);
+ }
+
+ if (access(full_filename, R_OK) != 0) {
+ s_log_message(_("Could not find [%s] for interpretation\n"),
+ full_filename);
+ return(-1);
+ }
+
+ expr = scm_list_2 (scm_from_locale_symbol ("load"),
+ scm_from_locale_string (full_filename));
+ eval_result = g_scm_eval_protected (expr,
+ scm_interaction_environment ());
+
+ g_free(full_filename);
+
+ return (eval_result != SCM_BOOL_F);
}
commit 91e8f087d133320cafebd692a2ff0fe7f764fc4b
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Add a function for turning a Guile error into a GError.
Splits out the backtrace/error logging in g_basic.c into a static
function that can also populate a GError with the error details,
simplifying it greatly in the process by reusing libguile functions to
do most of the hard work.
diff --git a/libgeda/include/libgeda/edaerrors.h b/libgeda/include/libgeda/edaerrors.h
index f719142..cda48ae 100644
--- a/libgeda/include/libgeda/edaerrors.h
+++ b/libgeda/include/libgeda/edaerrors.h
@@ -22,6 +22,7 @@
/*! Error numbers for errors originating in libgeda. */
typedef enum {
+ EDA_ERROR_SCHEME, /* A Scheme error occurred */
EDA_ERROR_RC_TWICE, /* Attempted to read a configuration file twice */
EDA_ERROR_NUM_ERRORS,
} EdaError;
diff --git a/libgeda/src/g_basic.c b/libgeda/src/g_basic.c
index 935ef54..e9d7327 100644
--- a/libgeda/src/g_basic.c
+++ b/libgeda/src/g_basic.c
@@ -39,6 +39,8 @@
#include <dmalloc.h>
#endif
+static void process_error_stack (SCM s_stack, SCM s_key, SCM s_args, GError **err);
+
/* Pre-unwind handler called in the context in which the exception was
* thrown. */
static SCM protected_pre_unwind_handler (void *data, SCM key, SCM args)
@@ -56,66 +58,8 @@ static SCM protected_post_unwind_handler (void *data, SCM key, SCM args)
{
/* The stack was captured pre-unwind */
SCM s_stack = *(SCM *) data;
- char *message = NULL;
-
- /* Capture the error message */
- if (scm_list_p (scm_caddr (args)) == SCM_BOOL_T) {
- SCM s_msg = scm_simple_format (SCM_BOOL_F,
- scm_cadr (args),
- scm_caddr (args));
- message = scm_to_locale_string (s_msg);
- } else {
- message = scm_to_locale_string (scm_cadr (args));
- }
-
- /* If a stack was captured, extract debugging information */
- if (scm_stack_p (s_stack) == SCM_BOOL_T) {
- SCM s_port, s_source, s_filename, s_line_num, s_col_num;
- char *filename, *trace;
-
- /* Capture & log backtrace */
- s_port = scm_open_output_string();
- scm_display_backtrace (s_stack, s_port,
- SCM_BOOL_F, SCM_BOOL_F);
- trace = scm_to_locale_string (scm_get_output_string (s_port));
- scm_close_output_port (s_port);
- s_log_message ("\n%s\n", trace);
- free (trace);
- trace = NULL;
-
- /* Capture & log location */
- s_source = scm_frame_source (scm_stack_ref (s_stack, scm_from_int (0)));
-
- s_filename = scm_source_property (s_source,
- scm_from_locale_symbol ("filename"));
- s_line_num = scm_source_property (s_source,
- scm_from_locale_symbol ("line"));
- s_col_num = scm_source_property (s_source,
- scm_from_locale_symbol ("column"));
-
- if (scm_is_string (s_filename)
- && scm_is_integer (s_line_num)
- && scm_is_integer (s_col_num)) {
-
- filename = scm_to_locale_string (s_filename);
- s_log_message (_("%s:%i:%i: %s\n"), filename,
- scm_to_int (s_line_num),
- scm_to_int (s_col_num), message);
- free (filename);
-
- } else {
-
- s_log_message (_("Unknown file: %s\n"), message);
-
- }
-
- } else {
- /* No stack, so can't display debugging info */
- s_log_message (_("Evaluation failed: %s\n"), message);
- s_log_message (_("Enable debugging for more detailed information\n"));
- }
- free (message);
+ process_error_stack (s_stack, key, args, NULL);
return SCM_BOOL_F;
}
@@ -253,3 +197,48 @@ g_read_file(TOPLEVEL *toplevel, const gchar *filename)
return (eval_result != SCM_BOOL_F);
}
+
+
+/*! \brief Process a Scheme error into the log and/or a GError
+ * \par Function Description
+ * Process a captured Guile exception with the given \a s_key and \a
+ * s_args, and optionally the stack trace \a s_stack. The stack trace
+ * and source location are logged, and if a GError return location \a
+ * err is provided, it is populated with an informative error message.
+ */
+static void
+process_error_stack (SCM s_stack, SCM s_key, SCM s_args, GError **err) {
+ char *long_message;
+ char *short_message;
+ SCM s_port, s_subr, s_message, s_message_args, s_rest;
+
+ /* Split s_args up */
+ s_rest = s_args;
+ s_subr = scm_car (s_rest); s_rest = scm_cdr (s_rest);
+ s_message = scm_car (s_rest); s_rest = scm_cdr (s_rest);
+ s_message_args = scm_car (s_rest); s_rest = scm_cdr (s_rest);
+
+ /* Capture short error message */
+ s_port = scm_open_output_string ();
+ scm_display_error_message (s_message, s_message_args, s_port);
+ short_message = scm_to_locale_string (scm_get_output_string (s_port));
+ scm_close_output_port (s_port);
+
+ /* Capture long error message (including possible backtrace) */
+ s_port = scm_open_output_string ();
+ if (scm_is_true (scm_stack_p (s_stack))) {
+ scm_puts (_("\nBacktrace:\n"), s_port);
+ scm_display_backtrace (s_stack, s_port, SCM_BOOL_F, SCM_BOOL_F);
+ scm_puts ("\n", s_port);
+ }
+ scm_display_error (s_stack, s_port, s_subr,
+ s_message, s_message_args, s_rest);
+ long_message = scm_to_locale_string (scm_get_output_string (s_port));
+ scm_close_output_port (s_port);
+
+ /* Send long message to log */
+ s_log_message ("%s", long_message);
+
+ /* Populate any GError */
+ g_set_error (err, EDA_ERROR, EDA_ERROR_SCHEME, "%s", short_message);
+}
commit 717b5819e626d0b051ae9ff6bfd657c918b6d338
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Rework config file parsing API.
Implement a new libgeda API for loading config files, which has the
following advantages:
1) All error reporting happens via GError, for more informative error
messages. The EDA_ERROR_RC_TWICE error code is added to indicate
that a config file has been prevented from being loaded twice.
2) It is possible to load local config files without chdir() into
their directory, and to specify a target *file* to load
corresponding local config for.
3) As many as possible of the bugs & corner cases that still
need fixing have been documented.
diff --git a/libgeda/include/libgeda/edaerrors.h b/libgeda/include/libgeda/edaerrors.h
index e97bdea..f719142 100644
--- a/libgeda/include/libgeda/edaerrors.h
+++ b/libgeda/include/libgeda/edaerrors.h
@@ -22,6 +22,7 @@
/*! Error numbers for errors originating in libgeda. */
typedef enum {
+ EDA_ERROR_RC_TWICE, /* Attempted to read a configuration file twice */
EDA_ERROR_NUM_ERRORS,
} EdaError;
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index 09cf151..106dec1 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -33,15 +33,11 @@ int g_read_file(TOPLEVEL *toplevel, const gchar *filename);
/* g_rc.c */
SCM g_rc_mode_general(SCM scmmode, const char *rc_name, int *mode_var,
const vstbl_entry *table, int table_size);
-gint g_rc_parse_general(TOPLEVEL *toplevel,
- const gchar *fname,
- const gchar *ok_msg, const gchar *err_msg);
-gint g_rc_parse_system_rc(TOPLEVEL *toplevel, const gchar *rcname);
-gint g_rc_parse_home_rc(TOPLEVEL *toplevel, const gchar *rcname);
-gint g_rc_parse_local_rc(TOPLEVEL *toplevel, const gchar *rcname);
-void g_rc_parse(TOPLEVEL *toplevel, const gchar* rcname,
- const gchar* specified_rc_filename);
-gint g_rc_parse_specified_rc(TOPLEVEL *toplevel, const gchar *rcfilename);
+gboolean g_rc_parse_system (TOPLEVEL *toplevel, const gchar *rcname, GError **err);
+gboolean g_rc_parse_user (TOPLEVEL *toplevel, const gchar *rcname, GError **err);
+gboolean g_rc_parse_local (TOPLEVEL *toplevel, const gchar *rcname, const gchar *path, GError **err);
+gboolean g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err);
+void g_rc_parse(TOPLEVEL *toplevel, const gchar* rcname, const gchar* rcfile);
/* g_smob.c */
SCM g_make_attrib_smob(TOPLEVEL *curr_w, OBJECT *curr_attr);
diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index 3c7d16d..e69110c 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -242,7 +242,12 @@ int f_open_flags(TOPLEVEL *toplevel, PAGE *page,
/* Now open RC and process file */
if (flags & F_OPEN_RC) {
full_rcfilename = g_build_filename (file_directory, "gafrc", NULL);
- g_rc_parse_specified_rc(toplevel, full_rcfilename);
+ g_rc_parse_file (toplevel, full_rcfilename, &tmp_err);
+ if (tmp_err != NULL) {
+ s_log_message ("%s\n", tmp_err->message);
+ g_error_free (tmp_err);
+ tmp_err = NULL;
+ }
}
g_free (file_directory);
diff --git a/libgeda/src/g_rc.c b/libgeda/src/g_rc.c
index 75112e9..2edd63e 100644
--- a/libgeda/src/g_rc.c
+++ b/libgeda/src/g_rc.c
@@ -19,6 +19,7 @@
*/
#include <config.h>
+#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -104,237 +105,272 @@ SCM g_rc_mode_general(SCM scmmode,
return ret;
}
-
-/*! \brief Reads the gafrc file.
- * \par Function Description
- * This is the function which actually reads in the RC file.
- * First, it looks in a list of previously read RC files. If the file has
- * already been read, it just says OK. After reading the file, it places
- * the filename in the list of read files.
- *
- * \param [in] toplevel The TOPLEVEL object.
- * \param [in] fname RC file name to read.
- * \param [in] ok_msg Message to print if file is read ok.
- * \param [in] err_msg Message to print if file read error occurs
- * \return 1 on success, 0 otherwise.
+/*! \brief Load a system configuration file.
+ * \par Function Description
+ * Attempts to load the system configuration file with basename \a
+ * rcname. The string "system-" is prefixed to \a rcname. If \a
+ * rcname is NULL, the default value of "gafrc" is used.
+ *
+ * \param toplevel The current #TOPLEVEL structure.
+ * \param rcfile The basename of the configuration file to load, or NULL.
+ * \param err Return location for errors, or NULL.
+ * \return TRUE on success, FALSE on failure.
*/
-gint g_rc_parse_general(TOPLEVEL *toplevel,
- const gchar *fname,
- const gchar *ok_msg, const gchar *err_msg)
+gboolean
+g_rc_parse_system (TOPLEVEL *toplevel, const gchar *rcname, GError **err)
{
- gint found_rc = FALSE;
- GList *found_rc_filename_element;
-
- /* First see if fname is in list of previously read RC files. */
- found_rc_filename_element = g_list_find_custom(toplevel->RC_list,
- (gconstpointer) fname,
- (GCompareFunc) strcmp);
- if (found_rc_filename_element != NULL) {
- /* We've already read this one in. */
- s_log_message(_("RC file [%s] already read in.\n"), fname);
- return 0;
- }
+ gchar *sysname = NULL;
+ gboolean status;
- /* Now try to read in contents of RC file. */
- if (access (fname, R_OK) == 0) {
- g_read_file (toplevel, fname);
- found_rc = 1;
- /* Everything was OK. Now add this file to list of read RC files. */
- toplevel->RC_list = g_list_append (toplevel->RC_list,
- g_strdup (fname));
- s_log_message (ok_msg, fname);
- } else {
- found_rc = 0;
- s_log_message (err_msg, fname);
- }
+ /* Default to gafrc */
+ rcname = (rcname != NULL) ? rcname : "gafrc";
- return found_rc;
+ sysname = g_strdup_printf ("system-%s", rcname);
+ status = g_rc_parse_local (toplevel, sysname, s_path_sys_config (), err);
+ g_free (sysname);
+ return status;
}
-
-/*! \brief Parses a system RC file.
- * \par Function Description
- * This function wil open and parse a system rc file.
+/*! \brief Load a user configuration file.
+ * \par Function Description
+ * Attempts to load the user configuration file with basename \a
+ * rcname. If \a rcname is NULL, the default value of "gafrc" is
+ * used.
*
- * \param [in] toplevel The TOPLEVEL object.
- * \param [in] rcname System RC file name to parse.
- * \return 1 on success, 0 on failure.
+ * \param toplevel The current #TOPLEVEL structure.
+ * \param rcfile The basename of the configuration file to load, or NULL.
+ * \param err Return location for errors, or NULL.
+ * \return TRUE on success, FALSE on failure.
*/
-gint g_rc_parse_system_rc(TOPLEVEL *toplevel, const gchar *rcname)
+gboolean
+g_rc_parse_user (TOPLEVEL *toplevel, const gchar *rcname, GError **err)
{
- gint found_rc;
- gchar *tmp;
- char *filename;
- gchar *ok_msg, *err_msg;
-
- tmp = g_strconcat (s_path_sys_config (),
- G_DIR_SEPARATOR_S,
- "system-", rcname,
- NULL);
- filename = f_normalize_filename (tmp, NULL);
- if (filename == NULL) {
- return 0;
- }
+ /* Default to gafrc */
+ rcname = (rcname != NULL) ? rcname : "gafrc";
- ok_msg = g_strdup_printf (_("Read system config file [%%s]\n"));
- err_msg = g_strdup_printf (_("Did not find required system config file [%%s]\n"));
- found_rc = g_rc_parse_general(toplevel, filename, ok_msg, err_msg);
-
- g_free(ok_msg);
- g_free(err_msg);
- g_free(tmp);
- g_free(filename);
-
- return found_rc;
+ return g_rc_parse_local (toplevel, rcname, s_path_user_config (), err);
}
-/*! \brief Parse a RC file in users home directory.
- * \par Function Description
- * This function will open and parse a RC file in the users home directory.
+/*! \brief Load a local configuration file.
+ * \par Function Description
+ * Attempts to load the configuration file with basename \a rcname
+ * corresponding to \a path, reporting errors via \a err. If \a path
+ * is a directory, looks for a file named \a rcname in that
+ * directory. Otherwise, looks for a file named \a rcname in the same
+ * directory as \a path. If \a path is NULL, looks in the current
+ * directory. If \a rcname is NULL, the default value of "gafrc" is
+ * used.
*
- * \param [in] toplevel The TOPLEVEL object.
- * \param [in] rcname User's RC file name.
- * \return 1 on success, 0 on failure.
+ * \param toplevel The current #TOPLEVEL structure.
+ * \param rcname The basename of the configuration file to load, or NULL.
+ * \param path The path to load a configuration file for, or NULL.
+ * \param err Return location for errors, or NULL.
+ * \return TRUE on success, FALSE on failure.
*/
-gint g_rc_parse_home_rc(TOPLEVEL *toplevel, const gchar *rcname)
+gboolean
+g_rc_parse_local (TOPLEVEL *toplevel, const gchar *rcname, const gchar *path,
+ GError **err)
{
- gint found_rc;
- gchar *tmp;
- char *filename;
- gchar *ok_msg, *err_msg;
-
- if (s_path_user_config () == NULL) return 0;
-
- tmp = g_build_filename (s_path_user_config (), rcname, NULL);
- filename = f_normalize_filename (tmp, NULL);
- if (filename == NULL) {
- return 0;
+ gchar *dir = NULL;
+ gchar *rcfile = NULL;
+ gboolean status;
+ g_return_val_if_fail ((toplevel != NULL), FALSE);
+
+ /* Default to gafrc */
+ rcname = (rcname != NULL) ? rcname : "gafrc";
+ /* Default to cwd */
+ path = (path != NULL) ? path : ".";
+
+ /* If path isn't a directory, get the dirname. */
+ if (g_file_test (path, G_FILE_TEST_IS_DIR)) {
+ dir = g_strdup (path);
+ } else {
+ dir = g_path_get_dirname (path);
}
- ok_msg = g_strdup_printf (_("Read user config file [%%s]\n"));
- err_msg = g_strdup_printf (_("Did not find optional user config file [%%s]\n"));
- found_rc = g_rc_parse_general(toplevel, filename, ok_msg, err_msg);
-
- g_free(ok_msg);
- g_free(err_msg);
- g_free(tmp);
- g_free(filename);
+ rcfile = g_build_filename (dir, rcname, NULL);
+ status = g_rc_parse_file (toplevel, rcfile, err);
- return found_rc;
+ g_free (dir);
+ g_free (rcfile);
+ return status;
}
-/*! \brief Parse rc file in current working directory.
- * \par Function Description
- * This function will open and parse a RC file in the current working directory.
+/*! \brief Mark a configuration file as read.
+ * \par Function Description
+ * If the config file \a filename has not already been loaded, mark it
+ * as loaded and return TRUE, storing \a filename in \a toplevel (\a
+ * filename should not subsequently be freed). Otherwise, return
+ * FALSE, and set \a err appropriately.
+ *
+ * \note Should only be called by g_rc_parse_file().
*
- * \param [in] toplevel The TOPLEVEL object.
- * \param [in] rcname Local directory RC file name.
- * \return 1 on success, 0 on failure.
+ * \param toplevel The current #TOPLEVEL structure.
+ * \param filename The config file name to test.
+ * \param err Return location for errors, or NULL.
+ * \return TRUE if \a filename not already loaded, FALSE otherwise.
*/
-gint g_rc_parse_local_rc(TOPLEVEL *toplevel, const gchar *rcname)
+static gboolean
+g_rc_try_mark_read (TOPLEVEL *toplevel, gchar *filename, GError **err)
{
- gint found_rc;
- char *filename;
- gchar *ok_msg;
- gchar *err_msg;
-
- filename = f_normalize_filename (rcname, NULL);
- if (filename == NULL) {
- return 0;
+ GList *found = NULL;
+ g_return_val_if_fail ((toplevel != NULL), FALSE);
+ g_return_val_if_fail ((filename != NULL), FALSE);
+
+ /* Test if marked read already */
+ found = g_list_find_custom (toplevel->RC_list, filename,
+ (GCompareFunc) strcmp);
+ if (found != NULL) {
+ g_set_error (err, EDA_ERROR, EDA_ERROR_RC_TWICE,
+ _("Config file already loaded"));
+ return FALSE;
}
- ok_msg = g_strdup_printf (_("Read local config file [%%s]\n"));
- err_msg = g_strdup_printf (_("Did not find optional local config file [%%s]\n"));
- found_rc = g_rc_parse_general(toplevel, filename, ok_msg, err_msg);
-
- g_free(ok_msg);
- g_free(err_msg);
- g_free(filename);
-
- return found_rc;
+ toplevel->RC_list = g_list_append (toplevel->RC_list, filename);
+ /* N.b. don't free name_norm here; it's stored in the TOPLEVEL. */
+ return TRUE;
}
-/*! \brief Parse a RC file from a specified location.
- * \par Function Description
- * This function will open and parse a RC file from a specified location.
+/*! \brief Load a configuration file.
+ * \par Function Description
+ * Load the configuration file \a rcfile, reporting errors via \a err.
*
- * \param [in] toplevel The TOPLEVEL object.
- * \param [in] rcname Specified location RC file name.
- * \return 1 on success, 0 on failure.
+ * \param toplevel The current #TOPLEVEL structure.
+ * \param rcfile The filename of the configuration file to load.
+ * \param err Return location for errors, or NULL;
+ * \return TRUE on success, FALSE on failure.
*/
-gint g_rc_parse_specified_rc(TOPLEVEL *toplevel, const gchar *rcname)
+gboolean
+g_rc_parse_file (TOPLEVEL *toplevel, const gchar *rcfile, GError **err)
{
- gint found_rc = 0;
- char *filename;
- gchar *rcbasename;
- gchar *ok_msg;
- gchar *err_msg;
-
- if (rcname == NULL) {
- return 0;
+ gchar *name_norm = NULL;
+ GError *tmp_err = NULL;
+ g_return_val_if_fail ((toplevel != NULL), FALSE);
+ g_return_val_if_fail ((rcfile != NULL), FALSE);
+
+ /* Normalise filename */
+ name_norm = f_normalize_filename (rcfile, &tmp_err);
+ if (name_norm == NULL) goto parse_file_error;
+
+ /* Test that we can read the file. */
+ /*! \bug This is unsafe; there is a potential race condition between
+ * this check and the subsequent call to g_read_file(). This test
+ * should be done at the time that the file is opened for
+ * reading. See 'man access' for more information on the problems
+ * with access(). */
+ /*! \bug This reports EACCES if the file does not exist. Testing
+ * whether the file exists, is not a directory, and is readable all
+ * ought to be done at the same time as actually opening it for
+ * loading. */
+ if (access (name_norm, R_OK) != 0) {
+ g_set_error (&tmp_err, G_FILE_ERROR,
+ g_file_error_from_errno (EACCES),
+ g_strerror (EACCES));
+ goto parse_file_error;
}
- filename = f_normalize_filename (rcname, NULL);
- if (filename == NULL) {
- return 0;
+ /* Attempt to load the rc file, if it hasn't been loaded already.
+ * If g_rc_try_mark_read() succeeds, it stores name_norm in
+ * toplevel, so we *don't* free it. */
+ if (g_rc_try_mark_read (toplevel, name_norm, &tmp_err)) {
+ /*! \bug We should *definitely* populate err if loading the file
+ * causes errors. g_read_file() needs an update to support
+ * this. */
+ g_read_file (toplevel, name_norm);
+ s_log_message (_("Parsed config from [%s]\n"), name_norm);
+ return TRUE;
+ } else {
+ goto parse_file_error;
}
- rcbasename = g_path_get_basename (rcname);
+ parse_file_error:
+ /* Copy tmp_err into err, with a prefixed message. */
+ /*! \todo We should upgrade to GLib >= 2.16 and use
+ * g_propagate_prefixed_error(). */
+ if (err == NULL) {
+ g_error_free (tmp_err);
+ } else {
+ gchar *orig_msg = tmp_err->message;
+ tmp_err->message = g_strdup_printf (_("Unable to parse config from [%s]: %s"),
+ rcfile, orig_msg);
+ g_free (orig_msg);
+ *err = tmp_err;
+ }
+ g_free (name_norm);
+ return FALSE;
+}
- ok_msg = g_strdup_printf (_("Read specified %s file [%%s]\n"),
- rcbasename);
- err_msg = g_strdup_printf (_("Did not find specified %s file [%%s]\n"),
- rcbasename);
- found_rc = g_rc_parse_general(toplevel, filename, ok_msg, err_msg);
-
- g_free(ok_msg);
- g_free(err_msg);
- g_free(filename);
- g_free(rcbasename);
+static gboolean
+g_rc_parse__process_error (GError **err)
+{
+ g_return_val_if_fail ((err != NULL), FALSE);
- return found_rc;
+ /* For now, just print a log message to say whether or not the RC
+ * file loaded okay. */
+ if (*err == NULL) {
+ return TRUE;
+ } else {
+ s_log_message ("%s\n", (*err)->message);
+ g_error_free (*err);
+ *err = NULL;
+ return FALSE;
+ }
}
/*! \brief General RC file parsing function.
- * \par Function Description
- * This function will check for System, HOME and Local RC files matching
- * the rcname input parameter. If none of those three are found it will
- * search for the specified_rc_filename. When none are found it will
- * call exit(-1) to terminate the program.
- *
- * \param [in] toplevel The TOPLEVEL object.
- * \param [in] rcname RC file name.
- * \param [in] specified_rc_filename Specific location RC file name.
- * \return calls exit(-1) when no RC file matching either rcname or
- * specified_rc_filename is found.
+ * \par Function Description
+ * Attempt to load system, user and local (current working directory)
+ * configuration files, first with the default "gafrc" basename and
+ * then with the basename \a rcname, if \a rcname is not NULL.
+ * Additionally, attempt to load configuration from \a rcfile if \a
+ * rcfile is not NULL. If all attempts fail, call exit(1) to
+ * terminate the program.
+ *
+ * \bug libgeda shouldn't call exit().
+ *
+ * \deprecated New code should call the g_rc_parse_system(),
+ * g_rc_parse_user(), g_rc_parse_local(), or g_rc_parse_file()
+ * functions directly, and use the GError information to determine
+ * how to deal with errors (e.g. displaying a dialog box to the
+ * user).
+ *
+ * \param [in] toplevel The current #TOPLEVEL structure.
+ * \param [in] rcname Config file basename, or NULL.
+ * \param [in] rcfile Specific config file path, or NULL.
*/
-void g_rc_parse(TOPLEVEL *toplevel,
- const gchar *rcname, const gchar *specified_rc_filename)
+void
+g_rc_parse(TOPLEVEL *toplevel, const gchar *rcname, const gchar *rcfile)
{
gint found_rc = 0;
+ GError *err = NULL;
+
+ /* Load configuration files in order. */
+ /* First gafrc files. */
+ g_rc_parse_system (toplevel, NULL, &err);
+ found_rc |= g_rc_parse__process_error (&err);
+ g_rc_parse_user (toplevel, NULL, &err);
+ found_rc |= g_rc_parse__process_error (&err);
+ g_rc_parse_local (toplevel, NULL, NULL, &err);
+ found_rc |= g_rc_parse__process_error (&err);
+ /* Next application-specific rcname. */
+ if (rcname != NULL) {
+ g_rc_parse_system (toplevel, rcname, &err);
+ found_rc |= g_rc_parse__process_error (&err);
+ g_rc_parse_user (toplevel, rcname, &err);
+ found_rc |= g_rc_parse__process_error (&err);
+ g_rc_parse_local (toplevel, rcname, NULL, &err);
+ found_rc |= g_rc_parse__process_error (&err);
+ }
+ /* Finally, optional additional config file. */
+ if (rcfile != NULL) {
+ g_rc_parse_file (toplevel, rcfile, &err);
+ found_rc |= g_rc_parse__process_error (&err);
+ }
- /* visit rc files in order */
- /* Changed by SDB 1.2.2005 in response to Peter Kaiser's bug report.
- * Read gafrc files first */
- found_rc |= g_rc_parse_system_rc(toplevel, "gafrc");
- found_rc |= g_rc_parse_home_rc(toplevel, "gafrc");
- found_rc |= g_rc_parse_local_rc(toplevel, "gafrc");
- /* continue support for individual rc files for each program. */
- found_rc |= g_rc_parse_system_rc(toplevel, rcname);
- found_rc |= g_rc_parse_home_rc(toplevel, rcname);
- found_rc |= g_rc_parse_local_rc(toplevel, rcname);
-
- /* New fcn introduced by SDB to consolidate this & make it available
- * for other programs */
- found_rc |= g_rc_parse_specified_rc(toplevel, specified_rc_filename);
-
- /* Oh well, I couldn't find any rcfile, exit! */
+ /*! Exit if no config files could be loaded. */
if (!found_rc) {
- /*! \todo these two are basically the
- * same. Inefficient!
- */
- s_log_message(_("Could not find any %s file!\n"), rcname);
- exit(-1);
+ s_log_message (_("ERROR: Could not load any config files."));
+ exit (1);
}
}
commit 2d8cf61e790e6a17cde3b3f16dae205b83e9395f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
Distribute a copy of the LGPL v2.1.
Since we have several source files which are LGPL licensed, and they
state that the reader should have received a copy of the LGPL with
this program, distribute a copy of the LGPL with this program.
diff --git a/COPYING.LGPL b/COPYING.LGPL
new file mode 100644
index 0000000..4362b49
--- /dev/null
+++ b/COPYING.LGPL
@@ -0,0 +1,502 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/Makefile.am b/Makefile.am
index c83837d..316d6f2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,8 @@ DISTCHECK_CONFIGURE_FLAGS = \
--disable-update-xdg-database
BUILT_SOURCES = version.h
-EXTRA_DIST = autogen.sh version.h version.h.in README.Cygwin HACKING
+EXTRA_DIST = autogen.sh version.h version.h.in README.Cygwin HACKING \
+ COPYING.LGPL
# Generate version.h. This works by looking at any git repository that
# is present in the source directory (detected at configure time). If
commit 34290684615f5cf562d3be4f15a3ed2280f99bf1
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Add a GError domain for libgeda errors.
This patch defines the EDA_ERROR domain for GErrors, and is required
in order to be able to return or handle libgeda-specific GErrors. It
does not define any error codes yet.
diff --git a/libgeda/include/Makefile.am b/libgeda/include/Makefile.am
index a8bfbef..6b06666 100644
--- a/libgeda/include/Makefile.am
+++ b/libgeda/include/Makefile.am
@@ -4,6 +4,7 @@ libgedaincludedir = $(includedir)/libgeda
libgedainclude_HEADERS = \
libgeda/colors.h \
libgeda/defines.h \
+ libgeda/edaerrors.h \
libgeda/funcs.h \
libgeda/geda_list.h \
libgeda/globals.h \
@@ -13,6 +14,7 @@ libgedainclude_HEADERS = \
libgeda/prototype.h \
libgeda/struct.h
+
noinst_HEADERS = \
gettext_priv.h \
i_vars_priv.h \
diff --git a/libgeda/include/libgeda/edaerrors.h b/libgeda/include/libgeda/edaerrors.h
new file mode 100644
index 0000000..e97bdea
--- /dev/null
+++ b/libgeda/include/libgeda/edaerrors.h
@@ -0,0 +1,28 @@
+/* gEDA - GPL Electronic Design Automation
+ * libgeda - gEDA's Library
+ * Copyright (C) 2011 gEDA Contributors (see ChangeLog for details)
+ *
+ * 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
+ */
+
+/*! Domain for GErrors originating in libgeda. */
+#define EDA_ERROR eda_error_quark ()
+
+/*! Error numbers for errors originating in libgeda. */
+typedef enum {
+ EDA_ERROR_NUM_ERRORS,
+} EdaError;
+
+GQuark eda_error_quark (void);
diff --git a/libgeda/include/libgeda/libgeda.h b/libgeda/include/libgeda/libgeda.h
index d8e6e7e..7dc8608 100644
--- a/libgeda/include/libgeda/libgeda.h
+++ b/libgeda/include/libgeda/libgeda.h
@@ -34,6 +34,7 @@
#include <libgeda/colors.h>
#include <libgeda/papersizes.h>
#include <libgeda/prototype.h>
+#include <libgeda/edaerrors.h>
#include <libgeda/geda_list.h>
#endif
diff --git a/libgeda/include/libgeda_priv.h b/libgeda/include/libgeda_priv.h
index 83f69ff..ccd1731 100644
--- a/libgeda/include/libgeda_priv.h
+++ b/libgeda/include/libgeda_priv.h
@@ -13,6 +13,7 @@
#include "papersizes.h"
#include "prototype.h"
#include "funcs.h"
+#include "edaerrors.h"
#include "geda_list.h"
diff --git a/libgeda/src/Makefile.am b/libgeda/src/Makefile.am
index ae62fe8..0a99ce7 100644
--- a/libgeda/src/Makefile.am
+++ b/libgeda/src/Makefile.am
@@ -4,6 +4,7 @@ lib_LTLIBRARIES = libgeda.la
libgeda_la_SOURCES = \
a_basic.c \
+ edaerrors.c \
f_basic.c \
f_print.c \
g_basic.c \
diff --git a/libgeda/src/edaerrors.c b/libgeda/src/edaerrors.c
new file mode 100644
index 0000000..ceff687
--- /dev/null
+++ b/libgeda/src/edaerrors.c
@@ -0,0 +1,28 @@
+/* gEDA - GPL Electronic Design Automation
+ * libgeda - gEDA's Library
+ * Copyright (C) 2011 gEDA Contributors (see ChangeLog for details)
+ *
+ * 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
+ */
+#include <config.h>
+#include <libgeda_priv.h>
+
+/* Used by EDA_ERROR. Returns a GQuark used to identify GErrors
+ * originating in libgeda. Should not be called directly. */
+GQuark
+eda_error_quark (void)
+{
+ return g_quark_from_static_string ("eda-error-quark");
+}
commit da0fbc2cc3317e6f5c995385f3986bb2e6689f1b
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>
libgeda: Simplify g_scm_eval_string_protected().
Instead of defining a body function and calling scm_c_catch()
ourselves, build a Scheme expression and evaluate it using
g_scm_eval_protected().
diff --git a/libgeda/src/g_basic.c b/libgeda/src/g_basic.c
index 15dda39..935ef54 100644
--- a/libgeda/src/g_basic.c
+++ b/libgeda/src/g_basic.c
@@ -174,13 +174,6 @@ SCM g_scm_eval_protected (SCM exp, SCM module_or_state)
return result;
}
-/* Actually carries out evaluation for protected eval-string */
-static SCM protected_body_eval_string (void *data)
-{
- SCM str = *((SCM *)data);
- return scm_eval_string (str);
-}
-
/*! \brief Evaluate a C string as a Scheme expression safely
* \par Function Description
*
@@ -213,21 +206,10 @@ SCM g_scm_c_eval_string_protected (const gchar *str) {
*/
SCM g_scm_eval_string_protected (SCM str)
{
- SCM stack = SCM_BOOL_T;
- SCM result;
-
- result = scm_c_catch (SCM_BOOL_T,
- protected_body_eval_string, /* catch body */
- &str, /* body data */
- protected_post_unwind_handler, /* post handler */
- &stack, /* post data */
- protected_pre_unwind_handler, /* pre handler */
- &stack /* pre data */
- );
-
- scm_remember_upto_here_1 (stack);
+ SCM expr = scm_list_2 (scm_from_locale_symbol ("eval-string"),
+ str);
- return result;
+ return g_scm_eval_protected (expr, SCM_UNDEFINED);
}
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs