Fossil

Check-in [a9b9b5bc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | double-dash-flag
Files: files | file ages | folders
SHA3-256: a9b9b5bceea2f4d24aa9ac81d298d240ab17734b4ac66870b374f3d08a697b66
User & Date: stephan 2019-09-27 09:55:12
Wiki:double-dash-flag
Context
2019-09-27
11:47
Added -- support to: (branch new) (uv add/cat/edit/export/rm) check-in: 78a30d8d user: stephan tags: double-dash-flag
09:55
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. check-in: a9b9b5bc user: stephan tags: double-dash-flag
08:48
Initial work on unified "--" flag support, as requested in https://fossil-scm.org/forum/forumpost/64acc6b653. There's still lots to do here. check-in: d8ebbd76 user: stephan tags: double-dash-flag
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/main.c.

1035
1036
1037
1038
1039
1040
1041
1042

1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
....
1071
1072
1073
1074
1075
1076
1077







1078
1079








1080
1081
1082
1083
1084
1085
1086
/*
** Verify that there are no unprocessed command-line options.  If
** Any remaining command-line argument begins with "-" print
** an error message and quit.
**
** If fAllowDoubleDash is true then if the flag "--" is found, it is
** removed from the list and arguments after that flag are not
** inspected by this function (they are assumed to be filenames, even

** if they syntactically look like flags). If fAllowDoubleDash is
** false then the "--" flag will trigger a fatal error exactly as if
** an unprocessed flag were encountered.
**
** Sidebar: the question of whether fAllowDoubleDash should be true or
** false would seem to boil down to: does the calling routine
** expect/allow arbitrary file/page/branch/whatever name arguments
** after its required arguments?
**
** Once the "--" support is completed, this function will be renamed
** (back) to verify_all_options().
*/
void verify_all_options_porting_crutch(int fAllowDoubleDash){
  int i;
  for(i=1; i<g.argc; i++){
    const char * arg = g.argv[i];
    if( arg[0]=='-' ){
      if( arg[1]=='-' && arg[2]==0 ){
        if(fAllowDoubleDash){
          /* Remove "--" from the list and assume any following
................................................................................
          "unrecognized command-line option, or missing argument: %s",
          arg);
      }
    }
  }
}








void verify_all_options(void){
  verify_all_options_porting_crutch(0);








}

/*
** This function returns a human readable version string.
*/
const char *get_version(){
  static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "







|
>
|
|
|





<
<
<

|







 







>
>
>
>
>
>
>

|
>
>
>
>
>
>
>
>







1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051



1052
1053
1054
1055
1056
1057
1058
1059
1060
....
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
/*
** Verify that there are no unprocessed command-line options.  If
** Any remaining command-line argument begins with "-" print
** an error message and quit.
**
** If fAllowDoubleDash is true then if the flag "--" is found, it is
** removed from the list and arguments after that flag are not
** inspected by this function (they are assumed to be
** file/wiki/branch/etc. names, even if they syntactically look like
** flags). If fAllowDoubleDash is false then the "--" flag will
** trigger a fatal error exactly as if an unprocessed flag were
** encountered.
**
** Sidebar: the question of whether fAllowDoubleDash should be true or
** false would seem to boil down to: does the calling routine
** expect/allow arbitrary file/page/branch/whatever name arguments
** after its required arguments?



*/
static void verify_all_options_impl(int fAllowDoubleDash){
  int i;
  for(i=1; i<g.argc; i++){
    const char * arg = g.argv[i];
    if( arg[0]=='-' ){
      if( arg[1]=='-' && arg[2]==0 ){
        if(fAllowDoubleDash){
          /* Remove "--" from the list and assume any following
................................................................................
          "unrecognized command-line option, or missing argument: %s",
          arg);
      }
    }
  }
}

/*
** Must be called by all commands which process CLI flags, after
** consuming those flags (via find_option() and friends), to confirm
** that no unconsumed flags are still in the arguments list.  If the
** command should/can honor the "--" flag, call verify_all_options2()
** instead.
*/
void verify_all_options(void){
  verify_all_options_impl(0);
}

/*
** Identical to verify_all_options() except that it honors the "--"
** flag.
*/
void verify_all_options2(void){
  verify_all_options_impl(1);
}

/*
** This function returns a human readable version string.
*/
const char *get_version(){
  static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "