Skip Menu |

This queue is for tickets about the Filter CPAN distribution.

Report information
The Basics
Id: 25206
Status: resolved
Priority: 0/
Queue: Filter

People
Owner: Nobody in particular
Requestors: at [...] altlinux.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] */*.xs: replaced ninstr() with memchr(3)
Date: Wed, 28 Feb 2007 11:34:47 +0300
To: bug-filter [...] rt.cpan.org
From: Alexey Tourbin <at [...] altlinux.ru>
See this thread http://www.nntp.perl.org/group/perl.perl5.porters/2007/02/msg121477.html --- Call/Call.xs | 3 +-- Exec/Exec.xs | 3 +-- decrypt/decrypt.xs | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Call/Call.xs b/Call/Call.xs index f3344dc..69281c3 100644 --- a/Call/Call.xs +++ b/Call/Call.xs @@ -50,7 +50,6 @@ filter_call(pTHX_ int idx, SV *buf_sv, int maxlen) { dMY_CXT; SV *my_sv = FILTER_DATA(idx); - char *nl = "\n"; char *p; char *out_ptr; int n; @@ -85,7 +84,7 @@ filter_call(pTHX_ int idx, SV *buf_sv, int maxlen) } else { /* want lines */ - if ((p = ninstr(out_ptr, out_ptr + n, nl, nl + 1))) { + if ((p = memchr(out_ptr, '\n', n))) { sv_catpvn(buf_sv, out_ptr, p - out_ptr + 1); diff --git a/Exec/Exec.xs b/Exec/Exec.xs index 712f704..e12bd08 100644 --- a/Exec/Exec.xs +++ b/Exec/Exec.xs @@ -481,7 +481,6 @@ filter_exec(pTHX_ int idx, SV *buf_sv, int maxlen) char * out_ptr = SvPVX(buffer) ; int n ; char * p ; - char * nl = "\n" ; if (fdebug) warn ("filter_sh(idx=%d, SvCUR(buf_sv)=%d, maxlen=%d\n", @@ -513,7 +512,7 @@ filter_exec(pTHX_ int idx, SV *buf_sv, int maxlen) /* want a line */ if (fdebug) warn("filter_sh(%d) - wants a line\n", idx) ; - if (p = ninstr(out_ptr, out_ptr + n - 1, nl, nl)) { + if ((p = memchr(out_ptr, '\n', n))) { sv_catpvn(buf_sv, out_ptr, p - out_ptr + 1); n = n - (p - out_ptr + 1); BUF_OFFSET(buffer) += (p - out_ptr + 1); diff --git a/decrypt/decrypt.xs b/decrypt/decrypt.xs index e550656..fdae675 100644 --- a/decrypt/decrypt.xs +++ b/decrypt/decrypt.xs @@ -129,7 +129,6 @@ static I32 filter_decrypt(pTHX_ int idx, SV *buf_sv, int maxlen) { SV *my_sv = FILTER_DATA(idx); - char *nl = "\n"; char *p; char *out_ptr; int n; @@ -186,7 +185,7 @@ filter_decrypt(pTHX_ int idx, SV *buf_sv, int maxlen) } else { /* want lines */ - if ((p = ninstr(out_ptr, out_ptr + n - 1, nl, nl))) { + if ((p = memchr(out_ptr, '\n', n))) { sv_catpvn(buf_sv, out_ptr, p - out_ptr + 1); -- 1.5.0.1.GIT
From: rurban [...] x-ray.at
Am Mi 28. Feb 2007, 03:27:40, at@altlinux.ru schrieb: Show quoted text
Here it was agreed, that using ninstr for searching single bytes is indeed inefficient and overengineering, but older systems like 4.2BSD-derived (ULTRIX) don't carry memchr. You could use #ifdef HAVE_MEMCHR but we already fixed the ninstr() off-by-one issue. So this ticket should be closed.
Thanks for your patch. You were technically right, but porters decided not to do it. So we did neither for consistency. See my previous message. -- Reini Urban