wasCSharpSQLite – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * SourceCmd.java |
||
3 | * |
||
4 | * Implements the "source" command. |
||
5 | * |
||
6 | * Copyright (c) 1997 Cornell University. |
||
7 | * Copyright (c) 1997 Sun Microsystems, Inc. |
||
8 | * |
||
9 | * See the file "license.terms" for information on usage and |
||
10 | * redistribution of this file, and for a DISCLAIMER OF ALL |
||
11 | * WARRANTIES. |
||
12 | * |
||
13 | * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart |
||
14 | * |
||
15 | * RCS @(#) $Id: SourceCmd.java,v 1.1.1.1 1998/10/14 21:09:20 cvsadmin Exp $ |
||
16 | * |
||
17 | */ |
||
18 | using System; |
||
19 | namespace tcl.lang |
||
20 | { |
||
21 | |||
22 | /* |
||
23 | * This class implements the built-in "source" command in Tcl. |
||
24 | */ |
||
25 | |||
26 | class SourceCmd : Command |
||
27 | { |
||
28 | |||
29 | public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv ) |
||
30 | { |
||
31 | string fileName = null; |
||
32 | bool url = false; |
||
33 | |||
34 | if ( argv.Length == 2 ) |
||
35 | { |
||
36 | |||
37 | fileName = argv[1].ToString(); |
||
38 | } |
||
39 | else if ( argv.Length == 3 ) |
||
40 | { |
||
41 | |||
42 | if ( argv[1].ToString().Equals( "-url" ) ) |
||
43 | { |
||
44 | url = true; |
||
45 | |||
46 | fileName = argv[2].ToString(); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | if ( (System.Object)fileName == null ) |
||
51 | { |
||
52 | throw new TclNumArgsException( interp, 1, argv, "?-url? fileName" ); |
||
53 | } |
||
54 | |||
55 | try |
||
56 | { |
||
57 | if ( url ) |
||
58 | { |
||
59 | if ( fileName.StartsWith( "resource:/" ) ) |
||
60 | { |
||
61 | interp.evalResource( fileName.Substring( 9 ) ); |
||
62 | } |
||
63 | else |
||
64 | { |
||
65 | interp.evalURL( null, fileName ); |
||
66 | } |
||
67 | } |
||
68 | else |
||
69 | { |
||
70 | interp.evalFile( fileName ); |
||
71 | } |
||
72 | } |
||
73 | catch ( TclException e ) |
||
74 | { |
||
75 | TCL.CompletionCode code = e.getCompletionCode(); |
||
76 | |||
77 | if ( code == TCL.CompletionCode.RETURN ) |
||
78 | { |
||
79 | TCL.CompletionCode realCode = interp.updateReturnInfo(); |
||
80 | if ( realCode != TCL.CompletionCode.OK ) |
||
81 | { |
||
82 | e.setCompletionCode( realCode ); |
||
83 | throw; |
||
84 | } |
||
85 | } |
||
86 | else if ( code == TCL.CompletionCode.ERROR ) |
||
87 | { |
||
88 | /* |
||
89 | * Record information telling where the error occurred. |
||
90 | */ |
||
91 | |||
92 | interp.addErrorInfo( "\n (file line " + interp.errorLine + ")" ); |
||
93 | throw; |
||
94 | } |
||
95 | else |
||
96 | { |
||
97 | throw; |
||
98 | } |
||
99 | } |
||
100 | return TCL.CompletionCode.RETURN; |
||
101 | } |
||
102 | } // end SourceCmd |
||
103 | } |