LCOV - code coverage report
Current view: top level - slsh/lib - require.sl (source / functions) Hit Total Coverage
Test: all.lcov Lines: 32 35 91.4 %
Date: 2022-08-02 14:41:00 Functions: 4 4 100.0 %

          Line data    Source code
       1             : % These functions were taken from the jed editor
       2             : 
       3             : private variable Features;
       4          36 : if (0 == __is_initialized (&Features))
       5          36 :   Features = Assoc_Type [Int_Type,0];
       6             : 
       7             : private define pop_feature_namespace (nargs)
       8             : {
       9         137 :    variable f, ns = current_namespace ();
      10         137 :    if (nargs == 2)
      11         114 :      ns = ();
      12         137 :    f = ();
      13         137 :    if ((ns == NULL) or (ns == ""))
      14         133 :      ns = "Global";
      15         137 :    return strcat (ns, ".", f);
      16             : }
      17             : 
      18             : define _featurep ()
      19             : {
      20             :    variable f;
      21          58 :    f = pop_feature_namespace (_NARGS);
      22          58 :    return Features[f];
      23             : }
      24             : 
      25             : define provide ()
      26             : {
      27          79 :    variable f = pop_feature_namespace (_NARGS);
      28          79 :    Features[f] = 1;
      29             : }
      30             : 
      31             : define require ()
      32             : {
      33             :    variable feat, file;
      34          57 :    variable ns = current_namespace ();
      35          57 :    switch (_NARGS)
      36             :      {
      37          57 :       case 1:
      38          55 :         feat = ();
      39          55 :         file = feat;
      40             :      }
      41             :      {
      42           2 :       case 2:
      43           1 :         (feat, ns) = ();
      44           1 :         file = feat;
      45             :      }
      46             :      {
      47           1 :       case 3:
      48           1 :         (feat, ns, file) = ();
      49             :      }
      50             :      {
      51           0 :         usage ("require (feature [,namespace [,file]])");
      52             :      }
      53             : 
      54          57 :    if (_featurep (feat, ns))
      55             :      return;
      56             : 
      57          57 :    if (ns == NULL)
      58           0 :      () = evalfile (file);
      59             :    else
      60          57 :      () = evalfile (file, ns);
      61             : 
      62          57 :    if (feat == file)
      63          56 :      provide (file, ns);
      64           1 :    else if (_featurep (feat, ns))
      65           0 :      vmessage ("***Warning: feature %s not provided by %s", feat, file);
      66             : }
      67             : 
      68          36 : $1 = path_concat (path_dirname (__FILE__), "help/require.hlp");
      69          36 : if (NULL != stat_file ($1))
      70          36 :   add_doc_file ($1);
      71             : 

Generated by: LCOV version 1.13