You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2013/10/09 14:34:11 UTC
svn commit: r1530582 - /subversion/trunk/subversion/libsvn_subr/cmdline.c
Author: rhuijben
Date: Wed Oct 9 12:34:11 2013
New Revision: 1530582
URL: http://svn.apache.org/r1530582
Log:
Hide some essentially dead code by using the preprocessor.
* subversion/libsvn_subr/cmdline.c
(CMDLINE_USE_CUSTOM_ENCODING): New macro. Document why this still exists.
(input_encoding,
output_encoding): Disable when CMDLINE_USE_CUSTOM_ENCODING is not defined.
(svn_cmdline_init): Use CMDLINE_USE_CUSTOM_ENCODING as condition around
initializing the encoding usage.
(svn_cmdline_cstring_from_utf8,
svn_cmdline_cstring_to_utf8,
svn_cmdline_output_encoding): Use preprocessor instead of runtime check
for the 99.9% case.
Modified:
subversion/trunk/subversion/libsvn_subr/cmdline.c
Modified: subversion/trunk/subversion/libsvn_subr/cmdline.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cmdline.c?rev=1530582&r1=1530581&r2=1530582&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cmdline.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cmdline.c Wed Oct 9 12:34:11 2013
@@ -67,11 +67,17 @@
#include "win32_crashrpt.h"
+#if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER < 1400)
+/* Before Visual Studio 2005, the C runtime didn't handle encodings for the
+ for the stdio output handling. */
+#define CMDLINE_USE_CUSTOM_ENCODING
+
/* The stdin encoding. If null, it's the same as the native encoding. */
static const char *input_encoding = NULL;
/* The stdout encoding. If null, it's the same as the native encoding. */
static const char *output_encoding = NULL;
+#endif
int
@@ -113,7 +119,7 @@ svn_cmdline_init(const char *progname, F
#endif
#ifdef WIN32
-#if _MSC_VER < 1400
+#ifdef CMDLINE_USE_CUSTOM_ENCODING
/* Initialize the input and output encodings. */
{
static char input_encoding_buffer[16];
@@ -127,7 +133,7 @@ svn_cmdline_init(const char *progname, F
"CP%u", (unsigned) GetConsoleOutputCP());
output_encoding = output_encoding_buffer;
}
-#endif /* _MSC_VER < 1400 */
+#endif /* CMDLINE_USE_CUSTOM_ENCODING */
#ifdef SVN_USE_WIN32_CRASHHANDLER
if (!getenv("SVN_CMDLINE_DISABLE_CRASH_HANDLER"))
@@ -257,10 +263,12 @@ svn_cmdline_cstring_from_utf8(const char
const char *src,
apr_pool_t *pool)
{
- if (output_encoding == NULL)
- return svn_utf_cstring_from_utf8(dest, src, pool);
- else
+#ifdef CMDLINE_USE_CUSTOM_ENCODING
+ if (output_encoding != NULL)
return svn_utf_cstring_from_utf8_ex2(dest, src, output_encoding, pool);
+#endif
+
+ return svn_utf_cstring_from_utf8(dest, src, pool);
}
@@ -278,10 +286,12 @@ svn_cmdline_cstring_to_utf8(const char *
const char *src,
apr_pool_t *pool)
{
- if (input_encoding == NULL)
- return svn_utf_cstring_to_utf8(dest, src, pool);
- else
+#ifdef CMDLINE_USE_CUSTOM_ENCODING
+ if (input_encoding != NULL)
return svn_utf_cstring_to_utf8_ex2(dest, src, input_encoding, pool);
+#endif
+
+ return svn_utf_cstring_to_utf8(dest, src, pool);
}
@@ -394,10 +404,12 @@ svn_cmdline_fflush(FILE *stream)
const char *svn_cmdline_output_encoding(apr_pool_t *pool)
{
+#ifdef CMDLINE_USE_CUSTOM_ENCODING
if (output_encoding)
return apr_pstrdup(pool, output_encoding);
- else
- return SVN_APR_LOCALE_CHARSET;
+#endif
+
+ return SVN_APR_LOCALE_CHARSET;
}
int