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

gEDA-cvs: branch: master updated (1.1.2.20070818-101-g6831e3c)



The branch, master has been updated
       via  6831e3cbfbd23964ceb42f294075053899a9bcad (commit)
       via  fff63c25fd6b3401cfc5bbf15706bb0107d74e8a (commit)
       via  74e7888ed1d23eac05d097f9d635d4a58a6576a3 (commit)
       via  8b490a404e682ac4f1e4cbd46e22c92f58b2ae76 (commit)
       via  537fc4784a25756d7c38b4fbbcc1059b41f5664b (commit)
       via  493fef662fb68301ad786fcbf3cf5cdbcb1078d1 (commit)
      from  0b0d1259692ffe36e3bbc617af78bbf8a1c8f716 (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
=========

 gattrib/configure.ac        |    3 +
 gnetlist/configure.ac       |    3 +
 gschem/autogen.sh           |   12 ++-
 gschem/configure.ac.in      |    3 +
 gschem/scripts/gschemdoc.sh |    6 +-
 gsymcheck/configure.ac      |    3 +
 libgeda/autogen.sh          |   12 ++-
 libgeda/configure.ac        |    3 +
 libgeda/include/prototype.h |    7 +-
 libgeda/src/a_basic.c       |  224 ++++++++++++++++--------------------------
 libgeda/src/o_attrib.c      |   22 +++--
 libgeda/src/s_clib.c        |    8 +-
 utils/.gitignore            |    1 +
 utils/configure.ac          |    3 +
 14 files changed, 142 insertions(+), 168 deletions(-)


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

commit 6831e3cbfbd23964ceb42f294075053899a9bcad
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Fri Nov 23 21:44:18 2007 +0000

    libgeda: Update some component library doc comments.

:100644 100644 0ecdaf2... 28e2878... M	libgeda/src/s_clib.c

commit fff63c25fd6b3401cfc5bbf15706bb0107d74e8a
Author: Cesar Strauss <cestrauss@xxxxxxxxx>
Date:   Sat Nov 10 17:45:13 2007 -0200

    utils: Tell git to ignore the ylwrap file. [1833107]

:100644 100644 5979c37... a6c1b63... M	utils/.gitignore

commit 74e7888ed1d23eac05d097f9d635d4a58a6576a3
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Fri Nov 23 21:43:49 2007 +0000

    gschemdoc: Quote variables in case they contain spaces. [1792986]
    
    In the gschemdoc shell script, the variables $pdfreader and $browser
    need quoting on lines 86, 113 and 128 (eg "${browser}"). Otherwise,
    paths with spaces in, like "Program Files/Mozilla Firefox" commonly
    used in Windows don't work.
    
    Based on anonymous SourceForge patch.

:100644 100644 ee6c1cb... acae51c... M	gschem/scripts/gschemdoc.sh

commit 8b490a404e682ac4f1e4cbd46e22c92f58b2ae76
Author: Tomaž Šolc <tomaz.solc@xxxxxxxxxx>
Date:   Fri Nov 23 21:42:50 2007 +0000

    Compilation fixes for Mac OS X 10.5 [1832417]
    
    This patch contains changes to gEDA source tree that were necessary to
    compile on Mac OS X (10.5 Leopard, PPC).

:100644 100644 fea2f3b... e4b594c... M	gattrib/configure.ac
:100644 100644 fbe6e50... 962ec34... M	gnetlist/configure.ac
:100755 100755 ffefb13... b06a5b7... M	gschem/autogen.sh
:100644 100644 4e0a882... 97b4297... M	gschem/configure.ac.in
:100644 100644 5da5c2d... 5f68235... M	gsymcheck/configure.ac
:100755 100755 e29a856... fe4732a... M	libgeda/autogen.sh
:100644 100644 68b5267... 291816b... M	libgeda/configure.ac
:100644 100644 48bf556... 51cffe2... M	utils/configure.ac

commit 537fc4784a25756d7c38b4fbbcc1059b41f5664b
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Fri Nov 23 21:42:47 2007 +0000

    libgeda: Add the ability to save into a buffer.

:100644 100644 1710fdf... ede03ef... M	libgeda/include/prototype.h
:100644 100644 8092655... f46b461... M	libgeda/src/a_basic.c
:100644 100644 c2c56ba... b8ea3f0... M	libgeda/src/o_attrib.c

commit 493fef662fb68301ad786fcbf3cf5cdbcb1078d1
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Fri Nov 23 21:42:37 2007 +0000

    libgeda: Refactor file header string generation.
    
    Replace function for writing file header out to file with one which
    just returns a string containing the header.

:100644 100644 f86e318... 1710fdf... M	libgeda/include/prototype.h
:100644 100644 b11e493... 8092655... M	libgeda/src/a_basic.c

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

commit 6831e3cbfbd23964ceb42f294075053899a9bcad
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Fri Nov 23 21:44:18 2007 +0000

    libgeda: Update some component library doc comments.

diff --git a/libgeda/src/s_clib.c b/libgeda/src/s_clib.c
index 0ecdaf2..28e2878 100644
--- a/libgeda/src/s_clib.c
+++ b/libgeda/src/s_clib.c
@@ -25,10 +25,10 @@
  *  The <b>component library</b> is made up of a number of
  *  <b>component sources</b>, each of which in turn makes available a
  *  number of component <b>symbols</b>.  Each source may be either a
- *  directory on disk containing symbol files, or a command in the
- *  system PATH which can generate gEDA symbol data (e.g. from a
- *  database).  A component source is represented by a #CLibSource
- *  instance.
+ *  directory on disk containing symbol files, a command in the system
+ *  PATH which can generate gEDA symbol data (e.g. from a database),
+ *  or a Scheme function which can do likewise.  A component source is
+ *  represented by a #CLibSource instance.
  *
  *  The component library system manages component sources and
  *  symbols, and abstracts the interface to the underlying storage.

commit fff63c25fd6b3401cfc5bbf15706bb0107d74e8a
Author: Cesar Strauss <cestrauss@xxxxxxxxx>
Date:   Sat Nov 10 17:45:13 2007 -0200

    utils: Tell git to ignore the ylwrap file. [1833107]

diff --git a/utils/.gitignore b/utils/.gitignore
index 5979c37..a6c1b63 100644
--- a/utils/.gitignore
+++ b/utils/.gitignore
@@ -16,3 +16,4 @@ missing
 mkinstalldirs
 compile
 *~
+ylwrap

commit 74e7888ed1d23eac05d097f9d635d4a58a6576a3
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Fri Nov 23 21:43:49 2007 +0000

    gschemdoc: Quote variables in case they contain spaces. [1792986]
    
    In the gschemdoc shell script, the variables $pdfreader and $browser
    need quoting on lines 86, 113 and 128 (eg "${browser}"). Otherwise,
    paths with spaces in, like "Program Files/Mozilla Firefox" commonly
    used in Windows don't work.
    
    Based on anonymous SourceForge patch.

diff --git a/gschem/scripts/gschemdoc.sh b/gschem/scripts/gschemdoc.sh
index ee6c1cb..acae51c 100644
--- a/gschem/scripts/gschemdoc.sh
+++ b/gschem/scripts/gschemdoc.sh
@@ -87,7 +87,7 @@ view_file_browser()
 		echo "Using browser and file: $file"
 		# NOTE: Mozilla and Netscape does not seem to support
 		#       -- on the command line
-		${browser} "file://$file"
+		"${browser}" "file://$file"
 		exit
 	else
 		echo "Did not find a browser application."
@@ -102,7 +102,7 @@ go_look_for()
 {
 	if test "${browser}" != "no" ; then
 		echo "Go look for: $1"
-		${browser} "http://www.google.com/search?q=$1%20filetype:pdf";
+		"${browser}" "http://www.google.com/search?q=$1%20filetype:pdf";
 		exit
 	else
 		echo "Did not find a browser application."
@@ -226,7 +226,7 @@ if test "${browser}" != "no"; then
 		if echo "$1" | grep -q "^$s:"; then
 			echo "Found ${browser}"
 			echo "Using browser and URL: $1"
-			${browser} "$1"
+			"${browser}" "$1"
 			exit
 		fi
 	done

commit 8b490a404e682ac4f1e4cbd46e22c92f58b2ae76
Author: Tomaž Šolc <tomaz.solc@xxxxxxxxxx>
Date:   Fri Nov 23 21:42:50 2007 +0000

    Compilation fixes for Mac OS X 10.5 [1832417]
    
    This patch contains changes to gEDA source tree that were necessary to
    compile on Mac OS X (10.5 Leopard, PPC).

diff --git a/gattrib/configure.ac b/gattrib/configure.ac
index fea2f3b..e4b594c 100644
--- a/gattrib/configure.ac
+++ b/gattrib/configure.ac
@@ -85,10 +85,13 @@ fi
 
 # Guile 1.6 compatability
 
+CFLAGS_temp_save="$CFLAGS"
+CFLAGS="$CFLAGS $GUILE_CFLAGS"
 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
 scm_from_int,  scm_is_true,    scm_is_false,
 scm_from_locale_string, scm_to_locale_string],,,
 [#include <libguile.h>])
+CFLAGS="$CFLAGS_temp_save"
 
 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
 #  define scm_is_string(x) SCM_STRINGP(x)
diff --git a/gnetlist/configure.ac b/gnetlist/configure.ac
index fbe6e50..962ec34 100644
--- a/gnetlist/configure.ac
+++ b/gnetlist/configure.ac
@@ -164,10 +164,13 @@ fi
 
 # Guile 1.6 compatability
 
+CFLAGS_temp_save="$CFLAGS"
+CFLAGS="$CFLAGS $GUILE_CFLAGS"
 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
 scm_from_int,  scm_is_true,    scm_is_false,
 scm_from_locale_string, scm_to_locale_string],,,
 [#include <libguile.h>])
+CFLAGS="$CFLAGS_temp_save"
 
 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
 #  define scm_is_string(x) SCM_STRINGP(x)
diff --git a/gschem/autogen.sh b/gschem/autogen.sh
index ffefb13..b06a5b7 100755
--- a/gschem/autogen.sh
+++ b/gschem/autogen.sh
@@ -8,6 +8,9 @@ srcdir=`dirname $0`
 test -z "$srcdir" && srcdir=.
 configure_script=configure.ac.in
 
+# Possible names for libtool/libtoolize
+libtoolize_candidates="libtoolize glibtoolize"
+
 DIE=0
 
 (test -f $srcdir/$configure_script) || {
@@ -25,7 +28,8 @@ DIE=0
 }
 
 (grep "^AM_PROG_LIBTOOL" $srcdir/$configure_script >/dev/null) && {
-  (libtool --version) < /dev/null > /dev/null 2>&1 || {
+  LIBTOOLIZE=`which $libtoolize_candidates 2>/dev/null | head -n1`
+  (! test -z "$LIBTOOLIZE") || {
     echo
     echo "**Error**: You must have \`libtool' installed."
     echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/";
@@ -104,10 +108,8 @@ do
         #mv -f $dr/po/Makevars.template $dr/po/Makevars
       fi
       if grep "^AM_PROG_LIBTOOL" $configure_script >/dev/null; then
-	if test -z "$NO_LIBTOOLIZE" ; then 
-	  echo "autogen.sh running: libtoolize ..."
-	  libtoolize --force --copy
-	fi
+	echo "autogen.sh running: libtoolize ..."
+	$LIBTOOLIZE --force --copy
       fi
       echo "autogen.sh running: aclocal $aclocalinclude ..."
       aclocal $aclocalinclude
diff --git a/gschem/configure.ac.in b/gschem/configure.ac.in
index 4e0a882..97b4297 100644
--- a/gschem/configure.ac.in
+++ b/gschem/configure.ac.in
@@ -88,10 +88,13 @@ fi
 
 # Guile 1.6 compatability
 
+CFLAGS_temp_save="$CFLAGS"
+CFLAGS="$CFLAGS $GUILE_CFLAGS"
 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
 scm_from_int,  scm_is_true,    scm_is_false,
 scm_from_locale_string, scm_to_locale_string],,,
 [#include <libguile.h>])
+CFLAGS="$CFLAGS_temp_save"
 
 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
 #  define scm_is_string(x) SCM_STRINGP(x)
diff --git a/gsymcheck/configure.ac b/gsymcheck/configure.ac
index 5da5c2d..5f68235 100644
--- a/gsymcheck/configure.ac
+++ b/gsymcheck/configure.ac
@@ -76,10 +76,13 @@ fi
 
 # Guile 1.6 compatability
 
+CFLAGS_temp_save="$CFLAGS"
+CFLAGS="$CFLAGS $GUILE_CFLAGS"
 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
 scm_from_int,  scm_is_true,    scm_is_false,
 scm_from_locale_string, scm_to_locale_string],,,
 [#include <libguile.h>])
+CFLAGS="$CFLAGS_temp_save"
 
 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
 #  define scm_is_string(x) SCM_STRINGP(x)
diff --git a/libgeda/autogen.sh b/libgeda/autogen.sh
index e29a856..fe4732a 100755
--- a/libgeda/autogen.sh
+++ b/libgeda/autogen.sh
@@ -13,6 +13,9 @@ AM_1=1  # Major number
 AM_2=6
 AM_3=0  # Minor number
 
+# Possible names for libtool/libtoolize
+libtoolize_candidates="libtoolize glibtoolize"
+
 DIE=0
 
 (test -f $srcdir/$configure_script) || {
@@ -30,7 +33,8 @@ DIE=0
 }
 
 (grep "^AM_PROG_LIBTOOL" $srcdir/$configure_script >/dev/null) && {
-  (libtool --version) < /dev/null > /dev/null 2>&1 || {
+  LIBTOOLIZE=`which $libtoolize_candidates 2>/dev/null | head -n1`
+  (! test -z "$LIBTOOLIZE") || {
     echo
     echo "**Error**: You must have \`libtool' installed."
     echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/";
@@ -134,10 +138,8 @@ do
         #mv -f $dr/po/Makevars.template $dr/po/Makevars
       fi
       if grep "^AM_PROG_LIBTOOL" $configure_script >/dev/null; then
-	if test -z "$NO_LIBTOOLIZE" ; then 
-	  echo "autogen.sh running: libtoolize ..."
-	  libtoolize --force --copy
-	fi
+	echo "autogen.sh running: libtoolize ..."
+	$LIBTOOLIZE --force --copy
       fi
       echo "autogen.sh running: aclocal $aclocalinclude ..."
       aclocal $aclocalinclude
diff --git a/libgeda/configure.ac b/libgeda/configure.ac
index 68b5267..291816b 100644
--- a/libgeda/configure.ac
+++ b/libgeda/configure.ac
@@ -86,10 +86,13 @@ fi
 
 # Guile 1.6 compatability
 
+CFLAGS_temp_save="$CFLAGS"
+CFLAGS="$CFLAGS $GUILE_CFLAGS"
 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
 scm_from_int,  scm_is_true,    scm_is_false,
 scm_from_locale_string, scm_to_locale_string],,,
 [#include <libguile.h>])
+CFLAGS="$CFLAGS_temp_save"
 
 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
 #  define scm_is_string(x) SCM_STRINGP(x)
diff --git a/utils/configure.ac b/utils/configure.ac
index 48bf556..51cffe2 100644
--- a/utils/configure.ac
+++ b/utils/configure.ac
@@ -115,10 +115,13 @@ fi
 
 # Guile 1.6 compatability
 
+CFLAGS_temp_save="$CFLAGS"
+CFLAGS="$CFLAGS $GUILE_CFLAGS"
 AC_CHECK_DECLS([scm_is_string, scm_is_integer, scm_to_int,
 scm_from_int,  scm_is_true,    scm_is_false,
 scm_from_locale_string, scm_to_locale_string],,,
 [#include <libguile.h>])
+CFLAGS="$CFLAGS_temp_save"
 
 AH_VERBATIM(SCM_IS_STRING, [#if !HAVE_DECL_SCM_IS_STRING
 #  define scm_is_string(x) SCM_STRINGP(x)

commit 537fc4784a25756d7c38b4fbbcc1059b41f5664b
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Fri Nov 23 21:42:47 2007 +0000

    libgeda: Add the ability to save into a buffer.

diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 1710fdf..ede03ef 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -1,6 +1,7 @@
 /* a_basic.c */
-void o_save_embedded(TOPLEVEL *toplevel, OBJECT *object_list, FILE *fp);
-const char *o_file_format_header();
+gchar *o_save_objects(OBJECT *object_list);
+const gchar *o_file_format_header();
+gchar *o_save_buffer(TOPLEVEL *toplevel);
 int o_save(TOPLEVEL *toplevel, const char *filename);
 OBJECT *o_read_buffer(TOPLEVEL *toplevel, OBJECT *object_list, char *buffer, const int size, const char *name);
 OBJECT *o_read(TOPLEVEL *toplevel, OBJECT *object_list, char *filename);
@@ -162,7 +163,7 @@ OBJECT *o_read_attribs(TOPLEVEL *toplevel,
 		       TextBuffer *tb,
 		       unsigned int release_ver, 
 		       unsigned int fileformat_ver);
-void o_save_attribs(FILE *fp, GList *attribs);
+gchar *o_save_attribs(GList *attribs);
 int o_attrib_get_name_value(char *string, char **name, char **value);
 void o_attrib_free_current(TOPLEVEL *toplevel);
 void o_attrib_set_string(TOPLEVEL *toplevel, char *string);
diff --git a/libgeda/src/a_basic.c b/libgeda/src/a_basic.c
index 8092655..f46b461 100644
--- a/libgeda/src/a_basic.c
+++ b/libgeda/src/a_basic.c
@@ -42,111 +42,6 @@
 /*! \brief Current version string */
 #define VERSION_20020825 20020825
 
-/*! \brief Save embedded attributes to current file
- *  \par Function Description
- *  This function will save all embedded attributes to a file.
- *
- *  \param [in,out] toplevel
- *  \param [in]     object_list  The list of attributes to write to file
- *  \param [in]     fp           The file to write to.
- */
-void o_save_embedded(TOPLEVEL *toplevel, OBJECT *object_list, FILE *fp)
-{
-  OBJECT *o_current=NULL;
-  char *out;
-
-  /* make sure you init net_consolide to false (default) in all */
-  /* programs */
-  if (toplevel->net_consolidate == TRUE) {
-    o_net_consolidate(toplevel);
-  }
-	
-  o_current = object_list;
-
-  while ( o_current != NULL ) {
-
-    if (o_current->type != OBJ_HEAD) {
-
-      if (o_current->attribute == 0) {
-
-        switch (o_current->type) {
-
-          case(OBJ_LINE):
-            out = (char *) o_line_save(o_current);
-            break;
-	
-          case(OBJ_NET):
-            out = (char *) o_net_save(o_current);
-            break;
-
-          case(OBJ_BUS):
-            out = (char *) o_bus_save(o_current);
-            break;
-	
-          case(OBJ_BOX):
-            out = (char *) o_box_save(o_current);
-            break;
-			
-          case(OBJ_CIRCLE):
-            out = (char *) o_circle_save(o_current);
-            break;
-
-          case(OBJ_COMPLEX):
-            out = (char *) o_complex_save(o_current);
-            if (o_complex_is_embedded(o_current)) {
-              fprintf(fp, "[\n");
-								
-              o_save_embedded(
-                              toplevel,
-                              o_current->
-                              complex->prim_objs,
-                              fp);
-
-              fprintf(fp, "]\n");
-            }
-            break;
-
-          case(OBJ_PLACEHOLDER):  /* new type by SDB 1.20.2005 */
-            out = (char *) o_complex_save(o_current);
-            break;
-
-          case(OBJ_TEXT):
-            out = (char *) o_text_save(o_current);
-            break;
-
-          case(OBJ_PIN):
-            out = (char *) o_pin_save(o_current);
-            break;
-	
-          case(OBJ_ARC):
-            out = (char *) o_arc_save(o_current);
-            break;
-
-  	  case(OBJ_PICTURE):
-	    out = (char *) o_picture_save(o_current); 
-	    break;
-
-          default:
-            fprintf(stderr, "Error type!\n");
-            exit(-1);
-            break;
-        }
-
-	/* output the line */
-        fprintf(fp, "%s\n", out);
-	g_free(out);
-
-        /* save those attributes */
-        if (o_current->attribs != NULL) {
-          o_save_attribs(fp, o_current->attribs);
-        }
-
-      }
-    } 
-    o_current = o_current->next;
-  }
-}
-
 /*! \brief Get the file header string.
  *  \par Function Description
  *  This function simply returns the DATE_VERSION and
@@ -164,29 +59,20 @@ const gchar *o_file_format_header()
   return header;
 }
 
-/*! \brief Save a file
+/*! \brief "Save" a file into a string buffer
  *  \par Function Description
- *  This function saves the data in a libgeda format to a file
- *  \param [in] toplevel  The data to save to file.
- *  \param [in] filename   The filename to save the data to.
- *  \return 1 on success, 0 on failure.
+ *  This function saves a whole schematic into a buffer in libgeda
+ *  format. The buffer should be freed when no longer needed.
+ *
+ *  \param [in] toplevel  The data to save.
+ *  \returns a buffer containing schematic data or NULL on failure.
  */
-int o_save(TOPLEVEL *toplevel, const char *filename)
+gchar *o_save_buffer (TOPLEVEL *toplevel)
 {
-  OBJECT *o_current=NULL;
-  FILE *fp;
-  char *out;
-  int already_wrote=0;
-	
-  fp = fopen(filename, "wb");
-	
-  if (fp == NULL) {
-    s_log_message("o_save: Could not open [%s]\n", filename);
-    return 0;
-  }
-
+  GString *acc;
+  gchar *buffer;
 
-  o_current = toplevel->page_current->object_head;
+  if (toplevel == NULL) return NULL;
 
   /* make sure you init net_consolide to false (default) in all */
   /* programs */
@@ -194,7 +80,34 @@ int o_save(TOPLEVEL *toplevel, const char *filename)
     o_net_consolidate(toplevel);
   }
 
-  fprintf(fp, o_file_format_header());
+  acc = g_string_new (o_file_format_header());
+
+  buffer = o_save_objects (toplevel->page_current->object_head);
+  g_string_append (acc, buffer);
+  g_free (buffer);
+
+  return g_string_free (acc, FALSE);
+}
+
+/*! \brief Save a series of objects into a string buffer
+ *  \par Function Description
+ *  This function recursively saves a set of objects into a buffer in
+ *  libgeda format.  User code should not normally call this function;
+ *  they should call o_save_buffer() instead.
+ *
+ *  \param [in] object_list  Head of list of objects to save.
+ *  \returns a buffer containing schematic data or NULL on failure.
+ */
+gchar *o_save_objects (OBJECT *object_list)
+{
+  OBJECT *o_current = object_list;
+  gchar *out;
+  GString *acc;
+  gboolean already_wrote = FALSE;
+
+  g_assert (object_list != NULL);
+
+  acc = g_string_new("");
 
   while ( o_current != NULL ) {
 
@@ -226,19 +139,18 @@ int o_save(TOPLEVEL *toplevel, const char *filename)
 
           case(OBJ_COMPLEX):
             out = (char *) o_complex_save(o_current);
-            fprintf(fp, "%s\n", out);
-            already_wrote=1;
+            g_string_append_printf(acc, "%s\n", out);
+            already_wrote = TRUE;
 	    g_free(out); /* need to free here because of the above flag */
+
             if (o_complex_is_embedded(o_current)) {
-              fprintf(fp, "[\n");
-								
-              o_save_embedded(
-                              toplevel,
-                              o_current->
-                              complex->prim_objs,
-                              fp);
-
-              fprintf(fp, "]\n");
+              g_string_append(acc, "[\n");
+	      
+              out = o_save_objects(o_current->complex->prim_objs);
+              g_string_append (acc, out);
+              g_free(out);
+
+              g_string_append(acc, "]\n");
             }
             break;
 
@@ -263,22 +175,25 @@ int o_save(TOPLEVEL *toplevel, const char *filename)
 	    break;
 
           default:
+            g_assert_not_reached();
             fprintf(stderr, "Error type!\n");
             exit(-1);
             break;
         }
 
-				/* output the line */
+        /* output the line */
         if (!already_wrote) {
-          fprintf(fp, "%s\n", out);
+          g_string_append_printf(acc, "%s\n", out);
 	  g_free(out);
         } else {
-          already_wrote=0;
+          already_wrote = FALSE;
         }
 
-				/* save those attributes */
+        /* save any attributes */
         if (o_current->attribs != NULL) {
-          o_save_attribs(fp, o_current->attribs);
+          out = o_save_attribs(o_current->attribs);
+          g_string_append(acc, out);
+          g_free (out);
         }
 
       }
@@ -286,7 +201,33 @@ int o_save(TOPLEVEL *toplevel, const char *filename)
     o_current = o_current->next;
   }
 
-  fclose(fp);
+  return g_string_free (acc, FALSE);
+}
+
+/*! \brief Save a file
+ *  \par Function Description
+ *  This function saves the data in a libgeda format to a file
+ *  \param [in] toplevel  The data to save to file.
+ *  \param [in] filename   The filename to save the data to.
+ *  \return 1 on success, 0 on failure.
+ */
+int o_save(TOPLEVEL *toplevel, const char *filename)
+{
+  FILE *fp;
+  char *buffer;
+	
+  fp = fopen(filename, "wb");
+	
+  if (fp == NULL) {
+    s_log_message("o_save: Could not open [%s]\n", filename);
+    return 0;
+  }
+
+  buffer = o_save_buffer (toplevel);
+  fwrite (buffer, strlen(buffer), 1, fp);
+  g_free (buffer);
+  fclose (fp);
+
   return 1;
 }
 
diff --git a/libgeda/src/o_attrib.c b/libgeda/src/o_attrib.c
index c2c56ba..b8ea3f0 100644
--- a/libgeda/src/o_attrib.c
+++ b/libgeda/src/o_attrib.c
@@ -488,26 +488,28 @@ OBJECT *o_read_attribs(TOPLEVEL *toplevel,
   return(object_list);
 }
 
-/*! \brief Save attributes to a file.
+/*! \brief Save attributes into a string buffer.
  *  \par Function Description
- *  Save attributes to a file.
+ *  Saves a list of attributes int a buffer in libgeda, including the
+ *  attribute list start and end markers.
  *
  *  \param [in] fp       FILE pointer to write attributes to.
  *  \param [in] attribs  attributes to write.
  *  \todo
  *  this should be trimmed down to only save attributes which are text items
  */
-void o_save_attribs(FILE *fp, GList *attribs)
+gchar *o_save_attribs(GList *attribs)
 {
   ATTRIB *a_current=NULL;
   OBJECT *o_current=NULL;
   GList *a_iter;
-  char *out;
+  GString *acc;
+  gchar *out;
 
   a_iter = attribs;
 
-  fprintf(fp, "{\n");
-	
+  acc = g_string_new("{\n");
+
   while ( a_iter != NULL ) {
     a_current = a_iter->data;
 
@@ -568,14 +570,16 @@ void o_save_attribs(FILE *fp, GList *attribs)
           exit(-1);
           break;
       }
-      /* output the line */
-      fprintf(fp, "%s\n", out);
+
+      g_string_append_printf(acc, "%s\n", out);
       g_free(out);
     }
     a_iter = g_list_next (a_iter);
   } 
 
-  fprintf(fp, "}\n");
+  g_string_append(acc, "}\n");
+
+  return g_string_free(acc, FALSE);
 }
 
 /*! \brief Get name and value from name=value attribute.

commit 493fef662fb68301ad786fcbf3cf5cdbcb1078d1
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Fri Nov 23 21:42:37 2007 +0000

    libgeda: Refactor file header string generation.
    
    Replace function for writing file header out to file with one which
    just returns a string containing the header.

diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index f86e318..1710fdf 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -1,6 +1,6 @@
 /* a_basic.c */
 void o_save_embedded(TOPLEVEL *toplevel, OBJECT *object_list, FILE *fp);
-void o_save_write_header(FILE *fp);
+const char *o_file_format_header();
 int o_save(TOPLEVEL *toplevel, const char *filename);
 OBJECT *o_read_buffer(TOPLEVEL *toplevel, OBJECT *object_list, char *buffer, const int size, const char *name);
 OBJECT *o_read(TOPLEVEL *toplevel, OBJECT *object_list, char *filename);
diff --git a/libgeda/src/a_basic.c b/libgeda/src/a_basic.c
index b11e493..8092655 100644
--- a/libgeda/src/a_basic.c
+++ b/libgeda/src/a_basic.c
@@ -147,16 +147,21 @@ void o_save_embedded(TOPLEVEL *toplevel, OBJECT *object_list, FILE *fp)
   }
 }
 
-/*! \brief Write libgeda file header
+/*! \brief Get the file header string.
  *  \par Function Description
- *  This function simply prints the DATE_VERSION and FILEFORMAT_VERSION
- *  definitions to the file.
- *  
- *  \param [in] fp  The file to write the header to.
+ *  This function simply returns the DATE_VERSION and
+ *  FILEFORMAT_VERSION formatted as a gEDA file header.
+ *
+ *  \warning <em>Do not</em> free the returned string.
  */
-void o_save_write_header(FILE *fp)
+const gchar *o_file_format_header()
 {
-  fprintf(fp, "v %s %u\n", DATE_VERSION, FILEFORMAT_VERSION);
+  static gchar *header = NULL;
+
+  if (header == NULL)
+    header = g_strdup_printf("v %s %u\n", DATE_VERSION, FILEFORMAT_VERSION);
+
+  return header;
 }
 
 /*! \brief Save a file
@@ -189,7 +194,7 @@ int o_save(TOPLEVEL *toplevel, const char *filename)
     o_net_consolidate(toplevel);
   }
 
-  o_save_write_header(fp);
+  fprintf(fp, o_file_format_header());
 
   while ( o_current != NULL ) {
 



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