Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 15 Jan 2013 19:55:23 +0100
From: Daniel Cegiełka <>
Subject: Re: REG_STARTEND (regex)

2013/1/15 Rich Felker <>

> 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];
#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';
			pmatch[0].rm_so = 0;
			pmatch[0].rm_eo = ms->search.s_len;
			rc = regexec(&rx, (const char *)ms->search.s,
			    1, pmatch, REG_STARTEND);
			((char *)(intptr_t)ms->search.s)[l] = c;
			switch (rc) {
			case 0:

Best regards,

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.