~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/libsvn_diff/parse-diff.c

  • Committer: Package Import Robot
  • Author(s): James McCoy, Peter Samuelson, James McCoy
  • Date: 2014-01-12 19:48:33 UTC
  • mfrom: (0.2.10)
  • Revision ID: package-import@ubuntu.com-20140112194833-w3axfwksn296jn5x
Tags: 1.8.5-1
[ Peter Samuelson ]
* New upstream release.  (Closes: #725787) Rediff patches:
  - Remove apr-abi1 (applied upstream), rename apr-abi2 to apr-abi
  - Remove loosen-sqlite-version-check (shouldn't be needed)
  - Remove java-osgi-metadata (applied upstream)
  - svnmucc prompts for a changelog if none is provided. (Closes: #507430)
  - Remove fix-bdb-version-detection, upstream uses "apu-config --dbm-libs"
  - Remove ruby-test-wc (applied upstream)
  - Fix “svn diff -r N file” when file has svn:mime-type set.
    (Closes: #734163)
  - Support specifying an encoding for mod_dav_svn's environment in which
    hooks are run.  (Closes: #601544)
  - Fix ordering of “svnadmin dump” paths with certain APR versions.
    (Closes: #687291)
  - Provide a better error message when authentication fails with an
    svn+ssh:// URL.  (Closes: #273874)
  - Updated Polish translations.  (Closes: #690815)

[ James McCoy ]
* Remove all traces of libneon, replaced by libserf.
* patches/sqlite_3.8.x_workaround: Upstream fix for wc-queries-test test
  failurse.
* Run configure with --with-apache-libexecdir, which allows removing part of
  patches/rpath.
* Re-enable auth-test as upstream has fixed the problem of picking up
  libraries from the environment rather than the build tree.
  (Closes: #654172)
* Point LD_LIBRARY_PATH at the built auth libraries when running the svn
  command during the build.  (Closes: #678224)
* Add a NEWS entry describing how to configure mod_dav_svn to understand
  UTF-8.  (Closes: #566148)
* Remove ancient transitional package, libsvn-ruby.
* Enable compatibility with Sqlite3 versions back to Wheezy.
* Enable hardening flags.  (Closes: #734918)
* patches/build-fixes: Enable verbose build logs.
* Build against the default ruby version.  (Closes: #722393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 */
23
23
 
24
24
#include <stdlib.h>
 
25
#include <stddef.h>
25
26
#include <string.h>
26
27
 
 
28
#include "svn_hash.h"
27
29
#include "svn_types.h"
28
30
#include "svn_error.h"
29
31
#include "svn_io.h"
269
271
  return TRUE;
270
272
}
271
273
 
272
 
/* A helper for reading a line of text from a range in the patch file.
273
 
 *
274
 
 * Allocate *STRINGBUF in RESULT_POOL, and read into it one line from FILE.
275
 
 * Reading stops either after a line-terminator was found or after MAX_LEN
276
 
 * bytes have been read. The line-terminator is not stored in *STRINGBUF.
277
 
 *
278
 
 * The line-terminator is detected automatically and stored in *EOL
279
 
 * if EOL is not NULL. If EOF is reached and FILE does not end
280
 
 * with a newline character, and EOL is not NULL, *EOL is set to NULL.
281
 
 *
282
 
 * SCRATCH_POOL is used for temporary allocations.
283
 
 */
284
 
static svn_error_t *
285
 
readline(apr_file_t *file,
286
 
         svn_stringbuf_t **stringbuf,
287
 
         const char **eol,
288
 
         svn_boolean_t *eof,
289
 
         apr_size_t max_len,
290
 
         apr_pool_t *result_pool,
291
 
         apr_pool_t *scratch_pool)
292
 
{
293
 
  svn_stringbuf_t *str;
294
 
  const char *eol_str;
295
 
  apr_size_t numbytes;
296
 
  char c;
297
 
  apr_size_t len;
298
 
  svn_boolean_t found_eof;
299
 
 
300
 
  str = svn_stringbuf_create_ensure(80, result_pool);
301
 
 
302
 
  /* Read bytes into STR up to and including, but not storing,
303
 
   * the next EOL sequence. */
304
 
  eol_str = NULL;
305
 
  numbytes = 1;
306
 
  len = 0;
307
 
  found_eof = FALSE;
308
 
  while (!found_eof)
309
 
    {
310
 
      if (len < max_len)
311
 
        SVN_ERR(svn_io_file_read_full2(file, &c, sizeof(c), &numbytes,
312
 
                                       &found_eof, scratch_pool));
313
 
      len++;
314
 
      if (numbytes != 1 || len > max_len)
315
 
        {
316
 
          found_eof = TRUE;
317
 
          break;
318
 
        }
319
 
 
320
 
      if (c == '\n')
321
 
        {
322
 
          eol_str = "\n";
323
 
        }
324
 
      else if (c == '\r')
325
 
        {
326
 
          eol_str = "\r";
327
 
 
328
 
          if (!found_eof && len < max_len)
329
 
            {
330
 
              apr_off_t pos;
331
 
 
332
 
              /* Check for "\r\n" by peeking at the next byte. */
333
 
              pos = 0;
334
 
              SVN_ERR(svn_io_file_seek(file, APR_CUR, &pos, scratch_pool));
335
 
              SVN_ERR(svn_io_file_read_full2(file, &c, sizeof(c), &numbytes,
336
 
                                             &found_eof, scratch_pool));
337
 
              if (numbytes == 1 && c == '\n')
338
 
                {
339
 
                  eol_str = "\r\n";
340
 
                  len++;
341
 
                }
342
 
              else
343
 
                {
344
 
                  /* Pretend we never peeked. */
345
 
                  SVN_ERR(svn_io_file_seek(file, APR_SET, &pos, scratch_pool));
346
 
                  found_eof = FALSE;
347
 
                  numbytes = 1;
348
 
                }
349
 
            }
350
 
        }
351
 
      else
352
 
        svn_stringbuf_appendbyte(str, c);
353
 
 
354
 
      if (eol_str)
355
 
        break;
356
 
    }
357
 
 
358
 
  if (eol)
359
 
    *eol = eol_str;
360
 
  if (eof)
361
 
    *eof = found_eof;
362
 
  *stringbuf = str;
363
 
 
364
 
  return SVN_NO_ERROR;
365
 
}
366
 
 
367
274
/* Read a line of original or modified hunk text from the specified
368
275
 * RANGE within FILE. FILE is expected to contain unidiff text.
369
276
 * Leading unidiff symbols ('+', '-', and ' ') are removed from the line,
395
302
      *eof = TRUE;
396
303
      if (eol)
397
304
        *eol = NULL;
398
 
      *stringbuf = svn_stringbuf_create("", result_pool);
 
305
      *stringbuf = svn_stringbuf_create_empty(result_pool);
399
306
      return SVN_NO_ERROR;
400
307
    }
401
308
 
405
312
  do
406
313
    {
407
314
      max_len = range->end - range->current;
408
 
      SVN_ERR(readline(file, &str, eol, eof, max_len,
409
 
                       result_pool, scratch_pool));
 
315
      SVN_ERR(svn_io_file_readline(file, &str, eol, eof, max_len,
 
316
                                   result_pool, scratch_pool));
410
317
      range->current = 0;
411
318
      SVN_ERR(svn_io_file_seek(file, APR_CUR, &range->current, scratch_pool));
412
319
      filtered = (str->data[0] == verboten || str->data[0] == '\\');
489
396
      *eof = TRUE;
490
397
      if (eol)
491
398
        *eol = NULL;
492
 
      *stringbuf = svn_stringbuf_create("", result_pool);
 
399
      *stringbuf = svn_stringbuf_create_empty(result_pool);
493
400
      return SVN_NO_ERROR;
494
401
    }
495
402
 
498
405
  SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_SET,
499
406
                           &hunk->diff_text_range.current, scratch_pool));
500
407
  max_len = hunk->diff_text_range.end - hunk->diff_text_range.current;
501
 
  SVN_ERR(readline(hunk->apr_file, &line, eol, eof, max_len, result_pool,
 
408
  SVN_ERR(svn_io_file_readline(hunk->apr_file, &line, eol, eof, max_len,
 
409
                               result_pool,
502
410
                   scratch_pool));
503
411
  hunk->diff_text_range.current = 0;
504
412
  SVN_ERR(svn_io_file_seek(hunk->apr_file, APR_CUR,
641
549
 
642
550
      /* Remember the current line's offset, and read the line. */
643
551
      last_line = pos;
644
 
      SVN_ERR(readline(apr_file, &line, NULL, &eof, APR_SIZE_MAX,
645
 
                       iterpool, iterpool));
 
552
      SVN_ERR(svn_io_file_readline(apr_file, &line, NULL, &eof, APR_SIZE_MAX,
 
553
                                   iterpool, iterpool));
646
554
 
647
555
      /* Update line offset for next iteration. */
648
556
      pos = 0;
649
557
      SVN_ERR(svn_io_file_seek(apr_file, APR_CUR, &pos, iterpool));
650
558
 
651
 
      /* Lines starting with a backslash are comments, such as
652
 
       * "\ No newline at end of file". */
 
559
      /* Lines starting with a backslash indicate a missing EOL:
 
560
       * "\ No newline at end of file" or "end of property". */
653
561
      if (line->data[0] == '\\')
654
562
        {
655
 
          if (in_hunk &&
656
 
              ((!*is_property &&
657
 
                strcmp(line->data, "\\ No newline at end of file") == 0) ||
658
 
               (*is_property &&
659
 
                strcmp(line->data, "\\ No newline at end of property") == 0)))
 
563
          if (in_hunk)
660
564
            {
661
565
              char eolbuf[2];
662
566
              apr_size_t len;
1033
937
 
1034
938
  while (TRUE)
1035
939
    {
1036
 
      int len_old;
1037
 
      int len_new;
 
940
      ptrdiff_t len_old;
 
941
      ptrdiff_t len_new;
1038
942
 
1039
943
      new_path_marker = strstr(new_path_start, " b/");
1040
944
 
1207
1111
{
1208
1112
  svn_prop_patch_t *prop_patch;
1209
1113
 
1210
 
  prop_patch = apr_hash_get(patch->prop_patches, prop_name,
1211
 
                            APR_HASH_KEY_STRING);
 
1114
  prop_patch = svn_hash_gets(patch->prop_patches, prop_name);
1212
1115
 
1213
1116
  if (! prop_patch)
1214
1117
    {
1218
1121
      prop_patch->hunks = apr_array_make(result_pool, 1,
1219
1122
                                         sizeof(svn_diff_hunk_t *));
1220
1123
 
1221
 
      apr_hash_set(patch->prop_patches, prop_name, APR_HASH_KEY_STRING,
1222
 
                   prop_patch);
 
1124
      svn_hash_sets(patch->prop_patches, prop_name, prop_patch);
1223
1125
    }
1224
1126
 
1225
1127
  APR_ARRAY_PUSH(prop_patch->hunks, svn_diff_hunk_t *) = hunk;
1245
1147
 
1246
1148
  p = apr_palloc(result_pool, sizeof(*p));
1247
1149
  SVN_ERR(svn_io_file_open(&p->apr_file, local_abspath,
1248
 
                           APR_READ | APR_BINARY, 0, result_pool));
 
1150
                           APR_READ | APR_BUFFERED, APR_OS_DEFAULT,
 
1151
                           result_pool));
1249
1152
  p->next_patch_offset = 0;
1250
1153
  *patch_file = p;
1251
1154
 
1362
1265
 
1363
1266
      /* Remember the current line's offset, and read the line. */
1364
1267
      last_line = pos;
1365
 
      SVN_ERR(readline(patch_file->apr_file, &line, NULL, &eof,
1366
 
                       APR_SIZE_MAX, iterpool, iterpool));
 
1268
      SVN_ERR(svn_io_file_readline(patch_file->apr_file, &line, NULL, &eof,
 
1269
                                   APR_SIZE_MAX, iterpool, iterpool));
1367
1270
 
1368
1271
      if (! eof)
1369
1272
        {