pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/editors/mg



Module Name:    pkgsrc
Committed By:   jperkin
Date:           Fri May 23 09:28:50 UTC 2025

Modified Files:
        pkgsrc/editors/mg: Makefile distinfo
        pkgsrc/editors/mg/patches: patch-GNUmakefile patch-af
Added Files:
        pkgsrc/editors/mg/patches: patch-fileio.c patch-openpty.c

Log Message:
mg: Various portability fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 pkgsrc/editors/mg/Makefile
cvs rdiff -u -r1.18 -r1.19 pkgsrc/editors/mg/distinfo
cvs rdiff -u -r1.3 -r1.4 pkgsrc/editors/mg/patches/patch-GNUmakefile
cvs rdiff -u -r1.4 -r1.5 pkgsrc/editors/mg/patches/patch-af
cvs rdiff -u -r0 -r1.1 pkgsrc/editors/mg/patches/patch-fileio.c \
    pkgsrc/editors/mg/patches/patch-openpty.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/editors/mg/Makefile
diff -u pkgsrc/editors/mg/Makefile:1.22 pkgsrc/editors/mg/Makefile:1.23
--- pkgsrc/editors/mg/Makefile:1.22     Mon Sep  2 17:15:26 2024
+++ pkgsrc/editors/mg/Makefile  Fri May 23 09:28:50 2025
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.22 2024/09/02 17:15:26 gutteridge Exp $
+# $NetBSD: Makefile,v 1.23 2025/05/23 09:28:50 jperkin Exp $
 
 DISTNAME=      mg-20240709
 CATEGORIES=    editors
@@ -13,7 +13,7 @@ LICENSE=      public-domain
 
 #FAKE_NCURSES= yes
 USE_TOOLS+=    install gmake pkg-config
-MAKE_ENV+=     prefix=${PREFIX}
+MAKE_ENV+=     prefix=${PREFIX} INSTALL=${INSTALL:Q}
 MAKE_FILE=     GNUmakefile
 
 CFLAGS.NetBSD+=        -D_OPENBSD_SOURCE
@@ -41,7 +41,7 @@ post-extract:
 pre-install:
        ${INSTALL_DATA} ${WRKSRC}/tutorial ${DESTDIR}${PREFIX}/share/doc/${PKGBASE}/tutorial
 
-.if ${OPSYS} == "Linux"
+.if ${OPSYS} == "Linux" || ${OPSYS} == "SunOS"
 .include "../../devel/libbsd/buildlink3.mk"
 .endif
 .include "../../devel/ncurses/buildlink3.mk"

Index: pkgsrc/editors/mg/distinfo
diff -u pkgsrc/editors/mg/distinfo:1.18 pkgsrc/editors/mg/distinfo:1.19
--- pkgsrc/editors/mg/distinfo:1.18     Mon Sep  2 17:15:26 2024
+++ pkgsrc/editors/mg/distinfo  Fri May 23 09:28:50 2025
@@ -1,11 +1,13 @@
-$NetBSD: distinfo,v 1.18 2024/09/02 17:15:26 gutteridge Exp $
+$NetBSD: distinfo,v 1.19 2025/05/23 09:28:50 jperkin Exp $
 
 BLAKE2s (mg-20240709-20240709.tar.gz) = a823ab171ddd7d2be4f8c21266244acac1896d4306171be4949af37f175757d4
 SHA512 (mg-20240709-20240709.tar.gz) = 1715f3378059c995cffd9b7e6f8d237cdbae43e67516542c9ef3a5d30c7d0b78183bce1f21db6570877261c2804258f664199b4a46febbf2c10ec25e08833926
 Size (mg-20240709-20240709.tar.gz) = 159302 bytes
-SHA1 (patch-GNUmakefile) = ec7a636e40a7d307333d9f1da03be3888a88ec26
-SHA1 (patch-af) = 678983bc292b41a2d67f969182bc377a47b89d2b
+SHA1 (patch-GNUmakefile) = be73e37d61abd86a33785db52cee82dd64ab58b0
+SHA1 (patch-af) = ffb9e155564654c5a3204800d22ac5bd78ca6315
 SHA1 (patch-def.h) = fa27b6e7d45c5fcd0f48490e3f515602095cdbd6
+SHA1 (patch-fileio.c) = d0f004976a3e6423556c925704b0edfaf0ddbeda
+SHA1 (patch-openpty.c) = 3066c9ac22fee18d4ed0d7ed5fa896581b964811
 SHA1 (patch-paragraph.c) = d68754b802c99fecb63a6cfa634f0360945f034f
 SHA1 (patch-tags.c) = 1f7bbaf75a8cced86499bc5f8f6426fc6fa1232a
 SHA1 (patch-ttyio.c) = 125cbdf461aec3f629340affc3c9f600bb9d7102

Index: pkgsrc/editors/mg/patches/patch-GNUmakefile
diff -u pkgsrc/editors/mg/patches/patch-GNUmakefile:1.3 pkgsrc/editors/mg/patches/patch-GNUmakefile:1.4
--- pkgsrc/editors/mg/patches/patch-GNUmakefile:1.3     Fri Dec  8 00:03:44 2023
+++ pkgsrc/editors/mg/patches/patch-GNUmakefile Fri May 23 09:28:50 2025
@@ -1,11 +1,16 @@
-$NetBSD: patch-GNUmakefile,v 1.3 2023/12/08 00:03:44 tnn Exp $
+$NetBSD: patch-GNUmakefile,v 1.4 2025/05/23 09:28:50 jperkin Exp $
 
+Support PKGMANDIR.
+Support more operating systems.
 
---- GNUmakefile.orig   2023-05-01 15:27:50.000000000 +0000
+--- GNUmakefile.orig   2024-07-09 15:39:50.000000000 +0000
 +++ GNUmakefile
-@@ -13,14 +13,20 @@ libdir=            $(prefix)/lib
+@@ -11,16 +11,26 @@ prefix=            /usr/local
+ bindir=               $(prefix)/bin
+ libdir=               $(prefix)/lib
  includedir=   $(prefix)/include
- mandir=               $(prefix)/man
+-mandir=               $(prefix)/man
++mandir=               $(prefix)/$(PKGMANDIR)
  
 -PKG_CONFIG=   /usr/bin/pkg-config --silence-errors
 -INSTALL=      /usr/bin/install
@@ -24,6 +29,19 @@ $NetBSD: patch-GNUmakefile,v 1.3 2023/12
 +else ifeq ($(UNAME),Darwin)
 +  BSD_CPPFLAGS:= -DHAVE_UTIL_H
 +  BSD_LIBS:=   -lutil
++else ifeq ($(UNAME),SunOS)
++  BSD_CPPFLAGS:= $(shell $(PKG_CONFIG) --cflags libbsd-overlay)
++  BSD_LIBS:=   $(shell $(PKG_CONFIG) --libs libbsd-overlay) -lsocket
++  OBJS:=         openpty.o
  else
    BSD_CPPFLAGS:= $(shell $(PKG_CONFIG) --cflags libbsd-overlay) -DHAVE_PTY_H
    BSD_LIBS:=   $(shell $(PKG_CONFIG) --libs libbsd-overlay) -lutil
+@@ -51,7 +61,7 @@ CPPFLAGS+=   $(BSD_CPPFLAGS)
+ LIBS=         $(CURSES_LIBS) $(BSD_LIBS)
+ 
+ 
+-OBJS= autoexec.o basic.o bell.o buffer.o cinfo.o dir.o display.o \
++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 \

Index: pkgsrc/editors/mg/patches/patch-af
diff -u pkgsrc/editors/mg/patches/patch-af:1.4 pkgsrc/editors/mg/patches/patch-af:1.5
--- pkgsrc/editors/mg/patches/patch-af:1.4      Tue Apr 25 21:53:01 2023
+++ pkgsrc/editors/mg/patches/patch-af  Fri May 23 09:28:50 2025
@@ -1,10 +1,10 @@
-$NetBSD: patch-af,v 1.4 2023/04/25 21:53:01 nikita Exp $
+$NetBSD: patch-af,v 1.5 2025/05/23 09:28:50 jperkin Exp $
 
-Include limits.h for INT_{MIN,MAX}
+Unsigned char fixes.
 
---- grep.c.orig        2011-01-02 22:57:56.000000000 +0000
+--- grep.c.orig        2024-07-09 15:39:50.000000000 +0000
 +++ grep.c
-@@ -152,7 +153,7 @@ gid(int f, int n)
+@@ -130,7 +130,7 @@ gid(int f, int n)
        /* Skip backwards over delimiters we are currently on */
        while (i > 0) {
                c = lgetc(curwp->w_dotp, i);
@@ -13,7 +13,7 @@ Include limits.h for INT_{MIN,MAX}
                        break;
  
                i--;
-@@ -161,14 +162,14 @@ gid(int f, int n)
+@@ -139,14 +139,14 @@ gid(int f, int n)
        /* Skip the symbol itself */
        for (; i > 0; i--) {
                c = lgetc(curwp->w_dotp, i - 1);

Added files:

Index: pkgsrc/editors/mg/patches/patch-fileio.c
diff -u /dev/null pkgsrc/editors/mg/patches/patch-fileio.c:1.1
--- /dev/null   Fri May 23 09:28:50 2025
+++ pkgsrc/editors/mg/patches/patch-fileio.c    Fri May 23 09:28:50 2025
@@ -0,0 +1,36 @@
+$NetBSD: patch-fileio.c,v 1.1 2025/05/23 09:28:50 jperkin Exp $
+
+Support systems that lack DT_DIR and friends.
+
+--- fileio.c.orig      2025-05-23 08:08:06.411929386 +0000
++++ fileio.c
+@@ -528,21 +528,28 @@ make_file_list(char *buf)
+       last = NULL;
+ 
+       while ((dent = readdir(dirp)) != NULL) {
++              struct stat statbuf;
+               int isdir;
+               if (strncmp(cp, dent->d_name, len) != 0)
+                       continue;
+               isdir = 0;
++#ifdef DT_DIR
+               if (dent->d_type == DT_DIR) {
+                       isdir = 1;
+               } else if (dent->d_type == DT_LNK ||
+                           dent->d_type == DT_UNKNOWN) {
+-                      struct stat     statbuf;
+ 
+                       if (fstatat(dirfd(dirp), dent->d_name, &statbuf, 0) < 0)
+                               continue;
+                       if (S_ISDIR(statbuf.st_mode))
+                               isdir = 1;
+               }
++#else
++              if (fstatat(dirfd(dirp), dent->d_name, &statbuf, 0) < 0)
++                      continue;
++              if (S_ISDIR(statbuf.st_mode))
++                      isdir = 1;
++#endif                
+ 
+               if ((current = malloc(sizeof(struct list))) == NULL) {
+                       free_file_list(last);
Index: pkgsrc/editors/mg/patches/patch-openpty.c
diff -u /dev/null pkgsrc/editors/mg/patches/patch-openpty.c:1.1
--- /dev/null   Fri May 23 09:28:50 2025
+++ pkgsrc/editors/mg/patches/patch-openpty.c   Fri May 23 09:28:50 2025
@@ -0,0 +1,182 @@
+$NetBSD: patch-openpty.c,v 1.1 2025/05/23 09:28:50 jperkin Exp $
+
+Implement openpty() for illumos.  Based on jclulow's patches for neovim.
+
+--- openpty.c.orig     2025-05-23 08:50:01.278615842 +0000
++++ openpty.c
+@@ -0,0 +1,175 @@
++#include <sys/types.h>
++#include <sys/termios.h>
++#include <stdlib.h>
++#include <fcntl.h>
++#include <unistd.h>
++#include <stropts.h>
++#include <strings.h>
++#include <errno.h>
++
++static int
++openpty_failure(int c, int s, int e)
++{
++      if (s >= 0) {
++              (void) close(s);
++      }
++
++      if (c >= 0) {
++              (void) close(c);
++      }
++
++      errno = e;
++      return (-1);
++}
++
++int
++openpty(int *controlp, int *subordp, char *name, const struct termios *termp,
++    const struct winsize *winp)
++{
++      int c = -1;
++      int s = -1;
++      char *sname;
++      int found;
++
++      /*
++       * Open a pseudo-terminal control device, making sure not to set it as
++       * the controlling terminal for this process:
++       */
++      if ((c = posix_openpt(O_RDWR | O_NOCTTY)) < 0) {
++              return (-1);
++      }
++
++      /*
++       * Set permissions and ownership on the subordinate device and unlock
++       * it:
++       */
++      if (grantpt(c) < 0 || unlockpt(c) < 0) {
++              return (openpty_failure(c, s, errno));
++      }
++
++      /*
++       * Open the subordinate device for this control device, again without
++       * setting it as the controlling terminal for this process:
++       */
++      if ((sname = ptsname(c)) == NULL ||
++          (s = open(sname, O_RDWR | O_NOCTTY)) < 0) {
++              return (openpty_failure(c, s, errno));
++      }
++
++      /*
++       * Check to see if the STREAMS modules have been automatically pushed:
++       */
++      if ((found = ioctl(s, I_FIND, "ldterm")) < 0) {
++              return (openpty_failure(c, s, errno));
++      } else if (found == 0) {
++              /*
++               * The line discipline is not present, so push the appropriate
++               * STREAMS modules for the subordinate device:
++               */
++              if (ioctl(s, __I_PUSH_NOCTTY, "ptem") < 0 ||
++                  ioctl(s, __I_PUSH_NOCTTY, "ldterm") < 0) {
++                      return (openpty_failure(c, s, errno));
++              }
++      }
++
++      /*
++       * If provided, set the terminal parameters:
++       */
++      if (termp != NULL && tcsetattr(s, TCSAFLUSH, termp) != 0) {
++              return (openpty_failure(c, s, errno));
++      }
++
++      /*
++       * If provided, set the window size:
++       */
++      if (winp != NULL && ioctl(s, TIOCSWINSZ, winp) != 0) {
++              return (openpty_failure(c, s, errno));
++      }
++
++      /*
++       * If the caller wants the name of the subordinate device, copy it out.
++       *
++       * Note that this is a terrible interface: there appears to be no
++       * standard upper bound on the copy length for this pointer.  Nobody
++       * should pass anything but NULL here, preferring instead to use
++       * ptsname(3C) directly.
++       */
++      if (name != NULL) {
++              strcpy(name, sname);
++      }
++      *controlp = c;
++      *subordp = s;
++      return (0);
++}
++
++int
++login_tty(int t)
++{
++      /*
++       * Use TIOCSCTTY to set this terminal device as our controlling
++       * terminal.  This will fail (with ENOTTY) if we are not the leader in
++       * our own session, so we call setsid() first.  Finally, arrange for
++       * the pseudo-terminal to occupy the standard I/O descriptors.
++       */
++      if (setsid() < 0 ||
++          ioctl(t, TIOCSCTTY, 0) < 0 ||
++          dup2(t, STDIN_FILENO) < 0 ||
++          dup2(t, STDOUT_FILENO) < 0 ||
++          dup2(t, STDERR_FILENO) < 0) {
++              return (-1);
++      }
++
++      /*
++       * Close the inherited descriptor, taking care to avoid closing the
++       * standard descriptors by mistake:
++       */
++      if (t > STDERR_FILENO) {
++              (void) close(t);
++      }
++
++      return (0);
++}
++
++int
++forkpty(int *controlp, char *name, const struct termios *termp,
++    const struct winsize *winp)
++{
++      int s;
++      int c;
++      int pid;
++      if (openpty(&c, &s, name, termp, winp) != 0) {
++              return (-1);
++      }
++      if ((pid = fork()) < 0) {
++              return (openpty_failure(c, s, errno));
++      } else if (pid > 0) {
++              /*
++               * In the parent process, we close the subordinate device and
++               * return the process ID of the new child:
++               */
++              (void) close(s);
++              *controlp = c;
++              return (pid);
++      }
++
++      /*
++       * The rest of this function executes in the child process.
++       */
++
++      /*
++       * Close the control side of the pseudo-terminal pair:
++       */
++      (void) close(c);
++
++      if (login_tty(s) != 0) {
++              /*
++               * At this stage there are no particularly good ways to handle
++               * failure.  Exit as abruptly as possible, using _exit() to
++               * avoid messing with any state still shared with the parent
++               * process.
++               */
++              _exit(EXIT_FAILURE);
++      }
++
++      return (0);
++}



Home | Main Index | Thread Index | Old Index