Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 03131C1F0 for ; Sun, 13 May 2012 05:10:12 +0000 (UTC) Received: (qmail 38419 invoked by uid 500); 13 May 2012 05:10:10 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 38125 invoked by uid 500); 13 May 2012 05:10:03 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 38054 invoked by uid 99); 13 May 2012 05:10:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 May 2012 05:10:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 May 2012 05:09:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 54A122388962; Sun, 13 May 2012 05:09:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1337779 - /subversion/trunk/subversion/libsvn_ra_serf/getdate.c Date: Sun, 13 May 2012 05:09:39 -0000 To: commits@subversion.apache.org From: gstein@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120513050939.54A122388962@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gstein Date: Sun May 13 05:09:38 2012 New Revision: 1337779 URL: http://svn.apache.org/viewvc?rev=1337779&view=rev Log: Switch getdate over to the new xml parsing system. * subversion/libsvn_ra_serf/getdate.c: (date_state_e): drop the typedef. rename NONE to INITIAL. add the REPORT state. (date_context_t): drop the DONE member (date_ttable): new transition table (start_getdate, end_getdata, cdata_getdate): removed. obsolete. (svn_ra_serf__get_dated_revision): drop old parsing stuff. switch to the new parser. use run_one(). Modified: subversion/trunk/subversion/libsvn_ra_serf/getdate.c Modified: subversion/trunk/subversion/libsvn_ra_serf/getdate.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/getdate.c?rev=1337779&r1=1337778&r2=1337779&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_ra_serf/getdate.c (original) +++ subversion/trunk/subversion/libsvn_ra_serf/getdate.c Sun May 13 05:09:38 2012 @@ -43,10 +43,11 @@ /* * This enum represents the current state of our XML parsing for a REPORT. */ -typedef enum date_state_e { - NONE = 0, +enum date_state_e { + INITIAL = 0, + REPORT, VERSION_NAME -} date_state_e; +}; typedef struct date_context_t { @@ -56,79 +57,41 @@ typedef struct date_context_t { /* What was the youngest revision at that time? */ svn_revnum_t *revision; - /* are we done? */ - svn_boolean_t done; - } date_context_t; +#define D_ "DAV:" +#define S_ SVN_XML_NAMESPACE +static const svn_ra_serf__xml_transition_t date_ttable[] = { + { INITIAL, S_, "dated-rev-report", REPORT, + FALSE, { NULL }, FALSE, FALSE }, -static svn_error_t * -start_getdate(svn_ra_serf__xml_parser_t *parser, - svn_ra_serf__dav_props_t name, - const char **attrs, - apr_pool_t *scratch_pool) -{ - date_context_t *date_ctx = parser->user_data; - date_state_e state = parser->state->current_state; + { REPORT, D_, SVN_DAV__VERSION_NAME, VERSION_NAME, + TRUE, { NULL }, FALSE, TRUE }, - UNUSED_CTX(date_ctx); + { 0 } +}; - if (state == NONE && - strcmp(name.name, SVN_DAV__VERSION_NAME) == 0) - { - svn_ra_serf__xml_push_state(parser, VERSION_NAME); - - parser->state->private = svn_stringbuf_create_empty(parser->state->pool); - } - - return SVN_NO_ERROR; -} +/* Conforms to svn_ra_serf__xml_closed_t */ static svn_error_t * -end_getdate(svn_ra_serf__xml_parser_t *parser, - svn_ra_serf__dav_props_t name, +date_closed(svn_ra_serf__xml_estate_t *xes, + void *baton, + int leaving_state, + const svn_string_t *cdata, + apr_hash_t *attrs, apr_pool_t *scratch_pool) { - date_context_t *date_ctx = parser->user_data; - date_state_e state = parser->state->current_state; - - if (state == VERSION_NAME && - strcmp(name.name, SVN_DAV__VERSION_NAME) == 0) - { - const svn_stringbuf_t *datebuf = parser->state->private; - - *date_ctx->revision = SVN_STR_TO_REV(datebuf->data); - svn_ra_serf__xml_pop_state(parser); - } + date_context_t *date_ctx = baton; - return SVN_NO_ERROR; -} + SVN_ERR_ASSERT(leaving_state == VERSION_NAME); + SVN_ERR_ASSERT(cdata != NULL); -static svn_error_t * -cdata_getdate(svn_ra_serf__xml_parser_t *parser, - const char *data, - apr_size_t len, - apr_pool_t *scratch_pool) -{ - date_context_t *date_ctx = parser->user_data; - date_state_e state = parser->state->current_state; - svn_stringbuf_t *datebuf; - - UNUSED_CTX(date_ctx); - - switch (state) - { - case VERSION_NAME: - datebuf = parser->state->private; - svn_stringbuf_appendbytes(datebuf, data, len); - break; - default: - break; - } + *date_ctx->revision = SVN_STR_TO_REV(cdata->data); return SVN_NO_ERROR; } + /* Implements svn_ra_serf__request_body_delegate_t */ static svn_error_t * create_getdate_body(serf_bucket_t **body_bkt, @@ -166,45 +129,32 @@ svn_ra_serf__get_dated_revision(svn_ra_s date_context_t *date_ctx; svn_ra_serf__session_t *session = ra_session->priv; svn_ra_serf__handler_t *handler; - svn_ra_serf__xml_parser_t *parser_ctx; + svn_ra_serf__xml_context_t *xmlctx; const char *report_target; date_ctx = apr_palloc(pool, sizeof(*date_ctx)); date_ctx->time = tm; date_ctx->revision = revision; - date_ctx->done = FALSE; SVN_ERR(svn_ra_serf__report_resource(&report_target, session, NULL, pool)); - handler = apr_pcalloc(pool, sizeof(*handler)); + xmlctx = svn_ra_serf__xml_context_create(date_ttable, + NULL, date_closed, date_ctx, + pool); + handler = svn_ra_serf__create_expat_handler(xmlctx, pool); - handler->handler_pool = pool; handler->method = "REPORT"; handler->path = report_target; handler->body_type = "text/xml"; handler->conn = session->conns[0]; handler->session = session; - parser_ctx = apr_pcalloc(pool, sizeof(*parser_ctx)); - - parser_ctx->pool = pool; - parser_ctx->user_data = date_ctx; - parser_ctx->start = start_getdate; - parser_ctx->end = end_getdate; - parser_ctx->cdata = cdata_getdate; - parser_ctx->done = &date_ctx->done; - handler->body_delegate = create_getdate_body; handler->body_delegate_baton = date_ctx; - handler->response_handler = svn_ra_serf__handle_xml_parser; - handler->response_baton = parser_ctx; - - svn_ra_serf__request_create(handler); - *date_ctx->revision = SVN_INVALID_REVNUM; /* ### use svn_ra_serf__error_on_status() ? */ - return svn_ra_serf__context_run_wait(&date_ctx->done, session, pool); + return svn_error_trace(svn_ra_serf__context_run_one(handler, pool)); }