Fossil SCM
When compiling with FOSSIL_DEBUG (from the --fossil-debug configure option) do not attempt to "compress" built-in javascript by removing comments and surplus whitespace. This makes the javascript easier to read in a debugger.
Commit
41b9873b4306723aea4c95083b7d7a9c7a9fd242b066dbb6b4c9dd8449ac3501
Parent
b699040d701464c…
1 file changed
+6
+6
| --- src/mkbuiltin.c | ||
| +++ src/mkbuiltin.c | ||
| @@ -62,10 +62,11 @@ | ||
| 62 | 62 | fclose(in); |
| 63 | 63 | z[got] = 0; |
| 64 | 64 | return z; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | +#ifndef FOSSIL_DEBUG | |
| 67 | 68 | /* |
| 68 | 69 | ** Try to compress a javascript file by removing unnecessary whitespace. |
| 69 | 70 | ** |
| 70 | 71 | ** Warning: This compression routine does not necessarily work for any |
| 71 | 72 | ** arbitrary Javascript source file. But it should work ok for the |
| @@ -99,10 +100,11 @@ | ||
| 99 | 100 | z[j++] = c; |
| 100 | 101 | } |
| 101 | 102 | z[j] = 0; |
| 102 | 103 | *pn = j; |
| 103 | 104 | } |
| 105 | +#endif /* FOSSIL_DEBUG */ | |
| 104 | 106 | |
| 105 | 107 | /* |
| 106 | 108 | ** There is an instance of the following for each file translated. |
| 107 | 109 | */ |
| 108 | 110 | typedef struct Resource Resource; |
| @@ -279,11 +281,13 @@ | ||
| 279 | 281 | int nRes; |
| 280 | 282 | unsigned char *pData; |
| 281 | 283 | int nErr = 0; |
| 282 | 284 | int nSkip; |
| 283 | 285 | int nPrefix = 0; |
| 286 | +#ifndef FOSSIL_DEBUG | |
| 284 | 287 | int nName; |
| 288 | +#endif | |
| 285 | 289 | |
| 286 | 290 | if( argc==1 ){ |
| 287 | 291 | fprintf(stderr, "usage\t:%s " |
| 288 | 292 | "[--prefix path] [--reslist file] [resource-file1 ...]\n", |
| 289 | 293 | argv[0] |
| @@ -350,19 +354,21 @@ | ||
| 350 | 354 | while( pData[nSkip]=='#' ){ |
| 351 | 355 | while( pData[nSkip]!=0 && pData[nSkip]!='\n' ){ nSkip++; } |
| 352 | 356 | if( pData[nSkip]=='\n' ) nSkip++; |
| 353 | 357 | } |
| 354 | 358 | |
| 359 | +#ifndef FOSSIL_DEBUG | |
| 355 | 360 | /* Compress javascript source files */ |
| 356 | 361 | nName = (int)strlen(aRes[i].zName); |
| 357 | 362 | if( (nName>3 && strcmp(&aRes[i].zName[nName-3],".js")==0) |
| 358 | 363 | || (nName>7 && strcmp(&aRes[i].zName[nName-7], "/js.txt")==0) |
| 359 | 364 | ){ |
| 360 | 365 | int x = sz-nSkip; |
| 361 | 366 | compressJavascript(pData+nSkip, &x); |
| 362 | 367 | sz = x + nSkip; |
| 363 | 368 | } |
| 369 | +#endif | |
| 364 | 370 | |
| 365 | 371 | aRes[i].nByte = sz - nSkip; |
| 366 | 372 | aRes[i].idx = i; |
| 367 | 373 | printf("/* Content of file %s */\n", aRes[i].zName); |
| 368 | 374 | printf("static const unsigned char bidata%d[%d] = {\n ", |
| 369 | 375 |
| --- src/mkbuiltin.c | |
| +++ src/mkbuiltin.c | |
| @@ -62,10 +62,11 @@ | |
| 62 | fclose(in); |
| 63 | z[got] = 0; |
| 64 | return z; |
| 65 | } |
| 66 | |
| 67 | /* |
| 68 | ** Try to compress a javascript file by removing unnecessary whitespace. |
| 69 | ** |
| 70 | ** Warning: This compression routine does not necessarily work for any |
| 71 | ** arbitrary Javascript source file. But it should work ok for the |
| @@ -99,10 +100,11 @@ | |
| 99 | z[j++] = c; |
| 100 | } |
| 101 | z[j] = 0; |
| 102 | *pn = j; |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | ** There is an instance of the following for each file translated. |
| 107 | */ |
| 108 | typedef struct Resource Resource; |
| @@ -279,11 +281,13 @@ | |
| 279 | int nRes; |
| 280 | unsigned char *pData; |
| 281 | int nErr = 0; |
| 282 | int nSkip; |
| 283 | int nPrefix = 0; |
| 284 | int nName; |
| 285 | |
| 286 | if( argc==1 ){ |
| 287 | fprintf(stderr, "usage\t:%s " |
| 288 | "[--prefix path] [--reslist file] [resource-file1 ...]\n", |
| 289 | argv[0] |
| @@ -350,19 +354,21 @@ | |
| 350 | while( pData[nSkip]=='#' ){ |
| 351 | while( pData[nSkip]!=0 && pData[nSkip]!='\n' ){ nSkip++; } |
| 352 | if( pData[nSkip]=='\n' ) nSkip++; |
| 353 | } |
| 354 | |
| 355 | /* Compress javascript source files */ |
| 356 | nName = (int)strlen(aRes[i].zName); |
| 357 | if( (nName>3 && strcmp(&aRes[i].zName[nName-3],".js")==0) |
| 358 | || (nName>7 && strcmp(&aRes[i].zName[nName-7], "/js.txt")==0) |
| 359 | ){ |
| 360 | int x = sz-nSkip; |
| 361 | compressJavascript(pData+nSkip, &x); |
| 362 | sz = x + nSkip; |
| 363 | } |
| 364 | |
| 365 | aRes[i].nByte = sz - nSkip; |
| 366 | aRes[i].idx = i; |
| 367 | printf("/* Content of file %s */\n", aRes[i].zName); |
| 368 | printf("static const unsigned char bidata%d[%d] = {\n ", |
| 369 |
| --- src/mkbuiltin.c | |
| +++ src/mkbuiltin.c | |
| @@ -62,10 +62,11 @@ | |
| 62 | fclose(in); |
| 63 | z[got] = 0; |
| 64 | return z; |
| 65 | } |
| 66 | |
| 67 | #ifndef FOSSIL_DEBUG |
| 68 | /* |
| 69 | ** Try to compress a javascript file by removing unnecessary whitespace. |
| 70 | ** |
| 71 | ** Warning: This compression routine does not necessarily work for any |
| 72 | ** arbitrary Javascript source file. But it should work ok for the |
| @@ -99,10 +100,11 @@ | |
| 100 | z[j++] = c; |
| 101 | } |
| 102 | z[j] = 0; |
| 103 | *pn = j; |
| 104 | } |
| 105 | #endif /* FOSSIL_DEBUG */ |
| 106 | |
| 107 | /* |
| 108 | ** There is an instance of the following for each file translated. |
| 109 | */ |
| 110 | typedef struct Resource Resource; |
| @@ -279,11 +281,13 @@ | |
| 281 | int nRes; |
| 282 | unsigned char *pData; |
| 283 | int nErr = 0; |
| 284 | int nSkip; |
| 285 | int nPrefix = 0; |
| 286 | #ifndef FOSSIL_DEBUG |
| 287 | int nName; |
| 288 | #endif |
| 289 | |
| 290 | if( argc==1 ){ |
| 291 | fprintf(stderr, "usage\t:%s " |
| 292 | "[--prefix path] [--reslist file] [resource-file1 ...]\n", |
| 293 | argv[0] |
| @@ -350,19 +354,21 @@ | |
| 354 | while( pData[nSkip]=='#' ){ |
| 355 | while( pData[nSkip]!=0 && pData[nSkip]!='\n' ){ nSkip++; } |
| 356 | if( pData[nSkip]=='\n' ) nSkip++; |
| 357 | } |
| 358 | |
| 359 | #ifndef FOSSIL_DEBUG |
| 360 | /* Compress javascript source files */ |
| 361 | nName = (int)strlen(aRes[i].zName); |
| 362 | if( (nName>3 && strcmp(&aRes[i].zName[nName-3],".js")==0) |
| 363 | || (nName>7 && strcmp(&aRes[i].zName[nName-7], "/js.txt")==0) |
| 364 | ){ |
| 365 | int x = sz-nSkip; |
| 366 | compressJavascript(pData+nSkip, &x); |
| 367 | sz = x + nSkip; |
| 368 | } |
| 369 | #endif |
| 370 | |
| 371 | aRes[i].nByte = sz - nSkip; |
| 372 | aRes[i].idx = i; |
| 373 | printf("/* Content of file %s */\n", aRes[i].zName); |
| 374 | printf("static const unsigned char bidata%d[%d] = {\n ", |
| 375 |