Add DPADD lines for used libs.
[dragonfly.git] / usr.bin / bzip2 / bzip2.c.patch
1 $DragonFly: src/usr.bin/bzip2/Attic/bzip2.c.patch,v 1.1 2005/06/29 23:03:22 corecode Exp $
2 Index: bzip2.c
3 ===================================================================
4 RCS file: /cvs/src/contrib/bzip2-1.0/bzip2.c,v
5 retrieving revision 1.1
6 diff -u -r1.1 bzip2.c
7 --- bzip2.c     29 Jun 2005 22:38:10 -0000      1.1
8 +++ bzip2.c     29 Jun 2005 22:50:59 -0000
9 @@ -312,6 +312,7 @@
10  
11  static void    copyFileName ( Char*, Char* );
12  static void*   myMalloc     ( Int32 );
13 +static int     applySavedFileAttrToOutputFile ( int fd );
14  
15  
16  
17 @@ -457,6 +458,10 @@
18     ret = fflush ( zStream );
19     if (ret == EOF) goto errhandler_io;
20     if (zStream != stdout) {
21 +      int fd = fileno ( zStream );
22 +      if (fd < 0) goto errhandler_io;
23 +      ret = applySavedFileAttrToOutputFile ( fd );
24 +      if (ret != 0) goto errhandler_io;
25        ret = fclose ( zStream );
26        outputHandleJustInCase = NULL;
27        if (ret == EOF) goto errhandler_io;
28 @@ -569,6 +574,12 @@
29  
30     closeok:
31     if (ferror(zStream)) goto errhandler_io;
32 +   if ( stream != stdout) {
33 +      int fd = fileno ( stream );
34 +      if (fd < 0) goto errhandler_io;
35 +      ret = applySavedFileAttrToOutputFile ( fd );
36 +      if (ret != 0) goto errhandler_io;
37 +   }
38     ret = fclose ( zStream );
39     if (ret == EOF) goto errhandler_io;
40  
41 @@ -1129,7 +1140,7 @@
42  
43  
44  static 
45 -void applySavedMetaInfoToOutputFile ( Char *dstName )
46 +void applySavedTimeInfoToOutputFile ( Char *dstName )
47  {
48  #  if BZ_UNIX
49     IntNative      retVal;
50 @@ -1138,16 +1149,26 @@
51     uTimBuf.actime = fileMetaInfo.st_atime;
52     uTimBuf.modtime = fileMetaInfo.st_mtime;
53  
54 -   retVal = chmod ( dstName, fileMetaInfo.st_mode );
55 -   ERROR_IF_NOT_ZERO ( retVal );
56 -
57     retVal = utime ( dstName, &uTimBuf );
58     ERROR_IF_NOT_ZERO ( retVal );
59 +#  endif
60 +}
61 +
62 +static 
63 +int applySavedFileAttrToOutputFile ( int fd )
64 +{
65 +#  if BZ_UNIX
66 +   IntNative      retVal;
67 +
68 +   retVal = fchmod ( fd, fileMetaInfo.st_mode );
69 +   if (retVal != 0)
70 +       return retVal;
71  
72 -   retVal = chown ( dstName, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
73 +   (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
74     /* chown() will in many cases return with EPERM, which can
75        be safely ignored.
76     */
77 +   return 0;
78  #  endif
79  }
80  
81 @@ -1370,7 +1391,7 @@
82  
83     /*--- If there was an I/O error, we won't get here. ---*/
84     if ( srcMode == SM_F2F ) {
85 -      applySavedMetaInfoToOutputFile ( outName );
86 +      applySavedTimeInfoToOutputFile ( outName );
87        deleteOutputOnInterrupt = False;
88        if ( !keepInputFiles ) {
89           IntNative retVal = remove ( inName );
90 @@ -1548,7 +1569,7 @@
91     /*--- If there was an I/O error, we won't get here. ---*/
92     if ( magicNumberOK ) {
93        if ( srcMode == SM_F2F ) {
94 -         applySavedMetaInfoToOutputFile ( outName );
95 +         applySavedTimeInfoToOutputFile ( outName );
96           deleteOutputOnInterrupt = False;
97           if ( !keepInputFiles ) {
98              IntNative retVal = remove ( inName );