OSDN Git Service

fail try to porting svndiff
authorFrank Li <lznuaa@gmail.com>
Wed, 17 Dec 2008 05:12:48 +0000 (13:12 +0800)
committerFrank Li <lznuaa@gmail.com>
Wed, 17 Dec 2008 05:12:48 +0000 (13:12 +0800)
src/TortoiseMerge/libsvn_diff/diff.h [new file with mode: 0644]
src/TortoiseMerge/libsvn_diff/porting.c [new file with mode: 0644]
src/TortoiseMerge/libsvn_diff/svn_diff.h [new file with mode: 0644]
src/TortoiseMerge/svninclude/apr_strings.h [new file with mode: 0644]
src/TortoiseMerge/svninclude/svn_string.h [new file with mode: 0644]

diff --git a/src/TortoiseMerge/libsvn_diff/diff.h b/src/TortoiseMerge/libsvn_diff/diff.h
new file mode 100644 (file)
index 0000000..42201c6
--- /dev/null
@@ -0,0 +1,157 @@
+/*\r
+ * diff.h :  private header file\r
+ *\r
+ * ====================================================================\r
+ * Copyright (c) 2000-2004 CollabNet.  All rights reserved.\r
+ *\r
+ * This software is licensed as described in the file COPYING, which\r
+ * you should have received as part of this distribution.  The terms\r
+ * are also available at http://subversion.tigris.org/license-1.html.\r
+ * If newer versions of this license are posted there, you may use a\r
+ * newer version instead, at your option.\r
+ *\r
+ * This software consists of voluntary contributions made by many\r
+ * individuals.  For exact contribution history, see the revision\r
+ * history and logs, available at http://subversion.tigris.org/.\r
+ * ====================================================================\r
+ */\r
+\r
+#if !defined(DIFF_H)\r
+#define DIFF_H\r
+\r
+#include <apr.h>\r
+#include <apr_pools.h>\r
+#include <apr_general.h>\r
+\r
+\r
+#include "svn_types.h"\r
+#include "svn_pools.h"\r
+#include "svn_diff.h"\r
+\r
+\r
+#define SVN_DIFF__UNIFIED_CONTEXT_SIZE 3\r
+\r
+typedef struct svn_diff__node_t svn_diff__node_t;\r
+typedef struct svn_diff__tree_t svn_diff__tree_t;\r
+typedef struct svn_diff__position_t svn_diff__position_t;\r
+typedef struct svn_diff__lcs_t svn_diff__lcs_t;\r
+\r
+typedef enum svn_diff__type_e\r
+{\r
+  svn_diff__type_common,\r
+  svn_diff__type_diff_modified,\r
+  svn_diff__type_diff_latest,\r
+  svn_diff__type_diff_common,\r
+  svn_diff__type_conflict\r
+} svn_diff__type_e;\r
+\r
+struct svn_diff_t {\r
+  svn_diff_t *next;\r
+  svn_diff__type_e type;\r
+  apr_off_t original_start;\r
+  apr_off_t original_length;\r
+  apr_off_t modified_start;\r
+  apr_off_t modified_length;\r
+  apr_off_t latest_start;\r
+  apr_off_t latest_length;\r
+  svn_diff_t *resolved_diff;\r
+};\r
+\r
+struct svn_diff__position_t\r
+{\r
+  svn_diff__position_t *next;\r
+  svn_diff__node_t     *node;\r
+  apr_off_t             offset;\r
+};\r
+\r
+struct svn_diff__lcs_t\r
+{\r
+  svn_diff__lcs_t      *next;\r
+  svn_diff__position_t *position[2];\r
+  apr_off_t             length;\r
+  int                   refcount;\r
+};\r
+\r
+\r
+/* State used when normalizing whitespace and EOL styles. */\r
+typedef enum svn_diff__normalize_state_t\r
+{\r
+  /* Initial state; not in a sequence of whitespace. */\r
+  svn_diff__normalize_state_normal,\r
+  /* We're in a sequence of whitespace characters.  Only entered if\r
+     we ignore whitespace. */\r
+  svn_diff__normalize_state_whitespace,\r
+  /* The previous character was CR. */\r
+  svn_diff__normalize_state_cr\r
+} svn_diff__normalize_state_t;\r
+\r
+\r
+svn_diff__lcs_t *\r
+svn_diff__lcs(svn_diff__position_t *position_list1, /* pointer to tail (ring) */\r
+              svn_diff__position_t *position_list2, /* pointer to tail (ring) */\r
+             apr_pool_t *pool);\r
+\r
+\r
+/*\r
+ * Support functions to build a tree of token positions\r
+ */\r
+void\r
+svn_diff__tree_create(svn_diff__tree_t **tree, apr_pool_t *pool);\r
+\r
+\r
+/*\r
+ * Get all tokens from a datasource.  Return the\r
+ * last item in the (circular) list.\r
+ */\r
+svn_error_t *\r
+svn_diff__get_tokens(svn_diff__position_t **position_list,\r
+                     svn_diff__tree_t *tree,\r
+                     void *diff_baton,\r
+                     const svn_diff_fns_t *vtable,\r
+                     svn_diff_datasource_e datasource,\r
+                     apr_pool_t *pool);\r
+\r
+\r
+/* Morph a svn_lcs_t into a svn_diff_t. */\r
+svn_diff_t *\r
+svn_diff__diff(svn_diff__lcs_t *lcs,\r
+               apr_off_t original_start, apr_off_t modified_start,\r
+               svn_boolean_t want_common,\r
+               apr_pool_t *pool);\r
+\r
+void\r
+svn_diff__resolve_conflict(svn_diff_t *hunk,\r
+                           svn_diff__position_t **position_list1,\r
+                           svn_diff__position_t **position_list2,\r
+                           apr_pool_t *pool);\r
+\r
+\r
+/*\r
+ * Return an adler32 checksum based on CHECKSUM, updated with\r
+ * DATA of size LEN.\r
+ */\r
+apr_uint32_t\r
+svn_diff__adler32(apr_uint32_t checksum, const char *data, apr_size_t len);\r
+\r
+\r
+/* Normalize the characters pointed to by BUF of length *LENGTHP, starting\r
+ * in state *STATEP according to the OPTIONS.\r
+ * Adjust *LENGTHP and *STATEP to be the length of the normalized buffer and\r
+ * the final state, respectively.\r
+ * Normalized data is written to the memory at *TGT. BUF and TGT may point\r
+ * to the same memory area.  The memory area pointed to by *TGT should be\r
+ * large enough to hold *LENGTHP bytes.\r
+ * When on return *TGT is not equal to the value passed in, it points somewhere\r
+ * into the memory region designated by BUF and *LENGTHP.\r
+ */\r
+void\r
+svn_diff__normalize_buffer(char **tgt,\r
+                           apr_off_t *lengthp,\r
+                           svn_diff__normalize_state_t *statep,\r
+                           const char *buf,\r
+                           const svn_diff_file_options_t *opts);\r
+\r
+\r
+\r
+\r
+#endif /* DIFF_H */\r
diff --git a/src/TortoiseMerge/libsvn_diff/porting.c b/src/TortoiseMerge/libsvn_diff/porting.c
new file mode 100644 (file)
index 0000000..ad2f2ec
--- /dev/null
@@ -0,0 +1,44 @@
+#include <apr.h>\r
+#include <apr_pools.h>\r
+#include <apr_general.h>\r
+\r
+void * apr_palloc(apr_pool_t *p, apr_size_t size)\r
+{\r
+       if(p->start+size> p->size)\r
+               return NULL;\r
+\r
+       else\r
+       {\r
+               p->start+=size;\r
+               return (void*)(p->data+p->start);\r
+       }\r
+}\r
+\r
+void * apr_pcalloc(apr_pool_t *p, apr_size_t size)\r
+{\r
+       void *p1=apr_palloc(p,size);\r
+       memset(p1,0,size);\r
+       return p1;\r
+}\r
+apr_pool_t * svn_pool_create(apr_pool_t *p)\r
+{\r
+       return malloc(4096);\r
+}\r
+\r
+void svn_pool_destroy(apr_pool_t *p)\r
+{\r
+       free(p);\r
+}\r
+\r
+void svn_pool_clear(apr_pool_t *p)\r
+{\r
+       p->start=0;\r
+}\r
+\r
+void svn_error__malfunction(char * error, int x, void* p)\r
+{\r
+}\r
+\r
+void svn_error_clear()\r
+{\r
+}
\ No newline at end of file
diff --git a/src/TortoiseMerge/libsvn_diff/svn_diff.h b/src/TortoiseMerge/libsvn_diff/svn_diff.h
new file mode 100644 (file)
index 0000000..928b08b
--- /dev/null
@@ -0,0 +1,752 @@
+/**\r
+ * @copyright\r
+ * ====================================================================\r
+ * Copyright (c) 2000-2008 CollabNet.  All rights reserved.\r
+ *\r
+ * This software is licensed as described in the file COPYING, which\r
+ * you should have received as part of this distribution.  The terms\r
+ * are also available at http://subversion.tigris.org/license-1.html.\r
+ * If newer versions of this license are posted there, you may use a\r
+ * newer version instead, at your option.\r
+ *\r
+ * This software consists of voluntary contributions made by many\r
+ * individuals.  For exact contribution history, see the revision\r
+ * history and logs, available at http://subversion.tigris.org/.\r
+ * ====================================================================\r
+ * @endcopyright\r
+ *\r
+ * @file svn_diff.h\r
+ * @brief Contextual diffing.\r
+ *\r
+ * This is an internalized library for performing contextual diffs\r
+ * between sources of data.\r
+ *\r
+ * @note This is different than Subversion's binary-diffing engine.\r
+ * That API lives in @c svn_delta.h -- see the "text deltas" section.  A\r
+ * "text delta" is way of representing precise binary diffs between\r
+ * strings of data.  The Subversion client and server send text deltas\r
+ * to one another during updates and commits.\r
+ *\r
+ * This API, however, is (or will be) used for performing *contextual*\r
+ * merges between files in the working copy.  During an update or\r
+ * merge, 3-way file merging is needed.  And 'svn diff' needs to show\r
+ * the differences between 2 files.\r
+ *\r
+ * The nice thing about this API is that it's very general.  It\r
+ * operates on any source of data (a "datasource") and calculates\r
+ * contextual differences on "tokens" within the data.  In our\r
+ * particular usage, the datasources are files and the tokens are\r
+ * lines.  But the possibilities are endless.\r
+ */\r
+\r
+\r
+#ifndef SVN_DIFF_H\r
+#define SVN_DIFF_H\r
+\r
+#include <apr.h>\r
+#include <apr_pools.h>\r
+#include <apr_file_io.h>\r
+\r
+#include "svn_types.h"\r
+#include "svn_error.h"\r
+#include "svn_pools.h"\r
+//#include "svn_version.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif /* __cplusplus */\r
+\r
+\r
+\r
+/**\r
+ * Get libsvn_diff version information.\r
+ *\r
+ * @since New in 1.1.\r
+ */\r
+const svn_version_t *\r
+svn_diff_version(void);\r
+\r
+\r
+/* Diffs. */\r
+\r
+/** An opaque type that represents a difference between either two or\r
+ * three datasources.   This object is returned by svn_diff_diff(),\r
+ * svn_diff_diff3() and svn_diff_diff4(), and consumed by a number of\r
+ * other routines.\r
+ */\r
+typedef struct svn_diff_t svn_diff_t;\r
+\r
+/**\r
+ * There are four types of datasources.  In GNU diff3 terminology,\r
+ * the first three types correspond to the phrases "older", "mine",\r
+ * and "yours".\r
+ */\r
+typedef enum svn_diff_datasource_e\r
+{\r
+  /** The oldest form of the data. */\r
+  svn_diff_datasource_original,\r
+\r
+  /** The same data, but potentially changed by the user. */\r
+  svn_diff_datasource_modified,\r
+\r
+  /** The latest version of the data, possibly different than the\r
+   * user's modified version.\r
+   */\r
+  svn_diff_datasource_latest,\r
+\r
+  /** The common ancestor of original and modified. */\r
+  svn_diff_datasource_ancestor\r
+\r
+} svn_diff_datasource_e;\r
+\r
+\r
+/** A vtable for reading data from the three datasources. */\r
+typedef struct svn_diff_fns_t\r
+{\r
+  /** Open the datasource of type @a datasource. */\r
+  svn_error_t *(*datasource_open)(void *diff_baton,\r
+                                  svn_diff_datasource_e datasource);\r
+\r
+  /** Close the datasource of type @a datasource. */\r
+  svn_error_t *(*datasource_close)(void *diff_baton,\r
+                                   svn_diff_datasource_e datasource);\r
+\r
+  /** Get the next "token" from the datasource of type @a datasource.\r
+   *  Return a "token" in @a *token.   Return a hash of "token" in @a *hash.\r
+   *  Leave @a token and @a hash untouched when the datasource is exhausted.\r
+   */\r
+  svn_error_t *(*datasource_get_next_token)(apr_uint32_t *hash, void **token,\r
+                                            void *diff_baton,\r
+                                            svn_diff_datasource_e datasource);\r
+\r
+  /** A function for ordering the tokens, resembling 'strcmp' in functionality.\r
+   * @a compare should contain the return value of the comparison:\r
+   * If @a ltoken and @a rtoken are "equal", return 0.  If @a ltoken is\r
+   * "less than" @a rtoken, return a number < 0.  If @a ltoken  is\r
+   * "greater than" @a rtoken, return a number > 0.\r
+   */\r
+  svn_error_t *(*token_compare)(void *diff_baton,\r
+                                void *ltoken,\r
+                                void *rtoken,\r
+                                int *compare);\r
+\r
+  /** Free @a token from memory, the diff algorithm is done with it. */\r
+  void (*token_discard)(void *diff_baton,\r
+                        void *token);\r
+\r
+  /** Free *all* tokens from memory, they're no longer needed. */\r
+  void (*token_discard_all)(void *diff_baton);\r
+} svn_diff_fns_t;\r
+\r
+\r
+/* The Main Events */\r
+\r
+/** Given a vtable of @a diff_fns/@a diff_baton for reading datasources,\r
+ * return a diff object in @a *diff that represents a difference between\r
+ * an "original" and "modified" datasource.  Do all allocation in @a pool.\r
+ */\r
+svn_error_t *\r
+svn_diff_diff(svn_diff_t **diff,\r
+              void *diff_baton,\r
+              const svn_diff_fns_t *diff_fns,\r
+              apr_pool_t *pool);\r
+\r
+/** Given a vtable of @a diff_fns/@a diff_baton for reading datasources,\r
+ * return a diff object in @a *diff that represents a difference between\r
+ * three datasources: "original", "modified", and "latest".  Do all\r
+ * allocation in @a pool.\r
+ */\r
+svn_error_t *\r
+svn_diff_diff3(svn_diff_t **diff,\r
+               void *diff_baton,\r
+               const svn_diff_fns_t *diff_fns,\r
+               apr_pool_t *pool);\r
+\r
+/** Given a vtable of @a diff_fns/@a diff_baton for reading datasources,\r
+ * return a diff object in @a *diff that represents a difference between\r
+ * two datasources: "original" and "latest", adjusted to become a full\r
+ * difference between "original", "modified" and "latest" using "ancestor".\r
+ * Do all allocation in @a pool.\r
+ */\r
+svn_error_t *\r
+svn_diff_diff4(svn_diff_t **diff,\r
+               void *diff_baton,\r
+               const svn_diff_fns_t *diff_fns,\r
+               apr_pool_t *pool);\r
+\r
+\f\r
+/* Utility functions */\r
+\r
+/** Determine if a diff object contains conflicts.  If it does, return\r
+ * @c TRUE, else return @c FALSE.\r
+ */\r
+svn_boolean_t\r
+svn_diff_contains_conflicts(svn_diff_t *diff);\r
+\r
+\r
+/** Determine if a diff object contains actual differences between the\r
+ * datasources.  If so, return @c TRUE, else return @c FALSE.\r
+ */\r
+svn_boolean_t\r
+svn_diff_contains_diffs(svn_diff_t *diff);\r
+\r
+\r
+\r
+\f\r
+/* Displaying Diffs */\r
+\r
+/** A vtable for displaying (or consuming) differences between datasources.\r
+ *\r
+ * Differences, similarities, and conflicts are described by lining up\r
+ * "ranges" of data.\r
+ *\r
+ * @note These callbacks describe data ranges in units of "tokens".\r
+ * A "token" is whatever you've defined it to be in your datasource\r
+ * @c svn_diff_fns_t vtable.\r
+ */\r
+typedef struct svn_diff_output_fns_t\r
+{\r
+  /* Two-way and three-way diffs both call the first two output functions: */\r
+\r
+  /**\r
+   * If doing a two-way diff, then an *identical* data range was found\r
+   * between the "original" and "modified" datasources.  Specifically,\r
+   * the match starts at @a original_start and goes for @a original_length\r
+   * tokens in the original data, and at @a modified_start for\r
+   * @a modified_length tokens in the modified data.\r
+   *\r
+   * If doing a three-way diff, then all three datasources have\r
+   * matching data ranges.  The range @a latest_start, @a latest_length in\r
+   * the "latest" datasource is identical to the range @a original_start,\r
+   * @a original_length in the original data, and is also identical to\r
+   * the range @a modified_start, @a modified_length in the modified data.\r
+   */\r
+  svn_error_t *(*output_common)(void *output_baton,\r
+                                apr_off_t original_start,\r
+                                apr_off_t original_length,\r
+                                apr_off_t modified_start,\r
+                                apr_off_t modified_length,\r
+                                apr_off_t latest_start,\r
+                                apr_off_t latest_length);\r
+\r
+  /**\r
+   * If doing a two-way diff, then an *conflicting* data range was found\r
+   * between the "original" and "modified" datasources.  Specifically,\r
+   * the conflict starts at @a original_start and goes for @a original_length\r
+   * tokens in the original data, and at @a modified_start for\r
+   * @a modified_length tokens in the modified data.\r
+   *\r
+   * If doing a three-way diff, then an identical data range was discovered\r
+   * between the "original" and "latest" datasources, but this conflicts with\r
+   * a range in the "modified" datasource.\r
+   */\r
+  svn_error_t *(*output_diff_modified)(void *output_baton,\r
+                                       apr_off_t original_start,\r
+                                       apr_off_t original_length,\r
+                                       apr_off_t modified_start,\r
+                                       apr_off_t modified_length,\r
+                                       apr_off_t latest_start,\r
+                                       apr_off_t latest_length);\r
+\r
+  /* ------ The following callbacks are used by three-way diffs only --- */\r
+\r
+  /** An identical data range was discovered between the "original" and\r
+   * "modified" datasources, but this conflicts with a range in the\r
+   * "latest" datasource.\r
+   */\r
+  svn_error_t *(*output_diff_latest)(void *output_baton,\r
+                                     apr_off_t original_start,\r
+                                     apr_off_t original_length,\r
+                                     apr_off_t modified_start,\r
+                                     apr_off_t modified_length,\r
+                                     apr_off_t latest_start,\r
+                                     apr_off_t latest_length);\r
+\r
+  /** An identical data range was discovered between the "modified" and\r
+   * "latest" datasources, but this conflicts with a range in the\r
+   * "original" datasource.\r
+   */\r
+  svn_error_t *(*output_diff_common)(void *output_baton,\r
+                                     apr_off_t original_start,\r
+                                     apr_off_t original_length,\r
+                                     apr_off_t modified_start,\r
+                                     apr_off_t modified_length,\r
+                                     apr_off_t latest_start,\r
+                                     apr_off_t latest_length);\r
+\r
+  /** All three datasources have conflicting data ranges.  The range\r
+   * @a latest_start, @a latest_length in the "latest" datasource conflicts\r
+   * with the range @a original_start, @a original_length in the "original"\r
+   * datasource, and also conflicts with the range @a modified_start,\r
+   * @a modified_length in the "modified" datasource.\r
+   * If there are common ranges in the "modified" and "latest" datasources\r
+   * in this conflicting range, @a resolved_diff will contain a diff\r
+   * which can be used to retrieve the common and conflicting ranges.\r
+   */\r
+  svn_error_t *(*output_conflict)(void *output_baton,\r
+                                  apr_off_t original_start,\r
+                                  apr_off_t original_length,\r
+                                  apr_off_t modified_start,\r
+                                  apr_off_t modified_length,\r
+                                  apr_off_t latest_start,\r
+                                  apr_off_t latest_length,\r
+                                  svn_diff_t *resolved_diff);\r
+} svn_diff_output_fns_t;\r
+\r
+/** Style for displaying conflicts during diff3 output.\r
+ *\r
+ * @since New in 1.6.\r
+ */\r
+typedef enum svn_diff_conflict_display_style_t\r
+{\r
+  /** Display modified and latest, with conflict markers. */\r
+  svn_diff_conflict_display_modified_latest,\r
+\r
+  /** Like svn_diff_conflict_display_modified_latest, but with an\r
+      extra effort to identify common sequences between modified and\r
+      latest. */\r
+  svn_diff_conflict_display_resolved_modified_latest,\r
+\r
+  /** Display modified, original, and latest, with conflict\r
+      markers. */\r
+  svn_diff_conflict_display_modified_original_latest,\r
+\r
+  /** Just display modified, with no markers. */\r
+  svn_diff_conflict_display_modified,\r
+\r
+  /** Just display latest, with no markers. */\r
+  svn_diff_conflict_display_latest,\r
+\r
+  /** Like svn_diff_conflict_display_modified_original_latest, but\r
+      *only* showing conflicts. */\r
+  svn_diff_conflict_display_only_conflicts\r
+} svn_diff_conflict_display_style_t;\r
+\r
+\r
+/** Given a vtable of @a output_fns/@a output_baton for consuming\r
+ * differences, output the differences in @a diff.\r
+ */\r
+svn_error_t *\r
+svn_diff_output(svn_diff_t *diff,\r
+                void *output_baton,\r
+                const svn_diff_output_fns_t *output_fns);\r
+\r
+\r
+\f\r
+/* Diffs on files */\r
+\r
+/** To what extent whitespace should be ignored when comparing lines.\r
+ *\r
+ * @since New in 1.4.\r
+ */\r
+typedef enum svn_diff_file_ignore_space_t\r
+{\r
+  /** Ignore no whitespace. */\r
+  svn_diff_file_ignore_space_none,\r
+\r
+  /** Ignore changes in sequences of whitespace characters, treating each\r
+   * sequence of whitespace characters as a single space. */\r
+  svn_diff_file_ignore_space_change,\r
+\r
+  /** Ignore all whitespace characters. */\r
+  svn_diff_file_ignore_space_all\r
+} svn_diff_file_ignore_space_t;\r
+\r
+/** Options to control the behaviour of the file diff routines.\r
+ *\r
+ * @since New in 1.4.\r
+ *\r
+ * @note This structure may be extended in the future, so to preserve binary\r
+ * compatibility, users must not allocate structs of this type themselves.\r
+ * @see svn_diff_file_options_create().\r
+ *\r
+ * @note Although its name suggests otherwise, this structure is used to\r
+ *       pass options to file as well as in-memory diff functions.\r
+ */\r
+typedef struct svn_diff_file_options_t\r
+{\r
+  /** To what extent whitespace should be ignored when comparing lines.\r
+   * The default is @c svn_diff_file_ignore_space_none. */\r
+  svn_diff_file_ignore_space_t ignore_space;\r
+  /** Whether to treat all end-of-line markers the same when comparing lines.\r
+   * The default is @c FALSE. */\r
+  svn_boolean_t ignore_eol_style;\r
+  /** Whether the '@@' lines of the unified diff output should include a prefix\r
+    * of the nearest preceding line that starts with a character that might be\r
+    * the initial character of a C language identifier.  The default is\r
+    * @c FALSE.\r
+    */\r
+  svn_boolean_t show_c_function;\r
+} svn_diff_file_options_t;\r
+\r
+/** Allocate a @c svn_diff_file_options_t structure in @a pool, initializing\r
+ * it with default values.\r
+ *\r
+ * @since New in 1.4.\r
+ */\r
+svn_diff_file_options_t *\r
+svn_diff_file_options_create(apr_pool_t *pool);\r
+\r
+/**\r
+ * Parse @a args, an array of <tt>const char *</tt> command line switches\r
+ * and adjust @a options accordingly.  @a options is assumed to be initialized\r
+ * with default values.  @a pool is used for temporary allocation.\r
+ *\r
+ * @since New in 1.4.\r
+ *\r
+ * The following options are supported:\r
+ * - --ignore-space-change, -b\r
+ * - --ignore-all-space, -w\r
+ * - --ignore-eol-style\r
+ * - --unified, -u (for compatibility, does nothing).\r
+ */\r
+#if 0\r
+svn_error_t *\r
+svn_diff_file_options_parse(svn_diff_file_options_t *options,\r
+                            const apr_array_header_t *args,\r
+                            apr_pool_t *pool);\r
+#endif\r
+\r
+/** A convenience function to produce a diff between two files.\r
+ *\r
+ * @since New in 1.4.\r
+ *\r
+ * Return a diff object in @a *diff (allocated from @a pool) that represents\r
+ * the difference between an @a original file and @a modified file.\r
+ * (The file arguments must be full paths to the files.)\r
+ *\r
+ * Compare lines according to the relevant fields of @a options.\r
+ */\r
+svn_error_t *\r
+svn_diff_file_diff_2(svn_diff_t **diff,\r
+                     const char *original,\r
+                     const char *modified,\r
+                     const svn_diff_file_options_t *options,\r
+                     apr_pool_t *pool);\r
+\r
+/** Similar to svn_file_diff_2(), but with @a options set to a struct with\r
+ * default options.\r
+ *\r
+ * @deprecated Provided for backwards compatibility with the 1.3 API.\r
+ */\r
+SVN_DEPRECATED\r
+svn_error_t *\r
+svn_diff_file_diff(svn_diff_t **diff,\r
+                   const char *original,\r
+                   const char *modified,\r
+                   apr_pool_t *pool);\r
+\r
+/** A convenience function to produce a diff between three files.\r
+ *\r
+ * @since New in 1.4.\r
+ *\r
+ * Return a diff object in @a *diff (allocated from @a pool) that represents\r
+ * the difference between an @a original file, @a modified file, and @a latest\r
+ * file.\r
+ *\r
+ * Compare lines according to the relevant fields of @a options.\r
+ */\r
+svn_error_t *\r
+svn_diff_file_diff3_2(svn_diff_t **diff,\r
+                      const char *original,\r
+                      const char *modified,\r
+                      const char *latest,\r
+                      const svn_diff_file_options_t *options,\r
+                      apr_pool_t *pool);\r
+\r
+/** Similar to svn_diff_file_diff3_2(), but with @a options set to a struct\r
+ * with default options.\r
+ *\r
+ * @deprecated Provided for backwards compatibility with the 1.3 API.\r
+ */\r
+SVN_DEPRECATED\r
+svn_error_t *\r
+svn_diff_file_diff3(svn_diff_t **diff,\r
+                    const char *original,\r
+                    const char *modified,\r
+                    const char *latest,\r
+                    apr_pool_t *pool);\r
+\r
+/** A convenience function to produce a diff between four files.\r
+ *\r
+ * @since New in 1.4.\r
+ *\r
+ * Return a diff object in @a *diff (allocated from @a pool) that represents\r
+ * the difference between an @a original file, @a modified file, @a latest\r
+ * and @a ancestor file. (The file arguments must be full paths to the files.)\r
+ *\r
+ * Compare lines according to the relevant fields of @a options.\r
+ */\r
+svn_error_t *\r
+svn_diff_file_diff4_2(svn_diff_t **diff,\r
+                      const char *original,\r
+                      const char *modified,\r
+                      const char *latest,\r
+                      const char *ancestor,\r
+                      const svn_diff_file_options_t *options,\r
+                      apr_pool_t *pool);\r
+\r
+/** Simliar to svn_file_diff4_2(), but with @a options set to a struct with\r
+ * default options.\r
+ *\r
+ * @deprecated Provided for backwards compatibility with the 1.3 API.\r
+ */\r
+SVN_DEPRECATED\r
+svn_error_t *\r
+svn_diff_file_diff4(svn_diff_t **diff,\r
+                    const char *original,\r
+                    const char *modified,\r
+                    const char *latest,\r
+                    const char *ancestor,\r
+                    apr_pool_t *pool);\r
+\r
+/** A convenience function to produce unified diff output from the\r
+ * diff generated by svn_diff_file_diff().\r
+ *\r
+ * @since New in 1.5.\r
+ *\r
+ * Output a @a diff between @a original_path and @a modified_path in unified\r
+ * context diff format to @a output_stream.  Optionally supply\r
+ * @a original_header and/or @a modified_header to be displayed in the header\r
+ * of the output.  If @a original_header or @a modified_header is @c NULL, a\r
+ * default header will be displayed, consisting of path and last modified time.\r
+ * Output all headers and markers in @a header_encoding.  If @a relative_to_dir\r
+ * is not @c NULL, the @a original_path and @a modified_path will have the\r
+ * @a relative_to_dir stripped from the front of the respective paths.  If\r
+ * @a relative_to_dir is @c NULL, paths will be not be modified.  If\r
+ * @a relative_to_dir is not @c NULL but @a relative_to_dir is not a parent\r
+ * path of the target, an error is returned. Finally, if @a relative_to_dir\r
+ * is a URL, an error will be returned.\r
+ */\r
+svn_error_t *\r
+svn_diff_file_output_unified3(svn_stream_t *output_stream,\r
+                              svn_diff_t *diff,\r
+                              const char *original_path,\r
+                              const char *modified_path,\r
+                              const char *original_header,\r
+                              const char *modified_header,\r
+                              const char *header_encoding,\r
+                              const char *relative_to_dir,\r
+                              svn_boolean_t show_c_function,\r
+                              apr_pool_t *pool);\r
+\r
+/** Similar to svn_diff_file_output_unified3(), but with @a relative_to_dir\r
+ * set to NULL and @a show_c_function to false.\r
+ *\r
+ * @deprecated Provided for backwards compatibility with the 1.3 API.\r
+ */\r
+SVN_DEPRECATED\r
+svn_error_t *\r
+svn_diff_file_output_unified2(svn_stream_t *output_stream,\r
+                              svn_diff_t *diff,\r
+                              const char *original_path,\r
+                              const char *modified_path,\r
+                              const char *original_header,\r
+                              const char *modified_header,\r
+                              const char *header_encoding,\r
+                              apr_pool_t *pool);\r
+\r
+/** Similar to svn_diff_file_output_unified2(), but with @a header_encoding\r
+ * set to @c APR_LOCALE_CHARSET.\r
+ *\r
+ * @deprecated Provided for backward compatibility with the 1.2 API.\r
+ */\r
+SVN_DEPRECATED\r
+svn_error_t *\r
+svn_diff_file_output_unified(svn_stream_t *output_stream,\r
+                             svn_diff_t *diff,\r
+                             const char *original_path,\r
+                             const char *modified_path,\r
+                             const char *original_header,\r
+                             const char *modified_header,\r
+                             apr_pool_t *pool);\r
+\r
+\r
+/** A convenience function to produce diff3 output from the\r
+ * diff generated by svn_diff_file_diff3().\r
+ *\r
+ * Output a @a diff between @a original_path, @a modified_path and\r
+ * @a latest_path in merged format to @a output_stream.  Optionally supply\r
+ * @a conflict_modified, @a conflict_original, @a conflict_separator and/or\r
+ * @a conflict_latest to be displayed as conflict markers in the output.\r
+ * If @a conflict_original, @a conflict_modified, @a conflict_latest and/or\r
+ * @a conflict_separator is @c NULL, a default marker will be displayed.\r
+ * @a conflict_style dictates how conflicts are displayed.\r
+ *\r
+ * @since New in 1.6.\r
+ */\r
+svn_error_t *\r
+svn_diff_file_output_merge2(svn_stream_t *output_stream,\r
+                            svn_diff_t *diff,\r
+                            const char *original_path,\r
+                            const char *modified_path,\r
+                            const char *latest_path,\r
+                            const char *conflict_original,\r
+                            const char *conflict_modified,\r
+                            const char *conflict_latest,\r
+                            const char *conflict_separator,\r
+                            svn_diff_conflict_display_style_t conflict_style,\r
+                            apr_pool_t *pool);\r
+\r
+\r
+/** Similar to svn_diff_file_output_merge2, but with @a\r
+ * display_original_in_conflict and @a display_resolved_conflicts\r
+ * booleans instead of the @a conflict_style enum.\r
+ *\r
+ * If both booleans are false, acts like\r
+ * svn_diff_conflict_display_modified_latest; if @a\r
+ * display_original_in_conflict is true, acts like\r
+ * svn_diff_conflict_display_modified_original_latest; if @a\r
+ * display_resolved_conflicts is true, acts like\r
+ * svn_diff_conflict_display_resolved_modified_latest.  The booleans\r
+ * may not both be true.\r
+ *\r
+ * @deprecated Provided for backward compatibility with the 1.5 API.\r
+ */\r
+SVN_DEPRECATED\r
+svn_error_t *\r
+svn_diff_file_output_merge(svn_stream_t *output_stream,\r
+                           svn_diff_t *diff,\r
+                           const char *original_path,\r
+                           const char *modified_path,\r
+                           const char *latest_path,\r
+                           const char *conflict_original,\r
+                           const char *conflict_modified,\r
+                           const char *conflict_latest,\r
+                           const char *conflict_separator,\r
+                           svn_boolean_t display_original_in_conflict,\r
+                           svn_boolean_t display_resolved_conflicts,\r
+                           apr_pool_t *pool);\r
+\r
+\r
+\f\r
+/* Diffs on in-memory structures */\r
+\r
+/** Generate @a diff output from the @a original and @a modified\r
+ * in-memory strings.  @a diff will be allocated from @a pool.\r
+ *\r
+ * @since New in 1.5.\r
+ */\r
+#if 0\r
+svn_error_t *\r
+svn_diff_mem_string_diff(svn_diff_t **diff,\r
+                         const svn_string_t *original,\r
+                         const svn_string_t *modified,\r
+                         const svn_diff_file_options_t *options,\r
+                         apr_pool_t *pool);\r
+\r
+#endif\r
+/** Generate @a diff output from the @a orginal, @a modified and @a latest\r
+ * in-memory strings.  @a diff will be allocated in @a pool.\r
+ *\r
+ * @since New in 1.5.\r
+ */\r
+#if 0\r
+svn_error_t *\r
+svn_diff_mem_string_diff3(svn_diff_t **diff,\r
+                          const svn_string_t *original,\r
+                          const svn_string_t *modified,\r
+                          const svn_string_t *latest,\r
+                          const svn_diff_file_options_t *options,\r
+                          apr_pool_t *pool);\r
+#endif\r
+\r
+/** Generate @a diff output from the @a original, @a modified and @a latest\r
+ * in-memory strings, using @a ancestor.  @a diff will be allocated in @a pool.\r
+ *\r
+ * @since New in 1.5.\r
+ */\r
+#if 0\r
+svn_error_t *\r
+svn_diff_mem_string_diff4(svn_diff_t **diff,\r
+                          const svn_string_t *original,\r
+                          const svn_string_t *modified,\r
+                          const svn_string_t *latest,\r
+                          const svn_string_t *ancestor,\r
+                          const svn_diff_file_options_t *options,\r
+                          apr_pool_t *pool);\r
+#endif\r
+\r
+/** Outputs the @a diff object generated by svn_diff_mem_string_diff()\r
+ * in unified diff format on @a output_stream, using @a original\r
+ * and @a modified for the text in the output.\r
+ * Outputs the header and markers in @a header_encoding.\r
+ *\r
+ * @a original_header and @a modified header are\r
+ * used to fill the field after the "---" and "+++" header markers.\r
+ *\r
+ * @since New in 1.5.\r
+ */\r
+#if 0\r
+svn_error_t *\r
+svn_diff_mem_string_output_unified(svn_stream_t *output_stream,\r
+                                   svn_diff_t *diff,\r
+                                   const char *original_header,\r
+                                   const char *modified_header,\r
+                                   const char *header_encoding,\r
+                                   const svn_string_t *original,\r
+                                   const svn_string_t *modified,\r
+                                   apr_pool_t *pool);\r
+#endif\r
+/** Output the @a diff generated by svn_diff_mem_string_diff3() in diff3\r
+ * format on @a output_stream, using @a original, @a modified and @a latest\r
+ * for content changes.\r
+ *\r
+ * Use the conflict markers @a conflict_original, @a conflict_modified,\r
+ * @a conflict_latest and @a conflict_separator or the default one for\r
+ * each of these if @c NULL is passed.\r
+ *\r
+ * @a conflict_style dictates how conflicts are displayed.\r
+ *\r
+ * @since New in 1.6.\r
+ */\r
+#if 0\r
+svn_error_t *\r
+svn_diff_mem_string_output_merge2(svn_stream_t *output_stream,\r
+                                  svn_diff_t *diff,\r
+                                  const svn_string_t *original,\r
+                                  const svn_string_t *modified,\r
+                                  const svn_string_t *latest,\r
+                                  const char *conflict_original,\r
+                                  const char *conflict_modified,\r
+                                  const char *conflict_latest,\r
+                                  const char *conflict_separator,\r
+                                  svn_diff_conflict_display_style_t style,\r
+                                  apr_pool_t *pool);\r
+#endif\r
+/** Similar to svn_diff_mem_string_output_merge2, but with @a\r
+ * display_original_in_conflict and @a display_resolved_conflicts\r
+ * booleans instead of the @a conflict_style enum.\r
+ *\r
+ * If both booleans are false, acts like\r
+ * svn_diff_conflict_display_modified_latest; if @a\r
+ * display_original_in_conflict is true, acts like\r
+ * svn_diff_conflict_display_modified_original_latest; if @a\r
+ * display_resolved_conflicts is true, acts like\r
+ * svn_diff_conflict_display_resolved_modified_latest.  The booleans\r
+ * may not both be true.\r
+ *\r
+ * @deprecated Provided for backward compatibility with the 1.5 API.\r
+ */\r
+#if 0\r
+SVN_DEPRECATED\r
+svn_error_t *\r
+svn_diff_mem_string_output_merge(svn_stream_t *output_stream,\r
+                                 svn_diff_t *diff,\r
+                                 const svn_string_t *original,\r
+                                 const svn_string_t *modified,\r
+                                 const svn_string_t *latest,\r
+                                 const char *conflict_original,\r
+                                 const char *conflict_modified,\r
+                                 const char *conflict_latest,\r
+                                 const char *conflict_separator,\r
+                                 svn_boolean_t display_original_in_conflict,\r
+                                 svn_boolean_t display_resolved_conflicts,\r
+                                 apr_pool_t *pool);\r
+\r
+#endif\r
+#ifdef __cplusplus\r
+}\r
+#endif /* __cplusplus */\r
+\r
+#endif /* SVN_DIFF_H */\r
diff --git a/src/TortoiseMerge/svninclude/apr_strings.h b/src/TortoiseMerge/svninclude/apr_strings.h
new file mode 100644 (file)
index 0000000..23d0472
--- /dev/null
@@ -0,0 +1,361 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more\r
+ * contributor license agreements.  See the NOTICE file distributed with\r
+ * this work for additional information regarding copyright ownership.\r
+ * The ASF licenses this file to You under the Apache License, Version 2.0\r
+ * (the "License"); you may not use this file except in compliance with\r
+ * the License.  You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/* Portions of this file are covered by */\r
+/* -*- mode: c; c-file-style: "k&r" -*-\r
+\r
+  strnatcmp.c -- Perform 'natural order' comparisons of strings in C.\r
+  Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>\r
+\r
+  This software is provided 'as-is', without any express or implied\r
+  warranty.  In no event will the authors be held liable for any damages\r
+  arising from the use of this software.\r
+\r
+  Permission is granted to anyone to use this software for any purpose,\r
+  including commercial applications, and to alter it and redistribute it\r
+  freely, subject to the following restrictions:\r
+\r
+  1. The origin of this software must not be misrepresented; you must not\r
+     claim that you wrote the original software. If you use this software\r
+     in a product, an acknowledgment in the product documentation would be\r
+     appreciated but is not required.\r
+  2. Altered source versions must be plainly marked as such, and must not be\r
+     misrepresented as being the original software.\r
+  3. This notice may not be removed or altered from any source distribution.\r
+*/\r
+\r
+#ifndef APR_STRINGS_H\r
+#define APR_STRINGS_H\r
+\r
+/**\r
+ * @file apr_strings.h\r
+ * @brief APR Strings library\r
+ */\r
+\r
+#include "apr.h"\r
+#include "apr_errno.h"\r
+#include "apr_pools.h"\r
+#define APR_WANT_IOVEC\r
+#include "apr_want.h"\r
+\r
+#if APR_HAVE_STDARG_H\r
+#include <stdarg.h>\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif /* __cplusplus */\r
+\r
+/**\r
+ * @defgroup apr_strings String routines\r
+ * @ingroup APR \r
+ * @{\r
+ */\r
+\r
+/**\r
+ * Do a natural order comparison of two strings.\r
+ * @param a The first string to compare\r
+ * @param b The second string to compare\r
+ * @return Either <0, 0, or >0.  If the first string is less than the second\r
+ *          this returns <0, if they are equivalent it returns 0, and if the\r
+ *          first string is greater than second string it retuns >0.\r
+ */\r
+APR_DECLARE(int) apr_strnatcmp(char const *a, char const *b);\r
+\r
+/**\r
+ * Do a natural order comparison of two strings ignoring the case of the \r
+ * strings.\r
+ * @param a The first string to compare\r
+ * @param b The second string to compare\r
+ * @return Either <0, 0, or >0.  If the first string is less than the second\r
+ *         this returns <0, if they are equivalent it returns 0, and if the\r
+ *         first string is greater than second string it retuns >0.\r
+ */\r
+APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b);\r
+\r
+/**\r
+ * duplicate a string into memory allocated out of a pool\r
+ * @param p The pool to allocate out of\r
+ * @param s The string to duplicate\r
+ * @return The new string\r
+ */\r
+APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s);\r
+\r
+/**\r
+ * Create a null-terminated string by making a copy of a sequence\r
+ * of characters and appending a null byte\r
+ * @param p The pool to allocate out of\r
+ * @param s The block of characters to duplicate\r
+ * @param n The number of characters to duplicate\r
+ * @return The new string\r
+ * @remark This is a faster alternative to apr_pstrndup, for use\r
+ *         when you know that the string being duplicated really\r
+ *         has 'n' or more characters.  If the string might contain\r
+ *         fewer characters, use apr_pstrndup.\r
+ */\r
+APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n);\r
+\r
+/**\r
+ * Duplicate at most n characters of a string into memory allocated \r
+ * out of a pool; the new string will be NUL-terminated\r
+ * @param p The pool to allocate out of\r
+ * @param s The string to duplicate\r
+ * @param n The maximum number of characters to duplicate\r
+ * @return The new string\r
+ * @remark The amount of memory allocated from the pool is the length\r
+ *         of the returned string including the NUL terminator\r
+ */\r
+APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n);\r
+\r
+/**\r
+ * Duplicate a block of memory.\r
+ *\r
+ * @param p The pool to allocate from\r
+ * @param m The memory to duplicate\r
+ * @param n The number of bytes to duplicate\r
+ * @return The new block of memory\r
+ */\r
+APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n);\r
+\r
+/**\r
+ * Concatenate multiple strings, allocating memory out a pool\r
+ * @param p The pool to allocate out of\r
+ * @param ... The strings to concatenate.  The final string must be NULL\r
+ * @return The new string\r
+ */\r
+APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *p, ...);\r
+\r
+/**\r
+ * Concatenate multiple strings specified in a writev-style vector\r
+ * @param p The pool from which to allocate\r
+ * @param vec The strings to concatenate\r
+ * @param nvec The number of strings to concatenate\r
+ * @param nbytes (output) strlen of new string (pass in NULL to omit)\r
+ * @return The new string\r
+ */\r
+APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *p, const struct iovec *vec,\r
+                                 apr_size_t nvec, apr_size_t *nbytes);\r
+\r
+/**\r
+ * printf-style style printing routine.  The data is output to a string \r
+ * allocated from a pool\r
+ * @param p The pool to allocate out of\r
+ * @param fmt The format of the string\r
+ * @param ap The arguments to use while printing the data\r
+ * @return The new string\r
+ */\r
+APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *p, const char *fmt, va_list ap);\r
+\r
+/**\r
+ * printf-style style printing routine.  The data is output to a string \r
+ * allocated from a pool\r
+ * @param p The pool to allocate out of\r
+ * @param fmt The format of the string\r
+ * @param ... The arguments to use while printing the data\r
+ * @return The new string\r
+ */\r
+APR_DECLARE_NONSTD(char *) apr_psprintf(apr_pool_t *p, const char *fmt, ...)\r
+        __attribute__((format(printf,2,3)));\r
+\r
+/**\r
+ * Copy up to dst_size characters from src to dst; does not copy\r
+ * past a NUL terminator in src, but always terminates dst with a NUL\r
+ * regardless.\r
+ * @param dst The destination string\r
+ * @param src The source string\r
+ * @param dst_size The space available in dst; dst always receives\r
+ *                 NUL termination, so if src is longer than\r
+ *                 dst_size, the actual number of characters copied is\r
+ *                 dst_size - 1.\r
+ * @return Pointer to the NUL terminator of the destination string, dst\r
+ * @remark\r
+ * <PRE>\r
+ * Note the differences between this function and strncpy():\r
+ *  1) strncpy() doesn't always NUL terminate; apr_cpystrn() does.\r
+ *  2) strncpy() pads the destination string with NULs, which is often \r
+ *     unnecessary; apr_cpystrn() does not.\r
+ *  3) strncpy() returns a pointer to the beginning of the dst string;\r
+ *     apr_cpystrn() returns a pointer to the NUL terminator of dst, \r
+ *     to allow a check for truncation.\r
+ * </PRE>\r
+ */\r
+APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src,\r
+                                apr_size_t dst_size);\r
+\r
+/**\r
+ * Strip spaces from a string\r
+ * @param dest The destination string.  It is okay to modify the string\r
+ *             in place.  Namely dest == src\r
+ * @param src The string to rid the spaces from.\r
+ * @return The destination string, dest.\r
+ */\r
+APR_DECLARE(char *) apr_collapse_spaces(char *dest, const char *src);\r
+\r
+/**\r
+ * Convert the arguments to a program from one string to an array of \r
+ * strings terminated by a NULL pointer\r
+ * @param arg_str The arguments to convert\r
+ * @param argv_out Output location.  This is a pointer to an array of strings.\r
+ * @param token_context Pool to use.\r
+ */\r
+APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str,\r
+                                               char ***argv_out,\r
+                                               apr_pool_t *token_context);\r
+\r
+/**\r
+ * Split a string into separate null-terminated tokens.  The tokens are \r
+ * delimited in the string by one or more characters from the sep\r
+ * argument.\r
+ * @param str The string to separate; this should be specified on the\r
+ *            first call to apr_strtok() for a given string, and NULL\r
+ *            on subsequent calls.\r
+ * @param sep The set of delimiters\r
+ * @param last Internal state saved by apr_strtok() between calls.\r
+ * @return The next token from the string\r
+ */\r
+APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last);\r
+\r
+/**\r
+ * @defgroup APR_Strings_Snprintf snprintf implementations\r
+ * @warning\r
+ * These are snprintf implementations based on apr_vformatter().\r
+ *\r
+ * Note that various standards and implementations disagree on the return\r
+ * value of snprintf, and side-effects due to %n in the formatting string.\r
+ * apr_snprintf (and apr_vsnprintf) behaves as follows:\r
+ *\r
+ * Process the format string until the entire string is exhausted, or\r
+ * the buffer fills.  If the buffer fills then stop processing immediately\r
+ * (so no further %n arguments are processed), and return the buffer\r
+ * length.  In all cases the buffer is NUL terminated. It will return the\r
+ * number of characters inserted into the buffer, not including the\r
+ * terminating NUL. As a special case, if len is 0, apr_snprintf will\r
+ * return the number of characters that would have been inserted if\r
+ * the buffer had been infinite (in this case, *buffer can be NULL)\r
+ *\r
+ * In no event does apr_snprintf return a negative number.\r
+ * @{\r
+ */\r
+\r
+/**\r
+ * snprintf routine based on apr_vformatter.  This means it understands the\r
+ * same extensions.\r
+ * @param buf The buffer to write to\r
+ * @param len The size of the buffer\r
+ * @param format The format string\r
+ * @param ... The arguments to use to fill out the format string.\r
+ */\r
+APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len,\r
+                                     const char *format, ...)\r
+        __attribute__((format(printf,3,4)));\r
+\r
+/**\r
+ * vsnprintf routine based on apr_vformatter.  This means it understands the\r
+ * same extensions.\r
+ * @param buf The buffer to write to\r
+ * @param len The size of the buffer\r
+ * @param format The format string\r
+ * @param ap The arguments to use to fill out the format string.\r
+ */\r
+APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format,\r
+                               va_list ap);\r
+/** @} */\r
+\r
+/**\r
+ * create a string representation of an int, allocated from a pool\r
+ * @param p The pool from which to allocate\r
+ * @param n The number to format\r
+ * @return The string representation of the number\r
+ */\r
+APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n);\r
+\r
+/**\r
+ * create a string representation of a long, allocated from a pool\r
+ * @param p The pool from which to allocate\r
+ * @param n The number to format\r
+ * @return The string representation of the number\r
+ */\r
+APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n);\r
+\r
+/**\r
+ * create a string representation of an apr_off_t, allocated from a pool\r
+ * @param p The pool from which to allocate\r
+ * @param n The number to format\r
+ * @return The string representation of the number\r
+ */\r
+APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n);\r
+\r
+/**\r
+ * Convert a numeric string into an apr_off_t numeric value.\r
+ * @param offset The value of the parsed string.\r
+ * @param buf The string to parse. It may contain optional whitespace,\r
+ *   followed by an optional '+' (positive, default) or '-' (negative)\r
+ *   character, followed by an optional '0x' prefix if base is 0 or 16,\r
+ *   followed by numeric digits appropriate for base.\r
+ * @param end A pointer to the end of the valid character in buf. If\r
+ *   not NULL, it is set to the first invalid character in buf.\r
+ * @param base A numeric base in the range between 2 and 36 inclusive,\r
+ *   or 0.  If base is zero, buf will be treated as base ten unless its\r
+ *   digits are prefixed with '0x', in which case it will be treated as\r
+ *   base 16.\r
+ * @bug *end breaks type safety; where *buf is const, *end needs to be\r
+ * declared as const in APR 2.0\r
+ */\r
+APR_DECLARE(apr_status_t) apr_strtoff(apr_off_t *offset, const char *buf, \r
+                                      char **end, int base);\r
+\r
+/**\r
+ * parse a numeric string into a 64-bit numeric value\r
+ * @param buf The string to parse. It may contain optional whitespace,\r
+ *   followed by an optional '+' (positive, default) or '-' (negative)\r
+ *   character, followed by an optional '0x' prefix if base is 0 or 16,\r
+ *   followed by numeric digits appropriate for base.\r
+ * @param end A pointer to the end of the valid character in buf. If\r
+ *   not NULL, it is set to the first invalid character in buf.\r
+ * @param base A numeric base in the range between 2 and 36 inclusive,\r
+ *   or 0.  If base is zero, buf will be treated as base ten unless its\r
+ *   digits are prefixed with '0x', in which case it will be treated as\r
+ *   base 16.\r
+ * @return The numeric value of the string.  On overflow, errno is set\r
+ * to ERANGE.\r
+ */\r
+APR_DECLARE(apr_int64_t) apr_strtoi64(const char *buf, char **end, int base);\r
+\r
+/**\r
+ * parse a base-10 numeric string into a 64-bit numeric value.\r
+ * Equivalent to apr_strtoi64(buf, (char**)NULL, 10).\r
+ * @param buf The string to parse\r
+ * @return The numeric value of the string\r
+ */\r
+APR_DECLARE(apr_int64_t) apr_atoi64(const char *buf);\r
+\r
+/**\r
+ * Format a binary size (magnitiudes are 2^10 rather than 10^3) from an apr_off_t,\r
+ * as bytes, K, M, T, etc, to a four character compacted human readable string.\r
+ * @param size The size to format\r
+ * @param buf The 5 byte text buffer (counting the trailing null)\r
+ * @return The buf passed to apr_strfsize()\r
+ * @remark All negative sizes report '  - ', apr_strfsize only formats positive values.\r
+ */\r
+APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf);\r
+\r
+/** @} */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif  /* !APR_STRINGS_H */\r
diff --git a/src/TortoiseMerge/svninclude/svn_string.h b/src/TortoiseMerge/svninclude/svn_string.h
new file mode 100644 (file)
index 0000000..7450ae9
--- /dev/null
@@ -0,0 +1,395 @@
+/**\r
+ * @copyright\r
+ * ====================================================================\r
+ * Copyright (c) 2000-2006 CollabNet.  All rights reserved.\r
+ *\r
+ * This software is licensed as described in the file COPYING, which\r
+ * you should have received as part of this distribution.  The terms\r
+ * are also available at http://subversion.tigris.org/license-1.html.\r
+ * If newer versions of this license are posted there, you may use a\r
+ * newer version instead, at your option.\r
+ *\r
+ * This software consists of voluntary contributions made by many\r
+ * individuals.  For exact contribution history, see the revision\r
+ * history and logs, available at http://subversion.tigris.org/.\r
+ * ====================================================================\r
+ * @endcopyright\r
+ *\r
+ * @file svn_string.h\r
+ * @brief Counted-length strings for Subversion, plus some C string goodies.\r
+ *\r
+ * There are two string datatypes: @c svn_string_t and @c svn_stringbuf_t.\r
+ * The former is a simple pointer/length pair useful for passing around\r
+ * strings (or arbitrary bytes) with a counted length. @c svn_stringbuf_t is\r
+ * buffered to enable efficient appending of strings without an allocation\r
+ * and copy for each append operation.\r
+ *\r
+ * @c svn_string_t contains a <tt>const char *</tt> for its data, so it is\r
+ * most appropriate for constant data and for functions which expect constant,\r
+ * counted data. Functions should generally use <tt>const @c svn_string_t\r
+ * *</tt> as their parameter to indicate they are expecting a constant,\r
+ * counted string.\r
+ *\r
+ * @c svn_stringbuf_t uses a plain <tt>char *</tt> for its data, so it is\r
+ * most appropriate for modifiable data.\r
+ *\r
+ * <h3>Invariants</h3>\r
+ *\r
+ *   1. Null termination:\r
+ *\r
+ *      Both structures maintain a significant invariant:\r
+ *\r
+ *         <tt>s->data[s->len] == '\\0'</tt>\r
+ *\r
+ *      The functions defined within this header file will maintain\r
+ *      the invariant (which does imply that memory is\r
+ *      allocated/defined as @c len+1 bytes).  If code outside of the\r
+ *      @c svn_string.h functions manually builds these structures,\r
+ *      then they must enforce this invariant.\r
+ *\r
+ *      Note that an @c svn_string(buf)_t may contain binary data,\r
+ *      which means that strlen(s->data) does not have to equal @c\r
+ *      s->len. The NULL terminator is provided to make it easier to\r
+ *      pass @c s->data to C string interfaces.\r
+ *\r
+ *\r
+ *   2. Non-NULL input:\r
+ *\r
+ *      All the functions assume their input data is non-NULL,\r
+ *      unless otherwise documented, and may seg fault if passed\r
+ *      NULL.  The input data may *contain* null bytes, of course, just\r
+ *      the data pointer itself must not be NULL.\r
+ *\r
+ * <h3>Memory allocation</h3>\r
+ *\r
+ *   All the functions make a deep copy of all input data, and never store\r
+ *   a pointer to the original input data.\r
+ */\r
+\r
+\r
+#ifndef SVN_STRING_H\r
+#define SVN_STRING_H\r
+\r
+#include <apr.h>\r
+#include <apr_tables.h>\r
+#include <apr_pools.h>       /* APR memory pools for everyone. */\r
+#include <apr_strings.h>\r
+\r
+#include "svn_types.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif /* __cplusplus */\r
+\r
+/**\r
+ * @defgroup svn_string String handling\r
+ * @{\r
+ */\r
+\r
+\f\r
+\r
+/** A simple counted string. */\r
+typedef struct svn_string_t\r
+{\r
+  const char *data; /**< pointer to the bytestring */\r
+  apr_size_t len;   /**< length of bytestring */\r
+} svn_string_t;\r
+\r
+/** A buffered string, capable of appending without an allocation and copy\r
+ * for each append. */\r
+typedef struct svn_stringbuf_t\r
+{\r
+  /** a pool from which this string was originally allocated, and is not\r
+   * necessarily specific to this string.  This is used only for allocating\r
+   * more memory from when the string needs to grow.\r
+   */\r
+  apr_pool_t *pool;\r
+\r
+  /** pointer to the bytestring */\r
+  char *data;\r
+\r
+  /** length of bytestring */\r
+  apr_size_t len;\r
+\r
+  /** total size of buffer allocated */\r
+  apr_size_t blocksize;\r
+} svn_stringbuf_t;\r
+\r
+\f\r
+/** svn_string_t functions.\r
+ *\r
+ * @defgroup svn_string_svn_string_t svn_string_t functions\r
+ * @{\r
+ */\r
+\r
+/** Create a new bytestring containing a C string (NULL-terminated). */\r
+svn_string_t *\r
+svn_string_create(const char *cstring, apr_pool_t *pool);\r
+\r
+/** Create a new bytestring containing a generic string of bytes\r
+ * (NOT NULL-terminated) */\r
+svn_string_t *\r
+svn_string_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool);\r
+\r
+/** Create a new string with the contents of the given stringbuf */\r
+svn_string_t *\r
+svn_string_create_from_buf(const svn_stringbuf_t *strbuf, apr_pool_t *pool);\r
+\r
+/** Create a new bytestring by formatting @a cstring (NULL-terminated)\r
+ * from varargs, which are as appropriate for apr_psprintf().\r
+ */\r
+svn_string_t *\r
+svn_string_createf(apr_pool_t *pool, const char *fmt, ...)\r
+  __attribute__((format(printf, 2, 3)));\r
+\r
+/** Create a new bytestring by formatting @a cstring (NULL-terminated)\r
+ * from a @c va_list (see svn_stringbuf_createf()).\r
+ */\r
+svn_string_t *\r
+svn_string_createv(apr_pool_t *pool, const char *fmt, va_list ap)\r
+  __attribute__((format(printf, 2, 0)));\r
+\r
+/** Return TRUE if a bytestring is empty (has length zero). */\r
+svn_boolean_t\r
+svn_string_isempty(const svn_string_t *str);\r
+\r
+/** Return a duplicate of @a original_string. */\r
+svn_string_t *\r
+svn_string_dup(const svn_string_t *original_string, apr_pool_t *pool);\r
+\r
+/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */\r
+svn_boolean_t\r
+svn_string_compare(const svn_string_t *str1, const svn_string_t *str2);\r
+\r
+/** Return offset of first non-whitespace character in @a str, or return\r
+ * @a str->len if none.\r
+ */\r
+apr_size_t\r
+svn_string_first_non_whitespace(const svn_string_t *str);\r
+\r
+/** Return position of last occurrence of @a ch in @a str, or return\r
+ * @a str->len if no occurrence.\r
+ */\r
+apr_size_t\r
+svn_string_find_char_backward(const svn_string_t *str, char ch);\r
+\r
+/** @} */\r
+\r
+\f\r
+/** svn_stringbuf_t functions.\r
+ *\r
+ * @defgroup svn_string_svn_stringbuf_t svn_stringbuf_t functions\r
+ * @{\r
+ */\r
+\r
+/** Create a new bytestring containing a C string (NULL-terminated). */\r
+svn_stringbuf_t *\r
+svn_stringbuf_create(const char *cstring, apr_pool_t *pool);\r
+/** Create a new bytestring containing a generic string of bytes\r
+ * (NON-NULL-terminated)\r
+ */\r
+svn_stringbuf_t *\r
+svn_stringbuf_ncreate(const char *bytes, apr_size_t size, apr_pool_t *pool);\r
+/** Create a new empty bytestring with at least @a minimum_size bytes of\r
+ * space available in the memory block.\r
+ *\r
+ * (@a minimum_size should include space for the terminating NULL character.)\r
+ *\r
+ * @since New in 1.6.\r
+ */\r
+svn_stringbuf_t *\r
+svn_stringbuf_create_ensure(apr_size_t minimum_size, apr_pool_t *pool);\r
+\r
+/** Create a new stringbuf with the contents of the given string */\r
+svn_stringbuf_t *\r
+svn_stringbuf_create_from_string(const svn_string_t *str, apr_pool_t *pool);\r
+\r
+/** Create a new bytestring by formatting @a cstring (NULL-terminated)\r
+ * from varargs, which are as appropriate for apr_psprintf().\r
+ */\r
+svn_stringbuf_t *\r
+svn_stringbuf_createf(apr_pool_t *pool, const char *fmt, ...)\r
+  __attribute__((format(printf, 2, 3)));\r
+\r
+/** Create a new bytestring by formatting @a cstring (NULL-terminated)\r
+ * from a @c va_list (see svn_stringbuf_createf()).\r
+ */\r
+svn_stringbuf_t *\r
+svn_stringbuf_createv(apr_pool_t *pool, const char *fmt, va_list ap)\r
+  __attribute__((format(printf, 2, 0)));\r
+\r
+/** Make sure that the string @a str has at least @a minimum_size bytes of\r
+ * space available in the memory block.\r
+ *\r
+ * (@a minimum_size should include space for the terminating NULL character.)\r
+ */\r
+void\r
+svn_stringbuf_ensure(svn_stringbuf_t *str, apr_size_t minimum_size);\r
+\r
+/** Set a bytestring @a str to @a value */\r
+void\r
+svn_stringbuf_set(svn_stringbuf_t *str, const char *value);\r
+\r
+/** Set a bytestring @a str to empty (0 length). */\r
+void\r
+svn_stringbuf_setempty(svn_stringbuf_t *str);\r
+\r
+/** Return @c TRUE if a bytestring is empty (has length zero). */\r
+svn_boolean_t\r
+svn_stringbuf_isempty(const svn_stringbuf_t *str);\r
+\r
+/** Chop @a nbytes bytes off end of @a str, but not more than @a str->len. */\r
+void\r
+svn_stringbuf_chop(svn_stringbuf_t *str, apr_size_t nbytes);\r
+\r
+/** Fill bytestring @a str with character @a c. */\r
+void\r
+svn_stringbuf_fillchar(svn_stringbuf_t *str, unsigned char c);\r
+\r
+/** Append an array of bytes onto @a targetstr.\r
+ *\r
+ * reallocs if necessary. @a targetstr is affected, nothing else is.\r
+ */\r
+void\r
+svn_stringbuf_appendbytes(svn_stringbuf_t *targetstr,\r
+                          const char *bytes,\r
+                          apr_size_t count);\r
+\r
+/** Append an @c svn_stringbuf_t onto @a targetstr.\r
+ *\r
+ * reallocs if necessary. @a targetstr is affected, nothing else is.\r
+ */\r
+void\r
+svn_stringbuf_appendstr(svn_stringbuf_t *targetstr,\r
+                        const svn_stringbuf_t *appendstr);\r
+\r
+/** Append a C string onto @a targetstr.\r
+ *\r
+ * reallocs if necessary. @a targetstr is affected, nothing else is.\r
+ */\r
+void\r
+svn_stringbuf_appendcstr(svn_stringbuf_t *targetstr,\r
+                         const char *cstr);\r
+\r
+/** Return a duplicate of @a original_string. */\r
+svn_stringbuf_t *\r
+svn_stringbuf_dup(const svn_stringbuf_t *original_string, apr_pool_t *pool);\r
+\r
+/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */\r
+svn_boolean_t\r
+svn_stringbuf_compare(const svn_stringbuf_t *str1,\r
+                      const svn_stringbuf_t *str2);\r
+\r
+/** Return offset of first non-whitespace character in @a str, or return\r
+ * @a str->len if none.\r
+ */\r
+apr_size_t\r
+svn_stringbuf_first_non_whitespace(const svn_stringbuf_t *str);\r
+\r
+/** Strip whitespace from both sides of @a str (modified in place). */\r
+void\r
+svn_stringbuf_strip_whitespace(svn_stringbuf_t *str);\r
+\r
+/** Return position of last occurrence of @a ch in @a str, or return\r
+ * @a str->len if no occurrence.\r
+ */\r
+apr_size_t\r
+svn_stringbuf_find_char_backward(const svn_stringbuf_t *str, char ch);\r
+\r
+/** Return @c TRUE iff @a str1 and @a str2 have identical length and data. */\r
+svn_boolean_t\r
+svn_string_compare_stringbuf(const svn_string_t *str1,\r
+                             const svn_stringbuf_t *str2);\r
+\r
+/** @} */\r
+\r
+\f\r
+/** C strings.\r
+ *\r
+ * @defgroup svn_string_cstrings c string functions\r
+ * @{\r
+ */\r
+\r
+/** Divide @a input into substrings along @a sep_chars boundaries, return an\r
+ * array of copies of those substrings, allocating both the array and\r
+ * the copies in @a pool.\r
+ *\r
+ * None of the elements added to the array contain any of the\r
+ * characters in @a sep_chars, and none of the new elements are empty\r
+ * (thus, it is possible that the returned array will have length\r
+ * zero).\r
+ *\r
+ * If @a chop_whitespace is TRUE, then remove leading and trailing\r
+ * whitespace from the returned strings.\r
+ */\r
+\r
+apr_array_header_t *\r
+svn_cstring_split(const char *input,\r
+                  const char *sep_chars,\r
+                  svn_boolean_t chop_whitespace,\r
+                  apr_pool_t *pool);\r
+\r
+/** Like svn_cstring_split(), but append to existing @a array instead of\r
+ * creating a new one.  Allocate the copied substrings in @a pool\r
+ * (i.e., caller decides whether or not to pass @a array->pool as @a pool).\r
+ */\r
+void\r
+svn_cstring_split_append(apr_array_header_t *array,\r
+                         const char *input,\r
+                         const char *sep_chars,\r
+                         svn_boolean_t chop_whitespace,\r
+                         apr_pool_t *pool);\r
+\r
+\r
+/** Return @c TRUE iff @a str matches any of the elements of @a list, a list\r
+ * of zero or more glob patterns.\r
+ */\r
+svn_boolean_t\r
+svn_cstring_match_glob_list(const char *str, apr_array_header_t *list);\r
+\r
+/**\r
+ * Return the number of line breaks in @a msg, allowing any kind of newline\r
+ * termination (CR, LF, CRLF, or LFCR), even inconsistent.\r
+ *\r
+ * @since New in 1.2.\r
+ */\r
+int\r
+svn_cstring_count_newlines(const char *msg);\r
+\r
+/**\r
+ * Return a cstring which is the concatenation of @a strings (an array\r
+ * of char *) each followed by @a separator (that is, @a separator\r
+ * will also end the resulting string).  Allocate the result in @a pool.\r
+ * If @a strings is empty, then return the empty string.\r
+ *\r
+ * @since New in 1.2.\r
+ */\r
+char *\r
+svn_cstring_join(apr_array_header_t *strings,\r
+                 const char *separator,\r
+                 apr_pool_t *pool);\r
+\r
+/**\r
+ * Compare two strings @a atr1 and @a atr2, treating case-equivalent\r
+ * unaccented Latin (ASCII subset) letters as equal.\r
+ *\r
+ * Returns in integer greater than, equal to, or less than 0,\r
+ * according to whether @a str1 is considered greater than, equal to,\r
+ * or less than @a str2.\r
+ *\r
+ * @since New in 1.5.\r
+ */\r
+int\r
+svn_cstring_casecmp(const char *str1, const char *str2);\r
+\r
+\r
+/** @} */\r
+\r
+/** @} */\r
+\r
+\f\r
+#ifdef __cplusplus\r
+}\r
+#endif /* __cplusplus */\r
+\r
+#endif  /* SVN_STRING_H */\r