From f88146d5d60c166de188f3b1ed40f19fdf283c05 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 2 Mar 2007 17:50:06 +0000 Subject: [PATCH] patch for systems that don't support REG_STARTEND --- src/softmagic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/softmagic.c b/src/softmagic.c index dd80d5e9..f60d840a 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -38,7 +38,7 @@ #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.89 2007/01/16 14:58:48 ljt Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.91 2007/01/18 05:29:33 ljt Exp $") #endif /* lint */ private int match(struct magic_set *, struct magic *, uint32_t, @@ -1523,10 +1523,19 @@ magiccheck(struct magic_set *ms, struct magic *m) } else { regmatch_t pmatch[1]; +#ifndef REG_STARTEND +#define REG_STARTEND 0 + char c = ms->search.s[ms->search.s_len - 1]; + ms->search.s[ms->search.s_len - 1] = '\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 + ms->search.s[ms->search.s_len - 1] = c; +#endif switch (rc) { case 0: ms->search.s += (int)pmatch[0].rm_so; -- 2.40.0