Fossil SCM
Cherrypick [252aff3e62] and related clean-ups: Use built-in Tcl for "diff --tk" implementation if possible. Fallback is to spawn an external "tclsh" as before. This makes "fossil diff --tk" work with ActiveState Tcl on Win32 out-of-the-box.
Commit
f325b2343e6a18f85a955683c568cd51c31cae11
Parent
7ecb9d25f9d9ec5…
15 files changed
+20
-3
+20
-3
+20
-3
+20
-3
+20
-3
+20
-3
+6
-2
+6
-2
+6
-2
+6
-2
+6
-2
+6
-2
+32
+32
+32
+20
-3
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -774,11 +774,11 @@ | ||
| 774 | 774 | @ grid remove $sb |
| 775 | 775 | @ } |
| 776 | 776 | @ } |
| 777 | 777 | @ enableSync x |
| 778 | 778 | @ } |
| 779 | -@ | |
| 779 | +@ | |
| 780 | 780 | @ proc sync-y {first last} { |
| 781 | 781 | @ disableSync y |
| 782 | 782 | @ foreach c [cols] { |
| 783 | 783 | @ $c yview moveto $first |
| 784 | 784 | @ } |
| @@ -793,10 +793,11 @@ | ||
| 793 | 793 | @ |
| 794 | 794 | @ wm withdraw . |
| 795 | 795 | @ wm title . $CFG(TITLE) |
| 796 | 796 | @ wm iconname . $CFG(TITLE) |
| 797 | 797 | @ bind . <q> exit |
| 798 | +@ bind . <Destroy> {after 0 exit} | |
| 798 | 799 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | 801 | @ bind . <Return> { |
| 801 | 802 | @ event generate .files <1> |
| 802 | 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | ||
| 907 | 908 | |
| 908 | 909 | /* |
| 909 | 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | 911 | ** to the diff command. |
| 911 | 912 | ** |
| 912 | -** Steps: | |
| 913 | +** If fossil has direct access to a Tcl interpreter (either loaded | |
| 914 | +** dynamically through stubs or linked in statically), we can use it | |
| 915 | +** directly. Otherwise: | |
| 913 | 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | -** (2) Invoke "wish" on the temp file using fossil_system(). | |
| 917 | +** (2) Invoke "tclsh" on the temp file using fossil_system(). | |
| 915 | 918 | ** (3) Delete the temp file. |
| 916 | 919 | */ |
| 917 | 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | 921 | int i; |
| 919 | 922 | Blob script; |
| @@ -943,10 +946,24 @@ | ||
| 943 | 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | 947 | if( zTempFile ){ |
| 945 | 948 | blob_write_to_file(&script, zTempFile); |
| 946 | 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | 950 | }else{ |
| 951 | +#if defined(FOSSIL_ENABLE_TCL) | |
| 952 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 953 | + if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), | |
| 954 | + blob_size(&script), 1)==TCL_OK ){ | |
| 955 | + blob_reset(&script); | |
| 956 | + return; | |
| 957 | + } | |
| 958 | + /* | |
| 959 | + * If evaluation of the Tcl script fails, the reason may be that Tk | |
| 960 | + * could not be found by the loaded Tcl, or that Tcl cannot be loaded | |
| 961 | + * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback | |
| 962 | + * to using the external "tclsh", if available. | |
| 963 | + */ | |
| 964 | +#endif | |
| 948 | 965 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | 967 | fossil_system(zCmd); |
| 951 | 968 | file_delete(zTempFile); |
| 952 | 969 | fossil_free(zCmd); |
| 953 | 970 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | @ bind . <Return> { |
| 801 | @ event generate .files <1> |
| 802 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 907 | |
| 908 | /* |
| 909 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | ** to the diff command. |
| 911 | ** |
| 912 | ** Steps: |
| 913 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| 953 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Destroy> {after 0 exit} |
| 799 | @ bind . <Tab> {cycleDiffs; break} |
| 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 801 | @ bind . <Return> { |
| 802 | @ event generate .files <1> |
| 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 908 | |
| 909 | /* |
| 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 911 | ** to the diff command. |
| 912 | ** |
| 913 | ** If fossil has direct access to a Tcl interpreter (either loaded |
| 914 | ** dynamically through stubs or linked in statically), we can use it |
| 915 | ** directly. Otherwise: |
| 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 917 | ** (2) Invoke "tclsh" on the temp file using fossil_system(). |
| 918 | ** (3) Delete the temp file. |
| 919 | */ |
| 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 921 | int i; |
| 922 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 947 | if( zTempFile ){ |
| 948 | blob_write_to_file(&script, zTempFile); |
| 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 950 | }else{ |
| 951 | #if defined(FOSSIL_ENABLE_TCL) |
| 952 | Th_FossilInit(TH_INIT_DEFAULT); |
| 953 | if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), |
| 954 | blob_size(&script), 1)==TCL_OK ){ |
| 955 | blob_reset(&script); |
| 956 | return; |
| 957 | } |
| 958 | /* |
| 959 | * If evaluation of the Tcl script fails, the reason may be that Tk |
| 960 | * could not be found by the loaded Tcl, or that Tcl cannot be loaded |
| 961 | * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback |
| 962 | * to using the external "tclsh", if available. |
| 963 | */ |
| 964 | #endif |
| 965 | zTempFile = write_blob_to_temp_file(&script); |
| 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 967 | fossil_system(zCmd); |
| 968 | file_delete(zTempFile); |
| 969 | fossil_free(zCmd); |
| 970 |
+20
-3
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -774,11 +774,11 @@ | ||
| 774 | 774 | @ grid remove $sb |
| 775 | 775 | @ } |
| 776 | 776 | @ } |
| 777 | 777 | @ enableSync x |
| 778 | 778 | @ } |
| 779 | -@ | |
| 779 | +@ | |
| 780 | 780 | @ proc sync-y {first last} { |
| 781 | 781 | @ disableSync y |
| 782 | 782 | @ foreach c [cols] { |
| 783 | 783 | @ $c yview moveto $first |
| 784 | 784 | @ } |
| @@ -793,10 +793,11 @@ | ||
| 793 | 793 | @ |
| 794 | 794 | @ wm withdraw . |
| 795 | 795 | @ wm title . $CFG(TITLE) |
| 796 | 796 | @ wm iconname . $CFG(TITLE) |
| 797 | 797 | @ bind . <q> exit |
| 798 | +@ bind . <Destroy> {after 0 exit} | |
| 798 | 799 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | 801 | @ bind . <Return> { |
| 801 | 802 | @ event generate .files <1> |
| 802 | 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | ||
| 907 | 908 | |
| 908 | 909 | /* |
| 909 | 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | 911 | ** to the diff command. |
| 911 | 912 | ** |
| 912 | -** Steps: | |
| 913 | +** If fossil has direct access to a Tcl interpreter (either loaded | |
| 914 | +** dynamically through stubs or linked in statically), we can use it | |
| 915 | +** directly. Otherwise: | |
| 913 | 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | -** (2) Invoke "wish" on the temp file using fossil_system(). | |
| 917 | +** (2) Invoke "tclsh" on the temp file using fossil_system(). | |
| 915 | 918 | ** (3) Delete the temp file. |
| 916 | 919 | */ |
| 917 | 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | 921 | int i; |
| 919 | 922 | Blob script; |
| @@ -943,10 +946,24 @@ | ||
| 943 | 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | 947 | if( zTempFile ){ |
| 945 | 948 | blob_write_to_file(&script, zTempFile); |
| 946 | 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | 950 | }else{ |
| 951 | +#if defined(FOSSIL_ENABLE_TCL) | |
| 952 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 953 | + if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), | |
| 954 | + blob_size(&script), 1)==TCL_OK ){ | |
| 955 | + blob_reset(&script); | |
| 956 | + return; | |
| 957 | + } | |
| 958 | + /* | |
| 959 | + * If evaluation of the Tcl script fails, the reason may be that Tk | |
| 960 | + * could not be found by the loaded Tcl, or that Tcl cannot be loaded | |
| 961 | + * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback | |
| 962 | + * to using the external "tclsh", if available. | |
| 963 | + */ | |
| 964 | +#endif | |
| 948 | 965 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | 967 | fossil_system(zCmd); |
| 951 | 968 | file_delete(zTempFile); |
| 952 | 969 | fossil_free(zCmd); |
| 953 | 970 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | @ bind . <Return> { |
| 801 | @ event generate .files <1> |
| 802 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 907 | |
| 908 | /* |
| 909 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | ** to the diff command. |
| 911 | ** |
| 912 | ** Steps: |
| 913 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| 953 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Destroy> {after 0 exit} |
| 799 | @ bind . <Tab> {cycleDiffs; break} |
| 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 801 | @ bind . <Return> { |
| 802 | @ event generate .files <1> |
| 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 908 | |
| 909 | /* |
| 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 911 | ** to the diff command. |
| 912 | ** |
| 913 | ** If fossil has direct access to a Tcl interpreter (either loaded |
| 914 | ** dynamically through stubs or linked in statically), we can use it |
| 915 | ** directly. Otherwise: |
| 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 917 | ** (2) Invoke "tclsh" on the temp file using fossil_system(). |
| 918 | ** (3) Delete the temp file. |
| 919 | */ |
| 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 921 | int i; |
| 922 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 947 | if( zTempFile ){ |
| 948 | blob_write_to_file(&script, zTempFile); |
| 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 950 | }else{ |
| 951 | #if defined(FOSSIL_ENABLE_TCL) |
| 952 | Th_FossilInit(TH_INIT_DEFAULT); |
| 953 | if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), |
| 954 | blob_size(&script), 1)==TCL_OK ){ |
| 955 | blob_reset(&script); |
| 956 | return; |
| 957 | } |
| 958 | /* |
| 959 | * If evaluation of the Tcl script fails, the reason may be that Tk |
| 960 | * could not be found by the loaded Tcl, or that Tcl cannot be loaded |
| 961 | * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback |
| 962 | * to using the external "tclsh", if available. |
| 963 | */ |
| 964 | #endif |
| 965 | zTempFile = write_blob_to_temp_file(&script); |
| 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 967 | fossil_system(zCmd); |
| 968 | file_delete(zTempFile); |
| 969 | fossil_free(zCmd); |
| 970 |
+20
-3
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -774,11 +774,11 @@ | ||
| 774 | 774 | @ grid remove $sb |
| 775 | 775 | @ } |
| 776 | 776 | @ } |
| 777 | 777 | @ enableSync x |
| 778 | 778 | @ } |
| 779 | -@ | |
| 779 | +@ | |
| 780 | 780 | @ proc sync-y {first last} { |
| 781 | 781 | @ disableSync y |
| 782 | 782 | @ foreach c [cols] { |
| 783 | 783 | @ $c yview moveto $first |
| 784 | 784 | @ } |
| @@ -793,10 +793,11 @@ | ||
| 793 | 793 | @ |
| 794 | 794 | @ wm withdraw . |
| 795 | 795 | @ wm title . $CFG(TITLE) |
| 796 | 796 | @ wm iconname . $CFG(TITLE) |
| 797 | 797 | @ bind . <q> exit |
| 798 | +@ bind . <Destroy> {after 0 exit} | |
| 798 | 799 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | 801 | @ bind . <Return> { |
| 801 | 802 | @ event generate .files <1> |
| 802 | 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | ||
| 907 | 908 | |
| 908 | 909 | /* |
| 909 | 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | 911 | ** to the diff command. |
| 911 | 912 | ** |
| 912 | -** Steps: | |
| 913 | +** If fossil has direct access to a Tcl interpreter (either loaded | |
| 914 | +** dynamically through stubs or linked in statically), we can use it | |
| 915 | +** directly. Otherwise: | |
| 913 | 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | -** (2) Invoke "wish" on the temp file using fossil_system(). | |
| 917 | +** (2) Invoke "tclsh" on the temp file using fossil_system(). | |
| 915 | 918 | ** (3) Delete the temp file. |
| 916 | 919 | */ |
| 917 | 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | 921 | int i; |
| 919 | 922 | Blob script; |
| @@ -943,10 +946,24 @@ | ||
| 943 | 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | 947 | if( zTempFile ){ |
| 945 | 948 | blob_write_to_file(&script, zTempFile); |
| 946 | 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | 950 | }else{ |
| 951 | +#if defined(FOSSIL_ENABLE_TCL) | |
| 952 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 953 | + if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), | |
| 954 | + blob_size(&script), 1)==TCL_OK ){ | |
| 955 | + blob_reset(&script); | |
| 956 | + return; | |
| 957 | + } | |
| 958 | + /* | |
| 959 | + * If evaluation of the Tcl script fails, the reason may be that Tk | |
| 960 | + * could not be found by the loaded Tcl, or that Tcl cannot be loaded | |
| 961 | + * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback | |
| 962 | + * to using the external "tclsh", if available. | |
| 963 | + */ | |
| 964 | +#endif | |
| 948 | 965 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | 967 | fossil_system(zCmd); |
| 951 | 968 | file_delete(zTempFile); |
| 952 | 969 | fossil_free(zCmd); |
| 953 | 970 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | @ bind . <Return> { |
| 801 | @ event generate .files <1> |
| 802 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 907 | |
| 908 | /* |
| 909 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | ** to the diff command. |
| 911 | ** |
| 912 | ** Steps: |
| 913 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| 953 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Destroy> {after 0 exit} |
| 799 | @ bind . <Tab> {cycleDiffs; break} |
| 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 801 | @ bind . <Return> { |
| 802 | @ event generate .files <1> |
| 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 908 | |
| 909 | /* |
| 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 911 | ** to the diff command. |
| 912 | ** |
| 913 | ** If fossil has direct access to a Tcl interpreter (either loaded |
| 914 | ** dynamically through stubs or linked in statically), we can use it |
| 915 | ** directly. Otherwise: |
| 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 917 | ** (2) Invoke "tclsh" on the temp file using fossil_system(). |
| 918 | ** (3) Delete the temp file. |
| 919 | */ |
| 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 921 | int i; |
| 922 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 947 | if( zTempFile ){ |
| 948 | blob_write_to_file(&script, zTempFile); |
| 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 950 | }else{ |
| 951 | #if defined(FOSSIL_ENABLE_TCL) |
| 952 | Th_FossilInit(TH_INIT_DEFAULT); |
| 953 | if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), |
| 954 | blob_size(&script), 1)==TCL_OK ){ |
| 955 | blob_reset(&script); |
| 956 | return; |
| 957 | } |
| 958 | /* |
| 959 | * If evaluation of the Tcl script fails, the reason may be that Tk |
| 960 | * could not be found by the loaded Tcl, or that Tcl cannot be loaded |
| 961 | * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback |
| 962 | * to using the external "tclsh", if available. |
| 963 | */ |
| 964 | #endif |
| 965 | zTempFile = write_blob_to_temp_file(&script); |
| 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 967 | fossil_system(zCmd); |
| 968 | file_delete(zTempFile); |
| 969 | fossil_free(zCmd); |
| 970 |
+20
-3
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -774,11 +774,11 @@ | ||
| 774 | 774 | @ grid remove $sb |
| 775 | 775 | @ } |
| 776 | 776 | @ } |
| 777 | 777 | @ enableSync x |
| 778 | 778 | @ } |
| 779 | -@ | |
| 779 | +@ | |
| 780 | 780 | @ proc sync-y {first last} { |
| 781 | 781 | @ disableSync y |
| 782 | 782 | @ foreach c [cols] { |
| 783 | 783 | @ $c yview moveto $first |
| 784 | 784 | @ } |
| @@ -793,10 +793,11 @@ | ||
| 793 | 793 | @ |
| 794 | 794 | @ wm withdraw . |
| 795 | 795 | @ wm title . $CFG(TITLE) |
| 796 | 796 | @ wm iconname . $CFG(TITLE) |
| 797 | 797 | @ bind . <q> exit |
| 798 | +@ bind . <Destroy> {after 0 exit} | |
| 798 | 799 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | 801 | @ bind . <Return> { |
| 801 | 802 | @ event generate .files <1> |
| 802 | 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | ||
| 907 | 908 | |
| 908 | 909 | /* |
| 909 | 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | 911 | ** to the diff command. |
| 911 | 912 | ** |
| 912 | -** Steps: | |
| 913 | +** If fossil has direct access to a Tcl interpreter (either loaded | |
| 914 | +** dynamically through stubs or linked in statically), we can use it | |
| 915 | +** directly. Otherwise: | |
| 913 | 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | -** (2) Invoke "wish" on the temp file using fossil_system(). | |
| 917 | +** (2) Invoke "tclsh" on the temp file using fossil_system(). | |
| 915 | 918 | ** (3) Delete the temp file. |
| 916 | 919 | */ |
| 917 | 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | 921 | int i; |
| 919 | 922 | Blob script; |
| @@ -943,10 +946,24 @@ | ||
| 943 | 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | 947 | if( zTempFile ){ |
| 945 | 948 | blob_write_to_file(&script, zTempFile); |
| 946 | 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | 950 | }else{ |
| 951 | +#if defined(FOSSIL_ENABLE_TCL) | |
| 952 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 953 | + if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), | |
| 954 | + blob_size(&script), 1)==TCL_OK ){ | |
| 955 | + blob_reset(&script); | |
| 956 | + return; | |
| 957 | + } | |
| 958 | + /* | |
| 959 | + * If evaluation of the Tcl script fails, the reason may be that Tk | |
| 960 | + * could not be found by the loaded Tcl, or that Tcl cannot be loaded | |
| 961 | + * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback | |
| 962 | + * to using the external "tclsh", if available. | |
| 963 | + */ | |
| 964 | +#endif | |
| 948 | 965 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | 967 | fossil_system(zCmd); |
| 951 | 968 | file_delete(zTempFile); |
| 952 | 969 | fossil_free(zCmd); |
| 953 | 970 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | @ bind . <Return> { |
| 801 | @ event generate .files <1> |
| 802 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 907 | |
| 908 | /* |
| 909 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | ** to the diff command. |
| 911 | ** |
| 912 | ** Steps: |
| 913 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| 953 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Destroy> {after 0 exit} |
| 799 | @ bind . <Tab> {cycleDiffs; break} |
| 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 801 | @ bind . <Return> { |
| 802 | @ event generate .files <1> |
| 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 908 | |
| 909 | /* |
| 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 911 | ** to the diff command. |
| 912 | ** |
| 913 | ** If fossil has direct access to a Tcl interpreter (either loaded |
| 914 | ** dynamically through stubs or linked in statically), we can use it |
| 915 | ** directly. Otherwise: |
| 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 917 | ** (2) Invoke "tclsh" on the temp file using fossil_system(). |
| 918 | ** (3) Delete the temp file. |
| 919 | */ |
| 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 921 | int i; |
| 922 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 947 | if( zTempFile ){ |
| 948 | blob_write_to_file(&script, zTempFile); |
| 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 950 | }else{ |
| 951 | #if defined(FOSSIL_ENABLE_TCL) |
| 952 | Th_FossilInit(TH_INIT_DEFAULT); |
| 953 | if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), |
| 954 | blob_size(&script), 1)==TCL_OK ){ |
| 955 | blob_reset(&script); |
| 956 | return; |
| 957 | } |
| 958 | /* |
| 959 | * If evaluation of the Tcl script fails, the reason may be that Tk |
| 960 | * could not be found by the loaded Tcl, or that Tcl cannot be loaded |
| 961 | * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback |
| 962 | * to using the external "tclsh", if available. |
| 963 | */ |
| 964 | #endif |
| 965 | zTempFile = write_blob_to_temp_file(&script); |
| 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 967 | fossil_system(zCmd); |
| 968 | file_delete(zTempFile); |
| 969 | fossil_free(zCmd); |
| 970 |
+20
-3
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -774,11 +774,11 @@ | ||
| 774 | 774 | @ grid remove $sb |
| 775 | 775 | @ } |
| 776 | 776 | @ } |
| 777 | 777 | @ enableSync x |
| 778 | 778 | @ } |
| 779 | -@ | |
| 779 | +@ | |
| 780 | 780 | @ proc sync-y {first last} { |
| 781 | 781 | @ disableSync y |
| 782 | 782 | @ foreach c [cols] { |
| 783 | 783 | @ $c yview moveto $first |
| 784 | 784 | @ } |
| @@ -793,10 +793,11 @@ | ||
| 793 | 793 | @ |
| 794 | 794 | @ wm withdraw . |
| 795 | 795 | @ wm title . $CFG(TITLE) |
| 796 | 796 | @ wm iconname . $CFG(TITLE) |
| 797 | 797 | @ bind . <q> exit |
| 798 | +@ bind . <Destroy> {after 0 exit} | |
| 798 | 799 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | 801 | @ bind . <Return> { |
| 801 | 802 | @ event generate .files <1> |
| 802 | 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | ||
| 907 | 908 | |
| 908 | 909 | /* |
| 909 | 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | 911 | ** to the diff command. |
| 911 | 912 | ** |
| 912 | -** Steps: | |
| 913 | +** If fossil has direct access to a Tcl interpreter (either loaded | |
| 914 | +** dynamically through stubs or linked in statically), we can use it | |
| 915 | +** directly. Otherwise: | |
| 913 | 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | -** (2) Invoke "wish" on the temp file using fossil_system(). | |
| 917 | +** (2) Invoke "tclsh" on the temp file using fossil_system(). | |
| 915 | 918 | ** (3) Delete the temp file. |
| 916 | 919 | */ |
| 917 | 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | 921 | int i; |
| 919 | 922 | Blob script; |
| @@ -943,10 +946,24 @@ | ||
| 943 | 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | 947 | if( zTempFile ){ |
| 945 | 948 | blob_write_to_file(&script, zTempFile); |
| 946 | 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | 950 | }else{ |
| 951 | +#if defined(FOSSIL_ENABLE_TCL) | |
| 952 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 953 | + if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), | |
| 954 | + blob_size(&script), 1)==TCL_OK ){ | |
| 955 | + blob_reset(&script); | |
| 956 | + return; | |
| 957 | + } | |
| 958 | + /* | |
| 959 | + * If evaluation of the Tcl script fails, the reason may be that Tk | |
| 960 | + * could not be found by the loaded Tcl, or that Tcl cannot be loaded | |
| 961 | + * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback | |
| 962 | + * to using the external "tclsh", if available. | |
| 963 | + */ | |
| 964 | +#endif | |
| 948 | 965 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | 967 | fossil_system(zCmd); |
| 951 | 968 | file_delete(zTempFile); |
| 952 | 969 | fossil_free(zCmd); |
| 953 | 970 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | @ bind . <Return> { |
| 801 | @ event generate .files <1> |
| 802 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 907 | |
| 908 | /* |
| 909 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | ** to the diff command. |
| 911 | ** |
| 912 | ** Steps: |
| 913 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| 953 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Destroy> {after 0 exit} |
| 799 | @ bind . <Tab> {cycleDiffs; break} |
| 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 801 | @ bind . <Return> { |
| 802 | @ event generate .files <1> |
| 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 908 | |
| 909 | /* |
| 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 911 | ** to the diff command. |
| 912 | ** |
| 913 | ** If fossil has direct access to a Tcl interpreter (either loaded |
| 914 | ** dynamically through stubs or linked in statically), we can use it |
| 915 | ** directly. Otherwise: |
| 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 917 | ** (2) Invoke "tclsh" on the temp file using fossil_system(). |
| 918 | ** (3) Delete the temp file. |
| 919 | */ |
| 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 921 | int i; |
| 922 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 947 | if( zTempFile ){ |
| 948 | blob_write_to_file(&script, zTempFile); |
| 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 950 | }else{ |
| 951 | #if defined(FOSSIL_ENABLE_TCL) |
| 952 | Th_FossilInit(TH_INIT_DEFAULT); |
| 953 | if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), |
| 954 | blob_size(&script), 1)==TCL_OK ){ |
| 955 | blob_reset(&script); |
| 956 | return; |
| 957 | } |
| 958 | /* |
| 959 | * If evaluation of the Tcl script fails, the reason may be that Tk |
| 960 | * could not be found by the loaded Tcl, or that Tcl cannot be loaded |
| 961 | * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback |
| 962 | * to using the external "tclsh", if available. |
| 963 | */ |
| 964 | #endif |
| 965 | zTempFile = write_blob_to_temp_file(&script); |
| 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 967 | fossil_system(zCmd); |
| 968 | file_delete(zTempFile); |
| 969 | fossil_free(zCmd); |
| 970 |
+20
-3
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -774,11 +774,11 @@ | ||
| 774 | 774 | @ grid remove $sb |
| 775 | 775 | @ } |
| 776 | 776 | @ } |
| 777 | 777 | @ enableSync x |
| 778 | 778 | @ } |
| 779 | -@ | |
| 779 | +@ | |
| 780 | 780 | @ proc sync-y {first last} { |
| 781 | 781 | @ disableSync y |
| 782 | 782 | @ foreach c [cols] { |
| 783 | 783 | @ $c yview moveto $first |
| 784 | 784 | @ } |
| @@ -793,10 +793,11 @@ | ||
| 793 | 793 | @ |
| 794 | 794 | @ wm withdraw . |
| 795 | 795 | @ wm title . $CFG(TITLE) |
| 796 | 796 | @ wm iconname . $CFG(TITLE) |
| 797 | 797 | @ bind . <q> exit |
| 798 | +@ bind . <Destroy> {after 0 exit} | |
| 798 | 799 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | 801 | @ bind . <Return> { |
| 801 | 802 | @ event generate .files <1> |
| 802 | 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | ||
| 907 | 908 | |
| 908 | 909 | /* |
| 909 | 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | 911 | ** to the diff command. |
| 911 | 912 | ** |
| 912 | -** Steps: | |
| 913 | +** If fossil has direct access to a Tcl interpreter (either loaded | |
| 914 | +** dynamically through stubs or linked in statically), we can use it | |
| 915 | +** directly. Otherwise: | |
| 913 | 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | -** (2) Invoke "wish" on the temp file using fossil_system(). | |
| 917 | +** (2) Invoke "tclsh" on the temp file using fossil_system(). | |
| 915 | 918 | ** (3) Delete the temp file. |
| 916 | 919 | */ |
| 917 | 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | 921 | int i; |
| 919 | 922 | Blob script; |
| @@ -943,10 +946,24 @@ | ||
| 943 | 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | 947 | if( zTempFile ){ |
| 945 | 948 | blob_write_to_file(&script, zTempFile); |
| 946 | 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | 950 | }else{ |
| 951 | +#if defined(FOSSIL_ENABLE_TCL) | |
| 952 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 953 | + if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), | |
| 954 | + blob_size(&script), 1)==TCL_OK ){ | |
| 955 | + blob_reset(&script); | |
| 956 | + return; | |
| 957 | + } | |
| 958 | + /* | |
| 959 | + * If evaluation of the Tcl script fails, the reason may be that Tk | |
| 960 | + * could not be found by the loaded Tcl, or that Tcl cannot be loaded | |
| 961 | + * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback | |
| 962 | + * to using the external "tclsh", if available. | |
| 963 | + */ | |
| 964 | +#endif | |
| 948 | 965 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | 967 | fossil_system(zCmd); |
| 951 | 968 | file_delete(zTempFile); |
| 952 | 969 | fossil_free(zCmd); |
| 953 | 970 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | @ bind . <Return> { |
| 801 | @ event generate .files <1> |
| 802 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 907 | |
| 908 | /* |
| 909 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | ** to the diff command. |
| 911 | ** |
| 912 | ** Steps: |
| 913 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| 953 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -793,10 +793,11 @@ | |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Destroy> {after 0 exit} |
| 799 | @ bind . <Tab> {cycleDiffs; break} |
| 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 801 | @ bind . <Return> { |
| 802 | @ event generate .files <1> |
| 803 | @ event generate .files <ButtonRelease-1> |
| @@ -907,13 +908,15 @@ | |
| 908 | |
| 909 | /* |
| 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 911 | ** to the diff command. |
| 912 | ** |
| 913 | ** If fossil has direct access to a Tcl interpreter (either loaded |
| 914 | ** dynamically through stubs or linked in statically), we can use it |
| 915 | ** directly. Otherwise: |
| 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 917 | ** (2) Invoke "tclsh" on the temp file using fossil_system(). |
| 918 | ** (3) Delete the temp file. |
| 919 | */ |
| 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 921 | int i; |
| 922 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 947 | if( zTempFile ){ |
| 948 | blob_write_to_file(&script, zTempFile); |
| 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 950 | }else{ |
| 951 | #if defined(FOSSIL_ENABLE_TCL) |
| 952 | Th_FossilInit(TH_INIT_DEFAULT); |
| 953 | if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), |
| 954 | blob_size(&script), 1)==TCL_OK ){ |
| 955 | blob_reset(&script); |
| 956 | return; |
| 957 | } |
| 958 | /* |
| 959 | * If evaluation of the Tcl script fails, the reason may be that Tk |
| 960 | * could not be found by the loaded Tcl, or that Tcl cannot be loaded |
| 961 | * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback |
| 962 | * to using the external "tclsh", if available. |
| 963 | */ |
| 964 | #endif |
| 965 | zTempFile = write_blob_to_temp_file(&script); |
| 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 967 | fossil_system(zCmd); |
| 968 | file_delete(zTempFile); |
| 969 | fossil_free(zCmd); |
| 970 |
M
src/th.h
+6
-2
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -157,12 +157,16 @@ | ||
| 157 | 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | 160 | |
| 161 | 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | -int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 163 | -int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 162 | +/* | |
| 163 | +** Interfaces to the full Tcl core library from "th_tcl.c". | |
| 164 | +*/ | |
| 165 | +int th_register_tcl(Th_Interp *, void *); | |
| 166 | +int unloadTcl(Th_Interp *, void *); | |
| 167 | +int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); | |
| 164 | 168 | #endif |
| 165 | 169 | |
| 166 | 170 | /* |
| 167 | 171 | ** General purpose hash table from th_lang.c. |
| 168 | 172 | */ |
| 169 | 173 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 163 | int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 164 | #endif |
| 165 | |
| 166 | /* |
| 167 | ** General purpose hash table from th_lang.c. |
| 168 | */ |
| 169 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | /* |
| 163 | ** Interfaces to the full Tcl core library from "th_tcl.c". |
| 164 | */ |
| 165 | int th_register_tcl(Th_Interp *, void *); |
| 166 | int unloadTcl(Th_Interp *, void *); |
| 167 | int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); |
| 168 | #endif |
| 169 | |
| 170 | /* |
| 171 | ** General purpose hash table from th_lang.c. |
| 172 | */ |
| 173 |
M
src/th.h
+6
-2
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -157,12 +157,16 @@ | ||
| 157 | 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | 160 | |
| 161 | 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | -int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 163 | -int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 162 | +/* | |
| 163 | +** Interfaces to the full Tcl core library from "th_tcl.c". | |
| 164 | +*/ | |
| 165 | +int th_register_tcl(Th_Interp *, void *); | |
| 166 | +int unloadTcl(Th_Interp *, void *); | |
| 167 | +int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); | |
| 164 | 168 | #endif |
| 165 | 169 | |
| 166 | 170 | /* |
| 167 | 171 | ** General purpose hash table from th_lang.c. |
| 168 | 172 | */ |
| 169 | 173 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 163 | int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 164 | #endif |
| 165 | |
| 166 | /* |
| 167 | ** General purpose hash table from th_lang.c. |
| 168 | */ |
| 169 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | /* |
| 163 | ** Interfaces to the full Tcl core library from "th_tcl.c". |
| 164 | */ |
| 165 | int th_register_tcl(Th_Interp *, void *); |
| 166 | int unloadTcl(Th_Interp *, void *); |
| 167 | int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); |
| 168 | #endif |
| 169 | |
| 170 | /* |
| 171 | ** General purpose hash table from th_lang.c. |
| 172 | */ |
| 173 |
M
src/th.h
+6
-2
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -157,12 +157,16 @@ | ||
| 157 | 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | 160 | |
| 161 | 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | -int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 163 | -int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 162 | +/* | |
| 163 | +** Interfaces to the full Tcl core library from "th_tcl.c". | |
| 164 | +*/ | |
| 165 | +int th_register_tcl(Th_Interp *, void *); | |
| 166 | +int unloadTcl(Th_Interp *, void *); | |
| 167 | +int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); | |
| 164 | 168 | #endif |
| 165 | 169 | |
| 166 | 170 | /* |
| 167 | 171 | ** General purpose hash table from th_lang.c. |
| 168 | 172 | */ |
| 169 | 173 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 163 | int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 164 | #endif |
| 165 | |
| 166 | /* |
| 167 | ** General purpose hash table from th_lang.c. |
| 168 | */ |
| 169 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | /* |
| 163 | ** Interfaces to the full Tcl core library from "th_tcl.c". |
| 164 | */ |
| 165 | int th_register_tcl(Th_Interp *, void *); |
| 166 | int unloadTcl(Th_Interp *, void *); |
| 167 | int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); |
| 168 | #endif |
| 169 | |
| 170 | /* |
| 171 | ** General purpose hash table from th_lang.c. |
| 172 | */ |
| 173 |
M
src/th.h
+6
-2
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -157,12 +157,16 @@ | ||
| 157 | 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | 160 | |
| 161 | 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | -int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 163 | -int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 162 | +/* | |
| 163 | +** Interfaces to the full Tcl core library from "th_tcl.c". | |
| 164 | +*/ | |
| 165 | +int th_register_tcl(Th_Interp *, void *); | |
| 166 | +int unloadTcl(Th_Interp *, void *); | |
| 167 | +int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); | |
| 164 | 168 | #endif |
| 165 | 169 | |
| 166 | 170 | /* |
| 167 | 171 | ** General purpose hash table from th_lang.c. |
| 168 | 172 | */ |
| 169 | 173 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 163 | int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 164 | #endif |
| 165 | |
| 166 | /* |
| 167 | ** General purpose hash table from th_lang.c. |
| 168 | */ |
| 169 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | /* |
| 163 | ** Interfaces to the full Tcl core library from "th_tcl.c". |
| 164 | */ |
| 165 | int th_register_tcl(Th_Interp *, void *); |
| 166 | int unloadTcl(Th_Interp *, void *); |
| 167 | int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); |
| 168 | #endif |
| 169 | |
| 170 | /* |
| 171 | ** General purpose hash table from th_lang.c. |
| 172 | */ |
| 173 |
M
src/th.h
+6
-2
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -157,12 +157,16 @@ | ||
| 157 | 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | 160 | |
| 161 | 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | -int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 163 | -int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 162 | +/* | |
| 163 | +** Interfaces to the full Tcl core library from "th_tcl.c". | |
| 164 | +*/ | |
| 165 | +int th_register_tcl(Th_Interp *, void *); | |
| 166 | +int unloadTcl(Th_Interp *, void *); | |
| 167 | +int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); | |
| 164 | 168 | #endif |
| 165 | 169 | |
| 166 | 170 | /* |
| 167 | 171 | ** General purpose hash table from th_lang.c. |
| 168 | 172 | */ |
| 169 | 173 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 163 | int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 164 | #endif |
| 165 | |
| 166 | /* |
| 167 | ** General purpose hash table from th_lang.c. |
| 168 | */ |
| 169 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | /* |
| 163 | ** Interfaces to the full Tcl core library from "th_tcl.c". |
| 164 | */ |
| 165 | int th_register_tcl(Th_Interp *, void *); |
| 166 | int unloadTcl(Th_Interp *, void *); |
| 167 | int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); |
| 168 | #endif |
| 169 | |
| 170 | /* |
| 171 | ** General purpose hash table from th_lang.c. |
| 172 | */ |
| 173 |
M
src/th.h
+6
-2
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -157,12 +157,16 @@ | ||
| 157 | 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | 160 | |
| 161 | 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | -int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 163 | -int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 162 | +/* | |
| 163 | +** Interfaces to the full Tcl core library from "th_tcl.c". | |
| 164 | +*/ | |
| 165 | +int th_register_tcl(Th_Interp *, void *); | |
| 166 | +int unloadTcl(Th_Interp *, void *); | |
| 167 | +int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); | |
| 164 | 168 | #endif |
| 165 | 169 | |
| 166 | 170 | /* |
| 167 | 171 | ** General purpose hash table from th_lang.c. |
| 168 | 172 | */ |
| 169 | 173 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 163 | int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 164 | #endif |
| 165 | |
| 166 | /* |
| 167 | ** General purpose hash table from th_lang.c. |
| 168 | */ |
| 169 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | /* |
| 163 | ** Interfaces to the full Tcl core library from "th_tcl.c". |
| 164 | */ |
| 165 | int th_register_tcl(Th_Interp *, void *); |
| 166 | int unloadTcl(Th_Interp *, void *); |
| 167 | int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); |
| 168 | #endif |
| 169 | |
| 170 | /* |
| 171 | ** General purpose hash table from th_lang.c. |
| 172 | */ |
| 173 |
+32
| --- src/th_tcl.c | ||
| +++ src/th_tcl.c | ||
| @@ -766,10 +766,42 @@ | ||
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | Tcl_DecrRefCount(listPtr); |
| 769 | 769 | return rc; |
| 770 | 770 | } |
| 771 | + | |
| 772 | +/* | |
| 773 | +** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the | |
| 774 | +** Tcl script succeeds, start a Tcl event loop until there are no more events | |
| 775 | +** remaining to process -OR- the script calls [exit]. If the bWait argument | |
| 776 | +** is zero, only process events that are already in the queue; otherwise, | |
| 777 | +** process events until the script terminates the Tcl event loop. | |
| 778 | +*/ | |
| 779 | +int evaluateTclWithEvents( | |
| 780 | + Th_Interp *interp, | |
| 781 | + void *pContext, | |
| 782 | + const char *zScript, | |
| 783 | + int nScript, | |
| 784 | + int bWait | |
| 785 | +){ | |
| 786 | + struct TclContext *tclContext = (struct TclContext *)pContext; | |
| 787 | + Tcl_Interp *tclInterp; | |
| 788 | + int rc; | |
| 789 | + int flags = TCL_ALL_EVENTS; | |
| 790 | + | |
| 791 | + if( createTclInterp(interp, pContext)!=TH_OK ){ | |
| 792 | + return TH_ERROR; | |
| 793 | + } | |
| 794 | + tclInterp = tclContext->interp; | |
| 795 | + rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); | |
| 796 | + if( rc!=TCL_OK ) return rc; | |
| 797 | + if( !bWait ) flags |= TCL_DONT_WAIT; | |
| 798 | + while( Tcl_DoOneEvent(flags) ){ | |
| 799 | + /* do nothing */ | |
| 800 | + } | |
| 801 | + return rc; | |
| 802 | +} | |
| 771 | 803 | |
| 772 | 804 | /* |
| 773 | 805 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 774 | 806 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 775 | 807 | ** by the caller. |
| 776 | 808 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -766,10 +766,42 @@ | |
| 766 | } |
| 767 | } |
| 768 | Tcl_DecrRefCount(listPtr); |
| 769 | return rc; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 774 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 775 | ** by the caller. |
| 776 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -766,10 +766,42 @@ | |
| 766 | } |
| 767 | } |
| 768 | Tcl_DecrRefCount(listPtr); |
| 769 | return rc; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the |
| 774 | ** Tcl script succeeds, start a Tcl event loop until there are no more events |
| 775 | ** remaining to process -OR- the script calls [exit]. If the bWait argument |
| 776 | ** is zero, only process events that are already in the queue; otherwise, |
| 777 | ** process events until the script terminates the Tcl event loop. |
| 778 | */ |
| 779 | int evaluateTclWithEvents( |
| 780 | Th_Interp *interp, |
| 781 | void *pContext, |
| 782 | const char *zScript, |
| 783 | int nScript, |
| 784 | int bWait |
| 785 | ){ |
| 786 | struct TclContext *tclContext = (struct TclContext *)pContext; |
| 787 | Tcl_Interp *tclInterp; |
| 788 | int rc; |
| 789 | int flags = TCL_ALL_EVENTS; |
| 790 | |
| 791 | if( createTclInterp(interp, pContext)!=TH_OK ){ |
| 792 | return TH_ERROR; |
| 793 | } |
| 794 | tclInterp = tclContext->interp; |
| 795 | rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); |
| 796 | if( rc!=TCL_OK ) return rc; |
| 797 | if( !bWait ) flags |= TCL_DONT_WAIT; |
| 798 | while( Tcl_DoOneEvent(flags) ){ |
| 799 | /* do nothing */ |
| 800 | } |
| 801 | return rc; |
| 802 | } |
| 803 | |
| 804 | /* |
| 805 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 806 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 807 | ** by the caller. |
| 808 |
+32
| --- src/th_tcl.c | ||
| +++ src/th_tcl.c | ||
| @@ -766,10 +766,42 @@ | ||
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | Tcl_DecrRefCount(listPtr); |
| 769 | 769 | return rc; |
| 770 | 770 | } |
| 771 | + | |
| 772 | +/* | |
| 773 | +** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the | |
| 774 | +** Tcl script succeeds, start a Tcl event loop until there are no more events | |
| 775 | +** remaining to process -OR- the script calls [exit]. If the bWait argument | |
| 776 | +** is zero, only process events that are already in the queue; otherwise, | |
| 777 | +** process events until the script terminates the Tcl event loop. | |
| 778 | +*/ | |
| 779 | +int evaluateTclWithEvents( | |
| 780 | + Th_Interp *interp, | |
| 781 | + void *pContext, | |
| 782 | + const char *zScript, | |
| 783 | + int nScript, | |
| 784 | + int bWait | |
| 785 | +){ | |
| 786 | + struct TclContext *tclContext = (struct TclContext *)pContext; | |
| 787 | + Tcl_Interp *tclInterp; | |
| 788 | + int rc; | |
| 789 | + int flags = TCL_ALL_EVENTS; | |
| 790 | + | |
| 791 | + if( createTclInterp(interp, pContext)!=TH_OK ){ | |
| 792 | + return TH_ERROR; | |
| 793 | + } | |
| 794 | + tclInterp = tclContext->interp; | |
| 795 | + rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); | |
| 796 | + if( rc!=TCL_OK ) return rc; | |
| 797 | + if( !bWait ) flags |= TCL_DONT_WAIT; | |
| 798 | + while( Tcl_DoOneEvent(flags) ){ | |
| 799 | + /* do nothing */ | |
| 800 | + } | |
| 801 | + return rc; | |
| 802 | +} | |
| 771 | 803 | |
| 772 | 804 | /* |
| 773 | 805 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 774 | 806 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 775 | 807 | ** by the caller. |
| 776 | 808 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -766,10 +766,42 @@ | |
| 766 | } |
| 767 | } |
| 768 | Tcl_DecrRefCount(listPtr); |
| 769 | return rc; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 774 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 775 | ** by the caller. |
| 776 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -766,10 +766,42 @@ | |
| 766 | } |
| 767 | } |
| 768 | Tcl_DecrRefCount(listPtr); |
| 769 | return rc; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the |
| 774 | ** Tcl script succeeds, start a Tcl event loop until there are no more events |
| 775 | ** remaining to process -OR- the script calls [exit]. If the bWait argument |
| 776 | ** is zero, only process events that are already in the queue; otherwise, |
| 777 | ** process events until the script terminates the Tcl event loop. |
| 778 | */ |
| 779 | int evaluateTclWithEvents( |
| 780 | Th_Interp *interp, |
| 781 | void *pContext, |
| 782 | const char *zScript, |
| 783 | int nScript, |
| 784 | int bWait |
| 785 | ){ |
| 786 | struct TclContext *tclContext = (struct TclContext *)pContext; |
| 787 | Tcl_Interp *tclInterp; |
| 788 | int rc; |
| 789 | int flags = TCL_ALL_EVENTS; |
| 790 | |
| 791 | if( createTclInterp(interp, pContext)!=TH_OK ){ |
| 792 | return TH_ERROR; |
| 793 | } |
| 794 | tclInterp = tclContext->interp; |
| 795 | rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); |
| 796 | if( rc!=TCL_OK ) return rc; |
| 797 | if( !bWait ) flags |= TCL_DONT_WAIT; |
| 798 | while( Tcl_DoOneEvent(flags) ){ |
| 799 | /* do nothing */ |
| 800 | } |
| 801 | return rc; |
| 802 | } |
| 803 | |
| 804 | /* |
| 805 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 806 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 807 | ** by the caller. |
| 808 |
+32
| --- src/th_tcl.c | ||
| +++ src/th_tcl.c | ||
| @@ -766,10 +766,42 @@ | ||
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | Tcl_DecrRefCount(listPtr); |
| 769 | 769 | return rc; |
| 770 | 770 | } |
| 771 | + | |
| 772 | +/* | |
| 773 | +** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the | |
| 774 | +** Tcl script succeeds, start a Tcl event loop until there are no more events | |
| 775 | +** remaining to process -OR- the script calls [exit]. If the bWait argument | |
| 776 | +** is zero, only process events that are already in the queue; otherwise, | |
| 777 | +** process events until the script terminates the Tcl event loop. | |
| 778 | +*/ | |
| 779 | +int evaluateTclWithEvents( | |
| 780 | + Th_Interp *interp, | |
| 781 | + void *pContext, | |
| 782 | + const char *zScript, | |
| 783 | + int nScript, | |
| 784 | + int bWait | |
| 785 | +){ | |
| 786 | + struct TclContext *tclContext = (struct TclContext *)pContext; | |
| 787 | + Tcl_Interp *tclInterp; | |
| 788 | + int rc; | |
| 789 | + int flags = TCL_ALL_EVENTS; | |
| 790 | + | |
| 791 | + if( createTclInterp(interp, pContext)!=TH_OK ){ | |
| 792 | + return TH_ERROR; | |
| 793 | + } | |
| 794 | + tclInterp = tclContext->interp; | |
| 795 | + rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); | |
| 796 | + if( rc!=TCL_OK ) return rc; | |
| 797 | + if( !bWait ) flags |= TCL_DONT_WAIT; | |
| 798 | + while( Tcl_DoOneEvent(flags) ){ | |
| 799 | + /* do nothing */ | |
| 800 | + } | |
| 801 | + return rc; | |
| 802 | +} | |
| 771 | 803 | |
| 772 | 804 | /* |
| 773 | 805 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 774 | 806 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 775 | 807 | ** by the caller. |
| 776 | 808 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -766,10 +766,42 @@ | |
| 766 | } |
| 767 | } |
| 768 | Tcl_DecrRefCount(listPtr); |
| 769 | return rc; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 774 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 775 | ** by the caller. |
| 776 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -766,10 +766,42 @@ | |
| 766 | } |
| 767 | } |
| 768 | Tcl_DecrRefCount(listPtr); |
| 769 | return rc; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the |
| 774 | ** Tcl script succeeds, start a Tcl event loop until there are no more events |
| 775 | ** remaining to process -OR- the script calls [exit]. If the bWait argument |
| 776 | ** is zero, only process events that are already in the queue; otherwise, |
| 777 | ** process events until the script terminates the Tcl event loop. |
| 778 | */ |
| 779 | int evaluateTclWithEvents( |
| 780 | Th_Interp *interp, |
| 781 | void *pContext, |
| 782 | const char *zScript, |
| 783 | int nScript, |
| 784 | int bWait |
| 785 | ){ |
| 786 | struct TclContext *tclContext = (struct TclContext *)pContext; |
| 787 | Tcl_Interp *tclInterp; |
| 788 | int rc; |
| 789 | int flags = TCL_ALL_EVENTS; |
| 790 | |
| 791 | if( createTclInterp(interp, pContext)!=TH_OK ){ |
| 792 | return TH_ERROR; |
| 793 | } |
| 794 | tclInterp = tclContext->interp; |
| 795 | rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); |
| 796 | if( rc!=TCL_OK ) return rc; |
| 797 | if( !bWait ) flags |= TCL_DONT_WAIT; |
| 798 | while( Tcl_DoOneEvent(flags) ){ |
| 799 | /* do nothing */ |
| 800 | } |
| 801 | return rc; |
| 802 | } |
| 803 | |
| 804 | /* |
| 805 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 806 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 807 | ** by the caller. |
| 808 |