7163e47fd855c1b6984431ab9eeed6886fb5d962
[debian/tar] / debian / patches / longlink-hack.diff
1 diff -ur orig/tar-1.25/src/common.h tar-1.25/src/common.h
2 --- orig/tar-1.25/src/common.h  2010-11-10 18:41:01.000000000 -0400
3 +++ tar-1.25/src/common.h       2010-11-11 20:28:06.000000000 -0400
4 @@ -834,3 +834,5 @@
5  
6  /* Module exit.c */
7  extern void (*fatal_exit_hook) (void);
8 +
9 +GLOBAL int debian_longlink_hack;
10 diff -ur orig/tar-1.25/src/create.c tar-1.25/src/create.c
11 --- orig/tar-1.25/src/create.c  2010-11-10 18:41:01.000000000 -0400
12 +++ tar-1.25/src/create.c       2010-11-11 20:30:44.000000000 -0400
13 @@ -26,6 +26,8 @@
14  #include "common.h"
15  #include <hash.h>
16  
17 +extern int debian_longlink_hack;
18 +
19  /* Error number to use when an impostor is discovered.
20     Pretend the impostor isn't there.  */
21  enum { IMPOSTOR_ERRNO = ENOENT };
22 @@ -735,7 +737,7 @@
23        return write_short_name (st);
24      }
25    else if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
26 -          < strlen (st->file_name))
27 +          < strlen (st->file_name) + debian_longlink_hack)
28      return write_long_name (st);
29    else
30      return write_short_name (st);
31 @@ -1456,7 +1458,7 @@
32           block_ordinal = current_block_ordinal ();
33           assign_string (&st->link_name, link_name);
34           if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
35 -             < strlen (link_name))
36 +             < strlen (link_name) + debian_longlink_hack)
37             write_long_link (st);
38  
39           st->stat.st_size = 0;
40 diff -ur orig/tar-1.25/src/tar.c tar-1.25/src/tar.c
41 --- orig/tar-1.25/src/tar.c     2010-11-10 18:41:01.000000000 -0400
42 +++ tar-1.25/src/tar.c  2010-11-11 20:28:59.000000000 -0400
43 @@ -2566,6 +2566,16 @@
44    report_textual_dates (&args);
45  }
46  
47 +/* Debian specific environment variable used by pristine-tar to enable use of
48 + * longlinks for filenames exactly 100 bytes long. */
49 +void debian_longlink_hack_init () {
50 + char *s=getenv ("TAR_LONGLINK_100");
51 + if (s && strcmp(s, "1") == 0)
52 +        debian_longlink_hack=1;
53 + else
54 +        debian_longlink_hack=0;
55 +}
56 +
57  \f
58  /* Tar proper.  */
59  
60 @@ -2585,6 +2595,8 @@
61    filename_terminator = '\n';
62    set_quoting_style (0, DEFAULT_QUOTING_STYLE);
63  
64 +  debian_longlink_hack_init ();
65 +
66    /* Make sure we have first three descriptors available */
67    stdopen ();
68