Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merged in double-dash-flag2 branch, which adds conventional -- handling to the vast majority of commands (the exception being those few which don't call verify_all_arguments()). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5cca46469f24d7c862f04cff94c9ede5 |
User & Date: | stephan 2019-10-28 19:16:53 |
Context
2019-11-09
| ||
04:27 | Told .editorconfig to use tabs for Makefiles, otherwise it mangles them with the default indention style (spaces). ... (check-in: b86c8b47 user: stephan tags: trunk) | |
2019-10-28
| ||
19:16 | Merged in double-dash-flag2 branch, which adds conventional -- handling to the vast majority of commands (the exception being those few which don't call verify_all_arguments()). ... (check-in: 5cca4646 user: stephan tags: trunk) | |
2019-10-23
| ||
00:46 | Make a hyperlink to the Artifact Receipt log from the "Received From" field of the /info page (visible to administrators only). ... (check-in: a92d5a51 user: drh tags: trunk) | |
2019-10-10
| ||
05:49 | Merged in trunk. ... (Closed-Leaf check-in: 22150aba user: stephan tags: double-dash-flag2) | |
Changes
Changes to src/main.c.
︙ | ︙ | |||
898 899 900 901 902 903 904 | g.argv[i] = g.argv[j]; } g.argc = i; } /* | | > > | > > > > | > > > | > > > | > | 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 | g.argv[i] = g.argv[j]; } g.argc = i; } /* ** Look for a command-line option. If present, remove it from the ** argument list and return a pointer to either the flag's name (if ** hasArg==0), sans leading - or --, or its value (if hasArg==1). ** Return NULL if the flag is not found. ** ** zLong is the "long" form of the flag and zShort is the ** short/abbreviated form (typically a single letter, but it may be ** longer). zLong must not be NULL, but zShort may be. ** ** hasArg==0 means the option is a flag. It is either present or not. ** hasArg==1 means the option has an argument, in which case a pointer ** to the argument's value is returned. For zLong, a flag value (if ** hasValue==1) may either be in the form (--flag=value) or (--flag ** value). For zShort, only the latter form is accepted. ** ** If a standalone argument of "--" is encountered in the argument ** list while searching for the given flag(s), this routine stops ** searching and NULL is returned. */ const char *find_option(const char *zLong, const char *zShort, int hasArg){ int i; int nLong; const char *zReturn = 0; assert( hasArg==0 || hasArg==1 ); nLong = strlen(zLong); for(i=1; i<g.argc; i++){ char *z; if( i+hasArg >= g.argc ) break; z = g.argv[i]; if( z[0]!='-' ) continue; z++; if( z[0]=='-' ){ if( z[1]==0 ){ /* Stop processing at "--" without consuming it. verify_all_options() will consume this flag. */ break; } z++; } if( strncmp(z,zLong,nLong)==0 ){ if( hasArg && z[nLong]=='=' ){ zReturn = &z[nLong+1]; |
︙ | ︙ | |||
953 954 955 956 957 958 959 | int has_option(const char *zOption){ int i; int n = (int)strlen(zOption); for(i=1; i<g.argc; i++){ char *z = g.argv[i]; if( z[0]!='-' ) continue; z++; | | > > > > > > | > > > | 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | int has_option(const char *zOption){ int i; int n = (int)strlen(zOption); for(i=1; i<g.argc; i++){ char *z = g.argv[i]; if( z[0]!='-' ) continue; z++; if( z[0]=='-' ){ if( z[1]==0 ){ /* Stop processing at "--" */ break; } z++; } if( strncmp(z,zOption,n)==0 && (z[n]==0 || z[n]=='=') ) return 1; } return 0; } /* ** Look for multiple occurrences of a command-line option with the ** corresponding argument. ** ** Return a malloc allocated array of pointers to the arguments. ** ** pnUsedArgs is used to store the number of matched arguments. ** ** Caller is responsible for freeing allocated memory by passing the ** head of the array (not each entry) to fossil_free(). (The ** individual entries have the same lifetime as values returned from ** find_option().) */ const char **find_repeatable_option( const char *zLong, const char *zShort, int *pnUsedArgs ){ const char *zOption; |
︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 | return g.zRepositoryOption; } /* ** Verify that there are no unprocessed command-line options. If ** Any remaining command-line argument begins with "-" print ** an error message and quit. */ void verify_all_options(void){ int i; for(i=1; i<g.argc; i++){ | > > > > > > > > > > > > > | > > > > > > | | | > < | 1033 1034 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 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 | return g.zRepositoryOption; } /* ** Verify that there are no unprocessed command-line options. If ** Any remaining command-line argument begins with "-" print ** an error message and quit. ** ** Exception: if "--" is encountered, it is consumed from the argument ** list and this function immediately returns. The effect is to treat ** all arguments after "--" as non-flags (conventionally used to ** enable passing-in of filenames which start with a dash). ** ** This function must normally only be called one time per app ** invokation. The exception is commands which process their ** arguments, call this to confirm that there are no extraneous flags, ** then modify the arguments list for forwarding to another ** (sub)command (which itself will call this to confirm its own ** arguments). */ void verify_all_options(void){ int i; for(i=1; i<g.argc; i++){ const char * arg = g.argv[i]; if( arg[0]=='-' ){ if( arg[1]=='-' && arg[2]==0 ){ /* Remove "--" from the list and treat all following ** arguments as non-flags. */ remove_from_argv(i, 1); break; }else if( arg[1]!=0 ){ fossil_fatal( "unrecognized command-line option or missing argument: %s", arg); } } } } /* ** This function returns a human readable version string. */ const char *get_version(){ static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " " MANIFEST_DATE " UTC"; |
︙ | ︙ |
Changes to src/unversioned.c.
︙ | ︙ | |||
289 290 291 292 293 294 295 | const char *zError = 0; const char *zIn; const char *zAs; Blob file; int i; zAs = find_option("as",0,1); | < > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | const char *zError = 0; const char *zIn; const char *zAs; Blob file; int i; zAs = find_option("as",0,1); verify_all_options(); if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE"); db_begin_transaction(); content_rcvid_init("#!fossil unversioned add"); for(i=3; i<g.argc; i++){ zIn = zAs ? zAs : g.argv[i]; if( zIn[0]==0 ){ zError = "be empty string"; }else if( zIn[0]=='/' ){ |
︙ | ︙ |