From: "Daniel Cegiełka" <daniel.cegielka@gmail.com>
To: musl@lists.openwall.com
Subject: Re: REG_STARTEND (regex)
Date: Tue, 15 Jan 2013 19:55:23 +0100 [thread overview]
Message-ID: <CAPLrYEQOt3DDtwt4j6gcnjkPrJCtPmLK=wpmfuZbPO1Xbf+AaA@mail.gmail.com> (raw)
In-Reply-To: <20130115184513.GZ20323@brightrain.aerifal.cx>
2013/1/15 Rich Felker <dalias@aerifal.cx>
> If the start position is 0, which it seems to be here, there's nothing
> to be done but removing REG_STARTEND. All it's doing is allowing you
> to process data with embedded nul bytes, which is not required by the
> standard or useful for any meaningful use of sed. Nobody will notice
> the difference with it missing unless they're trying to perform
> hideous hacks like patching binary files with sed...
>
> If the start position were not zero, you could compensate by just
> adding the start offset to the pointer you pass in, then adjusting all
> the match offsets after regexec returns.
>
thx Rich,
I found a similar solution in a 'file' package:
else {
regmatch_t pmatch[1];
#ifndef REG_STARTEND
#define REG_STARTEND 0
size_t l = ms->search.s_len - 1;
char c = ms->search.s[l];
((char *)(intptr_t)ms->search.s)[l] = '\0';
#else
pmatch[0].rm_so = 0;
pmatch[0].rm_eo = ms->search.s_len;
#endif
rc = regexec(&rx, (const char *)ms->search.s,
1, pmatch, REG_STARTEND);
#if REG_STARTEND == 0
((char *)(intptr_t)ms->search.s)[l] = c;
#endif
switch (rc) {
case 0:
https://raw.github.com/glensc/file/master/src/softmagic.c
Best regards,
Daniel
next prev parent reply other threads:[~2013-01-15 18:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 10:34 Daniel Cegiełka
2013-01-15 13:42 ` Rich Felker
2013-01-15 15:16 ` Daniel Cegiełka
2013-01-15 15:37 ` John Spencer
2013-01-15 15:50 ` Daniel Cegiełka
2013-01-15 16:13 ` Rob Landley
2013-01-15 18:38 ` John Spencer
2013-01-16 15:41 ` Rob Landley
2013-01-15 16:11 ` Rob Landley
2013-01-15 18:45 ` Rich Felker
2013-01-15 18:55 ` Daniel Cegiełka [this message]
2013-01-16 15:42 ` Rob Landley
2013-01-16 16:57 ` Rich Felker
2014-06-11 14:24 ` Justin Cormack
2014-06-12 1:00 ` bfdamkoehler
2014-06-12 1:40 ` Rich Felker
2014-06-13 1:15 ` bfdamkoehler
2014-06-13 3:00 ` Rich Felker
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='CAPLrYEQOt3DDtwt4j6gcnjkPrJCtPmLK=wpmfuZbPO1Xbf+AaA@mail.gmail.com' \
--to=daniel.cegielka@gmail.com \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).