[wiki] [sites] st externalpipe - Fix 0.4.1 and 0.5 diffs, update git-diff || FRIGN

From: <git_AT_suckless.org>
Date: Thu, 17 Sep 2015 16:49:39 +0200

commit c351deb9f36bb5de240d03902dbc51c4f20cc003
Author: FRIGN <dev_AT_frign.de>
Date: Thu Sep 17 16:48:32 2015 +0200

    st externalpipe - Fix 0.4.1 and 0.5 diffs, update git-diff
    
    The 0.4.1 and 0.5 diffs were broken for some reason. Remove the
    external links to the patches, we want to keep them at home.

diff --git a/st.suckless.org/patches/externalpipe.md b/st.suckless.org/patches/externalpipe.md
index 967a8c0..59ba463 100644
--- a/st.suckless.org/patches/externalpipe.md
+++ b/st.suckless.org/patches/externalpipe.md
_AT_@ -1,44 +1,36 @@
-External Pipe
-=============
+externalpipe
+============
 
 Description
 -----------
 
-This patch lets you write st's screen text out through a pipe, for example,
-url-select (below).
+This patch lets you write st's screen through a pipe.
 
 Example
 -------
 
-Bind alt+u to extract all visible urls and present dmenu, to choose and open
-said urls:
+config.h example, binding Mod1+u to extract all visible URLs and present
+dmenu to select and open one:
 
         static Shortcut shortcuts[] = {
                 ...
                 { MODKEY, 'u', externalpipe, { .s = "xurls | dmenu -l 10 | xargs -r open" } },
         };
 
-
-([xurls][1] and [open][2] are external scripts)
+([xurls](https://raw.github.com/bobrippling/perlbin/master/xurls) and
+[open](https://github.com/bobrippling/open) are external scripts)
 
 
 Download
 --------
 
-* [st-0.4.1-externalpipe.diff][0]
-* [st-0.5-externalpipe.diff][3]
-* [st-0.6-externalpipe.diff][4]
-* [st-git-20150824-externalpipe.diff][5]
-
-[0]: st-0.4.1-externalpipe.diff
-[1]: https://raw.github.com/bobrippling/perlbin/master/xurls
-[2]: https://github.com/bobrippling/open
-[3]: http://witsquash.com/~marty/st-0.5-externalpipe.diff
-[4]: st-0.6-externalpipe.diff
-[5]: st-git-20150824-externalpipe.diff
+* [st-0.4.1-externalpipe.diff](st-0.4.1-externalpipe.diff)
+* [st-0.5-externalpipe.diff](st-0.5-externalpipe.diff)
+* [st-0.6-externalpipe.diff](st-0.6-externalpipe.diff)
+* [st-git-20150917-externalpipe.diff][st-git-20150917-externalpipe.diff]
 
+Authors
+-------
 
-Author
-------
-
- * Rob Pilling - my name _AT_ gmail
+ * Rob Pilling - robpilling_AT_gmail.com
+ * Laslo Hunhold - dev_AT_frign.de (st-0.4.1, st-0.5, st-0.6, st-git-20150917 ports)
diff --git a/st.suckless.org/patches/st-0.4.1-externalpipe.diff b/st.suckless.org/patches/st-0.4.1-externalpipe.diff
index 53025e7..7c9c9e2 100644
--- a/st.suckless.org/patches/st-0.4.1-externalpipe.diff
+++ b/st.suckless.org/patches/st-0.4.1-externalpipe.diff
_AT_@ -1,17 +1,8 @@
-From 7982a2d238925028b45d5143db470e408b97469a Mon Sep 17 00:00:00 2001
-From: Rob Pilling <robpilling_AT_gmail.com>
-Date: Fri, 20 Dec 2013 12:40:55 +0000
-Subject: [PATCH] Add externalpipe() for piping out screen text
-
----
- st.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
- 1 file changed, 68 insertions(+), 6 deletions(-)
-
 diff --git a/st.c b/st.c
-index 4fb3311..adef257 100644
+index 686ed5d..697cd43 100644
 --- a/st.c
 +++ b/st.c
-_AT_@ -299,6 +299,7 @@ typedef union {
+_AT_@ -249,6 +249,7 @@ typedef union {
  	unsigned int ui;
  	float f;
  	const void *v;
_AT_@ -19,7 +10,7 @@ index 4fb3311..adef257 100644
  } Arg;
  
  typedef struct {
-_AT_@ -313,6 +314,7 @@ static void clippaste(const Arg *);
+_AT_@ -263,6 +264,7 @@ static void clippaste(const Arg *);
  static void numlock(const Arg *);
  static void selpaste(const Arg *);
  static void xzoom(const Arg *);
_AT_@ -27,14 +18,14 @@ index 4fb3311..adef257 100644
  
  /* Config.h for applying patches and the configuration. */
  #include "config.h"
-_AT_@ -1204,15 +1206,22 @@ execsh(void) {
+_AT_@ -1024,15 +1026,22 @@ execsh(void) {
  void
  sigchld(int a) {
  	int stat = 0;
 +	pid_t r;
  
 -	if(waitpid(pid, &stat, 0) < 0)
--		die("Waiting for pid %hd failed: %s
", pid, SERRNO);
+-		die("Waiting for pid %hd failed: %s
",	pid, SERRNO);
 +	r = wait(&stat);
 +	if(r < 0)
 +		die("wait(): %s
", SERRNO);
_AT_@ -44,7 +35,7 @@ index 4fb3311..adef257 100644
 -	} else {
 -		exit(EXIT_FAILURE);
 +	if(r == pid){
-+		/* _the_ sub porcess */
++		/* _the_ sub process */
 +		if(WIFEXITED(stat)) {
 +			exit(WEXITSTATUS(stat));
 +		} else {
_AT_@ -56,7 +47,7 @@ index 4fb3311..adef257 100644
  }
  
  void
-_AT_@ -2928,6 +2937,59 @@ xzoom(const Arg *arg) {
+_AT_@ -2593,6 +2602,59 @@ xzoom(const Arg *arg) {
  }
  
  void
_AT_@ -114,8 +105,5 @@ index 4fb3311..adef257 100644
 +
 +void
  xinit(void) {
+ 	XSetWindowAttributes attrs;
  	XGCValues gcvalues;
- 	Cursor cursor;
--- 
-1.7.10.4
-
diff --git a/st.suckless.org/patches/st-0.5-externalpipe.diff b/st.suckless.org/patches/st-0.5-externalpipe.diff
new file mode 100644
index 0000000..8a1ef05
--- /dev/null
+++ b/st.suckless.org/patches/st-0.5-externalpipe.diff
_AT_@ -0,0 +1,109 @@
+diff --git a/st.c b/st.c
+index 392f12d..31660c8 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -301,6 +301,7 @@ typedef union {
+ 	unsigned int ui;
+ 	float f;
+ 	const void *v;
++	const char *s;
+ } Arg;
+ 
+ typedef struct {
+_AT_@ -315,6 +316,7 @@ static void clippaste(const Arg *);
+ static void numlock(const Arg *);
+ static void selpaste(const Arg *);
+ static void xzoom(const Arg *);
++static void externalpipe(const Arg *);
+ static void printsel(const Arg *);
+ static void printscreen(const Arg *) ;
+ static void toggleprinter(const Arg *);
+_AT_@ -1179,15 +1181,22 @@ execsh(void) {
+ void
+ sigchld(int a) {
+ 	int stat = 0;
++	pid_t r;
+ 
+-	if(waitpid(pid, &stat, 0) < 0)
+-		die("Waiting for pid %hd failed: %s
", pid, SERRNO);
++	r = wait(&stat);
++	if(r < 0)
++		die("wait(): %s
", strerror(errno));
+ 
+-	if(WIFEXITED(stat)) {
+-		exit(WEXITSTATUS(stat));
+-	} else {
+-		exit(EXIT_FAILURE);
++	if(r == pid){
++		/* _the_ sub process */
++		if(WIFEXITED(stat)) {
++			exit(WEXITSTATUS(stat));
++		} else {
++			exit(EXIT_FAILURE);
++		}
+ 	}
++
++	/* something else we've forked out */
+ }
+ 
+ void
+_AT_@ -2982,6 +2991,59 @@ xzoom(const Arg *arg) {
+ }
+ 
+ void
++externalpipe(const Arg *arg)
++{
++	int to[2]; /* 0 = read, 1 = write */
++	pid_t child;
++	int y, x;
++	void (*oldsigpipe)(int);
++
++	if(pipe(to) == -1)
++		return;
++
++	/* sigchld() handles this */
++	switch((child = fork())){
++		case -1:
++			close(to[0]), close(to[1]);
++			return;
++		case 0:
++			/* child */
++			close(to[1]);
++			dup2(to[0], STDIN_FILENO); /* 0<&to */
++			close(to[0]);
++			execvp(
++					"sh",
++					(char *const []){
++						"/bin/sh",
++						"-c",
++						(char *)arg->s,
++						0
++					});
++			exit(127);
++	}
++
++	/* parent */
++	close(to[0]);
++	/* ignore sigpipe for now, in case child exits early */
++	oldsigpipe = signal(SIGPIPE, SIG_IGN);
++
++	for(y = 0; y < term.row; y++){
++		for(x = 0; x < term.col; x++){
++			if(write(to[1], term.line[y][x].c, 1) == -1)
++				goto done;
++		}
++		if(write(to[1], "
", 1) == -1)
++			break;
++	}
++
++done:
++	close(to[1]);
++
++	/* restore */
++	signal(SIGPIPE, oldsigpipe);
++}
++
++void
+ xinit(void) {
+ 	XGCValues gcvalues;
+ 	Cursor cursor;
diff --git a/st.suckless.org/patches/st-git-20150824-externalpipe.diff b/st.suckless.org/patches/st-git-20150824-externalpipe.diff
deleted file mode 100644
index 2815ab6..0000000
--- a/st.suckless.org/patches/st-git-20150824-externalpipe.diff
+++ /dev/null
_AT_@ -1,75 +0,0 @@
-diff --git a/st.c b/st.c
-index 35a840b..bb2dd17 100644
---- a/st.c
-+++ b/st.c
-_AT_@ -327,6 +327,7 @@ static void clipcopy(const Arg *);
- static void clippaste(const Arg *);
- static void numlock(const Arg *);
- static void selpaste(const Arg *);
-+static void externalpipe(const Arg *);
- static void xzoom(const Arg *);
- static void xzoomabs(const Arg *);
- static void xzoomreset(const Arg *);
-_AT_@ -2888,6 +2889,62 @@ eschandle(uchar ascii)
- }
- 
- void
-+externalpipe(const Arg *arg)
-+{
-+	int to[2]; /* 0 = read, 1 = write */
-+	pid_t child;
-+	int n;
-+	void (*oldsigpipe)(int);
-+	char buf[UTF_SIZ];
-+	Glyph *bp, *end;
-+
-+	if(pipe(to) == -1)
-+		return;
-+
-+	/* sigchld() handles this */
-+	switch(child = fork()){
-+		case -1:
-+			close(to[0]), close(to[1]);
-+			return;
-+		case 0:
-+			/* child */
-+			close(to[1]);
-+			dup2(to[0], STDIN_FILENO); /* 0<&to */
-+			close(to[0]);
-+			execvp(
-+					"sh",
-+					(char *const []){
-+						"/bin/sh",
-+						"-c",
-+						(char *)arg->v,
-+						0
-+					});
-+			exit(127);
-+	}
-+
-+	/* parent */
-+	close(to[0]);
-+	/* ignore sigpipe for now, in case child exits early */
-+	oldsigpipe = signal(SIGPIPE, SIG_IGN);
-+
-+	for(n = 0; n < term.row; n++){
-+		bp = &term.line[n][0];
-+		end = &bp[MIN(tlinelen(n), term.col) - 1];
-+		if(bp != end || bp->u != ' ')
-+			for(; bp <= end; ++bp)
-+				if(xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
-+					break;
-+		if(xwrite(to[1], "
", 1) < 0)
-+			break;
-+	}
-+
-+	close(to[1]);
-+
-+	/* restore */
-+	signal(SIGPIPE, oldsigpipe);
-+}
-+
-+void
- tputc(Rune u)
- {
- 	char c[UTF_SIZ];
diff --git a/st.suckless.org/patches/st-git-20150917-externalpipe.diff b/st.suckless.org/patches/st-git-20150917-externalpipe.diff
new file mode 100644
index 0000000..c6744bc
--- /dev/null
+++ b/st.suckless.org/patches/st-git-20150917-externalpipe.diff
_AT_@ -0,0 +1,75 @@
+diff --git a/st.c b/st.c
+index bd8b815..a43e615 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -328,6 +328,7 @@ static void clipcopy(const Arg *);
+ static void clippaste(const Arg *);
+ static void numlock(const Arg *);
+ static void selpaste(const Arg *);
++static void externalpipe(const Arg *);
+ static void xzoom(const Arg *);
+ static void xzoomabs(const Arg *);
+ static void xzoomreset(const Arg *);
+_AT_@ -2920,6 +2921,62 @@ eschandle(uchar ascii)
+ }
+ 
+ void
++externalpipe(const Arg *arg)
++{
++	int to[2]; /* 0 = read, 1 = write */
++	pid_t child;
++	int n;
++	void (*oldsigpipe)(int);
++	char buf[UTF_SIZ];
++	Glyph *bp, *end;
++
++	if(pipe(to) == -1)
++		return;
++
++	/* sigchld() handles this */
++	switch(child = fork()){
++		case -1:
++			close(to[0]), close(to[1]);
++			return;
++		case 0:
++			/* child */
++			close(to[1]);
++			dup2(to[0], STDIN_FILENO); /* 0<&to */
++			close(to[0]);
++			execvp(
++					"sh",
++					(char *const []){
++						"/bin/sh",
++						"-c",
++						(char *)arg->v,
++						0
++					});
++			exit(127);
++	}
++
++	/* parent */
++	close(to[0]);
++	/* ignore sigpipe for now, in case child exits early */
++	oldsigpipe = signal(SIGPIPE, SIG_IGN);
++
++	for(n = 0; n < term.row; n++){
++		bp = &term.line[n][0];
++		end = &bp[MIN(tlinelen(n), term.col) - 1];
++		if(bp != end || bp->u != ' ')
++			for(; bp <= end; ++bp)
++				if(xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
++					break;
++		if(xwrite(to[1], "
", 1) < 0)
++			break;
++	}
++
++	close(to[1]);
++
++	/* restore */
++	signal(SIGPIPE, oldsigpipe);
++}
++
++void
+ tputc(Rune u)
+ {
+ 	char c[UTF_SIZ];
Received on Thu Sep 17 2015 - 16:49:39 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 17 2015 - 17:00:15 CEST