Fossil SCM
Put Th_SubCommand constant tables in constant memory.
Commit
dce90fe35eee6c2a0022f298e4a2bdea099b2c8f
Parent
b4d538f8c6149de…
2 files changed
+2
-2
+3
-3
M
src/th.h
+2
-2
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -182,7 +182,7 @@ | ||
| 182 | 182 | /* |
| 183 | 183 | ** Useful functions from th_lang.c. |
| 184 | 184 | */ |
| 185 | 185 | int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg); |
| 186 | 186 | |
| 187 | -typedef struct Th_SubCommand {char *zName; Th_CommandProc xProc;} Th_SubCommand; | |
| 188 | -int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,Th_SubCommand*); | |
| 187 | +typedef struct Th_SubCommand {const char *zName; Th_CommandProc xProc;} Th_SubCommand; | |
| 188 | +int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,const Th_SubCommand*); | |
| 189 | 189 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -182,7 +182,7 @@ | |
| 182 | /* |
| 183 | ** Useful functions from th_lang.c. |
| 184 | */ |
| 185 | int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg); |
| 186 | |
| 187 | typedef struct Th_SubCommand {char *zName; Th_CommandProc xProc;} Th_SubCommand; |
| 188 | int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,Th_SubCommand*); |
| 189 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -182,7 +182,7 @@ | |
| 182 | /* |
| 183 | ** Useful functions from th_lang.c. |
| 184 | */ |
| 185 | int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg); |
| 186 | |
| 187 | typedef struct Th_SubCommand {const char *zName; Th_CommandProc xProc;} Th_SubCommand; |
| 188 | int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,const Th_SubCommand*); |
| 189 |
+3
-3
| --- src/th_lang.c | ||
| +++ src/th_lang.c | ||
| @@ -887,11 +887,11 @@ | ||
| 887 | 887 | Th_Interp *interp, |
| 888 | 888 | void *ctx, |
| 889 | 889 | int argc, |
| 890 | 890 | const char **argv, |
| 891 | 891 | int *argl, |
| 892 | - Th_SubCommand *aSub | |
| 892 | + const Th_SubCommand *aSub | |
| 893 | 893 | ){ |
| 894 | 894 | if( argc>1 ){ |
| 895 | 895 | int i; |
| 896 | 896 | for(i=0; aSub[i].zName; i++){ |
| 897 | 897 | char *zName = (char *)aSub[i].zName; |
| @@ -924,11 +924,11 @@ | ||
| 924 | 924 | void *ctx, |
| 925 | 925 | int argc, |
| 926 | 926 | const char **argv, |
| 927 | 927 | int *argl |
| 928 | 928 | ){ |
| 929 | - Th_SubCommand aSub[] = { | |
| 929 | + static const Th_SubCommand aSub[] = { | |
| 930 | 930 | { "compare", string_compare_command }, |
| 931 | 931 | { "first", string_first_command }, |
| 932 | 932 | { "is", string_is_command }, |
| 933 | 933 | { "last", string_last_command }, |
| 934 | 934 | { "length", string_length_command }, |
| @@ -952,11 +952,11 @@ | ||
| 952 | 952 | void *ctx, |
| 953 | 953 | int argc, |
| 954 | 954 | const char **argv, |
| 955 | 955 | int *argl |
| 956 | 956 | ){ |
| 957 | - Th_SubCommand aSub[] = { | |
| 957 | + static const Th_SubCommand aSub[] = { | |
| 958 | 958 | { "exists", info_exists_command }, |
| 959 | 959 | { 0, 0 } |
| 960 | 960 | }; |
| 961 | 961 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 962 | 962 | } |
| 963 | 963 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -887,11 +887,11 @@ | |
| 887 | Th_Interp *interp, |
| 888 | void *ctx, |
| 889 | int argc, |
| 890 | const char **argv, |
| 891 | int *argl, |
| 892 | Th_SubCommand *aSub |
| 893 | ){ |
| 894 | if( argc>1 ){ |
| 895 | int i; |
| 896 | for(i=0; aSub[i].zName; i++){ |
| 897 | char *zName = (char *)aSub[i].zName; |
| @@ -924,11 +924,11 @@ | |
| 924 | void *ctx, |
| 925 | int argc, |
| 926 | const char **argv, |
| 927 | int *argl |
| 928 | ){ |
| 929 | Th_SubCommand aSub[] = { |
| 930 | { "compare", string_compare_command }, |
| 931 | { "first", string_first_command }, |
| 932 | { "is", string_is_command }, |
| 933 | { "last", string_last_command }, |
| 934 | { "length", string_length_command }, |
| @@ -952,11 +952,11 @@ | |
| 952 | void *ctx, |
| 953 | int argc, |
| 954 | const char **argv, |
| 955 | int *argl |
| 956 | ){ |
| 957 | Th_SubCommand aSub[] = { |
| 958 | { "exists", info_exists_command }, |
| 959 | { 0, 0 } |
| 960 | }; |
| 961 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 962 | } |
| 963 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -887,11 +887,11 @@ | |
| 887 | Th_Interp *interp, |
| 888 | void *ctx, |
| 889 | int argc, |
| 890 | const char **argv, |
| 891 | int *argl, |
| 892 | const Th_SubCommand *aSub |
| 893 | ){ |
| 894 | if( argc>1 ){ |
| 895 | int i; |
| 896 | for(i=0; aSub[i].zName; i++){ |
| 897 | char *zName = (char *)aSub[i].zName; |
| @@ -924,11 +924,11 @@ | |
| 924 | void *ctx, |
| 925 | int argc, |
| 926 | const char **argv, |
| 927 | int *argl |
| 928 | ){ |
| 929 | static const Th_SubCommand aSub[] = { |
| 930 | { "compare", string_compare_command }, |
| 931 | { "first", string_first_command }, |
| 932 | { "is", string_is_command }, |
| 933 | { "last", string_last_command }, |
| 934 | { "length", string_length_command }, |
| @@ -952,11 +952,11 @@ | |
| 952 | void *ctx, |
| 953 | int argc, |
| 954 | const char **argv, |
| 955 | int *argl |
| 956 | ){ |
| 957 | static const Th_SubCommand aSub[] = { |
| 958 | { "exists", info_exists_command }, |
| 959 | { 0, 0 } |
| 960 | }; |
| 961 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 962 | } |
| 963 |