Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | merge from trunk |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | wolfgangHelpCmd |
| Files: | files | file ages | folders |
| SHA1: |
c1271793624224d2bc7df2a7f8f98b9f |
| User & Date: | wolfgang 2010-10-15 16:11:51.000 |
Context
|
2010-10-16
| ||
| 17:33 | merge from trunk ... (check-in: 586b0eb144 user: wolfgang tags: wolfgangHelpCmd) | |
|
2010-10-15
| ||
| 16:11 | merge from trunk ... (check-in: c127179362 user: wolfgang tags: wolfgangHelpCmd) | |
| 13:55 | On commit, check the repository for changes before starting the write transaction, so that a diff can be run during the check-in comment editing. Ticket [014ac374123d9a6ab6894]. ... (check-in: 59f685856b user: drh tags: trunk) | |
|
2010-10-14
| ||
| 18:41 | rename import to addremove ... (check-in: 7e65c703c0 user: wolfgang tags: wolfgangHelpCmd) | |
Changes
Changes to Makefile.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 | #### Extra arguments for linking the finished binary. Fossil needs # to link against the Z-Lib compression library. There are no # other dependencies. We sometimes add the -static option here # so that we can build a static executable that will run in a # chroot jail. # LIB = -lz $(LDFLAGS) | < | < | < > | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #### Extra arguments for linking the finished binary. Fossil needs # to link against the Z-Lib compression library. There are no # other dependencies. We sometimes add the -static option here # so that we can build a static executable that will run in a # chroot jail. # LIB = -lz $(LDFLAGS) HOST_OS!= uname -s LIB.SunOS= -lsocket -lnsl LIB += $(LIB.$(HOST_OS)) # If using HTTPS: LIB += -lcrypto -lssl #### Tcl shell for use in running the fossil testsuite. # TCLSH = tclsh |
| ︙ | ︙ |
Changes to src/allrepo.c.
| ︙ | ︙ | |||
32 33 34 35 36 37 38 |
** string is returned even if no quoting is needed.
*/
static char *quoteFilename(const char *zFilename){
int i, c;
int needQuote = 0;
for(i=0; (c = zFilename[i])!=0; i++){
if( c=='"' ) return 0;
| | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
** string is returned even if no quoting is needed.
*/
static char *quoteFilename(const char *zFilename){
int i, c;
int needQuote = 0;
for(i=0; (c = zFilename[i])!=0; i++){
if( c=='"' ) return 0;
if( fossil_isspace(c) ) needQuote = 1;
if( c=='\\' && zFilename[i+1]==0 ) return 0;
if( c=='$' ) return 0;
}
if( needQuote ){
return mprintf("\"%s\"", zFilename);
}else{
return mprintf("%s", zFilename);
|
| ︙ | ︙ |
Changes to src/attach.c.
| ︙ | ︙ | |||
80 81 82 83 84 85 86 |
zUrlTail = mprintf("tkt=%s&file=%t", zTarget, zFilename);
}else{
zUrlTail = mprintf("page=%t&file=%t", zTarget, zFilename);
}
@
@ <p><a href="/attachview?%s(zUrlTail)">%h(zFilename)</a>
@ [<a href="/attachdownload/%t(zFilename)?%s(zUrlTail)">download</a>]<br />
| | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
zUrlTail = mprintf("tkt=%s&file=%t", zTarget, zFilename);
}else{
zUrlTail = mprintf("page=%t&file=%t", zTarget, zFilename);
}
@
@ <p><a href="/attachview?%s(zUrlTail)">%h(zFilename)</a>
@ [<a href="/attachdownload/%t(zFilename)?%s(zUrlTail)">download</a>]<br />
if( zComment ) while( fossil_isspace(zComment[0]) ) zComment++;
if( zComment && zComment[0] ){
@ %w(zComment)<br />
}
if( zPage==0 && zTkt==0 ){
if( zSrc==0 || zSrc[0]==0 ){
zSrc = "Deleted from";
}else {
|
| ︙ | ︙ | |||
249 250 251 252 253 254 255 |
for(i=n=0; zName[i]; i++){
if( zName[i]=='/' || zName[i]=='\\' ) n = i;
}
zName += n;
if( zName[0]==0 ) zName = "unknown";
blob_appendf(&manifest, "A %F %F %s\n", zName, zTarget, zUUID);
zComment = PD("comment", "");
| | | | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
for(i=n=0; zName[i]; i++){
if( zName[i]=='/' || zName[i]=='\\' ) n = i;
}
zName += n;
if( zName[0]==0 ) zName = "unknown";
blob_appendf(&manifest, "A %F %F %s\n", zName, zTarget, zUUID);
zComment = PD("comment", "");
while( fossil_isspace(zComment[0]) ) zComment++;
n = strlen(zComment);
while( n>0 && fossil_isspace(zComment[n-1]) ){ n--; }
if( n>0 ){
blob_appendf(&manifest, "C %F\n", zComment);
}
zDate = db_text(0, "SELECT datetime('now')");
zDate[10] = 'T';
blob_appendf(&manifest, "D %s\n", zDate);
blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody");
|
| ︙ | ︙ |
Changes to src/blob.c.
| ︙ | ︙ | |||
70 71 72 73 74 75 76 | #define blob_is_reset(x) #endif /* ** We find that the built-in isspace() function does not work for ** some international character sets. So here is a substitute. */ | | > > > > > > > > > > > > > > > > > | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
#define blob_is_reset(x)
#endif
/*
** We find that the built-in isspace() function does not work for
** some international character sets. So here is a substitute.
*/
int fossil_isspace(char c){
return c==' ' || (c<='\r' && c>='\t');
}
/*
** Other replacements for ctype.h functions.
*/
int fossil_islower(char c){ return c>='a' && c<='z'; }
int fossil_isupper(char c){ return c>='A' && c<='Z'; }
int fossil_isdigit(char c){ return c>='0' && c<='9'; }
int fossil_tolower(char c){
return fossil_isupper(c) ? c - 'A' + 'a' : c;
}
int fossil_isalpha(char c){
return (c>='a' && c<='z') || (c>='A' && c<='Z');
}
int fossil_isalnum(char c){
return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9');
}
/*
** COMMAND: test-isspace
*/
void isspace_cmd(void){
int i;
for(i=0; i<=255; i++){
if( i==' ' || i=='\n' || i=='\t' || i=='\v'
|| i=='\f' || i=='\r' ){
assert( fossil_isspace((char)i) );
}else{
assert( !fossil_isspace((char)i) );
}
}
printf("All 256 characters OK\n");
}
/*
** This routine is called if a blob operation fails because we
|
| ︙ | ︙ | |||
427 428 429 430 431 432 433 |
**
** All this does is reduce the length counter. This routine does
** not insert a new zero terminator.
*/
int blob_trim(Blob *p){
char *z = p->aData;
int n = p->nUsed;
| | | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
**
** All this does is reduce the length counter. This routine does
** not insert a new zero terminator.
*/
int blob_trim(Blob *p){
char *z = p->aData;
int n = p->nUsed;
while( n>0 && fossil_isspace(z[n-1]) ){ n--; }
p->nUsed = n;
return n;
}
/*
** Extract a single token from pFrom and use it to initialize pTo.
** Return the number of bytes in the token. If no token is found,
|
| ︙ | ︙ | |||
450 451 452 453 454 455 456 |
** pTo will be an ephermeral blob. If pFrom changes, it might alter
** pTo as well.
*/
int blob_token(Blob *pFrom, Blob *pTo){
char *aData = pFrom->aData;
int n = pFrom->nUsed;
int i = pFrom->iCursor;
| | | | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
** pTo will be an ephermeral blob. If pFrom changes, it might alter
** pTo as well.
*/
int blob_token(Blob *pFrom, Blob *pTo){
char *aData = pFrom->aData;
int n = pFrom->nUsed;
int i = pFrom->iCursor;
while( i<n && fossil_isspace(aData[i]) ){ i++; }
pFrom->iCursor = i;
while( i<n && !fossil_isspace(aData[i]) ){ i++; }
blob_extract(pFrom, i-pFrom->iCursor, pTo);
while( i<n && fossil_isspace(aData[i]) ){ i++; }
pFrom->iCursor = i;
return pTo->nUsed;
}
/*
** Extract everything from the current cursor to the end of the blob
** into a new blob. The new blob is an ephemerial reference to the
|
| ︙ | ︙ | |||
521 522 523 524 525 526 527 |
** the integer value in *pValue.
*/
int blob_is_int(Blob *pBlob, int *pValue){
const char *z = blob_buffer(pBlob);
int i, n, c, v;
n = blob_size(pBlob);
v = 0;
| | | 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
** the integer value in *pValue.
*/
int blob_is_int(Blob *pBlob, int *pValue){
const char *z = blob_buffer(pBlob);
int i, n, c, v;
n = blob_size(pBlob);
v = 0;
for(i=0; i<n && (c = z[i])!=0 && c>='0' && c<='9'; i++){
v = v*10 + c - '0';
}
if( i==n ){
*pValue = v;
return 1;
}else{
return 0;
|
| ︙ | ︙ | |||
610 611 612 613 614 615 616 |
if( zFilename==0 || zFilename[0]==0
|| (zFilename[0]=='-' && zFilename[1]==0) ){
return blob_read_from_channel(pBlob, stdin, -1);
}
size = file_size(zFilename);
blob_zero(pBlob);
if( size<0 ){
| | | 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
if( zFilename==0 || zFilename[0]==0
|| (zFilename[0]=='-' && zFilename[1]==0) ){
return blob_read_from_channel(pBlob, stdin, -1);
}
size = file_size(zFilename);
blob_zero(pBlob);
if( size<0 ){
fossil_fatal("no such file: %s", zFilename);
}
if( size==0 ){
return 0;
}
blob_resize(pBlob, size);
in = fopen(zFilename, "rb");
if( in==0 ){
|
| ︙ | ︙ | |||
904 905 906 907 908 909 910 |
*/
void shell_escape(Blob *pBlob, const char *zIn){
int n = blob_size(pBlob);
int k = strlen(zIn);
int i, c;
char *z;
for(i=0; (c = zIn[i])!=0; i++){
| | | 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
*/
void shell_escape(Blob *pBlob, const char *zIn){
int n = blob_size(pBlob);
int k = strlen(zIn);
int i, c;
char *z;
for(i=0; (c = zIn[i])!=0; i++){
if( fossil_isspace(c) || c=='"' || (c=='\\' && zIn[i+1]!=0) ){
blob_appendf(pBlob, "\"%s\"", zIn);
z = blob_buffer(pBlob);
for(i=n+1; i<=n+k; i++){
if( z[i]=='"' ) z[i] = '_';
}
return;
}
}
blob_append(pBlob, zIn, -1);
}
|
Changes to src/cgi.c.
| ︙ | ︙ | |||
461 462 463 464 465 466 467 |
** should not be deallocated or changed again after this routine
** returns or it will corrupt the parameter table.
*/
static void add_param_list(char *z, int terminator){
while( *z ){
char *zName;
char *zValue;
| | | | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
** should not be deallocated or changed again after this routine
** returns or it will corrupt the parameter table.
*/
static void add_param_list(char *z, int terminator){
while( *z ){
char *zName;
char *zValue;
while( fossil_isspace(*z) ){ z++; }
zName = z;
while( *z && *z!='=' && *z!=terminator ){ z++; }
if( *z=='=' ){
*z = 0;
z++;
zValue = z;
while( *z && *z!=terminator ){ z++; }
if( *z ){
*z = 0;
z++;
}
dehttpize(zValue);
}else{
if( *z ){ *z++ = 0; }
zValue = "";
}
if( fossil_islower(zName[0]) ){
cgi_set_parameter_nocopy(zName, zValue);
}
}
}
/*
** *pz is a string that consists of multiple lines of text. This
|
| ︙ | ︙ | |||
573 574 575 576 577 578 579 |
** '\000' characters are inserted in z[] at the end of each token.
** This routine returns the total number of tokens on the line, 6
** in the example above.
*/
static int tokenize_line(char *z, int mxArg, char **azArg){
int i = 0;
while( *z ){
| | | | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
** '\000' characters are inserted in z[] at the end of each token.
** This routine returns the total number of tokens on the line, 6
** in the example above.
*/
static int tokenize_line(char *z, int mxArg, char **azArg){
int i = 0;
while( *z ){
while( fossil_isspace(*z) || *z==';' ){ z++; }
if( *z=='"' && z[1] ){
*z = 0;
z++;
if( i<mxArg-1 ){ azArg[i++] = z; }
while( *z && *z!='"' ){ z++; }
if( *z==0 ) break;
*z = 0;
z++;
}else{
if( i<mxArg-1 ){ azArg[i++] = z; }
while( *z && !fossil_isspace(*z) && *z!=';' && *z!='"' ){ z++; }
if( *z && *z!='"' ){
*z = 0;
z++;
}
}
}
azArg[i] = 0;
|
| ︙ | ︙ | |||
619 620 621 622 623 624 625 |
zBoundry = get_line_from_string(&z, &len);
if( zBoundry==0 ) return;
while( (zLine = get_line_from_string(&z, &len))!=0 ){
if( zLine[0]==0 ){
int nContent = 0;
zValue = get_bounded_content(&z, &len, zBoundry, &nContent);
| | | | | | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
zBoundry = get_line_from_string(&z, &len);
if( zBoundry==0 ) return;
while( (zLine = get_line_from_string(&z, &len))!=0 ){
if( zLine[0]==0 ){
int nContent = 0;
zValue = get_bounded_content(&z, &len, zBoundry, &nContent);
if( zName && zValue && fossil_islower(zName[0]) ){
cgi_set_parameter_nocopy(zName, zValue);
if( showBytes ){
cgi_set_parameter_nocopy(mprintf("%s:bytes", zName),
mprintf("%d",nContent));
}
}
zName = 0;
showBytes = 0;
}else{
nArg = tokenize_line(zLine, sizeof(azArg)/sizeof(azArg[0]), azArg);
for(i=0; i<nArg; i++){
int c = fossil_tolower(azArg[i][0]);
int n = strlen(azArg[i]);
if( c=='c' && sqlite3_strnicmp(azArg[i],"content-disposition:",n)==0 ){
i++;
}else if( c=='n' && sqlite3_strnicmp(azArg[i],"name=",n)==0 ){
zName = azArg[++i];
}else if( c=='f' && sqlite3_strnicmp(azArg[i],"filename=",n)==0 ){
char *z = azArg[++i];
if( zName && z && fossil_islower(zName[0]) ){
cgi_set_parameter_nocopy(mprintf("%s:filename",zName), z);
}
showBytes = 1;
}else if( c=='c' && sqlite3_strnicmp(azArg[i],"content-type:",n)==0 ){
char *z = azArg[++i];
if( zName && z && fossil_islower(zName[0]) ){
cgi_set_parameter_nocopy(mprintf("%s:mimetype",zName), z);
}
}
}
}
}
}
|
| ︙ | ︙ | |||
771 772 773 774 775 776 777 |
}
}
/* If no match is found and the name begins with an upper-case
** letter, then check to see if there is an environment variable
** with the given name.
*/
| | | 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 |
}
}
/* If no match is found and the name begins with an upper-case
** letter, then check to see if there is an environment variable
** with the given name.
*/
if( fossil_isupper(zName[0]) ){
const char *zValue = getenv(zName);
if( zValue ){
cgi_set_parameter_nocopy(zName, zValue);
CGIDEBUG(("env-match [%s] = [%s]\n", zName, zValue));
return zValue;
}
}
|
| ︙ | ︙ | |||
914 915 916 917 918 919 920 |
*/
static char *extract_token(char *zInput, char **zLeftOver){
char *zResult = 0;
if( zInput==0 ){
if( zLeftOver ) *zLeftOver = 0;
return 0;
}
| | | | | | 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 947 948 949 950 951 952 953 |
*/
static char *extract_token(char *zInput, char **zLeftOver){
char *zResult = 0;
if( zInput==0 ){
if( zLeftOver ) *zLeftOver = 0;
return 0;
}
while( fossil_isspace(*zInput) ){ zInput++; }
zResult = zInput;
while( *zInput && !fossil_isspace(*zInput) ){ zInput++; }
if( *zInput ){
*zInput = 0;
zInput++;
while( fossil_isspace(*zInput) ){ zInput++; }
}
if( zLeftOver ){ *zLeftOver = zInput; }
return zResult;
}
/*
** This routine handles a single HTTP request which is coming in on
** standard input and which replies on standard output.
**
** The HTTP request is read from standard input and is used to initialize
** environment variables as per CGI. The cgi_init() routine to complete
** the setup. Once all the setup is finished, this procedure returns
** and subsequent code handles the actual generation of the webpage.
*/
void cgi_handle_http_request(const char *zIpAddr){
char *z, *zToken;
int i;
struct sockaddr_in remoteName;
socklen_t size = sizeof(struct sockaddr_in);
char zLine[2000]; /* A single line of input. */
g.fullHttpReply = 1;
if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
malformed_request();
}
zToken = extract_token(zLine, &z);
|
| ︙ | ︙ | |||
967 968 969 970 971 972 973 |
cgi_setenv("REQUEST_URI", zToken);
for(i=0; zToken[i] && zToken[i]!='?'; i++){}
if( zToken[i] ) zToken[i++] = 0;
cgi_setenv("PATH_INFO", zToken);
cgi_setenv("QUERY_STRING", &zToken[i]);
if( zIpAddr==0 &&
getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName,
| | | | | > > | 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 1004 |
cgi_setenv("REQUEST_URI", zToken);
for(i=0; zToken[i] && zToken[i]!='?'; i++){}
if( zToken[i] ) zToken[i++] = 0;
cgi_setenv("PATH_INFO", zToken);
cgi_setenv("QUERY_STRING", &zToken[i]);
if( zIpAddr==0 &&
getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName,
&size)>=0
){
zIpAddr = inet_ntoa(remoteName.sin_addr);
}
if( zIpAddr ){
cgi_setenv("REMOTE_ADDR", zIpAddr);
g.zIpAddr = mprintf("%s", zIpAddr);
}
/* Get all the optional fields that follow the first line.
*/
while( fgets(zLine,sizeof(zLine),g.httpIn) ){
char *zFieldName;
char *zVal;
zFieldName = extract_token(zLine,&zVal);
if( zFieldName==0 || *zFieldName==0 ) break;
while( fossil_isspace(*zVal) ){ zVal++; }
i = strlen(zVal);
while( i>0 && fossil_isspace(zVal[i-1]) ){ i--; }
zVal[i] = 0;
for(i=0; zFieldName[i]; i++){
zFieldName[i] = fossil_tolower(zFieldName[i]);
}
if( strcmp(zFieldName,"content-length:")==0 ){
cgi_setenv("CONTENT_LENGTH", zVal);
}else if( strcmp(zFieldName,"content-type:")==0 ){
cgi_setenv("CONTENT_TYPE", zVal);
}else if( strcmp(zFieldName,"cookie:")==0 ){
cgi_setenv("HTTP_COOKIE", zVal);
}else if( strcmp(zFieldName,"https:")==0 ){
|
| ︙ | ︙ | |||
1048 1049 1050 1051 1052 1053 1054 | #if defined(_WIN32) /* Use win32_http_server() instead */ fossil_exit(1); #else int listener = -1; /* The server socket */ int connection; /* A socket for each individual connection */ fd_set readfds; /* Set of file descriptors for select() */ | | | 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 | #if defined(_WIN32) /* Use win32_http_server() instead */ fossil_exit(1); #else int listener = -1; /* The server socket */ int connection; /* A socket for each individual connection */ fd_set readfds; /* Set of file descriptors for select() */ socklen_t lenaddr; /* Length of the inaddr structure */ int child; /* PID of the child process */ int nchildren = 0; /* Number of child processes */ struct timeval delay; /* How long to wait inside select() */ struct sockaddr_in inaddr; /* The socket address */ int opt = 1; /* setsockopt flag */ int iPort = mnPort; |
| ︙ | ︙ | |||
1111 1112 1113 1114 1115 1116 1117 |
delay.tv_sec = 60;
delay.tv_usec = 0;
FD_ZERO(&readfds);
FD_SET( listener, &readfds);
select( listener+1, &readfds, 0, 0, &delay);
if( FD_ISSET(listener, &readfds) ){
lenaddr = sizeof(inaddr);
| | < | 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 |
delay.tv_sec = 60;
delay.tv_usec = 0;
FD_ZERO(&readfds);
FD_SET( listener, &readfds);
select( listener+1, &readfds, 0, 0, &delay);
if( FD_ISSET(listener, &readfds) ){
lenaddr = sizeof(inaddr);
connection = accept(listener, (struct sockaddr*)&inaddr, &lenaddr);
if( connection>=0 ){
child = fork();
if( child!=0 ){
if( child>0 ) nchildren++;
close(connection);
}else{
close(0);
|
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
216 217 218 219 220 221 222 |
int nTerm = 0;
int i;
int cTerm;
if( zGlobList==0 || zGlobList[0]==0 ) return "0";
blob_zero(&expr);
while( zGlobList[0] ){
| | | | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
int nTerm = 0;
int i;
int cTerm;
if( zGlobList==0 || zGlobList[0]==0 ) return "0";
blob_zero(&expr);
while( zGlobList[0] ){
while( fossil_isspace(zGlobList[0]) || zGlobList[0]==',' ) zGlobList++;
if( zGlobList[0]==0 ) break;
if( zGlobList[0]=='\'' || zGlobList[0]=='"' ){
cTerm = zGlobList[0];
zGlobList++;
}else{
cTerm = ',';
}
for(i=0; zGlobList[i] && zGlobList[i]!=cTerm; i++){}
if( cTerm==',' ){
while( i>0 && fossil_isspace(zGlobList[i-1]) ){ i--; }
}
blob_appendf(&expr, "%s%s GLOB '%.*q'", zSep, zVal, i, zGlobList);
zSep = " OR ";
if( cTerm!=',' && zGlobList[i] ) i++;
zGlobList += i;
if( zGlobList[0] ) zGlobList++;
nTerm++;
|
| ︙ | ︙ | |||
431 432 433 434 435 436 437 |
free(zFile);
blob_zero(pComment);
while( blob_line(&text, &line) ){
int i, n;
char *z;
n = blob_size(&line);
z = blob_buffer(&line);
| | | | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
free(zFile);
blob_zero(pComment);
while( blob_line(&text, &line) ){
int i, n;
char *z;
n = blob_size(&line);
z = blob_buffer(&line);
for(i=0; i<n && fossil_isspace(z[i]); i++){}
if( i<n && z[i]=='#' ) continue;
if( i<n || blob_size(pComment)>0 ){
blob_appendf(pComment, "%b", &line);
}
}
blob_reset(&text);
zComment = blob_str(pComment);
i = strlen(zComment);
while( i>0 && fossil_isspace(zComment[i-1]) ){ i--; }
blob_resize(pComment, i);
}
/*
** Populate the Global.aCommitFile[] based on the command line arguments
** to a [commit] command. Global.aCommitFile is an array of integers
** sized at (N+1), where N is the number of arguments passed to [commit].
|
| ︙ | ︙ | |||
683 684 685 686 687 688 689 690 691 |
/*
** Check that the user exists.
*/
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
fossil_fatal("no such user: %s", g.zLogin);
}
db_begin_transaction();
db_record_repository_filename(0);
| > < | | 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
/*
** Check that the user exists.
*/
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", g.zLogin) ){
fossil_fatal("no such user: %s", g.zLogin);
}
rc = unsaved_changes();
db_begin_transaction();
db_record_repository_filename(0);
if( rc==0 && !isAMerge && !forceFlag ){
fossil_fatal("nothing has changed");
}
/* If one or more files that were named on the command line have not
** been modified, bail out now.
*/
if( g.aCommitFile ){
Blob unmodified;
|
| ︙ | ︙ |
Changes to src/comformat.c.
| ︙ | ︙ | |||
36 37 38 39 40 41 42 |
int tlen = lineLength - indent;
int si, sk, i, k;
int doIndent = 0;
char zBuf[400];
int lineCnt = 0;
for(;;){
| | | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
int tlen = lineLength - indent;
int si, sk, i, k;
int doIndent = 0;
char zBuf[400];
int lineCnt = 0;
for(;;){
while( fossil_isspace(zText[0]) ){ zText++; }
if( zText[0]==0 ){
if( doIndent==0 ){
printf("\n");
lineCnt = 1;
}
return lineCnt;
}
for(sk=si=i=k=0; zText[i] && k<tlen; i++){
char c = zText[i];
if( fossil_isspace(c) ){
si = i;
sk = k;
if( k==0 || zBuf[k-1]!=' ' ){
zBuf[k++] = ' ';
}
}else{
zBuf[k] = c;
if( c=='-' && k>0 && fossil_isalpha(zBuf[k-1]) ){
si = i+1;
sk = k+1;
}
k++;
}
}
if( doIndent ){
|
| ︙ | ︙ |
Changes to src/config.h.
| ︙ | ︙ | |||
31 32 33 34 35 36 37 | /* ** System header files used by all modules */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /* ** System header files used by all modules */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> /* #include <ctype.h> // do not use - causes problems */ #include <string.h> #include <stdarg.h> #include <assert.h> #endif #if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__) |
| ︙ | ︙ | |||
83 84 85 86 87 88 89 | #ifndef _RC_COMPILE_ #include "sqlite3.h" /* ** Typedef for a 64-bit integer */ | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | #ifndef _RC_COMPILE_ #include "sqlite3.h" /* ** Typedef for a 64-bit integer */ typedef sqlite3_int64 i64; typedef sqlite3_uint64 u64; /* ** Unsigned character type */ typedef unsigned char u8; /* In the timeline, check-in messages are truncated at the first space ** that is more than MX_CKIN_MSG from the beginning, or at the first ** paragraph break that is more than MN_CKIN_MSG from the beginning. */ #define MN_CKIN_MSG 100 #define MX_CKIN_MSG 300 /* ** The following macros are used to cast pointers to integers and ** integers to pointers. The way you do this varies from one compiler ** to the next, so we have developed the following set of #if statements ** to generate appropriate macros for a wide range of compilers. ** ** The correct "ANSI" way to do this is to use the intptr_t type. ** Unfortunately, that typedef is not available on all compilers, or ** if it is available, it requires an #include of specific headers ** that vary from one machine to the next. */ #if defined(__PTRDIFF_TYPE__) /* This case should work for GCC */ # define FOSSIL_INT_TO_PTR(X) ((void*)(__PTRDIFF_TYPE__)(X)) # define FOSSIL_PTR_TO_INT(X) ((int)(__PTRDIFF_TYPE__)(X)) #elif !defined(__GNUC__) /* Works for compilers other than LLVM */ # define FOSSIL_INT_TO_PTR(X) ((void*)&((char*)0)[X]) # define FOSSIL_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) #else /* Generates a warning - but it always works */ # define FOSSIL_INT_TO_PTR(X) ((void*)(X)) # define FOSSIL_PTR_TO_INT(X) ((int)(X)) #endif /* Unset the following to disable internationalization code. */ #ifndef FOSSIL_I18N # define FOSSIL_I18N 1 #endif #if FOSSIL_I18N |
| ︙ | ︙ |
Changes to src/diff.c.
| ︙ | ︙ | |||
97 98 99 100 101 102 103 104 105 106 107 108 109 |
}
if( j>LENGTH_MASK ){
return 0;
}
a = malloc( nLine*sizeof(a[0]) );
if( a==0 ) fossil_panic("out of memory");
memset(a, 0, nLine*sizeof(a[0]) );
/* Fill in the array */
for(i=0; i<nLine; i++){
a[i].z = z;
for(j=0; z[j] && z[j]!='\n'; j++){}
k = j;
| > > > > | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
}
if( j>LENGTH_MASK ){
return 0;
}
a = malloc( nLine*sizeof(a[0]) );
if( a==0 ) fossil_panic("out of memory");
memset(a, 0, nLine*sizeof(a[0]) );
if( n==0 ){
*pnLine = 0;
return a;
}
/* Fill in the array */
for(i=0; i<nLine; i++){
a[i].z = z;
for(j=0; z[j] && z[j]!='\n'; j++){}
k = j;
while( ignoreWS && k>0 && fossil_isspace(z[k-1]) ){ k--; }
for(h=0, x=0; x<k; x++){
h = h ^ (h<<2) ^ z[x];
}
a[i].h = h = (h<<LENGTH_MASK_SZ) | k;;
h2 = h % nLine;
a[i].iNext = a[h2].iHash;
a[h2].iHash = i+1;
|
| ︙ | ︙ |
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
**
** This file contains code used to implement the "diff" command
*/
#include "config.h"
#include "diffcmd.h"
#include <assert.h>
/*
** This function implements a cross-platform "system()" interface.
*/
int portable_system(const char *zOrigCmd){
int rc;
#if defined(_WIN32)
/* On windows, we have to put double-quotes around the entire command.
| > > > > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
**
** This file contains code used to implement the "diff" command
*/
#include "config.h"
#include "diffcmd.h"
#include <assert.h>
/*
** Diff option flags
*/
#define DIFF_NEWFILE 0x01 /* Treat non-existing fails as empty files */
#define DIFF_NOEOLWS 0x02 /* Ignore whitespace at the end of lines */
/*
** This function implements a cross-platform "system()" interface.
*/
int portable_system(const char *zOrigCmd){
int rc;
#if defined(_WIN32)
/* On windows, we have to put double-quotes around the entire command.
|
| ︙ | ︙ | |||
51 52 53 54 55 56 57 | ** command zDiffCmd to do the diffing. */ static void diff_file( Blob *pFile1, /* In memory content to compare from */ const char *zFile2, /* On disk content to compare to */ const char *zName, /* Display name of the file */ const char *zDiffCmd, /* Command for comparison */ | | | | > > > > | > > | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
** command zDiffCmd to do the diffing.
*/
static void diff_file(
Blob *pFile1, /* In memory content to compare from */
const char *zFile2, /* On disk content to compare to */
const char *zName, /* Display name of the file */
const char *zDiffCmd, /* Command for comparison */
int ignoreEolWs /* Ignore whitespace at end of line */
){
if( zDiffCmd==0 ){
Blob out; /* Diff output text */
Blob file2; /* Content of zFile2 */
const char *zName2; /* Name of zFile2 for display */
/* Read content of zFile2 into memory */
blob_zero(&file2);
if( file_size(zFile2)<0 ){
zName2 = "/dev/null";
}else{
blob_read_from_file(&file2, zFile2);
zName2 = zName;
}
/* Compute and output the differences */
blob_zero(&out);
text_diff(pFile1, &file2, &out, 5, ignoreEolWs);
printf("--- %s\n+++ %s\n", zName, zName2);
printf("%s\n", blob_str(&out));
/* Release memory resources */
blob_reset(&file2);
blob_reset(&out);
}else{
int cnt = 0;
|
| ︙ | ︙ | |||
181 182 183 184 185 186 187 | ** Run a diff between the version zFrom and files on disk. zFrom might ** be NULL which means to simply show the difference between the edited ** files on disk and the check-out on which they are based. */ static void diff_all_against_disk( const char *zFrom, /* Version to difference from */ const char *zDiffCmd, /* Use this diff command. NULL for built-in */ | | > > > > | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
** Run a diff between the version zFrom and files on disk. zFrom might
** be NULL which means to simply show the difference between the edited
** files on disk and the check-out on which they are based.
*/
static void diff_all_against_disk(
const char *zFrom, /* Version to difference from */
const char *zDiffCmd, /* Use this diff command. NULL for built-in */
int diffFlags /* Flags controlling diff output */
){
int vid;
Blob sql;
Stmt q;
int ignoreEolWs; /* Ignore end-of-line whitespace */
int asNewFile; /* Treat non-existant files as empty files */
ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0;
asNewFile = (diffFlags & DIFF_NEWFILE)!=0;
vid = db_lget_int("checkout", 0);
vfile_check_signature(vid, 1);
blob_zero(&sql);
db_begin_transaction();
if( zFrom ){
int rid = name_to_rid(zFrom);
if( !is_a_version(rid) ){
|
| ︙ | ︙ | |||
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
}
db_prepare(&q, blob_str(&sql));
while( db_step(&q)==SQLITE_ROW ){
const char *zPathname = db_column_text(&q,0);
int isDeleted = db_column_int(&q, 1);
int isChnged = db_column_int(&q,2);
int isNew = db_column_int(&q,3);
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
if( isDeleted ){
printf("DELETED %s\n", zPathname);
}else if( access(zFullName, 0) ){
printf("MISSING %s\n", zPathname);
}else if( isNew ){
printf("ADDED %s\n", zPathname);
}else if( isChnged==3 ){
printf("ADDED_BY_MERGE %s\n", zPathname);
| > > > > > > < | > > > > | > > > | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
}
db_prepare(&q, blob_str(&sql));
while( db_step(&q)==SQLITE_ROW ){
const char *zPathname = db_column_text(&q,0);
int isDeleted = db_column_int(&q, 1);
int isChnged = db_column_int(&q,2);
int isNew = db_column_int(&q,3);
int srcid = db_column_int(&q, 4);
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
int showDiff = 1;
if( isDeleted ){
printf("DELETED %s\n", zPathname);
if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; }
}else if( access(zFullName, 0) ){
printf("MISSING %s\n", zPathname);
if( !asNewFile ){ showDiff = 0; }
}else if( isNew ){
printf("ADDED %s\n", zPathname);
srcid = 0;
if( !asNewFile ){ showDiff = 0; }
}else if( isChnged==3 ){
printf("ADDED_BY_MERGE %s\n", zPathname);
srcid = 0;
if( !asNewFile ){ showDiff = 0; }
}
if( showDiff ){
Blob content;
if( srcid>0 ){
content_get(srcid, &content);
}else{
blob_zero(&content);
}
printf("Index: %s\n======================================="
"============================\n",
zPathname
);
diff_file(&content, zFullName, zPathname, zDiffCmd, ignoreEolWs);
blob_reset(&content);
}
|
| ︙ | ︙ | |||
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | historical_version_of_file(zFrom, zName, &v1, 0); historical_version_of_file(zTo, zName, &v2, 0); diff_file_mem(&v1, &v2, zName, zDiffCmd, ignoreEolWs); blob_reset(&v1); blob_reset(&v2); blob_reset(&fname); } /* ** Output the differences between two check-ins. */ static void diff_all_two_versions( const char *zFrom, const char *zTo, const char *zDiffCmd, | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > > > > > < < < < | < < < < < | < < | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
historical_version_of_file(zFrom, zName, &v1, 0);
historical_version_of_file(zTo, zName, &v2, 0);
diff_file_mem(&v1, &v2, zName, zDiffCmd, ignoreEolWs);
blob_reset(&v1);
blob_reset(&v2);
blob_reset(&fname);
}
/*
** Show the difference between two files identified by ManifestFile
** entries.
*/
static void diff_manifest_entry(
struct ManifestFile *pFrom,
struct ManifestFile *pTo,
const char *zDiffCmd,
int ignoreEolWs
){
Blob f1, f2;
int rid;
const char *zName = pFrom ? pFrom->zName : pTo->zName;
printf("Index: %s\n======================================="
"============================\n", zName);
if( pFrom ){
rid = uuid_to_rid(pFrom->zUuid, 0);
content_get(rid, &f1);
}else{
blob_zero(&f1);
}
if( pTo ){
rid = uuid_to_rid(pTo->zUuid, 0);
content_get(rid, &f2);
}else{
blob_zero(&f2);
}
diff_file_mem(&f1, &f2, zName, zDiffCmd, ignoreEolWs);
blob_reset(&f1);
blob_reset(&f2);
}
/*
** Output the differences between two check-ins.
*/
static void diff_all_two_versions(
const char *zFrom,
const char *zTo,
const char *zDiffCmd,
int diffFlags
){
Manifest mFrom, mTo;
int iFrom, iTo;
int ignoreEolWs = (diffFlags & DIFF_NOEOLWS)!=0 ? 1 : 0;
int asNewFlag = (diffFlags & DIFF_NEWFILE)!=0 ? 1 : 0;
manifest_from_name(zFrom, &mFrom);
manifest_from_name(zTo, &mTo);
iFrom = iTo = 0;
while( iFrom<mFrom.nFile || iTo<mTo.nFile ){
int cmp;
if( iFrom>=mFrom.nFile ){
cmp = +1;
}else if( iTo>=mTo.nFile ){
cmp = -1;
}else{
cmp = strcmp(mFrom.aFile[iFrom].zName, mTo.aFile[iTo].zName);
}
if( cmp<0 ){
printf("DELETED %s\n", mFrom.aFile[iFrom].zName);
if( asNewFlag ){
diff_manifest_entry(&mFrom.aFile[iFrom], 0, zDiffCmd, ignoreEolWs);
}
iFrom++;
}else if( cmp>0 ){
printf("ADDED %s\n", mTo.aFile[iTo].zName);
if( asNewFlag ){
diff_manifest_entry(0, &mTo.aFile[iTo], zDiffCmd, ignoreEolWs);
}
iTo++;
}else if( strcmp(mFrom.aFile[iFrom].zUuid, mTo.aFile[iTo].zUuid)==0 ){
/* No changes */
iFrom++;
iTo++;
}else{
printf("CHANGED %s\n", mFrom.aFile[iFrom].zName);
diff_manifest_entry(&mFrom.aFile[iFrom], &mTo.aFile[iTo],
zDiffCmd, ignoreEolWs);
iFrom++;
iTo++;
}
}
manifest_clear(&mFrom);
manifest_clear(&mTo);
}
|
| ︙ | ︙ | |||
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
** The results of the internal diff command can also be seen in the gui:
** 1. Go to the <a href="vdiff">vdiff</a> page
** 2. use the "diff against another version" link on the Check-in detail view.
*/
void diff_cmd(void){
int isGDiff; /* True for gdiff. False for normal diff */
int isInternDiff; /* True for internal diff */
const char *zFrom; /* Source version number */
const char *zTo; /* Target version number */
const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
isGDiff = g.argv[1][0]=='g';
isInternDiff = find_option("internal","i",0)!=0;
zFrom = find_option("from", "r", 1);
zTo = find_option("to", 0, 1);
if( zTo==0 ){
db_must_be_within_tree();
verify_all_options();
if( !isInternDiff ){
zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
}
if( g.argc==3 ){
diff_one_against_disk(zFrom, zDiffCmd, 0);
}else{
| > > > > > | | | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
** The results of the internal diff command can also be seen in the gui:
** 1. Go to the <a href="vdiff">vdiff</a> page
** 2. use the "diff against another version" link on the Check-in detail view.
*/
void diff_cmd(void){
int isGDiff; /* True for gdiff. False for normal diff */
int isInternDiff; /* True for internal diff */
int hasNFlag; /* True if -N or --new-file flag is used */
const char *zFrom; /* Source version number */
const char *zTo; /* Target version number */
const char *zDiffCmd = 0; /* External diff command. NULL for internal diff */
int diffFlags = 0; /* Flags to control the DIFF */
isGDiff = g.argv[1][0]=='g';
isInternDiff = find_option("internal","i",0)!=0;
zFrom = find_option("from", "r", 1);
zTo = find_option("to", 0, 1);
hasNFlag = find_option("new-file","N",0)!=0;
if( hasNFlag ) diffFlags |= DIFF_NEWFILE;
if( zTo==0 ){
db_must_be_within_tree();
verify_all_options();
if( !isInternDiff ){
zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
}
if( g.argc==3 ){
diff_one_against_disk(zFrom, zDiffCmd, 0);
}else{
diff_all_against_disk(zFrom, zDiffCmd, diffFlags);
}
}else if( zFrom==0 ){
fossil_fatal("must use --from if --to is present");
}else{
db_find_and_open_repository(1);
verify_all_options();
if( !isInternDiff ){
zDiffCmd = db_get(isGDiff ? "gdiff-command" : "diff-command", 0);
}
if( g.argc==3 ){
diff_one_two_versions(zFrom, zTo, zDiffCmd, 0);
}else{
diff_all_two_versions(zFrom, zTo, zDiffCmd, diffFlags);
}
}
}
|
Changes to src/doc.c.
| ︙ | ︙ | |||
288 289 290 291 292 293 294 |
z = zName;
for(i=0; zName[i]; i++){
if( zName[i]=='.' ) z = &zName[i+1];
}
len = strlen(z);
if( len<sizeof(zSuffix)-1 ){
strcpy(zSuffix, z);
| | | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
z = zName;
for(i=0; zName[i]; i++){
if( zName[i]=='.' ) z = &zName[i+1];
}
len = strlen(z);
if( len<sizeof(zSuffix)-1 ){
strcpy(zSuffix, z);
for(i=0; zSuffix[i]; i++) zSuffix[i] = fossil_tolower(zSuffix[i]);
first = 0;
last = sizeof(aMime)/sizeof(aMime[0]);
while( first<=last ){
int c;
i = (first+last)/2;
c = strcmp(zSuffix, aMime[i].zSuffix);
if( c==0 ) return aMime[i].zMimetype;
|
| ︙ | ︙ |
Changes to src/encode.c.
| ︙ | ︙ | |||
98 99 100 101 102 103 104 |
static char *EncodeHttp(const char *zIn, int n, int encodeSlash){
int c;
int i = 0;
int count = 0;
char *zOut;
int other;
# define IsSafeChar(X) \
| | | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
static char *EncodeHttp(const char *zIn, int n, int encodeSlash){
int c;
int i = 0;
int count = 0;
char *zOut;
int other;
# define IsSafeChar(X) \
(fossil_isalnum(X) || (X)=='.' || (X)=='$' \
|| (X)=='~' || (X)=='-' || (X)=='_' || (X)==other)
if( zIn==0 ) return 0;
if( n<0 ) n = strlen(zIn);
other = encodeSlash ? 'a' : '/';
while( i<n && (c = zIn[i])!=0 ){
if( IsSafeChar(c) || c==' ' ){
|
| ︙ | ︙ | |||
242 243 244 245 246 247 248 |
int c = zIn[i];
if( c==0 ){
zOut[j++] = '\\';
zOut[j++] = '0';
}else if( c=='\\' ){
zOut[j++] = '\\';
zOut[j++] = '\\';
| | | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
int c = zIn[i];
if( c==0 ){
zOut[j++] = '\\';
zOut[j++] = '0';
}else if( c=='\\' ){
zOut[j++] = '\\';
zOut[j++] = '\\';
}else if( fossil_isspace(c) ){
zOut[j++] = '\\';
switch( c ){
case '\n': c = 'n'; break;
case ' ': c = 's'; break;
case '\t': c = 't'; break;
case '\r': c = 'r'; break;
case '\v': c = 'v'; break;
|
| ︙ | ︙ |
Changes to src/event.c.
| ︙ | ︙ | |||
319 320 321 322 323 324 325 |
blob_zero(&tags);
blob_append(&tags, zTags, -1);
/* Collapse all sequences of whitespace and "," characters into
** a single space character */
zBlob = blob_str(&tags);
for(i=j=0; zBlob[i]; i++, j++){
| | | | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
blob_zero(&tags);
blob_append(&tags, zTags, -1);
/* Collapse all sequences of whitespace and "," characters into
** a single space character */
zBlob = blob_str(&tags);
for(i=j=0; zBlob[i]; i++, j++){
if( fossil_isspace(zBlob[i]) || zBlob[i]==',' ){
while( fossil_isspace(zBlob[i+1]) ){ i++; }
zBlob[j] = ' ';
}else{
zBlob[j] = zBlob[i];
}
}
blob_resize(&tags, j);
|
| ︙ | ︙ |
Changes to src/http.c.
| ︙ | ︙ | |||
208 209 210 211 212 213 214 |
}
if( iHttpVersion==0 ){
closeConnection = 1;
}else{
closeConnection = 0;
}
}else if( strncasecmp(zLine, "content-length:", 15)==0 ){
| | | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
}
if( iHttpVersion==0 ){
closeConnection = 1;
}else{
closeConnection = 0;
}
}else if( strncasecmp(zLine, "content-length:", 15)==0 ){
for(i=15; fossil_isspace(zLine[i]); i++){}
iLength = atoi(&zLine[i]);
}else if( strncasecmp(zLine, "connection:", 11)==0 ){
char c;
for(i=11; fossil_isspace(zLine[i]); i++){}
c = zLine[i];
if( c=='c' || c=='C' ){
closeConnection = 1;
}else if( c=='k' || c=='K' ){
closeConnection = 0;
}
}else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){
|
| ︙ | ︙ |
Changes to src/http_transport.c.
| ︙ | ︙ | |||
81 82 83 84 85 86 87 |
*/
static void sshin_read(char *zBuf, int szBuf){
int got;
zBuf[0] = 0;
got = read(sshIn, zBuf, szBuf-1);
while( got>=0 ){
zBuf[got] = 0;
| | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
*/
static void sshin_read(char *zBuf, int szBuf){
int got;
zBuf[0] = 0;
got = read(sshIn, zBuf, szBuf-1);
while( got>=0 ){
zBuf[got] = 0;
if( got==0 || !fossil_isspace(zBuf[got-1]) ) break;
got--;
}
}
/*
** Default SSH command
*/
|
| ︙ | ︙ | |||
437 438 439 440 441 442 443 |
transport.pBuf[i] = 0;
transport.iCursor = i;
break;
}
}
if( transport.pBuf[i]=='\n' ){
transport.iCursor = i+1;
| | | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
transport.pBuf[i] = 0;
transport.iCursor = i;
break;
}
}
if( transport.pBuf[i]=='\n' ){
transport.iCursor = i+1;
while( i>=iStart && fossil_isspace(transport.pBuf[i]) ){
transport.pBuf[i] = 0;
i--;
}
break;
}
i++;
}
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
232 233 234 235 236 237 238 | } } /* ** Append the difference between two RIDs to the output */ | | > > > > | > > > > > | > > > | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
}
}
/*
** Append the difference between two RIDs to the output
*/
static void append_diff(const char *zFrom, const char *zTo){
int fromid;
int toid;
Blob from, to, out;
if( zFrom ){
fromid = uuid_to_rid(zFrom, 0);
content_get(fromid, &from);
}else{
blob_zero(&from);
}
if( zTo ){
toid = uuid_to_rid(zTo, 0);
content_get(toid, &to);
}else{
blob_zero(&to);
}
blob_zero(&out);
text_diff(&from, &to, &out, 5, 1);
@ %h(blob_str(&out))
blob_reset(&from);
blob_reset(&to);
blob_reset(&out);
}
|
| ︙ | ︙ | |||
261 262 263 264 265 266 267 |
if( !g.okHistory ){
if( zNew==0 ){
@ <p>Deleted %h(zName)</p>
}else if( zOld==0 ){
@ <p>Added %h(zName)</p>
}else{
@ <p>Changes to %h(zName)</p>
| > | < < | | | | | | | | | | < > | < > | > > | > > > < < < < < < | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
if( !g.okHistory ){
if( zNew==0 ){
@ <p>Deleted %h(zName)</p>
}else if( zOld==0 ){
@ <p>Added %h(zName)</p>
}else{
@ <p>Changes to %h(zName)</p>
}
if( showDiff ){
@ <blockquote><pre>
append_diff(zOld, zNew);
@ </pre></blockquote>
}
}else{
if( zOld && zNew ){
@ <p>Modified <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
@ from <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
@ to <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)].</a>
}else if( zOld ){
@ <p>Deleted <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
@ version <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
}else{
@ <p>Added <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
@ version <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)]</a>
}
if( showDiff ){
@ <blockquote><pre>
append_diff(zOld, zNew);
@ </pre></blockquote>
}else if( zOld && zNew ){
@
@ <a href="%s(g.zTop)/fdiff?v1=%S(zOld)&v2=%S(zNew)">[diff]</a>
}
@ </p>
}
}
/*
** WEBPAGE: vinfo
** WEBPAGE: ci
|
| ︙ | ︙ |
Changes to src/login.c.
| ︙ | ︙ | |||
351 352 353 354 355 356 357 |
g.noPswd = 1;
strcpy(g.zCsrfToken, "localhost");
}
/* Check the login cookie to see if it matches a known valid user.
*/
if( uid==0 && (zCookie = P(login_cookie_name()))!=0 ){
| | | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
g.noPswd = 1;
strcpy(g.zCsrfToken, "localhost");
}
/* Check the login cookie to see if it matches a known valid user.
*/
if( uid==0 && (zCookie = P(login_cookie_name()))!=0 ){
if( fossil_isdigit(zCookie[0]) ){
/* Cookies of the form "uid/randomness". There must be a
** corresponding entry in the user table. */
uid = db_int(0,
"SELECT uid FROM user"
" WHERE uid=%d"
" AND cookie=%Q"
" AND ipaddr=%Q"
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
702 703 704 705 706 707 708 |
}
}
@ see also the list of
@ <a href="help">available commands</a> in fossil
@ version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
}else{
int nCol, nRow, i, ignored, cnt, showTest;
| | | 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 |
}
}
@ see also the list of
@ <a href="help">available commands</a> in fossil
@ version %s(MANIFEST_VERSION" "MANIFEST_DATE) UTC
}else{
int nCol, nRow, i, ignored, cnt, showTest;
/* detect, if we show normal or test commands */
showTest = ( zCmd && !strncmp(zCmd,"test",4) );
for( i=0,ignored=0; i<count(aCommand); i++){
if( (strncmp(aCommand[i].zName,"test",4)==0) ^ showTest ) ignored++;
}
nCol = 4;
nRow = (count(aCommand)-ignored+nCol-1)/nCol;
|
| ︙ | ︙ | |||
846 847 848 849 850 851 852 |
while( zPathInfo[i] && zPathInfo[i]!='/' ){ i++; }
zRepo = mprintf("%s%.*s.fossil",g.zRepositoryName,i,zPathInfo);
/* To avoid mischief, make sure the repository basename contains no
** characters other than alphanumerics, "-", and "_".
*/
for(j=strlen(g.zRepositoryName)+1, k=0; k<i-1; j++, k++){
| | | 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
while( zPathInfo[i] && zPathInfo[i]!='/' ){ i++; }
zRepo = mprintf("%s%.*s.fossil",g.zRepositoryName,i,zPathInfo);
/* To avoid mischief, make sure the repository basename contains no
** characters other than alphanumerics, "-", and "_".
*/
for(j=strlen(g.zRepositoryName)+1, k=0; k<i-1; j++, k++){
if( !fossil_isalnum(zRepo[j]) && zRepo[j]!='-' ) zRepo[j] = '_';
}
if( zRepo[0]=='/' && zRepo[1]=='/' ) zRepo++;
if( file_size(zRepo)<1024 ){
if( zNotFound ){
cgi_redirect(zNotFound);
}else{
|
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
52 53 54 55 56 57 58 | char *zEventId; /* UUID for an event. E card. */ char *zTicketUuid; /* UUID for a ticket. K card. */ char *zAttachName; /* Filename of an attachment. A card. */ char *zAttachSrc; /* UUID of document being attached. A card. */ char *zAttachTarget; /* Ticket or wiki that attachment applies to. A card */ int nFile; /* Number of F cards */ int nFileAlloc; /* Slots allocated in aFile[] */ | | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
char *zEventId; /* UUID for an event. E card. */
char *zTicketUuid; /* UUID for a ticket. K card. */
char *zAttachName; /* Filename of an attachment. A card. */
char *zAttachSrc; /* UUID of document being attached. A card. */
char *zAttachTarget; /* Ticket or wiki that attachment applies to. A card */
int nFile; /* Number of F cards */
int nFileAlloc; /* Slots allocated in aFile[] */
struct ManifestFile {
char *zName; /* Name of a file */
char *zUuid; /* UUID of the file */
char *zPerm; /* File permissions */
char *zPrior; /* Prior name if the name was changed */
int iRename; /* index of renamed name in prior/next manifest */
} *aFile; /* One entry for each F card */
int nParent; /* Number of parents. */
|
| ︙ | ︙ | |||
1209 1210 1211 1212 1213 1214 1215 |
if( m.type==CFTYPE_WIKI ){
char *zTag = mprintf("wiki-%s", m.zWikiTitle);
int tagid = tag_findid(zTag, 1);
int prior;
char *zComment;
int nWiki;
char zLength[40];
| | | 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 |
if( m.type==CFTYPE_WIKI ){
char *zTag = mprintf("wiki-%s", m.zWikiTitle);
int tagid = tag_findid(zTag, 1);
int prior;
char *zComment;
int nWiki;
char zLength[40];
while( fossil_isspace(m.zWiki[0]) ) m.zWiki++;
nWiki = strlen(m.zWiki);
sqlite3_snprintf(sizeof(zLength), zLength, "%d", nWiki);
tag_insert(zTag, 1, zLength, rid, m.rDate, rid);
free(zTag);
prior = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime<%.17g"
|
| ︙ | ︙ | |||
1249 1250 1251 1252 1253 1254 1255 |
}
if( m.type==CFTYPE_EVENT ){
char *zTag = mprintf("event-%s", m.zEventId);
int tagid = tag_findid(zTag, 1);
int prior, subsequent;
int nWiki;
char zLength[40];
| | | 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 |
}
if( m.type==CFTYPE_EVENT ){
char *zTag = mprintf("event-%s", m.zEventId);
int tagid = tag_findid(zTag, 1);
int prior, subsequent;
int nWiki;
char zLength[40];
while( fossil_isspace(m.zWiki[0]) ) m.zWiki++;
nWiki = strlen(m.zWiki);
sqlite3_snprintf(sizeof(zLength), zLength, "%d", nWiki);
tag_insert(zTag, 1, zLength, rid, m.rDate, rid);
free(zTag);
prior = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=%d AND mtime<%.17g"
|
| ︙ | ︙ |
Changes to src/merge3.c.
| ︙ | ︙ | |||
149 150 151 152 153 154 155 |
int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
int *aC1; /* Changes from pPivot to pV1 */
int *aC2; /* Changes from pPivot to pV2 */
int i1, i2; /* Index into aC1[] and aC2[] */
int nCpy, nDel, nIns; /* Number of lines to copy, delete, or insert */
int limit1, limit2; /* Sizes of aC1[] and aC2[] */
int nConflict = 0; /* Number of merge conflicts seen so far */
| | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
int blob_merge(Blob *pPivot, Blob *pV1, Blob *pV2, Blob *pOut){
int *aC1; /* Changes from pPivot to pV1 */
int *aC2; /* Changes from pPivot to pV2 */
int i1, i2; /* Index into aC1[] and aC2[] */
int nCpy, nDel, nIns; /* Number of lines to copy, delete, or insert */
int limit1, limit2; /* Sizes of aC1[] and aC2[] */
int nConflict = 0; /* Number of merge conflicts seen so far */
static const char zBegin[] = "<<<<<<< BEGIN MERGE CONFLICT\n";
static const char zMid[] = "============================\n";
static const char zEnd[] = ">>>>>>> END MERGE CONFLICT\n";
blob_zero(pOut); /* Merge results stored in pOut */
/* Compute the edits that occur from pPivot => pV1 (into aC1)
** and pPivot => pV2 (into aC2). Each of the aC1 and aC2 arrays is
** an array of integer triples. Within each triple, the first integer
** is the number of lines of text to copy directly from the pivot,
|
| ︙ | ︙ |
Changes to src/name.c.
| ︙ | ︙ | |||
109 110 111 112 113 114 115 |
return rc;
}
/*
** Return TRUE if the string begins with an ISO8601 date: YYYY-MM-DD.
*/
static int is_date(const char *z){
| | | | | | | | | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
return rc;
}
/*
** Return TRUE if the string begins with an ISO8601 date: YYYY-MM-DD.
*/
static int is_date(const char *z){
if( !fossil_isdigit(z[0]) ) return 0;
if( !fossil_isdigit(z[1]) ) return 0;
if( !fossil_isdigit(z[2]) ) return 0;
if( !fossil_isdigit(z[3]) ) return 0;
if( z[4]!='-') return 0;
if( !fossil_isdigit(z[5]) ) return 0;
if( !fossil_isdigit(z[6]) ) return 0;
if( z[7]!='-') return 0;
if( !fossil_isdigit(z[8]) ) return 0;
if( !fossil_isdigit(z[9]) ) return 0;
return 1;
}
/*
** Convert a symbolic tag name into the UUID of a check-in that contains
** that tag. If the tag appears on multiple check-ins, return the UUID
** of the most recent check-in with the tag.
|
| ︙ | ︙ | |||
278 279 280 281 282 283 284 |
int rid;
Blob name;
if( zName==0 || zName[0]==0 ) return 0;
blob_init(&name, zName, -1);
if( name_to_uuid(&name, -1) ){
blob_reset(&name);
| | | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
int rid;
Blob name;
if( zName==0 || zName[0]==0 ) return 0;
blob_init(&name, zName, -1);
if( name_to_uuid(&name, -1) ){
blob_reset(&name);
for(i=0; zName[i] && fossil_isdigit(zName[i]); i++){}
if( zName[i]==0 ){
rid = atoi(zName);
if( db_exists("SELECT 1 FROM blob WHERE rid=%d", rid) ){
return rid;
}
}
fossil_error(1, "no such artifact: %s", zName);
|
| ︙ | ︙ | |||
346 347 348 349 350 351 352 |
Blob name;
if( zName==0 || zName[0]==0 ) return 0;
blob_init(&name, zName, -1);
rc = name_to_uuid(&name, -1);
if( rc==1 ){
blob_reset(&name);
| | | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
Blob name;
if( zName==0 || zName[0]==0 ) return 0;
blob_init(&name, zName, -1);
rc = name_to_uuid(&name, -1);
if( rc==1 ){
blob_reset(&name);
for(i=0; zName[i] && fossil_isdigit(zName[i]); i++){}
if( zName[i]==0 ){
rid = atoi(zName);
if( db_exists("SELECT 1 FROM blob WHERE rid=%d", rid) ){
return rid;
}
}
return 0;
|
| ︙ | ︙ |
Changes to src/report.c.
| ︙ | ︙ | |||
86 87 88 89 90 91 92 |
}
/*
** Remove whitespace from both ends of a string.
*/
char *trim_string(const char *zOrig){
int i;
| | | | | | | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
}
/*
** Remove whitespace from both ends of a string.
*/
char *trim_string(const char *zOrig){
int i;
while( fossil_isspace(*zOrig) ){ zOrig++; }
i = strlen(zOrig);
while( i>0 && fossil_isspace(zOrig[i-1]) ){ i--; }
return mprintf("%.*s", i, zOrig);
}
/*
** Extract a numeric (integer) value from a string.
*/
char *extract_integer(const char *zOrig){
if( zOrig == NULL || zOrig[0] == 0 ) return "";
while( *zOrig && !fossil_isdigit(*zOrig) ){ zOrig++; }
if( *zOrig ){
/* we have a digit. atoi() will get as much of the number as it
** can. We'll run it through mprintf() to get a string. Not
** an efficient way to do it, but effective.
*/
return mprintf("%d", atoi(zOrig));
}
return "";
}
/*
** Remove blank lines from the beginning of a string and
** all whitespace from the end. Removes whitespace preceeding a NL,
** which also converts any CRNL sequence into a single NL.
*/
char *remove_blank_lines(const char *zOrig){
int i, j, n;
char *z;
for(i=j=0; fossil_isspace(zOrig[i]); i++){ if( zOrig[i]=='\n' ) j = i+1; }
n = strlen(&zOrig[j]);
while( n>0 && fossil_isspace(zOrig[j+n-1]) ){ n--; }
z = mprintf("%.*s", n, &zOrig[j]);
for(i=j=0; z[i]; i++){
if( z[i+1]=='\n' && z[i]!='\n' && fossil_isspace(z[i]) ){
z[j] = z[i];
while(fossil_isspace(z[j]) && z[j] != '\n' ){ j--; }
j++;
continue;
}
z[j++] = z[i];
}
z[j] = 0;
|
| ︙ | ︙ | |||
210 211 212 213 214 215 216 | const char *zTail; sqlite3_stmt *pStmt; int rc; /* First make sure the SQL is a single query command by verifying that ** the first token is "SELECT" and that there are no unquoted semicolons. */ | | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
const char *zTail;
sqlite3_stmt *pStmt;
int rc;
/* First make sure the SQL is a single query command by verifying that
** the first token is "SELECT" and that there are no unquoted semicolons.
*/
for(i=0; fossil_isspace(zSql[i]); i++){}
if( strncasecmp(&zSql[i],"select",6)!=0 ){
return mprintf("The SQL must be a SELECT statement");
}
for(i=0; zSql[i]; i++){
if( zSql[i]==';' ){
int bad;
int c = zSql[i+1];
|
| ︙ | ︙ | |||
581 582 583 584 585 586 587 | @ title AS 'Title', @ wiki(substr(description,0,80)) AS 'Description' @ FROM ticket @ </pre></blockquote> @ } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
@ title AS 'Title',
@ wiki(substr(description,0,80)) AS 'Description'
@ FROM ticket
@ </pre></blockquote>
@
}
/*
** The state of the report generation.
*/
struct GenerateHTML {
int rn; /* Report number */
int nCount; /* Row number */
int nCol; /* Number of columns */
|
| ︙ | ︙ | |||
770 771 772 773 774 775 776 |
/*
** Output the text given in the argument. Convert tabs and newlines into
** spaces.
*/
static void output_no_tabs(const char *z){
while( z && z[0] ){
int i, j;
| | | | 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
/*
** Output the text given in the argument. Convert tabs and newlines into
** spaces.
*/
static void output_no_tabs(const char *z){
while( z && z[0] ){
int i, j;
for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){}
if( i>0 ){
cgi_printf("%.*s", i, z);
}
for(j=i; fossil_isspace(z[j]); j++){}
if( j>i ){
cgi_printf("%*s", j-i, "");
}
z += j;
}
}
|
| ︙ | ︙ | |||
814 815 816 817 818 819 820 |
/*
** Generate HTML that describes a color key.
*/
void output_color_key(const char *zClrKey, int horiz, char *zTabArgs){
int i, j, k;
char *zSafeKey, *zToFree;
| | | | | | 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
/*
** Generate HTML that describes a color key.
*/
void output_color_key(const char *zClrKey, int horiz, char *zTabArgs){
int i, j, k;
char *zSafeKey, *zToFree;
while( fossil_isspace(*zClrKey) ) zClrKey++;
if( zClrKey[0]==0 ) return;
@ <table %s(zTabArgs)>
if( horiz ){
@ <tr>
}
zToFree = zSafeKey = mprintf("%h", zClrKey);
while( zSafeKey[0] ){
while( fossil_isspace(*zSafeKey) ) zSafeKey++;
for(i=0; zSafeKey[i] && !fossil_isspace(zSafeKey[i]); i++){}
for(j=i; fossil_isspace(zSafeKey[j]); j++){}
for(k=j; zSafeKey[k] && zSafeKey[k]!='\n' && zSafeKey[k]!='\r'; k++){}
if( !horiz ){
cgi_printf("<tr style=\"background-color: %.*s;\"><td>%.*s</td></tr>\n",
i, zSafeKey, k-j, &zSafeKey[j]);
}else{
cgi_printf("<td style=\"background-color: %.*s;\">%.*s</td>\n",
i, zSafeKey, k-j, &zSafeKey[j]);
|
| ︙ | ︙ | |||
1004 1005 1006 1007 1008 1009 1010 |
free(zFosZ);
}
break;
}
default:
while( z && z[0] ){
int i, j;
| | | | 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
free(zFosZ);
}
break;
}
default:
while( z && z[0] ){
int i, j;
for(i=0; z[i] && (!fossil_isspace(z[i]) || z[i]==' '); i++){}
if( i>0 ){
printf("%.*s", i, z);
}
for(j=i; fossil_isspace(z[j]); j++){}
if( j>i ){
printf("%*s", j-i, "");
}
z += j;
}
break;
}
|
| ︙ | ︙ | |||
1103 1104 1105 1106 1107 1108 1109 |
sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1);
sqlite3_exec(g.db, zSql, output_separated_file, &count, &zErr2);
sqlite3_set_authorizer(g.db, 0, 0);
if( zFilter ){
free(zSql);
}
}
| < | 1074 1075 1076 1077 1078 1079 1080 |
sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1);
sqlite3_exec(g.db, zSql, output_separated_file, &count, &zErr2);
sqlite3_set_authorizer(g.db, 0, 0);
if( zFilter ){
free(zSql);
}
}
|
Changes to src/search.c.
| ︙ | ︙ | |||
46 47 48 49 50 51 52 |
p = malloc( nPattern + sizeof(*p) + 1);
if( p==0 ) fossil_panic("out of memory");
z = (char*)&p[1];
strcpy(z, zPattern);
memset(p, 0, sizeof(*p));
while( *z && p->nTerm<sizeof(p->a)/sizeof(p->a[0]) ){
| | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
p = malloc( nPattern + sizeof(*p) + 1);
if( p==0 ) fossil_panic("out of memory");
z = (char*)&p[1];
strcpy(z, zPattern);
memset(p, 0, sizeof(*p));
while( *z && p->nTerm<sizeof(p->a)/sizeof(p->a[0]) ){
while( !fossil_isalnum(*z) && *z ){ z++; }
if( *z==0 ) break;
p->a[p->nTerm].z = z;
for(i=1; fossil_isalnum(z[i]) || z[i]=='_'; i++){}
p->a[p->nTerm].n = i;
z += i;
p->nTerm++;
}
return p;
}
|
| ︙ | ︙ |
Changes to src/th_lang.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/*
** This file contains the implementation of all of the TH language
** built-in commands.
**
** All built-in commands are implemented using the public interface
** declared in th.h, so this file serves as both a part of the language
** implementation and an example of how to extend the language with
** new commands.
*/
#include "th.h"
#include <string.h>
#include <assert.h>
int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg){
Th_ErrorMessage(interp, "wrong # args: should be \"", zMsg, -1);
return TH_ERROR;
| > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/*
** This file contains the implementation of all of the TH language
** built-in commands.
**
** All built-in commands are implemented using the public interface
** declared in th.h, so this file serves as both a part of the language
** implementation and an example of how to extend the language with
** new commands.
*/
#include "config.h"
#include "th.h"
#include <string.h>
#include <assert.h>
int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg){
Th_ErrorMessage(interp, "wrong # args: should be \"", zMsg, -1);
return TH_ERROR;
|
| ︙ | ︙ | |||
569 570 571 572 573 574 575 |
){
if( argc!=1 && argc!=2 ){
return Th_WrongNumArgs(interp, "return ?value?");
}
if( argc==2 ){
Th_SetResult(interp, argv[1], argl[1]);
}
| | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
){
if( argc!=1 && argc!=2 ){
return Th_WrongNumArgs(interp, "return ?value?");
}
if( argc==2 ){
Th_SetResult(interp, argv[1], argl[1]);
}
return FOSSIL_PTR_TO_INT(ctx);
}
/*
** TH Syntax:
**
** return ?-code code? ?value?
*/
|
| ︙ | ︙ |
Changes to src/th_main.c.
| ︙ | ︙ | |||
433 434 435 436 437 438 439 |
static int validVarName(const char *z){
int i = 0;
int inBracket = 0;
if( z[0]=='<' ){
inBracket = 1;
z++;
}
| | | | | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
static int validVarName(const char *z){
int i = 0;
int inBracket = 0;
if( z[0]=='<' ){
inBracket = 1;
z++;
}
if( z[0]==':' && z[1]==':' && fossil_isalpha(z[2]) ){
z += 3;
i += 3;
}else if( fossil_isalpha(z[0]) ){
z ++;
i += 1;
}else{
return 0;
}
while( fossil_isalnum(z[0]) || z[0]=='_' ){
z++;
i++;
}
if( inBracket ){
if( z[0]!='>' ) return 0;
i += 2;
}
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
828 829 830 831 832 833 834 |
if ( zSearch ){
blob_appendf(&sql,
" AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
zSearch, zSearch);
url_add_parameter(&url, "s", zSearch);
}
if( zAfter ){
| | | | | 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 |
if ( zSearch ){
blob_appendf(&sql,
" AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
zSearch, zSearch);
url_add_parameter(&url, "s", zSearch);
}
if( zAfter ){
while( fossil_isspace(zAfter[0]) ){ zAfter++; }
if( zAfter[0] ){
blob_appendf(&sql,
" AND event.mtime>=(SELECT julianday(%Q, 'utc'))"
" ORDER BY event.mtime ASC", zAfter);
url_add_parameter(&url, "a", zAfter);
zBefore = 0;
}else{
zAfter = 0;
}
}else if( zBefore ){
while( fossil_isspace(zBefore[0]) ){ zBefore++; }
if( zBefore[0] ){
blob_appendf(&sql,
" AND event.mtime<=(SELECT julianday(%Q, 'utc'))"
" ORDER BY event.mtime DESC", zBefore);
url_add_parameter(&url, "b", zBefore);
}else{
zBefore = 0;
}
}else if( zCirca ){
while( fossil_isspace(zCirca[0]) ){ zCirca++; }
if( zCirca[0] ){
double rCirca = db_double(0.0, "SELECT julianday(%Q, 'utc')", zCirca);
Blob sql2;
blob_init(&sql2, blob_str(&sql), -1);
blob_appendf(&sql2,
" AND event.mtime<=%f ORDER BY event.mtime DESC LIMIT %d",
rCirca, (nEntry+1)/2
|
| ︙ | ︙ | |||
1058 1059 1060 1061 1062 1063 1064 |
** Return true if the input string is a date in the ISO 8601 format:
** YYYY-MM-DD.
*/
static int isIsoDate(const char *z){
return strlen(z)==10
&& z[4]=='-'
&& z[7]=='-'
| | | | 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 |
** Return true if the input string is a date in the ISO 8601 format:
** YYYY-MM-DD.
*/
static int isIsoDate(const char *z){
return strlen(z)==10
&& z[4]=='-'
&& z[7]=='-'
&& fossil_isdigit(z[0])
&& fossil_isdigit(z[5]);
}
/*
** COMMAND: timeline
**
** Usage: %fossil timeline ?WHEN? ?BASELINE|DATETIME? ?-n N? ?-t TYPE?
**
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
443 444 445 446 447 448 449 |
int nValue;
if( azAppend[i] ){
blob_appendf(&tktchng, "J +%s %z\n", azField[i],
fossilize(azAppend[i], -1));
}else{
zValue = Th_Fetch(azField[i], &nValue);
if( zValue ){
| | | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
int nValue;
if( azAppend[i] ){
blob_appendf(&tktchng, "J +%s %z\n", azField[i],
fossilize(azAppend[i], -1));
}else{
zValue = Th_Fetch(azField[i], &nValue);
if( zValue ){
while( nValue>0 && fossil_isspace(zValue[nValue-1]) ){ nValue--; }
if( strncmp(zValue, azValue[i], nValue) || strlen(azValue[i])!=nValue ){
if( strncmp(azField[i], "private_", 8)==0 ){
zValue = db_conceal(zValue, nValue);
blob_appendf(&tktchng, "J %s %s\n", azField[i], zValue);
}else{
blob_appendf(&tktchng, "J %s %#F\n", azField[i], nValue, zValue);
}
|
| ︙ | ︙ |
Changes to src/url.c.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 |
#include "url.h"
/*
** Convert a string to lower-case.
*/
static void url_tolower(char *z){
while( *z ){
| | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#include "url.h"
/*
** Convert a string to lower-case.
*/
static void url_tolower(char *z){
while( *z ){
*z = fossil_tolower(*z);
z++;
}
}
/*
** Parse the given URL. Populate variables in the global "g" structure.
**
|
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
g.urlName = mprintf("%.*s", i-iStart, &zUrl[iStart]);
zLogin = mprintf("");
}
url_tolower(g.urlName);
if( c==':' ){
g.urlPort = 0;
i++;
| | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
g.urlName = mprintf("%.*s", i-iStart, &zUrl[iStart]);
zLogin = mprintf("");
}
url_tolower(g.urlName);
if( c==':' ){
g.urlPort = 0;
i++;
while( (c = zUrl[i])!=0 && fossil_isdigit(c) ){
g.urlPort = g.urlPort*10 + c - '0';
i++;
}
g.urlHostname = mprintf("%s:%d", g.urlName, g.urlPort);
}else{
g.urlPort = g.urlDfltPort;
g.urlHostname = g.urlName;
|
| ︙ | ︙ |
Changes to src/user.c.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 |
/*
** Strip leading and trailing space from a string and add the string
** onto the end of a blob.
*/
static void strip_string(Blob *pBlob, char *z){
int i;
blob_reset(pBlob);
| | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
/*
** Strip leading and trailing space from a string and add the string
** onto the end of a blob.
*/
static void strip_string(Blob *pBlob, char *z){
int i;
blob_reset(pBlob);
while( fossil_isspace(*z) ){ z++; }
for(i=0; z[i]; i++){
if( z[i]=='\r' || z[i]=='\n' ){
while( i>0 && fossil_isspace(z[i-1]) ){ i--; }
z[i] = 0;
break;
}
if( z[i]<' ' ) z[i] = ' ';
}
blob_append(pBlob, z, -1);
}
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
184 185 186 187 188 189 190 |
memset(&m, 0, sizeof(m));
blob_zero(&m.content);
if( rid ){
Blob content;
content_get(rid, &content);
manifest_parse(&m, &content);
if( m.type==CFTYPE_WIKI && m.zWiki ){
| | | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
memset(&m, 0, sizeof(m));
blob_zero(&m.content);
if( rid ){
Blob content;
content_get(rid, &content);
manifest_parse(&m, &content);
if( m.type==CFTYPE_WIKI && m.zWiki ){
while( fossil_isspace(m.zWiki[0]) ) m.zWiki++;
if( m.zWiki[0] ) zBody = m.zWiki;
}
}
}
if( !g.isHome ){
if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){
style_submenu_element("Edit", "Edit Wiki Page", "%s/wikiedit?name=%T",
|
| ︙ | ︙ | |||
943 944 945 946 947 948 949 |
if( m.type==CFTYPE_WIKI ){
zBody = m.zWiki;
}
}
if( zBody==0 ){
fossil_fatal("wiki page [%s] not found",zPageName);
}
| | | 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 |
if( m.type==CFTYPE_WIKI ){
zBody = m.zWiki;
}
}
if( zBody==0 ){
fossil_fatal("wiki page [%s] not found",zPageName);
}
for(i=strlen(zBody); i>0 && fossil_isspace(zBody[i-1]); i--){}
zFile = (g.argc==4) ? 0 : g.argv[4];
if( zFile ){
FILE * zF;
short doClose = 0;
if( (1 == strlen(zFile)) && ('-'==zFile[0]) ){
zF = stdout;
}else{
|
| ︙ | ︙ |
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
410 411 412 413 414 415 416 |
** it is not well-formed markup, return 0.
*/
static int markupLength(const char *z){
int n = 1;
int inparen = 0;
int c;
if( z[n]=='/' ){ n++; }
| | | | | | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
** it is not well-formed markup, return 0.
*/
static int markupLength(const char *z){
int n = 1;
int inparen = 0;
int c;
if( z[n]=='/' ){ n++; }
if( !fossil_isalpha(z[n]) ) return 0;
while( fossil_isalnum(z[n]) ){ n++; }
c = z[n];
if( c=='/' && z[n+1]=='>' ){ return n+2; }
if( c!='>' && !fossil_isspace(c) ) return 0;
while( (c = z[n])!=0 && (c!='>' || inparen) ){
if( c==inparen ){
inparen = 0;
}else if( inparen==0 && (c=='"' || c=='\'') ){
inparen = c;
}
n++;
}
if( z[n]!='>' ) return 0;
return n+1;
}
/*
** z points to a "\n" character. Check to see if this newline is
** followed by one or more blank lines. If it is, return the number
** of characters through the closing "\n". If not, return 0.
*/
static int paragraphBreakLength(const char *z){
int i, n;
int nNewline = 1;
for(i=1, n=0; fossil_isspace(z[i]); i++){
if( z[i]=='\n' ){
nNewline++;
n = i;
}
}
if( nNewline>=2 ){
return n+1;
|
| ︙ | ︙ | |||
480 481 482 483 484 485 486 |
/*
** Return true if z[] begins with an HTML character element.
*/
static int isElement(const char *z){
int i;
assert( z[0]=='&' );
if( z[1]=='#' ){
| | | | 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
/*
** Return true if z[] begins with an HTML character element.
*/
static int isElement(const char *z){
int i;
assert( z[0]=='&' );
if( z[1]=='#' ){
for(i=2; fossil_isdigit(z[i]); i++){}
return i>2 && z[i]==';';
}else{
for(i=1; fossil_isalpha(z[i]); i++){}
return i>1 && z[i]==';';
}
}
/*
** Check to see if the z[] string is the beginning of a wiki list item.
** If it is, return the length of the bullet text. Otherwise return 0.
|
| ︙ | ︙ | |||
509 510 511 512 513 514 515 |
n++;
i = 0;
while( z[n]==' ' || z[n]=='\t' ){
if( z[n]=='\t' ) i++;
i++;
n++;
}
| | | 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
n++;
i = 0;
while( z[n]==' ' || z[n]=='\t' ){
if( z[n]=='\t' ) i++;
i++;
n++;
}
if( i<2 || fossil_isspace(z[n]) ) return 0;
return n;
}
/*
** Check to see if the z[] string is the beginning of a enumeration value.
** If it is, return the length of the bullet text. Otherwise return 0.
**
|
| ︙ | ︙ | |||
534 535 536 537 538 539 540 |
i = 0;
while( z[n]==' ' || z[n]=='\t' ){
if( z[n]=='\t' ) i++;
i++;
n++;
}
if( i<2 ) return 0;
| | | | | 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
i = 0;
while( z[n]==' ' || z[n]=='\t' ){
if( z[n]=='\t' ) i++;
i++;
n++;
}
if( i<2 ) return 0;
for(i=0; fossil_isdigit(z[n]); i++, n++){}
if( i==0 ) return 0;
if( z[n]=='.' ){
n++;
}
i = 0;
while( z[n]==' ' || z[n]=='\t' ){
if( z[n]=='\t' ) i++;
i++;
n++;
}
if( i<2 || fossil_isspace(z[n]) ) return 0;
return n;
}
/*
** Check to see if the z[] string is the beginning of an indented
** paragraph. If it is, return the length of the indent. Otherwise
** return 0.
*/
static int indentLength(const char *z){
int i, n;
n = 0;
i = 0;
while( z[n]==' ' || z[n]=='\t' ){
if( z[n]=='\t' ) i++;
i++;
n++;
}
if( i<2 || fossil_isspace(z[n]) ) return 0;
return n;
}
/*
** Check to see if the z[] string is a wiki hyperlink. If it is,
** return the length of the hyperlink. Otherwise return 0.
*/
|
| ︙ | ︙ | |||
610 611 612 613 614 615 616 |
}
if( (p->state & ALLOW_WIKI)!=0 ){
if( z[0]=='\n' ){
n = paragraphBreakLength(z);
if( n>0 ){
*pTokenType = TOKEN_PARAGRAPH;
return n;
| | | | | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
}
if( (p->state & ALLOW_WIKI)!=0 ){
if( z[0]=='\n' ){
n = paragraphBreakLength(z);
if( n>0 ){
*pTokenType = TOKEN_PARAGRAPH;
return n;
}else if( fossil_isspace(z[1]) ){
*pTokenType = TOKEN_NEWLINE;
return 1;
}
}
if( (p->state & AT_NEWLINE)!=0 && fossil_isspace(z[0]) ){
n = listItemLength(z, '*');
if( n>0 ){
*pTokenType = TOKEN_BUL_LI;
return n;
}
n = listItemLength(z, '#');
if( n>0 ){
*pTokenType = TOKEN_NUM_LI;
return n;
}
n = enumLength(z);
if( n>0 ){
*pTokenType = TOKEN_ENUM;
return n;
}
}
if( (p->state & AT_PARAGRAPH)!=0 && fossil_isspace(z[0]) ){
n = indentLength(z);
if( n>0 ){
*pTokenType = TOKEN_INDENT;
return n;
}
}
if( z[0]=='[' && (n = linkLength(z))>0 ){
|
| ︙ | ︙ | |||
703 704 705 706 707 708 709 |
p->endTag = 1;
i = 2;
}else{
p->endTag = 0;
i = 1;
}
j = 0;
| | | | | | | | | | | | 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
p->endTag = 1;
i = 2;
}else{
p->endTag = 0;
i = 1;
}
j = 0;
while( fossil_isalnum(z[i]) ){
if( j<sizeof(zTag)-1 ) zTag[j++] = fossil_tolower(z[i]);
i++;
}
zTag[j] = 0;
p->iCode = findTag(zTag);
p->iType = aMarkup[p->iCode].iType;
p->nAttr = 0;
while( fossil_isspace(z[i]) ){ i++; }
while( p->nAttr<8 && fossil_isalpha(z[i]) ){
int attrOk; /* True to preserver attribute. False to ignore it */
j = 0;
while( fossil_isalnum(z[i]) ){
if( j<sizeof(zTag)-1 ) zTag[j++] = fossil_tolower(z[i]);
i++;
}
zTag[j] = 0;
p->aAttr[p->nAttr].iACode = iACode = findAttr(zTag);
attrOk = iACode!=0 && (seen & aAttribute[iACode].iMask)==0;
while( fossil_isspace(z[i]) ){ z++; }
if( z[i]!='=' ){
p->aAttr[p->nAttr].zValue = 0;
p->aAttr[p->nAttr].cTerm = 0;
c = 0;
}else{
i++;
while( fossil_isspace(z[i]) ){ z++; }
if( z[i]=='"' ){
i++;
zValue = &z[i];
while( z[i] && z[i]!='"' ){ i++; }
}else if( z[i]=='\'' ){
i++;
zValue = &z[i];
while( z[i] && z[i]!='\'' ){ i++; }
}else{
zValue = &z[i];
while( !fossil_isspace(z[i]) && z[i]!='>' ){ z++; }
}
if( attrOk ){
p->aAttr[p->nAttr].zValue = zValue;
p->aAttr[p->nAttr].cTerm = c = z[i];
z[i] = 0;
}
i++;
}
if( attrOk ){
seen |= aAttribute[iACode].iMask;
p->nAttr++;
}
while( fossil_isspace(z[i]) ){ i++; }
if( z[i]=='>' || (z[i]=='/' && z[i+1]=='>') ) break;
}
}
/*
** Render markup on the given blob.
*/
|
| ︙ | ︙ | |||
1065 1066 1067 1068 1069 1070 1071 |
}else{
zTerm = "";
}
}
}else if( g.okHistory ){
blob_appendf(p->pOut, "<a href=\"%s/info/%s\">", g.zBaseURL, zTarget);
}
| | | 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 |
}else{
zTerm = "";
}
}
}else if( g.okHistory ){
blob_appendf(p->pOut, "<a href=\"%s/info/%s\">", g.zBaseURL, zTarget);
}
}else if( strlen(zTarget)>=10 && fossil_isdigit(zTarget[0]) && zTarget[4]=='-'
&& db_int(0, "SELECT datetime(%Q) NOT NULL", zTarget) ){
blob_appendf(p->pOut, "<a href=\"%s/timeline?c=%T\">", g.zBaseURL, zTarget);
}else if( strncmp(zTarget, "wiki:", 5)==0
&& wiki_name_is_wellformed((const unsigned char*)zTarget) ){
zTarget += 5;
blob_appendf(p->pOut, "<a href=\"%s/wiki?name=%T\">", g.zBaseURL, zTarget);
}else if( wiki_name_is_wellformed((const unsigned char *)zTarget) ){
|
| ︙ | ︙ | |||
1243 1244 1245 1246 1247 1248 1249 |
startAutoParagraph(p);
zTarget = &z[1];
for(i=1; z[i] && z[i]!=']'; i++){
if( z[i]=='|' && zDisplay==0 ){
zDisplay = &z[i+1];
z[i] = 0;
| | | | | 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 |
startAutoParagraph(p);
zTarget = &z[1];
for(i=1; z[i] && z[i]!=']'; i++){
if( z[i]=='|' && zDisplay==0 ){
zDisplay = &z[i+1];
z[i] = 0;
for(j=i-1; j>0 && fossil_isspace(z[j]); j--){ z[j] = 0; }
}
}
z[i] = 0;
if( zDisplay==0 ){
zDisplay = zTarget;
}else{
while( fossil_isspace(*zDisplay) ) zDisplay++;
}
openHyperlink(p, zTarget, zClose, sizeof(zClose));
savedState = p->state;
p->state &= ~ALLOW_WIKI;
p->state |= FONT_MARKUP_ONLY;
wiki_render(p, zDisplay);
p->state = savedState;
blob_append(p->pOut, zClose, -1);
break;
}
case TOKEN_TEXT: {
int i;
for(i=0; i<n && fossil_isspace(z[i]); i++){}
if( i<n ) startAutoParagraph(p);
blob_append(p->pOut, z, n);
break;
}
case TOKEN_RAW: {
blob_append(p->pOut, z, n);
break;
|
| ︙ | ︙ | |||
1519 1520 1521 1522 1523 1524 1525 |
** title.
*/
int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
char *z;
int i;
int iStart;
z = skip_bom(blob_str(pIn));
| | | 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 |
** title.
*/
int wiki_find_title(Blob *pIn, Blob *pTitle, Blob *pTail){
char *z;
int i;
int iStart;
z = skip_bom(blob_str(pIn));
for(i=0; fossil_isspace(z[i]); i++){}
if( z[i]!='<' ) return 0;
i++;
if( strncmp(&z[i],"title>", 6)!=0 ) return 0;
iStart = i+6;
for(i=iStart; z[i] && (z[i]!='<' || strncmp(&z[i],"</title>",8)!=0); i++){}
if( z[i]!='<' ) return 0;
blob_init(pTitle, &z[iStart], i-iStart);
|
| ︙ | ︙ |