Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package yank for openSUSE:Factory checked in 
at 2026-10-20 12:40:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yank (Old)
 and      /work/SRC/openSUSE:Factory/.yank.new.3698736 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yank"

Tue Oct 20 12:40:10 2026 rev:5 rq:1386226 version:1.4.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/yank/yank.changes        2022-12-01 
17:22:10.182543824 +0100
+++ /work/SRC/openSUSE:Factory/.yank.new.3698736/yank.changes   2026-10-20 
12:41:32.334566720 +0200
@@ -1,0 +2,7 @@
+Sun Oct 18 09:35:55 UTC 2026 - Dirk Müller <[email protected]>
+
+- update to 1.4.0:
+  * Add Ctrl+L to toggle between current delimiter and line
+    delimiter.
+
+-------------------------------------------------------------------

Old:
----
  yank-1.3.0.tar.gz

New:
----
  yank-1.4.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yank.spec ++++++
--- /var/tmp/diff_new_pack.r2dBO6/_old  2026-10-20 12:41:33.633621088 +0200
+++ /var/tmp/diff_new_pack.r2dBO6/_new  2026-10-20 12:41:33.635621171 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package yank
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2026 SUSE LLC and contributors
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           yank
-Version:        1.3.0
+Version:        1.4.0
 Release:        0
 Summary:        Tool for selecting and copying text from stdin without a mouse
 License:        MIT

++++++ yank-1.3.0.tar.gz -> yank-1.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/.clang-format new/yank-1.4.0/.clang-format
--- old/yank-1.3.0/.clang-format        1970-01-01 01:00:00.000000000 +0100
+++ new/yank-1.4.0/.clang-format        2026-07-16 20:26:03.000000000 +0200
@@ -0,0 +1,19 @@
+---
+BasedOnStyle: OpenBSD
+ColumnLimit: 100
+IncludeBlocks: Regroup
+IncludeCategories:
+  - Regex: '^"config\.h"'
+    Priority: 1
+  - Regex: '^<sys/types\.h'
+    Priority: 2
+    SortPriority: 0
+  - Regex: '^<sys/'
+    Priority: 2
+  - Regex: '^<'
+    Priority: 3
+  - Regex: '^"libks/'
+    Priority: 4
+  - Regex: '^"'
+    Priority: 5
+...
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/.valgrindrc new/yank-1.4.0/.valgrindrc
--- old/yank-1.3.0/.valgrindrc  1970-01-01 01:00:00.000000000 +0100
+++ new/yank-1.4.0/.valgrindrc  2026-07-16 20:26:03.000000000 +0200
@@ -0,0 +1,6 @@
+--memcheck:quiet
+--memcheck:child-silent-after-fork=yes
+--memcheck:error-exitcode=1
+--memcheck:errors-for-leak-kinds=all
+--memcheck:leak-check=full
+--memcheck:show-leak-kinds=all
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/CHANGELOG.md new/yank-1.4.0/CHANGELOG.md
--- old/yank-1.3.0/CHANGELOG.md 2022-06-18 08:25:45.000000000 +0200
+++ new/yank-1.4.0/CHANGELOG.md 2026-07-16 20:26:03.000000000 +0200
@@ -1,3 +1,11 @@
+# 1.4.0 - 2026-07-16
+
+## News
+
+- Add Ctrl+L to toggle between current delimiter and line delimiter.
+  (589709d9c549)
+  (Aurélien Buchet)
+
 # v1.3.0 - 2022-06-18
 
 ## News
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/LICENSE new/yank-1.4.0/LICENSE
--- old/yank-1.3.0/LICENSE      2022-06-18 08:25:45.000000000 +0200
+++ new/yank-1.4.0/LICENSE      2026-07-16 20:26:03.000000000 +0200
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2022 Anton Lindqvist
+Copyright (c) 2026 Anton Lindqvist
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/Makefile new/yank-1.4.0/Makefile
--- old/yank-1.3.0/Makefile     2022-06-18 08:25:45.000000000 +0200
+++ new/yank-1.4.0/Makefile     2026-07-16 20:26:03.000000000 +0200
@@ -1,4 +1,4 @@
-VERSION=       1.3.0
+VERSION=       1.4.0
 
 YANKCMD=       xsel
 
@@ -10,11 +10,26 @@
 
 KNFMT+=        yank.c
 
+CPPCHECK+=     yank.c
+
+CPPCHECKFLAGS+=        --quiet
+CPPCHECKFLAGS+=        --check-level=exhaustive
+CPPCHECKFLAGS+=        --enable=all
+CPPCHECKFLAGS+=        --error-exitcode=1
+CPPCHECKFLAGS+=        --library=bsd
+CPPCHECKFLAGS+=        --max-configs=1
+CPPCHECKFLAGS+=        --suppress-xml=cppcheck-suppressions.xml
+CPPCHECKFLAGS+=        -D__has_builtin
+CPPCHECKFLAGS+=        -UNDEBUG
+CPPCHECKFLAGS+=        ${CPPFLAGS}
+
+IWYUFLAGS+=    ${CPPFLAGS}
+
 INSTALL_PROGRAM=       install -s -m 0755
 INSTALL_MAN=           install -m 0644
 
+CPPFLAGS+=     -DVERSION=\"${VERSION}\" -DYANKCMD=\"${YANKCMD}\"
 CFLAGS+=       -pedantic -Wall -Wextra
-CFLAGS+=       -DVERSION=\"${VERSION}\" -DYANKCMD=\"${YANKCMD}\"
 
 DISTFILES=     CHANGELOG.md \
                LICENSE \
@@ -33,17 +48,9 @@
 .PHONY: clean
 
 dist:
-       set -e; \
-       d=yank-${VERSION}; \
-       mkdir $$d; \
-       for f in ${DISTFILES}; do \
-               mkdir -p $$d/`dirname $$f`; \
-               cp -p ${.CURDIR}/$$f $$d/$$f; \
-       done; \
-       find $$d -type d -exec touch -r ${.CURDIR}/Makefile {} \;; \
-       tar czvf ${.CURDIR}/$$d.tar.gz $$d; \
-       (cd ${.CURDIR}; sha256 $$d.tar.gz >$$d.sha256); \
-       rm -r $$d
+       set -e; p=yank-${VERSION}; cd ${.CURDIR}; \
+       git archive --output $$p.tar.gz --prefix $$p/ v${VERSION}; \
+       sha256 $$p.tar.gz >$$p.sha256
 .PHONY: dist
 
 format:
@@ -62,4 +69,15 @@
        cd ${.CURDIR} && knfmt -ds ${KNFMT}
 .PHONY: lint
 
+lint-cppcheck:
+       cd ${.CURDIR} && cppcheck ${CPPCHECKFLAGS} ${CPPCHECK}
+.PHONY: lint-cppcheck
+
+lint-include-what-you-use:
+       cd ${.CURDIR} && iwyu-filter ${IWYUFLAGS} -- ${CPPCHECK}
+.PHONY: lint-include-what-you-use
+
+test: all
+.PHONY: test
+
 -include config.mk
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/README.md new/yank-1.4.0/README.md
--- old/yank-1.3.0/README.md    2022-06-18 08:25:45.000000000 +0200
+++ new/yank-1.4.0/README.md    2026-07-16 20:26:03.000000000 +0200
@@ -73,10 +73,8 @@
 
 ### Arch Linux
 
-On AUR:
-
 ```sh
-$ yaourt -S yank
+$ pacman -S yank
 ```
 
 ### Debian
@@ -149,16 +147,24 @@
 ```
 
 The default yank command can be defined using the `YANKCMD` variable.
-For instance,
-macOS users would prefer `pbcopy(1)`:
 
-```sh
-$ make YANKCMD=pbcopy
-```
+- macOS users would prefer `pbcopy(1)`:
+
+  ```sh
+  $ make YANKCMD=pbcopy
+  ```
+
+- Using `shcopy(1)` allows the selected field to be synchronized with the
+  clipboard on your local machine when using yank over SSH or in headless
+  environments.
+
+  ```sh
+  $ make YANKCMD=shcopy
+  ```
 
 ## License
 
-Copyright (c) 2015-2022 Anton Lindqvist.
+Copyright (c) 2015-2026 Anton Lindqvist.
 Distributed under the MIT license.
 
 [xsel]: http://www.vergenet.net/~conrad/software/xsel/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/cppcheck-suppressions.xml 
new/yank-1.4.0/cppcheck-suppressions.xml
--- old/yank-1.3.0/cppcheck-suppressions.xml    1970-01-01 01:00:00.000000000 
+0100
+++ new/yank-1.4.0/cppcheck-suppressions.xml    2026-07-16 20:26:03.000000000 
+0200
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<suppressions>
+  <!-- nofile -->
+  <suppress>
+    <id>checkersReport</id>
+  </suppress>
+  <suppress>
+    <id>missingIncludeSystem</id>
+  </suppress>
+  <suppress>
+    <id>redundantContinue</id>
+  </suppress>
+</suppressions>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/yank.1 new/yank-1.4.0/yank.1
--- old/yank-1.3.0/yank.1       2022-06-18 08:25:45.000000000 +0200
+++ new/yank-1.4.0/yank.1       2026-07-16 20:26:03.000000000 +0200
@@ -30,9 +30,7 @@
 .Pa stdin .
 The
 .Ar command
-defaults to
-.Xr xsel 1x
-but could be anything that accepts input on
+defaults to xsel but could be anything that accepts input on
 .Pa stdin ,
 see
 .Sx EXAMPLES .
@@ -80,6 +78,10 @@
 Move selection to the last field.
 .It Ic Ctrl-P Ns / Ns Ic Ctrl-N | Ic Left Ns / Ns Ic Right | Ic h Ns / Ns Ic l
 Move selection to the left or right.
+.It Ic Ctrl-L
+Toggle between current and line delimiter, equivalent to the
+.Fl l
+option.
 .It Ic Up Ns / Ns Ic Down | Ic j Ns / Ns Ic k
 Move selection to the next or previous line.
 .It Ic Enter
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yank-1.3.0/yank.c new/yank-1.4.0/yank.c
--- old/yank-1.3.0/yank.c       2022-06-18 08:25:45.000000000 +0200
+++ new/yank-1.4.0/yank.c       2026-07-16 20:26:03.000000000 +0200
@@ -4,7 +4,6 @@
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <getopt.h>
 #include <locale.h>
 #include <regex.h>
 #include <stdio.h>
@@ -35,7 +34,8 @@
        KEY_UP,
        KEY_RIGHT,
        KEY_DOWN,
-       KEY_LEFT
+       KEY_LEFT,
+       KEY_LINE,
 };
 
 struct field {
@@ -44,7 +44,22 @@
        size_t  lo; /* line offset */
 };
 
-static regex_t reg;
+struct pattern {
+       regex_t  r;
+       char    *str;
+       int      flags;
+       int      valid;
+       int      line;
+};
+
+struct tty {
+       struct termios  attr;
+       struct winsize  ws;
+       int             rfd;
+       int             wfd;
+       int             ca;     /* use alternate screen */
+       int             dirty;
+};
 
 static char **yankargv;
 
@@ -52,6 +67,7 @@
        size_t           nmemb;
        size_t           size;
        struct field    *v;
+       int              nlines; /* effective number of lines */
 } f;
 
 static struct {
@@ -60,13 +76,6 @@
        char    *v;
 } in;
 
-static struct {
-       int             rfd;
-       int             wfd;
-       int             ca;     /* use alternate screen */
-       struct termios  attr;
-} tty;
-
 static void
 input(void)
 {
@@ -128,14 +137,77 @@
        return MAX(s1, s2) <= MIN(e1, e2) ? 0 : (e1 < s2 ? 1 : -1);
 }
 
+static int
+fields(struct pattern *pattern, const char *str, const struct tty *tty)
+{
+       regmatch_t r;
+       char *e, *s;
+       size_t m, n;
+       unsigned int i, j;
+
+       if (pattern->valid)
+               regfree(&pattern->r);
+       if (regcomp(&pattern->r, str, pattern->flags) != 0) {
+               warnx("invalid regular expression");
+               return 0;
+       }
+       pattern->valid = 1;
+
+       f.nmemb = 0;
+       f.size = 32;
+       free(f.v);
+       if ((f.v = malloc(f.size*sizeof(struct field))) == NULL)
+               err(1, NULL);
+       m = n = MIN(tty->ws.ws_col * tty->ws.ws_row, (ssize_t)in.nmemb);
+       s = e = in.v;
+       while (m && !regexec(&pattern->r, e, 1, &r, 0) && r.rm_eo - r.rm_so) {
+               f.v[f.nmemb].so = f.v[f.nmemb].eo = e - s;
+               f.v[f.nmemb].so += r.rm_so;
+               f.v[f.nmemb].eo += MAX(MIN(r.rm_eo, (ssize_t)m) - 1, 0);
+               e += r.rm_eo;
+               m -= MIN(r.rm_eo, (ssize_t)m);
+
+               if (++f.nmemb < f.size)
+                       continue;
+               f.size *= 2;
+               if ((f.v = realloc(f.v, f.size*sizeof(struct field))) == NULL)
+                       err(1, NULL);
+       }
+
+       for (i = j = 0, s = e = in.v; n && i < tty->ws.ws_row; i++) {
+               size_t w;
+
+               if (s == e && !(e = memchr(s + 1, '\n', n)))
+                       e = in.v + in.nmemb;
+
+               w = MIN(e - s, tty->ws.ws_col);
+               for (; j < f.nmemb && f.v[j].so < (size_t)(s - in.v + w); j++)
+                       f.v[j].lo = s - in.v;
+               s += w;
+               n -= w;
+       }
+       f.nmemb = MIN(f.nmemb, j);
+       /* Ensure last field does not exceed the terminal width. */
+       if (n > 0 && f.nmemb > 0 &&
+           f.v[f.nmemb - 1].eo - f.v[f.nmemb - 1].lo >= tty->ws.ws_col)
+               f.v[f.nmemb - 1].eo = f.v[f.nmemb - 1].lo + tty->ws.ws_col - 1;
+       /* Number of bytes to output. */
+       f.v[f.nmemb].lo = MAX(s - in.v - 1, 0);
+       /* Effective number of lines. */
+       f.nlines = i;
+
+       return 1;
+}
+
 static ssize_t
 xwrite(int fd, const char *s, size_t nmemb)
 {
-       ssize_t r;
        size_t n;
 
        n = nmemb;
        do {
+               ssize_t r;
+
                r = write(fd, s, n);
                if (r == -1)
                        return r;
@@ -189,110 +261,64 @@
 }
 
 static void
-twrite(const char *s, size_t nmemb)
+twrite(const struct tty *tty, const char *s, size_t nmemb)
 {
-       if (xwrite(tty.wfd, s, nmemb) == -1)
+       if (xwrite(tty->wfd, s, nmemb) == -1)
                err(1, "write");
 }
 
 static void
-tputs(const char *s)
+tputs(const struct tty *tty, const char *s)
 {
        size_t n;
 
        n = strlen(s);
-       twrite(s, n);
+       twrite(tty, s, n);
 }
 
 static void
-tsetup(void)
+tsetup(struct tty *tty)
 {
        struct termios attr;
-       struct winsize ws;
-       regmatch_t r;
-       char *e, *s;
-       size_t m, n, w;
-       unsigned int i, j;
 
-       if ((tty.rfd = open("/dev/tty", O_RDONLY)) == -1)
+       if ((tty->rfd = open("/dev/tty", O_RDONLY)) == -1)
                err(1, "/dev/tty");
-       if ((tty.wfd = open("/dev/tty", O_WRONLY)) == -1)
+       if ((tty->wfd = open("/dev/tty", O_WRONLY)) == -1)
                err(1, "/dev/tty");
 
-       if (ioctl(tty.rfd, TIOCGWINSZ, &ws) == -1)
+       if (ioctl(tty->rfd, TIOCGWINSZ, &tty->ws) == -1)
                err(1, "TIOCGWINSZ");
 
-       f.size = 32;
-       if ((f.v = malloc(f.size*sizeof(struct field))) == NULL)
-               err(1, NULL);
-       m = n = MIN(ws.ws_col*ws.ws_row, (ssize_t)in.nmemb);
-       s = e = in.v;
-       while (m && !regexec(&reg, e, 1, &r, 0) && r.rm_eo - r.rm_so) {
-               f.v[f.nmemb].so = f.v[f.nmemb].eo = e - s;
-               f.v[f.nmemb].so += r.rm_so;
-               f.v[f.nmemb].eo += MAX(MIN(r.rm_eo, (ssize_t)m) - 1, 0);
-               e += r.rm_eo;
-               m -= MIN(r.rm_eo, (ssize_t)m);
-
-               if (++f.nmemb < f.size)
-                       continue;
-               f.size *= 2;
-               if ((f.v = realloc(f.v, f.size*sizeof(struct field))) == NULL)
-                       err(1, NULL);
-       }
-
-       for (i = j = 0, s = e = in.v; n && i < ws.ws_row; i++) {
-               if (s == e && !(e = memchr(s + 1, '\n', n)))
-                       e = in.v + in.nmemb;
-
-               w = MIN(e - s, ws.ws_col);
-               for (; j < f.nmemb && f.v[j].so < (size_t)(s - in.v + w); j++)
-                       f.v[j].lo = s - in.v;
-               s += w;
-               n -= w;
-       }
-       f.nmemb = MIN(f.nmemb, j);
-       /* Ensure last field does not exceed the terminal width. */
-       if (n > 0 && f.nmemb > 0 &&
-           f.v[f.nmemb - 1].eo - f.v[f.nmemb - 1].lo >= ws.ws_col)
-               f.v[f.nmemb - 1].eo = f.v[f.nmemb - 1].lo + ws.ws_col - 1;
-       /* Number of bytes to output. */
-       f.v[f.nmemb].lo = MAX(s - in.v - 1, 0);
-
-       if (tcgetattr(tty.rfd, &tty.attr) == -1)
+       if (tcgetattr(tty->rfd, &tty->attr) == -1)
                err(1, "tcgetattr");
-       attr = tty.attr;
+       attr = tty->attr;
        attr.c_iflag |= ICRNL;
        attr.c_lflag &= ~(ICANON|ECHO|ISIG);
-       if (tcsetattr(tty.rfd, TCSANOW, &attr) == -1)
+       if (tcsetattr(tty->rfd, TCSANOW, &attr) == -1)
                err(1, "tcsetattr");
 
-       if (tty.ca)
-               tputs(T_ENTER_CA_MODE);
-       tputs(T_CURSOR_INVISIBLE);
-       /* Emit the number of lines and save the cursor position. */
-       for (j = 0; j < i; j++)
-               tputs("\n");
-       for (j = 0; j < i; j++)
-               tputs("\033M");
-       tputs(T_SAVE_CURSOR);
+       if (tty->ca)
+               tputs(tty, T_ENTER_CA_MODE);
+       tputs(tty, T_CURSOR_INVISIBLE);
 }
 
 static void
-tend(void)
+tend(const struct tty *tty)
 {
-       tputs(T_RESTORE_CURSOR);
-       tputs(T_CLR_EOS);
-       tputs(T_CURSOR_VISIBLE);
-       if (tty.ca)
-               tputs(T_EXIT_CA_MODE);
-       tcsetattr(tty.rfd, TCSANOW, &tty.attr);
-       close(tty.rfd);
-       close(tty.wfd);
+       if (tty->dirty) {
+               tputs(tty, T_RESTORE_CURSOR);
+               tputs(tty, T_CLR_EOS);
+       }
+       tputs(tty, T_CURSOR_VISIBLE);
+       if (tty->ca)
+               tputs(tty, T_EXIT_CA_MODE);
+       tcsetattr(tty->rfd, TCSANOW, &tty->attr);
+       close(tty->rfd);
+       close(tty->wfd);
 }
 
 static int
-tgetc(void)
+tgetc(const struct tty *tty)
 {
        static struct {
                const char      *s;
@@ -303,6 +329,7 @@
                { "\003",       KEY_TERM },     /* Ctrl-C */
                { "\004",       KEY_TERM },     /* Ctrl-D */
                { "\005",       KEY_END },      /* Ctrl-E */
+               { "\014",       KEY_LINE },     /* Ctrl-L */
                { "\016",       KEY_RIGHT },    /* Ctrl-N */
                { "\020",       KEY_LEFT },     /* Ctrl-P */
                { "G",          KEY_END },
@@ -321,41 +348,52 @@
        ssize_t n;
        int i;
 
-       n = read(tty.rfd, buf, sizeof(buf) - 1);
+       n = read(tty->rfd, buf, sizeof(buf) - 1);
        if (n == -1)
                err(1, "read");
        if (n == 0)
                return KEY_TERM;        /* EOF */
        buf[n] = '\0';
 
-       for (i = 0; keys[i].s != NULL; i++)
+       for (i = 0; keys[i].s != NULL; i++) {
                if (strncmp(keys[i].s, buf, strlen(keys[i].s)) == 0)
                        return keys[i].c;
+       }
 
        return 0;
 }
 
 static const struct field *
-tmain(void)
+tmain(struct tty *tty, struct pattern *pattern)
 {
        size_t n;
-       int c, i, j, k;
+       int i, j;
+
+       /* Emit the number of lines and save the cursor position. */
+       for (i = 0; i < f.nlines; i++)
+               tputs(tty, "\n");
+       for (i = 0; i < f.nlines; i++)
+               tputs(tty, "\033M");
+       tputs(tty, T_SAVE_CURSOR);
+       tty->dirty = 1;
 
        i = j = 0;
        n = f.v[f.nmemb].lo;
        for (;;) {
-               tputs(T_RESTORE_CURSOR);
+               int c;
+
+               tputs(tty, T_RESTORE_CURSOR);
                if (f.nmemb > 0) {
-                       twrite(in.v, f.v[i].so);
-                       tputs(T_ENTER_STANDOUT_MODE);
-                       twrite(in.v + f.v[i].so, f.v[i].eo - f.v[i].so + 1);
-                       tputs(T_EXIT_STANDOUT_MODE);
-                       twrite(in.v + f.v[i].eo + 1, n - f.v[i].eo);
+                       twrite(tty, in.v, f.v[i].so);
+                       tputs(tty, T_ENTER_STANDOUT_MODE);
+                       twrite(tty, in.v + f.v[i].so, f.v[i].eo - f.v[i].so + 
1);
+                       tputs(tty, T_EXIT_STANDOUT_MODE);
+                       twrite(tty, in.v + f.v[i].eo + 1, n - f.v[i].eo);
                } else {
-                       twrite(in.v, n);
+                       twrite(tty, in.v, n);
                }
 
-               c = tgetc();
+               c = tgetc(tty);
                switch (c) {
                case KEY_ENTER:
                        if (f.nmemb > 0)
@@ -385,7 +423,7 @@
                                if (j == (ssize_t)f.nmemb)
                                        break;
                        } else {
-                               k = i;
+                               int k = i;
                                while (k && f.v[i].lo == f.v[k].lo)
                                        k--;
                                j = k;
@@ -396,6 +434,29 @@
                            f.v[j].lo == f.v[j + 1].lo; j++)
                                continue;
                        break;
+               case KEY_LINE: {
+                       size_t oldlo = f.nmemb > 0 ? f.v[i].lo : 0;
+
+                       pattern->line = !pattern->line;
+                       if (pattern->line) {
+                               char *p = strtopat("");
+                               int ok = fields(pattern, p, tty);
+                               free(p);
+                               if (!ok)
+                                       return NULL;
+                       } else {
+                               if (!fields(pattern, pattern->str, tty))
+                                       return NULL;
+                       }
+
+                       n = f.v[f.nmemb].lo;
+                       /* Find first field on the same line. */
+                       for (j = 0; j < (ssize_t)f.nmemb && f.v[j].lo < oldlo; 
j++)
+                               continue;
+                       if (j == (ssize_t)f.nmemb)
+                               j = 0;
+                       break;
+               }
                }
                if (j >= 0 && j < (ssize_t)f.nmemb)
                        i = j;
@@ -413,41 +474,41 @@
 int
 main(int argc, char *argv[])
 {
-       const struct field *field;
-       char *pat;
+       struct pattern pattern = {.flags = REG_EXTENDED};
+       struct tty tty = {0};
+       const struct field *field = NULL;
        int one = 0;
-       int rflags = REG_EXTENDED;
        int c, i;
 
        setlocale(LC_CTYPE, "");
 
 #ifdef __OpenBSD__
-       if (pledge("stdio tty proc exec", NULL) == -1)
+       if (pledge("stdio rpath wpath tty proc exec", NULL) == -1)
                err(1, "pledge");
 #endif
 
-       pat = strtopat(" ");
-       while ((c = getopt(argc, argv, "1ilvxd:g:")) != -1)
+       pattern.str = strtopat(" ");
+       while ((c = getopt(argc, argv, "1ilvxd:g:")) != -1) {
                switch (c) {
                case '1':
                        one = 1;
                        break;
                case 'd':
-                       free(pat);
-                       pat = strtopat(optarg);
+                       free(pattern.str);
+                       pattern.str = strtopat(optarg);
                        break;
                case 'g':
-                       free(pat);
-                       if ((pat = strdup(optarg)) == NULL)
+                       free(pattern.str);
+                       if ((pattern.str = strdup(optarg)) == NULL)
                                err(1, NULL);
-                       rflags |= REG_NEWLINE;
+                       pattern.flags |= REG_NEWLINE;
                        break;
                case 'i':
-                       rflags |= REG_ICASE;
+                       pattern.flags |= REG_ICASE;
                        break;
                case 'l':
-                       free(pat);
-                       pat = strtopat("");
+                       free(pattern.str);
+                       pattern.str = strtopat("");
                        break;
                case 'v':
                        puts("yank " VERSION);
@@ -458,12 +519,10 @@
                default:
                        usage();
                }
+       }
        argc -= optind;
        argv += optind;
 
-       if (regcomp(&reg, pat, rflags) != 0)
-               errx(1, "invalid regular expression");
-
        /* Ensure space for yank command and null terminator. */
        if ((yankargv = calloc(argc + 2, sizeof(char *))) == NULL)
                err(1, NULL);
@@ -472,12 +531,15 @@
                yankargv[i] = argv[i];
 
        input();
-       tsetup();
-       if (one && f.nmemb == 1)
+       tsetup(&tty);
+       if (!fields(&pattern, pattern.str, &tty)) {
+               /* nothing */
+       } else if (one && f.nmemb == 1) {
                field = &f.v[0];
-       else
-               field = tmain();
-       tend();
+       } else {
+               field = tmain(&tty, &pattern);
+       }
+       tend(&tty);
        if (field == NULL)
                return 1;
        yank(in.v + field->so, field->eo - field->so + 1);

Reply via email to