X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=miniexpect.pod;h=b4f0edc3ec82772100934c4c1c3cc2bbb27924cf;hb=d911800d008faef4d35b6a55adcc2d5f8064cfc1;hp=0ab4a4aaa061d657afa690e189aac1e3f3a6ed4e;hpb=cdd5f93d5c8b51d8e80e2ccf45f1f4a90c79f6a6;p=miniexpect.git diff --git a/miniexpect.pod b/miniexpect.pod index 0ab4a4a..b4f0edc 100644 --- a/miniexpect.pod +++ b/miniexpect.pod @@ -114,6 +114,19 @@ the process, but it will contain at least the part matched by the regular expression (and maybe some more). C is the read buffer and C is the number of bytes of data in the buffer. + ssize_t next_match; + +If C returns a match, then C points to the +first byte in the buffer I the fully matched expression. (It +may be C<-1> which means it is invalid). The next time that +C is called, it will start by consuming the data +C. Callers may also need to read from +that point in the buffer before calling L on the file +descriptor. Callers may also set this, for example setting it to +C<-1> in order to ignore the remainder of the buffer. In most cases +callers can ignore this field, and C will just do the +right thing when called repeatedly. + size_t read_size; Callers may set this to the natural size (in bytes) for reads from the @@ -244,6 +257,29 @@ for EOF or timeout. C, C, C, C and C are passed through to the L function. +=item * + +If multiple regular expressions are passed, then they are checked in +turn and the I regular expression that matches is returned +I. + +For example if the input is C<"hello world"> and you pass the two +regular expressions: + + regexps[0].re = world + regexps[1].re = hello + +then the first regular expression (C<"world">) may match and the +C<"hello"> part of the input may be ignored. + +In some cases this can even lead to unpredictable matching. In the +case above, if we only happened to read C<"hello wor">, then the +second regular expression (C<"hello">) I match. + +If this is a concern, combine your regular expressions into a single +one, eg. C<(hello)|(world)>. + =back =head2 mexp_expect example