-STATIC const char *indirect_find(pTHX_ SV *sv, const char *s) {
-#define indirect_find(N, S) indirect_find(aTHX_ (N), (S))
+STATIC STRLEN indirect_nextline(const char *s, STRLEN len) {
+ STRLEN i;
+
+ for (i = 0; i < len; ++i) {
+ if (s[i] == '\n') {
+ ++i;
+ while (i < len && s[i] == '\r')
+ ++i;
+ break;
+ }
+ }
+
+ return i;
+}
+
+STATIC int indirect_find(pTHX_ SV *sv, const char *s, STRLEN *pos) {
+#define indirect_find(N, S, P) indirect_find(aTHX_ (N), (S), (P))