File: require.sl

package info (click to toggle)
slang2 2.3.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,488 kB
  • sloc: ansic: 101,756; sh: 3,435; makefile: 1,046; pascal: 440
file content (71 lines) | stat: -rw-r--r-- 1,303 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
% These functions were taken from the jed editor

private variable Features;
if (0 == __is_initialized (&Features))
  Features = Assoc_Type [Int_Type,0];

private define pop_feature_namespace (nargs)
{
   variable f, ns = current_namespace ();
   if (nargs == 2)
     ns = ();
   f = ();
   if ((ns == NULL) or (ns == ""))
     ns = "Global";
   return strcat (ns, ".", f);
}

define _featurep ()
{
   variable f;
   f = pop_feature_namespace (_NARGS);
   return Features[f];
}

define provide ()
{
   variable f = pop_feature_namespace (_NARGS);
   Features[f] = 1;
}

define require ()
{
   variable feat, file;
   variable ns = current_namespace ();
   switch (_NARGS)
     {
      case 1:
	feat = ();
	file = feat;
     }
     {
      case 2:
	(feat, ns) = ();
	file = feat;
     }
     {
      case 3:
	(feat, ns, file) = ();
     }
     {
	usage ("require (feature [,namespace [,file]])");
     }

   if (_featurep (feat, ns))
     return;

   if (ns == NULL)
     () = evalfile (file);
   else
     () = evalfile (file, ns);

   if (feat == file)
     provide (file, ns);
   else if (_featurep (feat, ns))
     vmessage ("***Warning: feature %s not provided by %s", feat, file);
}

$1 = path_concat (path_dirname (__FILE__), "help/require.hlp");
if (NULL != stat_file ($1))
  add_doc_file ($1);