9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
*
* Copyright (c) 1991-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclIOUtil.c,v 1.1.2.3 1998/09/28 20:24:18 stanton Exp $
*/
#include "tclInt.h"
#include "tclPort.h"
/*
* The following typedef declarations allow for hooking into the chain
|
|
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
*
* Copyright (c) 1991-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclIOUtil.c,v 1.1.2.4 1998/09/30 20:46:25 stanton Exp $
*/
#include "tclInt.h"
#include "tclPort.h"
/*
* The following typedef declarations allow for hooking into the chain
|
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
int
Tcl_EvalFile(interp, fileName)
Tcl_Interp *interp; /* Interpreter in which to process file. */
char *fileName; /* Name of file to process. Tilde-substitution
* will be performed on this name. */
{
int result, length;
char *oldScriptFile;
Interp *iPtr;
Tcl_DString nameString;
char *name, *string;
Tcl_Channel chan;
Tcl_Obj *objPtr;
name = Tcl_TranslateFileName(interp, fileName, &nameString);
if (name == NULL) {
return TCL_ERROR;
}
result = TCL_ERROR;
objPtr = Tcl_NewObj();
if (nativeName != Tcl_DStringValue(&buffer)) {
Tcl_DStringSetLength(&buffer, 0);
Tcl_DStringAppend(&buffer, nativeName, -1);
nativeName = Tcl_DStringValue(&buffer);
}
if (TclStat(nativeName, &statBuf) == -1) {
Tcl_SetErrno(errno);
Tcl_AppendResult(interp, "couldn't read file \"", fileName,
"\": ", Tcl_PosixError(interp), (char *) NULL);
goto error;
}
chan = Tcl_OpenFileChannel(interp, nativeName, "r", 0644);
if (chan == (Tcl_Channel) NULL) {
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "couldn't read file \"", fileName,
"\": ", Tcl_PosixError(interp), (char *) NULL);
goto end;
}
if (Tcl_ReadChars(chan, objPtr, -1, 0) < 0) {
|
>
<
<
<
<
<
|
|
|
|
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
int
Tcl_EvalFile(interp, fileName)
Tcl_Interp *interp; /* Interpreter in which to process file. */
char *fileName; /* Name of file to process. Tilde-substitution
* will be performed on this name. */
{
int result, length;
struct stat statBuf;
char *oldScriptFile;
Interp *iPtr;
Tcl_DString nameString;
char *name, *string;
Tcl_Channel chan;
Tcl_Obj *objPtr;
name = Tcl_TranslateFileName(interp, fileName, &nameString);
if (name == NULL) {
return TCL_ERROR;
}
result = TCL_ERROR;
objPtr = Tcl_NewObj();
if (TclStat(name, &statBuf) == -1) {
Tcl_SetErrno(errno);
Tcl_AppendResult(interp, "couldn't read file \"", fileName,
"\": ", Tcl_PosixError(interp), (char *) NULL);
goto end;
}
chan = Tcl_OpenFileChannel(interp, name, "r", 0644);
if (chan == (Tcl_Channel) NULL) {
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "couldn't read file \"", fileName,
"\": ", Tcl_PosixError(interp), (char *) NULL);
goto end;
}
if (Tcl_ReadChars(chan, objPtr, -1, 0) < 0) {
|