1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
-
+
|
/*
* tclUnixInit.c --
*
* Contains the Unix-specific interpreter initialization functions.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1999 by Scriptics Corporation.
* All rights reserved.
*
* RCS: @(#) $Id: tclUnixInit.c,v 1.35.2.11 2005/08/15 17:23:21 dgp Exp $
* RCS: @(#) $Id: tclUnixInit.c,v 1.35.2.12 2005/11/03 17:52:27 dgp Exp $
*/
#include "tclInt.h"
#include <stddef.h>
#include <locale.h>
#ifdef HAVE_LANGINFO
#include <langinfo.h>
|
| ︙ | | |
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
-
-
+
+
|
* the stack.
*
* NOTE: Now I have some idea why the maximum stack size must be divided by 64
* on FreeBSD with threads enabled to get a reasonably correct value.
*
* The getrlimit() function is documented to return the maximum stack size in
* bytes. However, with threads enabled, the pthread library does bad things
* to the stack size limits. First, the limits cannot be changed. Second,
* they appear to be reported incorrectly by a factor of about 64.
* to the stack size limits. First, the limits cannot be changed. Second, they
* appear to be reported incorrectly by a factor of about 64.
*
* The defines below may need to be adjusted if more platforms have this
* broken behavior with threads enabled.
*/
#if defined(__FreeBSD__)
# define TCL_MAGIC_STACK_DIVISOR 64
|
| ︙ | | |
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
-
+
-
+
-
-
+
-
|
{"zh_cn.gbk", "euc-cn"},
{"zh_cz.gb2312", "euc-cn"},
{"zh_tw", "euc-tw"},
{"zh_tw.big5", "big5"},
};
#ifndef TCL_NO_STACK_CHECK
static int GetStackSize _ANSI_ARGS_((size_t *stackSizePtr));
static int GetStackSize(size_t *stackSizePtr);
#endif /* TCL_NO_STACK_CHECK */
#ifdef HAVE_COREFOUNDATION
static int MacOSXGetLibraryPath _ANSI_ARGS_((
static int MacOSXGetLibraryPath(Tcl_Interp *interp,
Tcl_Interp *interp, int maxPathLen,
char *tclLibPath));
int maxPathLen, char *tclLibPath);
#endif /* HAVE_COREFOUNDATION */
/*
*---------------------------------------------------------------------------
*
* TclpInitPlatform --
*
* Initialize all the platform-dependant things like signals and
|
| ︙ | | |
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
-
+
|
* Side effects:
* None.
*
*---------------------------------------------------------------------------
*/
void
TclpInitPlatform()
TclpInitPlatform(void)
{
#ifdef DJGPP
tclPlatform = TCL_PLATFORM_WINDOWS;
#else
tclPlatform = TCL_PLATFORM_UNIX;
#endif
|
| ︙ | | |
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
-
+
|
open("/dev/null", O_WRONLY);
}
if (TclOSseek(2, (Tcl_SeekOffset) 0, SEEK_CUR) == -1 && errno == EBADF) {
open("/dev/null", O_WRONLY);
}
/*
* The code below causes SIGPIPE (broken pipe) errors to be ignored. This
* The code below causes SIGPIPE (broken pipe) errors to be ignored. This
* is needed so that Tcl processes don't die if they create child
* processes (e.g. using "exec" or "open") that terminate prematurely.
* The signal handler is only set up when the first interpreter is
* created; after this the application can override the handler with a
* different one of its own, if it wants.
*/
|
| ︙ | | |
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
|
-
-
-
-
+
+
+
+
|
* Side effects:
* Sets the library path to an initial value.
*
*-------------------------------------------------------------------------
*/
void
TclpInitLibraryPath(valuePtr, lengthPtr, encodingPtr)
char **valuePtr;
int *lengthPtr;
Tcl_Encoding *encodingPtr;
TclpInitLibraryPath(
char **valuePtr,
int *lengthPtr,
Tcl_Encoding *encodingPtr)
{
#define LIBRARY_SIZE 32
Tcl_Obj *pathPtr, *objPtr;
CONST char *str;
Tcl_DString buffer, ds;
int pathc;
CONST char **pathv;
|
| ︙ | | |
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
|
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
-
+
-
+
-
+
-
-
+
+
|
* the first call, and the encodings may be changed on first or second
* call.
*
*---------------------------------------------------------------------------
*/
void
TclpSetInitialEncodings()
TclpSetInitialEncodings(void)
{
Tcl_DString encodingName;
Tcl_SetSystemEncoding(NULL,
TclpGetEncodingNameFromEnvironment(&encodingName));
Tcl_DStringFree(&encodingName);
}
void
TclpSetInterfaces()
TclpSetInterfaces(void)
{
/* do nothing */
/* do nothing */
}
static CONST char *
SearchKnownEncodings(encoding)
CONST char *encoding;
SearchKnownEncodings(
CONST char *encoding)
{
int left = 0;
int right = sizeof(localeTable)/sizeof(LocaleTable);
while (left <= right) {
int test = (left + right)/2;
int code = strcmp(localeTable[test].lang, encoding);
|
| ︙ | | |
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
|
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
|
-
-
+
+
-
+
|
right = test-1;
}
}
return NULL;
}
CONST char *
TclpGetEncodingNameFromEnvironment(bufPtr)
Tcl_DString *bufPtr;
TclpGetEncodingNameFromEnvironment(
Tcl_DString *bufPtr)
{
CONST char *encoding;
CONST char *knownEncoding;
Tcl_DStringInit(bufPtr);
/*
* Determine the current encoding from the LC_* or LANG environment
* variables. We previously used setlocale() to determine the locale, but
* variables. We previously used setlocale() to determine the locale, but
* this does not work on some systems (e.g. Linux/i386 RH 5.0).
*/
#ifdef HAVE_LANGINFO
if (setlocale(LC_CTYPE, "") != NULL) {
Tcl_DString ds;
|
| ︙ | | |
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
-
-
+
+
|
* Sets "tclDefaultLibrary", "tcl_pkgPath", and "tcl_platform" Tcl
* variables.
*
*----------------------------------------------------------------------
*/
void
TclpSetVariables(interp)
Tcl_Interp *interp;
TclpSetVariables(
Tcl_Interp *interp)
{
#ifndef NO_UNAME
struct utsname name;
#endif
int unameOK;
CONST char *user;
Tcl_DString ds;
|
| ︙ | | |
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
|
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
|
-
+
-
-
+
+
-
+
|
* TclpFindVariable --
*
* Locate the entry in environ for a given name. On Unix this routine is
* case sensetive, on Windows this matches mixed case.
*
* Results:
* The return value is the index in environ of an entry with the name
* "name", or -1 if there is no such entry. The integer at *lengthPtr is
* "name", or -1 if there is no such entry. The integer at *lengthPtr is
* filled in with the length of name (if a matching entry is found) or
* the length of the environ array (if no matching entry is found).
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
TclpFindVariable(name, lengthPtr)
CONST char *name; /* Name of desired environment variable
TclpFindVariable(
CONST char *name, /* Name of desired environment variable
* (native). */
int *lengthPtr; /* Used to return length of name (for
int *lengthPtr) /* Used to return length of name (for
* successful searches) or number of non-NULL
* entries in environ (for unsuccessful
* searches). */
{
int i, result = -1;
register CONST char *env, *p1, *p2;
Tcl_DString envString;
|
| ︙ | | |
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
|
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
|
-
+
|
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
TclpCheckStackSpace()
TclpCheckStackSpace(void)
{
#ifdef TCL_NO_STACK_CHECK
/*
* This function was normally unimplemented on Unix platforms and this
* implements old behavior, i.e. no stack checking performed.
*/
|
| ︙ | | |
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
|
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
|
-
-
+
+
|
* None
*
*----------------------------------------------------------------------
*/
#ifndef TCL_NO_STACK_CHECK
static int
GetStackSize(stackSizePtr)
size_t *stackSizePtr;
GetStackSize(
size_t *stackSizePtr)
{
size_t rawStackSize;
struct rlimit rLimit; /* The result from getrlimit(). */
#ifdef TCL_THREADS
rawStackSize = (size_t) TclpThreadGetStackSize();
if (rawStackSize == (size_t) -1) {
|
| ︙ | | |
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
|
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
|
-
+
+
+
+
|
* Same as for Tcl_MacOSXOpenVersionedBundleResources.
*
*----------------------------------------------------------------------
*/
#ifdef HAVE_COREFOUNDATION
static int
MacOSXGetLibraryPath(Tcl_Interp *interp, int maxPathLen, char *tclLibPath)
MacOSXGetLibraryPath(
Tcl_Interp *interp,
int maxPathLen,
char *tclLibPath)
{
int foundInFramework = TCL_ERROR;
#ifdef TCL_FRAMEWORK
foundInFramework = Tcl_MacOSXOpenVersionedBundleResources(interp,
"com.tcltk.tcllibrary", TCL_FRAMEWORK_VERSION, 0, maxPathLen,
tclLibPath);
|
| ︙ | | |