Tk Source Code

Check-in [e5722050]
Login

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

Overview
Comment:Backout [c43ceec9f6]. Since the change in Tcl_GetIndexFromObj() was undone due to http://code.activestate.com/lists/tcl-core/12524/, it looks we have to live with uglier code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e57220500d0d0513da3912dca5f060c3e03f61d8
User & Date: jan.nijtmans 2012-11-22 09:04:44
Context
2012-12-03
01:22
merge-mark check-in: b7d2e2b8 user: fvogel tags: trunk
2012-11-22
17:47
merge trunk check-in: e7830c40 user: dgp tags: core-8-6-0-rc
09:04
Backout [c43ceec9f6]. Since the change in Tcl_GetIndexFromObj() was undone due to http://code.activestate.com/lists/tcl-core/12524/, it looks we have to live with uglier code. check-in: e5722050 user: jan.nijtmans tags: trunk
2012-11-15
11:55
Simplification: don't declare struct types that are never used. check-in: 91aa0783 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to win/tkWinDialog.c.

579
580
581
582
583
584
585





586
587
588

589
590

591





592

593
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
    Tk_Window tkwin = clientData;
    HWND hWnd;
    Tcl_Obj *filterObj = NULL, *initialTypeObj = NULL, *typeVariableObj = NULL;
    Tcl_DString utfFilterString, utfDirString, ds;
    Tcl_DString extString, filterString, dirString, titleString;
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));





    static const char *const saveOptionStrings[] = {
	"-confirmoverwrite", "-defaultextension", "-filetypes", "-initialdir",
	"-initialfile", "", "-parent", "-title", "-typevariable", NULL

    };
    static const char *const openOptionStrings[] = {

	"", "-defaultextension", "-filetypes", "-initialdir", "-initialfile",





	"-multiple", "-parent", "-title", "-typevariable", NULL

    };
    enum options {
	FILE_CONFIRMOW,	FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE,






	FILE_MULTIPLE,	FILE_PARENT,  FILE_TITLE, FILE_TYPEVARIABLE

    };


    file[0] = '\0';
    ZeroMemory(&ofnData, sizeof(OFNData));
    Tcl_DStringInit(&utfFilterString);
    Tcl_DStringInit(&utfDirString);

    /*
     * Parse the arguments.
     */

    for (i = 1; i < objc; i += 2) {
	int index;
	const char *string;
	Tcl_Obj *valuePtr = objv[i + 1];

	if (Tcl_GetIndexFromObj(interp, objv[i],
		open ? openOptionStrings : saveOptionStrings,
		"option", 0, &index) != TCL_OK) {
	    goto end;
	}

	if (i + 1 == objc) {
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		    "value for \"%s\" missing", Tcl_GetString(objv[i])));
	    Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL);
	    goto end;
	}

	string = Tcl_GetString(valuePtr);
	switch ((enum options) index) {
	case FILE_DEFAULT:
	    if (string[0] == '.') {
		string++;
	    }
	    extension = string;
	    break;
	case FILE_TYPES:







>
>
>
>
>
|
<
<
>

|
>
|
>
>
>
>
>
|
>

|
|
>
>
>
>
>
>
|
>

>















|
<
|

<
<
|

|





|







579
580
581
582
583
584
585
586
587
588
589
590
591


592
593
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632

633
634


635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
    Tk_Window tkwin = clientData;
    HWND hWnd;
    Tcl_Obj *filterObj = NULL, *initialTypeObj = NULL, *typeVariableObj = NULL;
    Tcl_DString utfFilterString, utfDirString, ds;
    Tcl_DString extString, filterString, dirString, titleString;
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
    enum options {
	FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, FILE_PARENT,
	FILE_TITLE, FILE_TYPEVARIABLE, FILE_MULTIPLE, FILE_CONFIRMOW
    };
    struct Options {
	const char *name;


	enum options value;
    };
    static const struct Options saveOptions[] = {
	{"-confirmoverwrite",	FILE_CONFIRMOW},
	{"-defaultextension",	FILE_DEFAULT},
	{"-filetypes",		FILE_TYPES},
	{"-initialdir",		FILE_INITDIR},
	{"-initialfile",	FILE_INITFILE},
	{"-parent",		FILE_PARENT},
	{"-title",		FILE_TITLE},
	{"-typevariable",	FILE_TYPEVARIABLE},
	{NULL,			FILE_DEFAULT/*ignored*/ }
    };
    static const struct Options openOptions[] = {
	{"-defaultextension",	FILE_DEFAULT},
	{"-filetypes",		FILE_TYPES},
	{"-initialdir",		FILE_INITDIR},
	{"-initialfile",	FILE_INITFILE},
	{"-multiple",		FILE_MULTIPLE},
	{"-parent",		FILE_PARENT},
	{"-title",		FILE_TITLE},
	{"-typevariable",	FILE_TYPEVARIABLE},
	{NULL,			FILE_DEFAULT/*ignored*/ }
    };
    const struct Options *const options = open ? openOptions : saveOptions;

    file[0] = '\0';
    ZeroMemory(&ofnData, sizeof(OFNData));
    Tcl_DStringInit(&utfFilterString);
    Tcl_DStringInit(&utfDirString);

    /*
     * Parse the arguments.
     */

    for (i = 1; i < objc; i += 2) {
	int index;
	const char *string;
	Tcl_Obj *valuePtr = objv[i + 1];

	if (Tcl_GetIndexFromObjStruct(interp, objv[i], options,

		sizeof(struct Options), "option", 0, &index) != TCL_OK) {
	    goto end;


	} else if (i + 1 == objc) {
	    Tcl_SetObjResult(interp, Tcl_ObjPrintf(
		    "value for \"%s\" missing", options[index].name));
	    Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL);
	    goto end;
	}

	string = Tcl_GetString(valuePtr);
	switch (options[index].value) {
	case FILE_DEFAULT:
	    if (string[0] == '.') {
		string++;
	    }
	    extension = string;
	    break;
	case FILE_TYPES: