diff options
author | D. Guthrie <dguthrie@posteo.net> | 2020-04-21 19:04:51 +0100 |
---|---|---|
committer | D. Guthrie <dguthrie@posteo.net> | 2020-04-21 19:04:51 +0100 |
commit | fcedd9f78e8072b629a5ff1da4f538f7e655f091 (patch) | |
tree | f9bfb35db6dd7fd2528d4746b3730f406ab36931 /pkgs/applications/editors/mg | |
parent | cdc8f3f3575f39849b09c741f0f269f33c0e7088 (diff) |
Fix the patch: when converting it to the new version (20200215), forgot to remove temporary files
Diffstat (limited to 'pkgs/applications/editors/mg')
-rw-r--r-- | pkgs/applications/editors/mg/darwin_no_libbsd.patch | 2379 |
1 files changed, 18 insertions, 2361 deletions
diff --git a/pkgs/applications/editors/mg/darwin_no_libbsd.patch b/pkgs/applications/editors/mg/darwin_no_libbsd.patch index 2484c03255b1..1863f2952b2b 100644 --- a/pkgs/applications/editors/mg/darwin_no_libbsd.patch +++ b/pkgs/applications/editors/mg/darwin_no_libbsd.patch @@ -1,6 +1,6 @@ diff -Naur a/GNUmakefile b/GNUmakefile --- a/GNUmakefile 2020-04-20 21:09:41.000000000 +0100 -+++ b/GNUmakefile 2020-04-20 21:31:19.000000000 +0100 ++++ b/GNUmakefile 2020-04-21 19:01:59.000000000 +0100 @@ -18,7 +18,7 @@ STRIP= /usr/bin/strip @@ -10,7 +10,7 @@ diff -Naur a/GNUmakefile b/GNUmakefile BSD_CPPFLAGS:= BSD_LIBS:= -lutil else -@@ -38,24 +38,21 @@ +@@ -38,10 +38,6 @@ $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) endif @@ -21,11 +21,7 @@ diff -Naur a/GNUmakefile b/GNUmakefile CC?= gcc CFLAGS?= -O2 -pipe CFLAGS+= -g -Wall - CPPFLAGS= -DREGEX - CPPFLAGS+= -D_GNU_SOURCE --CPPFLAGS+= $(BSD_CPPFLAGS) -+CPPFLAGS+= $(BSD_CPPFLAGS) -D__dead=__dead2 - LIBS= $(CURSES_LIBS) $(BSD_LIBS) +@@ -52,10 +48,11 @@ OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ @@ -41,109 +37,9 @@ diff -Naur a/GNUmakefile b/GNUmakefile OBJS+= cmode.o cscope.o dired.o grep.o tags.o -diff -Naur a/GNUmakefile~ b/GNUmakefile~ ---- a/GNUmakefile~ 1970-01-01 01:00:00.000000000 +0100 -+++ b/GNUmakefile~ 2020-04-20 21:27:39.000000000 +0100 -@@ -0,0 +1,96 @@ -+# Makefile for mg -+ -+# This Makefile has been written by Han Boetes -+# <hboetes@gmail.com> and is released in Public Domain. -+ -+# *sigh* Those debian folks are really tidy on their licenses. -+ -+name= mg -+ -+prefix= /usr/local -+bindir= $(prefix)/bin -+libdir= $(prefix)/lib -+includedir= $(prefix)/include -+mandir= $(prefix)/man -+ -+PKG_CONFIG= /usr/bin/pkg-config --silence-errors -+INSTALL= /usr/bin/install -+STRIP= /usr/bin/strip -+ -+UNAME:= $(shell uname) -+ifeq ($(UNAME),FreeBSD) -+ BSD_CPPFLAGS:= -+ BSD_LIBS:= -lutil -+else -+ BSD_CPPFLAGS:= $(shell $(PKG_CONFIG) --cflags libbsd-overlay) -+ BSD_LIBS:= $(shell $(PKG_CONFIG) --libs libbsd-overlay) -+endif -+ -+# Test is some required libraries are installed. Rather bummer that -+# they are also required to run make clean or uninstall. Oh well... Who -+# does that? -+ifeq ($(BSD_LIBS),) -+ $(error You probably need to install "libbsd-dev" or "libbsd-devel" or something like that.) -+endif -+ -+CURSES_LIBS:= $(shell $(PKG_CONFIG) --libs ncurses) -+ifeq ($(CURSES_LIBS),) -+ $(error You probably need to install "libncurses5-dev" or "libncurses6-devel" or something like that.) -+endif -+ -+ifdef STATIC -+ LDFLAGS=-static -static-libgcc -+endif -+ -+CC?= gcc -+CFLAGS?= -O2 -pipe -+CFLAGS+= -g -Wall -+CPPFLAGS= -DREGEX -+CPPFLAGS+= -D_GNU_SOURCE -+CPPFLAGS+= $(BSD_CPPFLAGS) -+LIBS= $(CURSES_LIBS) $(BSD_LIBS) -+ -+ -+OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \ -+ echo.o extend.o file.o fileio.o funmap.o interpreter.o help.o \ -+ kbd.o keymap.o line.o macro.o main.o match.o modes.o paragraph.o \ -+ re_search.o region.o search.o spawn.o tty.o ttyio.o ttykbd.o \ -+ undo.o util.o version.o window.o word.o yank.o -+OBJS+= cmode.o cscope.o dired.o grep.o tags.o -+ -+ -+# Portability stuff. -+CFLAGS+= -Wno-strict-aliasing -Wno-deprecated-declarations -+EXE_EXT= -+ -+.c.o: -+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -+ -+all: $(name) -+ -+$(name): $(OBJS) -+ $(CC) $(LDFLAGS) $(OBJS) -o $(name) $(LIBS) -+ -+distclean: clean -+ -rm -f *.core core.* -+ -+clean: -+ -rm -f *.o $(name)$(EXE_EXT) -+ -+ -+install: $(name) $(name).1 -+ $(INSTALL) -d $(DESTDIR)$(bindir) -+ $(INSTALL) -d $(DESTDIR)$(mandir)/man1 -+ $(INSTALL) -m 755 $(name) $(DESTDIR)$(bindir)/$(name) -+ $(INSTALL) -m 444 $(name).1 $(DESTDIR)$(mandir)/man1/$(name).1 -+ -+install-strip: install -+ $(STRIP) $(DESTDIR)$(bindir)/$(name) -+ -+uninstall: -+ rm -f \ -+ $(DESTDIR)$(bindir)/$(name)$(EXE_EXT) \ -+ $(DESTDIR)$(mandir)/man1/$(name).1 -+ -+rebuild: -+ make clean all diff -Naur a/_null.h b/_null.h --- a/_null.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/_null.h 2020-04-20 21:26:10.000000000 +0100 ++++ b/_null.h 2020-04-21 19:01:59.000000000 +0100 @@ -0,0 +1,18 @@ +/* $OpenBSD: _null.h,v 1.2 2016/09/09 22:07:58 millert Exp $ */ + @@ -165,7 +61,7 @@ diff -Naur a/_null.h b/_null.h +#endif diff -Naur a/apple.h b/apple.h --- a/apple.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/apple.h 2020-04-20 21:26:10.000000000 +0100 ++++ b/apple.h 2020-04-21 19:01:59.000000000 +0100 @@ -0,0 +1,27 @@ +/* + * Mac OS X-specific support. @@ -196,7 +92,7 @@ diff -Naur a/apple.h b/apple.h +extern int futimens(int, const struct timespec[2]); diff -Naur a/autoexec.c b/autoexec.c --- a/autoexec.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/autoexec.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/autoexec.c 2020-04-21 19:01:59.000000000 +0100 @@ -9,6 +9,9 @@ #include <stdlib.h> #include <string.h> @@ -209,7 +105,7 @@ diff -Naur a/autoexec.c b/autoexec.c diff -Naur a/basic.c b/basic.c --- a/basic.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/basic.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/basic.c 2020-04-21 19:01:59.000000000 +0100 @@ -19,6 +19,9 @@ #include <stdio.h> #include <stdlib.h> @@ -220,614 +116,9 @@ diff -Naur a/basic.c b/basic.c #include "def.h" #define percint(n1, n2) ((n1 * (int) n2) * 0.1) -diff -Naur a/basic.c.orig b/basic.c.orig ---- a/basic.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ b/basic.c.orig 2020-04-20 21:26:06.000000000 +0100 -@@ -0,0 +1,601 @@ -+/* $OpenBSD: basic.c,v 1.49 2019/06/17 11:39:26 lum Exp $ */ -+ -+/* This file is in the public domain */ -+ -+/* -+ * Basic cursor motion commands. -+ * -+ * The routines in this file are the basic -+ * command functions for moving the cursor around on -+ * the screen, setting mark, and swapping dot with -+ * mark. Only moves between lines, which might make the -+ * current buffer framing bad, are hard. -+ */ -+ -+#include <sys/queue.h> -+#include <ctype.h> -+#include <limits.h> -+#include <signal.h> -+#include <stdio.h> -+#include <stdlib.h> -+ -+#include "def.h" -+ -+#define percint(n1, n2) ((n1 * (int) n2) * 0.1) -+ -+/* -+ * Go to beginning of line. -+ */ -+/* ARGSUSED */ -+int -+gotobol(int f, int n) -+{ -+ if (n == 0) -+ return (TRUE); -+ -+ curwp->w_doto = 0; -+ return (TRUE); -+} -+ -+/* -+ * Move cursor backwards. Do the -+ * right thing if the count is less than -+ * 0. Error if you try to move back from -+ * the beginning of the buffer. -+ */ -+/* ARGSUSED */ -+int -+backchar(int f, int n) -+{ -+ struct line *lp; -+ -+ if (n < 0) -+ return (forwchar(f, -n)); -+ while (n--) { -+ if (curwp->w_doto == 0) { -+ if ((lp = lback(curwp->w_dotp)) == curbp->b_headp) { -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("Beginning of buffer"); -+ } -+ return (FALSE); -+ } -+ curwp->w_dotp = lp; -+ curwp->w_doto = llength(lp); -+ curwp->w_rflag |= WFMOVE; -+ curwp->w_dotline--; -+ } else -+ curwp->w_doto--; -+ } -+ return (TRUE); -+} -+ -+/* -+ * Go to end of line. -+ */ -+/* ARGSUSED */ -+int -+gotoeol(int f, int n) -+{ -+ if (n == 0) -+ return (TRUE); -+ -+ curwp->w_doto = llength(curwp->w_dotp); -+ return (TRUE); -+} -+ -+/* -+ * Move cursor forwards. Do the -+ * right thing if the count is less than -+ * 0. Error if you try to move forward -+ * from the end of the buffer. -+ */ -+/* ARGSUSED */ -+int -+forwchar(int f, int n) -+{ -+ if (n < 0) -+ return (backchar(f, -n)); -+ while (n--) { -+ if (curwp->w_doto == llength(curwp->w_dotp)) { -+ curwp->w_dotp = lforw(curwp->w_dotp); -+ if (curwp->w_dotp == curbp->b_headp) { -+ curwp->w_dotp = lback(curwp->w_dotp); -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("End of buffer"); -+ } -+ return (FALSE); -+ } -+ curwp->w_doto = 0; -+ curwp->w_dotline++; -+ curwp->w_rflag |= WFMOVE; -+ } else -+ curwp->w_doto++; -+ } -+ return (TRUE); -+} -+ -+/* -+ * Go to the beginning of the buffer. Setting WFFULL is conservative, -+ * but almost always the case. A universal argument of higher than 9 -+ * puts the cursor back to the end of buffer. -+ */ -+int -+gotobob(int f, int n) -+{ -+ if (!curwp->w_markp) -+ (void) setmark(f, n); -+ curwp->w_dotp = bfirstlp(curbp); -+ curwp->w_doto = 0; -+ curwp->w_rflag |= WFFULL; -+ curwp->w_dotline = 1; -+ if (f & FFOTHARG && n > 0) { -+ if (n > 9) -+ gotoeob(0, 0); -+ else -+ forwline(f, percint(curwp->w_bufp->b_lines, n) - 1); -+ } -+ return (TRUE); -+} -+ -+/* -+ * Go to the end of the buffer. Leave dot 3 lines from the bottom of the -+ * window if buffer length is longer than window length; same as emacs. -+ * Setting WFFULL is conservative, but almost always the case. A universal -+ * argument of higher than 9 puts the cursor back to the start of buffer. -+ */ -+int -+gotoeob(int f, int n) -+{ -+ int ln; -+ struct line *lp; -+ -+ if (!curwp->w_markp) -+ (void) setmark(f, n); -+ curwp->w_dotp = blastlp(curbp); -+ curwp->w_doto = llength(curwp->w_dotp); -+ curwp->w_dotline = curwp->w_bufp->b_lines; -+ -+ lp = curwp->w_dotp; -+ ln = curwp->w_ntrows - 3; -+ -+ if (ln < curwp->w_bufp->b_lines && ln >= 3) { -+ while (ln--) -+ curwp->w_dotp = lback(curwp->w_dotp); -+ -+ curwp->w_linep = curwp->w_dotp; -+ curwp->w_dotp = lp; -+ } -+ if (f & FFOTHARG && n > 0) { -+ if (n > 9) -+ gotobob(0, 0); -+ else -+ backline(f, percint(curwp->w_bufp->b_lines, n)); -+ } -+ -+ curwp->w_rflag |= WFFULL; -+ return (TRUE); -+} -+ -+/* -+ * Move forward by full lines. -+ * If the number of lines to move is less -+ * than zero, call the backward line function to -+ * actually do it. The last command controls how -+ * the goal column is set. -+ */ -+/* ARGSUSED */ -+int -+forwline(int f, int n) -+{ -+ struct line *dlp; -+ -+ if (n < 0) -+ return (backline(f | FFRAND, -n)); -+ if ((dlp = curwp->w_dotp) == curbp->b_headp) { -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("End of buffer"); -+ } -+ return(TRUE); -+ } -+ if ((lastflag & CFCPCN) == 0) /* Fix goal. */ -+ setgoal(); -+ thisflag |= CFCPCN; -+ if (n == 0) -+ return (TRUE); -+ while (n--) { -+ dlp = lforw(dlp); -+ if (dlp == curbp->b_headp) { -+ curwp->w_dotp = lback(dlp); -+ curwp->w_doto = llength(curwp->w_dotp); -+ curwp->w_rflag |= WFMOVE; -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("End of buffer"); -+ } -+ return (TRUE); -+ } -+ curwp->w_dotline++; -+ } -+ curwp->w_rflag |= WFMOVE; -+ curwp->w_dotp = dlp; -+ curwp->w_doto = getgoal(dlp); -+ -+ return (TRUE); -+} -+ -+/* -+ * This function is like "forwline", but -+ * goes backwards. The scheme is exactly the same. -+ * Check for arguments that are less than zero and -+ * call your alternate. Figure out the new line and -+ * call "movedot" to perform the motion. -+ */ -+/* ARGSUSED */ -+int -+backline(int f, int n) -+{ -+ struct line *dlp; -+ -+ if (n < 0) -+ return (forwline(f | FFRAND, -n)); -+ if ((lastflag & CFCPCN) == 0) /* Fix goal. */ -+ setgoal(); -+ thisflag |= CFCPCN; -+ dlp = curwp->w_dotp; -+ if (lback(dlp) == curbp->b_headp) { -+ if (!(f & FFRAND)) { -+ dobeep(); -+ ewprintf("Beginning of buffer"); -+ } -+ return(TRUE); -+ } -+ while (n-- && lback(dlp) != curbp->b_headp) { -+ dlp = lback(dlp); -+ curwp->w_dotline--; -+ } -+ if (n > 0 && !(f & FFRAND)) { -+ dobeep(); -+ ewprintf("Beginning of buffer"); -+ } -+ curwp->w_dotp = dlp; -+ curwp->w_doto = getgoal(dlp); -+ curwp->w_rflag |= WFMOVE; -+ return (TRUE); -+} -+ -+/* -+ * Set the current goal column, which is saved in the external variable -+ * "curgoal", to the current cursor column. The column is never off -+ * the edge of the screen; it's more like display then show position. -+ */ -+void -+setgoal(void) -+{ -+ curgoal = getcolpos(curwp); /* Get the position. */ -+ /* we can now display past end of display, don't chop! */ -+} -+ -+/* -+ * This routine looks at a line (pointed -+ * to by the LINE pointer "dlp") and the current -+ * vertical motion goal column (set by the "setgoal" -+ * routine above) and returns the best offset to use -+ * when a vertical motion is made into the line. -+ */ -+int -+getgoal(struct line *dlp) -+{ -+ int c, i, col = 0; -+ char tmp[5]; -+ -+ -+ for (i = 0; i < llength(dlp); i++) { -+ c = lgetc(dlp, i); -+ if (c == '\t' -+#ifdef NOTAB -+ && !(curbp->b_flag & BFNOTAB) -+#endif -+ ) { -+ col |= 0x07; -+ col++; -+ } else if (ISCTRL(c) != FALSE) { -+ col += 2; -+ } else if (isprint(c)) -+ col++; -+ else { -+ col += snprintf(tmp, sizeof(tmp), "\\%o", c); -+ } -+ if (col > curgoal) -+ break; -+ } -+ return (i); -+} -+ -+/* -+ * Scroll forward by a specified number -+ * of lines, or by a full page if no argument. -+ * The "2" is the window overlap (this is the default -+ * value from ITS EMACS). Because the top line in -+ * the window is zapped, we have to do a hard -+ * update and get it back. -+ */ -+/* ARGSUSED */ -+int -+forwpage(int f, int n) -+{ -+ struct line *lp; -+ -+ if (!(f & FFARG)) { -+ n = curwp->w_ntrows - 2; /* Default scroll. */ -+ if (n <= 0) /* Forget the overlap */ -+ n = 1; /* if tiny window. */ -+ } else if (n < 0) -+ return (backpage(f | FFRAND, -n)); -+ -+ lp = curwp->w_linep; -+ while (n--) -+ if ((lp = lforw(lp)) == curbp->b_headp) { -+ dobeep(); -+ ewprintf("End of buffer"); -+ return(TRUE); -+ } -+ -+ curwp->w_linep = lp; -+ curwp->w_rflag |= WFFULL; -+ -+ /* if in current window, don't move dot */ -+ for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) -+ if (lp == curwp->w_dotp) -+ return (TRUE); -+ -+ /* Advance the dot the slow way, for line nos */ -+ while (curwp->w_dotp != curwp->w_linep) { -+ curwp->w_dotp = lforw(curwp->w_dotp); -+ curwp->w_dotline++; -+ } -+ curwp->w_doto = 0; -+ return (TRUE); -+} -+ -+/* -+ * This command is like "forwpage", -+ * but it goes backwards. The "2", like above, -+ * is the overlap between the two windows. The -+ * value is from the ITS EMACS manual. The -+ * hard update is done because the top line in -+ * the window is zapped. -+ */ -+/* ARGSUSED */ -+int -+backpage(int f, int n) -+{ -+ struct line *lp, *lp2; -+ -+ if (!(f & FFARG)) { -+ n = curwp->w_ntrows - 2; /* Default scroll. */ -+ if (n <= 0) /* Don't blow up if the */ -+ return (backline(f, 1));/* window is tiny. */ -+ } else if (n < 0) -+ return (forwpage(f | FFRAND, -n)); -+ -+ lp = lp2 = curwp->w_linep; -+ -+ while (n-- && lback(lp) != curbp->b_headp) { -+ lp = lback(lp); -+ } -+ if (lp == curwp->w_linep) { -+ dobeep(); -+ ewprintf("Beginning of buffer"); -+ } -+ curwp->w_linep = lp; -+ curwp->w_rflag |= WFFULL; -+ -+ /* if in current window, don't move dot */ -+ for (n = curwp->w_ntrows; n-- && lp != curbp->b_headp; lp = lforw(lp)) -+ if (lp == curwp->w_dotp) -+ return (TRUE); -+ -+ lp2 = lforw(lp2); -+ -+ /* Move the dot the slow way, for line nos */ -+ while (curwp->w_dotp != lp2) { -+ if (curwp->w_dotline <= curwp->w_ntrows) -+ goto out; -+ curwp->w_dotp = lback(curwp->w_dotp); -+ curwp->w_dotline--; -+ } -+out: -+ curwp->w_doto = 0; -+ return (TRUE); -+} -+ -+/* -+ * These functions are provided for compatibility with Gosling's Emacs. They -+ * are used to scroll the display up (or down) one line at a time. -+ */ -+int -+forw1page(int f, int n) -+{ -+ if (!(f & FFARG)) { -+ n = 1; -+ f = FFUNIV; -+ } -+ forwpage(f | FFRAND, n); -+ return (TRUE); -+} -+ -+int -+back1page(int f, int n) -+{ -+ if (!(f & FFARG)) { -+ n = 1; -+ f = FFUNIV; -+ } -+ backpage(f | FFRAND, n); -+ return (TRUE); -+} -+ -+/* -+ * Page the other window. Check to make sure it exists, then -+ * nextwind, forwpage and restore window pointers. -+ */ -+int -+pagenext(int f, int n) -+{ -+ struct mgwin *wp; -+ -+ if (wheadp->w_wndp == NULL) { -+ dobeep(); -+ ewprintf("No other window"); -+ return (FALSE); -+ } -+ wp = curwp; -+ (void) nextwind(f, n); -+ (void) forwpage(f, n); -+ curwp = wp; -+ curbp = wp->w_bufp; -+ return (TRUE); -+} -+ -+/* -+ * Internal set mark routine, used by other functions (daveb). -+ */ -+void -+isetmark(void) -+{ -+ curwp->w_markp = curwp->w_dotp; -+ curwp->w_marko = curwp->w_doto; -+ curwp->w_markline = curwp->w_dotline; -+} -+ -+/* -+ * Set the mark in the current window -+ * to the value of dot. A message is written to -+ * the echo line. (ewprintf knows about macros) -+ */ -+/* ARGSUSED */ -+int -+setmark(int f, int n) -+{ -+ isetmark(); -+ ewprintf("Mark set"); -+ return (TRUE); -+} -+ -+/* Clear the mark, if set. */ -+/* ARGSUSED */ -+int -+clearmark(int f, int n) -+{ -+ if (!curwp->w_markp) -+ return (FALSE); -+ -+ curwp->w_markp = NULL; -+ curwp->w_marko = 0; -+ curwp->w_markline = 0; -+ -+ return (TRUE); -+} -+ -+/* -+ * Swap the values of "dot" and "mark" in -+ * the current window. This is pretty easy, because -+ * all of the hard work gets done by the standard routine -+ * that moves the mark about. The only possible -+ * error is "no mark". -+ */ -+/* ARGSUSED */ -+int -+swapmark(int f, int n) -+{ -+ struct line *odotp; -+ int odoto, odotline; -+ -+ if (curwp->w_markp == NULL) { -+ dobeep(); -+ ewprintf("No mark in this window"); -+ return (FALSE); -+ } -+ odotp = curwp->w_dotp; -+ odoto = curwp->w_doto; -+ odotline = curwp->w_dotline; -+ curwp->w_dotp = curwp->w_markp; -+ curwp->w_doto = curwp->w_marko; -+ curwp->w_dotline = curwp->w_markline; -+ curwp->w_markp = odotp; -+ curwp->w_marko = odoto; -+ curwp->w_markline = odotline; -+ curwp->w_rflag |= WFMOVE; -+ return (TRUE); -+} -+ -+/* -+ * Go to a specific line, mostly for -+ * looking up errors in C programs, which give the -+ * error a line number. If an argument is present, then -+ * it is the line number, else prompt for a line number -+ * to use. -+ */ -+/* ARGSUSED */ -+int -+gotoline(int f, int n) -+{ -+ char buf[32], *bufp; -+ const char *err; -+ -+ if (!(f & FFARG)) { -+ if ((bufp = eread("Goto line: ", buf, sizeof(buf), -+ EFNUL | EFNEW | EFCR)) == NULL) -+ return (ABORT); -+ if (bufp[0] == '\0') -+ return (ABORT); -+ n = (int)strtonum(buf, INT_MIN, INT_MAX, &err); -+ if (err) { -+ dobeep(); -+ ewprintf("Line number %s", err); -+ return (FALSE); -+ } -+ } -+ return(setlineno(n)); -+} -+ -+/* -+ * Set the line number and switch to it. -+ */ -+int -+setlineno(int n) -+{ -+ struct line *clp; -+ -+ if (n >= 0) { -+ if (n == 0) -+ n++; -+ curwp->w_dotline = n; -+ clp = lforw(curbp->b_headp); /* "clp" is first line */ -+ while (--n > 0) { -+ if (lforw(clp) == curbp->b_headp) { -+ curwp->w_dotline = curwp->w_bufp->b_lines; -+ break; -+ } -+ clp = lforw(clp); -+ } -+ } else { -+ curwp->w_dotline = curwp->w_bufp->b_lines + n; -+ clp = lback(curbp->b_headp); /* "clp" is last line */ -+ while (n < 0) { -+ if (lback(clp) == curbp->b_headp) { -+ curwp->w_dotline = 1; -+ break; -+ } -+ clp = lback(clp); -+ n++; -+ } -+ } -+ curwp->w_dotp = clp; -+ curwp->w_doto = 0; -+ curwp->w_rflag |= WFMOVE; -+ return (TRUE); -+} diff -Naur a/cscope.c b/cscope.c --- a/cscope.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/cscope.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/cscope.c 2020-04-21 19:01:59.000000000 +0100 @@ -20,6 +20,9 @@ #include <string.h> #include <unistd.h> @@ -840,7 +131,7 @@ diff -Naur a/cscope.c b/cscope.c #define CSSYMBOL 0 diff -Naur a/display.c b/display.c --- a/display.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/display.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/display.c 2020-04-21 19:01:59.000000000 +0100 @@ -19,6 +19,9 @@ #include <string.h> #include <term.h> @@ -853,7 +144,7 @@ diff -Naur a/display.c b/display.c diff -Naur a/fileio.c b/fileio.c --- a/fileio.c 2020-04-20 21:09:41.000000000 +0100 -+++ b/fileio.c 2020-04-20 21:26:10.000000000 +0100 ++++ b/fileio.c 2020-04-21 19:01:59.000000000 +0100 @@ -22,19 +22,13 @@ #include <stdlib.h> #include <string.h> @@ -913,774 +204,9 @@ diff -Naur a/fileio.c b/fileio.c ewprintf("Path too long"); return (NULL); } -diff -Naur a/fileio.c.orig b/fileio.c.orig ---- a/fileio.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ b/fileio.c.orig 2020-04-20 21:26:06.000000000 +0100 -@@ -0,0 +1,761 @@ -+/* $OpenBSD: fileio.c,v 1.106 2019/06/22 10:21:57 lum Exp $ */ -+ -+/* This file is in the public domain. */ -+ -+/* -+ * POSIX fileio.c -+ */ -+ -+#include <sys/queue.h> -+#include <sys/resource.h> -+#include <sys/stat.h> -+#include <sys/time.h> -+#include <sys/types.h> -+#include <sys/wait.h> -+#include <dirent.h> -+#include <errno.h> -+#include <fcntl.h> -+#include <limits.h> -+#include <pwd.h> -+#include <signal.h> -+#include <stdio.h> -+#include <stdlib.h> -+#include <string.h> -+#include <unistd.h> -+ -+#include "def.h" -+#include "kbd.h" -+#include "pathnames.h" -+ -+#ifndef MAXNAMLEN -+#define MAXNAMLEN 255 -+#endif -+ -+#ifndef DEFFILEMODE -+#define DEFFILEMODE 0666 -+#endif -+ -+static char *bkuplocation(const char *); -+static int bkupleavetmp(const char *); -+ -+static char *bkupdir; -+static int leavetmp = 0; /* 1 = leave any '~' files in tmp dir */ -+ -+/* -+ * Open a file for reading. -+ */ -+int -+ffropen(FILE ** ffp, const char *fn, struct buffer *bp) -+{ -+ if ((*ffp = fopen(fn, "r")) == NULL) { -+ if (errno == ENOENT) -+ return (FIOFNF); -+ return (FIOERR); -+ } -+ -+ /* If 'fn' is a directory open it with dired. */ -+ if (fisdir(fn) == TRUE) -+ return (FIODIR); -+ -+ ffstat(*ffp, bp); -+ -+ return (FIOSUC); -+} -+ -+/* -+ * Update stat/dirty info -+ */ -+void -+ffstat(FILE *ffp, struct buffer *bp) -+{ -+ struct stat sb; -+ -+ if (bp && fstat(fileno(ffp), &sb) == 0) { -+ /* set highorder bit to make sure this isn't all zero */ -+ bp->b_fi.fi_mode = sb.st_mode | 0x8000; -+ bp->b_fi.fi_uid = sb.st_uid; -+ bp->b_fi.fi_gid = sb.st_gid; -+ /* bp->b_fi.fi_mtime = sb.st_mtimespec; */ -+ bp->b_fi.fi_mtime.tv_sec = sb.st_mtime; -+ bp->b_fi.fi_mtime.tv_nsec = 0; -+ /* Clear the ignore flag */ -+ bp->b_flag &= ~(BFIGNDIRTY | BFDIRTY); -+ } -+} -+ -+/* -+ * Update the status/dirty info. If there is an error, -+ * there's not a lot we can do. -+ */ -+int -+fupdstat(struct buffer *bp) -+{ -+ FILE *ffp; -+ -+ if ((ffp = fopen(bp->b_fname, "r")) == NULL) { -+ if (errno == ENOENT) -+ return (FIOFNF); -+ return (FIOERR); -+ } -+ ffstat(ffp, bp); -+ (void)ffclose(ffp, bp); -+ return (FIOSUC); -+} -+ -+/* -+ * Open a file for writing. -+ */ -+int -+ffwopen(FILE ** ffp, const char *fn, struct buffer *bp) -+{ -+ int fd; -+ mode_t fmode = DEFFILEMODE; -+ -+ if (bp && bp->b_fi.fi_mode) -+ fmode = bp->b_fi.fi_mode & 07777; -+ -+ fd = open(fn, O_RDWR | O_CREAT | O_TRUNC, fmode); -+ if (fd == -1) { -+ ffp = NULL; -+ dobeep(); -+ ewprintf("Cannot open file for writing : %s", strerror(errno)); -+ return (FIOERR); -+ } -+ -+ if ((*ffp = fdopen(fd, "w")) == NULL) { -+ dobeep(); -+ ewprintf("Cannot open file for writing : %s", strerror(errno)); -+ close(fd); -+ return (FIOERR); -+ } -+ -+ /* -+ * If we have file information, use it. We don't bother to check for -+ * errors, because there's no a lot we can do about it. Certainly -+ * trying to change ownership will fail if we aren't root. That's -+ * probably OK. If we don't have info, no need to get it, since any -+ * future writes will do the same thing. -+ */ -+ if (bp && bp->b_fi.fi_mode) { -+ fchmod(fd, bp->b_fi.fi_mode & 07777); -+ fchown(fd, bp->b_fi.fi_uid, bp->b_fi.fi_gid); -+ } -+ return (FIOSUC); -+} -+ -+/* -+ * Close a file. -+ */ -+/* ARGSUSED */ -+int -+ffclose(FILE *ffp, struct buffer *bp) -+{ -+ if (fclose(ffp) == 0) -+ return (FIOSUC); -+ return (FIOERR); -+} -+ -+/* -+ * Write a buffer to the already opened file. bp points to the -+ * buffer. Return the status. -+ */ -+int -+ffputbuf(FILE *ffp, struct buffer *bp, int eobnl) -+{ -+ struct line *lp, *lpend; -+ -+ lpend = bp->b_headp; -+ -+ for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) { -+ if (fwrite(ltext(lp), 1, llength(lp), ffp) != llength(lp)) { -+ dobeep(); -+ ewprintf("Write I/O error"); -+ return (FIOERR); -+ } -+ if (lforw(lp) != lpend) /* no implied \n on last line */ -+ putc('\n', ffp); -+ } -+ if (eobnl) { -+ lnewline_at(lback(lpend), llength(lback(lpend))); -+ putc('\n', ffp); -+ } -+ return (FIOSUC); -+} -+ -+/* -+ * Read a line from a file, and store the bytes -+ * in the supplied buffer. Stop on end of file or end of -+ * line. When FIOEOF is returned, there is a valid line -+ * of data without the normally implied \n. -+ * If the line length exceeds nbuf, FIOLONG is returned. -+ */ -+int -+ffgetline(FILE *ffp, char *buf, int nbuf, int *nbytes) -+{ -+ int c, i; -+ -+ i = 0; -+ while ((c = getc(ffp)) != EOF && c != '\n') { -+ buf[i++] = c; -+ if (i >= nbuf) -+ return (FIOLONG); -+ } -+ if (c == EOF && ferror(ffp) != FALSE) { -+ dobeep(); -+ ewprintf("File read error"); -+ return (FIOERR); -+ } -+ *nbytes = i; -+ return (c == EOF ? FIOEOF : FIOSUC); -+} -+ -+/* -+ * Make a backup copy of "fname". On Unix the backup has the same -+ * name as the original file, with a "~" on the end; this seems to -+ * be newest of the new-speak. The error handling is all in "file.c". -+ * We do a copy instead of a rename since otherwise another process -+ * with an open fd will get the backup, not the new file. This is -+ * a problem when using mg with things like crontab and vipw. -+ */ -+int -+fbackupfile(const char *fn) -+{ -+ struct stat sb; -+ struct timespec new_times[2]; -+ int from, to, serrno; -+ ssize_t nread; -+ char buf[BUFSIZ]; -+ char *nname, *tname, *bkpth; -+ -+ if (stat(fn, &sb) == -1) { -+ dobeep(); -+ ewprintf("Can't stat %s : %s", fn, strerror(errno)); -+ return (FALSE); -+ } -+ -+ if ((bkpth = bkuplocation(fn)) == NULL) -+ return (FALSE); -+ -+ if (asprintf(&nname, "%s~", bkpth) == -1) { -+ dobeep(); -+ ewprintf("Can't allocate backup file name : %s", strerror(errno)); -+ free(bkpth); -+ return (ABORT); -+ } -+ if (asprintf(&tname, "%s.XXXXXXXXXX", bkpth) == -1) { -+ dobeep(); -+ ewprintf("Can't allocate temp file name : %s", strerror(errno)); -+ free(bkpth); -+ free(nname); -+ return (ABORT); -+ } -+ free(bkpth); -+ -+ if ((from = open(fn, O_RDONLY)) == -1) { -+ free(nname); -+ free(tname); -+ return (FALSE); -+ } -+ to = mkstemp(tname); -+ if (to == -1) { -+ serrno = errno; -+ close(from); -+ free(nname); -+ free(tname); -+ errno = serrno; -+ return (FALSE); -+ } -+ while ((nread = read(from, buf, sizeof(buf))) > 0) { -+ if (write(to, buf, (size_t)nread) != nread) { -+ nread = -1; -+ break; -+ } -+ } -+ serrno = errno; -+ (void) fchmod(to, (sb.st_mode & 0777)); -+ -+ /* copy the mtime to the backupfile */ -+ new_times[0] = sb.st_atim; -+ new_times[1] = sb.st_mtim; -+ futimens(to, new_times); -+ -+ close(from); -+ close(to); -+ if (nread == -1) { -+ if (unlink(tname) == -1) -+ ewprintf("Can't unlink temp : %s", strerror(errno)); -+ } else { -+ if (rename(tname, nname) == -1) { -+ ewprintf("Can't rename temp : %s", strerror(errno)); -+ (void) unlink(tname); -+ nread = -1; -+ } -+ } -+ free(nname); -+ free(tname); -+ errno = serrno; -+ -+ return (nread == -1 ? FALSE : TRUE); -+} -+ -+/* -+ * Convert "fn" to a canonicalized absolute filename, replacing -+ * a leading ~/ with the user's home dir, following symlinks, and -+ * remove all occurrences of /./ and /../ -+ */ -+char * -+adjustname(const char *fn, int slashslash) -+{ -+ static char fnb[PATH_MAX]; -+ const char *cp, *ep = NULL; -+ char *path; -+ -+ if (slashslash == TRUE) { -+ cp = fn + strlen(fn) - 1; -+ for (; cp >= fn; cp--) { -+ if (ep && (*cp == '/')) { -+ fn = ep; -+ break; -+ } -+ if (*cp == '/' || *cp == '~') -+ ep = cp; -+ else -+ ep = NULL; -+ } -+ } -+ if ((path = expandtilde(fn)) == NULL) -+ return (NULL); -+ -+ if (realpath(path, fnb) == NULL) -+ (void)strlcpy(fnb, path, sizeof(fnb)); -+ -+ free(path); -+ return (fnb); -+} -+ -+/* -+ * Find a startup file for the user and return its name. As a service -+ * to other pieces of code that may want to find a startup file (like -+ * the terminal driver in particular), accepts a suffix to be appended -+ * to the startup file name. -+ */ -+char * -+startupfile(char *suffix) -+{ -+ static char file[NFILEN]; -+ char *home; -+ int ret; -+ -+ if ((home = getenv("HOME")) == NULL || *home == '\0') -+ goto nohome; -+ -+ if (suffix == NULL) { -+ ret = snprintf(file, sizeof(file), _PATH_MG_STARTUP, home); -+ if (ret < 0 || ret >= sizeof(file)) -+ return (NULL); -+ } else { -+ ret = snprintf(file, sizeof(file), _PATH_M |