Tk Source Code

Check-in [6e5ca130]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix usage of ZIPFS_IN_TCL in various places, including the win32 configure script
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | androwish
Files: files | file ages | folders
SHA1: 6e5ca1307e04173501caf095f6398cdd252896f2
User & Date: jan.nijtmans 2015-12-17 15:01:20
Context
2015-12-18
10:02
Implement new function Tk_ZipMain, which can be used for applications which want to include the zipfs functions. check-in: d80f2887 user: jan.nijtmans tags: androwish
2015-12-17
15:01
Fix usage of ZIPFS_IN_TCL in various places, including the win32 configure script check-in: 6e5ca130 user: jan.nijtmans tags: androwish
11:03
Fix dynamic build on Windows (reported by Christian Werner) check-in: d111a2b4 user: jan.nijtmans tags: androwish
2015-12-16
12:54
merge-mark check-in: 1dd65fca user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkMain.c.

199
200
201
202
203
204
205

206
207
208
209
210
211
212
213
214
215
216
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
...
300
301
302
303
304
305
306

307
308
309
310
311
312
313
314
315
316
317


318
319
320
321
322
323
324
325
...
547
548
549
550
551
552
553
554
555
556
557
558
559

560
561
562
563
564
565
566
    Tcl_Interp *interp)
{
    Tcl_Obj *path, *argvPtr, *appName;
    const char *encodingName;
    int code, nullStdin = 0;
    Tcl_Channel chan;
    InteractiveState is;

    const char *zipFile = NULL;
    Tcl_Obj *zipval = NULL;
    int autoRun = 1;
#ifdef ZIPFS_IN_TCL
    int zipOk = TCL_ERROR;
#ifdef ANDROID
    const char *zipFile2 = NULL;
#else
    const char *exeName;
    Tcl_DString systemEncodingName;
#endif
................................................................................
		    goto loadCygwinTk;
		}
	    }
	}
    }
#endif

#ifndef ANDROID
    exeName = Tcl_GetNameOfExecutable();
#endif

    Tcl_InitMemory(interp);

    is.interp = interp;
    is.gotPartial = 0;
................................................................................
		Tcl_Obj *value = NewNativeObj(argv[2], -1);
	    Tcl_SetStartupScript(NewNativeObj(argv[3], -1), Tcl_GetString(value));
	    Tcl_DecrRefCount(value);
	    argc -= 3;
	    argv += 3;
        } else if (argc > 1) {
	    length = strlen((char *) argv[1]);

	    if ((length >= 2) &&
		(0 == _tcsncmp(TEXT("-zip"), argv[1], length))) {
		argc--;
		argv++;
		if ((argc > 1) && (argv[1][0] != (TCHAR) '-')) {
		    zipval = NewNativeObj(argv[1], -1);
		    zipFile = Tcl_GetString(zipval);
		    autoRun = 0;
		    argc--;
		    argv++;
		}


	    } else if (TEXT('-') != argv[1][0]) {
		Tcl_SetStartupScript(NewNativeObj(argv[1], -1), NULL);
		argc--;
		argv++;
	    }
	} else if ((argc > 2) && (length = _tcslen(argv[1]))
		&& (length > 1) && (0 == _tcsncmp(TEXT("-file"), argv[1], length))
		&& (TEXT('-') != argv[2][0])) {
................................................................................
		autoRun = 0;
	    }
#ifndef ZIPFS_BOOTDIR
	    Tcl_DStringFree(&dsFilename);
#endif
	}
    }
#endif

    if (zipval != NULL) {
        Tcl_DecrRefCount(zipval);
        zipval = NULL;
    }


    /*
     * Invoke application-specific initialization.
     */

    if (appInitProc(interp) != TCL_OK) {
	TkpDisplayWarning(Tcl_GetString(Tcl_GetObjResult(interp)),






>



<







 







|







 







>











>
>
|







 







<





>







199
200
201
202
203
204
205
206
207
208
209

210
211
212
213
214
215
216
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
...
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
...
550
551
552
553
554
555
556

557
558
559
560
561
562
563
564
565
566
567
568
569
    Tcl_Interp *interp)
{
    Tcl_Obj *path, *argvPtr, *appName;
    const char *encodingName;
    int code, nullStdin = 0;
    Tcl_Channel chan;
    InteractiveState is;
#ifdef ZIPFS_IN_TCL
    const char *zipFile = NULL;
    Tcl_Obj *zipval = NULL;
    int autoRun = 1;

    int zipOk = TCL_ERROR;
#ifdef ANDROID
    const char *zipFile2 = NULL;
#else
    const char *exeName;
    Tcl_DString systemEncodingName;
#endif
................................................................................
		    goto loadCygwinTk;
		}
	    }
	}
    }
#endif

#if defined(ZIPFS_IN_TCL) && !defined(ANDROID)
    exeName = Tcl_GetNameOfExecutable();
#endif

    Tcl_InitMemory(interp);

    is.interp = interp;
    is.gotPartial = 0;
................................................................................
		Tcl_Obj *value = NewNativeObj(argv[2], -1);
	    Tcl_SetStartupScript(NewNativeObj(argv[3], -1), Tcl_GetString(value));
	    Tcl_DecrRefCount(value);
	    argc -= 3;
	    argv += 3;
        } else if (argc > 1) {
	    length = strlen((char *) argv[1]);
#ifdef ZIPFS_IN_TCL
	    if ((length >= 2) &&
		(0 == _tcsncmp(TEXT("-zip"), argv[1], length))) {
		argc--;
		argv++;
		if ((argc > 1) && (argv[1][0] != (TCHAR) '-')) {
		    zipval = NewNativeObj(argv[1], -1);
		    zipFile = Tcl_GetString(zipval);
		    autoRun = 0;
		    argc--;
		    argv++;
		}
	    } else
#endif
	    if (TEXT('-') != argv[1][0]) {
		Tcl_SetStartupScript(NewNativeObj(argv[1], -1), NULL);
		argc--;
		argv++;
	    }
	} else if ((argc > 2) && (length = _tcslen(argv[1]))
		&& (length > 1) && (0 == _tcsncmp(TEXT("-file"), argv[1], length))
		&& (TEXT('-') != argv[2][0])) {
................................................................................
		autoRun = 0;
	    }
#ifndef ZIPFS_BOOTDIR
	    Tcl_DStringFree(&dsFilename);
#endif
	}
    }


    if (zipval != NULL) {
        Tcl_DecrRefCount(zipval);
        zipval = NULL;
    }
#endif

    /*
     * Invoke application-specific initialization.
     */

    if (appInitProc(interp) != TCL_OK) {
	TkpDisplayWarning(Tcl_GetString(Tcl_GetObjResult(interp)),

Changes to macosx/tkMacOSXInit.c.

344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
	    NSAutoreleasePool *pool = [NSAutoreleasePool new];
	    [NSApp _setupEventLoop];
	    TkMacOSXInitAppleEvents(interp);
	    TkMacOSXUseAntialiasedText(interp, -1);
	    TkMacOSXInitCGDrawing(interp, TRUE, 0);
	    [pool drain];
	}
	
	/*
	 * FIXME: Close stdin & stdout for remote debugging otherwise we will
	 * fight with gdb for stdin & stdout
	 */

	if (getenv("XCNOSTDIN") != NULL) {
	    close(0);






|







344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
	    NSAutoreleasePool *pool = [NSAutoreleasePool new];
	    [NSApp _setupEventLoop];
	    TkMacOSXInitAppleEvents(interp);
	    TkMacOSXUseAntialiasedText(interp, -1);
	    TkMacOSXInitCGDrawing(interp, TRUE, 0);
	    [pool drain];
	}

	/*
	 * FIXME: Close stdin & stdout for remote debugging otherwise we will
	 * fight with gdb for stdin & stdout
	 */

	if (getenv("XCNOSTDIN") != NULL) {
	    close(0);

Changes to macosx/tkMacOSXNotify.c.

257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
{
    NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode];
    /* runloopMode will be nil if we are in the Tcl event loop. */
    if (flags & TCL_WINDOW_EVENTS && !runloopMode) {
	NSEvent *currentEvent = nil;
	NSEvent *testEvent = nil;
	NSModalSession modalSession;
	
	do {
	    [NSApp _resetAutoreleasePool];
	    modalSession = TkMacOSXGetModalSession();
	    testEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
					      untilDate:[NSDate distantPast]
						 inMode:GetRunLoopMode(modalSession)
						dequeue:NO];






|







257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
{
    NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode];
    /* runloopMode will be nil if we are in the Tcl event loop. */
    if (flags & TCL_WINDOW_EVENTS && !runloopMode) {
	NSEvent *currentEvent = nil;
	NSEvent *testEvent = nil;
	NSModalSession modalSession;

	do {
	    [NSApp _resetAutoreleasePool];
	    modalSession = TkMacOSXGetModalSession();
	    testEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
					      untilDate:[NSDate distantPast]
						 inMode:GetRunLoopMode(modalSession)
						dequeue:NO];

Changes to macosx/tkMacOSXWindowEvent.c.

802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
...
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
@implementation TKContentView(TKWindowEvent)

- (void) drawRect: (NSRect) rect
{
    const NSRect *rectsBeingDrawn;
    NSInteger rectsBeingDrawnCount;
    
    [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount];

#ifdef TK_MAC_DEBUG_DRAWING
    TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(rect));
    [[NSColor colorWithDeviceRed:0.0 green:1.0 blue:0.0 alpha:.1] setFill];
    NSRectFillListUsingOperation(rectsBeingDrawn, rectsBeingDrawnCount,
	    NSCompositeSourceOver);
................................................................................
    	Tk_RestrictProc *oldProc;

	/* This can be called from outside the Tk event loop.
	 * Since it calls Tcl_DoOneEvent, we need to make sure we
	 * don't clobber the AutoreleasePool set up by the caller.
	 */
	[NSApp setPoolProtected:YES];
	
	/*
	 * Try to prevent flickers and flashes.
	 *
	 * This stops the flickers on OSX 10.11. But flashes still occur when
	 * the width of the window is 16, 32, 48, 64, 80, 96, 112, 256, 512,
	 * 768, ... :^(
	 */
	[w disableFlushWindow];
	
	/* Disable Tk drawing until the window has been completely configured.*/
	TkMacOSXSetDrawingEnabled(winPtr, 0);

	 /* Generate and handle a ConfigureNotify event for the new size.*/
	TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height,
			      TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY);
    	oldProc = Tk_RestrictEvents(ConfigureRestrictProc, NULL, &oldArg);






|







 







|








|







802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
...
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
@implementation TKContentView(TKWindowEvent)

- (void) drawRect: (NSRect) rect
{
    const NSRect *rectsBeingDrawn;
    NSInteger rectsBeingDrawnCount;
   
    [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount];

#ifdef TK_MAC_DEBUG_DRAWING
    TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(rect));
    [[NSColor colorWithDeviceRed:0.0 green:1.0 blue:0.0 alpha:.1] setFill];
    NSRectFillListUsingOperation(rectsBeingDrawn, rectsBeingDrawnCount,
	    NSCompositeSourceOver);
................................................................................
    	Tk_RestrictProc *oldProc;

	/* This can be called from outside the Tk event loop.
	 * Since it calls Tcl_DoOneEvent, we need to make sure we
	 * don't clobber the AutoreleasePool set up by the caller.
	 */
	[NSApp setPoolProtected:YES];

	/*
	 * Try to prevent flickers and flashes.
	 *
	 * This stops the flickers on OSX 10.11. But flashes still occur when
	 * the width of the window is 16, 32, 48, 64, 80, 96, 112, 256, 512,
	 * 768, ... :^(
	 */
	[w disableFlushWindow];

	/* Disable Tk drawing until the window has been completely configured.*/
	TkMacOSXSetDrawingEnabled(winPtr, 0);

	 /* Generate and handle a ConfigureNotify event for the new size.*/
	TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height,
			      TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY);
    	oldProc = Tk_RestrictEvents(ConfigureRestrictProc, NULL, &oldArg);

Changes to macosx/tkMacOSXXStubs.c.

139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    Display *display;
    Screen *screen;
    int fd = 0;
    static NSRect maxBounds = {{0, 0}, {0, 0}};
    static char vendor[25] = "";
    NSArray *cgVers;
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
    
    if (gMacDisplay != NULL) {
	if (strcmp(gMacDisplay->display->display_name, display_name) == 0) {
	    return gMacDisplay;
	} else {
	    return NULL;
	}
    }






|







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    Display *display;
    Screen *screen;
    int fd = 0;
    static NSRect maxBounds = {{0, 0}, {0, 0}};
    static char vendor[25] = "";
    NSArray *cgVers;
    NSAutoreleasePool *pool = [NSAutoreleasePool new];

    if (gMacDisplay != NULL) {
	if (strcmp(gMacDisplay->display->display_name, display_name) == 0) {
	    return gMacDisplay;
	} else {
	    return NULL;
	}
    }

Changes to win/configure.

4703
4704
4705
4706
4707
4708
4709










4710
4711
4712
4713
4714
4715
4716
if test $tcl_cv_strtoi64 = no; then

cat >>confdefs.h <<\_ACEOF
#define NO_STRTOI64 1
_ACEOF

fi











#--------------------------------------------------------------------
# Windows XP theme engine header for Ttk
#--------------------------------------------------------------------

echo "$as_me:$LINENO: checking for uxtheme.h" >&5
echo $ECHO_N "checking for uxtheme.h... $ECHO_C" >&6






>
>
>
>
>
>
>
>
>
>







4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
if test $tcl_cv_strtoi64 = no; then

cat >>confdefs.h <<\_ACEOF
#define NO_STRTOI64 1
_ACEOF

fi

#--------------------------------------------------------------------
#       Has Tcl ZIPFS_IN_TCL ?
#--------------------------------------------------------------------

case ${TCL_DEFS} in
    *ZIPFS_IN_TCL=1*)
	EXTRA_CC_SWITCHES="$EXTRA_CC_SWITCHES -DZIPFS_IN_TCL=1"
	;;
esac

#--------------------------------------------------------------------
# Windows XP theme engine header for Ttk
#--------------------------------------------------------------------

echo "$as_me:$LINENO: checking for uxtheme.h" >&5
echo $ECHO_N "checking for uxtheme.h... $ECHO_C" >&6

Changes to win/configure.in.

114
115
116
117
118
119
120










121
122
123
124
125
126
127
AC_CACHE_CHECK([availability of _strtoi64], tcl_cv_strtoi64, [
    AC_TRY_LINK([#include <stdlib.h>],
	    [_strtoi64(0,0,0)],
	    tcl_cv_strtoi64=yes, tcl_cv_strtoi64=no)])
if test $tcl_cv_strtoi64 = no; then
    AC_DEFINE(NO_STRTOI64, 1, [Is _strtoi64 function available?])
fi











#--------------------------------------------------------------------
# Windows XP theme engine header for Ttk
#--------------------------------------------------------------------

AC_CHECK_HEADER([uxtheme.h], [AC_DEFINE(HAVE_UXTHEME_H)],
	[AC_MSG_NOTICE([xpnative theme will be unavailable])],






>
>
>
>
>
>
>
>
>
>







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
AC_CACHE_CHECK([availability of _strtoi64], tcl_cv_strtoi64, [
    AC_TRY_LINK([#include <stdlib.h>],
	    [_strtoi64(0,0,0)],
	    tcl_cv_strtoi64=yes, tcl_cv_strtoi64=no)])
if test $tcl_cv_strtoi64 = no; then
    AC_DEFINE(NO_STRTOI64, 1, [Is _strtoi64 function available?])
fi

#--------------------------------------------------------------------
#       Has Tcl ZIPFS_IN_TCL ?
#--------------------------------------------------------------------

case ${TCL_DEFS} in
    *ZIPFS_IN_TCL=1*)
	EXTRA_CC_SWITCHES="$EXTRA_CC_SWITCHES -DZIPFS_IN_TCL=1"
	;;
esac

#--------------------------------------------------------------------
# Windows XP theme engine header for Ttk
#--------------------------------------------------------------------

AC_CHECK_HEADER([uxtheme.h], [AC_DEFINE(HAVE_UXTHEME_H)],
	[AC_MSG_NOTICE([xpnative theme will be unavailable])],