Author: stefan2
Date: Thu Sep 6 20:41:58 2012
New Revision: 1381747
URL: http://svn.apache.org/viewvc?rev=1381747&view=rev
Log:
Move string processing masks from .c files to a common header.
Also, give those constants a SVN__ prefix.
* subversion/include/private/svn_eol_private.h
(SVN__LOWER_7BITS_SET, SVN__BIT_7_SET, SVN__R_MASK, SVN__N_MASK):
define constants depending on natural word size
* subversion/libsvn_diff/diff_file.c
(LOWER_7BITS_SET, BIT_7_SET, R_MASK, N_MASK): drop local definitions
(contains_eol): adapt to renamed constants
* subversion/libsvn_subr/eol.c
(LOWER_7BITS_SET, BIT_7_SET, R_MASK, N_MASK): drop local definitions
(svn_eol__find_eol_start): adapt to renamed constants
Modified:
subversion/trunk/subversion/include/private/svn_eol_private.h
subversion/trunk/subversion/libsvn_diff/diff_file.c
subversion/trunk/subversion/libsvn_subr/eol.c
Modified: subversion/trunk/subversion/include/private/svn_eol_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_eol_private.h?rev=1381747&r1=1381746&r2=1381747&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_eol_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_eol_private.h Thu Sep 6 20:41:58 2012
@@ -37,6 +37,20 @@
extern "C" {
#endif /* __cplusplus */
+/* Constants used by various chunky string processing functions.
+ */
+#if APR_SIZEOF_VOIDP == 8
+# define SVN__LOWER_7BITS_SET 0x7f7f7f7f7f7f7f7f
+# define SVN__BIT_7_SET 0x8080808080808080
+# define SVN__R_MASK 0x0a0a0a0a0a0a0a0a
+# define SVN__N_MASK 0x0d0d0d0d0d0d0d0d
+#else
+# define SVN__LOWER_7BITS_SET 0x7f7f7f7f
+# define SVN__BIT_7_SET 0x80808080
+# define SVN__R_MASK 0x0a0a0a0a
+# define SVN__N_MASK 0x0d0d0d0d
+#endif
+
/* Generic EOL character helper routines */
/* Look for the start of an end-of-line sequence (i.e. CR or LF)
Modified: subversion/trunk/subversion/libsvn_diff/diff_file.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/diff_file.c?rev=1381747&r1=1381746&r2=1381747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/diff_file.c (original)
+++ subversion/trunk/subversion/libsvn_diff/diff_file.c Thu Sep 6 20:41:58 2012
@@ -340,30 +340,17 @@ is_one_at_eof(struct file_info file[], a
/* Quickly determine whether there is a eol char in CHUNK.
* (mainly copy-n-paste from eol.c#svn_eol__find_eol_start).
*/
-#if SVN_UNALIGNED_ACCESS_IS_OK
-#if APR_SIZEOF_VOIDP == 8
-# define LOWER_7BITS_SET 0x7f7f7f7f7f7f7f7f
-# define BIT_7_SET 0x8080808080808080
-# define R_MASK 0x0a0a0a0a0a0a0a0a
-# define N_MASK 0x0d0d0d0d0d0d0d0d
-#else
-# define LOWER_7BITS_SET 0x7f7f7f7f
-# define BIT_7_SET 0x80808080
-# define R_MASK 0x0a0a0a0a
-# define N_MASK 0x0d0d0d0d
-#endif
-#endif
#if SVN_UNALIGNED_ACCESS_IS_OK
static svn_boolean_t contains_eol(apr_uintptr_t chunk)
{
- apr_uintptr_t r_test = chunk ^ R_MASK;
- apr_uintptr_t n_test = chunk ^ N_MASK;
+ apr_uintptr_t r_test = chunk ^ SVN__R_MASK;
+ apr_uintptr_t n_test = chunk ^ SVN__N_MASK;
- r_test |= (r_test & LOWER_7BITS_SET) + LOWER_7BITS_SET;
- n_test |= (n_test & LOWER_7BITS_SET) + LOWER_7BITS_SET;
+ r_test |= (r_test & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
+ n_test |= (n_test & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
- return (r_test & n_test & BIT_7_SET) != BIT_7_SET;
+ return (r_test & n_test & SVN__BIT_7_SET) != SVN__BIT_7_SET;
}
#endif
Modified: subversion/trunk/subversion/libsvn_subr/eol.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/eol.c?rev=1381747&r1=1381746&r2=1381747&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/eol.c (original)
+++ subversion/trunk/subversion/libsvn_subr/eol.c Thu Sep 6 20:41:58 2012
@@ -32,18 +32,6 @@
/* Machine-word-sized masks used in svn_eol__find_eol_start.
*/
-#if APR_SIZEOF_VOIDP == 8
-# define LOWER_7BITS_SET 0x7f7f7f7f7f7f7f7f
-# define BIT_7_SET 0x8080808080808080
-# define R_MASK 0x0a0a0a0a0a0a0a0a
-# define N_MASK 0x0d0d0d0d0d0d0d0d
-#else
-# define LOWER_7BITS_SET 0x7f7f7f7f
-# define BIT_7_SET 0x80808080
-# define R_MASK 0x0a0a0a0a
-# define N_MASK 0x0d0d0d0d
-#endif
-
char *
svn_eol__find_eol_start(char *buf, apr_size_t len)
{
@@ -69,19 +57,19 @@ svn_eol__find_eol_start(char *buf, apr_s
/* This is a variant of the well-known strlen test: */
apr_uintptr_t chunk = *(const apr_uintptr_t *)buf;
- /* A byte in R_TEST is \0, iff it was \r in *BUF.
- * Similarly, N_TEST is an indicator for \n. */
- apr_uintptr_t r_test = chunk ^ R_MASK;
- apr_uintptr_t n_test = chunk ^ N_MASK;
-
- /* A byte in R_TEST can by < 0x80, iff it has been \0 before
- * (i.e. \r in *BUF). Dito for N_TEST. */
- r_test |= (r_test & LOWER_7BITS_SET) + LOWER_7BITS_SET;
- n_test |= (n_test & LOWER_7BITS_SET) + LOWER_7BITS_SET;
+ /* A byte in SVN__R_TEST is \0, iff it was \r in *BUF.
+ * Similarly, SVN__N_TEST is an indicator for \n. */
+ apr_uintptr_t r_test = chunk ^ SVN__R_MASK;
+ apr_uintptr_t n_test = chunk ^ SVN__N_MASK;
+
+ /* A byte in SVN__R_TEST can by < 0x80, iff it has been \0 before
+ * (i.e. \r in *BUF). Dito for SVN__N_TEST. */
+ r_test |= (r_test & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
+ n_test |= (n_test & SVN__LOWER_7BITS_SET) + SVN__LOWER_7BITS_SET;
/* Check whether at least one of the words contains a byte <0x80
* (if one is detected, there was a \r or \n in CHUNK). */
- if ((r_test & n_test & BIT_7_SET) != BIT_7_SET)
+ if ((r_test & n_test & SVN__BIT_7_SET) != SVN__BIT_7_SET)
break;
}
|