* [PR PATCH] mcom: remove needless invocations of awk
@ 2023-04-09 20:55 readmemyrights
2023-04-10 10:42 ` [PR PATCH] [Updated] " readmemyrights
2023-04-10 11:38 ` [PR PATCH] [Closed]: " readmemyrights
0 siblings, 2 replies; 3+ messages in thread
From: readmemyrights @ 2023-04-09 20:55 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 326 bytes --]
There is a new 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: 2059 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] 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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PR PATCH] [Updated] mcom: remove needless invocations of awk
2023-04-09 20:55 [PR PATCH] mcom: remove needless invocations of awk readmemyrights
@ 2023-04-10 10:42 ` readmemyrights
2023-04-10 11:38 ` [PR PATCH] [Closed]: " readmemyrights
1 sibling, 0 replies; 3+ messages in thread
From: readmemyrights @ 2023-04-10 10:42 UTC (permalink / raw)
To: ml
[-- 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");
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PR PATCH] [Closed]: mcom: remove needless invocations of awk
2023-04-09 20:55 [PR PATCH] mcom: remove needless invocations of awk readmemyrights
2023-04-10 10:42 ` [PR PATCH] [Updated] " readmemyrights
@ 2023-04-10 11:38 ` readmemyrights
1 sibling, 0 replies; 3+ messages in thread
From: readmemyrights @ 2023-04-10 11:38 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 174 bytes --]
There's a closed pull request on the mblaze repository
mcom: remove needless invocations of awk
https://github.com/leahneukirchen/mblaze/pull/239
Description:
Fixes #238.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-10 11:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-09 20:55 [PR PATCH] mcom: remove needless invocations of awk readmemyrights
2023-04-10 10:42 ` [PR PATCH] [Updated] " readmemyrights
2023-04-10 11:38 ` [PR PATCH] [Closed]: " readmemyrights
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).