LCOV - code coverage report
Current view: top level - modules - pcre.sl (source / functions) Hit Total Coverage
Test: all.lcov Lines: 21 23 91.3 %
Date: 2022-08-02 14:41:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : % Copyright (C) 2012-2021,2022 John E. Davis
       2             : %
       3             : % This file is part of the S-Lang Library and may be distributed under the
       4             : % terms of the GNU General Public License.  See the file COPYING for
       5             : % more information.
       6             : %---------------------------------------------------------------------------
       7           1 : import("pcre");
       8             : 
       9             : define pcre_matches ()
      10             : {
      11          13 :    variable nargs = _NARGS;
      12          13 :    if (nargs < 2)
      13           0 :      usage ("\
      14             : strings = pcre_matches (regexp, str [,pcre_exec_options])\n\
      15             : Qualifiers:\n\
      16             :   options=0       pcre_compile options if regexp is a string\n\
      17             :   offset=0        pcre_exec start matching offset in bytes\n\
      18             : ";
      19             :            );
      20             :    variable re, str, options;
      21          13 :    if (nargs == 2)
      22          13 :      0;
      23          13 :    (re, str, options) = ();
      24          13 :    variable pos = qualifier ("offset", 0);
      25          13 :    if (typeof (re) != PCRE_Type)
      26             :      {
      27          13 :         variable compile_options = qualifier ("options", 0);
      28          13 :         re = pcre_compile (re, compile_options);
      29             :      }
      30             : 
      31          13 :    variable n = pcre_exec (re, str, pos, options);
      32          13 :    if (n == 0)
      33           0 :      return NULL;
      34             : 
      35          13 :    variable matches = String_Type[n];
      36          13 :    _for (0, n-1, 1)
      37             :      {
      38          23 :         variable i = ();
      39          23 :         matches[i] = pcre_nth_substr (re, str, i);
      40             :      }
      41          13 :    return matches;
      42             : }
      43             : 
      44           1 : $1 = path_concat (path_dirname (__FILE__), "help/pcrefuns.hlp");
      45           1 : if (NULL != stat_file ($1))
      46           1 :   add_doc_file ($1);
      47             : 
      48           1 : provide("pcre");

Generated by: LCOV version 1.13