Export-store_cop_label-on-Windows.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. Required on Windows only for 5.10-5.15.1
  2. From a70c7e2f048a735797bc368a5de5669f371e78fa Mon Sep 17 00:00:00 2001
  3. From: Reini Urban <rurban@x-ray.at>
  4. Date: Tue, 21 Jun 2011 07:55:56 -0500
  5. Subject: [PATCH] Export store_cop_label for the perl compiler
  6. ---
  7. embed.fnc | 4 ++--
  8. ext/XS-APItest/APItest.xs | 21 +++++++++++++++++++++
  9. hv.c | 18 ++++++++++++++++++
  10. 3 files changed, 41 insertions(+), 2 deletions(-)
  11. diff --git a/embed.fnc b/embed.fnc
  12. index 71c10af..6b43bfb 100644
  13. --- a/embed.fnc
  14. +++ b/embed.fnc
  15. @@ -2446,8 +2446,8 @@ Apon |void |sys_init3 |NN int* argc|NN char*** argv|NN char*** env
  16. Apon |void |sys_term
  17. ApoM |const char *|fetch_cop_label|NN COP *const cop \
  18. |NULLOK STRLEN *len|NULLOK U32 *flags
  19. -: Only used in op.c
  20. -xpoM |void|store_cop_label \
  21. +: Only used in op.c and the perl compiler
  22. +ApoM |void|store_cop_label \
  23. |NN COP *const cop|NN const char *label|STRLEN len|U32 flags
  24. xpo |int |keyword_plugin_standard|NN char* keyword_ptr|STRLEN keyword_len|NN OP** op_ptr
  25. diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
  26. index 21f417d..6164bd0 100644
  27. --- a/ext/XS-APItest/APItest.xs
  28. +++ b/ext/XS-APItest/APItest.xs
  29. @@ -2348,6 +2348,27 @@ test_cophh()
  30. #undef msvpvs
  31. #undef msviv
  32. +void
  33. +test_coplabel()
  34. + PREINIT:
  35. + COP *cop;
  36. + char *label;
  37. + int len, utf8;
  38. + CODE:
  39. + cop = &PL_compiling;
  40. + Perl_store_cop_label(aTHX_ cop, "foo", 3, 0);
  41. + label = Perl_fetch_cop_label(aTHX_ cop, &len, &utf8);
  42. + if (strcmp(label,"foo")) croak("fail # fetch_cop_label label");
  43. + if (len != 3) croak("fail # fetch_cop_label len");
  44. + if (utf8) croak("fail # fetch_cop_label utf8");
  45. + /* SMALL GERMAN UMLAUT A */
  46. + Perl_store_cop_label(aTHX_ cop, "foä", 4, SVf_UTF8);
  47. + label = Perl_fetch_cop_label(aTHX_ cop, &len, &utf8);
  48. + if (strcmp(label,"foä")) croak("fail # fetch_cop_label label");
  49. + if (len != 3) croak("fail # fetch_cop_label len");
  50. + if (!utf8) croak("fail # fetch_cop_label utf8");
  51. +
  52. +
  53. HV *
  54. example_cophh_2hv()
  55. PREINIT:
  56. diff --git a/hv.c b/hv.c
  57. index a230c16..11c5565 100644
  58. --- a/hv.c
  59. +++ b/hv.c
  60. @@ -3286,6 +3286,15 @@ Perl_refcounted_he_inc(pTHX_ struct refcounted_he *he)
  61. return he;
  62. }
  63. +/*
  64. +=for apidoc fetch_cop_label
  65. +
  66. +Returns the label attached to a cop.
  67. +The flags pointer may be set to C<SVf_UTF8> or 0.
  68. +
  69. +=cut
  70. +*/
  71. +
  72. /* pp_entereval is aware that labels are stored with a key ':' at the top of
  73. the linked list. */
  74. const char *
  75. @@ -3322,6 +3331,15 @@ Perl_fetch_cop_label(pTHX_ COP *const cop, STRLEN *len, U32 *flags) {
  76. return chain->refcounted_he_data + 1;
  77. }
  78. +/*
  79. +=for apidoc store_cop_label
  80. +
  81. +Save a label into a C<cop_hints_hash>. You need to set flags to C<SVf_UTF8>
  82. +for a utf-8 label.
  83. +
  84. +=cut
  85. +*/
  86. +
  87. void
  88. Perl_store_cop_label(pTHX_ COP *const cop, const char *label, STRLEN len,
  89. U32 flags)
  90. --
  91. 1.7.5.4