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 2013/11/27 12:52:46 UTC
svn commit: r1546002 [19/39] - in /subversion/branches/verify-keep-going: ./
build/ build/ac-macros/ build/generator/ build/generator/swig/
build/generator/templates/ build/win32/ contrib/client-side/emacs/
contrib/server-side/ contrib/server-side/svnc...
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/config_win.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/config_win.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/config_win.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/config_win.c Wed Nov 27 11:52:35 2013
@@ -44,10 +44,11 @@
#include "svn_path.h"
#include "svn_pools.h"
#include "svn_utf.h"
+#include "private/svn_utf_private.h"
svn_error_t *
svn_config__win_config_path(const char **folder, int system_path,
- apr_pool_t *pool)
+ apr_pool_t *result_pool)
{
/* ### Adding CSIDL_FLAG_CREATE here, because those folders really
must exist. I'm not too sure about the SHGFP_TYPE_CURRENT
@@ -56,8 +57,6 @@ svn_config__win_config_path(const char *
| CSIDL_FLAG_CREATE);
WCHAR folder_ucs2[MAX_PATH];
- int inwords, outbytes, outlength;
- char *folder_utf8;
if (S_OK != SHGetFolderPathW(NULL, csidl, NULL, SHGFP_TYPE_CURRENT,
folder_ucs2))
@@ -66,26 +65,8 @@ svn_config__win_config_path(const char *
? "Can't determine the system config path"
: "Can't determine the user's config path"));
- /* ### When mapping from UCS-2 to UTF-8, we need at most 3 bytes
- per wide char, plus extra space for the nul terminator. */
- inwords = lstrlenW(folder_ucs2);
- outbytes = outlength = 3 * (inwords + 1);
-
- folder_utf8 = apr_palloc(pool, outlength);
-
- outbytes = WideCharToMultiByte(CP_UTF8, 0, folder_ucs2, inwords,
- folder_utf8, outbytes, NULL, NULL);
-
- if (outbytes == 0)
- return svn_error_wrap_apr(apr_get_os_error(),
- "Can't convert config path to UTF-8");
-
- /* Note that WideCharToMultiByte does _not_ terminate the
- outgoing buffer. */
- folder_utf8[outbytes] = '\0';
- *folder = folder_utf8;
-
- return SVN_NO_ERROR;
+ return svn_error_trace(svn_utf__win32_utf16_to_utf8(folder, folder_ucs2,
+ NULL, result_pool));
}
@@ -97,6 +78,8 @@ svn_config__win_config_path(const char *
#define SVN_REG_DEFAULT_NAME_SIZE 2048
#define SVN_REG_DEFAULT_VALUE_SIZE 8192
+/* ### This function should be converted to use the unicode functions
+ ### instead of the ansi functions */
static svn_error_t *
parse_section(svn_config_t *cfg, HKEY hkey, const char *section,
svn_stringbuf_t *option, svn_stringbuf_t *value)
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/deprecated.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/deprecated.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/deprecated.c Wed Nov 27 11:52:35 2013
@@ -32,6 +32,7 @@
deprecated functions in this file. */
#define SVN_DEPRECATED
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_subst.h"
#include "svn_path.h"
@@ -43,14 +44,13 @@
#include "svn_mergeinfo.h"
#include "svn_utf.h"
#include "svn_xml.h"
+#include "svn_auth.h"
#include "opt.h"
+#include "auth.h"
#include "private/svn_opt_private.h"
#include "private/svn_mergeinfo_private.h"
-#include "svn_private_config.h"
-
-
/*** Code. ***/
@@ -1252,6 +1252,8 @@ svn_xml_make_header(svn_stringbuf_t **st
svn_xml_make_header2(str, NULL, pool);
}
+
+/*** From utf.c ***/
void
svn_utf_initialize(apr_pool_t *pool)
{
@@ -1259,6 +1261,18 @@ svn_utf_initialize(apr_pool_t *pool)
}
svn_error_t *
+svn_utf_cstring_from_utf8_ex(const char **dest,
+ const char *src,
+ const char *topage,
+ const char *convset_key,
+ apr_pool_t *pool)
+{
+ return svn_utf_cstring_from_utf8_ex2(dest, src, topage, pool);
+}
+
+
+/*** From subst.c ***/
+svn_error_t *
svn_subst_build_keywords(svn_subst_keywords_t *kw,
const char *keywords_val,
const char *rev,
@@ -1301,4 +1315,62 @@ svn_subst_build_keywords(svn_subst_keywo
return SVN_NO_ERROR;
}
+/*** From version.c ***/
+svn_error_t *
+svn_ver_check_list(const svn_version_t *my_version,
+ const svn_version_checklist_t *checklist)
+{
+ return svn_ver_check_list2(my_version, checklist, svn_ver_compatible);
+}
+
+/*** From win32_crypto.c ***/
+#if defined(WIN32) && !defined(__MINGW32__)
+void
+svn_auth_get_windows_simple_provider(svn_auth_provider_object_t **provider,
+ apr_pool_t *pool)
+{
+ svn_auth__get_windows_simple_provider(provider, pool);
+}
+
+void
+svn_auth_get_windows_ssl_client_cert_pw_provider
+ (svn_auth_provider_object_t **provider,
+ apr_pool_t *pool)
+{
+ svn_auth__get_windows_ssl_client_cert_pw_provider(provider, pool);
+}
+
+void
+svn_auth_get_windows_ssl_server_trust_provider
+ (svn_auth_provider_object_t **provider, apr_pool_t *pool)
+{
+ svn_auth__get_windows_ssl_server_trust_provider(provider, pool);
+}
+#endif /* WIN32 && !__MINGW32__ */
+
+/*** From macos_keychain.c ***/
+#if defined(DARWIN)
+void
+svn_auth_get_keychain_simple_provider(svn_auth_provider_object_t **provider,
+ apr_pool_t *pool)
+{
+ svn_auth__get_keychain_simple_provider(provider, pool);
+}
+
+void
+svn_auth_get_keychain_ssl_client_cert_pw_provider
+ (svn_auth_provider_object_t **provider,
+ apr_pool_t *pool)
+{
+ svn_auth__get_keychain_ssl_client_cert_pw_provider(provider, pool);
+}
+#endif /* DARWIN */
+#if !defined(WIN32)
+void
+svn_auth_get_gpg_agent_simple_provider(svn_auth_provider_object_t **provider,
+ apr_pool_t *pool)
+{
+ svn_auth__get_gpg_agent_simple_provider(provider, pool);
+}
+#endif /* !WIN32 */
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/dirent_uri.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/dirent_uri.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/dirent_uri.c Wed Nov 27 11:52:35 2013
@@ -1293,6 +1293,29 @@ svn_relpath_split(const char **dirpath,
*base_name = svn_relpath_basename(relpath, pool);
}
+const char *
+svn_relpath_limit(const char *relpath,
+ int max_components,
+ apr_pool_t *result_pool)
+{
+ const char *end;
+ assert(relpath_is_canonical(relpath));
+
+ if (max_components <= 0)
+ return "";
+
+ for (end = relpath; *end; end++)
+ {
+ if (*end == '/')
+ {
+ if (!--max_components)
+ break;
+ }
+ }
+
+ return apr_pstrmemdup(result_pool, relpath, end-relpath);
+}
+
char *
svn_uri_dirname(const char *uri, apr_pool_t *pool)
{
@@ -1862,6 +1885,9 @@ svn_uri_is_canonical(const char *uri, ap
#endif /* SVN_USE_DOS_PATHS */
/* Now validate the rest of the URI. */
+ seg = ptr;
+ while (*ptr && (*ptr != '/'))
+ ptr++;
while(1)
{
apr_size_t seglen = ptr - seg;
@@ -1880,9 +1906,8 @@ svn_uri_is_canonical(const char *uri, ap
if (*ptr == '/')
ptr++;
- seg = ptr;
-
+ seg = ptr;
while (*ptr && (*ptr != '/'))
ptr++;
}
@@ -2396,7 +2421,7 @@ svn_uri_get_dirent_from_file_url(const c
"no path"), url);
/* We still know that the path starts with a slash. */
- *dirent = apr_pstrcat(pool, "//", hostname, dup_path, NULL);
+ *dirent = apr_pstrcat(pool, "//", hostname, dup_path, SVN_VA_NULL);
}
else
*dirent = dup_path;
@@ -2429,18 +2454,18 @@ svn_uri_get_file_url_from_dirent(const c
if (dirent[0] == '/' && dirent[1] == '\0')
dirent = NULL; /* "file://" is the canonical form of "file:///" */
- *url = apr_pstrcat(pool, "file://", dirent, (char *)NULL);
+ *url = apr_pstrcat(pool, "file://", dirent, SVN_VA_NULL);
#else
if (dirent[0] == '/')
{
/* Handle UNC paths //server/share -> file://server/share */
assert(dirent[1] == '/'); /* Expect UNC, not non-absolute */
- *url = apr_pstrcat(pool, "file:", dirent, NULL);
+ *url = apr_pstrcat(pool, "file:", dirent, SVN_VA_NULL);
}
else
{
- char *uri = apr_pstrcat(pool, "file:///", dirent, NULL);
+ char *uri = apr_pstrcat(pool, "file:///", dirent, SVN_VA_NULL);
apr_size_t len = 8 /* strlen("file:///") */ + strlen(dirent);
/* "C:/" is a canonical dirent on Windows,
@@ -2474,7 +2499,7 @@ svn_fspath__canonicalize(const char *fsp
return "/";
return apr_pstrcat(pool, "/", svn_relpath_canonicalize(fspath, pool),
- (char *)NULL);
+ SVN_VA_NULL);
}
@@ -2507,7 +2532,7 @@ svn_fspath__dirname(const char *fspath,
return apr_pstrdup(pool, fspath);
else
return apr_pstrcat(pool, "/", svn_relpath_dirname(fspath + 1, pool),
- (char *)NULL);
+ SVN_VA_NULL);
}
@@ -2551,9 +2576,9 @@ svn_fspath__join(const char *fspath,
if (relpath[0] == '\0')
result = apr_pstrdup(result_pool, fspath);
else if (fspath[1] == '\0')
- result = apr_pstrcat(result_pool, "/", relpath, (char *)NULL);
+ result = apr_pstrcat(result_pool, "/", relpath, SVN_VA_NULL);
else
- result = apr_pstrcat(result_pool, fspath, "/", relpath, (char *)NULL);
+ result = apr_pstrcat(result_pool, fspath, "/", relpath, SVN_VA_NULL);
assert(svn_fspath__is_canonical(result));
return result;
@@ -2572,7 +2597,7 @@ svn_fspath__get_longest_ancestor(const c
svn_relpath_get_longest_ancestor(fspath1 + 1,
fspath2 + 1,
result_pool),
- (char *)NULL);
+ SVN_VA_NULL);
assert(svn_fspath__is_canonical(result));
return result;
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/dso.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/dso.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/dso.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/dso.c Wed Nov 27 11:52:35 2013
@@ -22,10 +22,10 @@
#include <apr_thread_mutex.h>
#include <apr_hash.h>
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_dso.h"
#include "svn_pools.h"
-#include "svn_private_config.h"
#include "private/svn_mutex.h"
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/error.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/error.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/error.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/error.c Wed Nov 27 11:52:35 2013
@@ -110,7 +110,8 @@ make_error_internal(apr_status_t apr_err
pool = child->pool;
else
{
- if (apr_pool_create(&pool, NULL))
+ pool = svn_pool_create(NULL);
+ if (!pool)
abort();
}
@@ -201,7 +202,8 @@ svn_error_wrap_apr(apr_status_t status,
va_end(ap);
if (msg_apr)
{
- err->message = apr_pstrcat(err->pool, msg, ": ", msg_apr, NULL);
+ err->message = apr_pstrcat(err->pool, msg, ": ", msg_apr,
+ SVN_VA_NULL);
}
else
{
@@ -339,7 +341,8 @@ svn_error_dup(svn_error_t *err)
apr_pool_t *pool;
svn_error_t *new_err = NULL, *tmp_err = NULL;
- if (apr_pool_create(&pool, NULL))
+ pool = svn_pool_create(NULL);
+ if (!pool)
abort();
for (; err; err = err->child)
@@ -559,7 +562,7 @@ svn_handle_error2(svn_error_t *err,
preferring apr_pool_*() instead. I can't remember why -- it may
be an artifact of r843793, or it may be for some deeper reason --
but I'm playing it safe and using apr_pool_*() here too. */
- apr_pool_create(&subpool, err->pool);
+ subpool = svn_pool_create(err->pool);
empties = apr_array_make(subpool, 0, sizeof(apr_status_t));
tmp_err = err;
@@ -696,7 +699,7 @@ svn_error_symbolic_name(apr_status_t sta
return defn->errname;
/* "No error" is not in error_table. */
- if (statcode == SVN_NO_ERROR)
+ if (statcode == APR_SUCCESS)
return "SVN_NO_ERROR";
#ifdef SVN_DEBUG
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/gpg_agent.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/gpg_agent.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/gpg_agent.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/gpg_agent.c Wed Nov 27 11:52:35 2013
@@ -73,6 +73,7 @@
#include "svn_checksum.h"
#include "svn_string.h"
+#include "auth.h"
#include "private/svn_auth_private.h"
#include "svn_private_config.h"
@@ -475,7 +476,7 @@ static const svn_auth_provider_t gpg_age
/* Public API */
void
-svn_auth_get_gpg_agent_simple_provider(svn_auth_provider_object_t **provider,
+svn_auth__get_gpg_agent_simple_provider(svn_auth_provider_object_t **provider,
apr_pool_t *pool)
{
svn_auth_provider_object_t *po = apr_pcalloc(pool, sizeof(*po));
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/hash.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/hash.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/hash.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/hash.c Wed Nov 27 11:52:35 2013
@@ -31,6 +31,7 @@
#include <apr_hash.h>
#include <apr_file_io.h>
+#include "svn_private_config.h"
#include "svn_types.h"
#include "svn_string.h"
#include "svn_error.h"
@@ -42,8 +43,6 @@
#include "private/svn_dep_compat.h"
#include "private/svn_subr_private.h"
-#include "svn_private_config.h"
-
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/io.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/io.c Wed Nov 27 11:52:35 2013
@@ -47,14 +47,11 @@
#include <apr_portable.h>
#include <apr_md5.h>
-#ifdef WIN32
-#include <arch/win32/apr_arch_file_io.h>
-#endif
-
#if APR_HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_types.h"
#include "svn_dirent_uri.h"
@@ -65,11 +62,12 @@
#include "svn_pools.h"
#include "svn_utf.h"
#include "svn_config.h"
-#include "svn_private_config.h"
#include "svn_ctype.h"
#include "private/svn_atomic.h"
#include "private/svn_io_private.h"
+#include "private/svn_utf_private.h"
+#include "private/svn_dep_compat.h"
#define SVN_SLEEP_ENV_VAR "SVN_I_LOVE_CORRUPTED_WORKING_COPIES_SO_DISABLE_SLEEP_FOR_TIMESTAMPS"
@@ -143,6 +141,26 @@
#endif
#endif
+#ifdef WIN32
+/* One-time initialization of the late bound Windows API functions. */
+static volatile svn_atomic_t win_dynamic_imports_state = 0;
+
+/* Pointer to GetFinalPathNameByHandleW function from kernel32.dll. */
+typedef DWORD (WINAPI *GETFINALPATHNAMEBYHANDLE)(
+ HANDLE hFile,
+ WCHAR *lpszFilePath,
+ DWORD cchFilePath,
+ DWORD dwFlags);
+
+static GETFINALPATHNAMEBYHANDLE get_final_path_name_by_handle_proc = NULL;
+
+/* Forward declaration. */
+static svn_error_t * io_win_read_link(svn_string_t **dest,
+ const char *path,
+ apr_pool_t *pool);
+
+#endif
+
/* Forward declaration */
static apr_status_t
dir_is_empty(const char *dir, apr_pool_t *pool);
@@ -664,7 +682,7 @@ svn_io_read_link(svn_string_t **dest,
const char *path,
apr_pool_t *pool)
{
-#ifdef HAVE_READLINK
+#if defined(HAVE_READLINK)
svn_string_t dest_apr;
const char *path_apr;
char buf[1025];
@@ -685,6 +703,8 @@ svn_io_read_link(svn_string_t **dest,
/* ### Cast needed, one of these interfaces is wrong */
return svn_utf_string_to_utf8((const svn_string_t **)dest, &dest_apr, pool);
+#elif defined(WIN32)
+ return io_win_read_link(dest, path, pool);
#else
return svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
_("Symbolic links are not supported on this "
@@ -1144,9 +1164,11 @@ svn_io_make_dir_recursively(const char *
return SVN_NO_ERROR;
}
-svn_error_t *svn_io_file_create(const char *file,
- const char *contents,
- apr_pool_t *pool)
+svn_error_t *
+svn_io_file_create_binary(const char *file,
+ const char *contents,
+ apr_size_t length,
+ apr_pool_t *pool)
{
apr_file_t *f;
apr_size_t written;
@@ -1156,25 +1178,57 @@ svn_error_t *svn_io_file_create(const ch
(APR_WRITE | APR_CREATE | APR_EXCL),
APR_OS_DEFAULT,
pool));
- if (contents && *contents)
- err = svn_io_file_write_full(f, contents, strlen(contents),
- &written, pool);
+ if (length)
+ err = svn_io_file_write_full(f, contents, length, &written, pool);
+ err = svn_error_compose_create(
+ err,
+ svn_io_file_close(f, pool));
- return svn_error_trace(
- svn_error_compose_create(err,
- svn_io_file_close(f, pool)));
+ if (err)
+ {
+ /* Our caller doesn't know if we left a file or not if we return
+ an error. Better to cleanup after ourselves if we created the
+ file. */
+ return svn_error_trace(
+ svn_error_compose_create(
+ err,
+ svn_io_remove_file2(file, TRUE, pool)));
+ }
+
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_io_file_create(const char *file,
+ const char *contents,
+ apr_pool_t *pool)
+{
+ return svn_error_trace(svn_io_file_create_binary(file, contents,
+ contents
+ ? strlen(contents)
+ : 0,
+ pool));
}
-svn_error_t *svn_io_dir_file_copy(const char *src_path,
- const char *dest_path,
- const char *file,
- apr_pool_t *pool)
+svn_error_t *
+svn_io_file_create_empty(const char *file,
+ apr_pool_t *pool)
+{
+ return svn_error_trace(svn_io_file_create_binary(file, "", 0, pool));
+}
+
+svn_error_t *
+svn_io_dir_file_copy(const char *src_path,
+ const char *dest_path,
+ const char *file,
+ apr_pool_t *pool)
{
const char *file_dest_path = svn_dirent_join(dest_path, file, pool);
const char *file_src_path = svn_dirent_join(src_path, file, pool);
- return svn_io_copy_file(file_src_path, file_dest_path, TRUE, pool);
+ return svn_error_trace(
+ svn_io_copy_file(file_src_path, file_dest_path, TRUE, pool));
}
@@ -1537,14 +1591,9 @@ io_set_file_perms(const char *path,
{
if (enable_write) /* Make read-write. */
{
- apr_file_t *fd;
-
- /* Get the perms for the original file so we'll have any other bits
- * that were already set (like the execute bits, for example). */
- SVN_ERR(svn_io_file_open(&fd, path, APR_READ,
- APR_OS_DEFAULT, pool));
- SVN_ERR(merge_default_file_perms(fd, &perms_to_set, pool));
- SVN_ERR(svn_io_file_close(fd, pool));
+ /* Tweak the owner bits only. The group/other bits aren't safe to
+ * touch because we may end up setting them in undesired ways. */
+ perms_to_set |= (APR_UREAD|APR_UWRITE);
}
else
{
@@ -1637,27 +1686,13 @@ io_set_file_perms(const char *path,
#endif /* !WIN32 && !__OS2__ */
#ifdef WIN32
-#if APR_HAS_UNICODE_FS
-/* copy of the apr function utf8_to_unicode_path since apr doesn't export this one */
-static apr_status_t io_utf8_to_unicode_path(apr_wchar_t* retstr, apr_size_t retlen,
- const char* srcstr)
-{
- /* TODO: The computations could preconvert the string to determine
- * the true size of the retstr, but that's a memory over speed
- * tradeoff that isn't appropriate this early in development.
- *
- * Allocate the maximum string length based on leading 4
- * characters of \\?\ (allowing nearly unlimited path lengths)
- * plus the trailing null, then transform /'s into \\'s since
- * the \\?\ form doesn't allow '/' path separators.
- *
- * Note that the \\?\ form only works for local drive paths, and
- * \\?\UNC\ is needed UNC paths.
- */
- apr_size_t srcremains = strlen(srcstr) + 1;
- apr_wchar_t *t = retstr;
- apr_status_t rv;
-
+/* This is semantically the same as the APR utf8_to_unicode_path
+ function, but reimplemented here because APR does not export it. */
+static svn_error_t*
+io_utf8_to_unicode_path(const WCHAR **result,
+ const char *source,
+ apr_pool_t *result_pool)
+{
/* This is correct, we don't twist the filename if it will
* definitely be shorter than 248 characters. It merits some
* performance testing to see if this has any effect, but there
@@ -1672,95 +1707,200 @@ static apr_status_t io_utf8_to_unicode_p
* Note that a utf-8 name can never result in more wide chars
* than the original number of utf-8 narrow chars.
*/
- if (srcremains > 248) {
- if (srcstr[1] == ':' && (srcstr[2] == '/' || srcstr[2] == '\\')) {
- wcscpy (retstr, L"\\\\?\\");
- retlen -= 4;
- t += 4;
+ const WCHAR *prefix = NULL;
+ const int srclen = strlen(source);
+ WCHAR *buffer;
+
+ if (srclen > 248)
+ {
+ if (svn_ctype_isalpha(source[0]) && source[1] == ':'
+ && (source[2] == '/' || source[2] == '\\'))
+ {
+ /* This is an ordinary absolute path. */
+ prefix = L"\\\\?\\";
}
- else if ((srcstr[0] == '/' || srcstr[0] == '\\')
- && (srcstr[1] == '/' || srcstr[1] == '\\')
- && (srcstr[2] != '?')) {
- /* Skip the slashes */
- srcstr += 2;
- srcremains -= 2;
- wcscpy (retstr, L"\\\\?\\UNC\\");
- retlen -= 8;
- t += 8;
+ else if ((source[0] == '/' || source[0] == '\\')
+ && (source[1] == '/' || source[1] == '\\')
+ && source[2] != '?')
+ {
+ /* This is a UNC path */
+ source += 2; /* Skip the leading slashes */
+ prefix = L"\\\\?\\UNC\\";
}
}
- if (rv = apr_conv_utf8_to_ucs2(srcstr, &srcremains, t, &retlen)) {
- return (rv == APR_INCOMPLETE) ? APR_EINVAL : rv;
+ SVN_ERR(svn_utf__win32_utf8_to_utf16(&(const WCHAR*)buffer, source,
+ prefix, result_pool));
+
+ /* Convert slashes to backslashes because the \\?\ path format
+ does not allow backslashes as path separators. */
+ *result = buffer;
+ for (; *buffer; ++buffer)
+ {
+ if (*buffer == '/')
+ *buffer = '\\';
+ }
+ return SVN_NO_ERROR;
+}
+
+/* This is semantically the same as the APR unicode_to_utf8_path
+ function, but reimplemented here because APR does not export it. */
+static svn_error_t *
+io_unicode_to_utf8_path(const char **result,
+ const WCHAR *source,
+ apr_pool_t *result_pool)
+{
+ const char *utf8_buffer;
+ char *buffer;
+
+ SVN_ERR(svn_utf__win32_utf16_to_utf8(&utf8_buffer, source,
+ NULL, result_pool));
+ if (!*utf8_buffer)
+ {
+ *result = utf8_buffer;
+ return SVN_NO_ERROR;
+ }
+
+ /* We know that the non-empty buffer returned from the UTF-16 to
+ UTF-8 conversion function is in fact writable. */
+ buffer = (char*)utf8_buffer;
+
+ /* Skip the leading 4 characters if the path begins \\?\, or substitute
+ * // for the \\?\UNC\ path prefix, allocating the maximum string
+ * length based on the remaining string, plus the trailing null.
+ * then transform \\'s back into /'s since the \\?\ form never
+ * allows '/' path seperators, and APR always uses '/'s.
+ */
+ if (0 == strncmp(buffer, "\\\\?\\", 4))
+ {
+ buffer += 4;
+ if (0 == strncmp(buffer, "UNC\\", 4))
+ {
+ buffer += 2;
+ *buffer = '/';
+ }
}
- if (srcremains) {
- return APR_ENAMETOOLONG;
+
+ *result = buffer;
+ for (; *buffer; ++buffer)
+ {
+ if (*buffer == '\\')
+ *buffer = '/';
}
- for (; *t; ++t)
- if (*t == L'/')
- *t = L'\\';
- return APR_SUCCESS;
+ return SVN_NO_ERROR;
}
-#endif
-static apr_status_t io_win_file_attrs_set(const char *fname,
- DWORD attributes,
- DWORD attr_mask,
- apr_pool_t *pool)
+static svn_error_t *
+io_win_file_attrs_set(const char *fname,
+ DWORD attributes,
+ DWORD attr_mask,
+ apr_pool_t *pool)
{
/* this is an implementation of apr_file_attrs_set() but one
that uses the proper Windows attributes instead of the apr
attributes. This way, we can apply any Windows file and
folder attributes even if apr doesn't implement them */
DWORD flags;
- apr_status_t rv;
-#if APR_HAS_UNICODE_FS
- apr_wchar_t wfname[APR_PATH_MAX];
-#endif
+ const WCHAR *wfname;
-#if APR_HAS_UNICODE_FS
- IF_WIN_OS_IS_UNICODE
- {
- if (rv = io_utf8_to_unicode_path(wfname,
- sizeof(wfname) / sizeof(wfname[0]),
- fname))
- return rv;
- flags = GetFileAttributesW(wfname);
- }
-#endif
-#if APR_HAS_ANSI_FS
- ELSE_WIN_OS_IS_ANSI
- {
- flags = GetFileAttributesA(fname);
- }
-#endif
+ SVN_ERR(io_utf8_to_unicode_path(&wfname, fname, pool));
+ flags = GetFileAttributesW(wfname);
if (flags == 0xFFFFFFFF)
- return apr_get_os_error();
+ return svn_error_wrap_apr(apr_get_os_error(),
+ _("Can't get attributes of file '%s'"),
+ svn_dirent_local_style(fname, pool));
flags &= ~attr_mask;
flags |= (attributes & attr_mask);
-#if APR_HAS_UNICODE_FS
- IF_WIN_OS_IS_UNICODE
- {
- rv = SetFileAttributesW(wfname, flags);
- }
-#endif
-#if APR_HAS_ANSI_FS
- ELSE_WIN_OS_IS_ANSI
- {
- rv = SetFileAttributesA(fname, flags);
- }
-#endif
+ if (!SetFileAttributesW(wfname, flags))
+ return svn_error_wrap_apr(apr_get_os_error(),
+ _("Can't set attributes of file '%s'"),
+ svn_dirent_local_style(fname, pool));
- if (rv == 0)
- return apr_get_os_error();
+ return SVN_NO_ERROR;;
+}
- return APR_SUCCESS;
+static svn_error_t *win_init_dynamic_imports(void *baton, apr_pool_t *pool)
+{
+ get_final_path_name_by_handle_proc = (GETFINALPATHNAMEBYHANDLE)
+ GetProcAddress(GetModuleHandleA("kernel32.dll"),
+ "GetFinalPathNameByHandleW");
+
+ return SVN_NO_ERROR;
}
-#endif
+static svn_error_t * io_win_read_link(svn_string_t **dest,
+ const char *path,
+ apr_pool_t *pool)
+{
+ SVN_ERR(svn_atomic__init_once(&win_dynamic_imports_state,
+ win_init_dynamic_imports, NULL, pool));
+
+ if (get_final_path_name_by_handle_proc)
+ {
+ DWORD rv;
+ apr_status_t status;
+ apr_file_t *file;
+ apr_os_file_t filehand;
+ WCHAR wdest[APR_PATH_MAX];
+ const char *data;
+
+ /* reserve one char for terminating zero. */
+ DWORD wdest_len = sizeof(wdest)/sizeof(wdest[0]) - 1;
+
+ status = apr_file_open(&file, path, APR_OPENINFO, APR_OS_DEFAULT, pool);
+
+ if (status)
+ return svn_error_wrap_apr(status,
+ _("Can't read contents of link"));
+
+ apr_os_file_get(&filehand, file);
+
+ rv = get_final_path_name_by_handle_proc(
+ filehand, wdest, wdest_len,
+ FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
+
+ /* Save error code. */
+ status = apr_get_os_error();
+
+ /* Close file/directory handle in any case. */
+ apr_file_close(file);
+
+ /* GetFinaPathNameByHandleW returns number of characters copied to
+ * output buffer. Returns zero on error. Returns required buffer size
+ * if supplied buffer is not enough. */
+ if (rv > wdest_len || rv == 0)
+ {
+ return svn_error_wrap_apr(status,
+ _("Can't read contents of link"));
+ }
+
+ /* GetFinaPathNameByHandleW doesn't add terminating NUL. */
+ wdest[rv] = 0;
+ SVN_ERR(io_unicode_to_utf8_path(&data, wdest, pool));
+
+ /* The result is already in the correct pool, so avoid copying
+ it to create the string. */
+ *dest = svn_string_create_empty(pool);
+ if (*data)
+ {
+ (*dest)->data = data;
+ (*dest)->len = strlen(data);
+ }
+
+ return SVN_NO_ERROR;
+ }
+ else
+ {
+ return svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, NULL,
+ _("Symbolic links are not supported on this "
+ "platform"));
+ }
+}
+
+#endif /* WIN32 */
svn_error_t *
svn_io_set_file_read_write_carefully(const char *path,
@@ -2161,36 +2301,34 @@ stringbuf_from_aprfile(svn_stringbuf_t *
svn_error_t *err;
svn_stringbuf_t *res = NULL;
apr_size_t res_initial_len = SVN__STREAM_CHUNK_SIZE;
- char *buf = apr_palloc(pool, SVN__STREAM_CHUNK_SIZE);
+ char *buf;
/* If our caller wants us to check the size of the file for
efficient memory handling, we'll try to do so. */
if (check_size)
{
- apr_status_t status;
+ apr_finfo_t finfo = { 0 };
- /* If our caller didn't tell us the file's name, we'll ask APR
- if it knows the name. No problem if we can't figure it out. */
- if (! filename)
- {
- const char *filename_apr;
- if (! (status = apr_file_name_get(&filename_apr, file)))
- filename = filename_apr;
- }
-
- /* If we now know the filename, try to stat(). If we succeed,
- we know how to allocate our stringbuf. */
- if (filename)
- {
- apr_finfo_t finfo;
- if (! (status = apr_stat(&finfo, filename, APR_FINFO_MIN, pool)))
- res_initial_len = (apr_size_t)finfo.size;
+ /* In some cases we get size 0 and no error for non files,
+ so we also check for the name. (= cached in apr_file_t) */
+ if (! apr_file_info_get(&finfo, APR_FINFO_SIZE, file) && finfo.fname)
+ {
+ /* we've got the file length. Now, read it in one go. */
+ svn_boolean_t eof;
+ res_initial_len = (apr_size_t)finfo.size;
+ res = svn_stringbuf_create_ensure(res_initial_len, pool);
+ SVN_ERR(svn_io_file_read_full2(file, res->data,
+ res_initial_len, &res->len,
+ &eof, pool));
+ res->data[res->len] = 0;
+
+ *result = res;
+ return SVN_NO_ERROR;
}
}
-
/* XXX: We should check the incoming data for being of type binary. */
-
+ buf = apr_palloc(pool, SVN__STREAM_CHUNK_SIZE);
res = svn_stringbuf_create_ensure(res_initial_len, pool);
/* apr_file_read will not return data and eof in the same call. So this loop
@@ -2206,7 +2344,7 @@ stringbuf_from_aprfile(svn_stringbuf_t *
/* Having read all the data we *expect* EOF */
if (err && !APR_STATUS_IS_EOF(err->apr_err))
- return err;
+ return svn_error_trace(err);
svn_error_clear(err);
*result = res;
@@ -3027,7 +3165,8 @@ svn_io_run_diff3_3(int *exitcode,
svn_config_get(cfg, &diff_cmd, SVN_CONFIG_SECTION_HELPERS,
SVN_CONFIG_OPTION_DIFF_CMD, SVN_CLIENT_DIFF);
SVN_ERR(cstring_to_utf8(&diff_utf8, diff_cmd, pool));
- args[i++] = apr_pstrcat(pool, "--diff-program=", diff_utf8, NULL);
+ args[i++] = apr_pstrcat(pool, "--diff-program=", diff_utf8,
+ SVN_VA_NULL);
#ifndef NDEBUG
++nargs;
#endif
@@ -3315,7 +3454,7 @@ do_io_file_wrapper_cleanup(apr_file_t *f
/* ### Issue #3014: Return a specific error for broken pipes,
* ### with a single element in the error chain. */
- if (APR_STATUS_IS_EPIPE(status))
+ if (SVN__APR_STATUS_IS_EPIPE(status))
return svn_error_create(SVN_ERR_IO_PIPE_WRITE_ERROR, NULL, NULL);
if (name)
@@ -3418,6 +3557,101 @@ svn_io_file_seek(apr_file_t *file, apr_s
pool);
}
+svn_error_t *
+svn_io_file_aligned_seek(apr_file_t *file,
+ apr_off_t block_size,
+ apr_off_t *buffer_start,
+ apr_off_t offset,
+ apr_pool_t *pool)
+{
+ const apr_size_t apr_default_buffer_size = 4096;
+ apr_size_t file_buffer_size = apr_default_buffer_size;
+ apr_off_t desired_offset = 0;
+ apr_off_t current = 0;
+ apr_off_t aligned_offset = 0;
+ svn_boolean_t fill_buffer = FALSE;
+
+ /* paranoia check: huge blocks on 32 bit machines may cause overflows */
+ SVN_ERR_ASSERT(block_size == (apr_size_t)block_size);
+
+ /* default for invalid block sizes */
+ if (block_size == 0)
+ block_size = apr_default_buffer_size;
+
+ /* on old APRs, we are simply stuck with 4k blocks */
+#if APR_VERSION_AT_LEAST(1,3,0)
+ file_buffer_size = apr_file_buffer_size_get(file);
+
+ /* don't try to set a buffer size for non-buffered files! */
+ if (file_buffer_size == 0)
+ {
+ aligned_offset = offset;
+ }
+ else if (file_buffer_size != (apr_size_t)block_size)
+ {
+ /* FILE has the wrong buffer size. correct it */
+ char *buffer;
+ file_buffer_size = (apr_size_t)block_size;
+ buffer = apr_palloc(apr_file_pool_get(file), file_buffer_size);
+ apr_file_buffer_set(file, buffer, file_buffer_size);
+
+ /* seek to the start of the block and cause APR to read 1 block */
+ aligned_offset = offset - (offset % block_size);
+ fill_buffer = TRUE;
+ }
+#endif
+ {
+ aligned_offset = offset - (offset % file_buffer_size);
+
+ /* We have no way to determine the block start of an APR file.
+ Furthermore, we don't want to throw away the current buffer
+ contents. Thus, we re-align the buffer only if the CURRENT
+ offset definitely lies outside the desired, aligned buffer.
+ This covers the typical case of linear reads getting very
+ close to OFFSET but reading the previous / following block.
+
+ Note that ALIGNED_OFFSET may still be within the current
+ buffer and no I/O will actually happen in the FILL_BUFFER
+ section below.
+ */
+ SVN_ERR(svn_io_file_seek(file, SEEK_CUR, ¤t, pool));
+ fill_buffer = aligned_offset + file_buffer_size <= current
+ || current <= aligned_offset;
+ }
+
+ if (fill_buffer)
+ {
+ char dummy;
+ apr_status_t status;
+
+ /* seek to the start of the block and cause APR to read 1 block */
+ SVN_ERR(svn_io_file_seek(file, SEEK_SET, &aligned_offset, pool));
+ status = apr_file_getc(&dummy, file);
+
+ /* read may fail if we seek to or behind EOF. That's ok then. */
+ if (status != APR_SUCCESS && !APR_STATUS_IS_EOF(status))
+ return do_io_file_wrapper_cleanup(file, status,
+ N_("Can't read file '%s'"),
+ N_("Can't read stream"),
+ pool);
+ }
+
+ /* finally, seek to the OFFSET the caller wants */
+ desired_offset = offset;
+ SVN_ERR(svn_io_file_seek(file, SEEK_SET, &offset, pool));
+ if (desired_offset != offset)
+ return do_io_file_wrapper_cleanup(file, APR_EOF,
+ N_("Can't seek in file '%s'"),
+ N_("Can't seek in stream"),
+ pool);
+
+ /* return the buffer start that we (probably) enforced */
+ if (buffer_start)
+ *buffer_start = aligned_offset;
+
+ return SVN_NO_ERROR;
+}
+
svn_error_t *
svn_io_file_write(apr_file_t *file, const void *buf,
@@ -3547,14 +3781,20 @@ svn_io_write_atomic(const char *final_pa
if (!err && copy_perms_path)
err = svn_io_copy_perms(copy_perms_path, tmp_path, scratch_pool);
+ if (!err)
+ err = svn_io_file_rename(tmp_path, final_path, scratch_pool);
+
if (err)
{
- return svn_error_compose_create(err,
- svn_io_remove_file2(tmp_path, FALSE,
- scratch_pool));
- }
+ err = svn_error_compose_create(err,
+ svn_io_remove_file2(tmp_path, TRUE,
+ scratch_pool));
- SVN_ERR(svn_io_file_rename(tmp_path, final_path, scratch_pool));
+ return svn_error_createf(err->apr_err, err,
+ _("Can't write '%s' atomicly"),
+ svn_dirent_local_style(final_path,
+ scratch_pool));
+ }
#ifdef __linux__
{
@@ -3814,22 +4054,26 @@ dir_make(const char *path, apr_fileperms
APR_FILE_ATTR_HIDDEN,
APR_FILE_ATTR_HIDDEN,
pool);
-#else
- /* on Windows, use our wrapper so we can also set the
- FILE_ATTRIBUTE_NOT_CONTENT_INDEXED attribute */
- status = io_win_file_attrs_set(path_apr,
- FILE_ATTRIBUTE_HIDDEN |
- FILE_ATTRIBUTE_NOT_CONTENT_INDEXED,
- FILE_ATTRIBUTE_HIDDEN |
- FILE_ATTRIBUTE_NOT_CONTENT_INDEXED,
- pool);
-
-#endif
if (status)
return svn_error_wrap_apr(status, _("Can't hide directory '%s'"),
svn_dirent_local_style(path, pool));
+#else
+ /* on Windows, use our wrapper so we can also set the
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED attribute */
+ svn_error_t *err =
+ io_win_file_attrs_set(path_apr,
+ FILE_ATTRIBUTE_HIDDEN |
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED,
+ FILE_ATTRIBUTE_HIDDEN |
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED,
+ pool);
+ if (err)
+ return svn_error_createf(err->apr_err, err,
+ _("Can't hide directory '%s'"),
+ svn_dirent_local_style(path, pool));
+#endif /* WIN32 */
}
-#endif
+#endif /* APR_FILE_ATTR_HIDDEN */
/* Windows does not implement sgid. Skip here because retrieving
the file permissions via APR_FINFO_PROT | APR_FINFO_OWNER is documented
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/iter.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/iter.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/iter.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/iter.c Wed Nov 27 11:52:35 2013
@@ -193,24 +193,36 @@ svn_iter__break(void)
const void *svn__apr_hash_index_key(const apr_hash_index_t *hi)
{
+#if APR_VERSION_AT_LEAST(1, 5, 0)
+ return apr_hash_this_key((apr_hash_index_t *)hi);
+#else
const void *key;
apr_hash_this((apr_hash_index_t *)hi, &key, NULL, NULL);
return key;
+#endif
}
apr_ssize_t svn__apr_hash_index_klen(const apr_hash_index_t *hi)
{
+#if APR_VERSION_AT_LEAST(1, 5, 0)
+ return apr_hash_this_key_len((apr_hash_index_t *)hi);
+#else
apr_ssize_t klen;
apr_hash_this((apr_hash_index_t *)hi, NULL, &klen, NULL);
return klen;
+#endif
}
void *svn__apr_hash_index_val(const apr_hash_index_t *hi)
{
+#if APR_VERSION_AT_LEAST(1, 5, 0)
+ return apr_hash_this_val((apr_hash_index_t *)hi);
+#else
void *val;
apr_hash_this((apr_hash_index_t *)hi, NULL, NULL, &val);
return val;
+#endif
}
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/log.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/log.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/log.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/log.c Wed Nov 27 11:52:35 2013
@@ -45,7 +45,7 @@ log_depth(svn_depth_t depth, apr_pool_t
{
if (depth == svn_depth_unknown)
return "";
- return apr_pstrcat(pool, " depth=", svn_depth_to_word(depth), (char *)NULL);
+ return apr_pstrcat(pool, " depth=", svn_depth_to_word(depth), SVN_VA_NULL);
}
static const char *
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/macos_keychain.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/macos_keychain.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/macos_keychain.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/macos_keychain.c Wed Nov 27 11:52:35 2013
@@ -32,6 +32,7 @@
#include "svn_config.h"
#include "svn_user.h"
+#include "auth.h"
#include "private/svn_auth_private.h"
#include "svn_private_config.h"
@@ -241,7 +242,7 @@ static const svn_auth_provider_t keychai
/* Public API */
void
-svn_auth_get_keychain_simple_provider(svn_auth_provider_object_t **provider,
+svn_auth__get_keychain_simple_provider(svn_auth_provider_object_t **provider,
apr_pool_t *pool)
{
svn_auth_provider_object_t *po = apr_pcalloc(pool, sizeof(*po));
@@ -251,7 +252,7 @@ svn_auth_get_keychain_simple_provider(sv
}
void
-svn_auth_get_keychain_ssl_client_cert_pw_provider
+svn_auth__get_keychain_ssl_client_cert_pw_provider
(svn_auth_provider_object_t **provider,
apr_pool_t *pool)
{
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/mergeinfo.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/mergeinfo.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/mergeinfo.c Wed Nov 27 11:52:35 2013
@@ -23,6 +23,7 @@
#include <assert.h>
#include <ctype.h>
+#include "svn_private_config.h"
#include "svn_path.h"
#include "svn_types.h"
#include "svn_ctype.h"
@@ -36,7 +37,6 @@
#include "private/svn_mergeinfo_private.h"
#include "private/svn_string_private.h"
#include "private/svn_subr_private.h"
-#include "svn_private_config.h"
#include "svn_hash.h"
#include "private/svn_dep_compat.h"
@@ -2566,7 +2566,7 @@ svn_mergeinfo__mergeinfo_from_segments(s
continue;
/* Prepend a leading slash to our path. */
- source_path = apr_pstrcat(pool, "/", segment->path, (char *)NULL);
+ source_path = apr_pstrcat(pool, "/", segment->path, SVN_VA_NULL);
/* See if we already stored ranges for this path. If not, make
a new list. */
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/named_atomic.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/named_atomic.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/named_atomic.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/named_atomic.c Wed Nov 27 11:52:35 2013
@@ -413,8 +413,8 @@ svn_atomic_namespace__create(svn_atomic_
/* construct the names of the system objects that we need
*/
- shm_name = apr_pstrcat(subpool, name, SHM_NAME_SUFFIX, NULL);
- lock_name = apr_pstrcat(subpool, name, MUTEX_NAME_SUFFIX, NULL);
+ shm_name = apr_pstrcat(subpool, name, SHM_NAME_SUFFIX, SVN_VA_NULL);
+ lock_name = apr_pstrcat(subpool, name, MUTEX_NAME_SUFFIX, SVN_VA_NULL);
/* initialize the lock objects
*/
@@ -508,8 +508,8 @@ svn_atomic_namespace__cleanup(const char
const char *shm_name, *lock_name;
/* file names used for the specified namespace */
- shm_name = apr_pstrcat(pool, name, SHM_NAME_SUFFIX, NULL);
- lock_name = apr_pstrcat(pool, name, MUTEX_NAME_SUFFIX, NULL);
+ shm_name = apr_pstrcat(pool, name, SHM_NAME_SUFFIX, SVN_VA_NULL);
+ lock_name = apr_pstrcat(pool, name, MUTEX_NAME_SUFFIX, SVN_VA_NULL);
/* remove these files if they exist */
SVN_ERR(svn_io_remove_file2(shm_name, TRUE, pool));
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/nls.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/nls.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/nls.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/nls.c Wed Nov 27 11:52:35 2013
@@ -37,6 +37,8 @@
#include "svn_pools.h"
#include "svn_path.h"
+#include "private/svn_utf_private.h"
+
#include "svn_private_config.h"
svn_error_t *
@@ -53,69 +55,38 @@ svn_nls_init(void)
{
#ifdef WIN32
WCHAR ucs2_path[MAX_PATH];
- char* utf8_path;
+ const char* utf8_path;
const char* internal_path;
- apr_pool_t* pool;
- apr_size_t inwords, outbytes, outlength;
+ apr_pool_t* scratch_pool;
- apr_pool_create(&pool, 0);
+ scratch_pool = svn_pool_create(NULL);
/* get exe name - our locale info will be in '../share/locale' */
- inwords = GetModuleFileNameW(0, ucs2_path,
- sizeof(ucs2_path) / sizeof(ucs2_path[0]));
- if (! inwords)
+ GetModuleFileNameW(NULL, ucs2_path,
+ sizeof(ucs2_path) / sizeof(ucs2_path[0]))
+ if (apr_get_os_error())
{
- /* We must be on a Win9x machine, so attempt to get an ANSI path,
- and convert it to Unicode. */
- CHAR ansi_path[MAX_PATH];
-
- if (GetModuleFileNameA(0, ansi_path, sizeof(ansi_path)))
- {
- inwords =
- MultiByteToWideChar(CP_ACP, 0, ansi_path, -1, ucs2_path,
- sizeof(ucs2_path) / sizeof(ucs2_path[0]));
- if (! inwords)
- {
- err =
- svn_error_createf(APR_EINVAL, NULL,
- _("Can't convert string to UCS-2: '%s'"),
- ansi_path);
- }
- }
- else
- {
- err = svn_error_create(APR_EINVAL, NULL,
- _("Can't get module file name"));
- }
+ err = svn_error_wrap_apr(apr_get_os_error()
+ _("Can't get module file name"));
}
if (! err)
- {
- outbytes = outlength = 3 * (inwords + 1);
- utf8_path = apr_palloc(pool, outlength);
-
- outbytes = WideCharToMultiByte(CP_UTF8, 0, ucs2_path, inwords,
- utf8_path, outbytes, NULL, NULL);
+ err = svn_utf__win32_utf16_to_utf8(&utf8_path, ucs2_path,
+ NULL, scratch_pool);
- if (outbytes == 0)
- {
- err = svn_error_wrap_apr(apr_get_os_error(),
- _("Can't convert module path "
- "to UTF-8 from UCS-2: '%s'"),
- ucs2_path);
- }
- else
- {
- utf8_path[outlength - outbytes] = '\0';
- internal_path = svn_dirent_internal_style(utf8_path, pool);
- /* get base path name */
- internal_path = svn_dirent_dirname(internal_path, pool);
- internal_path = svn_dirent_join(internal_path,
- SVN_LOCALE_RELATIVE_PATH,
- pool);
- bindtextdomain(PACKAGE_NAME, internal_path);
- }
+ if (! err)
+ {
+ internal_path = svn_dirent_internal_style(utf8_path, scratch_pool);
+ /* get base path name */
+ internal_path = svn_dirent_dirname(internal_path, scratch_pool);
+ internal_path = svn_dirent_join(internal_path,
+ SVN_LOCALE_RELATIVE_PATH,
+ scratch_pool);
+ SVN_ERR(svn_dirent_get_absolute(&internal_path, internal_path,
+ scratch_pool));
+ bindtextdomain(PACKAGE_NAME, internal_path);
}
- svn_pool_destroy(pool);
+
+ svn_pool_destroy(scratch_pool);
}
#else /* ! WIN32 */
bindtextdomain(PACKAGE_NAME, SVN_LOCALE_DIR);
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/opt.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/opt.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/opt.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/opt.c Wed Nov 27 11:52:35 2013
@@ -34,6 +34,7 @@
#include <apr_lib.h>
#include <apr_file_info.h>
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_cmdline.h"
#include "svn_version.h"
@@ -50,7 +51,6 @@
#include "private/svn_opt_private.h"
#include "opt.h"
-#include "svn_private_config.h"
/*** Code. ***/
@@ -186,7 +186,7 @@ format_option(const char **string,
opts = apr_psprintf(pool, "--%s", opt->name);
if (opt->has_arg)
- opts = apr_pstrcat(pool, opts, _(" ARG"), (char *)NULL);
+ opts = apr_pstrcat(pool, opts, _(" ARG"), SVN_VA_NULL);
if (doc)
opts = apr_psprintf(pool, "%-24s : %s", opts, _(opt->description));
@@ -933,7 +933,7 @@ svn_opt__args_to_target_array(apr_array_
}
}
- target = apr_pstrcat(pool, true_target, peg_rev, (char *)NULL);
+ target = apr_pstrcat(pool, true_target, peg_rev, SVN_VA_NULL);
APR_ARRAY_PUSH(output_targets, const char *) = target;
}
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/path.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/path.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/path.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/path.c Wed Nov 27 11:52:35 2013
@@ -1304,7 +1304,7 @@ svn_path_resolve_repos_relative_url(cons
* this function, which will remove any duplicate path separator.
*/
*absolute_url = apr_pstrcat(pool, repos_root_url, relative_url + 1,
- (char *)NULL);
+ SVN_VA_NULL);
return SVN_NO_ERROR;
}
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/properties.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/properties.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/properties.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/properties.c Wed Nov 27 11:52:35 2013
@@ -27,6 +27,8 @@
#include <apr_hash.h>
#include <apr_tables.h>
#include <string.h> /* for strncmp() */
+
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_string.h"
#include "svn_props.h"
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/simple_providers.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/simple_providers.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/simple_providers.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/simple_providers.c Wed Nov 27 11:52:35 2013
@@ -28,6 +28,8 @@
/*** Includes. ***/
#include <apr_pools.h>
+
+#include "svn_private_config.h"
#include "svn_auth.h"
#include "svn_dirent_uri.h"
#include "svn_hash.h"
@@ -39,8 +41,6 @@
#include "private/svn_auth_private.h"
-#include "svn_private_config.h"
-
#include "auth.h"
/*-----------------------------------------------------------------------*/
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/sorts.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/sorts.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/sorts.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/sorts.c Wed Nov 27 11:52:35 2013
@@ -28,6 +28,8 @@
#include <apr_tables.h>
#include <stdlib.h> /* for qsort() */
#include <assert.h>
+
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_path.h"
#include "svn_sorts.h"
@@ -307,3 +309,149 @@ svn_sort__array_reverse(apr_array_header
}
}
}
+
+/* Our priority queue data structure:
+ * Simply remember the constructor parameters.
+ */
+struct svn_priority_queue__t
+{
+ /* the queue elements, ordered as a heap according to COMPARE_FUNC */
+ apr_array_header_t *elements;
+
+ /* predicate used to order the heap */
+ int (*compare_func)(const void *, const void *);
+};
+
+/* Return TRUE, if heap element number LHS in QUEUE is smaller than element
+ * number RHS according to QUEUE->COMPARE_FUNC
+ */
+static int
+heap_is_less(svn_priority_queue__t *queue,
+ apr_size_t lhs,
+ apr_size_t rhs)
+{
+ char *lhs_value = queue->elements->elts + lhs * queue->elements->elt_size;
+ char *rhs_value = queue->elements->elts + rhs * queue->elements->elt_size;
+
+ /* nelts is never negative */
+ assert(lhs < (apr_size_t)queue->elements->nelts);
+ assert(rhs < (apr_size_t)queue->elements->nelts);
+ return queue->compare_func((void *)lhs_value, (void *)rhs_value) < 0;
+}
+
+/* Exchange elements number LHS and RHS in QUEUE.
+ */
+static void
+heap_swap(svn_priority_queue__t *queue,
+ apr_size_t lhs,
+ apr_size_t rhs)
+{
+ int i;
+ char *lhs_value = queue->elements->elts + lhs * queue->elements->elt_size;
+ char *rhs_value = queue->elements->elts + rhs * queue->elements->elt_size;
+
+ for (i = 0; i < queue->elements->elt_size; ++i)
+ {
+ char temp = lhs_value[i];
+ lhs_value[i] = rhs_value[i];
+ rhs_value[i] = temp;
+ }
+}
+
+/* Move element number IDX to lower indexes until the heap criterion is
+ * fulfilled again.
+ */
+static void
+heap_bubble_down(svn_priority_queue__t *queue,
+ int idx)
+{
+ while (idx > 0 && heap_is_less(queue, idx, (idx - 1) / 2))
+ {
+ heap_swap(queue, idx, (idx - 1) / 2);
+ idx = (idx - 1) / 2;
+ }
+}
+
+/* Move element number IDX to higher indexes until the heap criterion is
+ * fulfilled again.
+ */
+static void
+heap_bubble_up(svn_priority_queue__t *queue,
+ int idx)
+{
+ while (2 * idx + 2 < queue->elements->nelts)
+ {
+ int child = heap_is_less(queue, 2 * idx + 1, 2 * idx + 2)
+ ? 2 * idx + 1
+ : 2 * idx + 2;
+
+ if (heap_is_less(queue, idx, child))
+ return;
+
+ heap_swap(queue, idx, child);
+ idx = child;
+ }
+
+ if ( 2 * idx + 1 < queue->elements->nelts
+ && heap_is_less(queue, 2 * idx + 1, idx))
+ heap_swap(queue, 2 * idx + 1, idx);
+}
+
+svn_priority_queue__t *
+svn_priority_queue__create(apr_array_header_t *elements,
+ int (*compare_func)(const void *, const void *))
+{
+ int i;
+
+ svn_priority_queue__t *queue = apr_pcalloc(elements->pool, sizeof(*queue));
+ queue->elements = elements;
+ queue->compare_func = compare_func;
+
+ for (i = elements->nelts / 2; i >= 0; --i)
+ heap_bubble_up(queue, i);
+
+ return queue;
+}
+
+apr_size_t
+svn_priority_queue__size(svn_priority_queue__t *queue)
+{
+ return queue->elements->nelts;
+}
+
+void *
+svn_priority_queue__peek(svn_priority_queue__t *queue)
+{
+ return queue->elements->nelts ? queue->elements->elts : NULL;
+}
+
+void
+svn_priority_queue__update(svn_priority_queue__t *queue)
+{
+ heap_bubble_up(queue, 0);
+}
+
+void
+svn_priority_queue__pop(svn_priority_queue__t *queue)
+{
+ if (queue->elements->nelts)
+ {
+ memcpy(queue->elements->elts,
+ queue->elements->elts + (queue->elements->nelts - 1)
+ * queue->elements->elt_size,
+ queue->elements->elt_size);
+ --queue->elements->nelts;
+ heap_bubble_up(queue, 0);
+ }
+}
+
+void
+svn_priority_queue__push(svn_priority_queue__t *queue,
+ const void *element)
+{
+ /* we cannot duplicate elements due to potential array re-allocs */
+ assert(element && element != queue->elements->elts);
+
+ memcpy(apr_array_push(queue->elements), element, queue->elements->elt_size);
+ heap_bubble_down(queue, queue->elements->nelts - 1);
+}
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/spillbuf.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/spillbuf.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/spillbuf.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/spillbuf.c Wed Nov 27 11:52:35 2013
@@ -73,12 +73,26 @@ struct svn_spillbuf_t {
/* How much content remains in SPILL. */
svn_filesize_t spill_size;
+
+ /* When false, do not delete the spill file when it is closed. */
+ svn_boolean_t delete_on_close;
+
+ /* When true, and the amount of data written to the spillbuf is
+ larger than MAXSIZE, all spillbuf contents will be written to the
+ spill file. */
+ svn_boolean_t spill_all_contents;
+
+ /* The directory in which the spill file is created. */
+ const char *dirpath;
+
+ /* The name of the temporary spill file. */
+ const char *filename;
};
struct svn_spillbuf_reader_t {
/* Embed the spill-buffer within the reader. */
- struct svn_spillbuf_t buf;
+ struct svn_spillbuf_t *buf;
/* When we read content from the underlying spillbuf, these fields store
the ptr/len pair. The ptr will be incremented as we "read" out of this
@@ -99,28 +113,86 @@ struct svn_spillbuf_reader_t {
};
+/* Extended spillbuf initialization. */
+static void
+init_spillbuf_extended(svn_spillbuf_t *buf,
+ apr_size_t blocksize,
+ apr_size_t maxsize,
+ svn_boolean_t delete_on_close,
+ svn_boolean_t spill_all_contents,
+ const char *dirpath,
+ apr_pool_t *result_pool)
+{
+ buf->pool = result_pool;
+ buf->blocksize = blocksize;
+ buf->maxsize = maxsize;
+ buf->delete_on_close = delete_on_close;
+ buf->spill_all_contents = spill_all_contents;
+ buf->dirpath = dirpath;
+}
+
+/* Common constructor for initializing spillbufs.
+ Used by svn_spillbuf__create, svn_spilbuff__reader_create. */
+static void
+init_spillbuf(svn_spillbuf_t *buf,
+ apr_size_t blocksize,
+ apr_size_t maxsize,
+ apr_pool_t *result_pool)
+{
+ init_spillbuf_extended(buf, blocksize, maxsize,
+ TRUE, FALSE, NULL,
+ result_pool);
+}
+
svn_spillbuf_t *
svn_spillbuf__create(apr_size_t blocksize,
apr_size_t maxsize,
apr_pool_t *result_pool)
{
svn_spillbuf_t *buf = apr_pcalloc(result_pool, sizeof(*buf));
+ init_spillbuf(buf, blocksize, maxsize, result_pool);
+ return buf;
+}
- buf->pool = result_pool;
- buf->blocksize = blocksize;
- buf->maxsize = maxsize;
- /* Note: changes here should also go into svn_spillbuf__reader_create() */
+svn_spillbuf_t *
+svn_spillbuf__create_extended(apr_size_t blocksize,
+ apr_size_t maxsize,
+ svn_boolean_t delete_on_close,
+ svn_boolean_t spill_all_contents,
+ const char *dirpath,
+ apr_pool_t *result_pool)
+{
+ svn_spillbuf_t *buf = apr_pcalloc(result_pool, sizeof(*buf));
+ init_spillbuf_extended(buf, blocksize, maxsize,
+ delete_on_close, spill_all_contents, dirpath,
+ result_pool);
return buf;
}
-
svn_filesize_t
svn_spillbuf__get_size(const svn_spillbuf_t *buf)
{
return buf->memory_size + buf->spill_size;
}
+svn_filesize_t
+svn_spillbuf__get_memory_size(const svn_spillbuf_t *buf)
+{
+ return buf->memory_size;
+}
+
+const char *
+svn_spillbuf__get_filename(const svn_spillbuf_t *buf)
+{
+ return buf->filename;
+}
+
+apr_file_t *
+svn_spillbuf__get_file(const svn_spillbuf_t *buf)
+{
+ return buf->spill;
+}
/* Get a memblock from the spill-buffer. It will be the block that we
passed out for reading, come from the free list, or allocated. */
@@ -173,10 +245,32 @@ svn_spillbuf__write(svn_spillbuf_t *buf,
&& (buf->memory_size + len) > buf->maxsize)
{
SVN_ERR(svn_io_open_unique_file3(&buf->spill,
- NULL /* temp_path */,
- NULL /* dirpath */,
- svn_io_file_del_on_close,
+ &buf->filename,
+ buf->dirpath,
+ (buf->delete_on_close
+ ? svn_io_file_del_on_close
+ : svn_io_file_del_none),
buf->pool, scratch_pool));
+
+ /* Optionally write the memory contents into the file. */
+ if (buf->spill_all_contents)
+ {
+ mem = buf->head;
+ while (mem != NULL)
+ {
+ SVN_ERR(svn_io_file_write_full(buf->spill, mem->data, mem->size,
+ NULL, scratch_pool));
+ mem = mem->next;
+ }
+
+ /* Adjust the start offset for reading from the spill file.
+
+ ### FIXME: Instead, we should simply discard the memory
+ buffers; but currently some tests expect to read data in
+ the same chunk sizes as were written, so we'll leave this
+ change for later.*/
+ buf->spill_start = buf->memory_size;
+ }
}
/* Once a spill file has been constructed, then we need to put all
@@ -440,16 +534,10 @@ svn_spillbuf__reader_create(apr_size_t b
apr_pool_t *result_pool)
{
svn_spillbuf_reader_t *sbr = apr_pcalloc(result_pool, sizeof(*sbr));
-
- /* See svn_spillbuf__create() */
- sbr->buf.pool = result_pool;
- sbr->buf.blocksize = blocksize;
- sbr->buf.maxsize = maxsize;
-
+ sbr->buf = svn_spillbuf__create(blocksize, maxsize, result_pool);
return sbr;
}
-
svn_error_t *
svn_spillbuf__reader_read(apr_size_t *amt,
svn_spillbuf_reader_t *reader,
@@ -488,7 +576,7 @@ svn_spillbuf__reader_read(apr_size_t *am
if (reader->sb_len == 0)
{
SVN_ERR(svn_spillbuf__read(&reader->sb_ptr, &reader->sb_len,
- &reader->buf,
+ reader->buf,
scratch_pool));
/* We've run out of content, so return with whatever has
@@ -547,7 +635,8 @@ svn_spillbuf__reader_write(svn_spillbuf_
if (reader->sb_len > 0)
{
if (reader->save_ptr == NULL)
- reader->save_ptr = apr_palloc(reader->buf.pool, reader->buf.blocksize);
+ reader->save_ptr = apr_palloc(reader->buf->pool,
+ reader->buf->blocksize);
memcpy(reader->save_ptr, reader->sb_ptr, reader->sb_len);
reader->save_len = reader->sb_len;
@@ -557,7 +646,7 @@ svn_spillbuf__reader_write(svn_spillbuf_
reader->sb_len = 0;
}
- return svn_error_trace(svn_spillbuf__write(&reader->buf, data, len,
+ return svn_error_trace(svn_spillbuf__write(reader->buf, data, len,
scratch_pool));
}
@@ -596,14 +685,14 @@ write_handler_spillbuf(void *baton, cons
svn_stream_t *
-svn_stream__from_spillbuf(apr_size_t blocksize,
- apr_size_t maxsize,
+svn_stream__from_spillbuf(svn_spillbuf_t *buf,
apr_pool_t *result_pool)
{
svn_stream_t *stream;
struct spillbuf_baton *sb = apr_palloc(result_pool, sizeof(*sb));
- sb->reader = svn_spillbuf__reader_create(blocksize, maxsize, result_pool);
+ sb->reader = apr_pcalloc(result_pool, sizeof(*sb->reader));
+ sb->reader->buf = buf;
sb->scratch_pool = svn_pool_create(result_pool);
stream = svn_stream_create(sb, result_pool);
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/sqlite.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/sqlite.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/sqlite.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/sqlite.c Wed Nov 27 11:52:35 2013
@@ -707,9 +707,20 @@ svn_sqlite__finalize(svn_sqlite__stmt_t
svn_error_t *
svn_sqlite__reset(svn_sqlite__stmt_t *stmt)
{
- SQLITE_ERR(sqlite3_reset(stmt->s3stmt), stmt->db);
- SQLITE_ERR(sqlite3_clear_bindings(stmt->s3stmt), stmt->db);
+ /* No need to reset again after a first attempt */
stmt->needs_reset = FALSE;
+
+ /* Clear bindings first, as there are no documented reasons
+ why this would ever fail, but keeping variable bindings
+ when reset is not what we expect. */
+ SQLITE_ERR(sqlite3_clear_bindings(stmt->s3stmt), stmt->db);
+
+ /* Reset last, as this *will* fail if the statement failed since
+ the last time it was reset, while reporting just the same failure.
+ (In this case the statement is also properly reset).
+
+ See the sqlite3_reset() documentation for more details. */
+ SQLITE_ERR(sqlite3_reset(stmt->s3stmt), stmt->db);
return SVN_NO_ERROR;
}
@@ -1426,3 +1437,9 @@ svn_sqlite__result_int64(svn_sqlite__con
{
sqlite3_result_int64(sctx->context, val);
}
+
+void
+svn_sqlite__result_error(svn_sqlite__context_t *sctx, const char *msg, int num)
+{
+ sqlite3_result_error(sctx->context, msg, num);
+}
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_client_cert_providers.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_client_cert_providers.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_client_cert_providers.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_client_cert_providers.c Wed Nov 27 11:52:35 2013
@@ -29,6 +29,8 @@
/*** Includes. ***/
#include <apr_pools.h>
+
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_auth.h"
#include "svn_error.h"
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_client_cert_pw_providers.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_client_cert_pw_providers.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_client_cert_pw_providers.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_client_cert_pw_providers.c Wed Nov 27 11:52:35 2013
@@ -25,6 +25,7 @@
#include <apr_pools.h>
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_auth.h"
#include "svn_error.h"
@@ -33,7 +34,6 @@
#include "private/svn_auth_private.h"
-#include "svn_private_config.h"
/*-----------------------------------------------------------------------*/
/* File provider */
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_server_trust_providers.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_server_trust_providers.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_server_trust_providers.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/ssl_server_trust_providers.c Wed Nov 27 11:52:35 2013
@@ -24,6 +24,7 @@
#include <apr_pools.h>
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_auth.h"
#include "svn_error.h"
@@ -78,13 +79,7 @@ ssl_server_trust_file_first_credentials(
failstr = svn_hash_gets(creds_hash, AUTHN_FAILURES_KEY);
if (failstr)
- {
- char *endptr;
- unsigned long tmp_ulong = strtoul(failstr->data, &endptr, 10);
-
- if (*endptr == '\0')
- last_failures = (apr_uint32_t) tmp_ulong;
- }
+ SVN_ERR(svn_cstring_atoui(&last_failures, failstr->data));
/* If the cert is trusted and there are no new failures, we
* accept it by clearing all failures. */
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/stream.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/stream.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/stream.c Wed Nov 27 11:52:35 2013
@@ -1379,6 +1379,36 @@ svn_stream_checksummed(svn_stream_t *str
/* Miscellaneous stream functions. */
+
+svn_error_t *
+svn_stringbuf_from_stream(svn_stringbuf_t **str,
+ svn_stream_t *stream,
+ apr_size_t len_hint,
+ apr_pool_t *pool)
+{
+#define MIN_READ_SIZE 64
+
+ apr_size_t to_read = 0;
+ svn_stringbuf_t *text
+ = svn_stringbuf_create_ensure(len_hint ? len_hint : MIN_READ_SIZE, pool);
+
+ do
+ {
+ to_read = text->blocksize - 1 - text->len;
+ SVN_ERR(svn_stream_read(stream, text->data + text->len, &to_read));
+ text->len += to_read;
+
+ if (to_read && text->blocksize < text->len + MIN_READ_SIZE)
+ svn_stringbuf_ensure(text, text->blocksize * 2);
+ }
+ while (to_read);
+
+ text->data[text->len] = '\0';
+ *str = text;
+
+ return SVN_NO_ERROR;
+}
+
struct stringbuf_stream_baton
{
svn_stringbuf_t *str;
@@ -1657,7 +1687,7 @@ svn_string_from_stream(svn_string_t **re
}
-/* These are somewhat arbirary, if we ever get good empirical data as to
+/* These are somewhat arbitrary, if we ever get good empirical data as to
actually valid values, feel free to update them. */
#define BUFFER_BLOCK_SIZE 1024
#define BUFFER_MAX_SIZE 100000
@@ -1665,7 +1695,9 @@ svn_string_from_stream(svn_string_t **re
svn_stream_t *
svn_stream_buffered(apr_pool_t *result_pool)
{
- return svn_stream__from_spillbuf(BUFFER_BLOCK_SIZE, BUFFER_MAX_SIZE,
+ return svn_stream__from_spillbuf(svn_spillbuf__create(BUFFER_BLOCK_SIZE,
+ BUFFER_MAX_SIZE,
+ result_pool),
result_pool);
}
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/string.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/string.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/string.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/string.c Wed Nov 27 11:52:35 2013
@@ -53,9 +53,9 @@ membuf_create(void **data, apr_size_t *s
/* apr_palloc will allocate multiples of 8.
* Thus, we would waste some of that memory if we stuck to the
* smaller size. Note that this is safe even if apr_palloc would
- * use some other aligment or none at all. */
+ * use some other alignment or none at all. */
minimum_size = APR_ALIGN_DEFAULT(minimum_size);
- *data = (!minimum_size ? NULL : apr_palloc(pool, minimum_size));
+ *data = apr_palloc(pool, minimum_size);
*size = minimum_size;
}
@@ -121,7 +121,10 @@ svn_membuf__resize(svn_membuf_t *membuf,
const apr_size_t old_size = membuf->size;
membuf_ensure(&membuf->data, &membuf->size, size, membuf->pool);
- if (membuf->data && old_data && old_data != membuf->data)
+
+ /* If we re-allocated MEMBUF->DATA, it cannot be NULL.
+ * Statically initialized membuffers (OLD_DATA) may be NULL, though. */
+ if (old_data && old_data != membuf->data)
memcpy(membuf->data, old_data, old_size);
}
@@ -418,6 +421,17 @@ svn_stringbuf_create_from_string(const s
return svn_stringbuf_ncreate(str->data, str->len, pool);
}
+svn_stringbuf_t *
+svn_stringbuf_create_wrap(char *str, apr_pool_t *pool)
+{
+ svn_stringbuf_t *result = apr_palloc(pool, sizeof(*result));
+ result->pool = pool;
+ result->data = str;
+ result->len = strlen(str);
+ result->blocksize = result->len + 1;
+
+ return result;
+}
svn_stringbuf_t *
svn_stringbuf_createv(apr_pool_t *pool, const char *fmt, va_list ap)
@@ -595,6 +609,21 @@ svn_stringbuf_appendbytes(svn_stringbuf_
to null-terminate. */
}
+void
+svn_stringbuf_appendfill(svn_stringbuf_t *str,
+ char byte,
+ apr_size_t count)
+{
+ apr_size_t new_len = str->len + count;
+ svn_stringbuf_ensure(str, new_len);
+
+ memset(str->data + str->len, byte, count);
+
+ /* update buffer length and always NUL-terminate it */
+ str->len = new_len;
+ str->data[new_len] = '\0';
+}
+
void
svn_stringbuf_appendstr(svn_stringbuf_t *targetstr,
@@ -1196,6 +1225,86 @@ svn__i64toa_sep(apr_int64_t number, char
return apr_pstrdup(pool, buffer);
}
+apr_size_t
+svn__ui64tobase36(char *dest, apr_uint64_t value)
+{
+ char *dest_start = dest;
+ if (value < 10)
+ {
+ /* pretty frequent and trivial case. Make it fast. */
+ *(dest++) = (char)(value) + '0';
+ }
+ else
+ {
+ char buffer[SVN_INT64_BUFFER_SIZE];
+ char *p = buffer;
+
+ /* write result as little-endian to buffer */
+ while (value > 0)
+ {
+ char c = (char)(value % 36);
+ value /= 36;
+
+ *p = (c <= 9) ? (c + '0') : (c - 10 + 'a');
+ ++p;
+ }
+
+ /* copy as big-endian to DEST */
+ while (p > buffer)
+ *(dest++) = *(--p);
+ }
+
+ *dest = '\0';
+ return dest - dest_start;
+}
+
+apr_uint64_t
+svn__base36toui64(const char **next, const char *source)
+{
+ apr_uint64_t result = 0;
+ apr_uint64_t factor = 1;
+ int i = 0;
+ char digits[SVN_INT64_BUFFER_SIZE];
+
+ /* convert digits to numerical values and count the number of places.
+ * Also, prevent buffer overflow. */
+ while (i < sizeof(digits))
+ {
+ char c = *source;
+ if (c < 'a')
+ {
+ /* includes detection of NUL terminator */
+ if (c < '0' || c > '9')
+ break;
+
+ c -= '0';
+ }
+ else
+ {
+ if (c < 'a' || c > 'z')
+ break;
+
+ c -= 'a' - 10;
+ }
+
+ digits[i++] = c;
+ source++;
+ }
+
+ /* fold digits into the result */
+ while (i > 0)
+ {
+ result += factor * (apr_uint64_t)digits[--i];
+ factor *= 36;
+ }
+
+ if (next)
+ *next = source;
+
+ return result;
+}
+
+
unsigned int
svn_cstring__similarity(const char *stra, const char *strb,
svn_membuf_t *buffer, apr_size_t *rlcs)
@@ -1301,3 +1410,67 @@ svn_string__similarity(const svn_string_
else
return 1000;
}
+
+apr_size_t
+svn_cstring__match_length(const char *a,
+ const char *b,
+ apr_size_t max_len)
+{
+ apr_size_t pos = 0;
+
+#if SVN_UNALIGNED_ACCESS_IS_OK
+
+ /* Chunky processing is so much faster ...
+ *
+ * We can't make this work on architectures that require aligned access
+ * because A and B will probably have different alignment. So, skipping
+ * the first few chars until alignment is reached is not an option.
+ */
+ for (; pos + sizeof(apr_size_t) <= max_len; pos += sizeof(apr_size_t))
+ if (*(const apr_size_t*)(a + pos) != *(const apr_size_t*)(b + pos))
+ break;
+
+#endif
+
+ for (; pos < max_len; ++pos)
+ if (a[pos] != b[pos])
+ break;
+
+ return pos;
+}
+
+apr_size_t
+svn_cstring__reverse_match_length(const char *a,
+ const char *b,
+ apr_size_t max_len)
+{
+ apr_size_t pos = 0;
+
+#if SVN_UNALIGNED_ACCESS_IS_OK
+
+ /* Chunky processing is so much faster ...
+ *
+ * We can't make this work on architectures that require aligned access
+ * because A and B will probably have different alignment. So, skipping
+ * the first few chars until alignment is reached is not an option.
+ */
+ for (pos = sizeof(apr_size_t); pos <= max_len; pos += sizeof(apr_size_t))
+ if (*(const apr_size_t*)(a - pos) != *(const apr_size_t*)(b - pos))
+ break;
+
+ pos -= sizeof(apr_size_t);
+
+#endif
+
+ /* If we find a mismatch at -pos, pos-1 characters matched.
+ */
+ while (++pos <= max_len)
+ if (a[0-pos] != b[0-pos])
+ return pos - 1;
+
+ /* No mismatch found -> at least MAX_LEN matching chars.
+ */
+ return max_len;
+}
+
+
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/subst.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/subst.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/subst.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/subst.c Wed Nov 27 11:52:35 2013
@@ -33,6 +33,7 @@
#include <apr_file_io.h>
#include <apr_strings.h>
+#include "svn_private_config.h"
#include "svn_hash.h"
#include "svn_cmdline.h"
#include "svn_types.h"
@@ -47,8 +48,6 @@
#include "svn_pools.h"
#include "private/svn_io_private.h"
-#include "svn_private_config.h"
-
#include "private/svn_string_private.h"
#include "private/svn_eol_private.h"
@@ -1960,7 +1959,11 @@ svn_subst_translate_string2(svn_string_t
return SVN_NO_ERROR;
}
- if (encoding)
+ if (encoding && !strcmp(encoding, "UTF-8"))
+ {
+ val_utf8 = value->data;
+ }
+ else if (encoding)
{
SVN_ERR(svn_utf_cstring_to_utf8_ex2(&val_utf8, value->data,
encoding, scratch_pool));
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/sysinfo.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/sysinfo.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/sysinfo.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/sysinfo.c Wed Nov 27 11:52:35 2013
@@ -23,14 +23,6 @@
-#ifdef WIN32
-#define WIN32_LEAN_AND_MEAN
-#define PSAPI_VERSION 1
-#include <windows.h>
-#include <psapi.h>
-#include <Ws2tcpip.h>
-#endif
-
#define APR_WANT_STRFUNC
#include <apr_want.h>
@@ -278,7 +270,7 @@ release_name_from_uname(apr_pool_t *pool
#if __linux__
/* Split a stringbuf into a key/value pair.
- Return the key, leaving the striped value in the stringbuf. */
+ Return the key, leaving the stripped value in the stringbuf. */
static const char *
stringbuf_split_key(svn_stringbuf_t *buffer, char delim)
{
@@ -290,11 +282,21 @@ stringbuf_split_key(svn_stringbuf_t *buf
return NULL;
svn_stringbuf_strip_whitespace(buffer);
+
+ /* Now we split the currently allocated buffer in two parts:
+ - a const char * HEAD
+ - the remaining stringbuf_t. */
+
+ /* Create HEAD as '\0' terminated const char * */
key = buffer->data;
end = strchr(key, delim);
*end = '\0';
- buffer->len = 1 + end - key;
+
+ /* And update the TAIL to be a smaller, but still valid stringbuf */
buffer->data = end + 1;
+ buffer->len -= 1 + end - key;
+ buffer->blocksize -= 1 + end - key;
+
svn_stringbuf_strip_whitespace(buffer);
return key;
@@ -508,7 +510,7 @@ debian_release(apr_pool_t *pool)
return NULL;
stringbuf_first_line_only(buffer);
- return apr_pstrcat(pool, "Debian ", buffer->data, NULL);
+ return apr_pstrcat(pool, "Debian ", buffer->data, SVN_VA_NULL);
}
/* Try to find the Linux distribution name, or return info from uname. */
@@ -546,7 +548,7 @@ linux_release_name(apr_pool_t *pool)
#ifdef WIN32
typedef DWORD (WINAPI *FNGETNATIVESYSTEMINFO)(LPSYSTEM_INFO);
-typedef BOOL (WINAPI *FNENUMPROCESSMODULES) (HANDLE, HMODULE, DWORD, LPDWORD);
+typedef BOOL (WINAPI *FNENUMPROCESSMODULES) (HANDLE, HMODULE*, DWORD, LPDWORD);
/* Get system and version info, and try to tell the difference
between the native system type and the runtime environment of the
@@ -763,16 +765,36 @@ win32_release_name(apr_pool_t *pool)
static HMODULE *
enum_loaded_modules(apr_pool_t *pool)
{
+ HMODULE psapi_dll = 0;
HANDLE current = GetCurrentProcess();
HMODULE dummy[1];
HMODULE *handles;
DWORD size;
+ FNENUMPROCESSMODULES EnumProcessModules_;
+
+ psapi_dll = GetModuleHandleA("psapi.dll");
+
+ if (!psapi_dll)
+ {
+ /* Load and never unload, just like static linking */
+ psapi_dll = LoadLibraryA("psapi.dll");
+ }
+
+ if (!psapi_dll)
+ return NULL;
+
+ EnumProcessModules_ = (FNENUMPROCESSMODULES)
+ GetProcAddress(psapi_dll, "EnumProcessModules");
+
+ /* Before Windows XP psapi was an optional module */
+ if (! EnumProcessModules_)
+ return NULL;
- if (!EnumProcessModules(current, dummy, sizeof(dummy), &size))
+ if (!EnumProcessModules_(current, dummy, sizeof(dummy), &size))
return NULL;
handles = apr_palloc(pool, size + sizeof *handles);
- if (!EnumProcessModules(current, handles, size, &size))
+ if (! EnumProcessModules_(current, handles, size, &size))
return NULL;
handles[size / sizeof *handles] = NULL;
return handles;
Modified: subversion/branches/verify-keep-going/subversion/libsvn_subr/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/branches/verify-keep-going/subversion/libsvn_subr/temp_serializer.c?rev=1546002&r1=1546001&r2=1546002&view=diff
==============================================================================
--- subversion/branches/verify-keep-going/subversion/libsvn_subr/temp_serializer.c (original)
+++ subversion/branches/verify-keep-going/subversion/libsvn_subr/temp_serializer.c Wed Nov 27 11:52:35 2013
@@ -279,6 +279,26 @@ svn_temp_serializer__pop(svn_temp_serial
context->recycler = old;
}
+void
+svn_temp_serializer__add_leaf(svn_temp_serializer__context_t *context,
+ const void * const * source_struct,
+ apr_size_t struct_size)
+{
+ const void *source = *source_struct;
+
+ /* the serialized structure must be properly aligned */
+ if (source)
+ align_buffer_end(context);
+
+ /* Store the offset at which the struct data that will the appended.
+ * Write 0 for NULL pointers. */
+ store_current_end_pointer(context, source_struct);
+
+ /* finally, actually append the struct contents */
+ if (*source_struct)
+ svn_stringbuf_appendbytes(context->buffer, source, struct_size);
+}
+
/* Serialize a string referenced from the current structure within the
* serialization CONTEXT. S must be a reference to the char* pointer in
* the original structure so that the correspondence in the serialized