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: |
586b0eb1449d03bcddd32c75652d4e7e |
| User & Date: | wolfgang 2010-10-16 17:33:22.000 |
Context
|
2010-10-16
| ||
| 19:07 | PellesC doesn't have pgmptr, update Makefile ... (Closed-Leaf check-in: f88368742d user: wolfgang tags: wolfgangHelpCmd) | |
| 17:33 | merge from trunk ... (check-in: 586b0eb144 user: wolfgang tags: wolfgangHelpCmd) | |
| 16:24 | Do not attempt to parse control artifacts that do not end with a '\n' character. Ticket [be56c89def7f86bcbd] ... (check-in: 7954ccba68 user: drh tags: trunk) | |
|
2010-10-15
| ||
| 16:11 | merge from trunk ... (check-in: c127179362 user: wolfgang tags: wolfgangHelpCmd) | |
Changes
Changes to src/bag.c.
| ︙ | ︙ | |||
84 85 86 87 88 89 90 | int i; Bag old; int nDel = 0; /* Number of deleted entries */ int nLive = 0; /* Number of live entries */ old = *p; assert( newSize>old.cnt ); | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
int i;
Bag old;
int nDel = 0; /* Number of deleted entries */
int nLive = 0; /* Number of live entries */
old = *p;
assert( newSize>old.cnt );
p->a = fossil_malloc( sizeof(p->a[0])*newSize );
p->sz = newSize;
memset(p->a, 0, sizeof(p->a[0])*newSize );
for(i=0; i<old.sz; i++){
int e = old.a[i];
if( e>0 ){
unsigned h = bag_hash(e)%newSize;
while( p->a[h] ){
|
| ︙ | ︙ |
Changes to src/blob.c.
| ︙ | ︙ | |||
134 135 136 137 138 139 140 |
if( newSize==0 ){
free(pBlob->aData);
pBlob->aData = 0;
pBlob->nAlloc = 0;
pBlob->nUsed = 0;
pBlob->iCursor = 0;
}else if( newSize>pBlob->nAlloc || newSize<pBlob->nAlloc-4000 ){
| | < | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
if( newSize==0 ){
free(pBlob->aData);
pBlob->aData = 0;
pBlob->nAlloc = 0;
pBlob->nUsed = 0;
pBlob->iCursor = 0;
}else if( newSize>pBlob->nAlloc || newSize<pBlob->nAlloc-4000 ){
char *pNew = fossil_realloc(pBlob->aData, newSize);
pBlob->aData = pNew;
pBlob->nAlloc = newSize;
if( pBlob->nUsed>pBlob->nAlloc ){
pBlob->nUsed = pBlob->nAlloc;
}
}
}
|
| ︙ | ︙ | |||
160 161 162 163 164 165 166 |
** A reallocation function for when the initial string is in unmanaged
** space. Copy the string to memory obtained from malloc().
*/
static void blobReallocStatic(Blob *pBlob, unsigned int newSize){
if( newSize==0 ){
*pBlob = empty_blob;
}else{
| | < | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
** A reallocation function for when the initial string is in unmanaged
** space. Copy the string to memory obtained from malloc().
*/
static void blobReallocStatic(Blob *pBlob, unsigned int newSize){
if( newSize==0 ){
*pBlob = empty_blob;
}else{
char *pNew = fossil_malloc( newSize );
if( pBlob->nUsed>newSize ) pBlob->nUsed = newSize;
memcpy(pNew, pBlob->aData, pBlob->nUsed);
pBlob->aData = pNew;
pBlob->xRealloc = blobReallocMalloc;
pBlob->nAlloc = newSize;
}
}
|
| ︙ | ︙ |
Changes to src/captcha.c.
| ︙ | ︙ | |||
67 68 69 70 71 72 73 |
/*
** Render an 8-character hexadecimal string as ascii art.
** Space to hold the result is obtained from malloc() and should be freed
** by the caller.
*/
char *captcha_render(const char *zPw){
| | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
/*
** Render an 8-character hexadecimal string as ascii art.
** Space to hold the result is obtained from malloc() and should be freed
** by the caller.
*/
char *captcha_render(const char *zPw){
char *z = fossil_malloc( 500 );
int i, j, k, m;
k = 0;
for(i=0; i<6; i++){
for(j=0; j<8; j++){
unsigned char v = hexValue(zPw[j]);
v = (aFont1[v] >> ((5-i)*4)) & 0xf;
|
| ︙ | ︙ | |||
200 201 202 203 204 205 206 |
/*
** Render an 8-digit hexadecimal string as ascii arg.
** Space to hold the result is obtained from malloc() and should be freed
** by the caller.
*/
char *captcha_render(const char *zPw){
| | | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
/*
** Render an 8-digit hexadecimal string as ascii arg.
** Space to hold the result is obtained from malloc() and should be freed
** by the caller.
*/
char *captcha_render(const char *zPw){
char *z = fossil_malloc( 300 );
int i, j, k, m;
const char *zChar;
k = 0;
for(i=0; i<4; i++){
for(j=0; j<8; j++){
unsigned char v = hexValue(zPw[j]);
|
| ︙ | ︙ | |||
357 358 359 360 361 362 363 |
/*
** Render an 8-digit hexadecimal string as ascii arg.
** Space to hold the result is obtained from malloc() and should be freed
** by the caller.
*/
char *captcha_render(const char *zPw){
| | | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
/*
** Render an 8-digit hexadecimal string as ascii arg.
** Space to hold the result is obtained from malloc() and should be freed
** by the caller.
*/
char *captcha_render(const char *zPw){
char *z = fossil_malloc( 600 );
int i, j, k, m;
const char *zChar;
k = 0;
for(i=0; i<6; i++){
for(j=0; j<8; j++){
unsigned char v = hexValue(zPw[j]);
|
| ︙ | ︙ |
Changes to src/cgi.c.
| ︙ | ︙ | |||
385 386 387 388 389 390 391 |
**
** zName and zValue are not copied and must not change or be
** deallocated after this routine returns.
*/
void cgi_set_parameter_nocopy(const char *zName, const char *zValue){
if( nAllocQP<=nUsedQP ){
nAllocQP = nAllocQP*2 + 10;
| | < | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
**
** zName and zValue are not copied and must not change or be
** deallocated after this routine returns.
*/
void cgi_set_parameter_nocopy(const char *zName, const char *zValue){
if( nAllocQP<=nUsedQP ){
nAllocQP = nAllocQP*2 + 10;
aParamQP = fossil_realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) );
}
aParamQP[nUsedQP].zName = zName;
aParamQP[nUsedQP].zValue = zValue;
if( g.fHttpTrace ){
fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue);
}
aParamQP[nUsedQP].seq = seqQP++;
|
| ︙ | ︙ | |||
679 680 681 682 683 684 685 |
len = atoi(PD("CONTENT_LENGTH", "0"));
g.zContentType = zType = P("CONTENT_TYPE");
if( len>0 && zType ){
blob_zero(&g.cgiIn);
if( strcmp(zType,"application/x-www-form-urlencoded")==0
|| strncmp(zType,"multipart/form-data",19)==0 ){
| | < | 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
len = atoi(PD("CONTENT_LENGTH", "0"));
g.zContentType = zType = P("CONTENT_TYPE");
if( len>0 && zType ){
blob_zero(&g.cgiIn);
if( strcmp(zType,"application/x-www-form-urlencoded")==0
|| strncmp(zType,"multipart/form-data",19)==0 ){
z = fossil_malloc( len+1 );
len = fread(z, 1, len, g.httpIn);
z[len] = 0;
if( zType[0]=='a' ){
add_param_list(z, '&');
}else{
process_multipart_form_data(z, len);
}
|
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
463 464 465 466 467 468 469 |
** to mean "all files".
*/
void select_commit_files(void){
if( g.argc>2 ){
int ii;
Blob b;
blob_zero(&b);
| | | 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
** to mean "all files".
*/
void select_commit_files(void){
if( g.argc>2 ){
int ii;
Blob b;
blob_zero(&b);
g.aCommitFile = fossil_malloc(sizeof(int)*(g.argc-1));
for(ii=2; ii<g.argc; ii++){
int iId;
file_tree_name(g.argv[ii], &b, 1);
iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b));
if( iId<0 ){
fossil_fatal("fossil knows nothing about: %s", g.argv[ii]);
|
| ︙ | ︙ |
Changes to src/content.c.
| ︙ | ︙ | |||
78 79 80 81 82 83 84 |
void content_cache_insert(int rid, Blob *pBlob){
struct cacheLine *p;
if( contentCache.n>500 || contentCache.szTotal>50000000 ){
content_cache_expire_oldest();
}
if( contentCache.n>=contentCache.nAlloc ){
contentCache.nAlloc = contentCache.nAlloc*2 + 10;
| | < | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
void content_cache_insert(int rid, Blob *pBlob){
struct cacheLine *p;
if( contentCache.n>500 || contentCache.szTotal>50000000 ){
content_cache_expire_oldest();
}
if( contentCache.n>=contentCache.nAlloc ){
contentCache.nAlloc = contentCache.nAlloc*2 + 10;
contentCache.a = fossil_realloc(contentCache.a,
contentCache.nAlloc*sizeof(contentCache.a[0]));
}
p = &contentCache.a[contentCache.n++];
p->rid = rid;
p->age = contentCache.nextAge++;
contentCache.szTotal += blob_size(pBlob);
p->content = *pBlob;
blob_zero(pBlob);
|
| ︙ | ︙ | |||
238 239 240 241 242 243 244 |
}else{
int n = 1;
int nAlloc = 10;
int *a = 0;
int mx;
Blob delta, next;
| | < | < | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
}else{
int n = 1;
int nAlloc = 10;
int *a = 0;
int mx;
Blob delta, next;
a = fossil_malloc( sizeof(a[0])*nAlloc );
a[0] = rid;
a[1] = nextRid;
n = 1;
while( !bag_find(&contentCache.inCache, nextRid)
&& (nextRid = findSrcid(nextRid))>0 ){
n++;
if( n>=nAlloc ){
nAlloc = nAlloc*2 + 10;
a = fossil_realloc(a, nAlloc*sizeof(a[0]));
}
a[n] = nextRid;
}
mx = n;
rc = content_get(a[n], pBlob);
n--;
while( rc && n>=0 ){
|
| ︙ | ︙ | |||
348 349 350 351 352 353 354 |
blob_reset(&content);
}
db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid);
while( db_step(&q)==SQLITE_ROW ){
int child = db_column_int(&q, 0);
if( nChildUsed>=nChildAlloc ){
nChildAlloc = nChildAlloc*2 + 10;
| | < | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
blob_reset(&content);
}
db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid);
while( db_step(&q)==SQLITE_ROW ){
int child = db_column_int(&q, 0);
if( nChildUsed>=nChildAlloc ){
nChildAlloc = nChildAlloc*2 + 10;
aChild = fossil_realloc(aChild, nChildAlloc*sizeof(aChild));
}
aChild[nChildUsed++] = child;
}
db_finalize(&q);
for(i=1; i<nChildUsed; i++){
after_dephantomize(aChild[i], 1);
}
|
| ︙ | ︙ |
Changes to src/delta.c.
| ︙ | ︙ | |||
315 316 317 318 319 320 321 |
return zDelta - zOrigDelta;
}
/* Compute the hash table used to locate matching sections in the
** source file.
*/
nHash = lenSrc/NHASH;
| | < | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
return zDelta - zOrigDelta;
}
/* Compute the hash table used to locate matching sections in the
** source file.
*/
nHash = lenSrc/NHASH;
collide = fossil_malloc( nHash*2*sizeof(int) );
landmark = &collide[nHash];
memset(landmark, -1, nHash*sizeof(int));
memset(collide, -1, nHash*sizeof(int));
for(i=0; i<lenSrc-NHASH; i+=NHASH){
int hv;
hash_init(&h, &zSrc[i]);
hv = hash_32bit(&h) % nHash;
|
| ︙ | ︙ |
Changes to src/diff.c.
| ︙ | ︙ | |||
94 95 96 97 98 99 100 |
}
j = 0;
}
}
if( j>LENGTH_MASK ){
return 0;
}
| | < | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
}
j = 0;
}
}
if( j>LENGTH_MASK ){
return 0;
}
a = fossil_malloc( nLine*sizeof(a[0]) );
memset(a, 0, nLine*sizeof(a[0]) );
if( n==0 ){
*pnLine = 0;
return a;
}
/* Fill in the array */
|
| ︙ | ︙ | |||
143 144 145 146 147 148 149 |
blob_append(pOut, "\n", 1);
}
/*
** Expand the size of aEdit[] array to hold nEdit elements.
*/
static void expandEdit(DContext *p, int nEdit){
| < | < < < < < < | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
blob_append(pOut, "\n", 1);
}
/*
** Expand the size of aEdit[] array to hold nEdit elements.
*/
static void expandEdit(DContext *p, int nEdit){
p->aEdit = fossil_realloc(p->aEdit, nEdit*sizeof(int));
p->nEditAlloc = nEdit;
}
/*
** Append a new COPY/DELETE/INSERT triple.
*/
static void appendTriple(DContext *p, int nCopy, int nDel, int nIns){
|
| ︙ | ︙ | |||
647 648 649 650 651 652 653 |
int i;
memset(p, 0, sizeof(*p));
p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,1);
if( p->c.aTo==0 ){
return 1;
}
| | < | 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
int i;
memset(p, 0, sizeof(*p));
p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,1);
if( p->c.aTo==0 ){
return 1;
}
p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo );
for(i=0; i<p->c.nTo; i++){
p->aOrig[i].z = p->c.aTo[i].z;
p->aOrig[i].n = p->c.aTo[i].h & LENGTH_MASK;
p->aOrig[i].zSrc = 0;
}
p->nOrig = p->c.nTo;
return 0;
|
| ︙ | ︙ |
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
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; }
| > | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
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);
char *zToFree = zFullName;
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; }
|
| ︙ | ︙ | |||
281 282 283 284 285 286 287 |
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 |
printf("Index: %s\n======================================="
"============================\n",
zPathname
);
diff_file(&content, zFullName, zPathname, zDiffCmd, ignoreEolWs);
blob_reset(&content);
}
free(zToFree);
}
db_finalize(&q);
db_end_transaction(1); /* ROLLBACK */
}
/*
** Output the differences between two versions of a single file.
|
| ︙ | ︙ |
Changes to src/encode.c.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
case '&': count += 5; break;
case '"': count += 6; break;
default: count++; break;
}
i++;
}
i = 0;
| | < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
case '&': count += 5; break;
case '"': count += 6; break;
default: count++; break;
}
i++;
}
i = 0;
zOut = fossil_malloc( count+1 );
while( n-->0 && (c = *zIn)!=0 ){
switch( c ){
case '<':
zOut[i++] = '&';
zOut[i++] = 'l';
zOut[i++] = 't';
zOut[i++] = ';';
|
| ︙ | ︙ | |||
113 114 115 116 117 118 119 |
count++;
}else{
count += 3;
}
i++;
}
i = 0;
| | < | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
count++;
}else{
count += 3;
}
i++;
}
i = 0;
zOut = fossil_malloc( count+1 );
while( n-->0 && (c = *zIn)!=0 ){
if( IsSafeChar(c) ){
zOut[i++] = c;
}else if( c==' ' ){
zOut[i++] = '+';
}else{
zOut[i++] = '%';
|
| ︙ | ︙ | |||
232 233 234 235 236 237 238 |
if( nIn<0 ) nIn = strlen(zIn);
for(i=n=0; i<nIn; i++){
c = zIn[i];
if( c==0 || c==' ' || c=='\n' || c=='\t' || c=='\r' || c=='\f' || c=='\v'
|| c=='\\' ) n++;
}
n += nIn;
| | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
if( nIn<0 ) nIn = strlen(zIn);
for(i=n=0; i<nIn; i++){
c = zIn[i];
if( c==0 || c==' ' || c=='\n' || c=='\t' || c=='\r' || c=='\f' || c=='\v'
|| c=='\\' ) n++;
}
n += nIn;
zOut = fossil_malloc( n+1 );
if( zOut ){
for(i=j=0; i<nIn; i++){
int c = zIn[i];
if( c==0 ){
zOut[j++] = '\\';
zOut[j++] = '0';
}else if( c=='\\' ){
|
| ︙ | ︙ | |||
308 309 310 311 312 313 314 |
char *encode64(const char *zData, int nData){
char *z64;
int i, n;
if( nData<=0 ){
nData = strlen(zData);
}
| | | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
char *encode64(const char *zData, int nData){
char *z64;
int i, n;
if( nData<=0 ){
nData = strlen(zData);
}
z64 = fossil_malloc( (nData*4)/3 + 8 );
for(i=n=0; i+2<nData; i+=3){
z64[n++] = zBase[ (zData[i]>>2) & 0x3f ];
z64[n++] = zBase[ ((zData[i]<<4) & 0x30) | ((zData[i+1]>>4) & 0x0f) ];
z64[n++] = zBase[ ((zData[i+1]<<2) & 0x3c) | ((zData[i+2]>>6) & 0x03) ];
z64[n++] = zBase[ zData[i+2] & 0x3f ];
}
if( i+1<nData ){
|
| ︙ | ︙ | |||
369 370 371 372 373 374 375 |
if( !isInit ){
for(i=0; i<128; i++){ trans[i] = 0; }
for(i=0; zBase[i]; i++){ trans[zBase[i] & 0x7f] = i; }
isInit = 1;
}
n64 = strlen(z64);
while( n64>0 && z64[n64-1]=='=' ) n64--;
| | | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
if( !isInit ){
for(i=0; i<128; i++){ trans[i] = 0; }
for(i=0; zBase[i]; i++){ trans[zBase[i] & 0x7f] = i; }
isInit = 1;
}
n64 = strlen(z64);
while( n64>0 && z64[n64-1]=='=' ) n64--;
zData = fossil_malloc( (n64*3)/4 + 4 );
for(i=j=0; i+3<n64; i+=4){
a = trans[z64[i] & 0x7f];
b = trans[z64[i+1] & 0x7f];
c = trans[z64[i+2] & 0x7f];
d = trans[z64[i+3] & 0x7f];
zData[j++] = ((a<<2) & 0xfc) | ((b>>4) & 0x03);
zData[j++] = ((b<<4) & 0xf0) | ((c>>2) & 0x0f);
|
| ︙ | ︙ | |||
530 531 532 533 534 535 536 |
char *obscure(const char *zIn){
int n, i;
unsigned char salt;
char *zOut;
if( zIn==0 ) return 0;
n = strlen(zIn);
| | < | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
char *obscure(const char *zIn){
int n, i;
unsigned char salt;
char *zOut;
if( zIn==0 ) return 0;
n = strlen(zIn);
zOut = fossil_malloc( n*2+3 );
sqlite3_randomness(1, &salt);
zOut[n+1] = (char)salt;
for(i=0; i<n; i++) zOut[i+n+2] = zIn[i]^aObscurer[i&0x0f]^salt;
encode16((unsigned char*)&zOut[n+1], (unsigned char*)zOut, n+1);
return zOut;
}
|
| ︙ | ︙ | |||
553 554 555 556 557 558 559 |
char *unobscure(const char *zIn){
int n, i;
unsigned char salt;
char *zOut;
if( zIn==0 ) return 0;
n = strlen(zIn);
| | < | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
char *unobscure(const char *zIn){
int n, i;
unsigned char salt;
char *zOut;
if( zIn==0 ) return 0;
n = strlen(zIn);
zOut = fossil_malloc( n + 1 );
if( n<2
|| decode16((unsigned char*)zIn, &salt, 2)
|| decode16((unsigned char*)&zIn[2], (unsigned char*)zOut, n-2)
){
memcpy(zOut, zIn, n+1);
}else{
n = n/2 - 1;
|
| ︙ | ︙ |
Changes to src/graph.c.
| ︙ | ︙ | |||
70 71 72 73 74 75 76 |
#endif
/*
** Malloc for zeroed space. Panic if unable to provide the
** requested space.
*/
void *safeMalloc(int nByte){
| | < | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
#endif
/*
** Malloc for zeroed space. Panic if unable to provide the
** requested space.
*/
void *safeMalloc(int nByte){
void *p = fossil_malloc(nByte);
memset(p, 0, nByte);
return p;
}
/*
** Create and initialize a GraphContext
*/
|
| ︙ | ︙ | |||
146 147 148 149 150 151 152 |
*/
static char *persistBranchName(GraphContext *p, const char *zBranch){
int i;
for(i=0; i<p->nBranch; i++){
if( strcmp(zBranch, p->azBranch[i])==0 ) return p->azBranch[i];
}
p->nBranch++;
| | < | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
*/
static char *persistBranchName(GraphContext *p, const char *zBranch){
int i;
for(i=0; i<p->nBranch; i++){
if( strcmp(zBranch, p->azBranch[i])==0 ) return p->azBranch[i];
}
p->nBranch++;
p->azBranch = fossil_realloc(p->azBranch, sizeof(char*)*p->nBranch);
p->azBranch[p->nBranch-1] = mprintf("%s", zBranch);
return p->azBranch[p->nBranch-1];
}
/*
** Add a new row to the graph context. Rows are added from top to bottom.
*/
|
| ︙ | ︙ |
Changes to src/http_transport.c.
| ︙ | ︙ | |||
384 385 386 387 388 389 390 |
** The buffer itself might be moved. And the transport.iCursor value
** might be reset to 0.
*/
static void transport_load_buffer(int N){
int i, j;
if( transport.nAlloc==0 ){
transport.nAlloc = N;
| | < | < | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
** The buffer itself might be moved. And the transport.iCursor value
** might be reset to 0.
*/
static void transport_load_buffer(int N){
int i, j;
if( transport.nAlloc==0 ){
transport.nAlloc = N;
transport.pBuf = fossil_malloc( N );
transport.iCursor = 0;
transport.nUsed = 0;
}
if( transport.iCursor>0 ){
for(i=0, j=transport.iCursor; j<transport.nUsed; i++, j++){
transport.pBuf[i] = transport.pBuf[j];
}
transport.nUsed -= transport.iCursor;
transport.iCursor = 0;
}
if( transport.nUsed + N > transport.nAlloc ){
char *pNew;
transport.nAlloc = transport.nUsed + N;
pNew = fossil_realloc(transport.pBuf, transport.nAlloc);
transport.pBuf = pNew;
}
if( N>0 ){
i = transport_fetch(&transport.pBuf[transport.nUsed], N);
if( i>0 ){
transport.nUsed += i;
}
|
| ︙ | ︙ |
Changes to src/login.c.
| ︙ | ︙ | |||
50 51 52 53 54 55 56 |
/*
** Return the name of the login cookie
*/
static char *login_cookie_name(void){
static char *zCookieName = 0;
if( zCookieName==0 ){
int n = strlen(g.zTop);
| | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
/*
** Return the name of the login cookie
*/
static char *login_cookie_name(void){
static char *zCookieName = 0;
if( zCookieName==0 ){
int n = strlen(g.zTop);
zCookieName = fossil_malloc( n*2+16 );
/* 0123456789 12345 */
strcpy(zCookieName, "fossil_login_");
encode16((unsigned char*)g.zTop, (unsigned char*)&zCookieName[13], n);
}
return zCookieName;
}
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
va_end(ap);
if( g.cgiOutput ){
cgi_printf("<p class=\"generalError\">%h</p>", z);
}else{
fprintf(stderr, "%s: %s\n", g.argv[0], z);
}
}
/*
** Return a name for an SQLite error code
*/
static const char *sqlite_error_code_name(int iCode){
static char zCode[30];
switch( iCode & 0xff ){
| > > > > > > > > > > > > > > > > > > | 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 |
va_end(ap);
if( g.cgiOutput ){
cgi_printf("<p class=\"generalError\">%h</p>", z);
}else{
fprintf(stderr, "%s: %s\n", g.argv[0], z);
}
}
/*
** Malloc and free routines that cannot fail
*/
void *fossil_malloc(size_t n){
void *p = malloc(n);
if( p==0 ) fossil_panic("out of memory");
return p;
}
void fossil_free(void *p){
free(p);
}
void *fossil_realloc(void *p, size_t n){
p = realloc(p, n);
if( p==0 ) fossil_panic("out of memory");
return p;
}
/*
** Return a name for an SQLite error code
*/
static const char *sqlite_error_code_name(int iCode){
static char zCode[30];
switch( iCode & 0xff ){
|
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
*/
int manifest_parse(Manifest *p, Blob *pContent){
int seenHeader = 0;
int seenZ = 0;
int i, lineNo=0;
Blob line, token, a1, a2, a3, a4;
char cPrevType = 0;
memset(p, 0, sizeof(*p));
memcpy(&p->content, pContent, sizeof(p->content));
blob_zero(pContent);
pContent = &p->content;
blob_zero(&a1);
| > > > > > > > > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
*/
int manifest_parse(Manifest *p, Blob *pContent){
int seenHeader = 0;
int seenZ = 0;
int i, lineNo=0;
Blob line, token, a1, a2, a3, a4;
char cPrevType = 0;
/* Every control artifact ends with a '\n' character. Exit early
** if that is not the case for this artifact. */
i = blob_size(pContent);
if( i<=0 || blob_buffer(pContent)[i-1]!='\n' ){
blob_reset(pContent);
return 0;
}
memset(p, 0, sizeof(*p));
memcpy(&p->content, pContent, sizeof(p->content));
blob_zero(pContent);
pContent = &p->content;
blob_zero(&a1);
|
| ︙ | ︙ | |||
362 363 364 365 366 367 368 |
goto manifest_syntax_error;
}
}else{
zPriorName = 0;
}
if( p->nFile>=p->nFileAlloc ){
p->nFileAlloc = p->nFileAlloc*2 + 10;
| > | < | 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
goto manifest_syntax_error;
}
}else{
zPriorName = 0;
}
if( p->nFile>=p->nFileAlloc ){
p->nFileAlloc = p->nFileAlloc*2 + 10;
p->aFile = fossil_realloc(p->aFile,
p->nFileAlloc*sizeof(p->aFile[0]) );
}
i = p->nFile++;
p->aFile[i].zName = zName;
p->aFile[i].zUuid = zUuid;
p->aFile[i].zPerm = zPerm;
p->aFile[i].zPrior = zPriorName;
p->aFile[i].iRename = -1;
|
| ︙ | ︙ | |||
396 397 398 399 400 401 402 |
blob_token(&line, &a2);
if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
zName = blob_terminate(&a1);
zValue = blob_terminate(&a2);
defossilize(zValue);
if( p->nField>=p->nFieldAlloc ){
p->nFieldAlloc = p->nFieldAlloc*2 + 10;
| | < | 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
blob_token(&line, &a2);
if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
zName = blob_terminate(&a1);
zValue = blob_terminate(&a2);
defossilize(zValue);
if( p->nField>=p->nFieldAlloc ){
p->nFieldAlloc = p->nFieldAlloc*2 + 10;
p->aField = fossil_realloc(p->aField,
p->nFieldAlloc*sizeof(p->aField[0]) );
}
i = p->nField++;
p->aField[i].zName = zName;
p->aField[i].zValue = zValue;
if( i>0 && strcmp(p->aField[i-1].zName, zName)>=0 ){
goto manifest_syntax_error;
}
|
| ︙ | ︙ | |||
462 463 464 465 466 467 468 |
md5sum_step_text(blob_buffer(&line), blob_size(&line));
if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
zUuid = blob_terminate(&a1);
if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error;
if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
if( p->nCChild>=p->nCChildAlloc ){
p->nCChildAlloc = p->nCChildAlloc*2 + 10;
| | | < | 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
md5sum_step_text(blob_buffer(&line), blob_size(&line));
if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
zUuid = blob_terminate(&a1);
if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error;
if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
if( p->nCChild>=p->nCChildAlloc ){
p->nCChildAlloc = p->nCChildAlloc*2 + 10;
p->azCChild = fossil_realloc(p->azCChild
, p->nCChildAlloc*sizeof(p->azCChild[0]) );
}
i = p->nCChild++;
p->azCChild[i] = zUuid;
if( i>0 && strcmp(p->azCChild[i-1], zUuid)>=0 ){
goto manifest_syntax_error;
}
break;
|
| ︙ | ︙ | |||
490 491 492 493 494 495 496 |
while( blob_token(&line, &a1) ){
char *zUuid;
if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error;
zUuid = blob_terminate(&a1);
if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
if( p->nParent>=p->nParentAlloc ){
p->nParentAlloc = p->nParentAlloc*2 + 5;
| > | < | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
while( blob_token(&line, &a1) ){
char *zUuid;
if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error;
zUuid = blob_terminate(&a1);
if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;
if( p->nParent>=p->nParentAlloc ){
p->nParentAlloc = p->nParentAlloc*2 + 5;
p->azParent = fossil_realloc(p->azParent,
p->nParentAlloc*sizeof(char*));
}
i = p->nParent++;
p->azParent[i] = zUuid;
}
break;
}
|
| ︙ | ︙ | |||
565 566 567 568 569 570 571 |
}
if( validate16(&zName[1], strlen(&zName[1])) ){
/* Do not allow tags whose names look like UUIDs */
goto manifest_syntax_error;
}
if( p->nTag>=p->nTagAlloc ){
p->nTagAlloc = p->nTagAlloc*2 + 10;
| | < | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
}
if( validate16(&zName[1], strlen(&zName[1])) ){
/* Do not allow tags whose names look like UUIDs */
goto manifest_syntax_error;
}
if( p->nTag>=p->nTagAlloc ){
p->nTagAlloc = p->nTagAlloc*2 + 10;
p->aTag = fossil_realloc(p->aTag, p->nTagAlloc*sizeof(p->aTag[0]) );
}
i = p->nTag++;
p->aTag[i].zName = zName;
p->aTag[i].zUuid = zUuid;
p->aTag[i].zValue = zValue;
if( i>0 && strcmp(p->aTag[i-1].zName, zName)>=0 ){
goto manifest_syntax_error;
|
| ︙ | ︙ |
Changes to src/pqueue.c.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 |
pqueue_init(p);
}
/*
** Change the size of the queue so that it contains N slots
*/
static void pqueue_resize(PQueue *p, int N){
| | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
pqueue_init(p);
}
/*
** Change the size of the queue so that it contains N slots
*/
static void pqueue_resize(PQueue *p, int N){
p->a = fossil_realloc(p->a, sizeof(p->a[0])*N);
p->sz = N;
}
/*
** Insert element e into the queue.
*/
void pqueue_insert(PQueue *p, int e, double v){
|
| ︙ | ︙ |
Changes to src/printf.c.
| ︙ | ︙ | |||
558 559 560 561 562 563 564 |
break;
case etPATH: {
int i;
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *e = va_arg(ap,char*);
if( e==0 ){e="";}
length = StrNLen32(e, limit);
| | | 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
break;
case etPATH: {
int i;
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *e = va_arg(ap,char*);
if( e==0 ){e="";}
length = StrNLen32(e, limit);
zExtra = bufpt = fossil_malloc(length+1);
for( i=0; i<length; i++ ){
if( e[i]=='\\' ){
bufpt[i]='/';
}else{
bufpt[i]=e[i];
}
}
|
| ︙ | ︙ | |||
603 604 605 606 607 608 609 |
Blob *pBlob = va_arg(ap, Blob*);
char *zOrig = blob_buffer(pBlob);
int i, j, n, cnt;
n = blob_size(pBlob);
if( limit>=0 && limit<n ) n = limit;
for(cnt=i=0; i<n; i++){ if( zOrig[i]=='\'' ) cnt++; }
if( n+cnt+2 > etBUFSIZE ){
| | | 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
Blob *pBlob = va_arg(ap, Blob*);
char *zOrig = blob_buffer(pBlob);
int i, j, n, cnt;
n = blob_size(pBlob);
if( limit>=0 && limit<n ) n = limit;
for(cnt=i=0; i<n; i++){ if( zOrig[i]=='\'' ) cnt++; }
if( n+cnt+2 > etBUFSIZE ){
bufpt = zExtra = fossil_malloc( n + cnt + 2 );
}else{
bufpt = buf;
}
bufpt[0] = '\'';
for(i=0, j=1; i<n; i++, j++){
if( zOrig[i]=='\'' ){ bufpt[j++] = '\''; }
bufpt[j] = zOrig[i];
|
| ︙ | ︙ | |||
632 633 634 635 636 637 638 |
if( limit<0 ) limit = strlen(escarg);
for(i=n=0; i<limit; i++){
if( escarg[i]=='\'' ) n++;
}
needQuote = !isnull && xtype==etSQLESCAPE2;
n += i + 1 + needQuote*2;
if( n>etBUFSIZE ){
| | < | 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
if( limit<0 ) limit = strlen(escarg);
for(i=n=0; i<limit; i++){
if( escarg[i]=='\'' ) n++;
}
needQuote = !isnull && xtype==etSQLESCAPE2;
n += i + 1 + needQuote*2;
if( n>etBUFSIZE ){
bufpt = zExtra = fossil_malloc( n );
}else{
bufpt = buf;
}
j = 0;
if( needQuote ) bufpt[j++] = '\'';
for(i=0; i<limit; i++){
bufpt[j++] = ch = escarg[i];
|
| ︙ | ︙ |
Changes to src/search.c.
| ︙ | ︙ | |||
40 41 42 43 44 45 46 |
*/
Search *search_init(const char *zPattern){
int nPattern = strlen(zPattern);
Search *p;
char *z;
int i;
| | < | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
*/
Search *search_init(const char *zPattern){
int nPattern = strlen(zPattern);
Search *p;
char *z;
int i;
p = fossil_malloc( nPattern + sizeof(*p) + 1);
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;
|
| ︙ | ︙ |
Changes to src/th_main.c.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 |
*/
static int nOutstandingMalloc = 0;
/*
** Implementations of malloc() and free() to pass to the interpreter.
*/
static void *xMalloc(unsigned int n){
| | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
*/
static int nOutstandingMalloc = 0;
/*
** Implementations of malloc() and free() to pass to the interpreter.
*/
static void *xMalloc(unsigned int n){
void *p = fossil_malloc(n);
if( p ){
nOutstandingMalloc++;
}
return p;
}
static void xFree(void *p){
if( p ){
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
51 52 53 54 55 56 57 |
int i;
if( nField>0 ) return;
db_prepare(&q, "PRAGMA table_info(ticket)");
while( db_step(&q)==SQLITE_ROW ){
const char *zField = db_column_text(&q, 1);
if( strncmp(zField,"tkt_",4)==0 ) continue;
if( nField%10==0 ){
| | < < < | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
int i;
if( nField>0 ) return;
db_prepare(&q, "PRAGMA table_info(ticket)");
while( db_step(&q)==SQLITE_ROW ){
const char *zField = db_column_text(&q, 1);
if( strncmp(zField,"tkt_",4)==0 ) continue;
if( nField%10==0 ){
azField = fossil_realloc(azField, sizeof(azField)*3*(nField+10) );
}
azField[nField] = mprintf("%s", zField);
nField++;
}
db_finalize(&q);
qsort(azField, nField, sizeof(azField[0]), nameCmpr);
azAppend = &azField[nField];
|
| ︙ | ︙ |
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
836 837 838 839 840 841 842 |
/*
** Push a new markup value onto the stack. Enlarge the stack
** if necessary.
*/
static void pushStackWithId(Renderer *p, int elem, const char *zId, int w){
if( p->nStack>=p->nAlloc ){
p->nAlloc = p->nAlloc*2 + 100;
| | < < < | 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
/*
** Push a new markup value onto the stack. Enlarge the stack
** if necessary.
*/
static void pushStackWithId(Renderer *p, int elem, const char *zId, int w){
if( p->nStack>=p->nAlloc ){
p->nAlloc = p->nAlloc*2 + 100;
p->aStack = fossil_realloc(p->aStack, p->nAlloc*sizeof(p->aStack[0]));
}
p->aStack[p->nStack].iCode = elem;
p->aStack[p->nStack].zId = zId;
p->aStack[p->nStack].allowWiki = w;
p->nStack++;
}
static void pushStack(Renderer *p, int elem){
|
| ︙ | ︙ |
Changes to src/winhttp.c.
| ︙ | ︙ | |||
107 108 109 110 111 112 113 |
break;
}
wanted -= got;
}
fclose(out);
out = 0;
sprintf(zCmd, "\"%s\" http \"%s\" %s %s %s%s",
| | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
break;
}
wanted -= got;
}
fclose(out);
out = 0;
sprintf(zCmd, "\"%s\" http \"%s\" %s %s %s%s",
_pgmptr, g.zRepositoryName, zRequestFName, zReplyFName,
inet_ntoa(p->addr.sin_addr), p->zNotFound
);
if( g.fHttpTrace ){
fprintf(stderr,"HTTPTRACE(%p): calling '%s'\n",pAppData,zCmd);
}
portable_system(zCmd);
in = fopen(zReplyFName, "rb");
|
| ︙ | ︙ | |||
218 219 220 221 222 223 224 |
if( zStopper && file_size(zStopper)>=0 ){
break;
}
if( client==INVALID_SOCKET ){
closesocket(s);
fossil_fatal("error from accept()");
}
| | < < < | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
if( zStopper && file_size(zStopper)>=0 ){
break;
}
if( client==INVALID_SOCKET ){
closesocket(s);
fossil_fatal("error from accept()");
}
p = fossil_malloc( sizeof(*p) );
p->id = ++idCnt;
p->s = client;
p->addr = client_addr;
p->zNotFound = zNotFoundOption;
if( g.fHttpTrace ){
fprintf(stderr,"HTTPTRACE(%p): start new request thread\n",p);
}
|
| ︙ | ︙ |
Changes to src/zip.c.
| ︙ | ︙ | |||
100 101 102 103 104 105 106 |
c = zName[i+1];
zName[i+1] = 0;
for(j=0; j<nDir; j++){
if( strcmp(zName, azDir[j])==0 ) break;
}
if( j>=nDir ){
nDir++;
| | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
c = zName[i+1];
zName[i+1] = 0;
for(j=0; j<nDir; j++){
if( strcmp(zName, azDir[j])==0 ) break;
}
if( j>=nDir ){
nDir++;
azDir = fossil_realloc(azDir, sizeof(azDir[0])*nDir);
azDir[j] = mprintf("%s", zName);
zip_add_file(zName, 0);
}
zName[i+1] = c;
}
}
}
|
| ︙ | ︙ |