999-upstream-reg-startend.dpatch 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh /usr/share/dpatch/dpatch-run
  2. @DPATCH@
  3. diff -Naur file-4.20.orig/src/softmagic.c file-4.20/src/softmagic.c
  4. --- file-4.20.orig/src/softmagic.c 2007-01-18 05:45:35.000000000 +0000
  5. +++ file-4.20/src/softmagic.c 2007-04-03 18:01:25.000000000 +0000
  6. @@ -38,7 +38,7 @@
  7. #ifndef lint
  8. -FILE_RCSID("@(#)$File: softmagic.c,v 1.91 2007/01/18 05:29:33 ljt Exp $")
  9. +FILE_RCSID("@(#)$File: softmagic.c,v 1.95 2007/03/03 19:09:25 christos Exp $")
  10. #endif /* lint */
  11. private int match(struct magic_set *, struct magic *, uint32_t,
  12. @@ -1523,10 +1523,20 @@
  13. }
  14. else {
  15. regmatch_t pmatch[1];
  16. +#ifndef REG_STARTEND
  17. +#define REG_STARTEND 0
  18. + size_t l = ms->search.s_len - 1;
  19. + char c = ms->search.s[l];
  20. + ((char *)(intptr_t)ms->search.s)[l] = '\0';
  21. +#else
  22. pmatch[0].rm_so = 0;
  23. pmatch[0].rm_eo = ms->search.s_len;
  24. +#endif
  25. rc = regexec(&rx, (const char *)ms->search.s,
  26. 1, pmatch, REG_STARTEND);
  27. +#if REG_STARTEND == 0
  28. + ((char *)(intptr_t)ms->search.s)[l] = c;
  29. +#endif
  30. switch (rc) {
  31. case 0:
  32. ms->search.s += (int)pmatch[0].rm_so;