134 {
135
136 if (ranges) {
138 regmatch_t matches[numberOfMatches];
139
140 const int err = regexec(self->
regex, chars, numberOfMatches, matches, options);
141 assert(err == 0 || err == REG_NOMATCH);
142
143 *ranges = calloc(numberOfMatches,
sizeof(
Range));
144 assert(*ranges);
145
146 Range *range = *ranges;
147 const regmatch_t *match = matches;
148 for (size_t i = 0; i < numberOfMatches; i++, range++, match++) {
150 if (range->location > -1) {
151 range->length = match->rm_eo - match->rm_so;
152 } else {
153 range->length = 0;
154 }
155 }
156
157 return err == 0;
158 }
159
160 const int err = regexec(self->
regex, chars, 0, NULL, options);
161 assert(err == 0 || err == REG_NOMATCH);
162
163 return err == 0;
164}
ssize_t location
The location.