Fossil SCM
Simplified the verify_all_options() porting strategy, such that -- is disallowed by default and routines which should/can support it need to call verify_all_options2() instead of us changing the signature of verify_all_options(). This will result in far fewer changes than the previous approach.
Commit
a9b9b5bceea2f4d24aa9ac81d298d240ab17734b4ac66870b374f3d08a697b66
Parent
d8ebbd76cc9ae94…
1 file changed
+22
-9
+22
-9
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -1037,24 +1037,22 @@ | ||
| 1037 | 1037 | ** Any remaining command-line argument begins with "-" print |
| 1038 | 1038 | ** an error message and quit. |
| 1039 | 1039 | ** |
| 1040 | 1040 | ** If fAllowDoubleDash is true then if the flag "--" is found, it is |
| 1041 | 1041 | ** removed from the list and arguments after that flag are not |
| 1042 | -** inspected by this function (they are assumed to be filenames, even | |
| 1043 | -** if they syntactically look like flags). If fAllowDoubleDash is | |
| 1044 | -** false then the "--" flag will trigger a fatal error exactly as if | |
| 1045 | -** an unprocessed flag were encountered. | |
| 1042 | +** inspected by this function (they are assumed to be | |
| 1043 | +** file/wiki/branch/etc. names, even if they syntactically look like | |
| 1044 | +** flags). If fAllowDoubleDash is false then the "--" flag will | |
| 1045 | +** trigger a fatal error exactly as if an unprocessed flag were | |
| 1046 | +** encountered. | |
| 1046 | 1047 | ** |
| 1047 | 1048 | ** Sidebar: the question of whether fAllowDoubleDash should be true or |
| 1048 | 1049 | ** false would seem to boil down to: does the calling routine |
| 1049 | 1050 | ** expect/allow arbitrary file/page/branch/whatever name arguments |
| 1050 | 1051 | ** after its required arguments? |
| 1051 | -** | |
| 1052 | -** Once the "--" support is completed, this function will be renamed | |
| 1053 | -** (back) to verify_all_options(). | |
| 1054 | 1052 | */ |
| 1055 | -void verify_all_options_porting_crutch(int fAllowDoubleDash){ | |
| 1053 | +static void verify_all_options_impl(int fAllowDoubleDash){ | |
| 1056 | 1054 | int i; |
| 1057 | 1055 | for(i=1; i<g.argc; i++){ |
| 1058 | 1056 | const char * arg = g.argv[i]; |
| 1059 | 1057 | if( arg[0]=='-' ){ |
| 1060 | 1058 | if( arg[1]=='-' && arg[2]==0 ){ |
| @@ -1073,12 +1071,27 @@ | ||
| 1073 | 1071 | } |
| 1074 | 1072 | } |
| 1075 | 1073 | } |
| 1076 | 1074 | } |
| 1077 | 1075 | |
| 1076 | +/* | |
| 1077 | +** Must be called by all commands which process CLI flags, after | |
| 1078 | +** consuming those flags (via find_option() and friends), to confirm | |
| 1079 | +** that no unconsumed flags are still in the arguments list. If the | |
| 1080 | +** command should/can honor the "--" flag, call verify_all_options2() | |
| 1081 | +** instead. | |
| 1082 | +*/ | |
| 1078 | 1083 | void verify_all_options(void){ |
| 1079 | - verify_all_options_porting_crutch(0); | |
| 1084 | + verify_all_options_impl(0); | |
| 1085 | +} | |
| 1086 | + | |
| 1087 | +/* | |
| 1088 | +** Identical to verify_all_options() except that it honors the "--" | |
| 1089 | +** flag. | |
| 1090 | +*/ | |
| 1091 | +void verify_all_options2(void){ | |
| 1092 | + verify_all_options_impl(1); | |
| 1080 | 1093 | } |
| 1081 | 1094 | |
| 1082 | 1095 | /* |
| 1083 | 1096 | ** This function returns a human readable version string. |
| 1084 | 1097 | */ |
| 1085 | 1098 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1037,24 +1037,22 @@ | |
| 1037 | ** Any remaining command-line argument begins with "-" print |
| 1038 | ** an error message and quit. |
| 1039 | ** |
| 1040 | ** If fAllowDoubleDash is true then if the flag "--" is found, it is |
| 1041 | ** removed from the list and arguments after that flag are not |
| 1042 | ** inspected by this function (they are assumed to be filenames, even |
| 1043 | ** if they syntactically look like flags). If fAllowDoubleDash is |
| 1044 | ** false then the "--" flag will trigger a fatal error exactly as if |
| 1045 | ** an unprocessed flag were encountered. |
| 1046 | ** |
| 1047 | ** Sidebar: the question of whether fAllowDoubleDash should be true or |
| 1048 | ** false would seem to boil down to: does the calling routine |
| 1049 | ** expect/allow arbitrary file/page/branch/whatever name arguments |
| 1050 | ** after its required arguments? |
| 1051 | ** |
| 1052 | ** Once the "--" support is completed, this function will be renamed |
| 1053 | ** (back) to verify_all_options(). |
| 1054 | */ |
| 1055 | void verify_all_options_porting_crutch(int fAllowDoubleDash){ |
| 1056 | int i; |
| 1057 | for(i=1; i<g.argc; i++){ |
| 1058 | const char * arg = g.argv[i]; |
| 1059 | if( arg[0]=='-' ){ |
| 1060 | if( arg[1]=='-' && arg[2]==0 ){ |
| @@ -1073,12 +1071,27 @@ | |
| 1073 | } |
| 1074 | } |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | void verify_all_options(void){ |
| 1079 | verify_all_options_porting_crutch(0); |
| 1080 | } |
| 1081 | |
| 1082 | /* |
| 1083 | ** This function returns a human readable version string. |
| 1084 | */ |
| 1085 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1037,24 +1037,22 @@ | |
| 1037 | ** Any remaining command-line argument begins with "-" print |
| 1038 | ** an error message and quit. |
| 1039 | ** |
| 1040 | ** If fAllowDoubleDash is true then if the flag "--" is found, it is |
| 1041 | ** removed from the list and arguments after that flag are not |
| 1042 | ** inspected by this function (they are assumed to be |
| 1043 | ** file/wiki/branch/etc. names, even if they syntactically look like |
| 1044 | ** flags). If fAllowDoubleDash is false then the "--" flag will |
| 1045 | ** trigger a fatal error exactly as if an unprocessed flag were |
| 1046 | ** encountered. |
| 1047 | ** |
| 1048 | ** Sidebar: the question of whether fAllowDoubleDash should be true or |
| 1049 | ** false would seem to boil down to: does the calling routine |
| 1050 | ** expect/allow arbitrary file/page/branch/whatever name arguments |
| 1051 | ** after its required arguments? |
| 1052 | */ |
| 1053 | static void verify_all_options_impl(int fAllowDoubleDash){ |
| 1054 | int i; |
| 1055 | for(i=1; i<g.argc; i++){ |
| 1056 | const char * arg = g.argv[i]; |
| 1057 | if( arg[0]=='-' ){ |
| 1058 | if( arg[1]=='-' && arg[2]==0 ){ |
| @@ -1073,12 +1071,27 @@ | |
| 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | /* |
| 1077 | ** Must be called by all commands which process CLI flags, after |
| 1078 | ** consuming those flags (via find_option() and friends), to confirm |
| 1079 | ** that no unconsumed flags are still in the arguments list. If the |
| 1080 | ** command should/can honor the "--" flag, call verify_all_options2() |
| 1081 | ** instead. |
| 1082 | */ |
| 1083 | void verify_all_options(void){ |
| 1084 | verify_all_options_impl(0); |
| 1085 | } |
| 1086 | |
| 1087 | /* |
| 1088 | ** Identical to verify_all_options() except that it honors the "--" |
| 1089 | ** flag. |
| 1090 | */ |
| 1091 | void verify_all_options2(void){ |
| 1092 | verify_all_options_impl(1); |
| 1093 | } |
| 1094 | |
| 1095 | /* |
| 1096 | ** This function returns a human readable version string. |
| 1097 | */ |
| 1098 |