file/file-4.20-reg_startend.dif

39 lines
1.1 KiB
Plaintext

Index: softmagic.c
===================================================================
RCS file: /p/file/cvsroot/file/src/softmagic.c,v
retrieving revision 1.91
retrieving revision 1.95
diff -u -r1.91 -r1.95
--- src/softmagic.c 18 Jan 2007 05:29:33 -0000 1.91
+++ src/softmagic.c 3 Mar 2007 19:09:25 -0000 1.95
@@ -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.95 2007/03/03 19:09:25 christos Exp $")
#endif /* lint */
private int match(struct magic_set *, struct magic *, uint32_t,
@@ -1523,10 +1523,20 @@
}
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:
ms->search.s += (int)pmatch[0].rm_so;