[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: CVS update: subversion/subversion/libsvn_delta xml_output.c

From: Karl Fogel <kfogel_at_galois.collab.net>
Date: 2000-10-05 16:46:42 CEST

Greg, looking over the code, I'm wondering if maybe you don't want to
use functions like

   svn_xml_write_tag()
   svn_xml_write_tag_v()
   svn_xml_write_tag_hash()
   svn_xml_write_header()

etc?

They're there precisely so you never have to hardwire XML syntax into
the code. Look over svn_xml.h and see if there's anything you can
use... If the interfaces aren't what you need, we can change that.

-K

ghudson@tigris.org writes:
> User: ghudson
> Date: 00/10/04 23:21:14
>
> Modified: subversion/libsvn_delta xml_output.c
> Log:
> Fix some bugs noted by Bob Miller and some mistakes noted by myself.
> (elem_prop_delta, elem_delta_pkg): Former renamed to latter; was a
> braino.
> (get_to_elem): text-delta-ref element should end with "/>". Close a
> tree-delta if we are trying to get to a directory prop-delta. Add an
> assertion to detect cases where get_to_elem doesn't get to where it
> should go.
> (close_directory): Set eb->elem to appropriate value (previously we
> left it at elem-dir). Don't close a <dir> element for the root
> directory, since we never opened one.
>
> Revision Changes Path
> 1.2 +23 -11 subversion/subversion/libsvn_delta/xml_output.c
>
> Index: xml_output.c
> ===================================================================
> RCS file: /cvs/subversion/subversion/libsvn_delta/xml_output.c,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- xml_output.c 2000/10/05 00:15:55 1.1
> +++ xml_output.c 2000/10/05 06:21:13 1.2
> @@ -49,6 +49,7 @@
>
> #include <stdio.h>
> #include <string.h>
> +#include <assert.h>
> #include "svn_types.h"
> #include "svn_string.h"
> #include "svn_error.h"
> @@ -76,7 +77,7 @@
> overlap, so it doesn't quite make sense to have a separate
> enueration for each use. */
> enum elemtype {
> - elem_prop_delta,
> + elem_delta_pkg,
> elem_add,
> elem_replace,
> elem_dir,
> @@ -105,7 +106,7 @@
> {
> struct edit_baton *edit_baton;
> enum elemtype addreplace; /* elem_add or elem_replace, or
> - elem_prop_delta for the root
> + elem_delta_pkg for the root
> directory. */
> apr_pool_t *pool;
> };
> @@ -197,7 +198,7 @@
> if (fb->txdelta_id == 0)
> {
> fb->txdelta_id = eb->txdelta_id_counter++;
> - sprintf (buf, "<text-delta-ref id='%d'>\n", fb->txdelta_id);
> + sprintf (buf, "<text-delta-ref id='%d'/>\n", fb->txdelta_id);
> svn_string_appendcstr (str, buf, pool);
> }
> svn_string_appendcstr (str, "</file>", pool);
> @@ -207,7 +208,8 @@
> eb->curfile = NULL;
> eb->elem = elem_tree_delta;
> }
> - if (eb->elem == elem_tree_delta && elem == elem_dir)
> + if (eb->elem == elem_tree_delta
> + && (elem == elem_dir || elem == elem_dir_prop_delta))
> {
> svn_string_appendcstr (str, "</tree-delta>\n", pool);
> eb->elem = elem_dir;
> @@ -235,6 +237,11 @@
> eb->elem = elem_file_prop_delta;
> }
>
> + /* If we didn't make it to the type of element the caller asked for,
> + either the caller wants us to do something we don't do or we have
> + a bug. */
> + assert (eb->elem == elem);
> +
> return str;
> }
>
> @@ -322,7 +329,7 @@
> const char *hdr = "<?xml version='1.0' encoding='utf-8'?>\n<delta-pkg>\n";
> apr_size_t len = strlen(hdr);
>
> - *dir_baton = make_dir_baton (eb, elem_prop_delta);
> + *dir_baton = make_dir_baton (eb, elem_delta_pkg);
>
> eb->elem = elem_dir;
> return eb->output (eb->output_baton, hdr, &len, eb->pool);
> @@ -405,12 +412,17 @@
> apr_size_t len;
>
> str = get_to_elem (eb, elem_dir, db->pool);
> - svn_string_appendcstr (str, "</dir>", db->pool);
> - if (db->addreplace == elem_add)
> - svn_string_appendcstr (str, "</add>", db->pool);
> - else if (db->addreplace == elem_replace)
> - svn_string_appendcstr (str, "</replace>", db->pool);
> - svn_string_appendcstr (str, "\n", db->pool);
> + if (db->addreplace != elem_delta_pkg)
> + {
> + /* Not the root directory. */
> + svn_string_appendcstr (str, "</dir>", db->pool);
> + svn_string_appendcstr (str, ((db->addreplace == elem_add) ? "</add>"
> + : "</replace>"), db->pool);
> + svn_string_appendcstr (str, "\n", db->pool);
> + eb->elem = elem_tree_delta;
> + }
> + else
> + eb->elem = elem_delta_pkg;
>
> len = str->len;
> err = eb->output (eb->output_baton, str->data, &len, db->pool);
>
>
>
Received on Sat Oct 21 14:36:10 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.