Fossil SCM
Add support for the tcl_platform(platform) and tcl_platform(engine) array elements to TH1.
Commit
663b722e270738addc55ec37f6d7b9a0fa0faf8a
Parent
d8d2222b91854e2…
2 files changed
+33
+18
-8
M
src/th.c
+33
| --- src/th.c | ||
| +++ src/th.c | ||
| @@ -6,10 +6,30 @@ | ||
| 6 | 6 | |
| 7 | 7 | #include "config.h" |
| 8 | 8 | #include "th.h" |
| 9 | 9 | #include <string.h> |
| 10 | 10 | #include <assert.h> |
| 11 | + | |
| 12 | +/* | |
| 13 | +** Values used for element values in the tcl_platform array. | |
| 14 | +*/ | |
| 15 | + | |
| 16 | +#if !defined(TH1_ENGINE) | |
| 17 | +# define TH1_ENGINE "TH1" | |
| 18 | +#endif | |
| 19 | + | |
| 20 | +#if !defined(TH1_PLATFORM) | |
| 21 | +# if defined(_WIN32) || defined(WIN32) | |
| 22 | +# define TH1_PLATFORM "windows" | |
| 23 | +# else | |
| 24 | +# define TH1_PLATFORM "unix" | |
| 25 | +# endif | |
| 26 | +#endif | |
| 27 | + | |
| 28 | +/* | |
| 29 | +** Forward declarations for structures defined below. | |
| 30 | +*/ | |
| 11 | 31 | |
| 12 | 32 | typedef struct Th_Command Th_Command; |
| 13 | 33 | typedef struct Th_Frame Th_Frame; |
| 14 | 34 | typedef struct Th_Variable Th_Variable; |
| 15 | 35 | typedef struct Th_InterpAndList Th_InterpAndList; |
| @@ -1756,10 +1776,22 @@ | ||
| 1756 | 1776 | *pzStr = zNew; |
| 1757 | 1777 | *pnStr = nNew; |
| 1758 | 1778 | |
| 1759 | 1779 | return TH_OK; |
| 1760 | 1780 | } |
| 1781 | + | |
| 1782 | +/* | |
| 1783 | +** Initialize an interpreter. | |
| 1784 | +*/ | |
| 1785 | +static int thInitialize(Th_Interp *interp){ | |
| 1786 | + assert(interp->pFrame); | |
| 1787 | + | |
| 1788 | + Th_SetVar(interp, (char *)"::tcl_platform(engine)", -1, TH1_ENGINE, -1); | |
| 1789 | + Th_SetVar(interp, (char *)"::tcl_platform(platform)", -1, TH1_PLATFORM, -1); | |
| 1790 | + | |
| 1791 | + return TH_OK; | |
| 1792 | +} | |
| 1761 | 1793 | |
| 1762 | 1794 | /* |
| 1763 | 1795 | ** Delete an interpreter. |
| 1764 | 1796 | */ |
| 1765 | 1797 | void Th_DeleteInterp(Th_Interp *interp){ |
| @@ -1790,10 +1822,11 @@ | ||
| 1790 | 1822 | p = pVtab->xMalloc(sizeof(Th_Interp) + sizeof(Th_Frame)); |
| 1791 | 1823 | memset(p, 0, sizeof(Th_Interp)); |
| 1792 | 1824 | p->pVtab = pVtab; |
| 1793 | 1825 | p->paCmd = Th_HashNew(p); |
| 1794 | 1826 | thPushFrame(p, (Th_Frame *)&p[1]); |
| 1827 | + thInitialize(p); | |
| 1795 | 1828 | |
| 1796 | 1829 | return p; |
| 1797 | 1830 | } |
| 1798 | 1831 | |
| 1799 | 1832 | /* |
| 1800 | 1833 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -6,10 +6,30 @@ | |
| 6 | |
| 7 | #include "config.h" |
| 8 | #include "th.h" |
| 9 | #include <string.h> |
| 10 | #include <assert.h> |
| 11 | |
| 12 | typedef struct Th_Command Th_Command; |
| 13 | typedef struct Th_Frame Th_Frame; |
| 14 | typedef struct Th_Variable Th_Variable; |
| 15 | typedef struct Th_InterpAndList Th_InterpAndList; |
| @@ -1756,10 +1776,22 @@ | |
| 1756 | *pzStr = zNew; |
| 1757 | *pnStr = nNew; |
| 1758 | |
| 1759 | return TH_OK; |
| 1760 | } |
| 1761 | |
| 1762 | /* |
| 1763 | ** Delete an interpreter. |
| 1764 | */ |
| 1765 | void Th_DeleteInterp(Th_Interp *interp){ |
| @@ -1790,10 +1822,11 @@ | |
| 1790 | p = pVtab->xMalloc(sizeof(Th_Interp) + sizeof(Th_Frame)); |
| 1791 | memset(p, 0, sizeof(Th_Interp)); |
| 1792 | p->pVtab = pVtab; |
| 1793 | p->paCmd = Th_HashNew(p); |
| 1794 | thPushFrame(p, (Th_Frame *)&p[1]); |
| 1795 | |
| 1796 | return p; |
| 1797 | } |
| 1798 | |
| 1799 | /* |
| 1800 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -6,10 +6,30 @@ | |
| 6 | |
| 7 | #include "config.h" |
| 8 | #include "th.h" |
| 9 | #include <string.h> |
| 10 | #include <assert.h> |
| 11 | |
| 12 | /* |
| 13 | ** Values used for element values in the tcl_platform array. |
| 14 | */ |
| 15 | |
| 16 | #if !defined(TH1_ENGINE) |
| 17 | # define TH1_ENGINE "TH1" |
| 18 | #endif |
| 19 | |
| 20 | #if !defined(TH1_PLATFORM) |
| 21 | # if defined(_WIN32) || defined(WIN32) |
| 22 | # define TH1_PLATFORM "windows" |
| 23 | # else |
| 24 | # define TH1_PLATFORM "unix" |
| 25 | # endif |
| 26 | #endif |
| 27 | |
| 28 | /* |
| 29 | ** Forward declarations for structures defined below. |
| 30 | */ |
| 31 | |
| 32 | typedef struct Th_Command Th_Command; |
| 33 | typedef struct Th_Frame Th_Frame; |
| 34 | typedef struct Th_Variable Th_Variable; |
| 35 | typedef struct Th_InterpAndList Th_InterpAndList; |
| @@ -1756,10 +1776,22 @@ | |
| 1776 | *pzStr = zNew; |
| 1777 | *pnStr = nNew; |
| 1778 | |
| 1779 | return TH_OK; |
| 1780 | } |
| 1781 | |
| 1782 | /* |
| 1783 | ** Initialize an interpreter. |
| 1784 | */ |
| 1785 | static int thInitialize(Th_Interp *interp){ |
| 1786 | assert(interp->pFrame); |
| 1787 | |
| 1788 | Th_SetVar(interp, (char *)"::tcl_platform(engine)", -1, TH1_ENGINE, -1); |
| 1789 | Th_SetVar(interp, (char *)"::tcl_platform(platform)", -1, TH1_PLATFORM, -1); |
| 1790 | |
| 1791 | return TH_OK; |
| 1792 | } |
| 1793 | |
| 1794 | /* |
| 1795 | ** Delete an interpreter. |
| 1796 | */ |
| 1797 | void Th_DeleteInterp(Th_Interp *interp){ |
| @@ -1790,10 +1822,11 @@ | |
| 1822 | p = pVtab->xMalloc(sizeof(Th_Interp) + sizeof(Th_Frame)); |
| 1823 | memset(p, 0, sizeof(Th_Interp)); |
| 1824 | p->pVtab = pVtab; |
| 1825 | p->paCmd = Th_HashNew(p); |
| 1826 | thPushFrame(p, (Th_Frame *)&p[1]); |
| 1827 | thInitialize(p); |
| 1828 | |
| 1829 | return p; |
| 1830 | } |
| 1831 | |
| 1832 | /* |
| 1833 |
+18
-8
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -944,35 +944,35 @@ | ||
| 944 | 944 | |
| 945 | 945 | fossil test-th-eval "info vars" |
| 946 | 946 | |
| 947 | 947 | if {$th1Hooks} { |
| 948 | 948 | test th1-info-vars-1 {$RESULT eq \ |
| 949 | - "th_stack_trace cmd_flags cmd_name cmd_args"} | |
| 949 | + "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"} | |
| 950 | 950 | } else { |
| 951 | - test th1-info-vars-1 {$RESULT eq ""} | |
| 951 | + test th1-info-vars-1 {$RESULT eq "tcl_platform"} | |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | ############################################################################### |
| 955 | 955 | |
| 956 | 956 | fossil test-th-eval "set x 1; info vars" |
| 957 | 957 | |
| 958 | 958 | if {$th1Hooks} { |
| 959 | 959 | test th1-info-vars-2 {$RESULT eq \ |
| 960 | - "x th_stack_trace cmd_flags cmd_name cmd_args"} | |
| 960 | + "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"} | |
| 961 | 961 | } else { |
| 962 | - test th1-info-vars-2 {$RESULT eq "x"} | |
| 962 | + test th1-info-vars-2 {$RESULT eq "x tcl_platform"} | |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | ############################################################################### |
| 966 | 966 | |
| 967 | 967 | fossil test-th-eval "set x 1; unset x; info vars" |
| 968 | 968 | |
| 969 | 969 | if {$th1Hooks} { |
| 970 | 970 | test th1-info-vars-3 {$RESULT eq \ |
| 971 | - "th_stack_trace cmd_flags cmd_name cmd_args"} | |
| 971 | + "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"} | |
| 972 | 972 | } else { |
| 973 | - test th1-info-vars-3 {$RESULT eq ""} | |
| 973 | + test th1-info-vars-3 {$RESULT eq "tcl_platform"} | |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | ############################################################################### |
| 977 | 977 | |
| 978 | 978 | fossil test-th-eval "proc foo {} {set x 1; info vars}; foo" |
| @@ -982,13 +982,13 @@ | ||
| 982 | 982 | |
| 983 | 983 | fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo" |
| 984 | 984 | |
| 985 | 985 | if {$th1Hooks} { |
| 986 | 986 | test th1-info-vars-5 {$RESULT eq \ |
| 987 | - "th_stack_trace y cmd_flags cmd_name cmd_args"} | |
| 987 | + "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"} | |
| 988 | 988 | } else { |
| 989 | - test th1-info-vars-5 {$RESULT eq "y"} | |
| 989 | + test th1-info-vars-5 {$RESULT eq "y tcl_platform"} | |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | ############################################################################### |
| 993 | 993 | |
| 994 | 994 | fossil test-th-eval "lsearch" |
| @@ -1361,5 +1361,15 @@ | ||
| 1361 | 1361 | {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]} |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | test th1-encode64-3 {$RESULT eq \ |
| 1365 | 1365 | "IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="} |
| 1366 | + | |
| 1367 | +############################################################################### | |
| 1368 | + | |
| 1369 | +fossil test-th-eval {set tcl_platform(engine)} | |
| 1370 | +test th1-platform-1 {$RESULT eq "TH1"} | |
| 1371 | + | |
| 1372 | +############################################################################### | |
| 1373 | + | |
| 1374 | +fossil test-th-eval {set tcl_platform(platform)} | |
| 1375 | +test th1-platform-2 {$RESULT eq "windows" || $RESULT eq "unix"} | |
| 1366 | 1376 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -944,35 +944,35 @@ | |
| 944 | |
| 945 | fossil test-th-eval "info vars" |
| 946 | |
| 947 | if {$th1Hooks} { |
| 948 | test th1-info-vars-1 {$RESULT eq \ |
| 949 | "th_stack_trace cmd_flags cmd_name cmd_args"} |
| 950 | } else { |
| 951 | test th1-info-vars-1 {$RESULT eq ""} |
| 952 | } |
| 953 | |
| 954 | ############################################################################### |
| 955 | |
| 956 | fossil test-th-eval "set x 1; info vars" |
| 957 | |
| 958 | if {$th1Hooks} { |
| 959 | test th1-info-vars-2 {$RESULT eq \ |
| 960 | "x th_stack_trace cmd_flags cmd_name cmd_args"} |
| 961 | } else { |
| 962 | test th1-info-vars-2 {$RESULT eq "x"} |
| 963 | } |
| 964 | |
| 965 | ############################################################################### |
| 966 | |
| 967 | fossil test-th-eval "set x 1; unset x; info vars" |
| 968 | |
| 969 | if {$th1Hooks} { |
| 970 | test th1-info-vars-3 {$RESULT eq \ |
| 971 | "th_stack_trace cmd_flags cmd_name cmd_args"} |
| 972 | } else { |
| 973 | test th1-info-vars-3 {$RESULT eq ""} |
| 974 | } |
| 975 | |
| 976 | ############################################################################### |
| 977 | |
| 978 | fossil test-th-eval "proc foo {} {set x 1; info vars}; foo" |
| @@ -982,13 +982,13 @@ | |
| 982 | |
| 983 | fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo" |
| 984 | |
| 985 | if {$th1Hooks} { |
| 986 | test th1-info-vars-5 {$RESULT eq \ |
| 987 | "th_stack_trace y cmd_flags cmd_name cmd_args"} |
| 988 | } else { |
| 989 | test th1-info-vars-5 {$RESULT eq "y"} |
| 990 | } |
| 991 | |
| 992 | ############################################################################### |
| 993 | |
| 994 | fossil test-th-eval "lsearch" |
| @@ -1361,5 +1361,15 @@ | |
| 1361 | {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]} |
| 1362 | } |
| 1363 | |
| 1364 | test th1-encode64-3 {$RESULT eq \ |
| 1365 | "IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="} |
| 1366 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -944,35 +944,35 @@ | |
| 944 | |
| 945 | fossil test-th-eval "info vars" |
| 946 | |
| 947 | if {$th1Hooks} { |
| 948 | test th1-info-vars-1 {$RESULT eq \ |
| 949 | "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"} |
| 950 | } else { |
| 951 | test th1-info-vars-1 {$RESULT eq "tcl_platform"} |
| 952 | } |
| 953 | |
| 954 | ############################################################################### |
| 955 | |
| 956 | fossil test-th-eval "set x 1; info vars" |
| 957 | |
| 958 | if {$th1Hooks} { |
| 959 | test th1-info-vars-2 {$RESULT eq \ |
| 960 | "x th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"} |
| 961 | } else { |
| 962 | test th1-info-vars-2 {$RESULT eq "x tcl_platform"} |
| 963 | } |
| 964 | |
| 965 | ############################################################################### |
| 966 | |
| 967 | fossil test-th-eval "set x 1; unset x; info vars" |
| 968 | |
| 969 | if {$th1Hooks} { |
| 970 | test th1-info-vars-3 {$RESULT eq \ |
| 971 | "th_stack_trace cmd_flags tcl_platform cmd_name cmd_args"} |
| 972 | } else { |
| 973 | test th1-info-vars-3 {$RESULT eq "tcl_platform"} |
| 974 | } |
| 975 | |
| 976 | ############################################################################### |
| 977 | |
| 978 | fossil test-th-eval "proc foo {} {set x 1; info vars}; foo" |
| @@ -982,13 +982,13 @@ | |
| 982 | |
| 983 | fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo" |
| 984 | |
| 985 | if {$th1Hooks} { |
| 986 | test th1-info-vars-5 {$RESULT eq \ |
| 987 | "th_stack_trace y cmd_flags tcl_platform cmd_name cmd_args"} |
| 988 | } else { |
| 989 | test th1-info-vars-5 {$RESULT eq "y tcl_platform"} |
| 990 | } |
| 991 | |
| 992 | ############################################################################### |
| 993 | |
| 994 | fossil test-th-eval "lsearch" |
| @@ -1361,5 +1361,15 @@ | |
| 1361 | {encode64 [artifact trunk ajax/cgi-bin/fossil-json.cgi.example]} |
| 1362 | } |
| 1363 | |
| 1364 | test th1-encode64-3 {$RESULT eq \ |
| 1365 | "IyEvcGF0aC90by9mb3NzaWwvYmluYXJ5CnJlcG9zaXRvcnk6IC9wYXRoL3RvL3JlcG8uZnNsCg=="} |
| 1366 | |
| 1367 | ############################################################################### |
| 1368 | |
| 1369 | fossil test-th-eval {set tcl_platform(engine)} |
| 1370 | test th1-platform-1 {$RESULT eq "TH1"} |
| 1371 | |
| 1372 | ############################################################################### |
| 1373 | |
| 1374 | fossil test-th-eval {set tcl_platform(platform)} |
| 1375 | test th1-platform-2 {$RESULT eq "windows" || $RESULT eq "unix"} |
| 1376 |