| | @@ -908,13 +908,15 @@ |
| 908 | 908 | |
| 909 | 909 | /* |
| 910 | 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 911 | 911 | ** to the diff command. |
| 912 | 912 | ** |
| 913 | | -** 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: |
| 914 | 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 915 | | -** (2) Invoke "wish" on the temp file using fossil_system(). |
| 917 | +** (2) Invoke "tclsh" on the temp file using fossil_system(). |
| 916 | 918 | ** (3) Delete the temp file. |
| 917 | 919 | */ |
| 918 | 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 919 | 921 | int i; |
| 920 | 922 | Blob script; |
| | @@ -944,10 +946,21 @@ |
| 944 | 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 945 | 947 | if( zTempFile ){ |
| 946 | 948 | blob_write_to_file(&script, zTempFile); |
| 947 | 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 948 | 950 | }else{ |
| 951 | +#if defined(FOSSIL_ENABLE_TCL) |
| 952 | + Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_FORCE_TCL); |
| 953 | + if (runTclGui(g.interp, &g.tcl, blob_str(&script)) == TCL_OK){ |
| 954 | + blob_reset(&script); |
| 955 | + return; |
| 956 | + } |
| 957 | + /* If evaluation of the script fails, the reason could be that Tk |
| 958 | + * cannot be found by the built-in Tcl, or that Tcl cannot be |
| 959 | + * loaded dynamically (e.g. Win64 Tcl in Win32 fossil). Try again |
| 960 | + * using an external "tclsh", which might work in those two cases. */ |
| 961 | +#endif |
| 949 | 962 | zTempFile = write_blob_to_temp_file(&script); |
| 950 | 963 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 951 | 964 | fossil_system(zCmd); |
| 952 | 965 | file_delete(zTempFile); |
| 953 | 966 | fossil_free(zCmd); |
| 954 | 967 | |