[Asterisk-code-review] app_read: Fix custom terminator functionality regression (asterisk[19])
Kevin Harwell
asteriskteam at digium.com
Tue Nov 16 15:44:38 CST 2021
Kevin Harwell has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/17486 )
Change subject: app_read: Fix custom terminator functionality regression
......................................................................
app_read: Fix custom terminator functionality regression
Currently, when the t option is specified with no arguments,
the # character is still treated as a terminator, even though
no character should be treated as a terminator.
This is because a previous regression fix was modified to
remove the use of NULL as a default altogether. However,
NULL and an empty string actually refer to different
arrangements and should be treated differently. NULL is the
default terminator (#), while an empty string removes the
terminator altogether. This is the behavior being used by
the rest of the core.
Additionally, since S_OR catches empty strings as well as
NULL (not intended), this is changed to a ternary operator
instead, which fixes the behavior.
ASTERISK-29705 #close
Change-Id: I9b6b72196dd04f5b1e0ab5aa1b0adf627725e086
---
M apps/app_read.c
M main/app.c
2 files changed, 2 insertions(+), 2 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved; Approved for Submit
diff --git a/apps/app_read.c b/apps/app_read.c
index 977b20d..f4a965c 100644
--- a/apps/app_read.c
+++ b/apps/app_read.c
@@ -250,7 +250,7 @@
break;
}
tmp[x++] = res;
- if (strchr(terminator, tmp[x-1])) {
+ if (terminator && strchr(terminator, tmp[x-1])) {
tmp[x-1] = '\0';
status = "OK";
break;
diff --git a/main/app.c b/main/app.c
index f5fbffd..411d507 100644
--- a/main/app.c
+++ b/main/app.c
@@ -249,7 +249,7 @@
fto = 50;
to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
}
- res = ast_readstring(c, s, maxlen, to, fto, S_OR(terminator, "#"));
+ res = ast_readstring(c, s, maxlen, to, fto, (terminator ? terminator : "#"));
if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
return res;
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17486
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: I9b6b72196dd04f5b1e0ab5aa1b0adf627725e086
Gerrit-Change-Number: 17486
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211116/7bf927a5/attachment.html>
More information about the asterisk-code-review
mailing list