rugged 1.9.4 → 1.9.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +1 -1
  4. data/vendor/libgit2/COPYING +83 -11
  5. data/vendor/libgit2/cmake/SelectRegex.cmake +8 -3
  6. data/vendor/libgit2/deps/pcre2/CMakeLists.txt +110 -0
  7. data/vendor/libgit2/deps/pcre2/LICENCE.md +104 -0
  8. data/vendor/libgit2/deps/pcre2/config.h.in +54 -0
  9. data/vendor/libgit2/deps/pcre2/pcre2.h +1079 -0
  10. data/vendor/libgit2/deps/pcre2/pcre2_auto_possess.c +1416 -0
  11. data/vendor/libgit2/deps/{pcre/pcre_chartables.c → pcre2/pcre2_chartables.c} +41 -47
  12. data/vendor/libgit2/deps/{pcre/pcre_ord2utf8.c → pcre2/pcre2_chkdint.c} +36 -36
  13. data/vendor/libgit2/deps/pcre2/pcre2_compile.c +11345 -0
  14. data/vendor/libgit2/deps/pcre2/pcre2_compile.h +356 -0
  15. data/vendor/libgit2/deps/pcre2/pcre2_compile_cgroup.c +632 -0
  16. data/vendor/libgit2/deps/pcre2/pcre2_compile_class.c +2777 -0
  17. data/vendor/libgit2/deps/pcre2/pcre2_config.c +250 -0
  18. data/vendor/libgit2/deps/pcre2/pcre2_context.c +557 -0
  19. data/vendor/libgit2/deps/pcre2/pcre2_convert.c +1263 -0
  20. data/vendor/libgit2/deps/{pcre/pcre_dfa_exec.c → pcre2/pcre2_dfa_match.c} +1402 -943
  21. data/vendor/libgit2/deps/pcre2/pcre2_error.c +384 -0
  22. data/vendor/libgit2/deps/pcre2/pcre2_extuni.c +159 -0
  23. data/vendor/libgit2/deps/pcre2/pcre2_find_bracket.c +217 -0
  24. data/vendor/libgit2/deps/pcre2/pcre2_fuzzsupport.c +844 -0
  25. data/vendor/libgit2/deps/pcre2/pcre2_internal.h +2353 -0
  26. data/vendor/libgit2/deps/pcre2/pcre2_intmodedep.h +1044 -0
  27. data/vendor/libgit2/deps/pcre2/pcre2_maketables.c +177 -0
  28. data/vendor/libgit2/deps/pcre2/pcre2_match.c +8244 -0
  29. data/vendor/libgit2/deps/pcre2/pcre2_match_data.c +184 -0
  30. data/vendor/libgit2/deps/pcre2/pcre2_match_next.c +171 -0
  31. data/vendor/libgit2/deps/{pcre/pcre_newline.c → pcre2/pcre2_newline.c} +92 -63
  32. data/vendor/libgit2/deps/{pcre/pcre_refcount.c → pcre2/pcre2_ord2utf.c} +64 -38
  33. data/vendor/libgit2/deps/pcre2/pcre2_pattern_info.c +430 -0
  34. data/vendor/libgit2/deps/pcre2/pcre2_printint_inc.h +1098 -0
  35. data/vendor/libgit2/deps/pcre2/pcre2_script_run.c +344 -0
  36. data/vendor/libgit2/deps/pcre2/pcre2_serialize.c +284 -0
  37. data/vendor/libgit2/deps/pcre2/pcre2_string_utils.c +199 -0
  38. data/vendor/libgit2/deps/pcre2/pcre2_study.c +2087 -0
  39. data/vendor/libgit2/deps/pcre2/pcre2_substitute.c +1761 -0
  40. data/vendor/libgit2/deps/pcre2/pcre2_substring.c +553 -0
  41. data/vendor/libgit2/deps/pcre2/pcre2_tables.c +310 -0
  42. data/vendor/libgit2/deps/pcre2/pcre2_ucd.c +5805 -0
  43. data/vendor/libgit2/deps/pcre2/pcre2_ucp.h +408 -0
  44. data/vendor/libgit2/deps/pcre2/pcre2_ucptables_inc.h +1596 -0
  45. data/vendor/libgit2/deps/pcre2/pcre2_util.h +179 -0
  46. data/vendor/libgit2/deps/pcre2/pcre2_valid_utf.c +397 -0
  47. data/vendor/libgit2/deps/pcre2/pcre2_xclass.c +547 -0
  48. data/vendor/libgit2/include/git2/common.h +13 -1
  49. data/vendor/libgit2/include/git2/version.h +2 -2
  50. data/vendor/libgit2/src/libgit2/blame.c +6 -0
  51. data/vendor/libgit2/src/libgit2/delta.c +8 -0
  52. data/vendor/libgit2/src/libgit2/indexer.c +3 -2
  53. data/vendor/libgit2/src/libgit2/settings.c +9 -0
  54. data/vendor/libgit2/src/libgit2/streams/openssl.c +4 -1
  55. data/vendor/libgit2/src/libgit2/submodule.c +77 -12
  56. data/vendor/libgit2/src/libgit2/transports/http.c +4 -4
  57. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +2 -1
  58. data/vendor/libgit2/src/util/fs_path.h +10 -10
  59. data/vendor/libgit2/src/util/regexp.c +27 -12
  60. data/vendor/libgit2/src/util/regexp.h +7 -2
  61. metadata +44 -37
  62. data/vendor/libgit2/deps/pcre/CMakeLists.txt +0 -140
  63. data/vendor/libgit2/deps/pcre/COPYING +0 -5
  64. data/vendor/libgit2/deps/pcre/LICENCE +0 -93
  65. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +0 -22
  66. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +0 -17
  67. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +0 -58
  68. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +0 -29
  69. data/vendor/libgit2/deps/pcre/config.h.in +0 -57
  70. data/vendor/libgit2/deps/pcre/pcre.h +0 -641
  71. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +0 -319
  72. data/vendor/libgit2/deps/pcre/pcre_compile.c +0 -9815
  73. data/vendor/libgit2/deps/pcre/pcre_config.c +0 -190
  74. data/vendor/libgit2/deps/pcre/pcre_exec.c +0 -7173
  75. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +0 -245
  76. data/vendor/libgit2/deps/pcre/pcre_get.c +0 -669
  77. data/vendor/libgit2/deps/pcre/pcre_globals.c +0 -86
  78. data/vendor/libgit2/deps/pcre/pcre_internal.h +0 -2787
  79. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +0 -11913
  80. data/vendor/libgit2/deps/pcre/pcre_maketables.c +0 -156
  81. data/vendor/libgit2/deps/pcre/pcre_printint.c +0 -834
  82. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +0 -211
  83. data/vendor/libgit2/deps/pcre/pcre_study.c +0 -1686
  84. data/vendor/libgit2/deps/pcre/pcre_tables.c +0 -727
  85. data/vendor/libgit2/deps/pcre/pcre_ucd.c +0 -3644
  86. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +0 -301
  87. data/vendor/libgit2/deps/pcre/pcre_version.c +0 -98
  88. data/vendor/libgit2/deps/pcre/pcre_xclass.c +0 -268
  89. data/vendor/libgit2/deps/pcre/pcreposix.c +0 -420
  90. data/vendor/libgit2/deps/pcre/pcreposix.h +0 -117
  91. data/vendor/libgit2/deps/pcre/ucp.h +0 -224
@@ -0,0 +1,184 @@
1
+ /*************************************************
2
+ * Perl-Compatible Regular Expressions *
3
+ *************************************************/
4
+
5
+ /* PCRE is a library of functions to support regular expressions whose syntax
6
+ and semantics are as close as possible to those of the Perl 5 language.
7
+
8
+ Written by Philip Hazel
9
+ Original API code Copyright (c) 1997-2012 University of Cambridge
10
+ New API code Copyright (c) 2016-2024 University of Cambridge
11
+
12
+ -----------------------------------------------------------------------------
13
+ Redistribution and use in source and binary forms, with or without
14
+ modification, are permitted provided that the following conditions are met:
15
+
16
+ * Redistributions of source code must retain the above copyright notice,
17
+ this list of conditions and the following disclaimer.
18
+
19
+ * Redistributions in binary form must reproduce the above copyright
20
+ notice, this list of conditions and the following disclaimer in the
21
+ documentation and/or other materials provided with the distribution.
22
+
23
+ * Neither the name of the University of Cambridge nor the names of its
24
+ contributors may be used to endorse or promote products derived from
25
+ this software without specific prior written permission.
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
+ POSSIBILITY OF SUCH DAMAGE.
38
+ -----------------------------------------------------------------------------
39
+ */
40
+
41
+
42
+ #include "pcre2_internal.h"
43
+
44
+
45
+
46
+ /*************************************************
47
+ * Create a match data block given ovector size *
48
+ *************************************************/
49
+
50
+ /* A minimum of 1 is imposed on the number of ovector pairs. A maximum is also
51
+ imposed because the oveccount field in a match data block is uintt6_t. */
52
+
53
+ PCRE2_EXP_DEFN pcre2_match_data * PCRE2_CALL_CONVENTION
54
+ pcre2_match_data_create(uint32_t oveccount, pcre2_general_context *gcontext)
55
+ {
56
+ pcre2_match_data *yield;
57
+ if (oveccount < 1) oveccount = 1;
58
+ if (oveccount > UINT16_MAX) oveccount = UINT16_MAX;
59
+ yield = PRIV(memctl_malloc)(
60
+ offsetof(pcre2_match_data, ovector) + 2*oveccount*sizeof(PCRE2_SIZE),
61
+ (pcre2_memctl *)gcontext);
62
+ if (yield == NULL) return NULL;
63
+ yield->oveccount = oveccount;
64
+ yield->flags = 0;
65
+ yield->heapframes = NULL;
66
+ yield->heapframes_size = 0;
67
+ return yield;
68
+ }
69
+
70
+
71
+
72
+ /*************************************************
73
+ * Create a match data block using pattern data *
74
+ *************************************************/
75
+
76
+ /* If no context is supplied, use the memory allocator from the code. This code
77
+ assumes that a general context contains nothing other than a memory allocator.
78
+ If that ever changes, this code will need fixing. */
79
+
80
+ PCRE2_EXP_DEFN pcre2_match_data * PCRE2_CALL_CONVENTION
81
+ pcre2_match_data_create_from_pattern(const pcre2_code *code,
82
+ pcre2_general_context *gcontext)
83
+ {
84
+ if (code == NULL) return NULL;
85
+ if (gcontext == NULL) gcontext = (pcre2_general_context *)code;
86
+ return pcre2_match_data_create(((const pcre2_real_code *)code)->top_bracket + 1,
87
+ gcontext);
88
+ }
89
+
90
+
91
+
92
+ /*************************************************
93
+ * Free a match data block *
94
+ *************************************************/
95
+
96
+ PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
97
+ pcre2_match_data_free(pcre2_match_data *match_data)
98
+ {
99
+ if (match_data != NULL)
100
+ {
101
+ if (match_data->heapframes != NULL)
102
+ match_data->memctl.free(match_data->heapframes,
103
+ match_data->memctl.memory_data);
104
+ if ((match_data->flags & PCRE2_MD_COPIED_SUBJECT) != 0)
105
+ match_data->memctl.free((void *)match_data->subject,
106
+ match_data->memctl.memory_data);
107
+ match_data->memctl.free(match_data, match_data->memctl.memory_data);
108
+ }
109
+ }
110
+
111
+
112
+
113
+ /*************************************************
114
+ * Get last mark in match *
115
+ *************************************************/
116
+
117
+ PCRE2_EXP_DEFN PCRE2_SPTR PCRE2_CALL_CONVENTION
118
+ pcre2_get_mark(pcre2_match_data *match_data)
119
+ {
120
+ return match_data->mark;
121
+ }
122
+
123
+
124
+
125
+ /*************************************************
126
+ * Get pointer to ovector *
127
+ *************************************************/
128
+
129
+ PCRE2_EXP_DEFN PCRE2_SIZE * PCRE2_CALL_CONVENTION
130
+ pcre2_get_ovector_pointer(pcre2_match_data *match_data)
131
+ {
132
+ return match_data->ovector;
133
+ }
134
+
135
+
136
+
137
+ /*************************************************
138
+ * Get number of ovector slots *
139
+ *************************************************/
140
+
141
+ PCRE2_EXP_DEFN uint32_t PCRE2_CALL_CONVENTION
142
+ pcre2_get_ovector_count(pcre2_match_data *match_data)
143
+ {
144
+ return match_data->oveccount;
145
+ }
146
+
147
+
148
+
149
+ /*************************************************
150
+ * Get starting code unit in match *
151
+ *************************************************/
152
+
153
+ PCRE2_EXP_DEFN PCRE2_SIZE PCRE2_CALL_CONVENTION
154
+ pcre2_get_startchar(pcre2_match_data *match_data)
155
+ {
156
+ return match_data->startchar;
157
+ }
158
+
159
+
160
+
161
+ /*************************************************
162
+ * Get size of match data block *
163
+ *************************************************/
164
+
165
+ PCRE2_EXP_DEFN PCRE2_SIZE PCRE2_CALL_CONVENTION
166
+ pcre2_get_match_data_size(pcre2_match_data *match_data)
167
+ {
168
+ return offsetof(pcre2_match_data, ovector) +
169
+ 2 * (match_data->oveccount) * sizeof(PCRE2_SIZE);
170
+ }
171
+
172
+
173
+
174
+ /*************************************************
175
+ * Get heapframes size *
176
+ *************************************************/
177
+
178
+ PCRE2_EXP_DEFN PCRE2_SIZE PCRE2_CALL_CONVENTION
179
+ pcre2_get_match_data_heapframes_size(pcre2_match_data *match_data)
180
+ {
181
+ return match_data->heapframes_size;
182
+ }
183
+
184
+ /* End of pcre2_match_data.c */
@@ -0,0 +1,171 @@
1
+ /*************************************************
2
+ * Perl-Compatible Regular Expressions *
3
+ *************************************************/
4
+
5
+ /* PCRE is a library of functions to support regular expressions whose syntax
6
+ and semantics are as close as possible to those of the Perl 5 language.
7
+
8
+ Written by Philip Hazel
9
+ Original API code Copyright (c) 1997-2012 University of Cambridge
10
+ New API code Copyright (c) 2016-2024 University of Cambridge
11
+
12
+ -----------------------------------------------------------------------------
13
+ Redistribution and use in source and binary forms, with or without
14
+ modification, are permitted provided that the following conditions are met:
15
+
16
+ * Redistributions of source code must retain the above copyright notice,
17
+ this list of conditions and the following disclaimer.
18
+
19
+ * Redistributions in binary form must reproduce the above copyright
20
+ notice, this list of conditions and the following disclaimer in the
21
+ documentation and/or other materials provided with the distribution.
22
+
23
+ * Neither the name of the University of Cambridge nor the names of its
24
+ contributors may be used to endorse or promote products derived from
25
+ this software without specific prior written permission.
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
+ POSSIBILITY OF SUCH DAMAGE.
38
+ -----------------------------------------------------------------------------
39
+ */
40
+
41
+
42
+ #include "pcre2_internal.h"
43
+
44
+
45
+
46
+ /* Advance the offset by one code unit, and return the new value.
47
+ It is only called when the offset is not at the end of the subject. */
48
+
49
+ static PCRE2_SIZE do_bumpalong(pcre2_match_data *match_data,
50
+ PCRE2_SIZE offset)
51
+ {
52
+ PCRE2_SPTR subject = match_data->subject;
53
+ PCRE2_SIZE subject_length = match_data->subject_length;
54
+ #ifdef SUPPORT_UNICODE
55
+ BOOL utf = (match_data->code->overall_options & PCRE2_UTF) != 0;
56
+ #endif
57
+
58
+ /* Skip over CRLF as an atomic sequence, if CRLF is configured as a newline
59
+ sequence. */
60
+
61
+ if (subject[offset] == CHAR_CR && offset + 1 < subject_length &&
62
+ subject[offset + 1] == CHAR_LF)
63
+ {
64
+ switch(match_data->code->newline_convention)
65
+ {
66
+ case PCRE2_NEWLINE_CRLF:
67
+ case PCRE2_NEWLINE_ANY:
68
+ case PCRE2_NEWLINE_ANYCRLF:
69
+ return offset + 2;
70
+ }
71
+ }
72
+
73
+ /* Advance by one full character if in UTF mode. */
74
+
75
+ #ifdef SUPPORT_UNICODE
76
+ if (utf)
77
+ {
78
+ PCRE2_SPTR next = subject + offset + 1;
79
+ PCRE2_SPTR subject_end = subject + subject_length;
80
+
81
+ (void)subject_end; /* Suppress warning; 32-bit FORWARDCHARTEST ignores this */
82
+ FORWARDCHARTEST(next, subject_end);
83
+ return next - subject;
84
+ }
85
+ #endif
86
+
87
+ return offset + 1;
88
+ }
89
+
90
+
91
+
92
+ /*************************************************
93
+ * Advance the match *
94
+ *************************************************/
95
+
96
+ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
97
+ pcre2_next_match(pcre2_match_data *match_data, PCRE2_SIZE *pstart_offset,
98
+ uint32_t *poptions)
99
+ {
100
+ int rc = match_data->rc;
101
+ PCRE2_SIZE start_offset = match_data->start_offset;
102
+ PCRE2_SIZE *ovector = match_data->ovector;
103
+
104
+ /* Match error, or no match: no further iteration possible. In previous versions
105
+ of PCRE2, we recommended that clients use a strategy which involved retrying in
106
+ certain cases after PCRE2_ERROR_NOMATCH, but this is no longer required. */
107
+
108
+ if (rc < 0)
109
+ return FALSE;
110
+
111
+ /* Match succeeded: get the start offset for the next match */
112
+
113
+ /* Although \K can affect the position of ovector[0], there are no ways to do
114
+ anything surprising with ovector[1], which must always be >= start_offset. */
115
+
116
+ PCRE2_ASSERT(ovector[1] >= start_offset);
117
+
118
+ /* Special handling for patterns which contain \K in a lookaround, which enables
119
+ the match start to be pushed back to before the starting search offset
120
+ (ovector[0] < start_offset) or after the match ends (ovector[0] > ovector[1]).
121
+ This is not a problem if ovector[1] > start_offset, because in this case, we can
122
+ just attempt the next match at ovector[1]: we are making progress, which is all
123
+ that we require.
124
+
125
+ However, if we have ovector[1] == start_offset, then we have a very rare case
126
+ which must be handled specially, because it's a non-empty match which
127
+ nonetheless fails to make progress through the subject. */
128
+
129
+ if (ovector[0] != start_offset && ovector[1] == start_offset)
130
+ {
131
+ /* If the match end is at the end of the subject, we are done. */
132
+
133
+ if (start_offset >= match_data->subject_length)
134
+ return FALSE;
135
+
136
+ /* Otherwise, bump along by one code unit, and do a normal search. */
137
+
138
+ *pstart_offset = do_bumpalong(match_data, ovector[1]);
139
+ *poptions = 0;
140
+ return TRUE;
141
+ }
142
+
143
+ /* If the previous match was for an empty string, we are finished if we are at
144
+ the end of the subject. Otherwise, arrange to run another match at the same
145
+ point to see if a non-empty match can be found. */
146
+
147
+ if (ovector[0] == ovector[1])
148
+ {
149
+ /* If the match is at the end of the subject, we are done. */
150
+
151
+ if (ovector[0] >= match_data->subject_length)
152
+ return FALSE;
153
+
154
+ /* Otherwise, continue at this exact same point, but we must set the flag
155
+ which ensures that we don't return the exact same empty match again. */
156
+
157
+ *pstart_offset = ovector[1];
158
+ *poptions = PCRE2_NOTEMPTY_ATSTART;
159
+ return TRUE;
160
+ }
161
+
162
+ /* Finally, we must be in the happy state of a non-empty match, where the end of
163
+ the match is further on in the subject than start_offset, so we are easily able
164
+ to continue and make progress. */
165
+
166
+ *pstart_offset = ovector[1];
167
+ *poptions = 0;
168
+ return TRUE;
169
+ }
170
+
171
+ /* End of pcre2_match_next.c */
@@ -6,7 +6,8 @@
6
6
  and semantics are as close as possible to those of the Perl 5 language.
7
7
 
8
8
  Written by Philip Hazel
9
- Copyright (c) 1997-2012 University of Cambridge
9
+ Original API code Copyright (c) 1997-2012 University of Cambridge
10
+ New API code Copyright (c) 2016 University of Cambridge
10
11
 
11
12
  -----------------------------------------------------------------------------
12
13
  Redistribution and use in source and binary forms, with or without
@@ -41,17 +42,13 @@ POSSIBILITY OF SUCH DAMAGE.
41
42
  /* This module contains internal functions for testing newlines when more than
42
43
  one kind of newline is to be recognized. When a newline is found, its length is
43
44
  returned. In principle, we could implement several newline "types", each
44
- referring to a different set of newline characters. At present, PCRE supports
45
+ referring to a different set of newline characters. At present, PCRE2 supports
45
46
  only NLTYPE_FIXED, which gets handled without these functions, NLTYPE_ANYCRLF,
46
47
  and NLTYPE_ANY. The full list of Unicode newline characters is taken from
47
48
  http://unicode.org/unicode/reports/tr18/. */
48
49
 
49
50
 
50
- #ifdef HAVE_CONFIG_H
51
- #include "config.h"
52
- #endif
53
-
54
- #include "pcre_internal.h"
51
+ #include "pcre2_internal.h"
55
52
 
56
53
 
57
54
 
@@ -59,8 +56,10 @@ http://unicode.org/unicode/reports/tr18/. */
59
56
  * Check for newline at given position *
60
57
  *************************************************/
61
58
 
62
- /* It is guaranteed that the initial value of ptr is less than the end of the
63
- string that is being processed.
59
+ /* This function is called only via the IS_NEWLINE macro, which does so only
60
+ when the newline type is NLTYPE_ANY or NLTYPE_ANYCRLF. The case of a fixed
61
+ newline (NLTYPE_FIXED) is handled inline. It is guaranteed that the code unit
62
+ pointed to by ptr is less than the end of the string.
64
63
 
65
64
  Arguments:
66
65
  ptr pointer to possible newline
@@ -73,28 +72,30 @@ Returns: TRUE or FALSE
73
72
  */
74
73
 
75
74
  BOOL
76
- PRIV(is_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR endptr, int *lenptr,
77
- BOOL utf)
75
+ PRIV(is_newline)(PCRE2_SPTR ptr, uint32_t type, PCRE2_SPTR endptr,
76
+ uint32_t *lenptr, BOOL utf)
78
77
  {
79
- pcre_uint32 c;
80
- (void)utf;
81
- #ifdef SUPPORT_UTF
82
- if (utf)
83
- {
84
- GETCHAR(c, ptr);
85
- }
86
- else
87
- #endif /* SUPPORT_UTF */
88
- c = *ptr;
78
+ uint32_t c;
89
79
 
90
- /* Note that this function is called only for ANY or ANYCRLF. */
80
+ #ifdef SUPPORT_UNICODE
81
+ if (utf) { GETCHAR(c, ptr); } else c = *ptr;
82
+ #else
83
+ (void)utf;
84
+ c = *ptr;
85
+ #endif /* SUPPORT_UNICODE */
91
86
 
92
87
  if (type == NLTYPE_ANYCRLF) switch(c)
93
88
  {
94
- case CHAR_LF: *lenptr = 1; return TRUE;
95
- case CHAR_CR: *lenptr = (ptr < endptr - 1 && ptr[1] == CHAR_LF)? 2 : 1;
96
- return TRUE;
97
- default: return FALSE;
89
+ case CHAR_LF:
90
+ *lenptr = 1;
91
+ return TRUE;
92
+
93
+ case CHAR_CR:
94
+ *lenptr = (ptr < endptr - 1 && ptr[1] == CHAR_LF)? 2 : 1;
95
+ return TRUE;
96
+
97
+ default:
98
+ return FALSE;
98
99
  }
99
100
 
100
101
  /* NLTYPE_ANY */
@@ -106,25 +107,36 @@ else switch(c)
106
107
  #endif
107
108
  case CHAR_LF:
108
109
  case CHAR_VT:
109
- case CHAR_FF: *lenptr = 1; return TRUE;
110
+ case CHAR_FF:
111
+ *lenptr = 1;
112
+ return TRUE;
110
113
 
111
114
  case CHAR_CR:
112
115
  *lenptr = (ptr < endptr - 1 && ptr[1] == CHAR_LF)? 2 : 1;
113
116
  return TRUE;
114
117
 
115
118
  #ifndef EBCDIC
116
- #ifdef COMPILE_PCRE8
117
- case CHAR_NEL: *lenptr = utf? 2 : 1; return TRUE;
118
- case 0x2028: /* LS */
119
- case 0x2029: *lenptr = 3; return TRUE; /* PS */
120
- #else /* COMPILE_PCRE16 || COMPILE_PCRE32 */
119
+ #if PCRE2_CODE_UNIT_WIDTH == 8
120
+ case CHAR_NEL:
121
+ *lenptr = utf? 2 : 1;
122
+ return TRUE;
123
+
124
+ case 0x2028: /* LS */
125
+ case 0x2029: /* PS */
126
+ *lenptr = 3;
127
+ return TRUE;
128
+
129
+ #else /* 16-bit or 32-bit code units */
121
130
  case CHAR_NEL:
122
- case 0x2028: /* LS */
123
- case 0x2029: *lenptr = 1; return TRUE; /* PS */
124
- #endif /* COMPILE_PCRE8 */
125
- #endif /* Not EBCDIC */
131
+ case 0x2028: /* LS */
132
+ case 0x2029: /* PS */
133
+ *lenptr = 1;
134
+ return TRUE;
135
+ #endif
136
+ #endif /* Not EBCDIC */
126
137
 
127
- default: return FALSE;
138
+ default:
139
+ return FALSE;
128
140
  }
129
141
  }
130
142
 
@@ -134,8 +146,10 @@ else switch(c)
134
146
  * Check for newline at previous position *
135
147
  *************************************************/
136
148
 
137
- /* It is guaranteed that the initial value of ptr is greater than the start of
138
- the string that is being processed.
149
+ /* This function is called only via the WAS_NEWLINE macro, which does so only
150
+ when the newline type is NLTYPE_ANY or NLTYPE_ANYCRLF. The case of a fixed
151
+ newline (NLTYPE_FIXED) is handled inline. It is guaranteed that the initial
152
+ value of ptr is greater than the start of the string that is being processed.
139
153
 
140
154
  Arguments:
141
155
  ptr pointer to possible newline
@@ -148,23 +162,23 @@ Returns: TRUE or FALSE
148
162
  */
149
163
 
150
164
  BOOL
151
- PRIV(was_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR startptr, int *lenptr,
152
- BOOL utf)
165
+ PRIV(was_newline)(PCRE2_SPTR ptr, uint32_t type, PCRE2_SPTR startptr,
166
+ uint32_t *lenptr, BOOL utf)
153
167
  {
154
- pcre_uint32 c;
155
- (void)utf;
168
+ uint32_t c;
156
169
  ptr--;
157
- #ifdef SUPPORT_UTF
170
+
171
+ #ifdef SUPPORT_UNICODE
158
172
  if (utf)
159
173
  {
160
174
  BACKCHAR(ptr);
161
175
  GETCHAR(c, ptr);
162
176
  }
163
- else
164
- #endif /* SUPPORT_UTF */
165
- c = *ptr;
166
-
167
- /* Note that this function is called only for ANY or ANYCRLF. */
177
+ else c = *ptr;
178
+ #else
179
+ (void)utf;
180
+ c = *ptr;
181
+ #endif /* SUPPORT_UNICODE */
168
182
 
169
183
  if (type == NLTYPE_ANYCRLF) switch(c)
170
184
  {
@@ -172,8 +186,12 @@ if (type == NLTYPE_ANYCRLF) switch(c)
172
186
  *lenptr = (ptr > startptr && ptr[-1] == CHAR_CR)? 2 : 1;
173
187
  return TRUE;
174
188
 
175
- case CHAR_CR: *lenptr = 1; return TRUE;
176
- default: return FALSE;
189
+ case CHAR_CR:
190
+ *lenptr = 1;
191
+ return TRUE;
192
+
193
+ default:
194
+ return FALSE;
177
195
  }
178
196
 
179
197
  /* NLTYPE_ANY */
@@ -189,22 +207,33 @@ else switch(c)
189
207
  #endif
190
208
  case CHAR_VT:
191
209
  case CHAR_FF:
192
- case CHAR_CR: *lenptr = 1; return TRUE;
210
+ case CHAR_CR:
211
+ *lenptr = 1;
212
+ return TRUE;
193
213
 
194
214
  #ifndef EBCDIC
195
- #ifdef COMPILE_PCRE8
196
- case CHAR_NEL: *lenptr = utf? 2 : 1; return TRUE;
197
- case 0x2028: /* LS */
198
- case 0x2029: *lenptr = 3; return TRUE; /* PS */
199
- #else /* COMPILE_PCRE16 || COMPILE_PCRE32 */
215
+ #if PCRE2_CODE_UNIT_WIDTH == 8
216
+ case CHAR_NEL:
217
+ *lenptr = utf? 2 : 1;
218
+ return TRUE;
219
+
220
+ case 0x2028: /* LS */
221
+ case 0x2029: /* PS */
222
+ *lenptr = 3;
223
+ return TRUE;
224
+
225
+ #else /* 16-bit or 32-bit code units */
200
226
  case CHAR_NEL:
201
- case 0x2028: /* LS */
202
- case 0x2029: *lenptr = 1; return TRUE; /* PS */
203
- #endif /* COMPILE_PCRE8 */
204
- #endif /* NotEBCDIC */
227
+ case 0x2028: /* LS */
228
+ case 0x2029: /* PS */
229
+ *lenptr = 1;
230
+ return TRUE;
231
+ #endif
232
+ #endif /* Not EBCDIC */
205
233
 
206
- default: return FALSE;
234
+ default:
235
+ return FALSE;
207
236
  }
208
237
  }
209
238
 
210
- /* End of pcre_newline.c */
239
+ /* End of pcre2_newline.c */