Github messages for mblaze
 help / color / mirror / Atom feed
From: readmemyrights <readmemyrights@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] mcom: remove needless invocations of awk
Date: Mon, 10 Apr 2023 12:42:35 +0200	[thread overview]
Message-ID: <20230410104235.04sMvaYCvLUyTJxWUejwi2Mq-WbUQi5Av7OzP9GbDuQ@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-239@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 331 bytes --]

There is an updated pull request by readmemyrights against master on the mblaze repository

https://github.com/readmemyrights/mblaze master
https://github.com/leahneukirchen/mblaze/pull/239

mcom: remove needless invocations of awk
Fixes #238.


A patch file from https://github.com/leahneukirchen/mblaze/pull/239.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-master-239.patch --]
[-- Type: text/x-diff, Size: 4969 bytes --]

From 63739502acefd23e2f5307921c7e88db1e5d5f34 Mon Sep 17 00:00:00 2001
From: Sekulum Forka <dictatorofturkmenistan@protonmail.com>
Date: Sun, 9 Apr 2023 22:50:45 +0200
Subject: [PATCH 1/2] mcom: remove needless invocations of awk

Fixes #238.
---
 mcom | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mcom b/mcom
index 397cb5f..9db1255 100755
--- a/mcom
+++ b/mcom
@@ -276,7 +276,7 @@ fi
 				commajoin | sed 's/^/Cc: /'
 			printf '%s' "$hdrs" | mhdr -M -h bcc - |
 				commajoin | sed 's/^/Bcc: /'
-			printf '%s\n' "$hdrs" | awk '{ print }' |
+			printf '%s\n' "$hdrs" |
 				msed "/to/d; /cc/d; /bcc/d; /body/d" -
 		} | msed "/cc/a//; /bcc/a//; /subject/a//; /from/a/$default_from/" - | sed '/^$/d'
 		msgid
@@ -298,7 +298,7 @@ fi
 			printf '%s' "$hdrs" | mhdr -M -h bcc - |
 				commajoin | sed 's/^/Bcc: /'
 			COLUMNS=10000 mscan -f 'Subject: Fwd: [%f] %s' "$@" 2>/dev/null | sed 1q
-			printf '%s\n' "$hdrs" | awk '{ print }' |
+			printf '%s\n' "$hdrs" |
 				msed "/to/d; /cc/d; /bcc/d" -
 		} | msed "/cc/a//; /bcc/a//; /from/a/$default_from/" - | sed '/^$/d'
 		msgid
@@ -335,7 +335,7 @@ fi
 				commajoin | sed 's/^/Resent-To: /'
 			printf '%s' "$hdrs" | mhdr -M -h resent-cc - |
 				commajoin | sed 's/^/Resent-Cc: /'
-			printf '%s\n' "$hdrs" | awk '{ print }' |
+			printf '%s\n' "$hdrs" |
 				msed "/resent-to/d; /resent-cc/d" -
 		} |
 			msed "/resent-to/a//; /resent-from/a/$default_from/" - | sed '/^$/d'
@@ -368,11 +368,11 @@ fi
 				       notmine |grep -Fv -e "$to" |
 				       ouniq |commajoin)"
 			printf 'Bcc: \n'
-			printf '%s\n' "$hdrs" | awk '{ print }' |
+			printf '%s\n' "$hdrs" |
 				msed "/body/d" -
 		fi | sed '/^$/d'
 		printf 'Subject: Re: %s\n' "$(COLUMNS=10000 mscan -f '%S' "$1")"
-		if ! printf '%s\n' "$hdrs" | awk '{ print }' |
+		if ! printf '%s\n' "$hdrs" |
 		     mhdr -h from: - >/dev/null; then
 			addr=$(maddr -a -h delivered-to:to:cc:bcc: "$1" | replyfrom | head -n1)
 			[ -n "$addr" ] && from=$(maddr -h reply-from "$MBLAZE/profile" | grep -Fi "<$addr>" | head -n1)

From e8eacb19578b7a59e4d673497329b7a7befaeed1 Mon Sep 17 00:00:00 2001
From: Sekulum Forka <dictatorofturkmenistan@protonmail.com>
Date: Mon, 10 Apr 2023 10:15:21 +0200
Subject: [PATCH 2/2] msed: replace while loops with c string functions

---
 msed.c | 42 +++++++++++++-----------------------------
 1 file changed, 13 insertions(+), 29 deletions(-)

diff --git a/msed.c b/msed.c
index c545278..ce94cb9 100644
--- a/msed.c
+++ b/msed.c
@@ -114,24 +114,19 @@ sed(char *file)
 		if (!v)
 			continue;
 		v++;
-		while (*v && (*v == ' ' || *v == '\t'))
-			v++;
+		v += strspn(v, " \t");
 
 		v = strdup(v);
 
 		char *e = expr;
 		while (*e) {
-			while (*e &&
-			    (*e == ' ' || *e == '\t' || *e == '\n' || *e == ';'))
-				e++;
-
 			*headersel = 0;
+		e += strspn(e, " \t\n;");
 			if (*e == '/') {
 				e++;
 				char *s = e;
 				// parse_headers, sets headersel
-				while (*e && *e != '/')
-					e++;
+				e = strchr(e, '/');
 				snprintf(headersel, sizeof headersel,
 				    "^(%.*s)*:", (int)(e-s), s);
 				for (s = headersel; *s && *(s+1); s++)
@@ -167,8 +162,7 @@ sed(char *file)
 						fprintf(stderr, "msed: unterminated a command\n");
 						exit(1);
 					}
-					while (*e && *e != sep)
-						e++;
+						e = strchr(e, sep);
 					if (*e == sep)
 						e++;
 					if (!(*e == ' ' || *e == ';' || *e == '\n' || !*e)) {
@@ -179,22 +173,18 @@ sed(char *file)
 				case 'c':
 					sep = *++e;
 					s = ++e;
-					while (*e && *e != sep)
-						e++;
+					e = strchr(e, sep);
 					free(v);
 					v = strndup(s, e-s);
 					break;
 				case 's':
 					sep = *++e;
 					s = ++e;
-					while (*e && *e != sep)
-						e++;
+					e = strchr(e, sep);
 					char *t = ++e;
-					while (*e && *e != sep)
-						e++;
+					e = strchr(e, sep);
 					char *u = ++e;
-					while (*e == 'd' || *e == 'g' || *e == 'i')
-						e++;
+					e += strspn(e, "dgi");
 
 					if (!(*e == ' ' || *e == ';' || *e == '\n' || !*e)) {
 						fprintf(stderr, "msed: unterminated s command\n");
@@ -226,8 +216,7 @@ sed(char *file)
 					exit(1);
 				}
 			}
-			while (*e && *e != ';' && *e != '\n')
-				e++;
+			e += strcspn(e, ";\n");
 		}
 		if (v) {
 			printhdr(h, 0);
@@ -241,17 +230,14 @@ sed(char *file)
 	char *hs, *he;
 	char *e = expr;
 	while (*e) {
-		while (*e &&
-		    (*e == ' ' || *e == '\t' || *e == '\n' || *e == ';'))
-			e++;
+		e += strspn(e, " \t\n;");
 
 		hs = he = 0;
 		if (*e == '/') {
 			e++;
 			hs = e;
 			// parse_headers, sets headersel
-			while (*e && *e != '/')
-				e++;
+			e = strchr(e, '/');
 			he = e;
 			if (*e)
 				e++;
@@ -281,8 +267,7 @@ sed(char *file)
 					exit(1);
 				}
 				s = ++e;
-				while (*e && *e != sep)
-					e++;
+				e = strchr(e, sep);
 				v = strndup(s, e-s);
 			}
 
@@ -305,8 +290,7 @@ sed(char *file)
 			// ignore here;
 			break;
 		}
-		while (*e && *e != ';' && *e != '\n')
-			e++;
+		e += strcspn(e, ";\n");
 	}
 
 	printf("\n");

  reply	other threads:[~2023-04-10 10:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-09 20:55 [PR PATCH] " readmemyrights
2023-04-10 10:42 ` readmemyrights [this message]
2023-04-10 11:38 ` [PR PATCH] [Closed]: " readmemyrights

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230410104235.04sMvaYCvLUyTJxWUejwi2Mq-WbUQi5Av7OzP9GbDuQ@z \
    --to=readmemyrights@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).