Author: stsp
Date: Fri Jul  6 10:06:38 2012
New Revision: 1358101

URL: http://svn.apache.org/viewvc?rev=1358101&view=rev
Log:
Cosmetic tweaks for the interactive merge tool side-by-side display.

* subversion/svn/file-merge.c
  (prepare_line_for_display): Always use the LINE_DISPLAY_WIDTH constant
    directly, rather than an intermediate local variable.
    Fix an off-by-one bug that prevented us from properly chopping newlines
    off lines that contain only a newline.
  (SEP_STRING): Adjust length of each segment to actual line display length.
  (merge_chunks): Stop displaying extra blanks to use as much screen estate
   as possible.

Modified:
    subversion/trunk/subversion/svn/file-merge.c

Modified: subversion/trunk/subversion/svn/file-merge.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/file-merge.c?rev=1358101&r1=1358100&r2=1358101&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/file-merge.c (original)
+++ subversion/trunk/subversion/svn/file-merge.c Fri Jul  6 10:06:38 2012
@@ -379,16 +379,15 @@ static const char *
 prepare_line_for_display(const char *line, apr_pool_t *pool)
 {
   svn_stringbuf_t *buf = svn_stringbuf_create(line, pool);
-  int line_width = LINE_DISPLAY_WIDTH;
   int width;
   apr_pool_t *iterpool;
 
   /* Trim EOL. */
-  if (buf->len > 2 &&
+  if (buf->len >= 2 &&
       buf->data[buf->len - 2] == '\r' && 
       buf->data[buf->len - 1] == '\n')
     svn_stringbuf_chop(buf, 2);
-  else if (buf->len > 1 &&
+  else if (buf->len >= 1 &&
            (buf->data[buf->len - 1] == '\n' ||
             buf->data[buf->len - 1] == '\r'))
     svn_stringbuf_chop(buf, 1);
@@ -408,7 +407,7 @@ prepare_line_for_display(const char *lin
   /* Trim further in case line is still too long, or add padding in case
    * it is too short. */
   iterpool = svn_pool_create(pool);
-  while (width > line_width)
+  while (width > LINE_DISPLAY_WIDTH)
     {
       const char *last_valid;
 
@@ -428,7 +427,7 @@ prepare_line_for_display(const char *lin
     }
   svn_pool_destroy(iterpool);
 
-  while (width == 0 || width < line_width)
+  while (width == 0 || width < LINE_DISPLAY_WIDTH)
     {
       svn_stringbuf_appendbyte(buf, ' ');
       width++;
@@ -556,7 +555,7 @@ edit_chunk(apr_array_header_t **merged_c
 }
 
 #define SEP_STRING \
-  
"-------------------------------------+-------------------------------------\n"
+  "------------------------------------+------------------------------------\n"
 
 /* Merge chunks CHUNK1 and CHUNK2.
  * Each lines array contains elements of type svn_stringbuf_t*.
@@ -585,7 +584,7 @@ merge_chunks(apr_array_header_t **merged
    */
 
   prompt = svn_stringbuf_create(
-             apr_psprintf(scratch_pool, "%s |%s\n%s",
+             apr_psprintf(scratch_pool, "%s|%s\n%s",
                           prepare_line_for_display(
                             apr_psprintf(scratch_pool,
                                          _("(1) their version (at line %lu)"),
@@ -634,7 +633,7 @@ merge_chunks(apr_array_header_t **merged
       else
         line2 = prepare_line_for_display("", iterpool);
         
-      prompt_line = apr_psprintf(iterpool, "%s |%s\n", line1, line2);
+      prompt_line = apr_psprintf(iterpool, "%s|%s\n", line1, line2);
 
       svn_stringbuf_appendcstr(prompt, prompt_line);
     }


Reply via email to