Fossil SCM
Eliminated an unnecessary allocation. Code style conformance tweaks.
Commit
e2a9fe4bc87824ea2e793898c25847a246eda1c28150ad057cd807ded4bc4016
Parent
06c7d57d189e27d…
1 file changed
+11
-12
+11
-12
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -340,12 +340,12 @@ | ||
| 340 | 340 | const struct Submenu *A = (const struct Submenu*)a; |
| 341 | 341 | const struct Submenu *B = (const struct Submenu*)b; |
| 342 | 342 | return fossil_strcmp(A->zLabel, B->zLabel); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | -/* Use this for the $current_page variable if it is not NULL. If it is | |
| 346 | -** NULL then use g.zPath. | |
| 345 | +/* Use this for the $current_page variable if it is not NULL. If it | |
| 346 | +** is NULL then use g.zPath. | |
| 347 | 347 | */ |
| 348 | 348 | static char *local_zCurrentPage = 0; |
| 349 | 349 | |
| 350 | 350 | /* |
| 351 | 351 | ** Set the desired $current_page to something other than g.zPath |
| @@ -361,38 +361,37 @@ | ||
| 361 | 361 | va_end(ap); |
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /* |
| 366 | -** Create a TH1 variable containing the URL for the specified config resource. | |
| 367 | -** The resulting variable name will be of the form $[zVarPrefix]_url. | |
| 366 | +** Create a TH1 variable containing the URL for the specified config | |
| 367 | +** resource. The resulting variable name will be of the form | |
| 368 | +** $[zVarPrefix]_url. | |
| 368 | 369 | */ |
| 369 | 370 | static void url_var( |
| 370 | 371 | const char *zVarPrefix, |
| 371 | 372 | const char *zConfigName, |
| 372 | 373 | const char *zPageName |
| 373 | 374 | ){ |
| 374 | 375 | char *zVarName = mprintf("%s_url", zVarPrefix); |
| 375 | - char *zExtra = 0; | |
| 376 | - char *zUrl = 0; | |
| 376 | + char *zUrl = 0; /* stylesheet URL */ | |
| 377 | + int hasBuiltin = 0; /* true for built-in page-specific CSS */ | |
| 378 | + | |
| 377 | 379 | if(0==strcmp("css",zConfigName)){ |
| 378 | 380 | /* Account for page-specific CSS, appending a /{{g.zPath}} to the |
| 379 | 381 | ** url only if we have a corresponding built-in page-specific CSS |
| 380 | 382 | ** file. Do not append it to all pages because we would |
| 381 | 383 | ** effectively cache-bust all pages which do not have |
| 382 | 384 | ** page-specific CSS. */ |
| 383 | 385 | char * zBuiltin = mprintf("style.%s.css", g.zPath); |
| 384 | - if(builtin_file(zBuiltin,0)!=0){ | |
| 385 | - zExtra = mprintf("/%s", g.zPath); | |
| 386 | - } | |
| 386 | + hasBuiltin = builtin_file(zBuiltin,0)!=0; | |
| 387 | 387 | fossil_free(zBuiltin); |
| 388 | 388 | } |
| 389 | - zUrl = mprintf("%R/%s%s?id=%x", zPageName, | |
| 390 | - zExtra ? zExtra : "", | |
| 389 | + zUrl = mprintf("%R/%s%s%s?id=%x", zPageName, | |
| 390 | + hasBuiltin ? "/" : "", hasBuiltin ? g.zPath : "", | |
| 391 | 391 | skin_id(zConfigName)); |
| 392 | 392 | Th_Store(zVarName, zUrl); |
| 393 | - fossil_free(zExtra); | |
| 394 | 393 | fossil_free(zUrl); |
| 395 | 394 | fossil_free(zVarName); |
| 396 | 395 | } |
| 397 | 396 | |
| 398 | 397 | /* |
| 399 | 398 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -340,12 +340,12 @@ | |
| 340 | const struct Submenu *A = (const struct Submenu*)a; |
| 341 | const struct Submenu *B = (const struct Submenu*)b; |
| 342 | return fossil_strcmp(A->zLabel, B->zLabel); |
| 343 | } |
| 344 | |
| 345 | /* Use this for the $current_page variable if it is not NULL. If it is |
| 346 | ** NULL then use g.zPath. |
| 347 | */ |
| 348 | static char *local_zCurrentPage = 0; |
| 349 | |
| 350 | /* |
| 351 | ** Set the desired $current_page to something other than g.zPath |
| @@ -361,38 +361,37 @@ | |
| 361 | va_end(ap); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 | ** Create a TH1 variable containing the URL for the specified config resource. |
| 367 | ** The resulting variable name will be of the form $[zVarPrefix]_url. |
| 368 | */ |
| 369 | static void url_var( |
| 370 | const char *zVarPrefix, |
| 371 | const char *zConfigName, |
| 372 | const char *zPageName |
| 373 | ){ |
| 374 | char *zVarName = mprintf("%s_url", zVarPrefix); |
| 375 | char *zExtra = 0; |
| 376 | char *zUrl = 0; |
| 377 | if(0==strcmp("css",zConfigName)){ |
| 378 | /* Account for page-specific CSS, appending a /{{g.zPath}} to the |
| 379 | ** url only if we have a corresponding built-in page-specific CSS |
| 380 | ** file. Do not append it to all pages because we would |
| 381 | ** effectively cache-bust all pages which do not have |
| 382 | ** page-specific CSS. */ |
| 383 | char * zBuiltin = mprintf("style.%s.css", g.zPath); |
| 384 | if(builtin_file(zBuiltin,0)!=0){ |
| 385 | zExtra = mprintf("/%s", g.zPath); |
| 386 | } |
| 387 | fossil_free(zBuiltin); |
| 388 | } |
| 389 | zUrl = mprintf("%R/%s%s?id=%x", zPageName, |
| 390 | zExtra ? zExtra : "", |
| 391 | skin_id(zConfigName)); |
| 392 | Th_Store(zVarName, zUrl); |
| 393 | fossil_free(zExtra); |
| 394 | fossil_free(zUrl); |
| 395 | fossil_free(zVarName); |
| 396 | } |
| 397 | |
| 398 | /* |
| 399 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -340,12 +340,12 @@ | |
| 340 | const struct Submenu *A = (const struct Submenu*)a; |
| 341 | const struct Submenu *B = (const struct Submenu*)b; |
| 342 | return fossil_strcmp(A->zLabel, B->zLabel); |
| 343 | } |
| 344 | |
| 345 | /* Use this for the $current_page variable if it is not NULL. If it |
| 346 | ** is NULL then use g.zPath. |
| 347 | */ |
| 348 | static char *local_zCurrentPage = 0; |
| 349 | |
| 350 | /* |
| 351 | ** Set the desired $current_page to something other than g.zPath |
| @@ -361,38 +361,37 @@ | |
| 361 | va_end(ap); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 | ** Create a TH1 variable containing the URL for the specified config |
| 367 | ** resource. The resulting variable name will be of the form |
| 368 | ** $[zVarPrefix]_url. |
| 369 | */ |
| 370 | static void url_var( |
| 371 | const char *zVarPrefix, |
| 372 | const char *zConfigName, |
| 373 | const char *zPageName |
| 374 | ){ |
| 375 | char *zVarName = mprintf("%s_url", zVarPrefix); |
| 376 | char *zUrl = 0; /* stylesheet URL */ |
| 377 | int hasBuiltin = 0; /* true for built-in page-specific CSS */ |
| 378 | |
| 379 | if(0==strcmp("css",zConfigName)){ |
| 380 | /* Account for page-specific CSS, appending a /{{g.zPath}} to the |
| 381 | ** url only if we have a corresponding built-in page-specific CSS |
| 382 | ** file. Do not append it to all pages because we would |
| 383 | ** effectively cache-bust all pages which do not have |
| 384 | ** page-specific CSS. */ |
| 385 | char * zBuiltin = mprintf("style.%s.css", g.zPath); |
| 386 | hasBuiltin = builtin_file(zBuiltin,0)!=0; |
| 387 | fossil_free(zBuiltin); |
| 388 | } |
| 389 | zUrl = mprintf("%R/%s%s%s?id=%x", zPageName, |
| 390 | hasBuiltin ? "/" : "", hasBuiltin ? g.zPath : "", |
| 391 | skin_id(zConfigName)); |
| 392 | Th_Store(zVarName, zUrl); |
| 393 | fossil_free(zUrl); |
| 394 | fossil_free(zVarName); |
| 395 | } |
| 396 | |
| 397 | /* |
| 398 |