Author: brane
Date: Wed Aug 20 11:24:22 2014
New Revision: 1619075
URL: http://svn.apache.org/r1619075
Log:
Replace weird code that uses magic numbers and produces warnings
in maintainer mode with equally weird code that does not use magic
numbers and avoids the warnings.
* subversion/libsvn_delta/svndiff.c
(SVNDIFF_V0, SVNDIFF_V1): New; svndiff header represenations.
(SVNDIFF_HEADER_SIZE): New.
(write_handler): Use the above new stuff instead of magic
numbers and string literals.
Modified:
subversion/trunk/subversion/libsvn_delta/svndiff.c
Modified: subversion/trunk/subversion/libsvn_delta/svndiff.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/svndiff.c?rev=1619075&r1=1619074&r2=1619075&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/svndiff.c (original)
+++ subversion/trunk/subversion/libsvn_delta/svndiff.c Wed Aug 20 11:24:22 2014
@@ -578,6 +578,10 @@ decode_window(svn_txdelta_window_t *wind
return SVN_NO_ERROR;
}
+static const char SVNDIFF_V0[] = { 'S', 'V', 'N', 0 };
+static const char SVNDIFF_V1[] = { 'S', 'V', 'N', 1 };
+#define SVNDIFF_HEADER_SIZE (sizeof(SVNDIFF_V0))
+
static svn_error_t *
write_handler(void *baton,
const char *buffer,
@@ -590,14 +594,14 @@ write_handler(void *baton,
apr_size_t buflen = *len;
/* Chew up four bytes at the beginning for the header. */
- if (db->header_bytes < 4)
+ if (db->header_bytes < SVNDIFF_HEADER_SIZE)
{
- apr_size_t nheader = 4 - db->header_bytes;
+ apr_size_t nheader = SVNDIFF_HEADER_SIZE - db->header_bytes;
if (nheader > buflen)
nheader = buflen;
- if (memcmp(buffer, "SVN\0" + db->header_bytes, nheader) == 0)
+ if (memcmp(buffer, SVNDIFF_V0 + db->header_bytes, nheader) == 0)
db->version = 0;
- else if (memcmp(buffer, "SVN\1" + db->header_bytes, nheader) == 0)
+ else if (memcmp(buffer, SVNDIFF_V1 + db->header_bytes, nheader) == 0)
db->version = 1;
else
return svn_error_create(SVN_ERR_SVNDIFF_INVALID_HEADER, NULL,