From 2d81af06d08d01a5d11d5d175a48924f226b623c Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 2 Mar 2007 19:29:55 +0000 Subject: [PATCH] ugly hack to override const. --- src/softmagic.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/softmagic.c b/src/softmagic.c index f60d840a..207685a2 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -38,7 +38,7 @@ #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.91 2007/01/18 05:29:33 ljt Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.92 2007/03/02 17:50:06 christos Exp $") #endif /* lint */ private int match(struct magic_set *, struct magic *, uint32_t, @@ -1525,8 +1525,9 @@ magiccheck(struct magic_set *ms, struct magic *m) 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'; + 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; @@ -1534,7 +1535,7 @@ magiccheck(struct magic_set *ms, struct magic *m) 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; + ((char *)(intptr_t)ms->search.s)[l] = c; #endif switch (rc) { case 0: -- 2.40.0