Check-in [4332aaffeb]
Not logged in

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

Overview
Comment:added TIP #414 as suggested by Jan Nijtmans
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4332aaffebe72eb1e912104a8d7ddc332445c844
User & Date: chw 2015-10-25 07:59:28
Original Comment: added tTIP #414 as suggested by Jan Nijtmans
Context
2015-10-26
07:54
added tk upstream changes plus comments in sdktools/bones check-in: 7200e354a1 user: chw tags: trunk
2015-10-25
07:59
added TIP #414 as suggested by Jan Nijtmans check-in: 4332aaffeb user: chw tags: trunk
2015-10-24
18:14
fixes and improvements in ZBar module check-in: c82e1d0988 user: chw tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jni/sdl2tk/sdl/tkAppInit.c.

13
14
15
16
17
18
19


20
21
22
23
24
25
26
27
28
29

30
31
32
33
34
35
36
 */

#undef BUILD_tk
#undef STATIC_BUILD
#include "tk.h"

#ifdef ANDROID


#include <jni.h>
#endif

#ifdef TK_TEST
extern Tcl_PackageInitProc Tktest_Init;
#endif /* TK_TEST */

#ifdef PLATFORM_SDL
#include <SDL2/SDL.h>
#ifdef ANDROID

#undef  main
#define main SDL_main
#endif
#endif

/*
 * The following #if block allows you to change the AppInit function by using







>
>










>







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
 */

#undef BUILD_tk
#undef STATIC_BUILD
#include "tk.h"

#ifdef ANDROID
#include <time.h>
#include <sys/system_properties.h>
#include <jni.h>
#endif

#ifdef TK_TEST
extern Tcl_PackageInitProc Tktest_Init;
#endif /* TK_TEST */

#ifdef PLATFORM_SDL
#include <SDL2/SDL.h>
#ifdef ANDROID
#include <android/log.h>
#undef  main
#define main SDL_main
#endif
#endif

/*
 * The following #if block allows you to change the AppInit function by using
56
57
58
59
60
61
62























63
64
65
66
67
68
69
#ifdef TK_LOCAL_MAIN_HOOK
MODULE_SCOPE int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
#endif

/* Make sure the stubbed variants of those are never used. */
#undef Tcl_ObjSetVar2
#undef Tcl_NewStringObj
























/*
 *----------------------------------------------------------------------
 *
 * GetPackageCodePath  --
 *
 *	Retrieve path name of APK file.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifdef TK_LOCAL_MAIN_HOOK
MODULE_SCOPE int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
#endif

/* Make sure the stubbed variants of those are never used. */
#undef Tcl_ObjSetVar2
#undef Tcl_NewStringObj


/*
 *----------------------------------------------------------------------
 *
 * AndroidPanic --
 *
 *	Panic proc when running on Android
 *
 *----------------------------------------------------------------------
 */
#ifdef ANDROID
static void
AndroidPanic(const char *fmt, ...)
{
    va_list args;

    va_start(args, fmt);
    __android_log_vprint(ANDROID_LOG_FATAL, "AndroWish", fmt, args);
    va_end(args);
    abort();
}
#endif

/*
 *----------------------------------------------------------------------
 *
 * GetPackageCodePath  --
 *
 *	Retrieve path name of APK file.
272
273
274
275
276
277
278














279
280
281
282
283
284
285
{
#if defined(ANDROID) && defined(PLATFORM_SDL)
    const char *path, *temp;
#endif

#ifdef TK_LOCAL_MAIN_HOOK
    TK_LOCAL_MAIN_HOOK(&argc, &argv);














#endif
#if defined(ANDROID) && defined(PLATFORM_SDL)
    path = SDL_AndroidGetInternalStoragePath();
    temp = SDL_AndroidGetTempStoragePath();
    if (temp != NULL) {
	/* to be able to write temporary files */
	setenv("TMPDIR", temp, 1);







>
>
>
>
>
>
>
>
>
>
>
>
>
>







298
299
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
{
#if defined(ANDROID) && defined(PLATFORM_SDL)
    const char *path, *temp;
#endif

#ifdef TK_LOCAL_MAIN_HOOK
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
#ifdef ANDROID
    Tcl_InitSubsystems(AndroidPanic);

    /* workaround to fix mktime(3) issues at DST boundaries */
    if (getenv("TZ") == NULL) {
	static char tzbuf[PROP_VALUE_MAX + 8];

	strcpy(tzbuf, "TZ=");
	if (__system_property_get("persist.sys.timezone", tzbuf + 3) > 0) {
	    putenv(tzbuf);
	    tzset();
	}
    }
#endif
#if defined(ANDROID) && defined(PLATFORM_SDL)
    path = SDL_AndroidGetInternalStoragePath();
    temp = SDL_AndroidGetTempStoragePath();
    if (temp != NULL) {
	/* to be able to write temporary files */
	setenv("TMPDIR", temp, 1);
359
360
361
362
363
364
365


366
367
368
369
370
371
372
373
374
375
    path = GetOBBDir();
    if (path != NULL) {
	setenv("OBB_DIR", path, 1);
    }

    /* On Android, argv[0] is not usable. */
    argv[0] = strdup("wish");


#endif

    Tk_Main(argc, argv, TK_LOCAL_APPINIT);
    return 0;			/* Needed only to prevent compiler warning. */
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_AppInit --







>
>

<
|







399
400
401
402
403
404
405
406
407
408

409
410
411
412
413
414
415
416
    path = GetOBBDir();
    if (path != NULL) {
	setenv("OBB_DIR", path, 1);
    }

    /* On Android, argv[0] is not usable. */
    argv[0] = strdup("wish");
#else
    Tcl_FindExecutable(argv[0]);
#endif

    Tk_MainEx(argc, argv, TK_LOCAL_APPINIT, Tcl_CreateInterp());
    return 0;			/* Needed only to prevent compiler warning. */
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_AppInit --

Changes to jni/src/tkAppInit.c.

305
306
307
308
309
310
311


312
313
314
315
316
317
318
    const char *path, *temp;
#endif

#ifdef TK_LOCAL_MAIN_HOOK
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
#ifdef ANDROID


    /* workaround to fix mktime(3) issues at DST boundaries */
    if (getenv("TZ") == NULL) {
	static char tzbuf[PROP_VALUE_MAX + 8];

	strcpy(tzbuf, "TZ=");
	if (__system_property_get("persist.sys.timezone", tzbuf + 3) > 0) {
	    putenv(tzbuf);







>
>







305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
    const char *path, *temp;
#endif

#ifdef TK_LOCAL_MAIN_HOOK
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
#ifdef ANDROID
    Tcl_InitSubsystems(AndroidPanic);

    /* workaround to fix mktime(3) issues at DST boundaries */
    if (getenv("TZ") == NULL) {
	static char tzbuf[PROP_VALUE_MAX + 8];

	strcpy(tzbuf, "TZ=");
	if (__system_property_get("persist.sys.timezone", tzbuf + 3) > 0) {
	    putenv(tzbuf);
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
    path = GetOBBDir();
    if (path != NULL) {
	setenv("OBB_DIR", path, 1);
    }

    /* On Android, argv[0] is not usable. */
    argv[0] = strdup("wish");

    Tcl_SetPanicProc(AndroidPanic);
#endif

    Tk_Main(argc, argv, TK_LOCAL_APPINIT);
    return 0;			/* Needed only to prevent compiler warning. */
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_AppInit --







|
|

<
|







404
405
406
407
408
409
410
411
412
413

414
415
416
417
418
419
420
421
    path = GetOBBDir();
    if (path != NULL) {
	setenv("OBB_DIR", path, 1);
    }

    /* On Android, argv[0] is not usable. */
    argv[0] = strdup("wish");
#else
    Tcl_FindExecutable(argv[0]);
#endif

    Tk_MainEx(argc, argv, TK_LOCAL_APPINIT, Tcl_CreateInterp());
    return 0;			/* Needed only to prevent compiler warning. */
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_AppInit --

Changes to jni/tcl/generic/tcl.h.

2419
2420
2421
2422
2423
2424
2425







2426
2427
2428
2429
2430
2431
2432
#define Tcl_InitStubs(interp, version, exact) \
    Tcl_PkgInitStubsCheck(interp, version, exact)
#endif

/*
 * TODO - tommath stubs export goes here!
 */








/*
 * Public functions that are not accessible via the stubs table.
 * Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171]
 */

#define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \







>
>
>
>
>
>
>







2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
#define Tcl_InitStubs(interp, version, exact) \
    Tcl_PkgInitStubsCheck(interp, version, exact)
#endif

/*
 * TODO - tommath stubs export goes here!
 */

/* Tcl_InitSubsystems, see TIP #414 */

#ifndef USE_TCL_STUBS
EXTERN const char *	Tcl_InitSubsystems(TCL_NORETURN1
			    Tcl_PanicProc *panicProc);
#endif

/*
 * Public functions that are not accessible via the stubs table.
 * Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171]
 */

#define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \

Changes to jni/tcl/generic/tclEncoding.c.

1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486

















1487
1488
1489
1490
1491
1492
1493

    return result;
}

/*
 *---------------------------------------------------------------------------
 *
 * Tcl_FindExecutable --
 *
 *	This function computes the absolute path name of the current
 *	application, given its argv[0] value.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	The absolute pathname for the application is computed and stored to be
 *	returned later by [info nameofexecutable].
 *
 *---------------------------------------------------------------------------
 */

















#undef Tcl_FindExecutable
void
Tcl_FindExecutable(
    const char *argv0)		/* The value of the application's argv[0]
				 * (native). */
{
    TclInitSubsystems();







|

|
|










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510

    return result;
}

/*
 *---------------------------------------------------------------------------
 *
 * Tcl_InitSubsystems/Tcl_FindExecutable --
 *
 *	This function initializes everything needed for the Tcl library
 *	to be able to operate.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	The absolute pathname for the application is computed and stored to be
 *	returned later by [info nameofexecutable].
 *
 *---------------------------------------------------------------------------
 */
MODULE_SCOPE const TclStubs tclStubs;

static const struct {
    const TclStubs *stubs;
    const char version[12];
} stubInfo = {
    &tclStubs, TCL_PATCH_LEVEL
};

const char *
Tcl_InitSubsystems(TCL_NORETURN1 Tcl_PanicProc *panicProc)
{
    Tcl_SetPanicProc(panicProc);
    TclInitSubsystems();
    return stubInfo.version;
}

#undef Tcl_FindExecutable
void
Tcl_FindExecutable(
    const char *argv0)		/* The value of the application's argv[0]
				 * (native). */
{
    TclInitSubsystems();

jni/tcl/generic/tclStrToD.c became a regular file.

jni/tcl/library/clock.tcl became executable.

jni/tcl/win/tclWinFile.c became executable.