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

Keywords as hash (section 1)

From: Max Bowsher <mob22_at_cam.ac.uk>
Date: 2005-03-22 00:51:23 CET

OK, here are the results of my recent work on keywords as hash.

Firstly, I've split the whole thing into 4 individually committable

1. include & libsvn_subr
2. libsvn_wc
3. libsvn_client
4. cmdline client & tests

At the moment, I am *only* working on section 1.

I've incorporated Justin's changes, and also made *MANY* of my own. (So
please could John and Justin re-review this)

First: a summary of the changes I've made:

Log message: overhauled. Several missing entries added.

svn_subst.h: Many tweaks to documentation comments. Most moderately minor,
but I've made notable changes to John's changes to the
svn_subst_translate_stream2 doc.

svn_types.h: Do not remove the large comment linking to mail messages. The
current patches don't do everything suggested there, yet.

subst.c: MANY... enumerated per function:

keyword_printf: Simplify some rather obscure code controlling the loop, and
remove one variable as a result. Fix a bug: If the format string had ended
with a % character, then the null terminator would not be noticed, and the
loop would continue on through random memory.
Alter the behaviour of unrecognized %? sequences - retain the % in the
output, instead of stripping it.

keywords_to_keyhash: Rename to kwstruct_to_kwhash. Document why we need to
check for NULL. Convert NULL to NULL, not to an empty hash, because NULL is
a special signifier for svn_subst_translate_stream and friends.

keyhash_to_keywords: Inline at its only callsite. Rewrite to accurately
mimic 1.1 behaviour.

svn_subst_build_keywords2: Remove special-casing from the "date" case -
keyword_printf already handles this special case! Silly to do it twice!

translate_keyword: Make code clearer.

svn_subst_keywords_differ: Why convert both structures to hashes, when we
have a nice pre-written piece of code to compare them directly? Let's just
leave this function alone.

svn_subst_keywords_differ2: Was quite crazy. Made it actually do what it's
supposed to.

And now, the edited log message:

Revise keywords API - represent keywords as a hash for better extensibility.
Implement printf-like format characters for keyword expansion. Change all
other libraries to use new keyword hash functions from libsvn_subst.
Includes a new keyword, UUID, and tests for same.
See issue #890 for details.
Based on a patch by John Peacock <jpeacock rowman com>.
This is phase 1 of 4: libsvn_subr.

* subversion/includes/svn_subst.h:
   (svn_subst_keywords_t): Deprecated.
   (svn_subst_build_keywords2): Interface change.
     A new argument const char *uuid, and produce hash instead of struct.
   (svn_subst_build_keywords): Deprecated.
   (svn_subst_keywords_differ2): Interface change.
     A new argument apr_pool_t *pool and use hash instead of struct.
   (svn_subst_keywords_differ): Deprecated.
   (svn_subst_translate_stream2): Interface change; hash instead of struct.
   (svn_subst_translate_stream): Deprecated.
   (svn_subst_copy_and_translate3): Interface change; hash instead of
   (svn_subst_copy_and_translate2): Deprecated.
   (svn_subst_translate_cstring2): Interface change; hash instead of struct.
   (svn_subst_translate_cstring): Deprecated.

* subversion/includes/svn_types.h:
     New defines - long and short names of a new keyword.
     New defines - format strings for keyword expansion.

* subversion/libsvn_subr/svn_subst.c:
   (keyword_printf): New private function;
     printf-style formatting of keywords based on format strings.
   (kwstruct_to_kwhash): New private function;
     convert keywords struct into keywords hash.
   (svn_subst_build_keywords): Convert to API compatibility wrapper.
   (svn_subst_build_keywords2): Build keywords using keyword_printf().
   (translate_keyword): Interface changes. Also, look up the keyword in the
     passed in buffer, instead of trying to translate all possibilities.
   (svn_subst_keywords_differ): Retain unchanged for API compatibility.
   (svn_subst_keywords_differ2): New function;
     compare two hashes instead of comparing individual structure elements.
   (svn_subst_translate_stream): Convert to API compatibility wrapper.
   (svn_subst_translate_stream2): Change interface only.
   (svn_subst_translate_cstring): Convert to API compatibility wrapper.
   (svn_subst_translate_cstring2): Update function call to new API version.
   (svn_subst_copy_and_translate2): Convert to API combatibility wrapper.
   (svn_subst_copy_and_translate3): Update function call to new API version.
   (svn_subst_translate_string): Update function call to new API version.
   (svn_subst_detranslate_string): Update function call to new API version.

Diff attached.

Passes testsuite.


To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Tue Mar 22 00:52:46 2005

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.