]> granicus.if.org Git - file/commitdiff
patch for systems that don't support REG_STARTEND
authorChristos Zoulas <christos@zoulas.com>
Fri, 2 Mar 2007 17:50:06 +0000 (17:50 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 2 Mar 2007 17:50:06 +0000 (17:50 +0000)
src/softmagic.c

index dd80d5e9e84cd189ab5c7753e8eb9efe3211a1be..f60d840ad3e3a63da7e1999c58ec00a1f705ce10 100644 (file)
@@ -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;