]> git.pld-linux.org Git - packages/xemacs.git/commitdiff
- patch from rawhide.
authorkloczek <kloczek@pld-linux.org>
Sat, 27 Jan 2001 23:26:32 +0000 (23:26 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    xemacs-mmencode.patch -> 1.1

xemacs-mmencode.patch [new file with mode: 0644]

diff --git a/xemacs-mmencode.patch b/xemacs-mmencode.patch
new file mode 100644 (file)
index 0000000..cefad55
--- /dev/null
@@ -0,0 +1,108 @@
+--- xemacs-21.1.9/lib-src/mmencode.c.chmou     Thu Mar 23 18:26:34 2000
++++ xemacs-21.1.9/lib-src/mmencode.c   Thu Mar 23 18:26:55 2000
+@@ -20,6 +20,13 @@
+ #include <string.h>
+ #include <errno.h>
++/* required for open */
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <fcntl.h>
++
++extern int errno;
++
+ static void
+ output64chunk(int c1, int c2, int c3, int pads, FILE *outfile);
+@@ -429,6 +436,29 @@
+     }    
+ }
++/* not safe on nfs filesystems, but this is close */
++FILE *
++safeopen(char *filename, char *mode)
++{
++    FILE *ret;
++    int fd;
++    int flags;
++
++    if(mode[0] == 'w') {
++        flags = O_EXCL | O_CREAT | O_WRONLY;
++    }
++    else {
++        flags = O_RDONLY;
++    }
++    
++    fd = open(filename, flags);
++    
++    if(fd == -1) {
++        return 0;
++    }
++    
++    return fdopen(fd, mode);
++}
+ /*
+ Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
+@@ -454,6 +484,7 @@
+ int main(int argc, char *argv[])
+ {
+     int encode = 1, which = BASE64, i, portablenewlines = 0;
++    struct stat theStat;
+     FILE *fp = stdin;
+     FILE *fpo = stdout;
+@@ -465,7 +496,12 @@
+                       fprintf(stderr, "mimencode: -o requires a file name.\n");
+                       exit(-1);
+                   }
+-                  fpo = fopen(argv[i], "w");
++                  fpo = safeopen(argv[i], "w");
++            if(fpo == 0) {
++                printf("Can't open output file(%s): %s\n",
++                       argv[i], strerror(errno));
++                exit(1);
++            }
+                   if (!fpo) {
+                       perror(argv[i]);
+                       exit(-1);
+@@ -490,15 +526,35 @@
+             }
+         } else {
+ #ifdef MSDOS
+-            if (encode)
+-                fp = fopen(argv[i], "rb");
++            if (encode) {
++                fp = safeopen(argv[i], "rb");
++                if(fp == 0) {
++                    exit(1);
++                }
++                
++            }
+             else
+             {
+-                fp = fopen(argv[i], "rt");
++                fp = safeopen(argv[i], "rt");
++                if(fp == 0) exit(1);
+                 setmode(fileno(fpo), O_BINARY);
+             } /* else */
+ #else
+-            fp = fopen(argv[i], "r");
++            fp = safeopen(argv[i], "r");
++            if(fp == 0) {
++                printf("Unable to open read file(%s): %s\n",
++                       argv[i], strerror(errno));
++                exit(1);
++            }
++            /* ok change the permissions on the output file to match
++               the permissions on the input file */
++            if(fstat(fileno(fp), &theStat) == -1) {
++                printf("Unable to stat read file: %s\n", strerror(errno));
++                exit(3);
++            }
++            fchmod(fileno(fpo),
++                   theStat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
++
+ #endif /* MSDOS */
+             if (!fp) {
+                 perror(argv[i]);
This page took 0.669963 seconds and 4 git commands to generate.