disable-linking-pcre.patch 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. From 5557838e5f2d8d6e4022168785a7b8cdfee08c25 Mon Sep 17 00:00:00 2001
  2. From: Alexandre Rostovtsev <tetromino@gentoo.org>
  3. Date: Fri, 20 Apr 2012 14:57:59 -0400
  4. Subject: [PATCH] Drop pcre workaround for <glib-2.15.1
  5. For unknown reason, it sometimes gets enabled even onmodern systems,
  6. causing problems.
  7. https://bugzilla.gnome.org/show_bug.cgi?id=670316
  8. ---
  9. configure.in | 24 +----------
  10. goffice/utils/regutf8.c | 106 -----------------------------------------------
  11. 2 files changed, 1 insertions(+), 129 deletions(-)
  12. diff --git a/configure.in b/configure.in
  13. index fd40d53..62e299d 100644
  14. --- a/configure.in
  15. +++ b/configure.in
  16. @@ -93,7 +93,7 @@ PKG_PROG_PKG_CONFIG
  17. dnl *****************************
  18. goffice_reqs="
  19. - glib-2.0 >= 2.8.0
  20. + glib-2.0 >= 2.16.0
  21. gobject-2.0 >= 2.16.0
  22. gmodule-2.0 >= 2.16.0
  23. gio-2.0 >= 2.16.0
  24. @@ -492,13 +492,6 @@ SAVE_CFLAGS=$CFLAGS
  25. SAVE_LIBS=$LIBS
  26. CFLAGS="$CFLAGS $GOFFICE_CFLAGS"
  27. LIBS="$GOFFICE_LIBS $LIBS"
  28. -AC_MSG_CHECKING([for G_REGEX_ERROR_STRAY_BACKSLASH])
  29. -AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gregex.h>]], [[GRegexError error=G_REGEX_ERROR_STRAY_BACKSLASH;]])],
  30. - [AC_DEFINE(HAVE_G_REGEX_ERROR_STRAY_BACKSLASH, 1, [Define if G_REGEX_ERROR_STRAY_BACKSLASH is defined])
  31. - glib_has_G_REGEX_ERROR_STRAY_BACKSLASH=yes
  32. - AC_MSG_RESULT(yes)],
  33. - [AC_MSG_RESULT(no)
  34. - glib_has_G_REGEX_ERROR_STRAY_BACKSLASH=no])
  35. if test "x$goffice_with_gtk" = "xtrue" ; then
  36. AC_CHECK_FUNCS(gtk_dialog_get_response_for_widget)
  37. AC_CHECK_FUNCS(gtk_widget_set_tooltip_text gtk_tool_item_set_tooltip_text,
  38. @@ -511,21 +504,6 @@ if test $gtk_disable_deprecated = yes; then
  39. CFLAGS="$CFLAGS -DGTK_DISABLE_DEPRECATED"
  40. fi
  41. -if test "x$glib_has_G_REGEX_ERROR_STRAY_BACKSLASH" = "xno"; then
  42. - dnl Check for working pcre
  43. - AC_CHECK_HEADER(pcre.h,[], AC_MSG_ERROR([Header files for PCRE were not found]))
  44. - AC_CHECK_LIB(pcre,pcre_compile2,[], AC_MSG_ERROR([The PCRE library is missing or too old]))
  45. - AC_MSG_CHECKING([for UTF-8 support in pcre])
  46. - if (pcretest -C 2>&1) | grep -i "^ *UTF-8 support" >/dev/null; then
  47. - AC_MSG_RESULT(yes)
  48. - LIBS="$LIBS -lpcre"
  49. - EXTRA_LIBS="$EXTRA_LIBS -lpcre"
  50. - else
  51. - AC_MSG_ERROR([The installed PCRE library is not configured for UTF-8 support.])
  52. - fi
  53. -fi
  54. -
  55. -
  56. AC_DEFUN([GOFFICE_CHECK_FUNC],
  57. [AC_CHECK_FUNC([$1],
  58. [],
  59. diff --git a/goffice/utils/regutf8.c b/goffice/utils/regutf8.c
  60. index bc4aae4..3f32dd6 100644
  61. --- a/goffice/utils/regutf8.c
  62. +++ b/goffice/utils/regutf8.c
  63. @@ -7,9 +7,6 @@
  64. #include <goffice/goffice-config.h>
  65. #include "regutf8.h"
  66. -#ifndef HAVE_G_REGEX_ERROR_STRAY_BACKSLASH
  67. -#include <pcre.h>
  68. -#endif
  69. #include "go-glib-extras.h"
  70. #include <gsf/gsf-impl-utils.h>
  71. #include <glib/gi18n-lib.h>
  72. @@ -21,11 +18,7 @@ void
  73. go_regfree (GORegexp *gor)
  74. {
  75. if (gor->ppcre) {
  76. -#ifdef HAVE_G_REGEX_ERROR_STRAY_BACKSLASH
  77. g_regex_unref (gor->ppcre);
  78. -#else
  79. - pcre_free (gor->ppcre);
  80. -#endif
  81. gor->ppcre = NULL;
  82. }
  83. }
  84. @@ -70,7 +63,6 @@ go_regerror (int errcode, const GORegexp *gor, char *dst, size_t dstsize)
  85. int
  86. go_regcomp (GORegexp *gor, const char *pat, int cflags)
  87. {
  88. -#ifdef HAVE_G_REGEX_ERROR_STRAY_BACKSLASH
  89. GError *error = NULL;
  90. GRegex *r;
  91. int coptions =
  92. @@ -119,47 +111,6 @@ go_regcomp (GORegexp *gor, const char *pat, int cflags)
  93. gor->nosub = (cflags & GO_REG_NOSUB) != 0;
  94. return 0;
  95. }
  96. -#else
  97. - const char *errorptr;
  98. - int errorofs, errorcode;
  99. - pcre *r;
  100. - int coptions =
  101. - PCRE_UTF8 |
  102. - PCRE_NO_UTF8_CHECK |
  103. - ((cflags & GO_REG_ICASE) ? PCRE_CASELESS : 0) |
  104. - ((cflags & GO_REG_NEWLINE) ? PCRE_MULTILINE : 0);
  105. -
  106. - if (&pcre_compile2 == NULL) {
  107. - g_error ("libgoffice has been dynamically linked against a libpcre\n"
  108. - "that lacks the pcre_compile2 function. This indicates a\n"
  109. - "distribution dependency problem. Please report this at\n"
  110. - "bugzilla.gnome.org and for you distribution.");
  111. - }
  112. -
  113. - gor->ppcre = r = pcre_compile2 (pat, coptions,
  114. - &errorcode, &errorptr, &errorofs,
  115. - NULL);
  116. -
  117. - if (r == NULL) {
  118. - switch (errorcode) {
  119. - case 1: case 2: case 3: case 37: return GO_REG_EESCAPE;
  120. - case 4: case 5: return GO_REG_EBRACE;
  121. - case 6: return GO_REG_EBRACK;
  122. - case 7: case 30: return GO_REG_ECTYPE;
  123. - case 8: return GO_REG_ERANGE;
  124. - case 9: case 10: return GO_REG_BADRPT;
  125. - case 14: case 18: case 22: return GO_REG_EPAREN;
  126. - case 15: return GO_REG_ESUBREG;
  127. - case 19: case 20: return GO_REG_ESIZE;
  128. - case 21: return GO_REG_ESPACE;
  129. - default: return GO_REG_BADPAT;
  130. - }
  131. - } else {
  132. - gor->re_nsub = pcre_info (r, NULL, NULL);
  133. - gor->nosub = (cflags & GO_REG_NOSUB) != 0;
  134. - return 0;
  135. - }
  136. -#endif
  137. return 0;
  138. }
  139. @@ -167,7 +118,6 @@ int
  140. go_regexec (const GORegexp *gor, const char *txt,
  141. size_t nmatch, GORegmatch *pmatch, int eflags)
  142. {
  143. -#ifdef HAVE_G_REGEX_ERROR_STRAY_BACKSLASH
  144. int eoptions =
  145. ((eflags & GO_REG_NOTBOL) ? G_REGEX_MATCH_NOTBOL : 0) |
  146. ((eflags & GO_REG_NOTEOL) ? G_REGEX_MATCH_NOTEOL : 0);
  147. @@ -196,62 +146,6 @@ go_regexec (const GORegexp *gor, const char *txt,
  148. g_match_info_free (match_info);
  149. return matched ? GO_REG_NOERROR : GO_REG_NOMATCH;
  150. -#else
  151. - size_t txtlen = strlen (txt);
  152. - int eoptions =
  153. - ((eflags & GO_REG_NOTBOL) ? PCRE_NOTBOL : 0) |
  154. - ((eflags & GO_REG_NOTEOL) ? PCRE_NOTEOL : 0);
  155. - int res;
  156. - int *offsets, *allocated;
  157. - int offsetcount;
  158. - if (gor->nosub)
  159. - nmatch = 0;
  160. -
  161. - if (nmatch > 0) {
  162. - /* Paranoia. */
  163. - if (nmatch >= G_MAXINT / sizeof (int) / 3)
  164. - return GO_REG_ESPACE;
  165. -
  166. - offsetcount = nmatch * 3;
  167. - offsets = allocated = g_try_new (int, offsetcount);
  168. - if (!offsets)
  169. - return GO_REG_ESPACE;
  170. - } else {
  171. - offsets = allocated = NULL;
  172. - offsetcount = 0;
  173. - }
  174. -
  175. - res = pcre_exec (gor->ppcre, NULL, txt, txtlen, 0, eoptions,
  176. - offsets, offsetcount);
  177. - if (res >= 0) {
  178. - int i;
  179. -
  180. - if (res == 0) res = nmatch;
  181. -
  182. - for (i = 0; i < res; i++) {
  183. - pmatch[i].rm_so = offsets[i * 2];
  184. - pmatch[i].rm_eo = offsets[i * 2 + 1];
  185. - }
  186. - for (; i < (int)nmatch; i++) {
  187. - pmatch[i].rm_so = -1;
  188. - pmatch[i].rm_eo = -1;
  189. - }
  190. - g_free (allocated);
  191. - return GO_REG_NOERROR;
  192. - }
  193. -
  194. - g_free (allocated);
  195. - switch (res) {
  196. - case PCRE_ERROR_NOMATCH:
  197. - return GO_REG_NOMATCH;
  198. - case PCRE_ERROR_BADUTF8:
  199. - case PCRE_ERROR_BADUTF8_OFFSET:
  200. - /* POSIX doesn't seem to foresee this kind of error. */
  201. - return GO_REG_BADPAT;
  202. - default:
  203. - return GO_REG_ESPACE;
  204. - }
  205. -#endif
  206. }
  207. /* ------------------------------------------------------------------------- */
  208. --
  209. 1.7.8.5