summaryrefslogtreecommitdiff
path: root/editors/joe-devel/files/patch-ad
diff options
context:
space:
mode:
Diffstat (limited to 'editors/joe-devel/files/patch-ad')
-rw-r--r--editors/joe-devel/files/patch-ad140
1 files changed, 54 insertions, 86 deletions
diff --git a/editors/joe-devel/files/patch-ad b/editors/joe-devel/files/patch-ad
index 38113e698cfc..7058d4f93000 100644
--- a/editors/joe-devel/files/patch-ad
+++ b/editors/joe-devel/files/patch-ad
@@ -1,98 +1,66 @@
---- b.c.orig Fri Jan 20 00:38:25 1995
-+++ b.c Sun Dec 3 09:58:21 2000
-@@ -21,6 +21,9 @@
+--- b.c.orig Wed Apr 11 17:10:49 2001
++++ b.c Sat Apr 21 23:11:38 2001
+@@ -16,6 +16,9 @@
#include <pwd.h>
#endif
#include <errno.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+ #include <stdlib.h>
+ #include <ctype.h>
+ #include <string.h>
+@@ -178,6 +181,7 @@
+ else
+ b->o = pdefault;
+ mset (b->marks, 0, sizeof (b->marks));
++ b->filehandle = -1; /* initialize filehandle &&& ob */
+ b->rdonly = 0;
+ b->orphan = 0;
+ b->oldcur = 0;
+@@ -229,6 +233,11 @@
+ void brm (B *b) {
+ if (b && !--b->count)
+ {
++ if (b->filehandle != -1) {
++ /* close filehandle, free lock &&& ob */
++ close (b->filehandle);
++ }
++
+ if (b->changed)
+ abrerr (b->name);
+ if (b == errbuf)
+@@ -1867,7 +1876,8 @@
+ B *b;
+ long skip, amnt;
+ char *n;
+- int nowrite = 0;
++ struct stat sb;
++ int nowrite = 0, fh = -1;
- #include "config.h"
- #include "blocks.h"
-@@ -201,6 +204,7 @@
- if(prop) b->o=prop->o;
- else b->o=pdefault;
- mset(b->marks,0,sizeof(b->marks));
-+ b->filehandle = -1; /* initialize filehandle &&& ob */
- b->rdonly=0;
- b->orphan=0;
- b->oldcur=0;
-@@ -255,6 +259,10 @@
- {
- if(b && !--b->count)
- {
-+ if (b->filehandle != -1) {
-+ /* close filehandle, free lock &&& ob */
-+ close (b->filehandle);
-+ }
- if(b->changed) abrerr(b->name);
- if(b==errbuf) errbuf=0;
- if(b->undo) undorm(b->undo);
-@@ -1671,7 +1679,8 @@
- B *b;
- long skip,amnt;
- char *n;
-- int nowrite=0;
-+ struct stat sb;
-+ int nowrite=0,fh=-1;
+ if (!s || !s[0])
+ {
+@@ -1920,6 +1930,14 @@
+ goto opnerr;
+ }
- if(!s || !s[0])
- {
-@@ -1704,6 +1713,28 @@
- else fclose(fi);
- fi=fopen(n,"r");
- if(!fi) nowrite=0;
-+/*printf ("nowrite open=%i\n", nowrite); */
-+
-+ /* check file mod, if no write flags set,
-+ joe in read only mode. &&& ob */
-+
-+ if (!nowrite) {
-+ nowrite = (!stat (n, &sb)) && (!(sb.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)));
-+ }
-+/*printf ("nowrite stat=%i\n", nowrite); */
++ /* Lock the file &&& ob,petef */
++ if (fi)
++ {
++ fh = dup( fileno(fi) );
++ nowrite = (flock (fh, LOCK_EX | LOCK_NB));
++ }
+
-+ /* lock the file if writable, or go into read only mode if
-+ already locked, */
-+
-+ if ((fi) && (!nowrite)) {
-+ fh = dup( fileno(fi) );
-+ nowrite = (flock (fh, LOCK_EX | LOCK_NB));
-+ }
-+/*printf ("nowrite flock=%i\n", nowrite); */
+
-+/*nowrite = 1; */ /* for test purpose */
-+/*printf ("nowrite=%i\n", nowrite); */
-+
- }
- joesep(n);
-
-@@ -1761,6 +1792,7 @@
- vsrm(n);
+ /* Skip data if we need to */
+ if (skip && lseek (fileno (fi), skip, 0) < 0)
+ {
+@@ -1978,6 +1996,8 @@
+ vsrm (n);
- b->er=error;
-+ if( fh != -1 ) b->filehandle = fh;
- return b;
- }
+ b->er = error;
++ if (fh != -1)
++ b->filehandle = fh;
+ return b;
+ }
-@@ -1990,7 +2022,18 @@
- {
- long tim=time(0);
- B *b;
-- FILE *f=fopen("DEADJOE","a");
-+ FILE *f;
-+ struct stat sb;
-+ if ((lstat("DEADJOE", &sb) == 0) && (((sb.st_mode & S_IFLNK) && (sb.st_uid != getuid())) || (sb.st_nlink > 1)))
-+ {
-+ printf("*** JOE was aborted ");
-+ if (sig) printf("by signal %d, cannot save DEADJOE due to unsafe symlink\n",sig);
-+ else printf("because the terminal closed, cannot save DEADJOE due to unsafe symlink\n");
-+ if(sig) ttclsn();
-+ _exit(1);
-+ }
-+ f=fopen("DEADJOE","a");
-+ chmod("DEADJOE", S_IRUSR | S_IWUSR);
- fprintf(f,"\n*** Modified files in JOE when it aborted on %s",ctime(&tim));
- if(sig) fprintf(f,"*** JOE was aborted by signal %d\n",sig);
- else fprintf(f,"*** JOE was aborted because the terminal closed\n");