You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/10/22 20:16:38 UTC
svn commit: r1710069 - in /subversion/trunk/subversion:
include/private/svn_string_private.h libsvn_repos/log.c libsvn_wc/props.c
Author: stefan2
Date: Thu Oct 22 18:16:37 2015
New Revision: 1710069
URL: http://svn.apache.org/viewvc?rev=1710069&view=rev
Log:
Introduce the SVN__STATIC_STRING macro to simplify the definition of
static svn_string_t instances.
* subversion/include/private/svn_string_private.h
(SVN__STATIC_STRING): Define new macro.
* subversion/libsvn_repos/log.c
(fill_log_entry): Use the new macro.
* subversion/libsvn_wc/props.c
(svn_wc_canonicalize_svn_prop): Ditto.
Modified:
subversion/trunk/subversion/include/private/svn_string_private.h
subversion/trunk/subversion/libsvn_repos/log.c
subversion/trunk/subversion/libsvn_wc/props.c
Modified: subversion/trunk/subversion/include/private/svn_string_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_string_private.h?rev=1710069&r1=1710068&r2=1710069&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_string_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_string_private.h Thu Oct 22 18:16:37 2015
@@ -131,6 +131,14 @@ svn_membuf__nzero(svn_membuf_t *membuf,
svn_string_t *
svn_stringbuf__morph_into_string(svn_stringbuf_t *strbuf);
+/** Utility macro to define static svn_string_t objects. @a value must
+ * be a static string; the "" in the macro declaration tries to ensure this.
+ *
+ * Usage:
+ * static const svn_string_t my_string = SVN__STATIC_STRING("my text");
+ */
+#define SVN__STATIC_STRING(value) { value "", sizeof(value "") - 1 }
+
/** Like strtoul but with a fixed base of 10 and without overflow checks.
* This allows the compiler to generate massively faster (4x on 64bit LINUX)
* code. Overflow checks may be added on the caller side where you might
Modified: subversion/trunk/subversion/libsvn_repos/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/log.c?rev=1710069&r1=1710068&r2=1710069&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/log.c (original)
+++ subversion/trunk/subversion/libsvn_repos/log.c Thu Oct 22 18:16:37 2015
@@ -43,6 +43,7 @@
#include "private/svn_mergeinfo_private.h"
#include "private/svn_subr_private.h"
#include "private/svn_sorts_private.h"
+#include "private/svn_string_private.h"
@@ -1151,9 +1152,9 @@ fill_log_entry(svn_log_entry_t *log_entr
we want static initialization here and must therefore emulate
strlen(x) by sizeof(x)-1. */
static const svn_string_t svn_prop_revision_author
- = {SVN_PROP_REVISION_AUTHOR, sizeof(SVN_PROP_REVISION_AUTHOR)-1};
+ = SVN__STATIC_STRING(SVN_PROP_REVISION_AUTHOR);
static const svn_string_t svn_prop_revision_date
- = {SVN_PROP_REVISION_DATE, sizeof(SVN_PROP_REVISION_DATE)-1};
+ = SVN__STATIC_STRING(SVN_PROP_REVISION_DATE);
/* often only the standard revprops got requested and delivered.
In that case, we can simply pass the hash on. */
Modified: subversion/trunk/subversion/libsvn_wc/props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/props.c?rev=1710069&r1=1710068&r2=1710069&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/props.c (original)
+++ subversion/trunk/subversion/libsvn_wc/props.c Thu Oct 22 18:16:37 2015
@@ -2170,11 +2170,8 @@ svn_wc_canonicalize_svn_prop(const svn_s
/* Keep this static, it may get stored (for read-only purposes) in a
hash that outlives this function. */
- static const svn_string_t boolean_value =
- {
- SVN_PROP_BOOLEAN_TRUE,
- sizeof(SVN_PROP_BOOLEAN_TRUE) - 1
- };
+ static const svn_string_t boolean_value
+ = SVN__STATIC_STRING(SVN_PROP_BOOLEAN_TRUE);
SVN_ERR(validate_prop_against_node_kind(propname, path, kind, pool));