Fossil SCM
Merge in updates from trunk. Some implementation simplifications and more comments (mainly in the SQLite part).
Commit
9cc1c9d6904103f4b89e869ae93eaa8efeaeb2d0
Parent
abb24004341aa5e…
61 files changed
+1
-1
+1
-1
+2
-13
+20
-20
+19
-23
+1
-1
+17
-17
+2
-8
-6
+52
-35
+1
-1
+1
-1
+1
-1
+100
-26
+67
-26
+27
-23
+4
-2
+25
-25
+6
-6
+3
-11
+1
-1
+1
-1
+15
-15
+2
-2
+26
-25
+37
-35
+1
-1
+8
-10
+267
-15
+2
-2
+119
-115
+119
-115
+2
-2
+1
-1
+5
-9
-6
+14
-12
+8
-4
+7
-7
+24
+32
+39
-24
+11
+40
-33
+40
-33
+12
-12
+14
-14
+15
-3
+7
-7
+39
-39
+5
-5
+6
-6
+6
-6
+2
-2
+2
-2
+65
+65
+2
-2
+2
-2
+11
-1
+3
-1
~
src/bag.c
~
src/bisect.c
~
src/branch.c
~
src/captcha.c
~
src/cgi.c
~
src/comformat.c
~
src/content.c
~
src/db.c
~
src/descendants.c
~
src/diffcmd.c
~
src/file.c
~
src/finfo.c
~
src/gzip.c
~
src/http_ssl.c
~
src/info.c
~
src/login.c
~
src/main.c
~
src/manifest.c
~
src/markdown.c
~
src/merge.c
~
src/merge3.c
~
src/moderate.c
~
src/name.c
~
src/printf.c
~
src/rebuild.c
~
src/report.c
~
src/search.c
~
src/setup.c
~
src/shell.c
~
src/sqlcmd.c
~
src/sqlite3.c
~
src/sqlite3.c
~
src/sqlite3.h
~
src/stash.c
~
src/style.c
~
src/tag.c
~
src/th.c
~
src/th.h
~
src/th_lang.c
~
src/th_main.c
~
src/th_tcl.c
~
src/timeline.c
~
src/url.c
~
src/utf8.c
~
src/utf8.c
~
src/vfile.c
~
src/wiki.c
~
src/winhttp.c
~
src/wysiwyg.c
~
src/xfer.c
~
src/zip.c
~
test/merge_renames.test
~
test/merge_renames.test
~
test/revert.test
~
test/revert.test
~
test/th1.test
~
test/th1.test
~
win/Makefile.mingw.mistachkin
~
win/Makefile.mingw.mistachkin
~
www/changes.wiki
~
www/sync.wiki
+1
-1
| --- src/bag.c | ||
| +++ src/bag.c | ||
| @@ -75,11 +75,11 @@ | ||
| 75 | 75 | /* |
| 76 | 76 | ** Change the size of the hash table on a bag so that |
| 77 | 77 | ** it contains N slots |
| 78 | 78 | ** |
| 79 | 79 | ** Completely reconstruct the hash table from scratch. Deleted |
| 80 | -** entries (indicated by a -1) are removed. When finished, it | |
| 80 | +** entries (indicated by a -1) are removed. When finished, it | |
| 81 | 81 | ** should be the case that p->cnt==p->used. |
| 82 | 82 | */ |
| 83 | 83 | static void bag_resize(Bag *p, int newSize){ |
| 84 | 84 | int i; |
| 85 | 85 | Bag old; |
| 86 | 86 |
| --- src/bag.c | |
| +++ src/bag.c | |
| @@ -75,11 +75,11 @@ | |
| 75 | /* |
| 76 | ** Change the size of the hash table on a bag so that |
| 77 | ** it contains N slots |
| 78 | ** |
| 79 | ** Completely reconstruct the hash table from scratch. Deleted |
| 80 | ** entries (indicated by a -1) are removed. When finished, it |
| 81 | ** should be the case that p->cnt==p->used. |
| 82 | */ |
| 83 | static void bag_resize(Bag *p, int newSize){ |
| 84 | int i; |
| 85 | Bag old; |
| 86 |
| --- src/bag.c | |
| +++ src/bag.c | |
| @@ -75,11 +75,11 @@ | |
| 75 | /* |
| 76 | ** Change the size of the hash table on a bag so that |
| 77 | ** it contains N slots |
| 78 | ** |
| 79 | ** Completely reconstruct the hash table from scratch. Deleted |
| 80 | ** entries (indicated by a -1) are removed. When finished, it |
| 81 | ** should be the case that p->cnt==p->used. |
| 82 | */ |
| 83 | static void bag_resize(Bag *p, int newSize){ |
| 84 | int i; |
| 85 | Bag old; |
| 86 |
+1
-1
| --- src/bisect.c | ||
| +++ src/bisect.c | ||
| @@ -370,11 +370,11 @@ | ||
| 370 | 370 | g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid); |
| 371 | 371 | g.argc = 3; |
| 372 | 372 | g.fNoSync = 1; |
| 373 | 373 | update_cmd(); |
| 374 | 374 | } |
| 375 | - | |
| 375 | + | |
| 376 | 376 | if( strncmp(zDisplay,"chart",m)==0 ){ |
| 377 | 377 | bisect_chart(1); |
| 378 | 378 | }else if( strncmp(zDisplay, "log", m)==0 ){ |
| 379 | 379 | bisect_chart(0); |
| 380 | 380 | }else if( strncmp(zDisplay, "status", m)==0 ){ |
| 381 | 381 |
| --- src/bisect.c | |
| +++ src/bisect.c | |
| @@ -370,11 +370,11 @@ | |
| 370 | g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid); |
| 371 | g.argc = 3; |
| 372 | g.fNoSync = 1; |
| 373 | update_cmd(); |
| 374 | } |
| 375 | |
| 376 | if( strncmp(zDisplay,"chart",m)==0 ){ |
| 377 | bisect_chart(1); |
| 378 | }else if( strncmp(zDisplay, "log", m)==0 ){ |
| 379 | bisect_chart(0); |
| 380 | }else if( strncmp(zDisplay, "status", m)==0 ){ |
| 381 |
| --- src/bisect.c | |
| +++ src/bisect.c | |
| @@ -370,11 +370,11 @@ | |
| 370 | g.argv[2] = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", pMid->rid); |
| 371 | g.argc = 3; |
| 372 | g.fNoSync = 1; |
| 373 | update_cmd(); |
| 374 | } |
| 375 | |
| 376 | if( strncmp(zDisplay,"chart",m)==0 ){ |
| 377 | bisect_chart(1); |
| 378 | }else if( strncmp(zDisplay, "log", m)==0 ){ |
| 379 | bisect_chart(0); |
| 380 | }else if( strncmp(zDisplay, "status", m)==0 ){ |
| 381 |
+2
-13
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -51,11 +51,12 @@ | ||
| 51 | 51 | verify_all_options(); |
| 52 | 52 | if( g.argc<5 ){ |
| 53 | 53 | usage("new BRANCH-NAME BASIS ?OPTIONS?"); |
| 54 | 54 | } |
| 55 | 55 | db_find_and_open_repository(0, 0); |
| 56 | - noSign = db_get_int("omitsign", 0)|noSign; | |
| 56 | + noSign = db_get_boolean("omitsign", 0)|noSign; | |
| 57 | + if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } | |
| 57 | 58 | |
| 58 | 59 | /* fossil branch new name */ |
| 59 | 60 | zBranch = g.argv[3]; |
| 60 | 61 | if( zBranch==0 || zBranch[0]==0 ){ |
| 61 | 62 | fossil_fatal("branch name cannot be empty"); |
| @@ -367,16 +368,10 @@ | ||
| 367 | 368 | } |
| 368 | 369 | if( cnt ){ |
| 369 | 370 | @ </ul> |
| 370 | 371 | } |
| 371 | 372 | db_finalize(&q); |
| 372 | - @ <script type="text/JavaScript"> | |
| 373 | - @ function xin(id){ | |
| 374 | - @ } | |
| 375 | - @ function xout(id){ | |
| 376 | - @ } | |
| 377 | - @ </script> | |
| 378 | 373 | style_footer(); |
| 379 | 374 | } |
| 380 | 375 | |
| 381 | 376 | /* |
| 382 | 377 | ** This routine is called while for each check-in that is rendered by |
| @@ -422,13 +417,7 @@ | ||
| 422 | 417 | " ORDER BY event.mtime DESC", |
| 423 | 418 | timeline_query_for_www(), TAG_BRANCH |
| 424 | 419 | ); |
| 425 | 420 | www_print_timeline(&q, 0, 0, 0, brtimeline_extra); |
| 426 | 421 | db_finalize(&q); |
| 427 | - @ <script type="text/JavaScript"> | |
| 428 | - @ function xin(id){ | |
| 429 | - @ } | |
| 430 | - @ function xout(id){ | |
| 431 | - @ } | |
| 432 | - @ </script> | |
| 433 | 422 | style_footer(); |
| 434 | 423 | } |
| 435 | 424 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -51,11 +51,12 @@ | |
| 51 | verify_all_options(); |
| 52 | if( g.argc<5 ){ |
| 53 | usage("new BRANCH-NAME BASIS ?OPTIONS?"); |
| 54 | } |
| 55 | db_find_and_open_repository(0, 0); |
| 56 | noSign = db_get_int("omitsign", 0)|noSign; |
| 57 | |
| 58 | /* fossil branch new name */ |
| 59 | zBranch = g.argv[3]; |
| 60 | if( zBranch==0 || zBranch[0]==0 ){ |
| 61 | fossil_fatal("branch name cannot be empty"); |
| @@ -367,16 +368,10 @@ | |
| 367 | } |
| 368 | if( cnt ){ |
| 369 | @ </ul> |
| 370 | } |
| 371 | db_finalize(&q); |
| 372 | @ <script type="text/JavaScript"> |
| 373 | @ function xin(id){ |
| 374 | @ } |
| 375 | @ function xout(id){ |
| 376 | @ } |
| 377 | @ </script> |
| 378 | style_footer(); |
| 379 | } |
| 380 | |
| 381 | /* |
| 382 | ** This routine is called while for each check-in that is rendered by |
| @@ -422,13 +417,7 @@ | |
| 422 | " ORDER BY event.mtime DESC", |
| 423 | timeline_query_for_www(), TAG_BRANCH |
| 424 | ); |
| 425 | www_print_timeline(&q, 0, 0, 0, brtimeline_extra); |
| 426 | db_finalize(&q); |
| 427 | @ <script type="text/JavaScript"> |
| 428 | @ function xin(id){ |
| 429 | @ } |
| 430 | @ function xout(id){ |
| 431 | @ } |
| 432 | @ </script> |
| 433 | style_footer(); |
| 434 | } |
| 435 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -51,11 +51,12 @@ | |
| 51 | verify_all_options(); |
| 52 | if( g.argc<5 ){ |
| 53 | usage("new BRANCH-NAME BASIS ?OPTIONS?"); |
| 54 | } |
| 55 | db_find_and_open_repository(0, 0); |
| 56 | noSign = db_get_boolean("omitsign", 0)|noSign; |
| 57 | if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; } |
| 58 | |
| 59 | /* fossil branch new name */ |
| 60 | zBranch = g.argv[3]; |
| 61 | if( zBranch==0 || zBranch[0]==0 ){ |
| 62 | fossil_fatal("branch name cannot be empty"); |
| @@ -367,16 +368,10 @@ | |
| 368 | } |
| 369 | if( cnt ){ |
| 370 | @ </ul> |
| 371 | } |
| 372 | db_finalize(&q); |
| 373 | style_footer(); |
| 374 | } |
| 375 | |
| 376 | /* |
| 377 | ** This routine is called while for each check-in that is rendered by |
| @@ -422,13 +417,7 @@ | |
| 417 | " ORDER BY event.mtime DESC", |
| 418 | timeline_query_for_www(), TAG_BRANCH |
| 419 | ); |
| 420 | www_print_timeline(&q, 0, 0, 0, brtimeline_extra); |
| 421 | db_finalize(&q); |
| 422 | style_footer(); |
| 423 | } |
| 424 |
+20
-20
| --- src/captcha.c | ||
| +++ src/captcha.c | ||
| @@ -92,11 +92,11 @@ | ||
| 92 | 92 | z[k++] = ' '; |
| 93 | 93 | } |
| 94 | 94 | z[k++] = '\n'; |
| 95 | 95 | } |
| 96 | 96 | z[k] = 0; |
| 97 | - return z; | |
| 97 | + return z; | |
| 98 | 98 | } |
| 99 | 99 | #endif /* CAPTCHA==1 */ |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | #if CAPTCHA==2 |
| @@ -148,11 +148,11 @@ | ||
| 148 | 148 | "|__ |", |
| 149 | 149 | " / / ", |
| 150 | 150 | " /_/ ", |
| 151 | 151 | |
| 152 | 152 | /* 8 */ |
| 153 | - " ___ ", | |
| 153 | + " ___ ", | |
| 154 | 154 | "( _ )", |
| 155 | 155 | "/ _ \\", |
| 156 | 156 | "\\___/", |
| 157 | 157 | |
| 158 | 158 | /* 9 */ |
| @@ -218,11 +218,11 @@ | ||
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | z[k++] = '\n'; |
| 221 | 221 | } |
| 222 | 222 | z[k] = 0; |
| 223 | - return z; | |
| 223 | + return z; | |
| 224 | 224 | } |
| 225 | 225 | #endif /* CAPTCHA==2 */ |
| 226 | 226 | |
| 227 | 227 | #if CAPTCHA==3 |
| 228 | 228 | static const char *const azFont3[] = { |
| @@ -231,123 +231,123 @@ | ||
| 231 | 231 | " / _ \\ ", |
| 232 | 232 | "| | | |", |
| 233 | 233 | "| | | |", |
| 234 | 234 | "| |_| |", |
| 235 | 235 | " \\___/ ", |
| 236 | - | |
| 236 | + | |
| 237 | 237 | /* 1 */ |
| 238 | 238 | " __ ", |
| 239 | 239 | "/_ |", |
| 240 | 240 | " | |", |
| 241 | 241 | " | |", |
| 242 | 242 | " | |", |
| 243 | 243 | " |_|", |
| 244 | - | |
| 244 | + | |
| 245 | 245 | /* 2 */ |
| 246 | 246 | " ___ ", |
| 247 | 247 | "|__ \\ ", |
| 248 | 248 | " ) |", |
| 249 | 249 | " / / ", |
| 250 | 250 | " / /_ ", |
| 251 | 251 | "|____|", |
| 252 | - | |
| 252 | + | |
| 253 | 253 | /* 3 */ |
| 254 | 254 | " ____ ", |
| 255 | 255 | "|___ \\ ", |
| 256 | 256 | " __) |", |
| 257 | 257 | " |__ < ", |
| 258 | 258 | " ___) |", |
| 259 | 259 | "|____/ ", |
| 260 | - | |
| 260 | + | |
| 261 | 261 | /* 4 */ |
| 262 | 262 | " _ _ ", |
| 263 | 263 | "| || | ", |
| 264 | 264 | "| || |_ ", |
| 265 | 265 | "|__ _|", |
| 266 | 266 | " | | ", |
| 267 | 267 | " |_| ", |
| 268 | - | |
| 268 | + | |
| 269 | 269 | /* 5 */ |
| 270 | 270 | " _____ ", |
| 271 | 271 | "| ____|", |
| 272 | 272 | "| |__ ", |
| 273 | 273 | "|___ \\ ", |
| 274 | 274 | " ___) |", |
| 275 | 275 | "|____/ ", |
| 276 | - | |
| 276 | + | |
| 277 | 277 | /* 6 */ |
| 278 | 278 | " __ ", |
| 279 | 279 | " / / ", |
| 280 | 280 | " / /_ ", |
| 281 | 281 | "| '_ \\ ", |
| 282 | 282 | "| (_) |", |
| 283 | 283 | " \\___/ ", |
| 284 | - | |
| 284 | + | |
| 285 | 285 | /* 7 */ |
| 286 | 286 | " ______ ", |
| 287 | 287 | "|____ |", |
| 288 | 288 | " / / ", |
| 289 | 289 | " / / ", |
| 290 | 290 | " / / ", |
| 291 | 291 | " /_/ ", |
| 292 | - | |
| 292 | + | |
| 293 | 293 | /* 8 */ |
| 294 | 294 | " ___ ", |
| 295 | 295 | " / _ \\ ", |
| 296 | 296 | "| (_) |", |
| 297 | 297 | " > _ < ", |
| 298 | 298 | "| (_) |", |
| 299 | 299 | " \\___/ ", |
| 300 | - | |
| 300 | + | |
| 301 | 301 | /* 9 */ |
| 302 | 302 | " ___ ", |
| 303 | 303 | " / _ \\ ", |
| 304 | 304 | "| (_) |", |
| 305 | 305 | " \\__, |", |
| 306 | 306 | " / / ", |
| 307 | 307 | " /_/ ", |
| 308 | - | |
| 308 | + | |
| 309 | 309 | /* A */ |
| 310 | 310 | " ", |
| 311 | 311 | " /\\ ", |
| 312 | 312 | " / \\ ", |
| 313 | 313 | " / /\\ \\ ", |
| 314 | 314 | " / ____ \\ ", |
| 315 | 315 | "/_/ \\_\\", |
| 316 | - | |
| 316 | + | |
| 317 | 317 | /* B */ |
| 318 | 318 | " ____ ", |
| 319 | 319 | "| _ \\ ", |
| 320 | 320 | "| |_) |", |
| 321 | 321 | "| _ < ", |
| 322 | 322 | "| |_) |", |
| 323 | 323 | "|____/ ", |
| 324 | - | |
| 324 | + | |
| 325 | 325 | /* C */ |
| 326 | 326 | " _____ ", |
| 327 | 327 | " / ____|", |
| 328 | 328 | "| | ", |
| 329 | 329 | "| | ", |
| 330 | 330 | "| |____ ", |
| 331 | 331 | " \\_____|", |
| 332 | - | |
| 332 | + | |
| 333 | 333 | /* D */ |
| 334 | 334 | " _____ ", |
| 335 | 335 | "| __ \\ ", |
| 336 | 336 | "| | | |", |
| 337 | 337 | "| | | |", |
| 338 | 338 | "| |__| |", |
| 339 | 339 | "|_____/ ", |
| 340 | - | |
| 340 | + | |
| 341 | 341 | /* E */ |
| 342 | 342 | " ______ ", |
| 343 | 343 | "| ____|", |
| 344 | 344 | "| |__ ", |
| 345 | 345 | "| __| ", |
| 346 | 346 | "| |____ ", |
| 347 | 347 | "|______|", |
| 348 | - | |
| 348 | + | |
| 349 | 349 | /* F */ |
| 350 | 350 | " ______ ", |
| 351 | 351 | "| ____|", |
| 352 | 352 | "| |__ ", |
| 353 | 353 | "| __| ", |
| @@ -408,11 +408,11 @@ | ||
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | z[k++] = '\n'; |
| 411 | 411 | } |
| 412 | 412 | z[k] = 0; |
| 413 | - return z; | |
| 413 | + return z; | |
| 414 | 414 | } |
| 415 | 415 | #endif /* CAPTCHA==3 */ |
| 416 | 416 | |
| 417 | 417 | /* |
| 418 | 418 | ** COMMAND: test-captcha |
| @@ -478,11 +478,11 @@ | ||
| 478 | 478 | ** Return true if a CAPTCHA is required for editing wiki or tickets or for |
| 479 | 479 | ** adding attachments. |
| 480 | 480 | ** |
| 481 | 481 | ** A CAPTCHA is required in those cases if the user is not logged in (if they |
| 482 | 482 | ** are user "nobody") and if the "require-captcha" setting is true. The |
| 483 | -** "require-captcha" setting is controlled on the Admin/Access page. It | |
| 483 | +** "require-captcha" setting is controlled on the Admin/Access page. It | |
| 484 | 484 | ** defaults to true. |
| 485 | 485 | */ |
| 486 | 486 | int captcha_needed(void){ |
| 487 | 487 | if( g.zLogin!=0 ) return 0; |
| 488 | 488 | return db_get_boolean("require-captcha", 1); |
| 489 | 489 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -92,11 +92,11 @@ | |
| 92 | z[k++] = ' '; |
| 93 | } |
| 94 | z[k++] = '\n'; |
| 95 | } |
| 96 | z[k] = 0; |
| 97 | return z; |
| 98 | } |
| 99 | #endif /* CAPTCHA==1 */ |
| 100 | |
| 101 | |
| 102 | #if CAPTCHA==2 |
| @@ -148,11 +148,11 @@ | |
| 148 | "|__ |", |
| 149 | " / / ", |
| 150 | " /_/ ", |
| 151 | |
| 152 | /* 8 */ |
| 153 | " ___ ", |
| 154 | "( _ )", |
| 155 | "/ _ \\", |
| 156 | "\\___/", |
| 157 | |
| 158 | /* 9 */ |
| @@ -218,11 +218,11 @@ | |
| 218 | } |
| 219 | } |
| 220 | z[k++] = '\n'; |
| 221 | } |
| 222 | z[k] = 0; |
| 223 | return z; |
| 224 | } |
| 225 | #endif /* CAPTCHA==2 */ |
| 226 | |
| 227 | #if CAPTCHA==3 |
| 228 | static const char *const azFont3[] = { |
| @@ -231,123 +231,123 @@ | |
| 231 | " / _ \\ ", |
| 232 | "| | | |", |
| 233 | "| | | |", |
| 234 | "| |_| |", |
| 235 | " \\___/ ", |
| 236 | |
| 237 | /* 1 */ |
| 238 | " __ ", |
| 239 | "/_ |", |
| 240 | " | |", |
| 241 | " | |", |
| 242 | " | |", |
| 243 | " |_|", |
| 244 | |
| 245 | /* 2 */ |
| 246 | " ___ ", |
| 247 | "|__ \\ ", |
| 248 | " ) |", |
| 249 | " / / ", |
| 250 | " / /_ ", |
| 251 | "|____|", |
| 252 | |
| 253 | /* 3 */ |
| 254 | " ____ ", |
| 255 | "|___ \\ ", |
| 256 | " __) |", |
| 257 | " |__ < ", |
| 258 | " ___) |", |
| 259 | "|____/ ", |
| 260 | |
| 261 | /* 4 */ |
| 262 | " _ _ ", |
| 263 | "| || | ", |
| 264 | "| || |_ ", |
| 265 | "|__ _|", |
| 266 | " | | ", |
| 267 | " |_| ", |
| 268 | |
| 269 | /* 5 */ |
| 270 | " _____ ", |
| 271 | "| ____|", |
| 272 | "| |__ ", |
| 273 | "|___ \\ ", |
| 274 | " ___) |", |
| 275 | "|____/ ", |
| 276 | |
| 277 | /* 6 */ |
| 278 | " __ ", |
| 279 | " / / ", |
| 280 | " / /_ ", |
| 281 | "| '_ \\ ", |
| 282 | "| (_) |", |
| 283 | " \\___/ ", |
| 284 | |
| 285 | /* 7 */ |
| 286 | " ______ ", |
| 287 | "|____ |", |
| 288 | " / / ", |
| 289 | " / / ", |
| 290 | " / / ", |
| 291 | " /_/ ", |
| 292 | |
| 293 | /* 8 */ |
| 294 | " ___ ", |
| 295 | " / _ \\ ", |
| 296 | "| (_) |", |
| 297 | " > _ < ", |
| 298 | "| (_) |", |
| 299 | " \\___/ ", |
| 300 | |
| 301 | /* 9 */ |
| 302 | " ___ ", |
| 303 | " / _ \\ ", |
| 304 | "| (_) |", |
| 305 | " \\__, |", |
| 306 | " / / ", |
| 307 | " /_/ ", |
| 308 | |
| 309 | /* A */ |
| 310 | " ", |
| 311 | " /\\ ", |
| 312 | " / \\ ", |
| 313 | " / /\\ \\ ", |
| 314 | " / ____ \\ ", |
| 315 | "/_/ \\_\\", |
| 316 | |
| 317 | /* B */ |
| 318 | " ____ ", |
| 319 | "| _ \\ ", |
| 320 | "| |_) |", |
| 321 | "| _ < ", |
| 322 | "| |_) |", |
| 323 | "|____/ ", |
| 324 | |
| 325 | /* C */ |
| 326 | " _____ ", |
| 327 | " / ____|", |
| 328 | "| | ", |
| 329 | "| | ", |
| 330 | "| |____ ", |
| 331 | " \\_____|", |
| 332 | |
| 333 | /* D */ |
| 334 | " _____ ", |
| 335 | "| __ \\ ", |
| 336 | "| | | |", |
| 337 | "| | | |", |
| 338 | "| |__| |", |
| 339 | "|_____/ ", |
| 340 | |
| 341 | /* E */ |
| 342 | " ______ ", |
| 343 | "| ____|", |
| 344 | "| |__ ", |
| 345 | "| __| ", |
| 346 | "| |____ ", |
| 347 | "|______|", |
| 348 | |
| 349 | /* F */ |
| 350 | " ______ ", |
| 351 | "| ____|", |
| 352 | "| |__ ", |
| 353 | "| __| ", |
| @@ -408,11 +408,11 @@ | |
| 408 | } |
| 409 | } |
| 410 | z[k++] = '\n'; |
| 411 | } |
| 412 | z[k] = 0; |
| 413 | return z; |
| 414 | } |
| 415 | #endif /* CAPTCHA==3 */ |
| 416 | |
| 417 | /* |
| 418 | ** COMMAND: test-captcha |
| @@ -478,11 +478,11 @@ | |
| 478 | ** Return true if a CAPTCHA is required for editing wiki or tickets or for |
| 479 | ** adding attachments. |
| 480 | ** |
| 481 | ** A CAPTCHA is required in those cases if the user is not logged in (if they |
| 482 | ** are user "nobody") and if the "require-captcha" setting is true. The |
| 483 | ** "require-captcha" setting is controlled on the Admin/Access page. It |
| 484 | ** defaults to true. |
| 485 | */ |
| 486 | int captcha_needed(void){ |
| 487 | if( g.zLogin!=0 ) return 0; |
| 488 | return db_get_boolean("require-captcha", 1); |
| 489 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -92,11 +92,11 @@ | |
| 92 | z[k++] = ' '; |
| 93 | } |
| 94 | z[k++] = '\n'; |
| 95 | } |
| 96 | z[k] = 0; |
| 97 | return z; |
| 98 | } |
| 99 | #endif /* CAPTCHA==1 */ |
| 100 | |
| 101 | |
| 102 | #if CAPTCHA==2 |
| @@ -148,11 +148,11 @@ | |
| 148 | "|__ |", |
| 149 | " / / ", |
| 150 | " /_/ ", |
| 151 | |
| 152 | /* 8 */ |
| 153 | " ___ ", |
| 154 | "( _ )", |
| 155 | "/ _ \\", |
| 156 | "\\___/", |
| 157 | |
| 158 | /* 9 */ |
| @@ -218,11 +218,11 @@ | |
| 218 | } |
| 219 | } |
| 220 | z[k++] = '\n'; |
| 221 | } |
| 222 | z[k] = 0; |
| 223 | return z; |
| 224 | } |
| 225 | #endif /* CAPTCHA==2 */ |
| 226 | |
| 227 | #if CAPTCHA==3 |
| 228 | static const char *const azFont3[] = { |
| @@ -231,123 +231,123 @@ | |
| 231 | " / _ \\ ", |
| 232 | "| | | |", |
| 233 | "| | | |", |
| 234 | "| |_| |", |
| 235 | " \\___/ ", |
| 236 | |
| 237 | /* 1 */ |
| 238 | " __ ", |
| 239 | "/_ |", |
| 240 | " | |", |
| 241 | " | |", |
| 242 | " | |", |
| 243 | " |_|", |
| 244 | |
| 245 | /* 2 */ |
| 246 | " ___ ", |
| 247 | "|__ \\ ", |
| 248 | " ) |", |
| 249 | " / / ", |
| 250 | " / /_ ", |
| 251 | "|____|", |
| 252 | |
| 253 | /* 3 */ |
| 254 | " ____ ", |
| 255 | "|___ \\ ", |
| 256 | " __) |", |
| 257 | " |__ < ", |
| 258 | " ___) |", |
| 259 | "|____/ ", |
| 260 | |
| 261 | /* 4 */ |
| 262 | " _ _ ", |
| 263 | "| || | ", |
| 264 | "| || |_ ", |
| 265 | "|__ _|", |
| 266 | " | | ", |
| 267 | " |_| ", |
| 268 | |
| 269 | /* 5 */ |
| 270 | " _____ ", |
| 271 | "| ____|", |
| 272 | "| |__ ", |
| 273 | "|___ \\ ", |
| 274 | " ___) |", |
| 275 | "|____/ ", |
| 276 | |
| 277 | /* 6 */ |
| 278 | " __ ", |
| 279 | " / / ", |
| 280 | " / /_ ", |
| 281 | "| '_ \\ ", |
| 282 | "| (_) |", |
| 283 | " \\___/ ", |
| 284 | |
| 285 | /* 7 */ |
| 286 | " ______ ", |
| 287 | "|____ |", |
| 288 | " / / ", |
| 289 | " / / ", |
| 290 | " / / ", |
| 291 | " /_/ ", |
| 292 | |
| 293 | /* 8 */ |
| 294 | " ___ ", |
| 295 | " / _ \\ ", |
| 296 | "| (_) |", |
| 297 | " > _ < ", |
| 298 | "| (_) |", |
| 299 | " \\___/ ", |
| 300 | |
| 301 | /* 9 */ |
| 302 | " ___ ", |
| 303 | " / _ \\ ", |
| 304 | "| (_) |", |
| 305 | " \\__, |", |
| 306 | " / / ", |
| 307 | " /_/ ", |
| 308 | |
| 309 | /* A */ |
| 310 | " ", |
| 311 | " /\\ ", |
| 312 | " / \\ ", |
| 313 | " / /\\ \\ ", |
| 314 | " / ____ \\ ", |
| 315 | "/_/ \\_\\", |
| 316 | |
| 317 | /* B */ |
| 318 | " ____ ", |
| 319 | "| _ \\ ", |
| 320 | "| |_) |", |
| 321 | "| _ < ", |
| 322 | "| |_) |", |
| 323 | "|____/ ", |
| 324 | |
| 325 | /* C */ |
| 326 | " _____ ", |
| 327 | " / ____|", |
| 328 | "| | ", |
| 329 | "| | ", |
| 330 | "| |____ ", |
| 331 | " \\_____|", |
| 332 | |
| 333 | /* D */ |
| 334 | " _____ ", |
| 335 | "| __ \\ ", |
| 336 | "| | | |", |
| 337 | "| | | |", |
| 338 | "| |__| |", |
| 339 | "|_____/ ", |
| 340 | |
| 341 | /* E */ |
| 342 | " ______ ", |
| 343 | "| ____|", |
| 344 | "| |__ ", |
| 345 | "| __| ", |
| 346 | "| |____ ", |
| 347 | "|______|", |
| 348 | |
| 349 | /* F */ |
| 350 | " ______ ", |
| 351 | "| ____|", |
| 352 | "| |__ ", |
| 353 | "| __| ", |
| @@ -408,11 +408,11 @@ | |
| 408 | } |
| 409 | } |
| 410 | z[k++] = '\n'; |
| 411 | } |
| 412 | z[k] = 0; |
| 413 | return z; |
| 414 | } |
| 415 | #endif /* CAPTCHA==3 */ |
| 416 | |
| 417 | /* |
| 418 | ** COMMAND: test-captcha |
| @@ -478,11 +478,11 @@ | |
| 478 | ** Return true if a CAPTCHA is required for editing wiki or tickets or for |
| 479 | ** adding attachments. |
| 480 | ** |
| 481 | ** A CAPTCHA is required in those cases if the user is not logged in (if they |
| 482 | ** are user "nobody") and if the "require-captcha" setting is true. The |
| 483 | ** "require-captcha" setting is controlled on the Admin/Access page. It |
| 484 | ** defaults to true. |
| 485 | */ |
| 486 | int captcha_needed(void){ |
| 487 | if( g.zLogin!=0 ) return 0; |
| 488 | return db_get_boolean("require-captcha", 1); |
| 489 |
+19
-23
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -266,11 +266,11 @@ | ||
| 266 | 266 | zTok = strtok_r(0, ",\"",&zPos)){} |
| 267 | 267 | fossil_free(zBuf); |
| 268 | 268 | if(zTok) return 1; |
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | - | |
| 271 | + | |
| 272 | 272 | return 0; |
| 273 | 273 | } |
| 274 | 274 | #endif |
| 275 | 275 | |
| 276 | 276 | /* |
| @@ -497,11 +497,11 @@ | ||
| 497 | 497 | ** must be made of zValue. |
| 498 | 498 | */ |
| 499 | 499 | void cgi_setenv(const char *zName, const char *zValue){ |
| 500 | 500 | cgi_set_parameter_nocopy(zName, mprintf("%s",zValue), 0); |
| 501 | 501 | } |
| 502 | - | |
| 502 | + | |
| 503 | 503 | |
| 504 | 504 | /* |
| 505 | 505 | ** Add a list of query parameters or cookies to the parameter set. |
| 506 | 506 | ** |
| 507 | 507 | ** Each parameter is of the form NAME=VALUE. Both the NAME and the |
| @@ -615,11 +615,11 @@ | ||
| 615 | 615 | break; |
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | *pz = &z[i]; |
| 619 | 619 | get_line_from_string(pz, pLen); |
| 620 | - return z; | |
| 620 | + return z; | |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /* |
| 624 | 624 | ** Tokenize a line of text into as many as nArg tokens. Make |
| 625 | 625 | ** azArg[] point to the start of each token. |
| @@ -722,11 +722,11 @@ | ||
| 722 | 722 | cgi_set_parameter_nocopy(mprintf("%s:mimetype",zName), z, 1); |
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | - } | |
| 727 | + } | |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | |
| 731 | 731 | #ifdef FOSSIL_ENABLE_JSON |
| 732 | 732 | /* |
| @@ -903,11 +903,11 @@ | ||
| 903 | 903 | z = (char*)P("HTTP_COOKIE"); |
| 904 | 904 | if( z ){ |
| 905 | 905 | z = mprintf("%s",z); |
| 906 | 906 | add_param_list(z, ';'); |
| 907 | 907 | } |
| 908 | - | |
| 908 | + | |
| 909 | 909 | z = (char*)P("QUERY_STRING"); |
| 910 | 910 | if( z ){ |
| 911 | 911 | z = mprintf("%s",z); |
| 912 | 912 | add_param_list(z, '&'); |
| 913 | 913 | } |
| @@ -919,11 +919,11 @@ | ||
| 919 | 919 | |
| 920 | 920 | len = atoi(PD("CONTENT_LENGTH", "0")); |
| 921 | 921 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 922 | 922 | blob_zero(&g.cgiIn); |
| 923 | 923 | if( len>0 && zType ){ |
| 924 | - if( fossil_strcmp(zType,"application/x-www-form-urlencoded")==0 | |
| 924 | + if( fossil_strcmp(zType,"application/x-www-form-urlencoded")==0 | |
| 925 | 925 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 926 | 926 | z = fossil_malloc( len+1 ); |
| 927 | 927 | len = fread(z, 1, len, g.httpIn); |
| 928 | 928 | z[len] = 0; |
| 929 | 929 | cgi_trace(z); |
| @@ -949,11 +949,11 @@ | ||
| 949 | 949 | /* FIXMEs: |
| 950 | 950 | |
| 951 | 951 | - See if fossil really needs g.cgiIn to be set for this purpose |
| 952 | 952 | (i don't think it does). If it does then fill g.cgiIn and |
| 953 | 953 | refactor to parse the JSON from there. |
| 954 | - | |
| 954 | + | |
| 955 | 955 | - After parsing POST JSON, copy the "first layer" of keys/values |
| 956 | 956 | to cgi_setenv(), honoring the upper-case distinction used |
| 957 | 957 | in add_param_list(). However... |
| 958 | 958 | |
| 959 | 959 | - If we do that then we might get a disconnect in precedence of |
| @@ -1225,11 +1225,11 @@ | ||
| 1225 | 1225 | ** loaded into g.zIpAddr. |
| 1226 | 1226 | */ |
| 1227 | 1227 | static const char *cgi_accept_forwarded_for(const char *z){ |
| 1228 | 1228 | int i; |
| 1229 | 1229 | if( fossil_strcmp(g.zIpAddr, "127.0.0.1")!=0 ) return 0; |
| 1230 | - | |
| 1230 | + | |
| 1231 | 1231 | i = strlen(z)-1; |
| 1232 | 1232 | while( i>=0 && z[i]!=',' && !fossil_isspace(z[i]) ) i--; |
| 1233 | 1233 | return &z[++i]; |
| 1234 | 1234 | } |
| 1235 | 1235 | |
| @@ -1297,20 +1297,20 @@ | ||
| 1297 | 1297 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 1298 | 1298 | if( zToken[i] ) zToken[i++] = 0; |
| 1299 | 1299 | cgi_setenv("PATH_INFO", zToken); |
| 1300 | 1300 | cgi_setenv("QUERY_STRING", &zToken[i]); |
| 1301 | 1301 | if( zIpAddr==0 && |
| 1302 | - getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName, | |
| 1302 | + getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName, | |
| 1303 | 1303 | &size)>=0 |
| 1304 | 1304 | ){ |
| 1305 | 1305 | zIpAddr = inet_ntoa(remoteName.sin_addr); |
| 1306 | 1306 | } |
| 1307 | - if( zIpAddr ){ | |
| 1307 | + if( zIpAddr ){ | |
| 1308 | 1308 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1309 | 1309 | g.zIpAddr = mprintf("%s", zIpAddr); |
| 1310 | 1310 | } |
| 1311 | - | |
| 1311 | + | |
| 1312 | 1312 | /* Get all the optional fields that follow the first line. |
| 1313 | 1313 | */ |
| 1314 | 1314 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1315 | 1315 | char *zFieldName; |
| 1316 | 1316 | char *zVal; |
| @@ -1340,14 +1340,12 @@ | ||
| 1340 | 1340 | cgi_setenv("HTTP_HOST", zVal); |
| 1341 | 1341 | }else if( fossil_strcmp(zFieldName,"if-none-match:")==0 ){ |
| 1342 | 1342 | cgi_setenv("HTTP_IF_NONE_MATCH", zVal); |
| 1343 | 1343 | }else if( fossil_strcmp(zFieldName,"if-modified-since:")==0 ){ |
| 1344 | 1344 | cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal); |
| 1345 | -#if 0 | |
| 1346 | 1345 | }else if( fossil_strcmp(zFieldName,"referer:")==0 ){ |
| 1347 | 1346 | cgi_setenv("HTTP_REFERER", zVal); |
| 1348 | -#endif | |
| 1349 | 1347 | }else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){ |
| 1350 | 1348 | cgi_setenv("HTTP_USER_AGENT", zVal); |
| 1351 | 1349 | }else if( fossil_strcmp(zFieldName,"x-forwarded-for:")==0 ){ |
| 1352 | 1350 | const char *zIpAddr = cgi_accept_forwarded_for(zVal); |
| 1353 | 1351 | if( zIpAddr!=0 ){ |
| @@ -1376,11 +1374,11 @@ | ||
| 1376 | 1374 | const char *zType = 0; |
| 1377 | 1375 | int i, content_length = 0; |
| 1378 | 1376 | char zLine[2000]; /* A single line of input. */ |
| 1379 | 1377 | |
| 1380 | 1378 | if( zIpAddr ){ |
| 1381 | - if( nCycles==0 ){ | |
| 1379 | + if( nCycles==0 ){ | |
| 1382 | 1380 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1383 | 1381 | g.zIpAddr = mprintf("%s", zIpAddr); |
| 1384 | 1382 | } |
| 1385 | 1383 | }else{ |
| 1386 | 1384 | fossil_panic("missing SSH IP address"); |
| @@ -1442,11 +1440,11 @@ | ||
| 1442 | 1440 | if( nCycles==0 ){ |
| 1443 | 1441 | cgi_setenv("PATH_INFO", zToken); |
| 1444 | 1442 | }else{ |
| 1445 | 1443 | cgi_replace_parameter("PATH_INFO", mprintf("%s",zToken)); |
| 1446 | 1444 | } |
| 1447 | - | |
| 1445 | + | |
| 1448 | 1446 | /* Get all the optional fields that follow the first line. |
| 1449 | 1447 | */ |
| 1450 | 1448 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1451 | 1449 | char *zFieldName; |
| 1452 | 1450 | char *zVal; |
| @@ -1623,11 +1621,11 @@ | ||
| 1623 | 1621 | cgi_init(); |
| 1624 | 1622 | } |
| 1625 | 1623 | |
| 1626 | 1624 | |
| 1627 | 1625 | #if INTERFACE |
| 1628 | -/* | |
| 1626 | +/* | |
| 1629 | 1627 | ** Bitmap values for the flags parameter to cgi_http_server(). |
| 1630 | 1628 | */ |
| 1631 | 1629 | #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ |
| 1632 | 1630 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 1633 | 1631 | |
| @@ -1708,15 +1706,13 @@ | ||
| 1708 | 1706 | " port in the range %d..%d", mnPort, mxPort); |
| 1709 | 1707 | } |
| 1710 | 1708 | } |
| 1711 | 1709 | if( iPort>mxPort ) return 1; |
| 1712 | 1710 | listen(listener,10); |
| 1713 | - if( iPort>mnPort ){ | |
| 1714 | - fossil_print("Listening for %s requests on TCP port %d\n", | |
| 1715 | - (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort); | |
| 1716 | - fflush(stdout); | |
| 1717 | - } | |
| 1711 | + fossil_print("Listening for %s requests on TCP port %d\n", | |
| 1712 | + (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort); | |
| 1713 | + fflush(stdout); | |
| 1718 | 1714 | if( zBrowser ){ |
| 1719 | 1715 | zBrowser = mprintf(zBrowser, iPort); |
| 1720 | 1716 | #if defined(__CYGWIN__) |
| 1721 | 1717 | /* On Cygwin, we can do better than "echo" */ |
| 1722 | 1718 | if( memcmp(zBrowser, "echo ", 5)==0 ){ |
| @@ -1771,11 +1767,11 @@ | ||
| 1771 | 1767 | /* Bury dead children */ |
| 1772 | 1768 | while( waitpid(0, 0, WNOHANG)>0 ){ |
| 1773 | 1769 | nchildren--; |
| 1774 | 1770 | } |
| 1775 | 1771 | } |
| 1776 | - /* NOT REACHED */ | |
| 1772 | + /* NOT REACHED */ | |
| 1777 | 1773 | fossil_exit(1); |
| 1778 | 1774 | #endif |
| 1779 | 1775 | /* NOT REACHED */ |
| 1780 | 1776 | return 0; |
| 1781 | 1777 | } |
| @@ -1859,11 +1855,11 @@ | ||
| 1859 | 1855 | p->tm_mon %= 12; |
| 1860 | 1856 | } |
| 1861 | 1857 | isLeapYr = p->tm_year%4==0 && (p->tm_year%100!=0 || (p->tm_year+300)%400==0); |
| 1862 | 1858 | p->tm_yday = priorDays[p->tm_mon] + p->tm_mday - 1; |
| 1863 | 1859 | if( isLeapYr && p->tm_mon>1 ) p->tm_yday++; |
| 1864 | - nDay = (p->tm_year-70)*365 + (p->tm_year-69)/4 -p->tm_year/100 + | |
| 1860 | + nDay = (p->tm_year-70)*365 + (p->tm_year-69)/4 -p->tm_year/100 + | |
| 1865 | 1861 | (p->tm_year+300)/400 + p->tm_yday; |
| 1866 | 1862 | t = ((nDay*24 + p->tm_hour)*60 + p->tm_min)*60 + p->tm_sec; |
| 1867 | 1863 | return t; |
| 1868 | 1864 | } |
| 1869 | 1865 | |
| 1870 | 1866 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -266,11 +266,11 @@ | |
| 266 | zTok = strtok_r(0, ",\"",&zPos)){} |
| 267 | fossil_free(zBuf); |
| 268 | if(zTok) return 1; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | return 0; |
| 273 | } |
| 274 | #endif |
| 275 | |
| 276 | /* |
| @@ -497,11 +497,11 @@ | |
| 497 | ** must be made of zValue. |
| 498 | */ |
| 499 | void cgi_setenv(const char *zName, const char *zValue){ |
| 500 | cgi_set_parameter_nocopy(zName, mprintf("%s",zValue), 0); |
| 501 | } |
| 502 | |
| 503 | |
| 504 | /* |
| 505 | ** Add a list of query parameters or cookies to the parameter set. |
| 506 | ** |
| 507 | ** Each parameter is of the form NAME=VALUE. Both the NAME and the |
| @@ -615,11 +615,11 @@ | |
| 615 | break; |
| 616 | } |
| 617 | } |
| 618 | *pz = &z[i]; |
| 619 | get_line_from_string(pz, pLen); |
| 620 | return z; |
| 621 | } |
| 622 | |
| 623 | /* |
| 624 | ** Tokenize a line of text into as many as nArg tokens. Make |
| 625 | ** azArg[] point to the start of each token. |
| @@ -722,11 +722,11 @@ | |
| 722 | cgi_set_parameter_nocopy(mprintf("%s:mimetype",zName), z, 1); |
| 723 | } |
| 724 | } |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | |
| 731 | #ifdef FOSSIL_ENABLE_JSON |
| 732 | /* |
| @@ -903,11 +903,11 @@ | |
| 903 | z = (char*)P("HTTP_COOKIE"); |
| 904 | if( z ){ |
| 905 | z = mprintf("%s",z); |
| 906 | add_param_list(z, ';'); |
| 907 | } |
| 908 | |
| 909 | z = (char*)P("QUERY_STRING"); |
| 910 | if( z ){ |
| 911 | z = mprintf("%s",z); |
| 912 | add_param_list(z, '&'); |
| 913 | } |
| @@ -919,11 +919,11 @@ | |
| 919 | |
| 920 | len = atoi(PD("CONTENT_LENGTH", "0")); |
| 921 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 922 | blob_zero(&g.cgiIn); |
| 923 | if( len>0 && zType ){ |
| 924 | if( fossil_strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 925 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 926 | z = fossil_malloc( len+1 ); |
| 927 | len = fread(z, 1, len, g.httpIn); |
| 928 | z[len] = 0; |
| 929 | cgi_trace(z); |
| @@ -949,11 +949,11 @@ | |
| 949 | /* FIXMEs: |
| 950 | |
| 951 | - See if fossil really needs g.cgiIn to be set for this purpose |
| 952 | (i don't think it does). If it does then fill g.cgiIn and |
| 953 | refactor to parse the JSON from there. |
| 954 | |
| 955 | - After parsing POST JSON, copy the "first layer" of keys/values |
| 956 | to cgi_setenv(), honoring the upper-case distinction used |
| 957 | in add_param_list(). However... |
| 958 | |
| 959 | - If we do that then we might get a disconnect in precedence of |
| @@ -1225,11 +1225,11 @@ | |
| 1225 | ** loaded into g.zIpAddr. |
| 1226 | */ |
| 1227 | static const char *cgi_accept_forwarded_for(const char *z){ |
| 1228 | int i; |
| 1229 | if( fossil_strcmp(g.zIpAddr, "127.0.0.1")!=0 ) return 0; |
| 1230 | |
| 1231 | i = strlen(z)-1; |
| 1232 | while( i>=0 && z[i]!=',' && !fossil_isspace(z[i]) ) i--; |
| 1233 | return &z[++i]; |
| 1234 | } |
| 1235 | |
| @@ -1297,20 +1297,20 @@ | |
| 1297 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 1298 | if( zToken[i] ) zToken[i++] = 0; |
| 1299 | cgi_setenv("PATH_INFO", zToken); |
| 1300 | cgi_setenv("QUERY_STRING", &zToken[i]); |
| 1301 | if( zIpAddr==0 && |
| 1302 | getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName, |
| 1303 | &size)>=0 |
| 1304 | ){ |
| 1305 | zIpAddr = inet_ntoa(remoteName.sin_addr); |
| 1306 | } |
| 1307 | if( zIpAddr ){ |
| 1308 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1309 | g.zIpAddr = mprintf("%s", zIpAddr); |
| 1310 | } |
| 1311 | |
| 1312 | /* Get all the optional fields that follow the first line. |
| 1313 | */ |
| 1314 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1315 | char *zFieldName; |
| 1316 | char *zVal; |
| @@ -1340,14 +1340,12 @@ | |
| 1340 | cgi_setenv("HTTP_HOST", zVal); |
| 1341 | }else if( fossil_strcmp(zFieldName,"if-none-match:")==0 ){ |
| 1342 | cgi_setenv("HTTP_IF_NONE_MATCH", zVal); |
| 1343 | }else if( fossil_strcmp(zFieldName,"if-modified-since:")==0 ){ |
| 1344 | cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal); |
| 1345 | #if 0 |
| 1346 | }else if( fossil_strcmp(zFieldName,"referer:")==0 ){ |
| 1347 | cgi_setenv("HTTP_REFERER", zVal); |
| 1348 | #endif |
| 1349 | }else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){ |
| 1350 | cgi_setenv("HTTP_USER_AGENT", zVal); |
| 1351 | }else if( fossil_strcmp(zFieldName,"x-forwarded-for:")==0 ){ |
| 1352 | const char *zIpAddr = cgi_accept_forwarded_for(zVal); |
| 1353 | if( zIpAddr!=0 ){ |
| @@ -1376,11 +1374,11 @@ | |
| 1376 | const char *zType = 0; |
| 1377 | int i, content_length = 0; |
| 1378 | char zLine[2000]; /* A single line of input. */ |
| 1379 | |
| 1380 | if( zIpAddr ){ |
| 1381 | if( nCycles==0 ){ |
| 1382 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1383 | g.zIpAddr = mprintf("%s", zIpAddr); |
| 1384 | } |
| 1385 | }else{ |
| 1386 | fossil_panic("missing SSH IP address"); |
| @@ -1442,11 +1440,11 @@ | |
| 1442 | if( nCycles==0 ){ |
| 1443 | cgi_setenv("PATH_INFO", zToken); |
| 1444 | }else{ |
| 1445 | cgi_replace_parameter("PATH_INFO", mprintf("%s",zToken)); |
| 1446 | } |
| 1447 | |
| 1448 | /* Get all the optional fields that follow the first line. |
| 1449 | */ |
| 1450 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1451 | char *zFieldName; |
| 1452 | char *zVal; |
| @@ -1623,11 +1621,11 @@ | |
| 1623 | cgi_init(); |
| 1624 | } |
| 1625 | |
| 1626 | |
| 1627 | #if INTERFACE |
| 1628 | /* |
| 1629 | ** Bitmap values for the flags parameter to cgi_http_server(). |
| 1630 | */ |
| 1631 | #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ |
| 1632 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 1633 | |
| @@ -1708,15 +1706,13 @@ | |
| 1708 | " port in the range %d..%d", mnPort, mxPort); |
| 1709 | } |
| 1710 | } |
| 1711 | if( iPort>mxPort ) return 1; |
| 1712 | listen(listener,10); |
| 1713 | if( iPort>mnPort ){ |
| 1714 | fossil_print("Listening for %s requests on TCP port %d\n", |
| 1715 | (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort); |
| 1716 | fflush(stdout); |
| 1717 | } |
| 1718 | if( zBrowser ){ |
| 1719 | zBrowser = mprintf(zBrowser, iPort); |
| 1720 | #if defined(__CYGWIN__) |
| 1721 | /* On Cygwin, we can do better than "echo" */ |
| 1722 | if( memcmp(zBrowser, "echo ", 5)==0 ){ |
| @@ -1771,11 +1767,11 @@ | |
| 1771 | /* Bury dead children */ |
| 1772 | while( waitpid(0, 0, WNOHANG)>0 ){ |
| 1773 | nchildren--; |
| 1774 | } |
| 1775 | } |
| 1776 | /* NOT REACHED */ |
| 1777 | fossil_exit(1); |
| 1778 | #endif |
| 1779 | /* NOT REACHED */ |
| 1780 | return 0; |
| 1781 | } |
| @@ -1859,11 +1855,11 @@ | |
| 1859 | p->tm_mon %= 12; |
| 1860 | } |
| 1861 | isLeapYr = p->tm_year%4==0 && (p->tm_year%100!=0 || (p->tm_year+300)%400==0); |
| 1862 | p->tm_yday = priorDays[p->tm_mon] + p->tm_mday - 1; |
| 1863 | if( isLeapYr && p->tm_mon>1 ) p->tm_yday++; |
| 1864 | nDay = (p->tm_year-70)*365 + (p->tm_year-69)/4 -p->tm_year/100 + |
| 1865 | (p->tm_year+300)/400 + p->tm_yday; |
| 1866 | t = ((nDay*24 + p->tm_hour)*60 + p->tm_min)*60 + p->tm_sec; |
| 1867 | return t; |
| 1868 | } |
| 1869 | |
| 1870 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -266,11 +266,11 @@ | |
| 266 | zTok = strtok_r(0, ",\"",&zPos)){} |
| 267 | fossil_free(zBuf); |
| 268 | if(zTok) return 1; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | return 0; |
| 273 | } |
| 274 | #endif |
| 275 | |
| 276 | /* |
| @@ -497,11 +497,11 @@ | |
| 497 | ** must be made of zValue. |
| 498 | */ |
| 499 | void cgi_setenv(const char *zName, const char *zValue){ |
| 500 | cgi_set_parameter_nocopy(zName, mprintf("%s",zValue), 0); |
| 501 | } |
| 502 | |
| 503 | |
| 504 | /* |
| 505 | ** Add a list of query parameters or cookies to the parameter set. |
| 506 | ** |
| 507 | ** Each parameter is of the form NAME=VALUE. Both the NAME and the |
| @@ -615,11 +615,11 @@ | |
| 615 | break; |
| 616 | } |
| 617 | } |
| 618 | *pz = &z[i]; |
| 619 | get_line_from_string(pz, pLen); |
| 620 | return z; |
| 621 | } |
| 622 | |
| 623 | /* |
| 624 | ** Tokenize a line of text into as many as nArg tokens. Make |
| 625 | ** azArg[] point to the start of each token. |
| @@ -722,11 +722,11 @@ | |
| 722 | cgi_set_parameter_nocopy(mprintf("%s:mimetype",zName), z, 1); |
| 723 | } |
| 724 | } |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | |
| 731 | #ifdef FOSSIL_ENABLE_JSON |
| 732 | /* |
| @@ -903,11 +903,11 @@ | |
| 903 | z = (char*)P("HTTP_COOKIE"); |
| 904 | if( z ){ |
| 905 | z = mprintf("%s",z); |
| 906 | add_param_list(z, ';'); |
| 907 | } |
| 908 | |
| 909 | z = (char*)P("QUERY_STRING"); |
| 910 | if( z ){ |
| 911 | z = mprintf("%s",z); |
| 912 | add_param_list(z, '&'); |
| 913 | } |
| @@ -919,11 +919,11 @@ | |
| 919 | |
| 920 | len = atoi(PD("CONTENT_LENGTH", "0")); |
| 921 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 922 | blob_zero(&g.cgiIn); |
| 923 | if( len>0 && zType ){ |
| 924 | if( fossil_strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 925 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 926 | z = fossil_malloc( len+1 ); |
| 927 | len = fread(z, 1, len, g.httpIn); |
| 928 | z[len] = 0; |
| 929 | cgi_trace(z); |
| @@ -949,11 +949,11 @@ | |
| 949 | /* FIXMEs: |
| 950 | |
| 951 | - See if fossil really needs g.cgiIn to be set for this purpose |
| 952 | (i don't think it does). If it does then fill g.cgiIn and |
| 953 | refactor to parse the JSON from there. |
| 954 | |
| 955 | - After parsing POST JSON, copy the "first layer" of keys/values |
| 956 | to cgi_setenv(), honoring the upper-case distinction used |
| 957 | in add_param_list(). However... |
| 958 | |
| 959 | - If we do that then we might get a disconnect in precedence of |
| @@ -1225,11 +1225,11 @@ | |
| 1225 | ** loaded into g.zIpAddr. |
| 1226 | */ |
| 1227 | static const char *cgi_accept_forwarded_for(const char *z){ |
| 1228 | int i; |
| 1229 | if( fossil_strcmp(g.zIpAddr, "127.0.0.1")!=0 ) return 0; |
| 1230 | |
| 1231 | i = strlen(z)-1; |
| 1232 | while( i>=0 && z[i]!=',' && !fossil_isspace(z[i]) ) i--; |
| 1233 | return &z[++i]; |
| 1234 | } |
| 1235 | |
| @@ -1297,20 +1297,20 @@ | |
| 1297 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 1298 | if( zToken[i] ) zToken[i++] = 0; |
| 1299 | cgi_setenv("PATH_INFO", zToken); |
| 1300 | cgi_setenv("QUERY_STRING", &zToken[i]); |
| 1301 | if( zIpAddr==0 && |
| 1302 | getpeername(fileno(g.httpIn), (struct sockaddr*)&remoteName, |
| 1303 | &size)>=0 |
| 1304 | ){ |
| 1305 | zIpAddr = inet_ntoa(remoteName.sin_addr); |
| 1306 | } |
| 1307 | if( zIpAddr ){ |
| 1308 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1309 | g.zIpAddr = mprintf("%s", zIpAddr); |
| 1310 | } |
| 1311 | |
| 1312 | /* Get all the optional fields that follow the first line. |
| 1313 | */ |
| 1314 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1315 | char *zFieldName; |
| 1316 | char *zVal; |
| @@ -1340,14 +1340,12 @@ | |
| 1340 | cgi_setenv("HTTP_HOST", zVal); |
| 1341 | }else if( fossil_strcmp(zFieldName,"if-none-match:")==0 ){ |
| 1342 | cgi_setenv("HTTP_IF_NONE_MATCH", zVal); |
| 1343 | }else if( fossil_strcmp(zFieldName,"if-modified-since:")==0 ){ |
| 1344 | cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal); |
| 1345 | }else if( fossil_strcmp(zFieldName,"referer:")==0 ){ |
| 1346 | cgi_setenv("HTTP_REFERER", zVal); |
| 1347 | }else if( fossil_strcmp(zFieldName,"user-agent:")==0 ){ |
| 1348 | cgi_setenv("HTTP_USER_AGENT", zVal); |
| 1349 | }else if( fossil_strcmp(zFieldName,"x-forwarded-for:")==0 ){ |
| 1350 | const char *zIpAddr = cgi_accept_forwarded_for(zVal); |
| 1351 | if( zIpAddr!=0 ){ |
| @@ -1376,11 +1374,11 @@ | |
| 1374 | const char *zType = 0; |
| 1375 | int i, content_length = 0; |
| 1376 | char zLine[2000]; /* A single line of input. */ |
| 1377 | |
| 1378 | if( zIpAddr ){ |
| 1379 | if( nCycles==0 ){ |
| 1380 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1381 | g.zIpAddr = mprintf("%s", zIpAddr); |
| 1382 | } |
| 1383 | }else{ |
| 1384 | fossil_panic("missing SSH IP address"); |
| @@ -1442,11 +1440,11 @@ | |
| 1440 | if( nCycles==0 ){ |
| 1441 | cgi_setenv("PATH_INFO", zToken); |
| 1442 | }else{ |
| 1443 | cgi_replace_parameter("PATH_INFO", mprintf("%s",zToken)); |
| 1444 | } |
| 1445 | |
| 1446 | /* Get all the optional fields that follow the first line. |
| 1447 | */ |
| 1448 | while( fgets(zLine,sizeof(zLine),g.httpIn) ){ |
| 1449 | char *zFieldName; |
| 1450 | char *zVal; |
| @@ -1623,11 +1621,11 @@ | |
| 1621 | cgi_init(); |
| 1622 | } |
| 1623 | |
| 1624 | |
| 1625 | #if INTERFACE |
| 1626 | /* |
| 1627 | ** Bitmap values for the flags parameter to cgi_http_server(). |
| 1628 | */ |
| 1629 | #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ |
| 1630 | #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ |
| 1631 | |
| @@ -1708,15 +1706,13 @@ | |
| 1706 | " port in the range %d..%d", mnPort, mxPort); |
| 1707 | } |
| 1708 | } |
| 1709 | if( iPort>mxPort ) return 1; |
| 1710 | listen(listener,10); |
| 1711 | fossil_print("Listening for %s requests on TCP port %d\n", |
| 1712 | (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort); |
| 1713 | fflush(stdout); |
| 1714 | if( zBrowser ){ |
| 1715 | zBrowser = mprintf(zBrowser, iPort); |
| 1716 | #if defined(__CYGWIN__) |
| 1717 | /* On Cygwin, we can do better than "echo" */ |
| 1718 | if( memcmp(zBrowser, "echo ", 5)==0 ){ |
| @@ -1771,11 +1767,11 @@ | |
| 1767 | /* Bury dead children */ |
| 1768 | while( waitpid(0, 0, WNOHANG)>0 ){ |
| 1769 | nchildren--; |
| 1770 | } |
| 1771 | } |
| 1772 | /* NOT REACHED */ |
| 1773 | fossil_exit(1); |
| 1774 | #endif |
| 1775 | /* NOT REACHED */ |
| 1776 | return 0; |
| 1777 | } |
| @@ -1859,11 +1855,11 @@ | |
| 1855 | p->tm_mon %= 12; |
| 1856 | } |
| 1857 | isLeapYr = p->tm_year%4==0 && (p->tm_year%100!=0 || (p->tm_year+300)%400==0); |
| 1858 | p->tm_yday = priorDays[p->tm_mon] + p->tm_mday - 1; |
| 1859 | if( isLeapYr && p->tm_mon>1 ) p->tm_yday++; |
| 1860 | nDay = (p->tm_year-70)*365 + (p->tm_year-69)/4 -p->tm_year/100 + |
| 1861 | (p->tm_year+300)/400 + p->tm_yday; |
| 1862 | t = ((nDay*24 + p->tm_hour)*60 + p->tm_min)*60 + p->tm_sec; |
| 1863 | return t; |
| 1864 | } |
| 1865 | |
| 1866 |
+1
-1
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -34,11 +34,11 @@ | ||
| 34 | 34 | int tlen = lineLength - indent; |
| 35 | 35 | int si, sk, i, k; |
| 36 | 36 | int doIndent = 0; |
| 37 | 37 | char *zBuf; |
| 38 | 38 | char zBuffer[400]; |
| 39 | - int lineCnt = 0; | |
| 39 | + int lineCnt = 0; | |
| 40 | 40 | |
| 41 | 41 | if( tlen<=0 ){ |
| 42 | 42 | tlen = strlen(zText); |
| 43 | 43 | } |
| 44 | 44 | if( tlen >= (sizeof(zBuffer)) ){ |
| 45 | 45 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -34,11 +34,11 @@ | |
| 34 | int tlen = lineLength - indent; |
| 35 | int si, sk, i, k; |
| 36 | int doIndent = 0; |
| 37 | char *zBuf; |
| 38 | char zBuffer[400]; |
| 39 | int lineCnt = 0; |
| 40 | |
| 41 | if( tlen<=0 ){ |
| 42 | tlen = strlen(zText); |
| 43 | } |
| 44 | if( tlen >= (sizeof(zBuffer)) ){ |
| 45 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -34,11 +34,11 @@ | |
| 34 | int tlen = lineLength - indent; |
| 35 | int si, sk, i, k; |
| 36 | int doIndent = 0; |
| 37 | char *zBuf; |
| 38 | char zBuffer[400]; |
| 39 | int lineCnt = 0; |
| 40 | |
| 41 | if( tlen<=0 ){ |
| 42 | tlen = strlen(zText); |
| 43 | } |
| 44 | if( tlen >= (sizeof(zBuffer)) ){ |
| 45 |
+17
-17
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -114,11 +114,11 @@ | ||
| 114 | 114 | contentCache.n = 0; |
| 115 | 115 | contentCache.szTotal = 0; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /* |
| 119 | -** Return the srcid associated with rid. Or return 0 if rid is | |
| 119 | +** Return the srcid associated with rid. Or return 0 if rid is | |
| 120 | 120 | ** original content and not a delta. |
| 121 | 121 | */ |
| 122 | 122 | static int findSrcid(int rid){ |
| 123 | 123 | static Stmt q; |
| 124 | 124 | int srcid; |
| @@ -154,11 +154,11 @@ | ||
| 154 | 154 | ** a phantom. |
| 155 | 155 | */ |
| 156 | 156 | int content_is_available(int rid){ |
| 157 | 157 | int srcid; |
| 158 | 158 | int depth = 0; /* Limit to recursion depth */ |
| 159 | - while( depth++ < 10000000 ){ | |
| 159 | + while( depth++ < 10000000 ){ | |
| 160 | 160 | if( bag_find(&contentCache.missing, rid) ){ |
| 161 | 161 | return 0; |
| 162 | 162 | } |
| 163 | 163 | if( bag_find(&contentCache.available, rid) ){ |
| 164 | 164 | return 1; |
| @@ -416,11 +416,11 @@ | ||
| 416 | 416 | |
| 417 | 417 | /* Recursively dephantomize all artifacts that are derived by |
| 418 | 418 | ** delta from artifact rid and which have not already been |
| 419 | 419 | ** cross-linked. */ |
| 420 | 420 | nChildUsed = 0; |
| 421 | - db_prepare(&q, | |
| 421 | + db_prepare(&q, | |
| 422 | 422 | "SELECT rid FROM delta" |
| 423 | 423 | " WHERE srcid=%d" |
| 424 | 424 | " AND NOT EXISTS(SELECT 1 FROM mlink WHERE mid=delta.rid)", |
| 425 | 425 | rid |
| 426 | 426 | ); |
| @@ -455,11 +455,11 @@ | ||
| 455 | 455 | /* |
| 456 | 456 | ** Write content into the database. Return the record ID. If the |
| 457 | 457 | ** content is already in the database, just return the record ID. |
| 458 | 458 | ** |
| 459 | 459 | ** If srcId is specified, then pBlob is delta content from |
| 460 | -** the srcId record. srcId might be a phantom. | |
| 460 | +** the srcId record. srcId might be a phantom. | |
| 461 | 461 | ** |
| 462 | 462 | ** pBlob is normally uncompressed text. But if nBlob>0 then the |
| 463 | 463 | ** pBlob value has already been compressed and nBlob is its uncompressed |
| 464 | 464 | ** size. If nBlob>0 then zUuid must be valid. |
| 465 | 465 | ** |
| @@ -486,11 +486,11 @@ | ||
| 486 | 486 | Stmt s1; |
| 487 | 487 | Blob cmpr; |
| 488 | 488 | Blob hash; |
| 489 | 489 | int markAsUnclustered = 0; |
| 490 | 490 | int isDephantomize = 0; |
| 491 | - | |
| 491 | + | |
| 492 | 492 | assert( g.repositoryOpen ); |
| 493 | 493 | assert( pBlob!=0 ); |
| 494 | 494 | assert( srcId==0 || zUuid!=0 ); |
| 495 | 495 | if( zUuid==0 ){ |
| 496 | 496 | assert( nBlob==0 ); |
| @@ -580,18 +580,18 @@ | ||
| 580 | 580 | ** really a delta. Record this fact in the delta table. |
| 581 | 581 | */ |
| 582 | 582 | if( srcId ){ |
| 583 | 583 | db_multi_exec("REPLACE INTO delta(rid,srcid) VALUES(%d,%d)", rid, srcId); |
| 584 | 584 | } |
| 585 | - if( !isDephantomize && bag_find(&contentCache.missing, rid) && | |
| 585 | + if( !isDephantomize && bag_find(&contentCache.missing, rid) && | |
| 586 | 586 | (srcId==0 || content_is_available(srcId)) ){ |
| 587 | 587 | content_mark_available(rid); |
| 588 | 588 | } |
| 589 | 589 | if( isDephantomize ){ |
| 590 | 590 | after_dephantomize(rid, 0); |
| 591 | 591 | } |
| 592 | - | |
| 592 | + | |
| 593 | 593 | /* Add the element to the unclustered table if has never been |
| 594 | 594 | ** previously seen. |
| 595 | 595 | */ |
| 596 | 596 | if( markAsUnclustered ){ |
| 597 | 597 | db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d)", rid); |
| @@ -628,11 +628,11 @@ | ||
| 628 | 628 | ** Create a new phantom with the given UUID and return its artifact ID. |
| 629 | 629 | */ |
| 630 | 630 | int content_new(const char *zUuid, int isPrivate){ |
| 631 | 631 | int rid; |
| 632 | 632 | static Stmt s1, s2, s3; |
| 633 | - | |
| 633 | + | |
| 634 | 634 | assert( g.repositoryOpen ); |
| 635 | 635 | db_begin_transaction(); |
| 636 | 636 | if( uuid_is_shunned(zUuid) ){ |
| 637 | 637 | db_end_transaction(0); |
| 638 | 638 | return 0; |
| @@ -727,15 +727,15 @@ | ||
| 727 | 727 | "SELECT 1 FROM private WHERE rid=:rid" |
| 728 | 728 | ); |
| 729 | 729 | db_bind_int(&s1, ":rid", rid); |
| 730 | 730 | rc = db_step(&s1); |
| 731 | 731 | db_reset(&s1); |
| 732 | - return rc==SQLITE_ROW; | |
| 732 | + return rc==SQLITE_ROW; | |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | /* |
| 736 | -** Make sure an artifact is public. | |
| 736 | +** Make sure an artifact is public. | |
| 737 | 737 | */ |
| 738 | 738 | void content_make_public(int rid){ |
| 739 | 739 | static Stmt s1; |
| 740 | 740 | db_static_prepare(&s1, |
| 741 | 741 | "DELETE FROM private WHERE rid=:rid" |
| @@ -758,11 +758,11 @@ | ||
| 758 | 758 | ** |
| 759 | 759 | ** If srcid is a delta that depends on rid, then srcid is |
| 760 | 760 | ** converted to undeltaed text. |
| 761 | 761 | ** |
| 762 | 762 | ** If either rid or srcid contain less than 50 bytes, or if the |
| 763 | -** resulting delta does not achieve a compression of at least 25% | |
| 763 | +** resulting delta does not achieve a compression of at least 25% | |
| 764 | 764 | ** the rid is left untouched. |
| 765 | 765 | ** |
| 766 | 766 | ** Return 1 if a delta is made and 0 if no delta occurs. |
| 767 | 767 | */ |
| 768 | 768 | int content_deltify(int rid, int srcid, int force){ |
| @@ -883,11 +883,11 @@ | ||
| 883 | 883 | zId, rid, zSrc, srcid |
| 884 | 884 | ); |
| 885 | 885 | nErr++; |
| 886 | 886 | } |
| 887 | 887 | db_finalize(&q); |
| 888 | - | |
| 888 | + | |
| 889 | 889 | db_prepare(&q, "SELECT rid, uuid, size FROM blob ORDER BY rid"); |
| 890 | 890 | total = db_int(0, "SELECT max(rid) FROM blob"); |
| 891 | 891 | while( db_step(&q)==SQLITE_ROW ){ |
| 892 | 892 | int rid = db_column_int(&q, 0); |
| 893 | 893 | const char *zUuid = db_column_text(&q, 1); |
| @@ -945,12 +945,12 @@ | ||
| 945 | 945 | } |
| 946 | 946 | db_finalize(&q); |
| 947 | 947 | fossil_print("%d non-phantom blobs (out of %d total) checked: %d errors\n", |
| 948 | 948 | n2, n1, nErr); |
| 949 | 949 | if( bParse ){ |
| 950 | - const char *azType[] = { 0, "manifest", "cluster", "control", "wiki", | |
| 951 | - "ticket", "attachment", "event" }; | |
| 950 | + static const char *const azType[] = { 0, "manifest", "cluster", | |
| 951 | + "control", "wiki", "ticket", "attachment", "event" }; | |
| 952 | 952 | int i; |
| 953 | 953 | fossil_print("%d total control artifacts\n", nCA); |
| 954 | 954 | for(i=1; i<count(azType); i++){ |
| 955 | 955 | if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]); |
| 956 | 956 | } |
| @@ -1050,11 +1050,11 @@ | ||
| 1050 | 1050 | if( zDetail && zDetail[0] ){ |
| 1051 | 1051 | fossil_print(" %s\n", zDetail); |
| 1052 | 1052 | } |
| 1053 | 1053 | fossil_free(zSrc); |
| 1054 | 1054 | fossil_free(zDate); |
| 1055 | - rc = 1; | |
| 1055 | + rc = 1; | |
| 1056 | 1056 | } |
| 1057 | 1057 | return rc; |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | /* |
| @@ -1097,11 +1097,11 @@ | ||
| 1097 | 1097 | if( p ){ |
| 1098 | 1098 | nArtifact++; |
| 1099 | 1099 | nErr += check_exists(p->zBaseline, flags, p, "baseline of", 0); |
| 1100 | 1100 | nErr += check_exists(p->zAttachSrc, flags, p, "file of", 0); |
| 1101 | 1101 | for(i=0; i<p->nFile; i++){ |
| 1102 | - nErr += check_exists(p->aFile[i].zUuid, flags, p, "file of", | |
| 1102 | + nErr += check_exists(p->aFile[i].zUuid, flags, p, "file of", | |
| 1103 | 1103 | p->aFile[i].zName); |
| 1104 | 1104 | } |
| 1105 | 1105 | for(i=0; i<p->nParent; i++){ |
| 1106 | 1106 | nErr += check_exists(p->azParent[i], flags, p, "parent of", 0); |
| 1107 | 1107 | } |
| @@ -1115,14 +1115,14 @@ | ||
| 1115 | 1115 | nErr += check_exists(p->azCChild[i], flags, p, "in", 0); |
| 1116 | 1116 | } |
| 1117 | 1117 | for(i=0; i<p->nTag; i++){ |
| 1118 | 1118 | nErr += check_exists(p->aTag[i].zUuid, flags, p, "target of", 0); |
| 1119 | 1119 | } |
| 1120 | - manifest_destroy(p); | |
| 1120 | + manifest_destroy(p); | |
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | db_finalize(&q); |
| 1124 | 1124 | if( nErr>0 || quietFlag==0 ){ |
| 1125 | 1125 | fossil_print("%d missing or shunned references in %d control artifacts\n", |
| 1126 | 1126 | nErr, nArtifact); |
| 1127 | 1127 | } |
| 1128 | 1128 | } |
| 1129 | 1129 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -114,11 +114,11 @@ | |
| 114 | contentCache.n = 0; |
| 115 | contentCache.szTotal = 0; |
| 116 | } |
| 117 | |
| 118 | /* |
| 119 | ** Return the srcid associated with rid. Or return 0 if rid is |
| 120 | ** original content and not a delta. |
| 121 | */ |
| 122 | static int findSrcid(int rid){ |
| 123 | static Stmt q; |
| 124 | int srcid; |
| @@ -154,11 +154,11 @@ | |
| 154 | ** a phantom. |
| 155 | */ |
| 156 | int content_is_available(int rid){ |
| 157 | int srcid; |
| 158 | int depth = 0; /* Limit to recursion depth */ |
| 159 | while( depth++ < 10000000 ){ |
| 160 | if( bag_find(&contentCache.missing, rid) ){ |
| 161 | return 0; |
| 162 | } |
| 163 | if( bag_find(&contentCache.available, rid) ){ |
| 164 | return 1; |
| @@ -416,11 +416,11 @@ | |
| 416 | |
| 417 | /* Recursively dephantomize all artifacts that are derived by |
| 418 | ** delta from artifact rid and which have not already been |
| 419 | ** cross-linked. */ |
| 420 | nChildUsed = 0; |
| 421 | db_prepare(&q, |
| 422 | "SELECT rid FROM delta" |
| 423 | " WHERE srcid=%d" |
| 424 | " AND NOT EXISTS(SELECT 1 FROM mlink WHERE mid=delta.rid)", |
| 425 | rid |
| 426 | ); |
| @@ -455,11 +455,11 @@ | |
| 455 | /* |
| 456 | ** Write content into the database. Return the record ID. If the |
| 457 | ** content is already in the database, just return the record ID. |
| 458 | ** |
| 459 | ** If srcId is specified, then pBlob is delta content from |
| 460 | ** the srcId record. srcId might be a phantom. |
| 461 | ** |
| 462 | ** pBlob is normally uncompressed text. But if nBlob>0 then the |
| 463 | ** pBlob value has already been compressed and nBlob is its uncompressed |
| 464 | ** size. If nBlob>0 then zUuid must be valid. |
| 465 | ** |
| @@ -486,11 +486,11 @@ | |
| 486 | Stmt s1; |
| 487 | Blob cmpr; |
| 488 | Blob hash; |
| 489 | int markAsUnclustered = 0; |
| 490 | int isDephantomize = 0; |
| 491 | |
| 492 | assert( g.repositoryOpen ); |
| 493 | assert( pBlob!=0 ); |
| 494 | assert( srcId==0 || zUuid!=0 ); |
| 495 | if( zUuid==0 ){ |
| 496 | assert( nBlob==0 ); |
| @@ -580,18 +580,18 @@ | |
| 580 | ** really a delta. Record this fact in the delta table. |
| 581 | */ |
| 582 | if( srcId ){ |
| 583 | db_multi_exec("REPLACE INTO delta(rid,srcid) VALUES(%d,%d)", rid, srcId); |
| 584 | } |
| 585 | if( !isDephantomize && bag_find(&contentCache.missing, rid) && |
| 586 | (srcId==0 || content_is_available(srcId)) ){ |
| 587 | content_mark_available(rid); |
| 588 | } |
| 589 | if( isDephantomize ){ |
| 590 | after_dephantomize(rid, 0); |
| 591 | } |
| 592 | |
| 593 | /* Add the element to the unclustered table if has never been |
| 594 | ** previously seen. |
| 595 | */ |
| 596 | if( markAsUnclustered ){ |
| 597 | db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d)", rid); |
| @@ -628,11 +628,11 @@ | |
| 628 | ** Create a new phantom with the given UUID and return its artifact ID. |
| 629 | */ |
| 630 | int content_new(const char *zUuid, int isPrivate){ |
| 631 | int rid; |
| 632 | static Stmt s1, s2, s3; |
| 633 | |
| 634 | assert( g.repositoryOpen ); |
| 635 | db_begin_transaction(); |
| 636 | if( uuid_is_shunned(zUuid) ){ |
| 637 | db_end_transaction(0); |
| 638 | return 0; |
| @@ -727,15 +727,15 @@ | |
| 727 | "SELECT 1 FROM private WHERE rid=:rid" |
| 728 | ); |
| 729 | db_bind_int(&s1, ":rid", rid); |
| 730 | rc = db_step(&s1); |
| 731 | db_reset(&s1); |
| 732 | return rc==SQLITE_ROW; |
| 733 | } |
| 734 | |
| 735 | /* |
| 736 | ** Make sure an artifact is public. |
| 737 | */ |
| 738 | void content_make_public(int rid){ |
| 739 | static Stmt s1; |
| 740 | db_static_prepare(&s1, |
| 741 | "DELETE FROM private WHERE rid=:rid" |
| @@ -758,11 +758,11 @@ | |
| 758 | ** |
| 759 | ** If srcid is a delta that depends on rid, then srcid is |
| 760 | ** converted to undeltaed text. |
| 761 | ** |
| 762 | ** If either rid or srcid contain less than 50 bytes, or if the |
| 763 | ** resulting delta does not achieve a compression of at least 25% |
| 764 | ** the rid is left untouched. |
| 765 | ** |
| 766 | ** Return 1 if a delta is made and 0 if no delta occurs. |
| 767 | */ |
| 768 | int content_deltify(int rid, int srcid, int force){ |
| @@ -883,11 +883,11 @@ | |
| 883 | zId, rid, zSrc, srcid |
| 884 | ); |
| 885 | nErr++; |
| 886 | } |
| 887 | db_finalize(&q); |
| 888 | |
| 889 | db_prepare(&q, "SELECT rid, uuid, size FROM blob ORDER BY rid"); |
| 890 | total = db_int(0, "SELECT max(rid) FROM blob"); |
| 891 | while( db_step(&q)==SQLITE_ROW ){ |
| 892 | int rid = db_column_int(&q, 0); |
| 893 | const char *zUuid = db_column_text(&q, 1); |
| @@ -945,12 +945,12 @@ | |
| 945 | } |
| 946 | db_finalize(&q); |
| 947 | fossil_print("%d non-phantom blobs (out of %d total) checked: %d errors\n", |
| 948 | n2, n1, nErr); |
| 949 | if( bParse ){ |
| 950 | const char *azType[] = { 0, "manifest", "cluster", "control", "wiki", |
| 951 | "ticket", "attachment", "event" }; |
| 952 | int i; |
| 953 | fossil_print("%d total control artifacts\n", nCA); |
| 954 | for(i=1; i<count(azType); i++){ |
| 955 | if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]); |
| 956 | } |
| @@ -1050,11 +1050,11 @@ | |
| 1050 | if( zDetail && zDetail[0] ){ |
| 1051 | fossil_print(" %s\n", zDetail); |
| 1052 | } |
| 1053 | fossil_free(zSrc); |
| 1054 | fossil_free(zDate); |
| 1055 | rc = 1; |
| 1056 | } |
| 1057 | return rc; |
| 1058 | } |
| 1059 | |
| 1060 | /* |
| @@ -1097,11 +1097,11 @@ | |
| 1097 | if( p ){ |
| 1098 | nArtifact++; |
| 1099 | nErr += check_exists(p->zBaseline, flags, p, "baseline of", 0); |
| 1100 | nErr += check_exists(p->zAttachSrc, flags, p, "file of", 0); |
| 1101 | for(i=0; i<p->nFile; i++){ |
| 1102 | nErr += check_exists(p->aFile[i].zUuid, flags, p, "file of", |
| 1103 | p->aFile[i].zName); |
| 1104 | } |
| 1105 | for(i=0; i<p->nParent; i++){ |
| 1106 | nErr += check_exists(p->azParent[i], flags, p, "parent of", 0); |
| 1107 | } |
| @@ -1115,14 +1115,14 @@ | |
| 1115 | nErr += check_exists(p->azCChild[i], flags, p, "in", 0); |
| 1116 | } |
| 1117 | for(i=0; i<p->nTag; i++){ |
| 1118 | nErr += check_exists(p->aTag[i].zUuid, flags, p, "target of", 0); |
| 1119 | } |
| 1120 | manifest_destroy(p); |
| 1121 | } |
| 1122 | } |
| 1123 | db_finalize(&q); |
| 1124 | if( nErr>0 || quietFlag==0 ){ |
| 1125 | fossil_print("%d missing or shunned references in %d control artifacts\n", |
| 1126 | nErr, nArtifact); |
| 1127 | } |
| 1128 | } |
| 1129 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -114,11 +114,11 @@ | |
| 114 | contentCache.n = 0; |
| 115 | contentCache.szTotal = 0; |
| 116 | } |
| 117 | |
| 118 | /* |
| 119 | ** Return the srcid associated with rid. Or return 0 if rid is |
| 120 | ** original content and not a delta. |
| 121 | */ |
| 122 | static int findSrcid(int rid){ |
| 123 | static Stmt q; |
| 124 | int srcid; |
| @@ -154,11 +154,11 @@ | |
| 154 | ** a phantom. |
| 155 | */ |
| 156 | int content_is_available(int rid){ |
| 157 | int srcid; |
| 158 | int depth = 0; /* Limit to recursion depth */ |
| 159 | while( depth++ < 10000000 ){ |
| 160 | if( bag_find(&contentCache.missing, rid) ){ |
| 161 | return 0; |
| 162 | } |
| 163 | if( bag_find(&contentCache.available, rid) ){ |
| 164 | return 1; |
| @@ -416,11 +416,11 @@ | |
| 416 | |
| 417 | /* Recursively dephantomize all artifacts that are derived by |
| 418 | ** delta from artifact rid and which have not already been |
| 419 | ** cross-linked. */ |
| 420 | nChildUsed = 0; |
| 421 | db_prepare(&q, |
| 422 | "SELECT rid FROM delta" |
| 423 | " WHERE srcid=%d" |
| 424 | " AND NOT EXISTS(SELECT 1 FROM mlink WHERE mid=delta.rid)", |
| 425 | rid |
| 426 | ); |
| @@ -455,11 +455,11 @@ | |
| 455 | /* |
| 456 | ** Write content into the database. Return the record ID. If the |
| 457 | ** content is already in the database, just return the record ID. |
| 458 | ** |
| 459 | ** If srcId is specified, then pBlob is delta content from |
| 460 | ** the srcId record. srcId might be a phantom. |
| 461 | ** |
| 462 | ** pBlob is normally uncompressed text. But if nBlob>0 then the |
| 463 | ** pBlob value has already been compressed and nBlob is its uncompressed |
| 464 | ** size. If nBlob>0 then zUuid must be valid. |
| 465 | ** |
| @@ -486,11 +486,11 @@ | |
| 486 | Stmt s1; |
| 487 | Blob cmpr; |
| 488 | Blob hash; |
| 489 | int markAsUnclustered = 0; |
| 490 | int isDephantomize = 0; |
| 491 | |
| 492 | assert( g.repositoryOpen ); |
| 493 | assert( pBlob!=0 ); |
| 494 | assert( srcId==0 || zUuid!=0 ); |
| 495 | if( zUuid==0 ){ |
| 496 | assert( nBlob==0 ); |
| @@ -580,18 +580,18 @@ | |
| 580 | ** really a delta. Record this fact in the delta table. |
| 581 | */ |
| 582 | if( srcId ){ |
| 583 | db_multi_exec("REPLACE INTO delta(rid,srcid) VALUES(%d,%d)", rid, srcId); |
| 584 | } |
| 585 | if( !isDephantomize && bag_find(&contentCache.missing, rid) && |
| 586 | (srcId==0 || content_is_available(srcId)) ){ |
| 587 | content_mark_available(rid); |
| 588 | } |
| 589 | if( isDephantomize ){ |
| 590 | after_dephantomize(rid, 0); |
| 591 | } |
| 592 | |
| 593 | /* Add the element to the unclustered table if has never been |
| 594 | ** previously seen. |
| 595 | */ |
| 596 | if( markAsUnclustered ){ |
| 597 | db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d)", rid); |
| @@ -628,11 +628,11 @@ | |
| 628 | ** Create a new phantom with the given UUID and return its artifact ID. |
| 629 | */ |
| 630 | int content_new(const char *zUuid, int isPrivate){ |
| 631 | int rid; |
| 632 | static Stmt s1, s2, s3; |
| 633 | |
| 634 | assert( g.repositoryOpen ); |
| 635 | db_begin_transaction(); |
| 636 | if( uuid_is_shunned(zUuid) ){ |
| 637 | db_end_transaction(0); |
| 638 | return 0; |
| @@ -727,15 +727,15 @@ | |
| 727 | "SELECT 1 FROM private WHERE rid=:rid" |
| 728 | ); |
| 729 | db_bind_int(&s1, ":rid", rid); |
| 730 | rc = db_step(&s1); |
| 731 | db_reset(&s1); |
| 732 | return rc==SQLITE_ROW; |
| 733 | } |
| 734 | |
| 735 | /* |
| 736 | ** Make sure an artifact is public. |
| 737 | */ |
| 738 | void content_make_public(int rid){ |
| 739 | static Stmt s1; |
| 740 | db_static_prepare(&s1, |
| 741 | "DELETE FROM private WHERE rid=:rid" |
| @@ -758,11 +758,11 @@ | |
| 758 | ** |
| 759 | ** If srcid is a delta that depends on rid, then srcid is |
| 760 | ** converted to undeltaed text. |
| 761 | ** |
| 762 | ** If either rid or srcid contain less than 50 bytes, or if the |
| 763 | ** resulting delta does not achieve a compression of at least 25% |
| 764 | ** the rid is left untouched. |
| 765 | ** |
| 766 | ** Return 1 if a delta is made and 0 if no delta occurs. |
| 767 | */ |
| 768 | int content_deltify(int rid, int srcid, int force){ |
| @@ -883,11 +883,11 @@ | |
| 883 | zId, rid, zSrc, srcid |
| 884 | ); |
| 885 | nErr++; |
| 886 | } |
| 887 | db_finalize(&q); |
| 888 | |
| 889 | db_prepare(&q, "SELECT rid, uuid, size FROM blob ORDER BY rid"); |
| 890 | total = db_int(0, "SELECT max(rid) FROM blob"); |
| 891 | while( db_step(&q)==SQLITE_ROW ){ |
| 892 | int rid = db_column_int(&q, 0); |
| 893 | const char *zUuid = db_column_text(&q, 1); |
| @@ -945,12 +945,12 @@ | |
| 945 | } |
| 946 | db_finalize(&q); |
| 947 | fossil_print("%d non-phantom blobs (out of %d total) checked: %d errors\n", |
| 948 | n2, n1, nErr); |
| 949 | if( bParse ){ |
| 950 | static const char *const azType[] = { 0, "manifest", "cluster", |
| 951 | "control", "wiki", "ticket", "attachment", "event" }; |
| 952 | int i; |
| 953 | fossil_print("%d total control artifacts\n", nCA); |
| 954 | for(i=1; i<count(azType); i++){ |
| 955 | if( anCA[i] ) fossil_print(" %d %ss\n", anCA[i], azType[i]); |
| 956 | } |
| @@ -1050,11 +1050,11 @@ | |
| 1050 | if( zDetail && zDetail[0] ){ |
| 1051 | fossil_print(" %s\n", zDetail); |
| 1052 | } |
| 1053 | fossil_free(zSrc); |
| 1054 | fossil_free(zDate); |
| 1055 | rc = 1; |
| 1056 | } |
| 1057 | return rc; |
| 1058 | } |
| 1059 | |
| 1060 | /* |
| @@ -1097,11 +1097,11 @@ | |
| 1097 | if( p ){ |
| 1098 | nArtifact++; |
| 1099 | nErr += check_exists(p->zBaseline, flags, p, "baseline of", 0); |
| 1100 | nErr += check_exists(p->zAttachSrc, flags, p, "file of", 0); |
| 1101 | for(i=0; i<p->nFile; i++){ |
| 1102 | nErr += check_exists(p->aFile[i].zUuid, flags, p, "file of", |
| 1103 | p->aFile[i].zName); |
| 1104 | } |
| 1105 | for(i=0; i<p->nParent; i++){ |
| 1106 | nErr += check_exists(p->azParent[i], flags, p, "parent of", 0); |
| 1107 | } |
| @@ -1115,14 +1115,14 @@ | |
| 1115 | nErr += check_exists(p->azCChild[i], flags, p, "in", 0); |
| 1116 | } |
| 1117 | for(i=0; i<p->nTag; i++){ |
| 1118 | nErr += check_exists(p->aTag[i].zUuid, flags, p, "target of", 0); |
| 1119 | } |
| 1120 | manifest_destroy(p); |
| 1121 | } |
| 1122 | } |
| 1123 | db_finalize(&q); |
| 1124 | if( nErr>0 || quietFlag==0 ){ |
| 1125 | fossil_print("%d missing or shunned references in %d control artifacts\n", |
| 1126 | nErr, nArtifact); |
| 1127 | } |
| 1128 | } |
| 1129 |
M
src/db.c
+2
-8
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -44,11 +44,11 @@ | ||
| 44 | 44 | ** An single SQL statement is represented as an instance of the following |
| 45 | 45 | ** structure. |
| 46 | 46 | */ |
| 47 | 47 | struct Stmt { |
| 48 | 48 | Blob sql; /* The SQL for this statement */ |
| 49 | - sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */ | |
| 49 | + sqlite3_stmt *pStmt; /* The results of sqlite3_prepare_v2() */ | |
| 50 | 50 | Stmt *pNext, *pPrev; /* List of all unfinalized statements */ |
| 51 | 51 | int nStep; /* Number of sqlite3_step() calls */ |
| 52 | 52 | }; |
| 53 | 53 | |
| 54 | 54 | /* |
| @@ -108,11 +108,11 @@ | ||
| 108 | 108 | static struct DbLocalData { |
| 109 | 109 | int nBegin; /* Nesting depth of BEGIN */ |
| 110 | 110 | int doRollback; /* True to force a rollback */ |
| 111 | 111 | int nCommitHook; /* Number of commit hooks */ |
| 112 | 112 | Stmt *pAllStmt; /* List of all unfinalized statements */ |
| 113 | - int nPrepare; /* Number of calls to sqlite3_prepare() */ | |
| 113 | + int nPrepare; /* Number of calls to sqlite3_prepare_v2() */ | |
| 114 | 114 | int nDeleteOnFail; /* Number of entries in azDeleteOnFail[] */ |
| 115 | 115 | struct sCommitHook { |
| 116 | 116 | int (*xHook)(void); /* Functions to call at db_end_transaction() */ |
| 117 | 117 | int sequence; /* Call functions in sequence order */ |
| 118 | 118 | } aHook[5]; |
| @@ -716,17 +716,11 @@ | ||
| 716 | 716 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 717 | 717 | int rc; |
| 718 | 718 | sqlite3 *db; |
| 719 | 719 | |
| 720 | 720 | #if defined(__CYGWIN__) |
| 721 | - /* Necessary if we want Cygwin fossil to recognize win32 file | |
| 722 | - * paths, as SQLite doesn't handle that (yet) */ | |
| 723 | 721 | zDbName = fossil_utf8_to_filename(zDbName); |
| 724 | -#elif defined(_WIN32) | |
| 725 | - /* Only necessary when SQLite doesn't handle Extended paths. */ | |
| 726 | - zDbName = fossil_utf8_to_filename(zDbName); | |
| 727 | - zDbName = fossil_filename_to_utf8(zDbName); | |
| 728 | 722 | #endif |
| 729 | 723 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 730 | 724 | rc = sqlite3_open_v2( |
| 731 | 725 | zDbName, &db, |
| 732 | 726 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 733 | 727 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -44,11 +44,11 @@ | |
| 44 | ** An single SQL statement is represented as an instance of the following |
| 45 | ** structure. |
| 46 | */ |
| 47 | struct Stmt { |
| 48 | Blob sql; /* The SQL for this statement */ |
| 49 | sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */ |
| 50 | Stmt *pNext, *pPrev; /* List of all unfinalized statements */ |
| 51 | int nStep; /* Number of sqlite3_step() calls */ |
| 52 | }; |
| 53 | |
| 54 | /* |
| @@ -108,11 +108,11 @@ | |
| 108 | static struct DbLocalData { |
| 109 | int nBegin; /* Nesting depth of BEGIN */ |
| 110 | int doRollback; /* True to force a rollback */ |
| 111 | int nCommitHook; /* Number of commit hooks */ |
| 112 | Stmt *pAllStmt; /* List of all unfinalized statements */ |
| 113 | int nPrepare; /* Number of calls to sqlite3_prepare() */ |
| 114 | int nDeleteOnFail; /* Number of entries in azDeleteOnFail[] */ |
| 115 | struct sCommitHook { |
| 116 | int (*xHook)(void); /* Functions to call at db_end_transaction() */ |
| 117 | int sequence; /* Call functions in sequence order */ |
| 118 | } aHook[5]; |
| @@ -716,17 +716,11 @@ | |
| 716 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 717 | int rc; |
| 718 | sqlite3 *db; |
| 719 | |
| 720 | #if defined(__CYGWIN__) |
| 721 | /* Necessary if we want Cygwin fossil to recognize win32 file |
| 722 | * paths, as SQLite doesn't handle that (yet) */ |
| 723 | zDbName = fossil_utf8_to_filename(zDbName); |
| 724 | #elif defined(_WIN32) |
| 725 | /* Only necessary when SQLite doesn't handle Extended paths. */ |
| 726 | zDbName = fossil_utf8_to_filename(zDbName); |
| 727 | zDbName = fossil_filename_to_utf8(zDbName); |
| 728 | #endif |
| 729 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 730 | rc = sqlite3_open_v2( |
| 731 | zDbName, &db, |
| 732 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 733 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -44,11 +44,11 @@ | |
| 44 | ** An single SQL statement is represented as an instance of the following |
| 45 | ** structure. |
| 46 | */ |
| 47 | struct Stmt { |
| 48 | Blob sql; /* The SQL for this statement */ |
| 49 | sqlite3_stmt *pStmt; /* The results of sqlite3_prepare_v2() */ |
| 50 | Stmt *pNext, *pPrev; /* List of all unfinalized statements */ |
| 51 | int nStep; /* Number of sqlite3_step() calls */ |
| 52 | }; |
| 53 | |
| 54 | /* |
| @@ -108,11 +108,11 @@ | |
| 108 | static struct DbLocalData { |
| 109 | int nBegin; /* Nesting depth of BEGIN */ |
| 110 | int doRollback; /* True to force a rollback */ |
| 111 | int nCommitHook; /* Number of commit hooks */ |
| 112 | Stmt *pAllStmt; /* List of all unfinalized statements */ |
| 113 | int nPrepare; /* Number of calls to sqlite3_prepare_v2() */ |
| 114 | int nDeleteOnFail; /* Number of entries in azDeleteOnFail[] */ |
| 115 | struct sCommitHook { |
| 116 | int (*xHook)(void); /* Functions to call at db_end_transaction() */ |
| 117 | int sequence; /* Call functions in sequence order */ |
| 118 | } aHook[5]; |
| @@ -716,17 +716,11 @@ | |
| 716 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 717 | int rc; |
| 718 | sqlite3 *db; |
| 719 | |
| 720 | #if defined(__CYGWIN__) |
| 721 | zDbName = fossil_utf8_to_filename(zDbName); |
| 722 | #endif |
| 723 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 724 | rc = sqlite3_open_v2( |
| 725 | zDbName, &db, |
| 726 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 727 |
-6
| --- src/descendants.c | ||
| +++ src/descendants.c | ||
| @@ -447,16 +447,10 @@ | ||
| 447 | 447 | db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql)); |
| 448 | 448 | blob_reset(&sql); |
| 449 | 449 | www_print_timeline(&q, TIMELINE_LEAFONLY, 0, 0, 0); |
| 450 | 450 | db_finalize(&q); |
| 451 | 451 | @ <br /> |
| 452 | - @ <script type="text/JavaScript"> | |
| 453 | - @ function xin(id){ | |
| 454 | - @ } | |
| 455 | - @ function xout(id){ | |
| 456 | - @ } | |
| 457 | - @ </script> | |
| 458 | 452 | style_footer(); |
| 459 | 453 | } |
| 460 | 454 | |
| 461 | 455 | #if INTERFACE |
| 462 | 456 | /* Flag parameters to compute_uses_file() */ |
| 463 | 457 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -447,16 +447,10 @@ | |
| 447 | db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql)); |
| 448 | blob_reset(&sql); |
| 449 | www_print_timeline(&q, TIMELINE_LEAFONLY, 0, 0, 0); |
| 450 | db_finalize(&q); |
| 451 | @ <br /> |
| 452 | @ <script type="text/JavaScript"> |
| 453 | @ function xin(id){ |
| 454 | @ } |
| 455 | @ function xout(id){ |
| 456 | @ } |
| 457 | @ </script> |
| 458 | style_footer(); |
| 459 | } |
| 460 | |
| 461 | #if INTERFACE |
| 462 | /* Flag parameters to compute_uses_file() */ |
| 463 |
| --- src/descendants.c | |
| +++ src/descendants.c | |
| @@ -447,16 +447,10 @@ | |
| 447 | db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_str(&sql)); |
| 448 | blob_reset(&sql); |
| 449 | www_print_timeline(&q, TIMELINE_LEAFONLY, 0, 0, 0); |
| 450 | db_finalize(&q); |
| 451 | @ <br /> |
| 452 | style_footer(); |
| 453 | } |
| 454 | |
| 455 | #if INTERFACE |
| 456 | /* Flag parameters to compute_uses_file() */ |
| 457 |
+52
-35
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -599,11 +599,11 @@ | ||
| 599 | 599 | |
| 600 | 600 | /* A Tcl/Tk script used to render diff output. |
| 601 | 601 | */ |
| 602 | 602 | static const char zDiffScript[] = |
| 603 | 603 | @ package require Tk |
| 604 | -@ | |
| 604 | +@ | |
| 605 | 605 | @ array set CFG { |
| 606 | 606 | @ TITLE {Fossil Diff} |
| 607 | 607 | @ LN_COL_BG #dddddd |
| 608 | 608 | @ LN_COL_FG #444444 |
| 609 | 609 | @ TXT_COL_BG #ffffff |
| @@ -622,30 +622,30 @@ | ||
| 622 | 622 | @ PADX 5 |
| 623 | 623 | @ WIDTH 80 |
| 624 | 624 | @ HEIGHT 45 |
| 625 | 625 | @ LB_HEIGHT 25 |
| 626 | 626 | @ } |
| 627 | -@ | |
| 627 | +@ | |
| 628 | 628 | @ if {![namespace exists ttk]} { |
| 629 | 629 | @ interp alias {} ::ttk::scrollbar {} ::scrollbar |
| 630 | 630 | @ interp alias {} ::ttk::menubutton {} ::menubutton |
| 631 | 631 | @ } |
| 632 | -@ | |
| 632 | +@ | |
| 633 | 633 | @ proc dehtml {x} { |
| 634 | 634 | @ set x [regsub -all {<[^>]*>} $x {}] |
| 635 | 635 | @ return [string map {& & < < > > ' ' " \"} $x] |
| 636 | 636 | @ } |
| 637 | -@ | |
| 637 | +@ | |
| 638 | 638 | @ proc cols {} { |
| 639 | 639 | @ return [list .lnA .txtA .mkr .lnB .txtB] |
| 640 | 640 | @ } |
| 641 | -@ | |
| 641 | +@ | |
| 642 | 642 | @ proc colType {c} { |
| 643 | 643 | @ regexp {[a-z]+} $c type |
| 644 | 644 | @ return $type |
| 645 | 645 | @ } |
| 646 | -@ | |
| 646 | +@ | |
| 647 | 647 | @ proc readDiffs {fossilcmd} { |
| 648 | 648 | @ set in [open $fossilcmd r] |
| 649 | 649 | @ fconfigure $in -encoding utf-8 |
| 650 | 650 | @ set nDiffs 0 |
| 651 | 651 | @ array set widths {txt 0 ln 0 mkr 0} |
| @@ -657,34 +657,34 @@ | ||
| 657 | 657 | @ continue |
| 658 | 658 | @ } |
| 659 | 659 | @ incr nDiffs |
| 660 | 660 | @ set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}] |
| 661 | 661 | @ .wfiles.lb insert end $fn |
| 662 | -@ | |
| 662 | +@ | |
| 663 | 663 | @ foreach c [cols] { |
| 664 | 664 | @ while {[gets $in] ne "<pre>"} continue |
| 665 | -@ | |
| 665 | +@ | |
| 666 | 666 | @ if {$nDiffs > 1} { |
| 667 | 667 | @ $c insert end \n - |
| 668 | 668 | @ } |
| 669 | 669 | @ if {[colType $c] eq "txt"} { |
| 670 | 670 | @ $c insert end $fn\n fn |
| 671 | 671 | @ } else { |
| 672 | 672 | @ $c insert end \n fn |
| 673 | 673 | @ } |
| 674 | 674 | @ $c insert end \n - |
| 675 | -@ | |
| 675 | +@ | |
| 676 | 676 | @ set type [colType $c] |
| 677 | 677 | @ set str {} |
| 678 | 678 | @ while {[set line [gets $in]] ne "</pre>"} { |
| 679 | 679 | @ set len [string length [dehtml $line]] |
| 680 | 680 | @ if {$len > $widths($type)} { |
| 681 | 681 | @ set widths($type) $len |
| 682 | 682 | @ } |
| 683 | 683 | @ append str $line\n |
| 684 | 684 | @ } |
| 685 | -@ | |
| 685 | +@ | |
| 686 | 686 | @ set re {<span class="diff([a-z]+)">([^<]*)</span>} |
| 687 | 687 | @ # Use \r as separator since it can't appear in the diff output (it gets |
| 688 | 688 | @ # converted to a space). |
| 689 | 689 | @ set str [regsub -all $re $str "\r\\1\r\\2\r"] |
| 690 | 690 | @ foreach {pre class mid} [split $str \r] { |
| @@ -695,11 +695,11 @@ | ||
| 695 | 695 | @ } |
| 696 | 696 | @ } |
| 697 | 697 | @ } |
| 698 | 698 | @ } |
| 699 | 699 | @ close $in |
| 700 | -@ | |
| 700 | +@ | |
| 701 | 701 | @ foreach c [cols] { |
| 702 | 702 | @ set type [colType $c] |
| 703 | 703 | @ if {$type ne "txt"} { |
| 704 | 704 | @ $c config -width $widths($type) |
| 705 | 705 | @ } |
| @@ -707,19 +707,19 @@ | ||
| 707 | 707 | @ } |
| 708 | 708 | @ if {$nDiffs <= [.wfiles.lb cget -height]} { |
| 709 | 709 | @ .wfiles.lb config -height $nDiffs |
| 710 | 710 | @ grid remove .wfiles.sb |
| 711 | 711 | @ } |
| 712 | -@ | |
| 712 | +@ | |
| 713 | 713 | @ return $nDiffs |
| 714 | 714 | @ } |
| 715 | -@ | |
| 715 | +@ | |
| 716 | 716 | @ proc viewDiff {idx} { |
| 717 | 717 | @ .txtA yview $idx |
| 718 | 718 | @ .txtA xview moveto 0 |
| 719 | 719 | @ } |
| 720 | -@ | |
| 720 | +@ | |
| 721 | 721 | @ proc cycleDiffs {{reverse 0}} { |
| 722 | 722 | @ if {$reverse} { |
| 723 | 723 | @ set range [.txtA tag prevrange fn @0,0 1.0] |
| 724 | 724 | @ if {$range eq ""} { |
| 725 | 725 | @ viewDiff {fn.last -1c} |
| @@ -733,36 +733,36 @@ | ||
| 733 | 733 | @ } else { |
| 734 | 734 | @ viewDiff [lindex $range 0] |
| 735 | 735 | @ } |
| 736 | 736 | @ } |
| 737 | 737 | @ } |
| 738 | -@ | |
| 738 | +@ | |
| 739 | 739 | @ proc xvis {col} { |
| 740 | 740 | @ set view [$col xview] |
| 741 | 741 | @ return [expr {[lindex $view 1]-[lindex $view 0]}] |
| 742 | 742 | @ } |
| 743 | -@ | |
| 743 | +@ | |
| 744 | 744 | @ proc scroll-x {args} { |
| 745 | 745 | @ set c .txt[expr {[xvis .txtA] < [xvis .txtB] ? "A" : "B"}] |
| 746 | 746 | @ eval $c xview $args |
| 747 | 747 | @ } |
| 748 | -@ | |
| 748 | +@ | |
| 749 | 749 | @ interp alias {} scroll-y {} .txtA yview |
| 750 | -@ | |
| 750 | +@ | |
| 751 | 751 | @ proc noop {args} {} |
| 752 | -@ | |
| 752 | +@ | |
| 753 | 753 | @ proc enableSync {axis} { |
| 754 | 754 | @ update idletasks |
| 755 | 755 | @ interp alias {} sync-$axis {} |
| 756 | 756 | @ rename _sync-$axis sync-$axis |
| 757 | 757 | @ } |
| 758 | -@ | |
| 758 | +@ | |
| 759 | 759 | @ proc disableSync {axis} { |
| 760 | 760 | @ rename sync-$axis _sync-$axis |
| 761 | 761 | @ interp alias {} sync-$axis {} noop |
| 762 | 762 | @ } |
| 763 | -@ | |
| 763 | +@ | |
| 764 | 764 | @ proc sync-x {col first last} { |
| 765 | 765 | @ disableSync x |
| 766 | 766 | @ $col xview moveto [expr {$first*[xvis $col]/($last-$first)}] |
| 767 | 767 | @ foreach side {A B} { |
| 768 | 768 | @ set sb .sbx$side |
| @@ -774,11 +774,11 @@ | ||
| 774 | 774 | @ grid remove $sb |
| 775 | 775 | @ } |
| 776 | 776 | @ } |
| 777 | 777 | @ enableSync x |
| 778 | 778 | @ } |
| 779 | -@ | |
| 779 | +@ | |
| 780 | 780 | @ proc sync-y {first last} { |
| 781 | 781 | @ disableSync y |
| 782 | 782 | @ foreach c [cols] { |
| 783 | 783 | @ $c yview moveto $first |
| 784 | 784 | @ } |
| @@ -788,15 +788,16 @@ | ||
| 788 | 788 | @ } else { |
| 789 | 789 | @ grid remove .sby |
| 790 | 790 | @ } |
| 791 | 791 | @ enableSync y |
| 792 | 792 | @ } |
| 793 | -@ | |
| 793 | +@ | |
| 794 | 794 | @ wm withdraw . |
| 795 | 795 | @ wm title . $CFG(TITLE) |
| 796 | 796 | @ wm iconname . $CFG(TITLE) |
| 797 | 797 | @ bind . <q> exit |
| 798 | +@ bind . <Destroy> {after 0 exit} | |
| 798 | 799 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | 801 | @ bind . <Return> { |
| 801 | 802 | @ event generate .files <1> |
| 802 | 803 | @ event generate .files <ButtonRelease-1> |
| @@ -813,11 +814,11 @@ | ||
| 813 | 814 | @ End y {moveto 1} |
| 814 | 815 | @ } { |
| 815 | 816 | @ bind . <$key> "scroll-$axis $args; break" |
| 816 | 817 | @ bind . <Shift-$key> continue |
| 817 | 818 | @ } |
| 818 | -@ | |
| 819 | +@ | |
| 819 | 820 | @ ::ttk::menubutton .files -text "Files" |
| 820 | 821 | @ toplevel .wfiles |
| 821 | 822 | @ wm withdraw .wfiles |
| 822 | 823 | @ update idletasks |
| 823 | 824 | @ wm transient .wfiles . |
| @@ -847,16 +848,16 @@ | ||
| 847 | 848 | @ } |
| 848 | 849 | @ bind .wfiles.lb <Motion> { |
| 849 | 850 | @ %W selection clear 0 end |
| 850 | 851 | @ %W selection set @%x,%y |
| 851 | 852 | @ } |
| 852 | -@ | |
| 853 | +@ | |
| 853 | 854 | @ foreach {side syncCol} {A .txtB B .txtA} { |
| 854 | 855 | @ set ln .ln$side |
| 855 | 856 | @ text $ln |
| 856 | 857 | @ $ln tag config - -justify right |
| 857 | -@ | |
| 858 | +@ | |
| 858 | 859 | @ set txt .txt$side |
| 859 | 860 | @ text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \ |
| 860 | 861 | @ -xscroll "sync-x $syncCol" |
| 861 | 862 | @ catch {$txt config -tabstyle wordprocessor} ;# Required for Tk>=8.5 |
| 862 | 863 | @ foreach tag {add rm chng} { |
| @@ -865,11 +866,11 @@ | ||
| 865 | 866 | @ } |
| 866 | 867 | @ $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \ |
| 867 | 868 | @ -justify center |
| 868 | 869 | @ } |
| 869 | 870 | @ text .mkr |
| 870 | -@ | |
| 871 | +@ | |
| 871 | 872 | @ foreach c [cols] { |
| 872 | 873 | @ set keyPrefix [string toupper [colType $c]]_COL_ |
| 873 | 874 | @ if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}} |
| 874 | 875 | @ $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \ |
| 875 | 876 | @ -padx $CFG(PADX) -yscroll sync-y |
| @@ -877,22 +878,22 @@ | ||
| 877 | 878 | @ -foreground $CFG(HR_FG) |
| 878 | 879 | @ $c tag config fn -spacing1 $CFG(FN_PAD) -spacing3 $CFG(FN_PAD) |
| 879 | 880 | @ bindtags $c ". $c Text all" |
| 880 | 881 | @ bind $c <1> {focus %W} |
| 881 | 882 | @ } |
| 882 | -@ | |
| 883 | +@ | |
| 883 | 884 | @ ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical |
| 884 | 885 | @ ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal |
| 885 | 886 | @ ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal |
| 886 | 887 | @ frame .spacer |
| 887 | -@ | |
| 888 | +@ | |
| 888 | 889 | @ if {[readDiffs $fossilcmd] == 0} { |
| 889 | 890 | @ tk_messageBox -type ok -title $CFG(TITLE) -message "No changes" |
| 890 | 891 | @ exit |
| 891 | 892 | @ } |
| 892 | 893 | @ update idletasks |
| 893 | -@ | |
| 894 | +@ | |
| 894 | 895 | @ grid rowconfigure . 1 -weight 1 |
| 895 | 896 | @ grid columnconfigure . 1 -weight 1 |
| 896 | 897 | @ grid columnconfigure . 4 -weight 1 |
| 897 | 898 | @ grid .files -row 0 -columnspan 6 |
| 898 | 899 | @ eval grid [cols] -row 1 -sticky nsew |
| @@ -906,14 +907,16 @@ | ||
| 906 | 907 | ; |
| 907 | 908 | |
| 908 | 909 | /* |
| 909 | 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | 911 | ** to the diff command. |
| 911 | -** | |
| 912 | -** Steps: | |
| 912 | +** | |
| 913 | +** If fossil has direct access to a Tcl interpreter (either loaded | |
| 914 | +** dynamically through stubs or linked in statically), we can use it | |
| 915 | +** directly. Otherwise: | |
| 913 | 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | -** (2) Invoke "wish" on the temp file using fossil_system(). | |
| 917 | +** (2) Invoke "tclsh" on the temp file using fossil_system(). | |
| 915 | 918 | ** (3) Delete the temp file. |
| 916 | 919 | */ |
| 917 | 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | 921 | int i; |
| 919 | 922 | Blob script; |
| @@ -943,10 +946,24 @@ | ||
| 943 | 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | 947 | if( zTempFile ){ |
| 945 | 948 | blob_write_to_file(&script, zTempFile); |
| 946 | 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | 950 | }else{ |
| 951 | +#if defined(FOSSIL_ENABLE_TCL) | |
| 952 | + Th_FossilInit(TH_INIT_DEFAULT); | |
| 953 | + if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), | |
| 954 | + blob_size(&script), 1)==TCL_OK ){ | |
| 955 | + blob_reset(&script); | |
| 956 | + return; | |
| 957 | + } | |
| 958 | + /* | |
| 959 | + * If evaluation of the Tcl script fails, the reason may be that Tk | |
| 960 | + * could not be found by the loaded Tcl, or that Tcl cannot be loaded | |
| 961 | + * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback | |
| 962 | + * to using the external "tclsh", if available. | |
| 963 | + */ | |
| 964 | +#endif | |
| 948 | 965 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | 967 | fossil_system(zCmd); |
| 951 | 968 | file_delete(zTempFile); |
| 952 | 969 | fossil_free(zCmd); |
| @@ -988,11 +1005,11 @@ | ||
| 988 | 1005 | ** specified (as they exist on disk) and that same file as it was checked |
| 989 | 1006 | ** out. Or if the FILE arguments are omitted, show the unsaved changed |
| 990 | 1007 | ** currently in the working check-out. |
| 991 | 1008 | ** |
| 992 | 1009 | ** If the "--from VERSION" or "-r VERSION" option is used it specifies |
| 993 | -** the source check-in for the diff operation. If not specified, the | |
| 1010 | +** the source check-in for the diff operation. If not specified, the | |
| 994 | 1011 | ** source check-in is the base check-in for the current check-out. |
| 995 | 1012 | ** |
| 996 | 1013 | ** If the "--to VERSION" option appears, it specifies the check-in from |
| 997 | 1014 | ** which the second version of the file or files is taken. If there is |
| 998 | 1015 | ** no "--to" option then the (possibly edited) files in the current check-out |
| @@ -1015,11 +1032,11 @@ | ||
| 1015 | 1032 | ** |
| 1016 | 1033 | ** Options: |
| 1017 | 1034 | ** --binary PATTERN Treat files that match the glob PATTERN as binary |
| 1018 | 1035 | ** --branch BRANCH Show diff of all changes on BRANCH |
| 1019 | 1036 | ** --brief Show filenames only |
| 1020 | -** --context|-c N Use N lines of context | |
| 1037 | +** --context|-c N Use N lines of context | |
| 1021 | 1038 | ** --diff-binary BOOL Include binary files when using external commands |
| 1022 | 1039 | ** --from|-r VERSION select VERSION as source for the diff |
| 1023 | 1040 | ** --internal|-i use internal diff logic |
| 1024 | 1041 | ** --side-by-side|-y side-by-side diff |
| 1025 | 1042 | ** --tk Launch a Tcl/Tk GUI for display |
| 1026 | 1043 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -599,11 +599,11 @@ | |
| 599 | |
| 600 | /* A Tcl/Tk script used to render diff output. |
| 601 | */ |
| 602 | static const char zDiffScript[] = |
| 603 | @ package require Tk |
| 604 | @ |
| 605 | @ array set CFG { |
| 606 | @ TITLE {Fossil Diff} |
| 607 | @ LN_COL_BG #dddddd |
| 608 | @ LN_COL_FG #444444 |
| 609 | @ TXT_COL_BG #ffffff |
| @@ -622,30 +622,30 @@ | |
| 622 | @ PADX 5 |
| 623 | @ WIDTH 80 |
| 624 | @ HEIGHT 45 |
| 625 | @ LB_HEIGHT 25 |
| 626 | @ } |
| 627 | @ |
| 628 | @ if {![namespace exists ttk]} { |
| 629 | @ interp alias {} ::ttk::scrollbar {} ::scrollbar |
| 630 | @ interp alias {} ::ttk::menubutton {} ::menubutton |
| 631 | @ } |
| 632 | @ |
| 633 | @ proc dehtml {x} { |
| 634 | @ set x [regsub -all {<[^>]*>} $x {}] |
| 635 | @ return [string map {& & < < > > ' ' " \"} $x] |
| 636 | @ } |
| 637 | @ |
| 638 | @ proc cols {} { |
| 639 | @ return [list .lnA .txtA .mkr .lnB .txtB] |
| 640 | @ } |
| 641 | @ |
| 642 | @ proc colType {c} { |
| 643 | @ regexp {[a-z]+} $c type |
| 644 | @ return $type |
| 645 | @ } |
| 646 | @ |
| 647 | @ proc readDiffs {fossilcmd} { |
| 648 | @ set in [open $fossilcmd r] |
| 649 | @ fconfigure $in -encoding utf-8 |
| 650 | @ set nDiffs 0 |
| 651 | @ array set widths {txt 0 ln 0 mkr 0} |
| @@ -657,34 +657,34 @@ | |
| 657 | @ continue |
| 658 | @ } |
| 659 | @ incr nDiffs |
| 660 | @ set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}] |
| 661 | @ .wfiles.lb insert end $fn |
| 662 | @ |
| 663 | @ foreach c [cols] { |
| 664 | @ while {[gets $in] ne "<pre>"} continue |
| 665 | @ |
| 666 | @ if {$nDiffs > 1} { |
| 667 | @ $c insert end \n - |
| 668 | @ } |
| 669 | @ if {[colType $c] eq "txt"} { |
| 670 | @ $c insert end $fn\n fn |
| 671 | @ } else { |
| 672 | @ $c insert end \n fn |
| 673 | @ } |
| 674 | @ $c insert end \n - |
| 675 | @ |
| 676 | @ set type [colType $c] |
| 677 | @ set str {} |
| 678 | @ while {[set line [gets $in]] ne "</pre>"} { |
| 679 | @ set len [string length [dehtml $line]] |
| 680 | @ if {$len > $widths($type)} { |
| 681 | @ set widths($type) $len |
| 682 | @ } |
| 683 | @ append str $line\n |
| 684 | @ } |
| 685 | @ |
| 686 | @ set re {<span class="diff([a-z]+)">([^<]*)</span>} |
| 687 | @ # Use \r as separator since it can't appear in the diff output (it gets |
| 688 | @ # converted to a space). |
| 689 | @ set str [regsub -all $re $str "\r\\1\r\\2\r"] |
| 690 | @ foreach {pre class mid} [split $str \r] { |
| @@ -695,11 +695,11 @@ | |
| 695 | @ } |
| 696 | @ } |
| 697 | @ } |
| 698 | @ } |
| 699 | @ close $in |
| 700 | @ |
| 701 | @ foreach c [cols] { |
| 702 | @ set type [colType $c] |
| 703 | @ if {$type ne "txt"} { |
| 704 | @ $c config -width $widths($type) |
| 705 | @ } |
| @@ -707,19 +707,19 @@ | |
| 707 | @ } |
| 708 | @ if {$nDiffs <= [.wfiles.lb cget -height]} { |
| 709 | @ .wfiles.lb config -height $nDiffs |
| 710 | @ grid remove .wfiles.sb |
| 711 | @ } |
| 712 | @ |
| 713 | @ return $nDiffs |
| 714 | @ } |
| 715 | @ |
| 716 | @ proc viewDiff {idx} { |
| 717 | @ .txtA yview $idx |
| 718 | @ .txtA xview moveto 0 |
| 719 | @ } |
| 720 | @ |
| 721 | @ proc cycleDiffs {{reverse 0}} { |
| 722 | @ if {$reverse} { |
| 723 | @ set range [.txtA tag prevrange fn @0,0 1.0] |
| 724 | @ if {$range eq ""} { |
| 725 | @ viewDiff {fn.last -1c} |
| @@ -733,36 +733,36 @@ | |
| 733 | @ } else { |
| 734 | @ viewDiff [lindex $range 0] |
| 735 | @ } |
| 736 | @ } |
| 737 | @ } |
| 738 | @ |
| 739 | @ proc xvis {col} { |
| 740 | @ set view [$col xview] |
| 741 | @ return [expr {[lindex $view 1]-[lindex $view 0]}] |
| 742 | @ } |
| 743 | @ |
| 744 | @ proc scroll-x {args} { |
| 745 | @ set c .txt[expr {[xvis .txtA] < [xvis .txtB] ? "A" : "B"}] |
| 746 | @ eval $c xview $args |
| 747 | @ } |
| 748 | @ |
| 749 | @ interp alias {} scroll-y {} .txtA yview |
| 750 | @ |
| 751 | @ proc noop {args} {} |
| 752 | @ |
| 753 | @ proc enableSync {axis} { |
| 754 | @ update idletasks |
| 755 | @ interp alias {} sync-$axis {} |
| 756 | @ rename _sync-$axis sync-$axis |
| 757 | @ } |
| 758 | @ |
| 759 | @ proc disableSync {axis} { |
| 760 | @ rename sync-$axis _sync-$axis |
| 761 | @ interp alias {} sync-$axis {} noop |
| 762 | @ } |
| 763 | @ |
| 764 | @ proc sync-x {col first last} { |
| 765 | @ disableSync x |
| 766 | @ $col xview moveto [expr {$first*[xvis $col]/($last-$first)}] |
| 767 | @ foreach side {A B} { |
| 768 | @ set sb .sbx$side |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -788,15 +788,16 @@ | |
| 788 | @ } else { |
| 789 | @ grid remove .sby |
| 790 | @ } |
| 791 | @ enableSync y |
| 792 | @ } |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Tab> {cycleDiffs; break} |
| 799 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 800 | @ bind . <Return> { |
| 801 | @ event generate .files <1> |
| 802 | @ event generate .files <ButtonRelease-1> |
| @@ -813,11 +814,11 @@ | |
| 813 | @ End y {moveto 1} |
| 814 | @ } { |
| 815 | @ bind . <$key> "scroll-$axis $args; break" |
| 816 | @ bind . <Shift-$key> continue |
| 817 | @ } |
| 818 | @ |
| 819 | @ ::ttk::menubutton .files -text "Files" |
| 820 | @ toplevel .wfiles |
| 821 | @ wm withdraw .wfiles |
| 822 | @ update idletasks |
| 823 | @ wm transient .wfiles . |
| @@ -847,16 +848,16 @@ | |
| 847 | @ } |
| 848 | @ bind .wfiles.lb <Motion> { |
| 849 | @ %W selection clear 0 end |
| 850 | @ %W selection set @%x,%y |
| 851 | @ } |
| 852 | @ |
| 853 | @ foreach {side syncCol} {A .txtB B .txtA} { |
| 854 | @ set ln .ln$side |
| 855 | @ text $ln |
| 856 | @ $ln tag config - -justify right |
| 857 | @ |
| 858 | @ set txt .txt$side |
| 859 | @ text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \ |
| 860 | @ -xscroll "sync-x $syncCol" |
| 861 | @ catch {$txt config -tabstyle wordprocessor} ;# Required for Tk>=8.5 |
| 862 | @ foreach tag {add rm chng} { |
| @@ -865,11 +866,11 @@ | |
| 865 | @ } |
| 866 | @ $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \ |
| 867 | @ -justify center |
| 868 | @ } |
| 869 | @ text .mkr |
| 870 | @ |
| 871 | @ foreach c [cols] { |
| 872 | @ set keyPrefix [string toupper [colType $c]]_COL_ |
| 873 | @ if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}} |
| 874 | @ $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \ |
| 875 | @ -padx $CFG(PADX) -yscroll sync-y |
| @@ -877,22 +878,22 @@ | |
| 877 | @ -foreground $CFG(HR_FG) |
| 878 | @ $c tag config fn -spacing1 $CFG(FN_PAD) -spacing3 $CFG(FN_PAD) |
| 879 | @ bindtags $c ". $c Text all" |
| 880 | @ bind $c <1> {focus %W} |
| 881 | @ } |
| 882 | @ |
| 883 | @ ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical |
| 884 | @ ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal |
| 885 | @ ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal |
| 886 | @ frame .spacer |
| 887 | @ |
| 888 | @ if {[readDiffs $fossilcmd] == 0} { |
| 889 | @ tk_messageBox -type ok -title $CFG(TITLE) -message "No changes" |
| 890 | @ exit |
| 891 | @ } |
| 892 | @ update idletasks |
| 893 | @ |
| 894 | @ grid rowconfigure . 1 -weight 1 |
| 895 | @ grid columnconfigure . 1 -weight 1 |
| 896 | @ grid columnconfigure . 4 -weight 1 |
| 897 | @ grid .files -row 0 -columnspan 6 |
| 898 | @ eval grid [cols] -row 1 -sticky nsew |
| @@ -906,14 +907,16 @@ | |
| 906 | ; |
| 907 | |
| 908 | /* |
| 909 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 910 | ** to the diff command. |
| 911 | ** |
| 912 | ** Steps: |
| 913 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 914 | ** (2) Invoke "wish" on the temp file using fossil_system(). |
| 915 | ** (3) Delete the temp file. |
| 916 | */ |
| 917 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 918 | int i; |
| 919 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 943 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 944 | if( zTempFile ){ |
| 945 | blob_write_to_file(&script, zTempFile); |
| 946 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 947 | }else{ |
| 948 | zTempFile = write_blob_to_temp_file(&script); |
| 949 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 950 | fossil_system(zCmd); |
| 951 | file_delete(zTempFile); |
| 952 | fossil_free(zCmd); |
| @@ -988,11 +1005,11 @@ | |
| 988 | ** specified (as they exist on disk) and that same file as it was checked |
| 989 | ** out. Or if the FILE arguments are omitted, show the unsaved changed |
| 990 | ** currently in the working check-out. |
| 991 | ** |
| 992 | ** If the "--from VERSION" or "-r VERSION" option is used it specifies |
| 993 | ** the source check-in for the diff operation. If not specified, the |
| 994 | ** source check-in is the base check-in for the current check-out. |
| 995 | ** |
| 996 | ** If the "--to VERSION" option appears, it specifies the check-in from |
| 997 | ** which the second version of the file or files is taken. If there is |
| 998 | ** no "--to" option then the (possibly edited) files in the current check-out |
| @@ -1015,11 +1032,11 @@ | |
| 1015 | ** |
| 1016 | ** Options: |
| 1017 | ** --binary PATTERN Treat files that match the glob PATTERN as binary |
| 1018 | ** --branch BRANCH Show diff of all changes on BRANCH |
| 1019 | ** --brief Show filenames only |
| 1020 | ** --context|-c N Use N lines of context |
| 1021 | ** --diff-binary BOOL Include binary files when using external commands |
| 1022 | ** --from|-r VERSION select VERSION as source for the diff |
| 1023 | ** --internal|-i use internal diff logic |
| 1024 | ** --side-by-side|-y side-by-side diff |
| 1025 | ** --tk Launch a Tcl/Tk GUI for display |
| 1026 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -599,11 +599,11 @@ | |
| 599 | |
| 600 | /* A Tcl/Tk script used to render diff output. |
| 601 | */ |
| 602 | static const char zDiffScript[] = |
| 603 | @ package require Tk |
| 604 | @ |
| 605 | @ array set CFG { |
| 606 | @ TITLE {Fossil Diff} |
| 607 | @ LN_COL_BG #dddddd |
| 608 | @ LN_COL_FG #444444 |
| 609 | @ TXT_COL_BG #ffffff |
| @@ -622,30 +622,30 @@ | |
| 622 | @ PADX 5 |
| 623 | @ WIDTH 80 |
| 624 | @ HEIGHT 45 |
| 625 | @ LB_HEIGHT 25 |
| 626 | @ } |
| 627 | @ |
| 628 | @ if {![namespace exists ttk]} { |
| 629 | @ interp alias {} ::ttk::scrollbar {} ::scrollbar |
| 630 | @ interp alias {} ::ttk::menubutton {} ::menubutton |
| 631 | @ } |
| 632 | @ |
| 633 | @ proc dehtml {x} { |
| 634 | @ set x [regsub -all {<[^>]*>} $x {}] |
| 635 | @ return [string map {& & < < > > ' ' " \"} $x] |
| 636 | @ } |
| 637 | @ |
| 638 | @ proc cols {} { |
| 639 | @ return [list .lnA .txtA .mkr .lnB .txtB] |
| 640 | @ } |
| 641 | @ |
| 642 | @ proc colType {c} { |
| 643 | @ regexp {[a-z]+} $c type |
| 644 | @ return $type |
| 645 | @ } |
| 646 | @ |
| 647 | @ proc readDiffs {fossilcmd} { |
| 648 | @ set in [open $fossilcmd r] |
| 649 | @ fconfigure $in -encoding utf-8 |
| 650 | @ set nDiffs 0 |
| 651 | @ array set widths {txt 0 ln 0 mkr 0} |
| @@ -657,34 +657,34 @@ | |
| 657 | @ continue |
| 658 | @ } |
| 659 | @ incr nDiffs |
| 660 | @ set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}] |
| 661 | @ .wfiles.lb insert end $fn |
| 662 | @ |
| 663 | @ foreach c [cols] { |
| 664 | @ while {[gets $in] ne "<pre>"} continue |
| 665 | @ |
| 666 | @ if {$nDiffs > 1} { |
| 667 | @ $c insert end \n - |
| 668 | @ } |
| 669 | @ if {[colType $c] eq "txt"} { |
| 670 | @ $c insert end $fn\n fn |
| 671 | @ } else { |
| 672 | @ $c insert end \n fn |
| 673 | @ } |
| 674 | @ $c insert end \n - |
| 675 | @ |
| 676 | @ set type [colType $c] |
| 677 | @ set str {} |
| 678 | @ while {[set line [gets $in]] ne "</pre>"} { |
| 679 | @ set len [string length [dehtml $line]] |
| 680 | @ if {$len > $widths($type)} { |
| 681 | @ set widths($type) $len |
| 682 | @ } |
| 683 | @ append str $line\n |
| 684 | @ } |
| 685 | @ |
| 686 | @ set re {<span class="diff([a-z]+)">([^<]*)</span>} |
| 687 | @ # Use \r as separator since it can't appear in the diff output (it gets |
| 688 | @ # converted to a space). |
| 689 | @ set str [regsub -all $re $str "\r\\1\r\\2\r"] |
| 690 | @ foreach {pre class mid} [split $str \r] { |
| @@ -695,11 +695,11 @@ | |
| 695 | @ } |
| 696 | @ } |
| 697 | @ } |
| 698 | @ } |
| 699 | @ close $in |
| 700 | @ |
| 701 | @ foreach c [cols] { |
| 702 | @ set type [colType $c] |
| 703 | @ if {$type ne "txt"} { |
| 704 | @ $c config -width $widths($type) |
| 705 | @ } |
| @@ -707,19 +707,19 @@ | |
| 707 | @ } |
| 708 | @ if {$nDiffs <= [.wfiles.lb cget -height]} { |
| 709 | @ .wfiles.lb config -height $nDiffs |
| 710 | @ grid remove .wfiles.sb |
| 711 | @ } |
| 712 | @ |
| 713 | @ return $nDiffs |
| 714 | @ } |
| 715 | @ |
| 716 | @ proc viewDiff {idx} { |
| 717 | @ .txtA yview $idx |
| 718 | @ .txtA xview moveto 0 |
| 719 | @ } |
| 720 | @ |
| 721 | @ proc cycleDiffs {{reverse 0}} { |
| 722 | @ if {$reverse} { |
| 723 | @ set range [.txtA tag prevrange fn @0,0 1.0] |
| 724 | @ if {$range eq ""} { |
| 725 | @ viewDiff {fn.last -1c} |
| @@ -733,36 +733,36 @@ | |
| 733 | @ } else { |
| 734 | @ viewDiff [lindex $range 0] |
| 735 | @ } |
| 736 | @ } |
| 737 | @ } |
| 738 | @ |
| 739 | @ proc xvis {col} { |
| 740 | @ set view [$col xview] |
| 741 | @ return [expr {[lindex $view 1]-[lindex $view 0]}] |
| 742 | @ } |
| 743 | @ |
| 744 | @ proc scroll-x {args} { |
| 745 | @ set c .txt[expr {[xvis .txtA] < [xvis .txtB] ? "A" : "B"}] |
| 746 | @ eval $c xview $args |
| 747 | @ } |
| 748 | @ |
| 749 | @ interp alias {} scroll-y {} .txtA yview |
| 750 | @ |
| 751 | @ proc noop {args} {} |
| 752 | @ |
| 753 | @ proc enableSync {axis} { |
| 754 | @ update idletasks |
| 755 | @ interp alias {} sync-$axis {} |
| 756 | @ rename _sync-$axis sync-$axis |
| 757 | @ } |
| 758 | @ |
| 759 | @ proc disableSync {axis} { |
| 760 | @ rename sync-$axis _sync-$axis |
| 761 | @ interp alias {} sync-$axis {} noop |
| 762 | @ } |
| 763 | @ |
| 764 | @ proc sync-x {col first last} { |
| 765 | @ disableSync x |
| 766 | @ $col xview moveto [expr {$first*[xvis $col]/($last-$first)}] |
| 767 | @ foreach side {A B} { |
| 768 | @ set sb .sbx$side |
| @@ -774,11 +774,11 @@ | |
| 774 | @ grid remove $sb |
| 775 | @ } |
| 776 | @ } |
| 777 | @ enableSync x |
| 778 | @ } |
| 779 | @ |
| 780 | @ proc sync-y {first last} { |
| 781 | @ disableSync y |
| 782 | @ foreach c [cols] { |
| 783 | @ $c yview moveto $first |
| 784 | @ } |
| @@ -788,15 +788,16 @@ | |
| 788 | @ } else { |
| 789 | @ grid remove .sby |
| 790 | @ } |
| 791 | @ enableSync y |
| 792 | @ } |
| 793 | @ |
| 794 | @ wm withdraw . |
| 795 | @ wm title . $CFG(TITLE) |
| 796 | @ wm iconname . $CFG(TITLE) |
| 797 | @ bind . <q> exit |
| 798 | @ bind . <Destroy> {after 0 exit} |
| 799 | @ bind . <Tab> {cycleDiffs; break} |
| 800 | @ bind . <<PrevWindow>> {cycleDiffs 1; break} |
| 801 | @ bind . <Return> { |
| 802 | @ event generate .files <1> |
| 803 | @ event generate .files <ButtonRelease-1> |
| @@ -813,11 +814,11 @@ | |
| 814 | @ End y {moveto 1} |
| 815 | @ } { |
| 816 | @ bind . <$key> "scroll-$axis $args; break" |
| 817 | @ bind . <Shift-$key> continue |
| 818 | @ } |
| 819 | @ |
| 820 | @ ::ttk::menubutton .files -text "Files" |
| 821 | @ toplevel .wfiles |
| 822 | @ wm withdraw .wfiles |
| 823 | @ update idletasks |
| 824 | @ wm transient .wfiles . |
| @@ -847,16 +848,16 @@ | |
| 848 | @ } |
| 849 | @ bind .wfiles.lb <Motion> { |
| 850 | @ %W selection clear 0 end |
| 851 | @ %W selection set @%x,%y |
| 852 | @ } |
| 853 | @ |
| 854 | @ foreach {side syncCol} {A .txtB B .txtA} { |
| 855 | @ set ln .ln$side |
| 856 | @ text $ln |
| 857 | @ $ln tag config - -justify right |
| 858 | @ |
| 859 | @ set txt .txt$side |
| 860 | @ text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \ |
| 861 | @ -xscroll "sync-x $syncCol" |
| 862 | @ catch {$txt config -tabstyle wordprocessor} ;# Required for Tk>=8.5 |
| 863 | @ foreach tag {add rm chng} { |
| @@ -865,11 +866,11 @@ | |
| 866 | @ } |
| 867 | @ $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \ |
| 868 | @ -justify center |
| 869 | @ } |
| 870 | @ text .mkr |
| 871 | @ |
| 872 | @ foreach c [cols] { |
| 873 | @ set keyPrefix [string toupper [colType $c]]_COL_ |
| 874 | @ if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}} |
| 875 | @ $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \ |
| 876 | @ -padx $CFG(PADX) -yscroll sync-y |
| @@ -877,22 +878,22 @@ | |
| 878 | @ -foreground $CFG(HR_FG) |
| 879 | @ $c tag config fn -spacing1 $CFG(FN_PAD) -spacing3 $CFG(FN_PAD) |
| 880 | @ bindtags $c ". $c Text all" |
| 881 | @ bind $c <1> {focus %W} |
| 882 | @ } |
| 883 | @ |
| 884 | @ ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical |
| 885 | @ ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal |
| 886 | @ ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal |
| 887 | @ frame .spacer |
| 888 | @ |
| 889 | @ if {[readDiffs $fossilcmd] == 0} { |
| 890 | @ tk_messageBox -type ok -title $CFG(TITLE) -message "No changes" |
| 891 | @ exit |
| 892 | @ } |
| 893 | @ update idletasks |
| 894 | @ |
| 895 | @ grid rowconfigure . 1 -weight 1 |
| 896 | @ grid columnconfigure . 1 -weight 1 |
| 897 | @ grid columnconfigure . 4 -weight 1 |
| 898 | @ grid .files -row 0 -columnspan 6 |
| 899 | @ eval grid [cols] -row 1 -sticky nsew |
| @@ -906,14 +907,16 @@ | |
| 907 | ; |
| 908 | |
| 909 | /* |
| 910 | ** Show diff output in a Tcl/Tk window, in response to the --tk option |
| 911 | ** to the diff command. |
| 912 | ** |
| 913 | ** If fossil has direct access to a Tcl interpreter (either loaded |
| 914 | ** dynamically through stubs or linked in statically), we can use it |
| 915 | ** directly. Otherwise: |
| 916 | ** (1) Write the Tcl/Tk script used for rendering into a temp file. |
| 917 | ** (2) Invoke "tclsh" on the temp file using fossil_system(). |
| 918 | ** (3) Delete the temp file. |
| 919 | */ |
| 920 | void diff_tk(const char *zSubCmd, int firstArg){ |
| 921 | int i; |
| 922 | Blob script; |
| @@ -943,10 +946,24 @@ | |
| 946 | blob_appendf(&script, "}\n%s", zDiffScript); |
| 947 | if( zTempFile ){ |
| 948 | blob_write_to_file(&script, zTempFile); |
| 949 | fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile); |
| 950 | }else{ |
| 951 | #if defined(FOSSIL_ENABLE_TCL) |
| 952 | Th_FossilInit(TH_INIT_DEFAULT); |
| 953 | if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script), |
| 954 | blob_size(&script), 1)==TCL_OK ){ |
| 955 | blob_reset(&script); |
| 956 | return; |
| 957 | } |
| 958 | /* |
| 959 | * If evaluation of the Tcl script fails, the reason may be that Tk |
| 960 | * could not be found by the loaded Tcl, or that Tcl cannot be loaded |
| 961 | * dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback |
| 962 | * to using the external "tclsh", if available. |
| 963 | */ |
| 964 | #endif |
| 965 | zTempFile = write_blob_to_temp_file(&script); |
| 966 | zCmd = mprintf("tclsh \"%s\"", zTempFile); |
| 967 | fossil_system(zCmd); |
| 968 | file_delete(zTempFile); |
| 969 | fossil_free(zCmd); |
| @@ -988,11 +1005,11 @@ | |
| 1005 | ** specified (as they exist on disk) and that same file as it was checked |
| 1006 | ** out. Or if the FILE arguments are omitted, show the unsaved changed |
| 1007 | ** currently in the working check-out. |
| 1008 | ** |
| 1009 | ** If the "--from VERSION" or "-r VERSION" option is used it specifies |
| 1010 | ** the source check-in for the diff operation. If not specified, the |
| 1011 | ** source check-in is the base check-in for the current check-out. |
| 1012 | ** |
| 1013 | ** If the "--to VERSION" option appears, it specifies the check-in from |
| 1014 | ** which the second version of the file or files is taken. If there is |
| 1015 | ** no "--to" option then the (possibly edited) files in the current check-out |
| @@ -1015,11 +1032,11 @@ | |
| 1032 | ** |
| 1033 | ** Options: |
| 1034 | ** --binary PATTERN Treat files that match the glob PATTERN as binary |
| 1035 | ** --branch BRANCH Show diff of all changes on BRANCH |
| 1036 | ** --brief Show filenames only |
| 1037 | ** --context|-c N Use N lines of context |
| 1038 | ** --diff-binary BOOL Include binary files when using external commands |
| 1039 | ** --from|-r VERSION select VERSION as source for the diff |
| 1040 | ** --internal|-i use internal diff logic |
| 1041 | ** --side-by-side|-y side-by-side diff |
| 1042 | ** --tk Launch a Tcl/Tk GUI for display |
| 1043 |
+1
-1
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -996,11 +996,11 @@ | ||
| 996 | 996 | }else{ |
| 997 | 997 | xCmp = fossil_strnicmp; |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | /* Special case. zOrigName refers to g.zLocalRoot directory. */ |
| 1001 | - if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0) | |
| 1001 | + if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0) | |
| 1002 | 1002 | || (nFull==1 && zFull[0]=='/' && nLocalRoot==1 && zLocalRoot[0]=='/') ){ |
| 1003 | 1003 | blob_append(pOut, ".", 1); |
| 1004 | 1004 | blob_reset(&localRoot); |
| 1005 | 1005 | blob_reset(&full); |
| 1006 | 1006 | return 1; |
| 1007 | 1007 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -996,11 +996,11 @@ | |
| 996 | }else{ |
| 997 | xCmp = fossil_strnicmp; |
| 998 | } |
| 999 | |
| 1000 | /* Special case. zOrigName refers to g.zLocalRoot directory. */ |
| 1001 | if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0) |
| 1002 | || (nFull==1 && zFull[0]=='/' && nLocalRoot==1 && zLocalRoot[0]=='/') ){ |
| 1003 | blob_append(pOut, ".", 1); |
| 1004 | blob_reset(&localRoot); |
| 1005 | blob_reset(&full); |
| 1006 | return 1; |
| 1007 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -996,11 +996,11 @@ | |
| 996 | }else{ |
| 997 | xCmp = fossil_strnicmp; |
| 998 | } |
| 999 | |
| 1000 | /* Special case. zOrigName refers to g.zLocalRoot directory. */ |
| 1001 | if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0) |
| 1002 | || (nFull==1 && zFull[0]=='/' && nLocalRoot==1 && zLocalRoot[0]=='/') ){ |
| 1003 | blob_append(pOut, ".", 1); |
| 1004 | blob_reset(&localRoot); |
| 1005 | blob_reset(&full); |
| 1006 | return 1; |
| 1007 |
+1
-1
| --- src/finfo.c | ||
| +++ src/finfo.c | ||
| @@ -322,11 +322,11 @@ | ||
| 322 | 322 | ); |
| 323 | 323 | if( firstChngOnly ){ |
| 324 | 324 | #if 0 |
| 325 | 325 | blob_appendf(&sql, ", min(event.mtime)"); |
| 326 | 326 | #else |
| 327 | - blob_appendf(&sql, | |
| 327 | + blob_appendf(&sql, | |
| 328 | 328 | ", min(CASE (SELECT value FROM tagxref" |
| 329 | 329 | " WHERE tagtype>0 AND tagid=%d" |
| 330 | 330 | " AND tagxref.rid=mlink.mid)" |
| 331 | 331 | " WHEN 'trunk' THEN event.mtime-10000 ELSE event.mtime END)", |
| 332 | 332 | TAG_BRANCH); |
| 333 | 333 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -322,11 +322,11 @@ | |
| 322 | ); |
| 323 | if( firstChngOnly ){ |
| 324 | #if 0 |
| 325 | blob_appendf(&sql, ", min(event.mtime)"); |
| 326 | #else |
| 327 | blob_appendf(&sql, |
| 328 | ", min(CASE (SELECT value FROM tagxref" |
| 329 | " WHERE tagtype>0 AND tagid=%d" |
| 330 | " AND tagxref.rid=mlink.mid)" |
| 331 | " WHEN 'trunk' THEN event.mtime-10000 ELSE event.mtime END)", |
| 332 | TAG_BRANCH); |
| 333 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -322,11 +322,11 @@ | |
| 322 | ); |
| 323 | if( firstChngOnly ){ |
| 324 | #if 0 |
| 325 | blob_appendf(&sql, ", min(event.mtime)"); |
| 326 | #else |
| 327 | blob_appendf(&sql, |
| 328 | ", min(CASE (SELECT value FROM tagxref" |
| 329 | " WHERE tagtype>0 AND tagid=%d" |
| 330 | " AND tagxref.rid=mlink.mid)" |
| 331 | " WHEN 'trunk' THEN event.mtime-10000 ELSE event.mtime END)", |
| 332 | TAG_BRANCH); |
| 333 |
+1
-1
| --- src/gzip.c | ||
| +++ src/gzip.c | ||
| @@ -73,11 +73,11 @@ | ||
| 73 | 73 | */ |
| 74 | 74 | #define GZIP_BUFSZ 100000 |
| 75 | 75 | void gzip_step(const char *pIn, int nIn){ |
| 76 | 76 | char *zOutBuf; |
| 77 | 77 | int nOut; |
| 78 | - | |
| 78 | + | |
| 79 | 79 | nOut = nIn + nIn/10 + 100; |
| 80 | 80 | if( nOut<100000 ) nOut = 100000; |
| 81 | 81 | zOutBuf = fossil_malloc(nOut); |
| 82 | 82 | gzip.stream.avail_in = nIn; |
| 83 | 83 | gzip.stream.next_in = (unsigned char*)pIn; |
| 84 | 84 |
| --- src/gzip.c | |
| +++ src/gzip.c | |
| @@ -73,11 +73,11 @@ | |
| 73 | */ |
| 74 | #define GZIP_BUFSZ 100000 |
| 75 | void gzip_step(const char *pIn, int nIn){ |
| 76 | char *zOutBuf; |
| 77 | int nOut; |
| 78 | |
| 79 | nOut = nIn + nIn/10 + 100; |
| 80 | if( nOut<100000 ) nOut = 100000; |
| 81 | zOutBuf = fossil_malloc(nOut); |
| 82 | gzip.stream.avail_in = nIn; |
| 83 | gzip.stream.next_in = (unsigned char*)pIn; |
| 84 |
| --- src/gzip.c | |
| +++ src/gzip.c | |
| @@ -73,11 +73,11 @@ | |
| 73 | */ |
| 74 | #define GZIP_BUFSZ 100000 |
| 75 | void gzip_step(const char *pIn, int nIn){ |
| 76 | char *zOutBuf; |
| 77 | int nOut; |
| 78 | |
| 79 | nOut = nIn + nIn/10 + 100; |
| 80 | if( nOut<100000 ) nOut = 100000; |
| 81 | zOutBuf = fossil_malloc(nOut); |
| 82 | gzip.stream.avail_in = nIn; |
| 83 | gzip.stream.next_in = (unsigned char*)pIn; |
| 84 |
+100
-26
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -173,17 +173,65 @@ | ||
| 173 | 173 | if( iBio!=NULL ){ |
| 174 | 174 | (void)BIO_reset(iBio); |
| 175 | 175 | BIO_free_all(iBio); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | + | |
| 179 | +/* See RFC2817 for details */ | |
| 180 | +static int establish_proxy_tunnel(UrlData *pUrlData, BIO *bio){ | |
| 181 | + int rc, httpVerMin; | |
| 182 | + char *bbuf; | |
| 183 | + Blob snd, reply; | |
| 184 | + int done=0,end=0; | |
| 185 | + blob_zero(&snd); | |
| 186 | + blob_appendf(&snd, "CONNECT %s:%d HTTP/1.1\r\n", pUrlData->hostname, | |
| 187 | + pUrlData->proxyOrigPort); | |
| 188 | + blob_appendf(&snd, "Host: %s:%d\r\n", pUrlData->hostname, pUrlData->proxyOrigPort); | |
| 189 | + if( pUrlData->proxyAuth ){ | |
| 190 | + blob_appendf(&snd, "Proxy-Authorization: %s\r\n", pUrlData->proxyAuth); | |
| 191 | + } | |
| 192 | + blob_append(&snd, "Proxy-Connection: keep-alive\r\n", -1); | |
| 193 | + blob_appendf(&snd, "User-Agent: %s\r\n", get_user_agent()); | |
| 194 | + blob_append(&snd, "\r\n", 2); | |
| 195 | + BIO_write(bio, blob_buffer(&snd), blob_size(&snd)); | |
| 196 | + blob_reset(&snd); | |
| 197 | + | |
| 198 | + /* Wait for end of reply */ | |
| 199 | + blob_zero(&reply); | |
| 200 | + do{ | |
| 201 | + int len; | |
| 202 | + char buf[256]; | |
| 203 | + len = BIO_read(bio, buf, sizeof(buf)); | |
| 204 | + blob_append(&reply, buf, len); | |
| 205 | + | |
| 206 | + bbuf = blob_buffer(&reply); | |
| 207 | + len = blob_size(&reply); | |
| 208 | + while(end < len) { | |
| 209 | + if(bbuf[end] == '\r') { | |
| 210 | + if(len - end < 4) { | |
| 211 | + /* need more data */ | |
| 212 | + break; | |
| 213 | + } | |
| 214 | + if(memcmp(&bbuf[end], "\r\n\r\n", 4) == 0) { | |
| 215 | + done = 1; | |
| 216 | + break; | |
| 217 | + } | |
| 218 | + } | |
| 219 | + end++; | |
| 220 | + } | |
| 221 | + }while(!done); | |
| 222 | + sscanf(bbuf, "HTTP/1.%d %d", &httpVerMin, &rc); | |
| 223 | + blob_reset(&reply); | |
| 224 | + return rc; | |
| 225 | +} | |
| 178 | 226 | |
| 179 | 227 | /* |
| 180 | 228 | ** Open an SSL connection. The identify of the server is determined |
| 181 | -** by global variables that are set using url_parse(): | |
| 229 | +** by variables that are set using url_parse(): | |
| 182 | 230 | ** |
| 183 | -** g.urlName Name of the server. Ex: www.fossil-scm.org | |
| 184 | -** g.urlPort TCP/IP port to use. Ex: 80 | |
| 231 | +** pUrlData->name Name of the server. Ex: www.fossil-scm.org | |
| 232 | +** pUrlData->port TCP/IP port to use. Ex: 80 | |
| 185 | 233 | ** |
| 186 | 234 | ** Return the number of errors. |
| 187 | 235 | */ |
| 188 | 236 | int ssl_open(UrlData *pUrlData){ |
| 189 | 237 | X509 *cert; |
| @@ -201,41 +249,67 @@ | ||
| 201 | 249 | X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert); |
| 202 | 250 | X509_free(cert); |
| 203 | 251 | hasSavedCertificate = 1; |
| 204 | 252 | } |
| 205 | 253 | |
| 206 | - iBio = BIO_new_ssl_connect(sslCtx); | |
| 254 | + if( pUrlData->useProxy ){ | |
| 255 | + int rc; | |
| 256 | + BIO *sBio; | |
| 257 | + char *connStr; | |
| 258 | + connStr = mprintf("%s:%d", g.urlName, pUrlData->port); | |
| 259 | + sBio = BIO_new_connect(connStr); | |
| 260 | + free(connStr); | |
| 261 | + if( BIO_do_connect(sBio)<=0 ){ | |
| 262 | + ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)", | |
| 263 | + pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error())); | |
| 264 | + ssl_close(); | |
| 265 | + return 1; | |
| 266 | + } | |
| 267 | + rc = establish_proxy_tunnel(pUrlData, sBio); | |
| 268 | + if( rc<200||rc>299 ){ | |
| 269 | + ssl_set_errmsg("SSL: proxy connect failed with HTTP status code %d", rc); | |
| 270 | + return 1; | |
| 271 | + } | |
| 272 | + | |
| 273 | + pUrlData->path = pUrlData->proxyUrlPath; | |
| 274 | + | |
| 275 | + iBio = BIO_new_ssl(sslCtx, 1); | |
| 276 | + BIO_push(iBio, sBio); | |
| 277 | + }else{ | |
| 278 | + iBio = BIO_new_ssl_connect(sslCtx); | |
| 279 | + } | |
| 280 | + if( iBio==NULL ) { | |
| 281 | + ssl_set_errmsg("SSL: cannot open SSL (%s)", | |
| 282 | + ERR_reason_error_string(ERR_get_error())); | |
| 283 | + return 1; | |
| 284 | + } | |
| 207 | 285 | BIO_get_ssl(iBio, &ssl); |
| 208 | 286 | |
| 209 | 287 | #if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT) |
| 210 | - if( !SSL_set_tlsext_host_name(ssl, pUrlData->name) ){ | |
| 288 | + if( !SSL_set_tlsext_host_name(ssl, (pUrlData->useProxy?pUrlData->hostname:pUrlData->name)) ){ | |
| 211 | 289 | fossil_warning("WARNING: failed to set server name indication (SNI), " |
| 212 | 290 | "continuing without it.\n"); |
| 213 | 291 | } |
| 214 | 292 | #endif |
| 215 | 293 | |
| 216 | 294 | SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); |
| 217 | - if( iBio==NULL ) { | |
| 218 | - ssl_set_errmsg("SSL: cannot open SSL (%s)", | |
| 219 | - ERR_reason_error_string(ERR_get_error())); | |
| 220 | - return 1; | |
| 221 | - } | |
| 222 | - | |
| 223 | - BIO_set_conn_hostname(iBio, pUrlData->name); | |
| 224 | - BIO_set_conn_int_port(iBio, &pUrlData->port); | |
| 225 | - | |
| 226 | - if( BIO_do_connect(iBio)<=0 ){ | |
| 227 | - ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)", | |
| 228 | - pUrlData->name, pUrlData->port, | |
| 229 | - ERR_reason_error_string(ERR_get_error())); | |
| 230 | - ssl_close(); | |
| 231 | - return 1; | |
| 295 | + | |
| 296 | + if( !pUrlData->useProxy ){ | |
| 297 | + BIO_set_conn_hostname(iBio, pUrlData->name); | |
| 298 | + BIO_set_conn_int_port(iBio, &pUrlData->port); | |
| 299 | + if( BIO_do_connect(iBio)<=0 ){ | |
| 300 | + ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)", | |
| 301 | + pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error())); | |
| 302 | + ssl_close(); | |
| 303 | + return 1; | |
| 304 | + } | |
| 232 | 305 | } |
| 233 | 306 | |
| 234 | 307 | if( BIO_do_handshake(iBio)<=0 ) { |
| 235 | 308 | ssl_set_errmsg("Error establishing SSL connection %s:%d (%s)", |
| 236 | - pUrlData->name, pUrlData->port, | |
| 309 | + pUrlData->useProxy?pUrlData->hostname:pUrlData->name, | |
| 310 | + pUrlData->useProxy?pUrlData->proxyOrigPort:pUrlData->port, | |
| 237 | 311 | ERR_reason_error_string(ERR_get_error())); |
| 238 | 312 | ssl_close(); |
| 239 | 313 | return 1; |
| 240 | 314 | } |
| 241 | 315 | /* Check if certificate is valid */ |
| @@ -283,11 +357,11 @@ | ||
| 283 | 357 | " certificates list\n\n" |
| 284 | 358 | "If you are not expecting this message, answer no and " |
| 285 | 359 | "contact your server\nadministrator.\n\n" |
| 286 | 360 | "Accept certificate for host %s (a=always/y/N)? ", |
| 287 | 361 | X509_verify_cert_error_string(e), desc, warning, |
| 288 | - pUrlData->name); | |
| 362 | + pUrlData->useProxy?pUrlData->hostname:pUrlData->name); | |
| 289 | 363 | BIO_free(mem); |
| 290 | 364 | |
| 291 | 365 | prompt_user(prompt, &ans); |
| 292 | 366 | free(prompt); |
| 293 | 367 | cReply = blob_str(&ans)[0]; |
| @@ -333,14 +407,14 @@ | ||
| 333 | 407 | |
| 334 | 408 | mem = BIO_new(BIO_s_mem()); |
| 335 | 409 | PEM_write_bio_X509(mem, cert); |
| 336 | 410 | BIO_write(mem, "", 1); /* nul-terminate mem buffer */ |
| 337 | 411 | BIO_get_mem_data(mem, &zCert); |
| 338 | - zHost = mprintf("cert:%s", pUrlData->name); | |
| 412 | + zHost = mprintf("cert:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name); | |
| 339 | 413 | db_set(zHost, zCert, 1); |
| 340 | 414 | free(zHost); |
| 341 | - zHost = mprintf("trusted:%s", pUrlData->name); | |
| 415 | + zHost = mprintf("trusted:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name); | |
| 342 | 416 | db_set_int(zHost, trusted, 1); |
| 343 | 417 | free(zHost); |
| 344 | 418 | BIO_free(mem); |
| 345 | 419 | } |
| 346 | 420 | |
| @@ -351,18 +425,18 @@ | ||
| 351 | 425 | X509 *ssl_get_certificate(UrlData *pUrlData, int *pTrusted){ |
| 352 | 426 | char *zHost, *zCert; |
| 353 | 427 | BIO *mem; |
| 354 | 428 | X509 *cert; |
| 355 | 429 | |
| 356 | - zHost = mprintf("cert:%s", pUrlData->name); | |
| 430 | + zHost = mprintf("cert:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name); | |
| 357 | 431 | zCert = db_get(zHost, NULL); |
| 358 | 432 | free(zHost); |
| 359 | 433 | if ( zCert==NULL ) |
| 360 | 434 | return NULL; |
| 361 | 435 | |
| 362 | 436 | if ( pTrusted!=0 ){ |
| 363 | - zHost = mprintf("trusted:%s", pUrlData->name); | |
| 437 | + zHost = mprintf("trusted:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name); | |
| 364 | 438 | *pTrusted = db_get_int(zHost, 0); |
| 365 | 439 | free(zHost); |
| 366 | 440 | } |
| 367 | 441 | |
| 368 | 442 | mem = BIO_new(BIO_s_mem()); |
| 369 | 443 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -173,17 +173,65 @@ | |
| 173 | if( iBio!=NULL ){ |
| 174 | (void)BIO_reset(iBio); |
| 175 | BIO_free_all(iBio); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /* |
| 180 | ** Open an SSL connection. The identify of the server is determined |
| 181 | ** by global variables that are set using url_parse(): |
| 182 | ** |
| 183 | ** g.urlName Name of the server. Ex: www.fossil-scm.org |
| 184 | ** g.urlPort TCP/IP port to use. Ex: 80 |
| 185 | ** |
| 186 | ** Return the number of errors. |
| 187 | */ |
| 188 | int ssl_open(UrlData *pUrlData){ |
| 189 | X509 *cert; |
| @@ -201,41 +249,67 @@ | |
| 201 | X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert); |
| 202 | X509_free(cert); |
| 203 | hasSavedCertificate = 1; |
| 204 | } |
| 205 | |
| 206 | iBio = BIO_new_ssl_connect(sslCtx); |
| 207 | BIO_get_ssl(iBio, &ssl); |
| 208 | |
| 209 | #if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT) |
| 210 | if( !SSL_set_tlsext_host_name(ssl, pUrlData->name) ){ |
| 211 | fossil_warning("WARNING: failed to set server name indication (SNI), " |
| 212 | "continuing without it.\n"); |
| 213 | } |
| 214 | #endif |
| 215 | |
| 216 | SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); |
| 217 | if( iBio==NULL ) { |
| 218 | ssl_set_errmsg("SSL: cannot open SSL (%s)", |
| 219 | ERR_reason_error_string(ERR_get_error())); |
| 220 | return 1; |
| 221 | } |
| 222 | |
| 223 | BIO_set_conn_hostname(iBio, pUrlData->name); |
| 224 | BIO_set_conn_int_port(iBio, &pUrlData->port); |
| 225 | |
| 226 | if( BIO_do_connect(iBio)<=0 ){ |
| 227 | ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)", |
| 228 | pUrlData->name, pUrlData->port, |
| 229 | ERR_reason_error_string(ERR_get_error())); |
| 230 | ssl_close(); |
| 231 | return 1; |
| 232 | } |
| 233 | |
| 234 | if( BIO_do_handshake(iBio)<=0 ) { |
| 235 | ssl_set_errmsg("Error establishing SSL connection %s:%d (%s)", |
| 236 | pUrlData->name, pUrlData->port, |
| 237 | ERR_reason_error_string(ERR_get_error())); |
| 238 | ssl_close(); |
| 239 | return 1; |
| 240 | } |
| 241 | /* Check if certificate is valid */ |
| @@ -283,11 +357,11 @@ | |
| 283 | " certificates list\n\n" |
| 284 | "If you are not expecting this message, answer no and " |
| 285 | "contact your server\nadministrator.\n\n" |
| 286 | "Accept certificate for host %s (a=always/y/N)? ", |
| 287 | X509_verify_cert_error_string(e), desc, warning, |
| 288 | pUrlData->name); |
| 289 | BIO_free(mem); |
| 290 | |
| 291 | prompt_user(prompt, &ans); |
| 292 | free(prompt); |
| 293 | cReply = blob_str(&ans)[0]; |
| @@ -333,14 +407,14 @@ | |
| 333 | |
| 334 | mem = BIO_new(BIO_s_mem()); |
| 335 | PEM_write_bio_X509(mem, cert); |
| 336 | BIO_write(mem, "", 1); /* nul-terminate mem buffer */ |
| 337 | BIO_get_mem_data(mem, &zCert); |
| 338 | zHost = mprintf("cert:%s", pUrlData->name); |
| 339 | db_set(zHost, zCert, 1); |
| 340 | free(zHost); |
| 341 | zHost = mprintf("trusted:%s", pUrlData->name); |
| 342 | db_set_int(zHost, trusted, 1); |
| 343 | free(zHost); |
| 344 | BIO_free(mem); |
| 345 | } |
| 346 | |
| @@ -351,18 +425,18 @@ | |
| 351 | X509 *ssl_get_certificate(UrlData *pUrlData, int *pTrusted){ |
| 352 | char *zHost, *zCert; |
| 353 | BIO *mem; |
| 354 | X509 *cert; |
| 355 | |
| 356 | zHost = mprintf("cert:%s", pUrlData->name); |
| 357 | zCert = db_get(zHost, NULL); |
| 358 | free(zHost); |
| 359 | if ( zCert==NULL ) |
| 360 | return NULL; |
| 361 | |
| 362 | if ( pTrusted!=0 ){ |
| 363 | zHost = mprintf("trusted:%s", pUrlData->name); |
| 364 | *pTrusted = db_get_int(zHost, 0); |
| 365 | free(zHost); |
| 366 | } |
| 367 | |
| 368 | mem = BIO_new(BIO_s_mem()); |
| 369 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -173,17 +173,65 @@ | |
| 173 | if( iBio!=NULL ){ |
| 174 | (void)BIO_reset(iBio); |
| 175 | BIO_free_all(iBio); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /* See RFC2817 for details */ |
| 180 | static int establish_proxy_tunnel(UrlData *pUrlData, BIO *bio){ |
| 181 | int rc, httpVerMin; |
| 182 | char *bbuf; |
| 183 | Blob snd, reply; |
| 184 | int done=0,end=0; |
| 185 | blob_zero(&snd); |
| 186 | blob_appendf(&snd, "CONNECT %s:%d HTTP/1.1\r\n", pUrlData->hostname, |
| 187 | pUrlData->proxyOrigPort); |
| 188 | blob_appendf(&snd, "Host: %s:%d\r\n", pUrlData->hostname, pUrlData->proxyOrigPort); |
| 189 | if( pUrlData->proxyAuth ){ |
| 190 | blob_appendf(&snd, "Proxy-Authorization: %s\r\n", pUrlData->proxyAuth); |
| 191 | } |
| 192 | blob_append(&snd, "Proxy-Connection: keep-alive\r\n", -1); |
| 193 | blob_appendf(&snd, "User-Agent: %s\r\n", get_user_agent()); |
| 194 | blob_append(&snd, "\r\n", 2); |
| 195 | BIO_write(bio, blob_buffer(&snd), blob_size(&snd)); |
| 196 | blob_reset(&snd); |
| 197 | |
| 198 | /* Wait for end of reply */ |
| 199 | blob_zero(&reply); |
| 200 | do{ |
| 201 | int len; |
| 202 | char buf[256]; |
| 203 | len = BIO_read(bio, buf, sizeof(buf)); |
| 204 | blob_append(&reply, buf, len); |
| 205 | |
| 206 | bbuf = blob_buffer(&reply); |
| 207 | len = blob_size(&reply); |
| 208 | while(end < len) { |
| 209 | if(bbuf[end] == '\r') { |
| 210 | if(len - end < 4) { |
| 211 | /* need more data */ |
| 212 | break; |
| 213 | } |
| 214 | if(memcmp(&bbuf[end], "\r\n\r\n", 4) == 0) { |
| 215 | done = 1; |
| 216 | break; |
| 217 | } |
| 218 | } |
| 219 | end++; |
| 220 | } |
| 221 | }while(!done); |
| 222 | sscanf(bbuf, "HTTP/1.%d %d", &httpVerMin, &rc); |
| 223 | blob_reset(&reply); |
| 224 | return rc; |
| 225 | } |
| 226 | |
| 227 | /* |
| 228 | ** Open an SSL connection. The identify of the server is determined |
| 229 | ** by variables that are set using url_parse(): |
| 230 | ** |
| 231 | ** pUrlData->name Name of the server. Ex: www.fossil-scm.org |
| 232 | ** pUrlData->port TCP/IP port to use. Ex: 80 |
| 233 | ** |
| 234 | ** Return the number of errors. |
| 235 | */ |
| 236 | int ssl_open(UrlData *pUrlData){ |
| 237 | X509 *cert; |
| @@ -201,41 +249,67 @@ | |
| 249 | X509_STORE_add_cert(SSL_CTX_get_cert_store(sslCtx), cert); |
| 250 | X509_free(cert); |
| 251 | hasSavedCertificate = 1; |
| 252 | } |
| 253 | |
| 254 | if( pUrlData->useProxy ){ |
| 255 | int rc; |
| 256 | BIO *sBio; |
| 257 | char *connStr; |
| 258 | connStr = mprintf("%s:%d", g.urlName, pUrlData->port); |
| 259 | sBio = BIO_new_connect(connStr); |
| 260 | free(connStr); |
| 261 | if( BIO_do_connect(sBio)<=0 ){ |
| 262 | ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)", |
| 263 | pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error())); |
| 264 | ssl_close(); |
| 265 | return 1; |
| 266 | } |
| 267 | rc = establish_proxy_tunnel(pUrlData, sBio); |
| 268 | if( rc<200||rc>299 ){ |
| 269 | ssl_set_errmsg("SSL: proxy connect failed with HTTP status code %d", rc); |
| 270 | return 1; |
| 271 | } |
| 272 | |
| 273 | pUrlData->path = pUrlData->proxyUrlPath; |
| 274 | |
| 275 | iBio = BIO_new_ssl(sslCtx, 1); |
| 276 | BIO_push(iBio, sBio); |
| 277 | }else{ |
| 278 | iBio = BIO_new_ssl_connect(sslCtx); |
| 279 | } |
| 280 | if( iBio==NULL ) { |
| 281 | ssl_set_errmsg("SSL: cannot open SSL (%s)", |
| 282 | ERR_reason_error_string(ERR_get_error())); |
| 283 | return 1; |
| 284 | } |
| 285 | BIO_get_ssl(iBio, &ssl); |
| 286 | |
| 287 | #if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT) |
| 288 | if( !SSL_set_tlsext_host_name(ssl, (pUrlData->useProxy?pUrlData->hostname:pUrlData->name)) ){ |
| 289 | fossil_warning("WARNING: failed to set server name indication (SNI), " |
| 290 | "continuing without it.\n"); |
| 291 | } |
| 292 | #endif |
| 293 | |
| 294 | SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); |
| 295 | |
| 296 | if( !pUrlData->useProxy ){ |
| 297 | BIO_set_conn_hostname(iBio, pUrlData->name); |
| 298 | BIO_set_conn_int_port(iBio, &pUrlData->port); |
| 299 | if( BIO_do_connect(iBio)<=0 ){ |
| 300 | ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)", |
| 301 | pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error())); |
| 302 | ssl_close(); |
| 303 | return 1; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | if( BIO_do_handshake(iBio)<=0 ) { |
| 308 | ssl_set_errmsg("Error establishing SSL connection %s:%d (%s)", |
| 309 | pUrlData->useProxy?pUrlData->hostname:pUrlData->name, |
| 310 | pUrlData->useProxy?pUrlData->proxyOrigPort:pUrlData->port, |
| 311 | ERR_reason_error_string(ERR_get_error())); |
| 312 | ssl_close(); |
| 313 | return 1; |
| 314 | } |
| 315 | /* Check if certificate is valid */ |
| @@ -283,11 +357,11 @@ | |
| 357 | " certificates list\n\n" |
| 358 | "If you are not expecting this message, answer no and " |
| 359 | "contact your server\nadministrator.\n\n" |
| 360 | "Accept certificate for host %s (a=always/y/N)? ", |
| 361 | X509_verify_cert_error_string(e), desc, warning, |
| 362 | pUrlData->useProxy?pUrlData->hostname:pUrlData->name); |
| 363 | BIO_free(mem); |
| 364 | |
| 365 | prompt_user(prompt, &ans); |
| 366 | free(prompt); |
| 367 | cReply = blob_str(&ans)[0]; |
| @@ -333,14 +407,14 @@ | |
| 407 | |
| 408 | mem = BIO_new(BIO_s_mem()); |
| 409 | PEM_write_bio_X509(mem, cert); |
| 410 | BIO_write(mem, "", 1); /* nul-terminate mem buffer */ |
| 411 | BIO_get_mem_data(mem, &zCert); |
| 412 | zHost = mprintf("cert:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name); |
| 413 | db_set(zHost, zCert, 1); |
| 414 | free(zHost); |
| 415 | zHost = mprintf("trusted:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name); |
| 416 | db_set_int(zHost, trusted, 1); |
| 417 | free(zHost); |
| 418 | BIO_free(mem); |
| 419 | } |
| 420 | |
| @@ -351,18 +425,18 @@ | |
| 425 | X509 *ssl_get_certificate(UrlData *pUrlData, int *pTrusted){ |
| 426 | char *zHost, *zCert; |
| 427 | BIO *mem; |
| 428 | X509 *cert; |
| 429 | |
| 430 | zHost = mprintf("cert:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name); |
| 431 | zCert = db_get(zHost, NULL); |
| 432 | free(zHost); |
| 433 | if ( zCert==NULL ) |
| 434 | return NULL; |
| 435 | |
| 436 | if ( pTrusted!=0 ){ |
| 437 | zHost = mprintf("trusted:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name); |
| 438 | *pTrusted = db_get_int(zHost, 0); |
| 439 | free(zHost); |
| 440 | } |
| 441 | |
| 442 | mem = BIO_new(BIO_s_mem()); |
| 443 |
+67
-26
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -108,10 +108,26 @@ | ||
| 108 | 108 | ); |
| 109 | 109 | fossil_print("%-13s %s %s\n", zType, zUuid, zDate); |
| 110 | 110 | free(zDate); |
| 111 | 111 | } |
| 112 | 112 | db_finalize(&q); |
| 113 | + } | |
| 114 | + if( zUuid ){ | |
| 115 | + fossil_print("%-13s ", "leaf:"); | |
| 116 | + if(is_a_leaf(rid)){ | |
| 117 | + if(db_int(0, "SELECT 1 FROM tagxref AS tx" | |
| 118 | + " WHERE tx.rid=%d" | |
| 119 | + " AND tx.tagid=%d" | |
| 120 | + " AND tx.tagtype>0", | |
| 121 | + rid, TAG_CLOSED)){ | |
| 122 | + fossil_print("%s\n", "closed"); | |
| 123 | + }else{ | |
| 124 | + fossil_print("%s\n", "open"); | |
| 125 | + } | |
| 126 | + }else{ | |
| 127 | + fossil_print("no\n"); | |
| 128 | + } | |
| 113 | 129 | } |
| 114 | 130 | zTags = info_tags_of_checkin(rid, 0); |
| 115 | 131 | if( zTags && zTags[0] ){ |
| 116 | 132 | fossil_print("tags: %s\n", zTags); |
| 117 | 133 | } |
| @@ -917,15 +933,16 @@ | ||
| 917 | 933 | ** WEBPAGE: vdiff |
| 918 | 934 | ** URL: /vdiff |
| 919 | 935 | ** |
| 920 | 936 | ** Query parameters: |
| 921 | 937 | ** |
| 922 | -** from=TAG | |
| 923 | -** to=TAG | |
| 924 | -** branch=TAG | |
| 925 | -** v=BOOLEAN | |
| 926 | -** sbs=BOOLEAN | |
| 938 | +** from=TAG Left side of the comparison | |
| 939 | +** to=TAG Right side of the comparison | |
| 940 | +** branch=TAG Show all changes on a particular branch | |
| 941 | +** v=BOOLEAN Default true. If false, only list files that have changed | |
| 942 | +** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false | |
| 943 | +** glob=STRING only diff files matching this glob | |
| 927 | 944 | ** |
| 928 | 945 | ** |
| 929 | 946 | ** Show all differences between two checkins. |
| 930 | 947 | */ |
| 931 | 948 | void vdiff_page(void){ |
| @@ -938,16 +955,15 @@ | ||
| 938 | 955 | const char *zBranch; |
| 939 | 956 | const char *zFrom; |
| 940 | 957 | const char *zTo; |
| 941 | 958 | const char *zRe; |
| 942 | 959 | const char *zVerbose; |
| 960 | + const char *zGlob; | |
| 943 | 961 | ReCompiled *pRe = 0; |
| 944 | - | |
| 945 | 962 | login_check_credentials(); |
| 946 | 963 | if( !g.perm.Read ){ login_needed(); return; } |
| 947 | 964 | login_anonymous_available(); |
| 948 | - | |
| 949 | 965 | zRe = P("regex"); |
| 950 | 966 | if( zRe ) re_compile(&pRe, zRe, 0); |
| 951 | 967 | zBranch = P("branch"); |
| 952 | 968 | if( zBranch && zBranch[0] ){ |
| 953 | 969 | cgi_replace_parameter("from", mprintf("root:%s", zBranch)); |
| @@ -965,30 +981,46 @@ | ||
| 965 | 981 | if( !zVerbose ){ |
| 966 | 982 | zVerbose = P("detail"); /* deprecated */ |
| 967 | 983 | } |
| 968 | 984 | verboseFlag = (zVerbose!=0) && !is_false(zVerbose); |
| 969 | 985 | if( !verboseFlag && sideBySide ) verboseFlag = 1; |
| 986 | + zGlob = P("glob"); | |
| 970 | 987 | zFrom = P("from"); |
| 971 | 988 | zTo = P("to"); |
| 989 | + if(zGlob && !*zGlob){ | |
| 990 | + zGlob = NULL; | |
| 991 | + } | |
| 972 | 992 | if( sideBySide || verboseFlag ){ |
| 973 | 993 | style_submenu_element("Hide Diff", "hidediff", |
| 974 | - "%R/vdiff?from=%T&to=%T&sbs=0", | |
| 975 | - zFrom, zTo); | |
| 994 | + "%R/vdiff?from=%T&to=%T&sbs=0%s%T", | |
| 995 | + zFrom, zTo, | |
| 996 | + zGlob ? "&glob=" : "", zGlob ? zGlob : ""); | |
| 976 | 997 | } |
| 977 | 998 | if( !sideBySide ){ |
| 978 | 999 | style_submenu_element("Side-by-side Diff", "sbsdiff", |
| 979 | - "%R/vdiff?from=%T&to=%T&sbs=1", | |
| 980 | - zFrom, zTo); | |
| 1000 | + "%R/vdiff?from=%T&to=%T&sbs=1%s%T", | |
| 1001 | + zFrom, zTo, | |
| 1002 | + zGlob ? "&glob=" : "", zGlob ? zGlob : ""); | |
| 981 | 1003 | } |
| 982 | 1004 | if( sideBySide || !verboseFlag ) { |
| 983 | 1005 | style_submenu_element("Unified Diff", "udiff", |
| 984 | - "%R/vdiff?from=%T&to=%T&sbs=0&v", | |
| 985 | - zFrom, zTo); | |
| 1006 | + "%R/vdiff?from=%T&to=%T&sbs=0&v%s%T", | |
| 1007 | + zFrom, zTo, | |
| 1008 | + zGlob ? "&glob=" : "", zGlob ? zGlob : ""); | |
| 986 | 1009 | } |
| 987 | 1010 | style_submenu_element("Invert", "invert", |
| 988 | - "%R/vdiff?from=%T&to=%T&sbs=%d%s", zTo, zFrom, | |
| 989 | - sideBySide, (verboseFlag && !sideBySide)?"&v":""); | |
| 1011 | + "%R/vdiff?from=%T&to=%T&sbs=%d%s%s%T", zTo, zFrom, | |
| 1012 | + sideBySide, (verboseFlag && !sideBySide)?"&v":"", | |
| 1013 | + zGlob ? "&glob=" : "", zGlob ? zGlob : ""); | |
| 1014 | + if( zGlob ){ | |
| 1015 | + style_submenu_element("Clear glob", "clearglob", | |
| 1016 | + "%R/vdiff?from=%T&to=%T&sbs=%d%s", zFrom, zTo, | |
| 1017 | + sideBySide, (verboseFlag && !sideBySide)?"&v":""); | |
| 1018 | + }else{ | |
| 1019 | + style_submenu_element("Patch", "patch", | |
| 1020 | + "%R/vpatch?from=%T&to=%T", zFrom, zTo); | |
| 1021 | + } | |
| 990 | 1022 | style_header("Check-in Differences"); |
| 991 | 1023 | @ <h2>Difference From:</h2><blockquote> |
| 992 | 1024 | checkin_description(ridFrom); |
| 993 | 1025 | @ </blockquote><h2>To:</h2><blockquote> |
| 994 | 1026 | checkin_description(ridTo); |
| @@ -995,10 +1027,13 @@ | ||
| 995 | 1027 | @ </blockquote> |
| 996 | 1028 | if( pRe ){ |
| 997 | 1029 | @ <p><b>Only differences that match regular expression "%h(zRe)" |
| 998 | 1030 | @ are shown.</b></p> |
| 999 | 1031 | } |
| 1032 | + if( zGlob ){ | |
| 1033 | + @ <p><b>Only files matching the glob "%h(zGlob)" are shown.</b></p> | |
| 1034 | + } | |
| 1000 | 1035 | @<hr /><p> |
| 1001 | 1036 | |
| 1002 | 1037 | manifest_file_rewind(pFrom); |
| 1003 | 1038 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1004 | 1039 | manifest_file_rewind(pTo); |
| @@ -1012,27 +1047,33 @@ | ||
| 1012 | 1047 | cmp = -1; |
| 1013 | 1048 | }else{ |
| 1014 | 1049 | cmp = fossil_strcmp(pFileFrom->zName, pFileTo->zName); |
| 1015 | 1050 | } |
| 1016 | 1051 | if( cmp<0 ){ |
| 1017 | - append_file_change_line(pFileFrom->zName, | |
| 1018 | - pFileFrom->zUuid, 0, 0, diffFlags, pRe, 0); | |
| 1052 | + if(!zGlob || strglob(zGlob, pFileFrom->zName)){ | |
| 1053 | + append_file_change_line(pFileFrom->zName, | |
| 1054 | + pFileFrom->zUuid, 0, 0, diffFlags, pRe, 0); | |
| 1055 | + } | |
| 1019 | 1056 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1020 | 1057 | }else if( cmp>0 ){ |
| 1021 | - append_file_change_line(pFileTo->zName, | |
| 1022 | - 0, pFileTo->zUuid, 0, diffFlags, pRe, | |
| 1023 | - manifest_file_mperm(pFileTo)); | |
| 1058 | + if(!zGlob || strglob(zGlob, pFileTo->zName)){ | |
| 1059 | + append_file_change_line(pFileTo->zName, | |
| 1060 | + 0, pFileTo->zUuid, 0, diffFlags, pRe, | |
| 1061 | + manifest_file_mperm(pFileTo)); | |
| 1062 | + } | |
| 1024 | 1063 | pFileTo = manifest_file_next(pTo, 0); |
| 1025 | 1064 | }else if( fossil_strcmp(pFileFrom->zUuid, pFileTo->zUuid)==0 ){ |
| 1026 | - /* No changes */ | |
| 1027 | 1065 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1028 | 1066 | pFileTo = manifest_file_next(pTo, 0); |
| 1029 | 1067 | }else{ |
| 1030 | - append_file_change_line(pFileFrom->zName, | |
| 1031 | - pFileFrom->zUuid, | |
| 1032 | - pFileTo->zUuid, 0, diffFlags, pRe, | |
| 1033 | - manifest_file_mperm(pFileTo)); | |
| 1068 | + if(!zGlob || (strglob(zGlob, pFileFrom->zName) | |
| 1069 | + || strglob(zGlob, pFileTo->zName))){ | |
| 1070 | + append_file_change_line(pFileFrom->zName, | |
| 1071 | + pFileFrom->zUuid, | |
| 1072 | + pFileTo->zUuid, 0, diffFlags, pRe, | |
| 1073 | + manifest_file_mperm(pFileTo)); | |
| 1074 | + } | |
| 1034 | 1075 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1035 | 1076 | pFileTo = manifest_file_next(pTo, 0); |
| 1036 | 1077 | } |
| 1037 | 1078 | } |
| 1038 | 1079 | manifest_destroy(pFrom); |
| @@ -2372,11 +2413,11 @@ | ||
| 2372 | 2413 | @ onkeyup="chgbn(this.value.trim(),'%h(zBranchName)')" /></td></tr> |
| 2373 | 2414 | if( !fHasHidden ){ |
| 2374 | 2415 | @ <tr><th align="right" valign="top">Branch Hiding:</th> |
| 2375 | 2416 | @ <td valign="top"> |
| 2376 | 2417 | @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) /> |
| 2377 | - @ Hide branch | |
| 2418 | + @ Hide branch | |
| 2378 | 2419 | @ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span> |
| 2379 | 2420 | @ from the timeline starting from this check-in</label> |
| 2380 | 2421 | @ </td></tr> |
| 2381 | 2422 | } |
| 2382 | 2423 | if( !fHasClosed ){ |
| 2383 | 2424 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -108,10 +108,26 @@ | |
| 108 | ); |
| 109 | fossil_print("%-13s %s %s\n", zType, zUuid, zDate); |
| 110 | free(zDate); |
| 111 | } |
| 112 | db_finalize(&q); |
| 113 | } |
| 114 | zTags = info_tags_of_checkin(rid, 0); |
| 115 | if( zTags && zTags[0] ){ |
| 116 | fossil_print("tags: %s\n", zTags); |
| 117 | } |
| @@ -917,15 +933,16 @@ | |
| 917 | ** WEBPAGE: vdiff |
| 918 | ** URL: /vdiff |
| 919 | ** |
| 920 | ** Query parameters: |
| 921 | ** |
| 922 | ** from=TAG |
| 923 | ** to=TAG |
| 924 | ** branch=TAG |
| 925 | ** v=BOOLEAN |
| 926 | ** sbs=BOOLEAN |
| 927 | ** |
| 928 | ** |
| 929 | ** Show all differences between two checkins. |
| 930 | */ |
| 931 | void vdiff_page(void){ |
| @@ -938,16 +955,15 @@ | |
| 938 | const char *zBranch; |
| 939 | const char *zFrom; |
| 940 | const char *zTo; |
| 941 | const char *zRe; |
| 942 | const char *zVerbose; |
| 943 | ReCompiled *pRe = 0; |
| 944 | |
| 945 | login_check_credentials(); |
| 946 | if( !g.perm.Read ){ login_needed(); return; } |
| 947 | login_anonymous_available(); |
| 948 | |
| 949 | zRe = P("regex"); |
| 950 | if( zRe ) re_compile(&pRe, zRe, 0); |
| 951 | zBranch = P("branch"); |
| 952 | if( zBranch && zBranch[0] ){ |
| 953 | cgi_replace_parameter("from", mprintf("root:%s", zBranch)); |
| @@ -965,30 +981,46 @@ | |
| 965 | if( !zVerbose ){ |
| 966 | zVerbose = P("detail"); /* deprecated */ |
| 967 | } |
| 968 | verboseFlag = (zVerbose!=0) && !is_false(zVerbose); |
| 969 | if( !verboseFlag && sideBySide ) verboseFlag = 1; |
| 970 | zFrom = P("from"); |
| 971 | zTo = P("to"); |
| 972 | if( sideBySide || verboseFlag ){ |
| 973 | style_submenu_element("Hide Diff", "hidediff", |
| 974 | "%R/vdiff?from=%T&to=%T&sbs=0", |
| 975 | zFrom, zTo); |
| 976 | } |
| 977 | if( !sideBySide ){ |
| 978 | style_submenu_element("Side-by-side Diff", "sbsdiff", |
| 979 | "%R/vdiff?from=%T&to=%T&sbs=1", |
| 980 | zFrom, zTo); |
| 981 | } |
| 982 | if( sideBySide || !verboseFlag ) { |
| 983 | style_submenu_element("Unified Diff", "udiff", |
| 984 | "%R/vdiff?from=%T&to=%T&sbs=0&v", |
| 985 | zFrom, zTo); |
| 986 | } |
| 987 | style_submenu_element("Invert", "invert", |
| 988 | "%R/vdiff?from=%T&to=%T&sbs=%d%s", zTo, zFrom, |
| 989 | sideBySide, (verboseFlag && !sideBySide)?"&v":""); |
| 990 | style_header("Check-in Differences"); |
| 991 | @ <h2>Difference From:</h2><blockquote> |
| 992 | checkin_description(ridFrom); |
| 993 | @ </blockquote><h2>To:</h2><blockquote> |
| 994 | checkin_description(ridTo); |
| @@ -995,10 +1027,13 @@ | |
| 995 | @ </blockquote> |
| 996 | if( pRe ){ |
| 997 | @ <p><b>Only differences that match regular expression "%h(zRe)" |
| 998 | @ are shown.</b></p> |
| 999 | } |
| 1000 | @<hr /><p> |
| 1001 | |
| 1002 | manifest_file_rewind(pFrom); |
| 1003 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1004 | manifest_file_rewind(pTo); |
| @@ -1012,27 +1047,33 @@ | |
| 1012 | cmp = -1; |
| 1013 | }else{ |
| 1014 | cmp = fossil_strcmp(pFileFrom->zName, pFileTo->zName); |
| 1015 | } |
| 1016 | if( cmp<0 ){ |
| 1017 | append_file_change_line(pFileFrom->zName, |
| 1018 | pFileFrom->zUuid, 0, 0, diffFlags, pRe, 0); |
| 1019 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1020 | }else if( cmp>0 ){ |
| 1021 | append_file_change_line(pFileTo->zName, |
| 1022 | 0, pFileTo->zUuid, 0, diffFlags, pRe, |
| 1023 | manifest_file_mperm(pFileTo)); |
| 1024 | pFileTo = manifest_file_next(pTo, 0); |
| 1025 | }else if( fossil_strcmp(pFileFrom->zUuid, pFileTo->zUuid)==0 ){ |
| 1026 | /* No changes */ |
| 1027 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1028 | pFileTo = manifest_file_next(pTo, 0); |
| 1029 | }else{ |
| 1030 | append_file_change_line(pFileFrom->zName, |
| 1031 | pFileFrom->zUuid, |
| 1032 | pFileTo->zUuid, 0, diffFlags, pRe, |
| 1033 | manifest_file_mperm(pFileTo)); |
| 1034 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1035 | pFileTo = manifest_file_next(pTo, 0); |
| 1036 | } |
| 1037 | } |
| 1038 | manifest_destroy(pFrom); |
| @@ -2372,11 +2413,11 @@ | |
| 2372 | @ onkeyup="chgbn(this.value.trim(),'%h(zBranchName)')" /></td></tr> |
| 2373 | if( !fHasHidden ){ |
| 2374 | @ <tr><th align="right" valign="top">Branch Hiding:</th> |
| 2375 | @ <td valign="top"> |
| 2376 | @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) /> |
| 2377 | @ Hide branch |
| 2378 | @ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span> |
| 2379 | @ from the timeline starting from this check-in</label> |
| 2380 | @ </td></tr> |
| 2381 | } |
| 2382 | if( !fHasClosed ){ |
| 2383 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -108,10 +108,26 @@ | |
| 108 | ); |
| 109 | fossil_print("%-13s %s %s\n", zType, zUuid, zDate); |
| 110 | free(zDate); |
| 111 | } |
| 112 | db_finalize(&q); |
| 113 | } |
| 114 | if( zUuid ){ |
| 115 | fossil_print("%-13s ", "leaf:"); |
| 116 | if(is_a_leaf(rid)){ |
| 117 | if(db_int(0, "SELECT 1 FROM tagxref AS tx" |
| 118 | " WHERE tx.rid=%d" |
| 119 | " AND tx.tagid=%d" |
| 120 | " AND tx.tagtype>0", |
| 121 | rid, TAG_CLOSED)){ |
| 122 | fossil_print("%s\n", "closed"); |
| 123 | }else{ |
| 124 | fossil_print("%s\n", "open"); |
| 125 | } |
| 126 | }else{ |
| 127 | fossil_print("no\n"); |
| 128 | } |
| 129 | } |
| 130 | zTags = info_tags_of_checkin(rid, 0); |
| 131 | if( zTags && zTags[0] ){ |
| 132 | fossil_print("tags: %s\n", zTags); |
| 133 | } |
| @@ -917,15 +933,16 @@ | |
| 933 | ** WEBPAGE: vdiff |
| 934 | ** URL: /vdiff |
| 935 | ** |
| 936 | ** Query parameters: |
| 937 | ** |
| 938 | ** from=TAG Left side of the comparison |
| 939 | ** to=TAG Right side of the comparison |
| 940 | ** branch=TAG Show all changes on a particular branch |
| 941 | ** v=BOOLEAN Default true. If false, only list files that have changed |
| 942 | ** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false |
| 943 | ** glob=STRING only diff files matching this glob |
| 944 | ** |
| 945 | ** |
| 946 | ** Show all differences between two checkins. |
| 947 | */ |
| 948 | void vdiff_page(void){ |
| @@ -938,16 +955,15 @@ | |
| 955 | const char *zBranch; |
| 956 | const char *zFrom; |
| 957 | const char *zTo; |
| 958 | const char *zRe; |
| 959 | const char *zVerbose; |
| 960 | const char *zGlob; |
| 961 | ReCompiled *pRe = 0; |
| 962 | login_check_credentials(); |
| 963 | if( !g.perm.Read ){ login_needed(); return; } |
| 964 | login_anonymous_available(); |
| 965 | zRe = P("regex"); |
| 966 | if( zRe ) re_compile(&pRe, zRe, 0); |
| 967 | zBranch = P("branch"); |
| 968 | if( zBranch && zBranch[0] ){ |
| 969 | cgi_replace_parameter("from", mprintf("root:%s", zBranch)); |
| @@ -965,30 +981,46 @@ | |
| 981 | if( !zVerbose ){ |
| 982 | zVerbose = P("detail"); /* deprecated */ |
| 983 | } |
| 984 | verboseFlag = (zVerbose!=0) && !is_false(zVerbose); |
| 985 | if( !verboseFlag && sideBySide ) verboseFlag = 1; |
| 986 | zGlob = P("glob"); |
| 987 | zFrom = P("from"); |
| 988 | zTo = P("to"); |
| 989 | if(zGlob && !*zGlob){ |
| 990 | zGlob = NULL; |
| 991 | } |
| 992 | if( sideBySide || verboseFlag ){ |
| 993 | style_submenu_element("Hide Diff", "hidediff", |
| 994 | "%R/vdiff?from=%T&to=%T&sbs=0%s%T", |
| 995 | zFrom, zTo, |
| 996 | zGlob ? "&glob=" : "", zGlob ? zGlob : ""); |
| 997 | } |
| 998 | if( !sideBySide ){ |
| 999 | style_submenu_element("Side-by-side Diff", "sbsdiff", |
| 1000 | "%R/vdiff?from=%T&to=%T&sbs=1%s%T", |
| 1001 | zFrom, zTo, |
| 1002 | zGlob ? "&glob=" : "", zGlob ? zGlob : ""); |
| 1003 | } |
| 1004 | if( sideBySide || !verboseFlag ) { |
| 1005 | style_submenu_element("Unified Diff", "udiff", |
| 1006 | "%R/vdiff?from=%T&to=%T&sbs=0&v%s%T", |
| 1007 | zFrom, zTo, |
| 1008 | zGlob ? "&glob=" : "", zGlob ? zGlob : ""); |
| 1009 | } |
| 1010 | style_submenu_element("Invert", "invert", |
| 1011 | "%R/vdiff?from=%T&to=%T&sbs=%d%s%s%T", zTo, zFrom, |
| 1012 | sideBySide, (verboseFlag && !sideBySide)?"&v":"", |
| 1013 | zGlob ? "&glob=" : "", zGlob ? zGlob : ""); |
| 1014 | if( zGlob ){ |
| 1015 | style_submenu_element("Clear glob", "clearglob", |
| 1016 | "%R/vdiff?from=%T&to=%T&sbs=%d%s", zFrom, zTo, |
| 1017 | sideBySide, (verboseFlag && !sideBySide)?"&v":""); |
| 1018 | }else{ |
| 1019 | style_submenu_element("Patch", "patch", |
| 1020 | "%R/vpatch?from=%T&to=%T", zFrom, zTo); |
| 1021 | } |
| 1022 | style_header("Check-in Differences"); |
| 1023 | @ <h2>Difference From:</h2><blockquote> |
| 1024 | checkin_description(ridFrom); |
| 1025 | @ </blockquote><h2>To:</h2><blockquote> |
| 1026 | checkin_description(ridTo); |
| @@ -995,10 +1027,13 @@ | |
| 1027 | @ </blockquote> |
| 1028 | if( pRe ){ |
| 1029 | @ <p><b>Only differences that match regular expression "%h(zRe)" |
| 1030 | @ are shown.</b></p> |
| 1031 | } |
| 1032 | if( zGlob ){ |
| 1033 | @ <p><b>Only files matching the glob "%h(zGlob)" are shown.</b></p> |
| 1034 | } |
| 1035 | @<hr /><p> |
| 1036 | |
| 1037 | manifest_file_rewind(pFrom); |
| 1038 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1039 | manifest_file_rewind(pTo); |
| @@ -1012,27 +1047,33 @@ | |
| 1047 | cmp = -1; |
| 1048 | }else{ |
| 1049 | cmp = fossil_strcmp(pFileFrom->zName, pFileTo->zName); |
| 1050 | } |
| 1051 | if( cmp<0 ){ |
| 1052 | if(!zGlob || strglob(zGlob, pFileFrom->zName)){ |
| 1053 | append_file_change_line(pFileFrom->zName, |
| 1054 | pFileFrom->zUuid, 0, 0, diffFlags, pRe, 0); |
| 1055 | } |
| 1056 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1057 | }else if( cmp>0 ){ |
| 1058 | if(!zGlob || strglob(zGlob, pFileTo->zName)){ |
| 1059 | append_file_change_line(pFileTo->zName, |
| 1060 | 0, pFileTo->zUuid, 0, diffFlags, pRe, |
| 1061 | manifest_file_mperm(pFileTo)); |
| 1062 | } |
| 1063 | pFileTo = manifest_file_next(pTo, 0); |
| 1064 | }else if( fossil_strcmp(pFileFrom->zUuid, pFileTo->zUuid)==0 ){ |
| 1065 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1066 | pFileTo = manifest_file_next(pTo, 0); |
| 1067 | }else{ |
| 1068 | if(!zGlob || (strglob(zGlob, pFileFrom->zName) |
| 1069 | || strglob(zGlob, pFileTo->zName))){ |
| 1070 | append_file_change_line(pFileFrom->zName, |
| 1071 | pFileFrom->zUuid, |
| 1072 | pFileTo->zUuid, 0, diffFlags, pRe, |
| 1073 | manifest_file_mperm(pFileTo)); |
| 1074 | } |
| 1075 | pFileFrom = manifest_file_next(pFrom, 0); |
| 1076 | pFileTo = manifest_file_next(pTo, 0); |
| 1077 | } |
| 1078 | } |
| 1079 | manifest_destroy(pFrom); |
| @@ -2372,11 +2413,11 @@ | |
| 2413 | @ onkeyup="chgbn(this.value.trim(),'%h(zBranchName)')" /></td></tr> |
| 2414 | if( !fHasHidden ){ |
| 2415 | @ <tr><th align="right" valign="top">Branch Hiding:</th> |
| 2416 | @ <td valign="top"> |
| 2417 | @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) /> |
| 2418 | @ Hide branch |
| 2419 | @ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span> |
| 2420 | @ from the timeline starting from this check-in</label> |
| 2421 | @ </td></tr> |
| 2422 | } |
| 2423 | if( !fHasClosed ){ |
| 2424 |
+27
-23
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -41,11 +41,11 @@ | ||
| 41 | 41 | ** logs and downloading diffs of very version of the archive that |
| 42 | 42 | ** has ever existed, and things like that. |
| 43 | 43 | */ |
| 44 | 44 | #include "config.h" |
| 45 | 45 | #include "login.h" |
| 46 | -#if defined(_WIN32) | |
| 46 | +#if defined(_WIN32) | |
| 47 | 47 | # include <windows.h> /* for Sleep */ |
| 48 | 48 | # if defined(__MINGW32__) || defined(_MSC_VER) |
| 49 | 49 | # define sleep Sleep /* windows does not have sleep, but Sleep */ |
| 50 | 50 | # endif |
| 51 | 51 | #endif |
| @@ -112,13 +112,13 @@ | ||
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /* |
| 116 | 116 | ** The IP address of the client is stored as part of login cookies. |
| 117 | -** But some clients are behind firewalls that shift the IP address | |
| 118 | -** with each HTTP request. To allow such (broken) clients to log in, | |
| 119 | -** extract just a prefix of the IP address. | |
| 117 | +** But some clients are behind firewalls that shift the IP address | |
| 118 | +** with each HTTP request. To allow such (broken) clients to log in, | |
| 119 | +** extract just a prefix of the IP address. | |
| 120 | 120 | */ |
| 121 | 121 | static char *ipPrefix(const char *zIP){ |
| 122 | 122 | int i, j; |
| 123 | 123 | static int ip_prefix_terms = -1; |
| 124 | 124 | if( ip_prefix_terms<0 ){ |
| @@ -344,11 +344,11 @@ | ||
| 344 | 344 | */ |
| 345 | 345 | void login_clear_login_data(){ |
| 346 | 346 | if(!g.userUid){ |
| 347 | 347 | return; |
| 348 | 348 | }else{ |
| 349 | - char const * cookie = login_cookie_name(); | |
| 349 | + char const * cookie = login_cookie_name(); | |
| 350 | 350 | /* To logout, change the cookie value to an empty string */ |
| 351 | 351 | cgi_set_cookie(cookie, "", |
| 352 | 352 | login_cookie_path(), -86400); |
| 353 | 353 | db_multi_exec("UPDATE user SET cookie=NULL, ipaddr=NULL, " |
| 354 | 354 | " cexpire=0 WHERE uid=%d" |
| @@ -472,10 +472,11 @@ | ||
| 472 | 472 | int anonFlag; |
| 473 | 473 | char *zErrMsg = ""; |
| 474 | 474 | int uid; /* User id logged in user */ |
| 475 | 475 | char *zSha1Pw; |
| 476 | 476 | const char *zIpAddr; /* IP address of requestor */ |
| 477 | + const char *zReferer; | |
| 477 | 478 | |
| 478 | 479 | login_check_credentials(); |
| 479 | 480 | sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0, |
| 480 | 481 | constant_time_cmp_function, 0, 0); |
| 481 | 482 | zUsername = P("u"); |
| @@ -491,21 +492,21 @@ | ||
| 491 | 492 | /* The user requests a password change */ |
| 492 | 493 | zSha1Pw = sha1_shared_secret(zPasswd, g.zLogin, 0); |
| 493 | 494 | if( db_int(1, "SELECT 0 FROM user" |
| 494 | 495 | " WHERE uid=%d" |
| 495 | 496 | " AND (constant_time_cmp(pw,%Q)=0" |
| 496 | - " OR constant_time_cmp(pw,%Q)=0)", | |
| 497 | + " OR constant_time_cmp(pw,%Q)=0)", | |
| 497 | 498 | g.userUid, zSha1Pw, zPasswd) ){ |
| 498 | 499 | sleep(1); |
| 499 | - zErrMsg = | |
| 500 | + zErrMsg = | |
| 500 | 501 | @ <p><span class="loginError"> |
| 501 | 502 | @ You entered an incorrect old password while attempting to change |
| 502 | 503 | @ your password. Your password is unchanged. |
| 503 | 504 | @ </span></p> |
| 504 | 505 | ; |
| 505 | 506 | }else if( fossil_strcmp(zNew1,zNew2)!=0 ){ |
| 506 | - zErrMsg = | |
| 507 | + zErrMsg = | |
| 507 | 508 | @ <p><span class="loginError"> |
| 508 | 509 | @ The two copies of your new passwords do not match. |
| 509 | 510 | @ Your password is unchanged. |
| 510 | 511 | @ </span></p> |
| 511 | 512 | ; |
| @@ -532,10 +533,11 @@ | ||
| 532 | 533 | return; |
| 533 | 534 | } |
| 534 | 535 | } |
| 535 | 536 | } |
| 536 | 537 | zIpAddr = PD("REMOTE_ADDR","nil"); /* Complete IP address for logging */ |
| 538 | + zReferer = P("HTTP_REFERER"); | |
| 537 | 539 | uid = login_is_valid_anonymous(zUsername, zPasswd, P("cs")); |
| 538 | 540 | if( uid>0 ){ |
| 539 | 541 | login_set_anon_cookie(zIpAddr, NULL); |
| 540 | 542 | record_login_attempt("anonymous", zIpAddr, 1); |
| 541 | 543 | redirect_to_g(); |
| @@ -544,11 +546,11 @@ | ||
| 544 | 546 | /* Attempting to log in as a user other than anonymous. |
| 545 | 547 | */ |
| 546 | 548 | uid = login_search_uid(zUsername, zPasswd); |
| 547 | 549 | if( uid<=0 ){ |
| 548 | 550 | sleep(1); |
| 549 | - zErrMsg = | |
| 551 | + zErrMsg = | |
| 550 | 552 | @ <p><span class="loginError"> |
| 551 | 553 | @ You entered an unknown user or an incorrect password. |
| 552 | 554 | @ </span></p> |
| 553 | 555 | ; |
| 554 | 556 | record_login_attempt(zUsername, zIpAddr, 0); |
| @@ -570,10 +572,12 @@ | ||
| 570 | 572 | @ <p>A login is required for <a href="%h(zGoto)">%h(zGoto)</a>.</p> |
| 571 | 573 | } |
| 572 | 574 | form_begin(0, "%R/login"); |
| 573 | 575 | if( zGoto ){ |
| 574 | 576 | @ <input type="hidden" name="g" value="%h(zGoto)" /> |
| 577 | + }else if( zReferer && strncmp(g.zBaseURL, zReferer, strlen(g.zBaseURL))==0 ){ | |
| 578 | + @ <input type="hidden" name="g" value="%h(zReferer)" /> | |
| 575 | 579 | } |
| 576 | 580 | @ <table class="login_out"> |
| 577 | 581 | @ <tr> |
| 578 | 582 | @ <td class="login_out_label">User ID:</td> |
| 579 | 583 | if( anonFlag ){ |
| @@ -595,11 +599,11 @@ | ||
| 595 | 599 | @ <td></td> |
| 596 | 600 | @ <td><input type="submit" name="in" value="Login" |
| 597 | 601 | @ onClick="chngAction(this.form)" /></td> |
| 598 | 602 | @ </tr> |
| 599 | 603 | @ </table> |
| 600 | - @ <script type="text/JavaScript"> | |
| 604 | + @ <script> | |
| 601 | 605 | @ gebi('u').focus() |
| 602 | 606 | @ function chngAction(form){ |
| 603 | 607 | if( g.sslNotAvailable==0 |
| 604 | 608 | && strncmp(g.zBaseURL,"https:",6)!=0 |
| 605 | 609 | && db_get_boolean("https-login",0) |
| @@ -620,11 +624,11 @@ | ||
| 620 | 624 | @ your user-id and password at the left and press the |
| 621 | 625 | @ "Login" button. Your user name will be stored in a browser cookie. |
| 622 | 626 | @ You must configure your web browser to accept cookies in order for |
| 623 | 627 | @ the login to take.</p> |
| 624 | 628 | if( db_get_boolean("self-register", 0) ){ |
| 625 | - @ <p>If you do not have an account, you can | |
| 629 | + @ <p>If you do not have an account, you can | |
| 626 | 630 | @ <a href="%s(g.zTop)/register?g=%T(P("G"))">create one</a>. |
| 627 | 631 | } |
| 628 | 632 | if( zAnonPw ){ |
| 629 | 633 | unsigned int uSeed = captcha_seed(); |
| 630 | 634 | char const *zDecoded = captcha_decode(uSeed); |
| @@ -672,11 +676,11 @@ | ||
| 672 | 676 | style_footer(); |
| 673 | 677 | } |
| 674 | 678 | |
| 675 | 679 | /* |
| 676 | 680 | ** Attempt to find login credentials for user zLogin on a peer repository |
| 677 | -** with project code zCode. Transfer those credentials to the local | |
| 681 | +** with project code zCode. Transfer those credentials to the local | |
| 678 | 682 | ** repository. |
| 679 | 683 | ** |
| 680 | 684 | ** Return true if a transfer was made and false if not. |
| 681 | 685 | */ |
| 682 | 686 | static int login_transfer_credentials( |
| @@ -690,11 +694,11 @@ | ||
| 690 | 694 | char *zSQL; /* SQL of the query against other repo */ |
| 691 | 695 | char *zOtherRepo; /* Filename of the other repository */ |
| 692 | 696 | int rc; /* Result code from SQLite library functions */ |
| 693 | 697 | int nXfer = 0; /* Number of credentials transferred */ |
| 694 | 698 | |
| 695 | - zOtherRepo = db_text(0, | |
| 699 | + zOtherRepo = db_text(0, | |
| 696 | 700 | "SELECT value FROM config WHERE name='peer-repo-%q'", |
| 697 | 701 | zCode |
| 698 | 702 | ); |
| 699 | 703 | if( zOtherRepo==0 ) return 0; /* No such peer repository */ |
| 700 | 704 | |
| @@ -752,11 +756,11 @@ | ||
| 752 | 756 | int uid; |
| 753 | 757 | if( fossil_strcmp(zLogin, "anonymous")==0 ) return 0; |
| 754 | 758 | if( fossil_strcmp(zLogin, "nobody")==0 ) return 0; |
| 755 | 759 | if( fossil_strcmp(zLogin, "developer")==0 ) return 0; |
| 756 | 760 | if( fossil_strcmp(zLogin, "reader")==0 ) return 0; |
| 757 | - uid = db_int(0, | |
| 761 | + uid = db_int(0, | |
| 758 | 762 | "SELECT uid FROM user" |
| 759 | 763 | " WHERE login=%Q" |
| 760 | 764 | " AND ipaddr=%Q" |
| 761 | 765 | " AND cexpire>julianday('now')" |
| 762 | 766 | " AND length(cap)>0" |
| @@ -792,11 +796,11 @@ | ||
| 792 | 796 | |
| 793 | 797 | sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0, |
| 794 | 798 | constant_time_cmp_function, 0, 0); |
| 795 | 799 | |
| 796 | 800 | /* If the HTTP connection is coming over 127.0.0.1 and if |
| 797 | - ** local login is disabled and if we are using HTTP and not HTTPS, | |
| 801 | + ** local login is disabled and if we are using HTTP and not HTTPS, | |
| 798 | 802 | ** then there is no need to check user credentials. |
| 799 | 803 | ** |
| 800 | 804 | ** This feature allows the "fossil ui" command to give the user |
| 801 | 805 | ** full access rights without having to log in. |
| 802 | 806 | */ |
| @@ -847,15 +851,15 @@ | ||
| 847 | 851 | ** SECRET is the "captcha-secret" value in the repository. |
| 848 | 852 | */ |
| 849 | 853 | double rTime = atof(zArg); |
| 850 | 854 | Blob b; |
| 851 | 855 | blob_zero(&b); |
| 852 | - blob_appendf(&b, "%s/%s/%s", | |
| 856 | + blob_appendf(&b, "%s/%s/%s", | |
| 853 | 857 | zArg, zRemoteAddr, db_get("captcha-secret","")); |
| 854 | 858 | sha1sum_blob(&b, &b); |
| 855 | 859 | if( fossil_strcmp(zHash, blob_str(&b))==0 ){ |
| 856 | - uid = db_int(0, | |
| 860 | + uid = db_int(0, | |
| 857 | 861 | "SELECT uid FROM user WHERE login='anonymous'" |
| 858 | 862 | " AND length(cap)>0" |
| 859 | 863 | " AND length(pw)>0" |
| 860 | 864 | " AND %.17g+0.25>julianday('now')", |
| 861 | 865 | rTime |
| @@ -1002,11 +1006,11 @@ | ||
| 1002 | 1006 | for(i=0; zCap[i]; i++){ |
| 1003 | 1007 | switch( zCap[i] ){ |
| 1004 | 1008 | case 's': g.perm.Setup = 1; /* Fall thru into Admin */ |
| 1005 | 1009 | case 'a': g.perm.Admin = g.perm.RdTkt = g.perm.WrTkt = g.perm.Zip = |
| 1006 | 1010 | g.perm.RdWiki = g.perm.WrWiki = g.perm.NewWiki = |
| 1007 | - g.perm.ApndWiki = g.perm.Hyperlink = g.perm.Clone = | |
| 1011 | + g.perm.ApndWiki = g.perm.Hyperlink = g.perm.Clone = | |
| 1008 | 1012 | g.perm.NewTkt = g.perm.Password = g.perm.RdAddr = |
| 1009 | 1013 | g.perm.TktFmt = g.perm.Attach = g.perm.ApndTkt = |
| 1010 | 1014 | g.perm.ModWiki = g.perm.ModTkt = 1; |
| 1011 | 1015 | /* Fall thru into Read/Write */ |
| 1012 | 1016 | case 'i': g.perm.Read = g.perm.Write = 1; break; |
| @@ -1025,19 +1029,19 @@ | ||
| 1025 | 1029 | case 'l': g.perm.ModWiki = 1; break; |
| 1026 | 1030 | |
| 1027 | 1031 | case 'e': g.perm.RdAddr = 1; break; |
| 1028 | 1032 | case 'r': g.perm.RdTkt = 1; break; |
| 1029 | 1033 | case 'n': g.perm.NewTkt = 1; break; |
| 1030 | - case 'w': g.perm.WrTkt = g.perm.RdTkt = g.perm.NewTkt = | |
| 1034 | + case 'w': g.perm.WrTkt = g.perm.RdTkt = g.perm.NewTkt = | |
| 1031 | 1035 | g.perm.ApndTkt = 1; break; |
| 1032 | 1036 | case 'c': g.perm.ApndTkt = 1; break; |
| 1033 | 1037 | case 'q': g.perm.ModTkt = 1; break; |
| 1034 | 1038 | case 't': g.perm.TktFmt = 1; break; |
| 1035 | 1039 | case 'b': g.perm.Attach = 1; break; |
| 1036 | 1040 | case 'x': g.perm.Private = 1; break; |
| 1037 | 1041 | |
| 1038 | - /* The "u" privileges is a little different. It recursively | |
| 1042 | + /* The "u" privileges is a little different. It recursively | |
| 1039 | 1043 | ** inherits all privileges of the user named "reader" */ |
| 1040 | 1044 | case 'u': { |
| 1041 | 1045 | if( (flags & LOGIN_IGNORE_UV)==0 ){ |
| 1042 | 1046 | const char *zUser; |
| 1043 | 1047 | zUser = db_text("", "SELECT cap FROM user WHERE login='reader'"); |
| @@ -1044,11 +1048,11 @@ | ||
| 1044 | 1048 | login_set_capabilities(zUser, flags | LOGIN_IGNORE_UV); |
| 1045 | 1049 | } |
| 1046 | 1050 | break; |
| 1047 | 1051 | } |
| 1048 | 1052 | |
| 1049 | - /* The "v" privileges is a little different. It recursively | |
| 1053 | + /* The "v" privileges is a little different. It recursively | |
| 1050 | 1054 | ** inherits all privileges of the user named "developer" */ |
| 1051 | 1055 | case 'v': { |
| 1052 | 1056 | if( (flags & LOGIN_IGNORE_UV)==0 ){ |
| 1053 | 1057 | const char *zDev; |
| 1054 | 1058 | zDev = db_text("", "SELECT cap FROM user WHERE login='developer'"); |
| @@ -1359,11 +1363,11 @@ | ||
| 1359 | 1363 | if( zPrefix==0 ) zPrefix = ""; |
| 1360 | 1364 | if( zSuffix==0 ) zSuffix = ""; |
| 1361 | 1365 | if( pzErrorMsg ) *pzErrorMsg = 0; |
| 1362 | 1366 | zSelfCode = abbreviated_project_code(db_get("project-code", "x")); |
| 1363 | 1367 | blob_zero(&err); |
| 1364 | - db_prepare(&q, | |
| 1368 | + db_prepare(&q, | |
| 1365 | 1369 | "SELECT name, value FROM config" |
| 1366 | 1370 | " WHERE name GLOB 'peer-repo-*'" |
| 1367 | 1371 | " AND name <> 'peer-repo-%q'" |
| 1368 | 1372 | " ORDER BY +value", |
| 1369 | 1373 | zSelfCode |
| @@ -1441,11 +1445,11 @@ | ||
| 1441 | 1445 | const char *zSelf; /* The ATTACH name of our repository */ |
| 1442 | 1446 | |
| 1443 | 1447 | *pzErrMsg = 0; /* Default to no errors */ |
| 1444 | 1448 | zSelf = db_name("repository"); |
| 1445 | 1449 | |
| 1446 | - /* Get the full pathname of the other repository */ | |
| 1450 | + /* Get the full pathname of the other repository */ | |
| 1447 | 1451 | file_canonical_name(zRepo, &fullName, 0); |
| 1448 | 1452 | zRepo = mprintf(blob_str(&fullName)); |
| 1449 | 1453 | blob_reset(&fullName); |
| 1450 | 1454 | |
| 1451 | 1455 | /* Get the full pathname for our repository. Also the project code |
| 1452 | 1456 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -41,11 +41,11 @@ | |
| 41 | ** logs and downloading diffs of very version of the archive that |
| 42 | ** has ever existed, and things like that. |
| 43 | */ |
| 44 | #include "config.h" |
| 45 | #include "login.h" |
| 46 | #if defined(_WIN32) |
| 47 | # include <windows.h> /* for Sleep */ |
| 48 | # if defined(__MINGW32__) || defined(_MSC_VER) |
| 49 | # define sleep Sleep /* windows does not have sleep, but Sleep */ |
| 50 | # endif |
| 51 | #endif |
| @@ -112,13 +112,13 @@ | |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /* |
| 116 | ** The IP address of the client is stored as part of login cookies. |
| 117 | ** But some clients are behind firewalls that shift the IP address |
| 118 | ** with each HTTP request. To allow such (broken) clients to log in, |
| 119 | ** extract just a prefix of the IP address. |
| 120 | */ |
| 121 | static char *ipPrefix(const char *zIP){ |
| 122 | int i, j; |
| 123 | static int ip_prefix_terms = -1; |
| 124 | if( ip_prefix_terms<0 ){ |
| @@ -344,11 +344,11 @@ | |
| 344 | */ |
| 345 | void login_clear_login_data(){ |
| 346 | if(!g.userUid){ |
| 347 | return; |
| 348 | }else{ |
| 349 | char const * cookie = login_cookie_name(); |
| 350 | /* To logout, change the cookie value to an empty string */ |
| 351 | cgi_set_cookie(cookie, "", |
| 352 | login_cookie_path(), -86400); |
| 353 | db_multi_exec("UPDATE user SET cookie=NULL, ipaddr=NULL, " |
| 354 | " cexpire=0 WHERE uid=%d" |
| @@ -472,10 +472,11 @@ | |
| 472 | int anonFlag; |
| 473 | char *zErrMsg = ""; |
| 474 | int uid; /* User id logged in user */ |
| 475 | char *zSha1Pw; |
| 476 | const char *zIpAddr; /* IP address of requestor */ |
| 477 | |
| 478 | login_check_credentials(); |
| 479 | sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0, |
| 480 | constant_time_cmp_function, 0, 0); |
| 481 | zUsername = P("u"); |
| @@ -491,21 +492,21 @@ | |
| 491 | /* The user requests a password change */ |
| 492 | zSha1Pw = sha1_shared_secret(zPasswd, g.zLogin, 0); |
| 493 | if( db_int(1, "SELECT 0 FROM user" |
| 494 | " WHERE uid=%d" |
| 495 | " AND (constant_time_cmp(pw,%Q)=0" |
| 496 | " OR constant_time_cmp(pw,%Q)=0)", |
| 497 | g.userUid, zSha1Pw, zPasswd) ){ |
| 498 | sleep(1); |
| 499 | zErrMsg = |
| 500 | @ <p><span class="loginError"> |
| 501 | @ You entered an incorrect old password while attempting to change |
| 502 | @ your password. Your password is unchanged. |
| 503 | @ </span></p> |
| 504 | ; |
| 505 | }else if( fossil_strcmp(zNew1,zNew2)!=0 ){ |
| 506 | zErrMsg = |
| 507 | @ <p><span class="loginError"> |
| 508 | @ The two copies of your new passwords do not match. |
| 509 | @ Your password is unchanged. |
| 510 | @ </span></p> |
| 511 | ; |
| @@ -532,10 +533,11 @@ | |
| 532 | return; |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 | zIpAddr = PD("REMOTE_ADDR","nil"); /* Complete IP address for logging */ |
| 537 | uid = login_is_valid_anonymous(zUsername, zPasswd, P("cs")); |
| 538 | if( uid>0 ){ |
| 539 | login_set_anon_cookie(zIpAddr, NULL); |
| 540 | record_login_attempt("anonymous", zIpAddr, 1); |
| 541 | redirect_to_g(); |
| @@ -544,11 +546,11 @@ | |
| 544 | /* Attempting to log in as a user other than anonymous. |
| 545 | */ |
| 546 | uid = login_search_uid(zUsername, zPasswd); |
| 547 | if( uid<=0 ){ |
| 548 | sleep(1); |
| 549 | zErrMsg = |
| 550 | @ <p><span class="loginError"> |
| 551 | @ You entered an unknown user or an incorrect password. |
| 552 | @ </span></p> |
| 553 | ; |
| 554 | record_login_attempt(zUsername, zIpAddr, 0); |
| @@ -570,10 +572,12 @@ | |
| 570 | @ <p>A login is required for <a href="%h(zGoto)">%h(zGoto)</a>.</p> |
| 571 | } |
| 572 | form_begin(0, "%R/login"); |
| 573 | if( zGoto ){ |
| 574 | @ <input type="hidden" name="g" value="%h(zGoto)" /> |
| 575 | } |
| 576 | @ <table class="login_out"> |
| 577 | @ <tr> |
| 578 | @ <td class="login_out_label">User ID:</td> |
| 579 | if( anonFlag ){ |
| @@ -595,11 +599,11 @@ | |
| 595 | @ <td></td> |
| 596 | @ <td><input type="submit" name="in" value="Login" |
| 597 | @ onClick="chngAction(this.form)" /></td> |
| 598 | @ </tr> |
| 599 | @ </table> |
| 600 | @ <script type="text/JavaScript"> |
| 601 | @ gebi('u').focus() |
| 602 | @ function chngAction(form){ |
| 603 | if( g.sslNotAvailable==0 |
| 604 | && strncmp(g.zBaseURL,"https:",6)!=0 |
| 605 | && db_get_boolean("https-login",0) |
| @@ -620,11 +624,11 @@ | |
| 620 | @ your user-id and password at the left and press the |
| 621 | @ "Login" button. Your user name will be stored in a browser cookie. |
| 622 | @ You must configure your web browser to accept cookies in order for |
| 623 | @ the login to take.</p> |
| 624 | if( db_get_boolean("self-register", 0) ){ |
| 625 | @ <p>If you do not have an account, you can |
| 626 | @ <a href="%s(g.zTop)/register?g=%T(P("G"))">create one</a>. |
| 627 | } |
| 628 | if( zAnonPw ){ |
| 629 | unsigned int uSeed = captcha_seed(); |
| 630 | char const *zDecoded = captcha_decode(uSeed); |
| @@ -672,11 +676,11 @@ | |
| 672 | style_footer(); |
| 673 | } |
| 674 | |
| 675 | /* |
| 676 | ** Attempt to find login credentials for user zLogin on a peer repository |
| 677 | ** with project code zCode. Transfer those credentials to the local |
| 678 | ** repository. |
| 679 | ** |
| 680 | ** Return true if a transfer was made and false if not. |
| 681 | */ |
| 682 | static int login_transfer_credentials( |
| @@ -690,11 +694,11 @@ | |
| 690 | char *zSQL; /* SQL of the query against other repo */ |
| 691 | char *zOtherRepo; /* Filename of the other repository */ |
| 692 | int rc; /* Result code from SQLite library functions */ |
| 693 | int nXfer = 0; /* Number of credentials transferred */ |
| 694 | |
| 695 | zOtherRepo = db_text(0, |
| 696 | "SELECT value FROM config WHERE name='peer-repo-%q'", |
| 697 | zCode |
| 698 | ); |
| 699 | if( zOtherRepo==0 ) return 0; /* No such peer repository */ |
| 700 | |
| @@ -752,11 +756,11 @@ | |
| 752 | int uid; |
| 753 | if( fossil_strcmp(zLogin, "anonymous")==0 ) return 0; |
| 754 | if( fossil_strcmp(zLogin, "nobody")==0 ) return 0; |
| 755 | if( fossil_strcmp(zLogin, "developer")==0 ) return 0; |
| 756 | if( fossil_strcmp(zLogin, "reader")==0 ) return 0; |
| 757 | uid = db_int(0, |
| 758 | "SELECT uid FROM user" |
| 759 | " WHERE login=%Q" |
| 760 | " AND ipaddr=%Q" |
| 761 | " AND cexpire>julianday('now')" |
| 762 | " AND length(cap)>0" |
| @@ -792,11 +796,11 @@ | |
| 792 | |
| 793 | sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0, |
| 794 | constant_time_cmp_function, 0, 0); |
| 795 | |
| 796 | /* If the HTTP connection is coming over 127.0.0.1 and if |
| 797 | ** local login is disabled and if we are using HTTP and not HTTPS, |
| 798 | ** then there is no need to check user credentials. |
| 799 | ** |
| 800 | ** This feature allows the "fossil ui" command to give the user |
| 801 | ** full access rights without having to log in. |
| 802 | */ |
| @@ -847,15 +851,15 @@ | |
| 847 | ** SECRET is the "captcha-secret" value in the repository. |
| 848 | */ |
| 849 | double rTime = atof(zArg); |
| 850 | Blob b; |
| 851 | blob_zero(&b); |
| 852 | blob_appendf(&b, "%s/%s/%s", |
| 853 | zArg, zRemoteAddr, db_get("captcha-secret","")); |
| 854 | sha1sum_blob(&b, &b); |
| 855 | if( fossil_strcmp(zHash, blob_str(&b))==0 ){ |
| 856 | uid = db_int(0, |
| 857 | "SELECT uid FROM user WHERE login='anonymous'" |
| 858 | " AND length(cap)>0" |
| 859 | " AND length(pw)>0" |
| 860 | " AND %.17g+0.25>julianday('now')", |
| 861 | rTime |
| @@ -1002,11 +1006,11 @@ | |
| 1002 | for(i=0; zCap[i]; i++){ |
| 1003 | switch( zCap[i] ){ |
| 1004 | case 's': g.perm.Setup = 1; /* Fall thru into Admin */ |
| 1005 | case 'a': g.perm.Admin = g.perm.RdTkt = g.perm.WrTkt = g.perm.Zip = |
| 1006 | g.perm.RdWiki = g.perm.WrWiki = g.perm.NewWiki = |
| 1007 | g.perm.ApndWiki = g.perm.Hyperlink = g.perm.Clone = |
| 1008 | g.perm.NewTkt = g.perm.Password = g.perm.RdAddr = |
| 1009 | g.perm.TktFmt = g.perm.Attach = g.perm.ApndTkt = |
| 1010 | g.perm.ModWiki = g.perm.ModTkt = 1; |
| 1011 | /* Fall thru into Read/Write */ |
| 1012 | case 'i': g.perm.Read = g.perm.Write = 1; break; |
| @@ -1025,19 +1029,19 @@ | |
| 1025 | case 'l': g.perm.ModWiki = 1; break; |
| 1026 | |
| 1027 | case 'e': g.perm.RdAddr = 1; break; |
| 1028 | case 'r': g.perm.RdTkt = 1; break; |
| 1029 | case 'n': g.perm.NewTkt = 1; break; |
| 1030 | case 'w': g.perm.WrTkt = g.perm.RdTkt = g.perm.NewTkt = |
| 1031 | g.perm.ApndTkt = 1; break; |
| 1032 | case 'c': g.perm.ApndTkt = 1; break; |
| 1033 | case 'q': g.perm.ModTkt = 1; break; |
| 1034 | case 't': g.perm.TktFmt = 1; break; |
| 1035 | case 'b': g.perm.Attach = 1; break; |
| 1036 | case 'x': g.perm.Private = 1; break; |
| 1037 | |
| 1038 | /* The "u" privileges is a little different. It recursively |
| 1039 | ** inherits all privileges of the user named "reader" */ |
| 1040 | case 'u': { |
| 1041 | if( (flags & LOGIN_IGNORE_UV)==0 ){ |
| 1042 | const char *zUser; |
| 1043 | zUser = db_text("", "SELECT cap FROM user WHERE login='reader'"); |
| @@ -1044,11 +1048,11 @@ | |
| 1044 | login_set_capabilities(zUser, flags | LOGIN_IGNORE_UV); |
| 1045 | } |
| 1046 | break; |
| 1047 | } |
| 1048 | |
| 1049 | /* The "v" privileges is a little different. It recursively |
| 1050 | ** inherits all privileges of the user named "developer" */ |
| 1051 | case 'v': { |
| 1052 | if( (flags & LOGIN_IGNORE_UV)==0 ){ |
| 1053 | const char *zDev; |
| 1054 | zDev = db_text("", "SELECT cap FROM user WHERE login='developer'"); |
| @@ -1359,11 +1363,11 @@ | |
| 1359 | if( zPrefix==0 ) zPrefix = ""; |
| 1360 | if( zSuffix==0 ) zSuffix = ""; |
| 1361 | if( pzErrorMsg ) *pzErrorMsg = 0; |
| 1362 | zSelfCode = abbreviated_project_code(db_get("project-code", "x")); |
| 1363 | blob_zero(&err); |
| 1364 | db_prepare(&q, |
| 1365 | "SELECT name, value FROM config" |
| 1366 | " WHERE name GLOB 'peer-repo-*'" |
| 1367 | " AND name <> 'peer-repo-%q'" |
| 1368 | " ORDER BY +value", |
| 1369 | zSelfCode |
| @@ -1441,11 +1445,11 @@ | |
| 1441 | const char *zSelf; /* The ATTACH name of our repository */ |
| 1442 | |
| 1443 | *pzErrMsg = 0; /* Default to no errors */ |
| 1444 | zSelf = db_name("repository"); |
| 1445 | |
| 1446 | /* Get the full pathname of the other repository */ |
| 1447 | file_canonical_name(zRepo, &fullName, 0); |
| 1448 | zRepo = mprintf(blob_str(&fullName)); |
| 1449 | blob_reset(&fullName); |
| 1450 | |
| 1451 | /* Get the full pathname for our repository. Also the project code |
| 1452 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -41,11 +41,11 @@ | |
| 41 | ** logs and downloading diffs of very version of the archive that |
| 42 | ** has ever existed, and things like that. |
| 43 | */ |
| 44 | #include "config.h" |
| 45 | #include "login.h" |
| 46 | #if defined(_WIN32) |
| 47 | # include <windows.h> /* for Sleep */ |
| 48 | # if defined(__MINGW32__) || defined(_MSC_VER) |
| 49 | # define sleep Sleep /* windows does not have sleep, but Sleep */ |
| 50 | # endif |
| 51 | #endif |
| @@ -112,13 +112,13 @@ | |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /* |
| 116 | ** The IP address of the client is stored as part of login cookies. |
| 117 | ** But some clients are behind firewalls that shift the IP address |
| 118 | ** with each HTTP request. To allow such (broken) clients to log in, |
| 119 | ** extract just a prefix of the IP address. |
| 120 | */ |
| 121 | static char *ipPrefix(const char *zIP){ |
| 122 | int i, j; |
| 123 | static int ip_prefix_terms = -1; |
| 124 | if( ip_prefix_terms<0 ){ |
| @@ -344,11 +344,11 @@ | |
| 344 | */ |
| 345 | void login_clear_login_data(){ |
| 346 | if(!g.userUid){ |
| 347 | return; |
| 348 | }else{ |
| 349 | char const * cookie = login_cookie_name(); |
| 350 | /* To logout, change the cookie value to an empty string */ |
| 351 | cgi_set_cookie(cookie, "", |
| 352 | login_cookie_path(), -86400); |
| 353 | db_multi_exec("UPDATE user SET cookie=NULL, ipaddr=NULL, " |
| 354 | " cexpire=0 WHERE uid=%d" |
| @@ -472,10 +472,11 @@ | |
| 472 | int anonFlag; |
| 473 | char *zErrMsg = ""; |
| 474 | int uid; /* User id logged in user */ |
| 475 | char *zSha1Pw; |
| 476 | const char *zIpAddr; /* IP address of requestor */ |
| 477 | const char *zReferer; |
| 478 | |
| 479 | login_check_credentials(); |
| 480 | sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0, |
| 481 | constant_time_cmp_function, 0, 0); |
| 482 | zUsername = P("u"); |
| @@ -491,21 +492,21 @@ | |
| 492 | /* The user requests a password change */ |
| 493 | zSha1Pw = sha1_shared_secret(zPasswd, g.zLogin, 0); |
| 494 | if( db_int(1, "SELECT 0 FROM user" |
| 495 | " WHERE uid=%d" |
| 496 | " AND (constant_time_cmp(pw,%Q)=0" |
| 497 | " OR constant_time_cmp(pw,%Q)=0)", |
| 498 | g.userUid, zSha1Pw, zPasswd) ){ |
| 499 | sleep(1); |
| 500 | zErrMsg = |
| 501 | @ <p><span class="loginError"> |
| 502 | @ You entered an incorrect old password while attempting to change |
| 503 | @ your password. Your password is unchanged. |
| 504 | @ </span></p> |
| 505 | ; |
| 506 | }else if( fossil_strcmp(zNew1,zNew2)!=0 ){ |
| 507 | zErrMsg = |
| 508 | @ <p><span class="loginError"> |
| 509 | @ The two copies of your new passwords do not match. |
| 510 | @ Your password is unchanged. |
| 511 | @ </span></p> |
| 512 | ; |
| @@ -532,10 +533,11 @@ | |
| 533 | return; |
| 534 | } |
| 535 | } |
| 536 | } |
| 537 | zIpAddr = PD("REMOTE_ADDR","nil"); /* Complete IP address for logging */ |
| 538 | zReferer = P("HTTP_REFERER"); |
| 539 | uid = login_is_valid_anonymous(zUsername, zPasswd, P("cs")); |
| 540 | if( uid>0 ){ |
| 541 | login_set_anon_cookie(zIpAddr, NULL); |
| 542 | record_login_attempt("anonymous", zIpAddr, 1); |
| 543 | redirect_to_g(); |
| @@ -544,11 +546,11 @@ | |
| 546 | /* Attempting to log in as a user other than anonymous. |
| 547 | */ |
| 548 | uid = login_search_uid(zUsername, zPasswd); |
| 549 | if( uid<=0 ){ |
| 550 | sleep(1); |
| 551 | zErrMsg = |
| 552 | @ <p><span class="loginError"> |
| 553 | @ You entered an unknown user or an incorrect password. |
| 554 | @ </span></p> |
| 555 | ; |
| 556 | record_login_attempt(zUsername, zIpAddr, 0); |
| @@ -570,10 +572,12 @@ | |
| 572 | @ <p>A login is required for <a href="%h(zGoto)">%h(zGoto)</a>.</p> |
| 573 | } |
| 574 | form_begin(0, "%R/login"); |
| 575 | if( zGoto ){ |
| 576 | @ <input type="hidden" name="g" value="%h(zGoto)" /> |
| 577 | }else if( zReferer && strncmp(g.zBaseURL, zReferer, strlen(g.zBaseURL))==0 ){ |
| 578 | @ <input type="hidden" name="g" value="%h(zReferer)" /> |
| 579 | } |
| 580 | @ <table class="login_out"> |
| 581 | @ <tr> |
| 582 | @ <td class="login_out_label">User ID:</td> |
| 583 | if( anonFlag ){ |
| @@ -595,11 +599,11 @@ | |
| 599 | @ <td></td> |
| 600 | @ <td><input type="submit" name="in" value="Login" |
| 601 | @ onClick="chngAction(this.form)" /></td> |
| 602 | @ </tr> |
| 603 | @ </table> |
| 604 | @ <script> |
| 605 | @ gebi('u').focus() |
| 606 | @ function chngAction(form){ |
| 607 | if( g.sslNotAvailable==0 |
| 608 | && strncmp(g.zBaseURL,"https:",6)!=0 |
| 609 | && db_get_boolean("https-login",0) |
| @@ -620,11 +624,11 @@ | |
| 624 | @ your user-id and password at the left and press the |
| 625 | @ "Login" button. Your user name will be stored in a browser cookie. |
| 626 | @ You must configure your web browser to accept cookies in order for |
| 627 | @ the login to take.</p> |
| 628 | if( db_get_boolean("self-register", 0) ){ |
| 629 | @ <p>If you do not have an account, you can |
| 630 | @ <a href="%s(g.zTop)/register?g=%T(P("G"))">create one</a>. |
| 631 | } |
| 632 | if( zAnonPw ){ |
| 633 | unsigned int uSeed = captcha_seed(); |
| 634 | char const *zDecoded = captcha_decode(uSeed); |
| @@ -672,11 +676,11 @@ | |
| 676 | style_footer(); |
| 677 | } |
| 678 | |
| 679 | /* |
| 680 | ** Attempt to find login credentials for user zLogin on a peer repository |
| 681 | ** with project code zCode. Transfer those credentials to the local |
| 682 | ** repository. |
| 683 | ** |
| 684 | ** Return true if a transfer was made and false if not. |
| 685 | */ |
| 686 | static int login_transfer_credentials( |
| @@ -690,11 +694,11 @@ | |
| 694 | char *zSQL; /* SQL of the query against other repo */ |
| 695 | char *zOtherRepo; /* Filename of the other repository */ |
| 696 | int rc; /* Result code from SQLite library functions */ |
| 697 | int nXfer = 0; /* Number of credentials transferred */ |
| 698 | |
| 699 | zOtherRepo = db_text(0, |
| 700 | "SELECT value FROM config WHERE name='peer-repo-%q'", |
| 701 | zCode |
| 702 | ); |
| 703 | if( zOtherRepo==0 ) return 0; /* No such peer repository */ |
| 704 | |
| @@ -752,11 +756,11 @@ | |
| 756 | int uid; |
| 757 | if( fossil_strcmp(zLogin, "anonymous")==0 ) return 0; |
| 758 | if( fossil_strcmp(zLogin, "nobody")==0 ) return 0; |
| 759 | if( fossil_strcmp(zLogin, "developer")==0 ) return 0; |
| 760 | if( fossil_strcmp(zLogin, "reader")==0 ) return 0; |
| 761 | uid = db_int(0, |
| 762 | "SELECT uid FROM user" |
| 763 | " WHERE login=%Q" |
| 764 | " AND ipaddr=%Q" |
| 765 | " AND cexpire>julianday('now')" |
| 766 | " AND length(cap)>0" |
| @@ -792,11 +796,11 @@ | |
| 796 | |
| 797 | sqlite3_create_function(g.db, "constant_time_cmp", 2, SQLITE_UTF8, 0, |
| 798 | constant_time_cmp_function, 0, 0); |
| 799 | |
| 800 | /* If the HTTP connection is coming over 127.0.0.1 and if |
| 801 | ** local login is disabled and if we are using HTTP and not HTTPS, |
| 802 | ** then there is no need to check user credentials. |
| 803 | ** |
| 804 | ** This feature allows the "fossil ui" command to give the user |
| 805 | ** full access rights without having to log in. |
| 806 | */ |
| @@ -847,15 +851,15 @@ | |
| 851 | ** SECRET is the "captcha-secret" value in the repository. |
| 852 | */ |
| 853 | double rTime = atof(zArg); |
| 854 | Blob b; |
| 855 | blob_zero(&b); |
| 856 | blob_appendf(&b, "%s/%s/%s", |
| 857 | zArg, zRemoteAddr, db_get("captcha-secret","")); |
| 858 | sha1sum_blob(&b, &b); |
| 859 | if( fossil_strcmp(zHash, blob_str(&b))==0 ){ |
| 860 | uid = db_int(0, |
| 861 | "SELECT uid FROM user WHERE login='anonymous'" |
| 862 | " AND length(cap)>0" |
| 863 | " AND length(pw)>0" |
| 864 | " AND %.17g+0.25>julianday('now')", |
| 865 | rTime |
| @@ -1002,11 +1006,11 @@ | |
| 1006 | for(i=0; zCap[i]; i++){ |
| 1007 | switch( zCap[i] ){ |
| 1008 | case 's': g.perm.Setup = 1; /* Fall thru into Admin */ |
| 1009 | case 'a': g.perm.Admin = g.perm.RdTkt = g.perm.WrTkt = g.perm.Zip = |
| 1010 | g.perm.RdWiki = g.perm.WrWiki = g.perm.NewWiki = |
| 1011 | g.perm.ApndWiki = g.perm.Hyperlink = g.perm.Clone = |
| 1012 | g.perm.NewTkt = g.perm.Password = g.perm.RdAddr = |
| 1013 | g.perm.TktFmt = g.perm.Attach = g.perm.ApndTkt = |
| 1014 | g.perm.ModWiki = g.perm.ModTkt = 1; |
| 1015 | /* Fall thru into Read/Write */ |
| 1016 | case 'i': g.perm.Read = g.perm.Write = 1; break; |
| @@ -1025,19 +1029,19 @@ | |
| 1029 | case 'l': g.perm.ModWiki = 1; break; |
| 1030 | |
| 1031 | case 'e': g.perm.RdAddr = 1; break; |
| 1032 | case 'r': g.perm.RdTkt = 1; break; |
| 1033 | case 'n': g.perm.NewTkt = 1; break; |
| 1034 | case 'w': g.perm.WrTkt = g.perm.RdTkt = g.perm.NewTkt = |
| 1035 | g.perm.ApndTkt = 1; break; |
| 1036 | case 'c': g.perm.ApndTkt = 1; break; |
| 1037 | case 'q': g.perm.ModTkt = 1; break; |
| 1038 | case 't': g.perm.TktFmt = 1; break; |
| 1039 | case 'b': g.perm.Attach = 1; break; |
| 1040 | case 'x': g.perm.Private = 1; break; |
| 1041 | |
| 1042 | /* The "u" privileges is a little different. It recursively |
| 1043 | ** inherits all privileges of the user named "reader" */ |
| 1044 | case 'u': { |
| 1045 | if( (flags & LOGIN_IGNORE_UV)==0 ){ |
| 1046 | const char *zUser; |
| 1047 | zUser = db_text("", "SELECT cap FROM user WHERE login='reader'"); |
| @@ -1044,11 +1048,11 @@ | |
| 1048 | login_set_capabilities(zUser, flags | LOGIN_IGNORE_UV); |
| 1049 | } |
| 1050 | break; |
| 1051 | } |
| 1052 | |
| 1053 | /* The "v" privileges is a little different. It recursively |
| 1054 | ** inherits all privileges of the user named "developer" */ |
| 1055 | case 'v': { |
| 1056 | if( (flags & LOGIN_IGNORE_UV)==0 ){ |
| 1057 | const char *zDev; |
| 1058 | zDev = db_text("", "SELECT cap FROM user WHERE login='developer'"); |
| @@ -1359,11 +1363,11 @@ | |
| 1363 | if( zPrefix==0 ) zPrefix = ""; |
| 1364 | if( zSuffix==0 ) zSuffix = ""; |
| 1365 | if( pzErrorMsg ) *pzErrorMsg = 0; |
| 1366 | zSelfCode = abbreviated_project_code(db_get("project-code", "x")); |
| 1367 | blob_zero(&err); |
| 1368 | db_prepare(&q, |
| 1369 | "SELECT name, value FROM config" |
| 1370 | " WHERE name GLOB 'peer-repo-*'" |
| 1371 | " AND name <> 'peer-repo-%q'" |
| 1372 | " ORDER BY +value", |
| 1373 | zSelfCode |
| @@ -1441,11 +1445,11 @@ | |
| 1445 | const char *zSelf; /* The ATTACH name of our repository */ |
| 1446 | |
| 1447 | *pzErrMsg = 0; /* Default to no errors */ |
| 1448 | zSelf = db_name("repository"); |
| 1449 | |
| 1450 | /* Get the full pathname of the other repository */ |
| 1451 | file_canonical_name(zRepo, &fullName, 0); |
| 1452 | zRepo = mprintf(blob_str(&fullName)); |
| 1453 | blob_reset(&fullName); |
| 1454 | |
| 1455 | /* Get the full pathname for our repository. Also the project code |
| 1456 |
+4
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -189,11 +189,13 @@ | ||
| 189 | 189 | char *urlPasswd; /* Password for http: */ |
| 190 | 190 | char *urlCanonical; /* Canonical representation of the URL */ |
| 191 | 191 | char *urlProxyAuth; /* Proxy-Authorizer: string */ |
| 192 | 192 | char *urlFossil; /* The fossil query parameter on ssh: */ |
| 193 | 193 | unsigned urlFlags; /* Boolean flags controlling URL processing */ |
| 194 | - | |
| 194 | + int useProxy; /* Used to remember that a proxy is in use */ | |
| 195 | + char *proxyUrlPath; | |
| 196 | + int proxyOrigPort; /* Tunneled port number for https through proxy */ | |
| 195 | 197 | const char *zLogin; /* Login name. "" if not logged in. */ |
| 196 | 198 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 197 | 199 | ** SSL client identity */ |
| 198 | 200 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| 199 | 201 | int noPswd; /* Logged in without password (on 127.0.0.1) */ |
| @@ -600,11 +602,11 @@ | ||
| 600 | 602 | #endif |
| 601 | 603 | g.mainTimerId = fossil_timer_start(); |
| 602 | 604 | g.zVfsName = find_option("vfs",0,1); |
| 603 | 605 | if( g.zVfsName==0 ){ |
| 604 | 606 | g.zVfsName = fossil_getenv("FOSSIL_VFS"); |
| 605 | -#if defined(_WIN32) || defined(__CYGWIN__) | |
| 607 | +#if defined(__CYGWIN__) | |
| 606 | 608 | if( g.zVfsName==0 ){ |
| 607 | 609 | g.zVfsName = "win32-longpath"; |
| 608 | 610 | } |
| 609 | 611 | #endif |
| 610 | 612 | } |
| 611 | 613 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -189,11 +189,13 @@ | |
| 189 | char *urlPasswd; /* Password for http: */ |
| 190 | char *urlCanonical; /* Canonical representation of the URL */ |
| 191 | char *urlProxyAuth; /* Proxy-Authorizer: string */ |
| 192 | char *urlFossil; /* The fossil query parameter on ssh: */ |
| 193 | unsigned urlFlags; /* Boolean flags controlling URL processing */ |
| 194 | |
| 195 | const char *zLogin; /* Login name. "" if not logged in. */ |
| 196 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 197 | ** SSL client identity */ |
| 198 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| 199 | int noPswd; /* Logged in without password (on 127.0.0.1) */ |
| @@ -600,11 +602,11 @@ | |
| 600 | #endif |
| 601 | g.mainTimerId = fossil_timer_start(); |
| 602 | g.zVfsName = find_option("vfs",0,1); |
| 603 | if( g.zVfsName==0 ){ |
| 604 | g.zVfsName = fossil_getenv("FOSSIL_VFS"); |
| 605 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 606 | if( g.zVfsName==0 ){ |
| 607 | g.zVfsName = "win32-longpath"; |
| 608 | } |
| 609 | #endif |
| 610 | } |
| 611 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -189,11 +189,13 @@ | |
| 189 | char *urlPasswd; /* Password for http: */ |
| 190 | char *urlCanonical; /* Canonical representation of the URL */ |
| 191 | char *urlProxyAuth; /* Proxy-Authorizer: string */ |
| 192 | char *urlFossil; /* The fossil query parameter on ssh: */ |
| 193 | unsigned urlFlags; /* Boolean flags controlling URL processing */ |
| 194 | int useProxy; /* Used to remember that a proxy is in use */ |
| 195 | char *proxyUrlPath; |
| 196 | int proxyOrigPort; /* Tunneled port number for https through proxy */ |
| 197 | const char *zLogin; /* Login name. "" if not logged in. */ |
| 198 | const char *zSSLIdentity; /* Value of --ssl-identity option, filename of |
| 199 | ** SSL client identity */ |
| 200 | int useLocalauth; /* No login required if from 127.0.0.1 */ |
| 201 | int noPswd; /* Logged in without password (on 127.0.0.1) */ |
| @@ -600,11 +602,11 @@ | |
| 602 | #endif |
| 603 | g.mainTimerId = fossil_timer_start(); |
| 604 | g.zVfsName = find_option("vfs",0,1); |
| 605 | if( g.zVfsName==0 ){ |
| 606 | g.zVfsName = fossil_getenv("FOSSIL_VFS"); |
| 607 | #if defined(__CYGWIN__) |
| 608 | if( g.zVfsName==0 ){ |
| 609 | g.zVfsName = "win32-longpath"; |
| 610 | } |
| 611 | #endif |
| 612 | } |
| 613 |
+25
-25
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -51,11 +51,11 @@ | ||
| 51 | 51 | #define MC_PERMIT_HOOKS 1 /* permit hooks to execute */ |
| 52 | 52 | |
| 53 | 53 | /* |
| 54 | 54 | ** A single F-card within a manifest |
| 55 | 55 | */ |
| 56 | -struct ManifestFile { | |
| 56 | +struct ManifestFile { | |
| 57 | 57 | char *zName; /* Name of a file */ |
| 58 | 58 | char *zUuid; /* UUID of the file */ |
| 59 | 59 | char *zPerm; /* File permissions */ |
| 60 | 60 | char *zPrior; /* Prior name if the name was changed */ |
| 61 | 61 | }; |
| @@ -89,11 +89,11 @@ | ||
| 89 | 89 | ManifestFile *aFile; /* One entry for each F-card */ |
| 90 | 90 | int nParent; /* Number of parents. */ |
| 91 | 91 | int nParentAlloc; /* Slots allocated in azParent[] */ |
| 92 | 92 | char **azParent; /* UUIDs of parents. One for each P card argument */ |
| 93 | 93 | int nCherrypick; /* Number of entries in aCherrypick[] */ |
| 94 | - struct { | |
| 94 | + struct { | |
| 95 | 95 | char *zCPTarget; /* UUID of cherry-picked version w/ +|- prefix */ |
| 96 | 96 | char *zCPBase; /* UUID of cherry-pick baseline. NULL for singletons */ |
| 97 | 97 | } *aCherrypick; |
| 98 | 98 | int nCChild; /* Number of cluster children */ |
| 99 | 99 | int nCChildAlloc; /* Number of closts allocated in azCChild[] */ |
| @@ -105,11 +105,11 @@ | ||
| 105 | 105 | char *zUuid; /* UUID that the tag is applied to */ |
| 106 | 106 | char *zValue; /* Value if the tag is really a property */ |
| 107 | 107 | } *aTag; /* One for each T card */ |
| 108 | 108 | int nField; /* Number of J cards */ |
| 109 | 109 | int nFieldAlloc; /* Slots allocated in aField[] */ |
| 110 | - struct { | |
| 110 | + struct { | |
| 111 | 111 | char *zName; /* Key or field name */ |
| 112 | 112 | char *zValue; /* Value of the field */ |
| 113 | 113 | } *aField; /* One for each J card */ |
| 114 | 114 | }; |
| 115 | 115 | #endif |
| @@ -251,11 +251,11 @@ | ||
| 251 | 251 | ** Verify the Z-card checksum on the artifact, if there is such a |
| 252 | 252 | ** checksum. Return 0 if there is no Z-card. Return 1 if the Z-card |
| 253 | 253 | ** exists and is correct. Return 2 if the Z-card exists and has the wrong |
| 254 | 254 | ** value. |
| 255 | 255 | ** |
| 256 | -** 0123456789 123456789 123456789 123456789 | |
| 256 | +** 0123456789 123456789 123456789 123456789 | |
| 257 | 257 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 258 | 258 | */ |
| 259 | 259 | static int verify_z_card(const char *z, int n){ |
| 260 | 260 | if( n<35 ) return 0; |
| 261 | 261 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| @@ -435,11 +435,11 @@ | ||
| 435 | 435 | char *zName, *zTarget, *zSrc; |
| 436 | 436 | int nTarget = 0, nSrc = 0; |
| 437 | 437 | zName = next_token(&x, 0); |
| 438 | 438 | zTarget = next_token(&x, &nTarget); |
| 439 | 439 | zSrc = next_token(&x, &nSrc); |
| 440 | - if( zName==0 || zTarget==0 ) goto manifest_syntax_error; | |
| 440 | + if( zName==0 || zTarget==0 ) goto manifest_syntax_error; | |
| 441 | 441 | if( p->zAttachName!=0 ) goto manifest_syntax_error; |
| 442 | 442 | defossilize(zName); |
| 443 | 443 | if( !file_is_simple_pathname(zName, 0) ){ |
| 444 | 444 | SYNTAX("invalid filename on A-card"); |
| 445 | 445 | } |
| @@ -504,11 +504,11 @@ | ||
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /* |
| 507 | 507 | ** E <timestamp> <uuid> |
| 508 | 508 | ** |
| 509 | - ** An "event" card that contains the timestamp of the event in the | |
| 509 | + ** An "event" card that contains the timestamp of the event in the | |
| 510 | 510 | ** format YYYY-MM-DDtHH:MM:SS and a unique identifier for the event. |
| 511 | 511 | ** The event timestamp is distinct from the D timestamp. The D |
| 512 | 512 | ** timestamp is when the artifact was created whereas the E timestamp |
| 513 | 513 | ** is when the specific event is said to occur. |
| 514 | 514 | */ |
| @@ -551,11 +551,11 @@ | ||
| 551 | 551 | SYNTAX("F-card old filename is not a simple path"); |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | if( p->nFile>=p->nFileAlloc ){ |
| 555 | 555 | p->nFileAlloc = p->nFileAlloc*2 + 10; |
| 556 | - p->aFile = fossil_realloc(p->aFile, | |
| 556 | + p->aFile = fossil_realloc(p->aFile, | |
| 557 | 557 | p->nFileAlloc*sizeof(p->aFile[0]) ); |
| 558 | 558 | } |
| 559 | 559 | i = p->nFile++; |
| 560 | 560 | p->aFile[i].zName = zName; |
| 561 | 561 | p->aFile[i].zUuid = zUuid; |
| @@ -743,11 +743,11 @@ | ||
| 743 | 743 | ** singleton tag, "*" to create a propagating tag, or "-" to create |
| 744 | 744 | ** anti-tag that undoes a prior "+" or blocks propagation of of |
| 745 | 745 | ** a "*". |
| 746 | 746 | ** |
| 747 | 747 | ** The tag is applied to <uuid>. If <uuid> is "*" then the tag is |
| 748 | - ** applied to the current manifest. If <value> is provided then | |
| 748 | + ** applied to the current manifest. If <value> is provided then | |
| 749 | 749 | ** the tag is really a property with the given value. |
| 750 | 750 | ** |
| 751 | 751 | ** Tags are not allowed in clusters. Multiple T lines are allowed. |
| 752 | 752 | */ |
| 753 | 753 | case 'T': { |
| @@ -1050,11 +1050,11 @@ | ||
| 1050 | 1050 | db_multi_exec( |
| 1051 | 1051 | "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)", |
| 1052 | 1052 | p->rid, rid |
| 1053 | 1053 | ); |
| 1054 | 1054 | return 1; |
| 1055 | - } | |
| 1055 | + } | |
| 1056 | 1056 | fossil_fatal("cannot access baseline manifest %S", p->zBaseline); |
| 1057 | 1057 | } |
| 1058 | 1058 | } |
| 1059 | 1059 | return 0; |
| 1060 | 1060 | } |
| @@ -1075,11 +1075,11 @@ | ||
| 1075 | 1075 | ** |
| 1076 | 1076 | ** Return NULL for end-of-records or if there is an error. If an error |
| 1077 | 1077 | ** occurs and pErr!=0 then store 1 in *pErr. |
| 1078 | 1078 | */ |
| 1079 | 1079 | ManifestFile *manifest_file_next( |
| 1080 | - Manifest *p, | |
| 1080 | + Manifest *p, | |
| 1081 | 1081 | int *pErr |
| 1082 | 1082 | ){ |
| 1083 | 1083 | ManifestFile *pOut = 0; |
| 1084 | 1084 | if( pErr ) *pErr = 0; |
| 1085 | 1085 | if( p->pBaseline==0 ){ |
| @@ -1219,11 +1219,11 @@ | ||
| 1219 | 1219 | content_deltify(pid, fid, 0); |
| 1220 | 1220 | } |
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | /* |
| 1224 | -** Do a binary search to find a file in the p->aFile[] array. | |
| 1224 | +** Do a binary search to find a file in the p->aFile[] array. | |
| 1225 | 1225 | ** |
| 1226 | 1226 | ** As an optimization, guess that the file we seek is at index p->iFile. |
| 1227 | 1227 | ** That will usually be the case. If it is not found there, then do the |
| 1228 | 1228 | ** actual binary search. |
| 1229 | 1229 | ** |
| @@ -1263,18 +1263,18 @@ | ||
| 1263 | 1263 | /* |
| 1264 | 1264 | ** Locate a file named zName in the aFile[] array of the given manifest. |
| 1265 | 1265 | ** Return a pointer to the appropriate ManifestFile object. Return NULL |
| 1266 | 1266 | ** if not found. |
| 1267 | 1267 | ** |
| 1268 | -** This routine works even if p is a delta-manifest. The pointer | |
| 1268 | +** This routine works even if p is a delta-manifest. The pointer | |
| 1269 | 1269 | ** returned might be to the baseline. |
| 1270 | 1270 | ** |
| 1271 | 1271 | ** We assume that filenames are in sorted order and use a binary search. |
| 1272 | 1272 | */ |
| 1273 | 1273 | ManifestFile *manifest_file_seek(Manifest *p, const char *zName){ |
| 1274 | 1274 | ManifestFile *pFile; |
| 1275 | - | |
| 1275 | + | |
| 1276 | 1276 | pFile = manifest_file_seek_base(p, zName); |
| 1277 | 1277 | if( pFile && pFile->zUuid==0 ) return 0; |
| 1278 | 1278 | if( pFile==0 && p->zBaseline ){ |
| 1279 | 1279 | fetch_baseline(p, 1); |
| 1280 | 1280 | pFile = manifest_file_seek_base(p->pBaseline, zName); |
| @@ -1362,15 +1362,15 @@ | ||
| 1362 | 1362 | return; |
| 1363 | 1363 | } |
| 1364 | 1364 | isPublic = !content_is_private(cid); |
| 1365 | 1365 | |
| 1366 | 1366 | /* Try to make the parent manifest a delta from the child, if that |
| 1367 | - ** is an appropriate thing to do. For a new baseline, make the | |
| 1367 | + ** is an appropriate thing to do. For a new baseline, make the | |
| 1368 | 1368 | ** previous baseline a delta from the current baseline. |
| 1369 | 1369 | */ |
| 1370 | 1370 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1371 | - content_deltify(pid, cid, 0); | |
| 1371 | + content_deltify(pid, cid, 0); | |
| 1372 | 1372 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1373 | 1373 | content_deltify(pParent->pBaseline->rid, cid, 0); |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | /* Remember all children less than a few seconds younger than their parent, |
| @@ -1385,11 +1385,11 @@ | ||
| 1385 | 1385 | ); |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | /* First look at all files in pChild, ignoring its baseline. This |
| 1389 | 1389 | ** is where most of the changes will be found. |
| 1390 | - */ | |
| 1390 | + */ | |
| 1391 | 1391 | for(i=0, pChildFile=pChild->aFile; i<pChild->nFile; i++, pChildFile++){ |
| 1392 | 1392 | int mperm = manifest_file_mperm(pChildFile); |
| 1393 | 1393 | if( pChildFile->zPrior ){ |
| 1394 | 1394 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior); |
| 1395 | 1395 | if( pParentFile ){ |
| @@ -1450,11 +1450,11 @@ | ||
| 1450 | 1450 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1451 | 1451 | manifest_file_rewind(pParent); |
| 1452 | 1452 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1453 | 1453 | pChildFile = manifest_file_seek(pChild, pParentFile->zName); |
| 1454 | 1454 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1455 | - add_one_mlink(cid, pParentFile->zUuid, 0, pParentFile->zName, 0, | |
| 1455 | + add_one_mlink(cid, pParentFile->zUuid, 0, pParentFile->zName, 0, | |
| 1456 | 1456 | isPublic, 0); |
| 1457 | 1457 | } |
| 1458 | 1458 | } |
| 1459 | 1459 | } |
| 1460 | 1460 | manifest_cache_insert(*ppOther); |
| @@ -1578,11 +1578,11 @@ | ||
| 1578 | 1578 | if( once ){ |
| 1579 | 1579 | once = 0; |
| 1580 | 1580 | zTitleExpr = db_get("ticket-title-expr", "title"); |
| 1581 | 1581 | zStatusColumn = db_get("ticket-status-column", "status"); |
| 1582 | 1582 | } |
| 1583 | - zTitle = db_text("unknown", | |
| 1583 | + zTitle = db_text("unknown", | |
| 1584 | 1584 | "SELECT %s FROM ticket WHERE tkt_uuid='%s'", |
| 1585 | 1585 | zTitleExpr, pManifest->zTicketUuid |
| 1586 | 1586 | ); |
| 1587 | 1587 | if( !isNew ){ |
| 1588 | 1588 | for(i=0; i<pManifest->nField; i++){ |
| @@ -1599,11 +1599,11 @@ | ||
| 1599 | 1599 | pManifest->nField-1, pManifest->nField==2 ? "" : "s"); |
| 1600 | 1600 | } |
| 1601 | 1601 | blob_appendf(&brief, "%h ticket [%.10s].", |
| 1602 | 1602 | zNewStatus, pManifest->zTicketUuid); |
| 1603 | 1603 | }else{ |
| 1604 | - zNewStatus = db_text("unknown", | |
| 1604 | + zNewStatus = db_text("unknown", | |
| 1605 | 1605 | "SELECT %s FROM ticket WHERE tkt_uuid='%s'", |
| 1606 | 1606 | zStatusColumn, pManifest->zTicketUuid |
| 1607 | 1607 | ); |
| 1608 | 1608 | blob_appendf(&comment, "Ticket [%.10s] <i>%h</i> status still %h with " |
| 1609 | 1609 | "%d other change%s", |
| @@ -1661,11 +1661,11 @@ | ||
| 1661 | 1661 | ** |
| 1662 | 1662 | ** If the input is a control artifact, then make appropriate entries |
| 1663 | 1663 | ** in the auxiliary tables of the database in order to crosslink the |
| 1664 | 1664 | ** artifact. |
| 1665 | 1665 | ** |
| 1666 | -** If global variable g.xlinkClusterOnly is true, then ignore all | |
| 1666 | +** If global variable g.xlinkClusterOnly is true, then ignore all | |
| 1667 | 1667 | ** control artifacts other than clusters. |
| 1668 | 1668 | ** |
| 1669 | 1669 | ** This routine always resets the pContent blob before returning. |
| 1670 | 1670 | ** |
| 1671 | 1671 | ** Historical note: This routine original processed manifests only. |
| @@ -1744,11 +1744,11 @@ | ||
| 1744 | 1744 | " %d,%Q,%Q," |
| 1745 | 1745 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>0)," |
| 1746 | 1746 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)," |
| 1747 | 1747 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),%.17g);", |
| 1748 | 1748 | TAG_DATE, rid, p->rDate, |
| 1749 | - rid, p->zUser, p->zComment, | |
| 1749 | + rid, p->zUser, p->zComment, | |
| 1750 | 1750 | TAG_BGCOLOR, rid, |
| 1751 | 1751 | TAG_USER, rid, |
| 1752 | 1752 | TAG_COMMENT, rid, p->rDate |
| 1753 | 1753 | ); |
| 1754 | 1754 | zCom = db_text(0, "SELECT coalesce(ecomment, comment) FROM event" |
| @@ -1802,11 +1802,11 @@ | ||
| 1802 | 1802 | case '*': type = 2; break; /* Propagate to descendants */ |
| 1803 | 1803 | default: |
| 1804 | 1804 | fossil_error(1, "unknown tag type in manifest: %s", p->aTag); |
| 1805 | 1805 | return 0; |
| 1806 | 1806 | } |
| 1807 | - tag_insert(&p->aTag[i].zName[1], type, p->aTag[i].zValue, | |
| 1807 | + tag_insert(&p->aTag[i].zName[1], type, p->aTag[i].zValue, | |
| 1808 | 1808 | rid, p->rDate, tid); |
| 1809 | 1809 | } |
| 1810 | 1810 | } |
| 1811 | 1811 | if( parentid ){ |
| 1812 | 1812 | tag_propagate_all(parentid); |
| @@ -1843,11 +1843,11 @@ | ||
| 1843 | 1843 | " bgcolor,euser,ecomment)" |
| 1844 | 1844 | "VALUES('w',%.17g,%d,%Q,%Q," |
| 1845 | 1845 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1)," |
| 1846 | 1846 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)," |
| 1847 | 1847 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));", |
| 1848 | - p->rDate, rid, p->zUser, zComment, | |
| 1848 | + p->rDate, rid, p->zUser, zComment, | |
| 1849 | 1849 | TAG_BGCOLOR, rid, |
| 1850 | 1850 | TAG_BGCOLOR, rid, |
| 1851 | 1851 | TAG_USER, rid, |
| 1852 | 1852 | TAG_COMMENT, rid |
| 1853 | 1853 | ); |
| @@ -1893,11 +1893,11 @@ | ||
| 1893 | 1893 | }else{ |
| 1894 | 1894 | db_multi_exec( |
| 1895 | 1895 | "REPLACE INTO event(type,mtime,objid,tagid,user,comment,bgcolor)" |
| 1896 | 1896 | "VALUES('e',%.17g,%d,%d,%Q,%Q," |
| 1897 | 1897 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));", |
| 1898 | - p->rEventDate, rid, tagid, p->zUser, p->zComment, | |
| 1898 | + p->rEventDate, rid, tagid, p->zUser, p->zComment, | |
| 1899 | 1899 | TAG_BGCOLOR, rid |
| 1900 | 1900 | ); |
| 1901 | 1901 | } |
| 1902 | 1902 | } |
| 1903 | 1903 | if( p->type==CFTYPE_TICKET ){ |
| @@ -1925,11 +1925,11 @@ | ||
| 1925 | 1925 | " WHERE target=%Q AND filename=%Q", |
| 1926 | 1926 | p->zAttachTarget, p->zAttachName, |
| 1927 | 1927 | p->zAttachTarget, p->zAttachName |
| 1928 | 1928 | ); |
| 1929 | 1929 | if( strlen(p->zAttachTarget)!=UUID_SIZE |
| 1930 | - || !validate16(p->zAttachTarget, UUID_SIZE) | |
| 1930 | + || !validate16(p->zAttachTarget, UUID_SIZE) | |
| 1931 | 1931 | ){ |
| 1932 | 1932 | char *zComment; |
| 1933 | 1933 | if( p->zAttachSrc && p->zAttachSrc[0] ){ |
| 1934 | 1934 | zComment = mprintf( |
| 1935 | 1935 | "Add attachment [/artifact/%S|%h] to wiki page [%h]", |
| 1936 | 1936 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -51,11 +51,11 @@ | |
| 51 | #define MC_PERMIT_HOOKS 1 /* permit hooks to execute */ |
| 52 | |
| 53 | /* |
| 54 | ** A single F-card within a manifest |
| 55 | */ |
| 56 | struct ManifestFile { |
| 57 | char *zName; /* Name of a file */ |
| 58 | char *zUuid; /* UUID of the file */ |
| 59 | char *zPerm; /* File permissions */ |
| 60 | char *zPrior; /* Prior name if the name was changed */ |
| 61 | }; |
| @@ -89,11 +89,11 @@ | |
| 89 | ManifestFile *aFile; /* One entry for each F-card */ |
| 90 | int nParent; /* Number of parents. */ |
| 91 | int nParentAlloc; /* Slots allocated in azParent[] */ |
| 92 | char **azParent; /* UUIDs of parents. One for each P card argument */ |
| 93 | int nCherrypick; /* Number of entries in aCherrypick[] */ |
| 94 | struct { |
| 95 | char *zCPTarget; /* UUID of cherry-picked version w/ +|- prefix */ |
| 96 | char *zCPBase; /* UUID of cherry-pick baseline. NULL for singletons */ |
| 97 | } *aCherrypick; |
| 98 | int nCChild; /* Number of cluster children */ |
| 99 | int nCChildAlloc; /* Number of closts allocated in azCChild[] */ |
| @@ -105,11 +105,11 @@ | |
| 105 | char *zUuid; /* UUID that the tag is applied to */ |
| 106 | char *zValue; /* Value if the tag is really a property */ |
| 107 | } *aTag; /* One for each T card */ |
| 108 | int nField; /* Number of J cards */ |
| 109 | int nFieldAlloc; /* Slots allocated in aField[] */ |
| 110 | struct { |
| 111 | char *zName; /* Key or field name */ |
| 112 | char *zValue; /* Value of the field */ |
| 113 | } *aField; /* One for each J card */ |
| 114 | }; |
| 115 | #endif |
| @@ -251,11 +251,11 @@ | |
| 251 | ** Verify the Z-card checksum on the artifact, if there is such a |
| 252 | ** checksum. Return 0 if there is no Z-card. Return 1 if the Z-card |
| 253 | ** exists and is correct. Return 2 if the Z-card exists and has the wrong |
| 254 | ** value. |
| 255 | ** |
| 256 | ** 0123456789 123456789 123456789 123456789 |
| 257 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 258 | */ |
| 259 | static int verify_z_card(const char *z, int n){ |
| 260 | if( n<35 ) return 0; |
| 261 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| @@ -435,11 +435,11 @@ | |
| 435 | char *zName, *zTarget, *zSrc; |
| 436 | int nTarget = 0, nSrc = 0; |
| 437 | zName = next_token(&x, 0); |
| 438 | zTarget = next_token(&x, &nTarget); |
| 439 | zSrc = next_token(&x, &nSrc); |
| 440 | if( zName==0 || zTarget==0 ) goto manifest_syntax_error; |
| 441 | if( p->zAttachName!=0 ) goto manifest_syntax_error; |
| 442 | defossilize(zName); |
| 443 | if( !file_is_simple_pathname(zName, 0) ){ |
| 444 | SYNTAX("invalid filename on A-card"); |
| 445 | } |
| @@ -504,11 +504,11 @@ | |
| 504 | } |
| 505 | |
| 506 | /* |
| 507 | ** E <timestamp> <uuid> |
| 508 | ** |
| 509 | ** An "event" card that contains the timestamp of the event in the |
| 510 | ** format YYYY-MM-DDtHH:MM:SS and a unique identifier for the event. |
| 511 | ** The event timestamp is distinct from the D timestamp. The D |
| 512 | ** timestamp is when the artifact was created whereas the E timestamp |
| 513 | ** is when the specific event is said to occur. |
| 514 | */ |
| @@ -551,11 +551,11 @@ | |
| 551 | SYNTAX("F-card old filename is not a simple path"); |
| 552 | } |
| 553 | } |
| 554 | if( p->nFile>=p->nFileAlloc ){ |
| 555 | p->nFileAlloc = p->nFileAlloc*2 + 10; |
| 556 | p->aFile = fossil_realloc(p->aFile, |
| 557 | p->nFileAlloc*sizeof(p->aFile[0]) ); |
| 558 | } |
| 559 | i = p->nFile++; |
| 560 | p->aFile[i].zName = zName; |
| 561 | p->aFile[i].zUuid = zUuid; |
| @@ -743,11 +743,11 @@ | |
| 743 | ** singleton tag, "*" to create a propagating tag, or "-" to create |
| 744 | ** anti-tag that undoes a prior "+" or blocks propagation of of |
| 745 | ** a "*". |
| 746 | ** |
| 747 | ** The tag is applied to <uuid>. If <uuid> is "*" then the tag is |
| 748 | ** applied to the current manifest. If <value> is provided then |
| 749 | ** the tag is really a property with the given value. |
| 750 | ** |
| 751 | ** Tags are not allowed in clusters. Multiple T lines are allowed. |
| 752 | */ |
| 753 | case 'T': { |
| @@ -1050,11 +1050,11 @@ | |
| 1050 | db_multi_exec( |
| 1051 | "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)", |
| 1052 | p->rid, rid |
| 1053 | ); |
| 1054 | return 1; |
| 1055 | } |
| 1056 | fossil_fatal("cannot access baseline manifest %S", p->zBaseline); |
| 1057 | } |
| 1058 | } |
| 1059 | return 0; |
| 1060 | } |
| @@ -1075,11 +1075,11 @@ | |
| 1075 | ** |
| 1076 | ** Return NULL for end-of-records or if there is an error. If an error |
| 1077 | ** occurs and pErr!=0 then store 1 in *pErr. |
| 1078 | */ |
| 1079 | ManifestFile *manifest_file_next( |
| 1080 | Manifest *p, |
| 1081 | int *pErr |
| 1082 | ){ |
| 1083 | ManifestFile *pOut = 0; |
| 1084 | if( pErr ) *pErr = 0; |
| 1085 | if( p->pBaseline==0 ){ |
| @@ -1219,11 +1219,11 @@ | |
| 1219 | content_deltify(pid, fid, 0); |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | /* |
| 1224 | ** Do a binary search to find a file in the p->aFile[] array. |
| 1225 | ** |
| 1226 | ** As an optimization, guess that the file we seek is at index p->iFile. |
| 1227 | ** That will usually be the case. If it is not found there, then do the |
| 1228 | ** actual binary search. |
| 1229 | ** |
| @@ -1263,18 +1263,18 @@ | |
| 1263 | /* |
| 1264 | ** Locate a file named zName in the aFile[] array of the given manifest. |
| 1265 | ** Return a pointer to the appropriate ManifestFile object. Return NULL |
| 1266 | ** if not found. |
| 1267 | ** |
| 1268 | ** This routine works even if p is a delta-manifest. The pointer |
| 1269 | ** returned might be to the baseline. |
| 1270 | ** |
| 1271 | ** We assume that filenames are in sorted order and use a binary search. |
| 1272 | */ |
| 1273 | ManifestFile *manifest_file_seek(Manifest *p, const char *zName){ |
| 1274 | ManifestFile *pFile; |
| 1275 | |
| 1276 | pFile = manifest_file_seek_base(p, zName); |
| 1277 | if( pFile && pFile->zUuid==0 ) return 0; |
| 1278 | if( pFile==0 && p->zBaseline ){ |
| 1279 | fetch_baseline(p, 1); |
| 1280 | pFile = manifest_file_seek_base(p->pBaseline, zName); |
| @@ -1362,15 +1362,15 @@ | |
| 1362 | return; |
| 1363 | } |
| 1364 | isPublic = !content_is_private(cid); |
| 1365 | |
| 1366 | /* Try to make the parent manifest a delta from the child, if that |
| 1367 | ** is an appropriate thing to do. For a new baseline, make the |
| 1368 | ** previous baseline a delta from the current baseline. |
| 1369 | */ |
| 1370 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1371 | content_deltify(pid, cid, 0); |
| 1372 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1373 | content_deltify(pParent->pBaseline->rid, cid, 0); |
| 1374 | } |
| 1375 | |
| 1376 | /* Remember all children less than a few seconds younger than their parent, |
| @@ -1385,11 +1385,11 @@ | |
| 1385 | ); |
| 1386 | } |
| 1387 | |
| 1388 | /* First look at all files in pChild, ignoring its baseline. This |
| 1389 | ** is where most of the changes will be found. |
| 1390 | */ |
| 1391 | for(i=0, pChildFile=pChild->aFile; i<pChild->nFile; i++, pChildFile++){ |
| 1392 | int mperm = manifest_file_mperm(pChildFile); |
| 1393 | if( pChildFile->zPrior ){ |
| 1394 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior); |
| 1395 | if( pParentFile ){ |
| @@ -1450,11 +1450,11 @@ | |
| 1450 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1451 | manifest_file_rewind(pParent); |
| 1452 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1453 | pChildFile = manifest_file_seek(pChild, pParentFile->zName); |
| 1454 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1455 | add_one_mlink(cid, pParentFile->zUuid, 0, pParentFile->zName, 0, |
| 1456 | isPublic, 0); |
| 1457 | } |
| 1458 | } |
| 1459 | } |
| 1460 | manifest_cache_insert(*ppOther); |
| @@ -1578,11 +1578,11 @@ | |
| 1578 | if( once ){ |
| 1579 | once = 0; |
| 1580 | zTitleExpr = db_get("ticket-title-expr", "title"); |
| 1581 | zStatusColumn = db_get("ticket-status-column", "status"); |
| 1582 | } |
| 1583 | zTitle = db_text("unknown", |
| 1584 | "SELECT %s FROM ticket WHERE tkt_uuid='%s'", |
| 1585 | zTitleExpr, pManifest->zTicketUuid |
| 1586 | ); |
| 1587 | if( !isNew ){ |
| 1588 | for(i=0; i<pManifest->nField; i++){ |
| @@ -1599,11 +1599,11 @@ | |
| 1599 | pManifest->nField-1, pManifest->nField==2 ? "" : "s"); |
| 1600 | } |
| 1601 | blob_appendf(&brief, "%h ticket [%.10s].", |
| 1602 | zNewStatus, pManifest->zTicketUuid); |
| 1603 | }else{ |
| 1604 | zNewStatus = db_text("unknown", |
| 1605 | "SELECT %s FROM ticket WHERE tkt_uuid='%s'", |
| 1606 | zStatusColumn, pManifest->zTicketUuid |
| 1607 | ); |
| 1608 | blob_appendf(&comment, "Ticket [%.10s] <i>%h</i> status still %h with " |
| 1609 | "%d other change%s", |
| @@ -1661,11 +1661,11 @@ | |
| 1661 | ** |
| 1662 | ** If the input is a control artifact, then make appropriate entries |
| 1663 | ** in the auxiliary tables of the database in order to crosslink the |
| 1664 | ** artifact. |
| 1665 | ** |
| 1666 | ** If global variable g.xlinkClusterOnly is true, then ignore all |
| 1667 | ** control artifacts other than clusters. |
| 1668 | ** |
| 1669 | ** This routine always resets the pContent blob before returning. |
| 1670 | ** |
| 1671 | ** Historical note: This routine original processed manifests only. |
| @@ -1744,11 +1744,11 @@ | |
| 1744 | " %d,%Q,%Q," |
| 1745 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>0)," |
| 1746 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)," |
| 1747 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),%.17g);", |
| 1748 | TAG_DATE, rid, p->rDate, |
| 1749 | rid, p->zUser, p->zComment, |
| 1750 | TAG_BGCOLOR, rid, |
| 1751 | TAG_USER, rid, |
| 1752 | TAG_COMMENT, rid, p->rDate |
| 1753 | ); |
| 1754 | zCom = db_text(0, "SELECT coalesce(ecomment, comment) FROM event" |
| @@ -1802,11 +1802,11 @@ | |
| 1802 | case '*': type = 2; break; /* Propagate to descendants */ |
| 1803 | default: |
| 1804 | fossil_error(1, "unknown tag type in manifest: %s", p->aTag); |
| 1805 | return 0; |
| 1806 | } |
| 1807 | tag_insert(&p->aTag[i].zName[1], type, p->aTag[i].zValue, |
| 1808 | rid, p->rDate, tid); |
| 1809 | } |
| 1810 | } |
| 1811 | if( parentid ){ |
| 1812 | tag_propagate_all(parentid); |
| @@ -1843,11 +1843,11 @@ | |
| 1843 | " bgcolor,euser,ecomment)" |
| 1844 | "VALUES('w',%.17g,%d,%Q,%Q," |
| 1845 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1)," |
| 1846 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)," |
| 1847 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));", |
| 1848 | p->rDate, rid, p->zUser, zComment, |
| 1849 | TAG_BGCOLOR, rid, |
| 1850 | TAG_BGCOLOR, rid, |
| 1851 | TAG_USER, rid, |
| 1852 | TAG_COMMENT, rid |
| 1853 | ); |
| @@ -1893,11 +1893,11 @@ | |
| 1893 | }else{ |
| 1894 | db_multi_exec( |
| 1895 | "REPLACE INTO event(type,mtime,objid,tagid,user,comment,bgcolor)" |
| 1896 | "VALUES('e',%.17g,%d,%d,%Q,%Q," |
| 1897 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));", |
| 1898 | p->rEventDate, rid, tagid, p->zUser, p->zComment, |
| 1899 | TAG_BGCOLOR, rid |
| 1900 | ); |
| 1901 | } |
| 1902 | } |
| 1903 | if( p->type==CFTYPE_TICKET ){ |
| @@ -1925,11 +1925,11 @@ | |
| 1925 | " WHERE target=%Q AND filename=%Q", |
| 1926 | p->zAttachTarget, p->zAttachName, |
| 1927 | p->zAttachTarget, p->zAttachName |
| 1928 | ); |
| 1929 | if( strlen(p->zAttachTarget)!=UUID_SIZE |
| 1930 | || !validate16(p->zAttachTarget, UUID_SIZE) |
| 1931 | ){ |
| 1932 | char *zComment; |
| 1933 | if( p->zAttachSrc && p->zAttachSrc[0] ){ |
| 1934 | zComment = mprintf( |
| 1935 | "Add attachment [/artifact/%S|%h] to wiki page [%h]", |
| 1936 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -51,11 +51,11 @@ | |
| 51 | #define MC_PERMIT_HOOKS 1 /* permit hooks to execute */ |
| 52 | |
| 53 | /* |
| 54 | ** A single F-card within a manifest |
| 55 | */ |
| 56 | struct ManifestFile { |
| 57 | char *zName; /* Name of a file */ |
| 58 | char *zUuid; /* UUID of the file */ |
| 59 | char *zPerm; /* File permissions */ |
| 60 | char *zPrior; /* Prior name if the name was changed */ |
| 61 | }; |
| @@ -89,11 +89,11 @@ | |
| 89 | ManifestFile *aFile; /* One entry for each F-card */ |
| 90 | int nParent; /* Number of parents. */ |
| 91 | int nParentAlloc; /* Slots allocated in azParent[] */ |
| 92 | char **azParent; /* UUIDs of parents. One for each P card argument */ |
| 93 | int nCherrypick; /* Number of entries in aCherrypick[] */ |
| 94 | struct { |
| 95 | char *zCPTarget; /* UUID of cherry-picked version w/ +|- prefix */ |
| 96 | char *zCPBase; /* UUID of cherry-pick baseline. NULL for singletons */ |
| 97 | } *aCherrypick; |
| 98 | int nCChild; /* Number of cluster children */ |
| 99 | int nCChildAlloc; /* Number of closts allocated in azCChild[] */ |
| @@ -105,11 +105,11 @@ | |
| 105 | char *zUuid; /* UUID that the tag is applied to */ |
| 106 | char *zValue; /* Value if the tag is really a property */ |
| 107 | } *aTag; /* One for each T card */ |
| 108 | int nField; /* Number of J cards */ |
| 109 | int nFieldAlloc; /* Slots allocated in aField[] */ |
| 110 | struct { |
| 111 | char *zName; /* Key or field name */ |
| 112 | char *zValue; /* Value of the field */ |
| 113 | } *aField; /* One for each J card */ |
| 114 | }; |
| 115 | #endif |
| @@ -251,11 +251,11 @@ | |
| 251 | ** Verify the Z-card checksum on the artifact, if there is such a |
| 252 | ** checksum. Return 0 if there is no Z-card. Return 1 if the Z-card |
| 253 | ** exists and is correct. Return 2 if the Z-card exists and has the wrong |
| 254 | ** value. |
| 255 | ** |
| 256 | ** 0123456789 123456789 123456789 123456789 |
| 257 | ** Z aea84f4f863865a8d59d0384e4d2a41c |
| 258 | */ |
| 259 | static int verify_z_card(const char *z, int n){ |
| 260 | if( n<35 ) return 0; |
| 261 | if( z[n-35]!='Z' || z[n-34]!=' ' ) return 0; |
| @@ -435,11 +435,11 @@ | |
| 435 | char *zName, *zTarget, *zSrc; |
| 436 | int nTarget = 0, nSrc = 0; |
| 437 | zName = next_token(&x, 0); |
| 438 | zTarget = next_token(&x, &nTarget); |
| 439 | zSrc = next_token(&x, &nSrc); |
| 440 | if( zName==0 || zTarget==0 ) goto manifest_syntax_error; |
| 441 | if( p->zAttachName!=0 ) goto manifest_syntax_error; |
| 442 | defossilize(zName); |
| 443 | if( !file_is_simple_pathname(zName, 0) ){ |
| 444 | SYNTAX("invalid filename on A-card"); |
| 445 | } |
| @@ -504,11 +504,11 @@ | |
| 504 | } |
| 505 | |
| 506 | /* |
| 507 | ** E <timestamp> <uuid> |
| 508 | ** |
| 509 | ** An "event" card that contains the timestamp of the event in the |
| 510 | ** format YYYY-MM-DDtHH:MM:SS and a unique identifier for the event. |
| 511 | ** The event timestamp is distinct from the D timestamp. The D |
| 512 | ** timestamp is when the artifact was created whereas the E timestamp |
| 513 | ** is when the specific event is said to occur. |
| 514 | */ |
| @@ -551,11 +551,11 @@ | |
| 551 | SYNTAX("F-card old filename is not a simple path"); |
| 552 | } |
| 553 | } |
| 554 | if( p->nFile>=p->nFileAlloc ){ |
| 555 | p->nFileAlloc = p->nFileAlloc*2 + 10; |
| 556 | p->aFile = fossil_realloc(p->aFile, |
| 557 | p->nFileAlloc*sizeof(p->aFile[0]) ); |
| 558 | } |
| 559 | i = p->nFile++; |
| 560 | p->aFile[i].zName = zName; |
| 561 | p->aFile[i].zUuid = zUuid; |
| @@ -743,11 +743,11 @@ | |
| 743 | ** singleton tag, "*" to create a propagating tag, or "-" to create |
| 744 | ** anti-tag that undoes a prior "+" or blocks propagation of of |
| 745 | ** a "*". |
| 746 | ** |
| 747 | ** The tag is applied to <uuid>. If <uuid> is "*" then the tag is |
| 748 | ** applied to the current manifest. If <value> is provided then |
| 749 | ** the tag is really a property with the given value. |
| 750 | ** |
| 751 | ** Tags are not allowed in clusters. Multiple T lines are allowed. |
| 752 | */ |
| 753 | case 'T': { |
| @@ -1050,11 +1050,11 @@ | |
| 1050 | db_multi_exec( |
| 1051 | "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)", |
| 1052 | p->rid, rid |
| 1053 | ); |
| 1054 | return 1; |
| 1055 | } |
| 1056 | fossil_fatal("cannot access baseline manifest %S", p->zBaseline); |
| 1057 | } |
| 1058 | } |
| 1059 | return 0; |
| 1060 | } |
| @@ -1075,11 +1075,11 @@ | |
| 1075 | ** |
| 1076 | ** Return NULL for end-of-records or if there is an error. If an error |
| 1077 | ** occurs and pErr!=0 then store 1 in *pErr. |
| 1078 | */ |
| 1079 | ManifestFile *manifest_file_next( |
| 1080 | Manifest *p, |
| 1081 | int *pErr |
| 1082 | ){ |
| 1083 | ManifestFile *pOut = 0; |
| 1084 | if( pErr ) *pErr = 0; |
| 1085 | if( p->pBaseline==0 ){ |
| @@ -1219,11 +1219,11 @@ | |
| 1219 | content_deltify(pid, fid, 0); |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | /* |
| 1224 | ** Do a binary search to find a file in the p->aFile[] array. |
| 1225 | ** |
| 1226 | ** As an optimization, guess that the file we seek is at index p->iFile. |
| 1227 | ** That will usually be the case. If it is not found there, then do the |
| 1228 | ** actual binary search. |
| 1229 | ** |
| @@ -1263,18 +1263,18 @@ | |
| 1263 | /* |
| 1264 | ** Locate a file named zName in the aFile[] array of the given manifest. |
| 1265 | ** Return a pointer to the appropriate ManifestFile object. Return NULL |
| 1266 | ** if not found. |
| 1267 | ** |
| 1268 | ** This routine works even if p is a delta-manifest. The pointer |
| 1269 | ** returned might be to the baseline. |
| 1270 | ** |
| 1271 | ** We assume that filenames are in sorted order and use a binary search. |
| 1272 | */ |
| 1273 | ManifestFile *manifest_file_seek(Manifest *p, const char *zName){ |
| 1274 | ManifestFile *pFile; |
| 1275 | |
| 1276 | pFile = manifest_file_seek_base(p, zName); |
| 1277 | if( pFile && pFile->zUuid==0 ) return 0; |
| 1278 | if( pFile==0 && p->zBaseline ){ |
| 1279 | fetch_baseline(p, 1); |
| 1280 | pFile = manifest_file_seek_base(p->pBaseline, zName); |
| @@ -1362,15 +1362,15 @@ | |
| 1362 | return; |
| 1363 | } |
| 1364 | isPublic = !content_is_private(cid); |
| 1365 | |
| 1366 | /* Try to make the parent manifest a delta from the child, if that |
| 1367 | ** is an appropriate thing to do. For a new baseline, make the |
| 1368 | ** previous baseline a delta from the current baseline. |
| 1369 | */ |
| 1370 | if( (pParent->zBaseline==0)==(pChild->zBaseline==0) ){ |
| 1371 | content_deltify(pid, cid, 0); |
| 1372 | }else if( pChild->zBaseline==0 && pParent->zBaseline!=0 ){ |
| 1373 | content_deltify(pParent->pBaseline->rid, cid, 0); |
| 1374 | } |
| 1375 | |
| 1376 | /* Remember all children less than a few seconds younger than their parent, |
| @@ -1385,11 +1385,11 @@ | |
| 1385 | ); |
| 1386 | } |
| 1387 | |
| 1388 | /* First look at all files in pChild, ignoring its baseline. This |
| 1389 | ** is where most of the changes will be found. |
| 1390 | */ |
| 1391 | for(i=0, pChildFile=pChild->aFile; i<pChild->nFile; i++, pChildFile++){ |
| 1392 | int mperm = manifest_file_mperm(pChildFile); |
| 1393 | if( pChildFile->zPrior ){ |
| 1394 | pParentFile = manifest_file_seek(pParent, pChildFile->zPrior); |
| 1395 | if( pParentFile ){ |
| @@ -1450,11 +1450,11 @@ | |
| 1450 | ** but are missing from pChild and mark them as having been deleted. */ |
| 1451 | manifest_file_rewind(pParent); |
| 1452 | while( (pParentFile = manifest_file_next(pParent,0))!=0 ){ |
| 1453 | pChildFile = manifest_file_seek(pChild, pParentFile->zName); |
| 1454 | if( pChildFile==0 && pParentFile->zUuid!=0 ){ |
| 1455 | add_one_mlink(cid, pParentFile->zUuid, 0, pParentFile->zName, 0, |
| 1456 | isPublic, 0); |
| 1457 | } |
| 1458 | } |
| 1459 | } |
| 1460 | manifest_cache_insert(*ppOther); |
| @@ -1578,11 +1578,11 @@ | |
| 1578 | if( once ){ |
| 1579 | once = 0; |
| 1580 | zTitleExpr = db_get("ticket-title-expr", "title"); |
| 1581 | zStatusColumn = db_get("ticket-status-column", "status"); |
| 1582 | } |
| 1583 | zTitle = db_text("unknown", |
| 1584 | "SELECT %s FROM ticket WHERE tkt_uuid='%s'", |
| 1585 | zTitleExpr, pManifest->zTicketUuid |
| 1586 | ); |
| 1587 | if( !isNew ){ |
| 1588 | for(i=0; i<pManifest->nField; i++){ |
| @@ -1599,11 +1599,11 @@ | |
| 1599 | pManifest->nField-1, pManifest->nField==2 ? "" : "s"); |
| 1600 | } |
| 1601 | blob_appendf(&brief, "%h ticket [%.10s].", |
| 1602 | zNewStatus, pManifest->zTicketUuid); |
| 1603 | }else{ |
| 1604 | zNewStatus = db_text("unknown", |
| 1605 | "SELECT %s FROM ticket WHERE tkt_uuid='%s'", |
| 1606 | zStatusColumn, pManifest->zTicketUuid |
| 1607 | ); |
| 1608 | blob_appendf(&comment, "Ticket [%.10s] <i>%h</i> status still %h with " |
| 1609 | "%d other change%s", |
| @@ -1661,11 +1661,11 @@ | |
| 1661 | ** |
| 1662 | ** If the input is a control artifact, then make appropriate entries |
| 1663 | ** in the auxiliary tables of the database in order to crosslink the |
| 1664 | ** artifact. |
| 1665 | ** |
| 1666 | ** If global variable g.xlinkClusterOnly is true, then ignore all |
| 1667 | ** control artifacts other than clusters. |
| 1668 | ** |
| 1669 | ** This routine always resets the pContent blob before returning. |
| 1670 | ** |
| 1671 | ** Historical note: This routine original processed manifests only. |
| @@ -1744,11 +1744,11 @@ | |
| 1744 | " %d,%Q,%Q," |
| 1745 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>0)," |
| 1746 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)," |
| 1747 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),%.17g);", |
| 1748 | TAG_DATE, rid, p->rDate, |
| 1749 | rid, p->zUser, p->zComment, |
| 1750 | TAG_BGCOLOR, rid, |
| 1751 | TAG_USER, rid, |
| 1752 | TAG_COMMENT, rid, p->rDate |
| 1753 | ); |
| 1754 | zCom = db_text(0, "SELECT coalesce(ecomment, comment) FROM event" |
| @@ -1802,11 +1802,11 @@ | |
| 1802 | case '*': type = 2; break; /* Propagate to descendants */ |
| 1803 | default: |
| 1804 | fossil_error(1, "unknown tag type in manifest: %s", p->aTag); |
| 1805 | return 0; |
| 1806 | } |
| 1807 | tag_insert(&p->aTag[i].zName[1], type, p->aTag[i].zValue, |
| 1808 | rid, p->rDate, tid); |
| 1809 | } |
| 1810 | } |
| 1811 | if( parentid ){ |
| 1812 | tag_propagate_all(parentid); |
| @@ -1843,11 +1843,11 @@ | |
| 1843 | " bgcolor,euser,ecomment)" |
| 1844 | "VALUES('w',%.17g,%d,%Q,%Q," |
| 1845 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1)," |
| 1846 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)," |
| 1847 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));", |
| 1848 | p->rDate, rid, p->zUser, zComment, |
| 1849 | TAG_BGCOLOR, rid, |
| 1850 | TAG_BGCOLOR, rid, |
| 1851 | TAG_USER, rid, |
| 1852 | TAG_COMMENT, rid |
| 1853 | ); |
| @@ -1893,11 +1893,11 @@ | |
| 1893 | }else{ |
| 1894 | db_multi_exec( |
| 1895 | "REPLACE INTO event(type,mtime,objid,tagid,user,comment,bgcolor)" |
| 1896 | "VALUES('e',%.17g,%d,%d,%Q,%Q," |
| 1897 | " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));", |
| 1898 | p->rEventDate, rid, tagid, p->zUser, p->zComment, |
| 1899 | TAG_BGCOLOR, rid |
| 1900 | ); |
| 1901 | } |
| 1902 | } |
| 1903 | if( p->type==CFTYPE_TICKET ){ |
| @@ -1925,11 +1925,11 @@ | |
| 1925 | " WHERE target=%Q AND filename=%Q", |
| 1926 | p->zAttachTarget, p->zAttachName, |
| 1927 | p->zAttachTarget, p->zAttachName |
| 1928 | ); |
| 1929 | if( strlen(p->zAttachTarget)!=UUID_SIZE |
| 1930 | || !validate16(p->zAttachTarget, UUID_SIZE) |
| 1931 | ){ |
| 1932 | char *zComment; |
| 1933 | if( p->zAttachSrc && p->zAttachSrc[0] ){ |
| 1934 | zComment = mprintf( |
| 1935 | "Add attachment [/artifact/%S|%h] to wiki page [%h]", |
| 1936 |
+6
-6
| --- src/markdown.c | ||
| +++ src/markdown.c | ||
| @@ -161,11 +161,11 @@ | ||
| 161 | 161 | }; |
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | /* html_tag -- structure for quick HTML tag search (inspired from discount) */ |
| 165 | 165 | struct html_tag { |
| 166 | - char *text; | |
| 166 | + const char *text; | |
| 167 | 167 | int size; |
| 168 | 168 | }; |
| 169 | 169 | |
| 170 | 170 | |
| 171 | 171 | |
| @@ -172,11 +172,11 @@ | ||
| 172 | 172 | /******************** |
| 173 | 173 | * GLOBAL VARIABLES * |
| 174 | 174 | ********************/ |
| 175 | 175 | |
| 176 | 176 | /* block_tags -- recognised block tags, sorted by cmp_html_tag */ |
| 177 | -static struct html_tag block_tags[] = { | |
| 177 | +static const struct html_tag block_tags[] = { | |
| 178 | 178 | { "p", 1 }, |
| 179 | 179 | { "dl", 2 }, |
| 180 | 180 | { "h1", 2 }, |
| 181 | 181 | { "h2", 2 }, |
| 182 | 182 | { "h3", 2 }, |
| @@ -276,11 +276,11 @@ | ||
| 276 | 276 | return fossil_strnicmp(hta->text, htb->text, hta->size); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | |
| 280 | 280 | /* find_block_tag -- returns the current block tag */ |
| 281 | -static struct html_tag *find_block_tag(char *data, size_t size){ | |
| 281 | +static const struct html_tag *find_block_tag(const char *data, size_t size){ | |
| 282 | 282 | size_t i = 0; |
| 283 | 283 | struct html_tag key; |
| 284 | 284 | |
| 285 | 285 | /* looking for the word end */ |
| 286 | 286 | while( i<size |
| @@ -1070,11 +1070,11 @@ | ||
| 1070 | 1070 | /********************************* |
| 1071 | 1071 | * BLOCK-LEVEL PARSING FUNCTIONS * |
| 1072 | 1072 | *********************************/ |
| 1073 | 1073 | |
| 1074 | 1074 | /* is_empty -- returns the line length when it is empty, 0 otherwise */ |
| 1075 | -static size_t is_empty(char *data, size_t size){ | |
| 1075 | +static size_t is_empty(const char *data, size_t size){ | |
| 1076 | 1076 | size_t i; |
| 1077 | 1077 | for(i=0; i<size && data[i]!='\n'; i++){ |
| 1078 | 1078 | if( data[i]!=' ' && data[i]!='\t' ) return 0; |
| 1079 | 1079 | } |
| 1080 | 1080 | return i+1; |
| @@ -1631,11 +1631,11 @@ | ||
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | |
| 1634 | 1634 | /* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */ |
| 1635 | 1635 | /* returns the length on match, 0 otherwise */ |
| 1636 | -static size_t htmlblock_end(struct html_tag *tag, char *data, size_t size){ | |
| 1636 | +static size_t htmlblock_end(const struct html_tag *tag, const char *data, size_t size){ | |
| 1637 | 1637 | size_t i, w; |
| 1638 | 1638 | |
| 1639 | 1639 | /* assuming data[0]=='<' && data[1]=='/' already tested */ |
| 1640 | 1640 | |
| 1641 | 1641 | /* checking tag is a match */ |
| @@ -1668,11 +1668,11 @@ | ||
| 1668 | 1668 | struct render *rndr, |
| 1669 | 1669 | char *data, |
| 1670 | 1670 | size_t size |
| 1671 | 1671 | ){ |
| 1672 | 1672 | size_t i, j = 0; |
| 1673 | - struct html_tag *curtag; | |
| 1673 | + const struct html_tag *curtag; | |
| 1674 | 1674 | int found; |
| 1675 | 1675 | size_t work_size = 0; |
| 1676 | 1676 | struct Blob work = BLOB_INITIALIZER; |
| 1677 | 1677 | |
| 1678 | 1678 | /* identification of the opening tag */ |
| 1679 | 1679 |
| --- src/markdown.c | |
| +++ src/markdown.c | |
| @@ -161,11 +161,11 @@ | |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | /* html_tag -- structure for quick HTML tag search (inspired from discount) */ |
| 165 | struct html_tag { |
| 166 | char *text; |
| 167 | int size; |
| 168 | }; |
| 169 | |
| 170 | |
| 171 | |
| @@ -172,11 +172,11 @@ | |
| 172 | /******************** |
| 173 | * GLOBAL VARIABLES * |
| 174 | ********************/ |
| 175 | |
| 176 | /* block_tags -- recognised block tags, sorted by cmp_html_tag */ |
| 177 | static struct html_tag block_tags[] = { |
| 178 | { "p", 1 }, |
| 179 | { "dl", 2 }, |
| 180 | { "h1", 2 }, |
| 181 | { "h2", 2 }, |
| 182 | { "h3", 2 }, |
| @@ -276,11 +276,11 @@ | |
| 276 | return fossil_strnicmp(hta->text, htb->text, hta->size); |
| 277 | } |
| 278 | |
| 279 | |
| 280 | /* find_block_tag -- returns the current block tag */ |
| 281 | static struct html_tag *find_block_tag(char *data, size_t size){ |
| 282 | size_t i = 0; |
| 283 | struct html_tag key; |
| 284 | |
| 285 | /* looking for the word end */ |
| 286 | while( i<size |
| @@ -1070,11 +1070,11 @@ | |
| 1070 | /********************************* |
| 1071 | * BLOCK-LEVEL PARSING FUNCTIONS * |
| 1072 | *********************************/ |
| 1073 | |
| 1074 | /* is_empty -- returns the line length when it is empty, 0 otherwise */ |
| 1075 | static size_t is_empty(char *data, size_t size){ |
| 1076 | size_t i; |
| 1077 | for(i=0; i<size && data[i]!='\n'; i++){ |
| 1078 | if( data[i]!=' ' && data[i]!='\t' ) return 0; |
| 1079 | } |
| 1080 | return i+1; |
| @@ -1631,11 +1631,11 @@ | |
| 1631 | } |
| 1632 | |
| 1633 | |
| 1634 | /* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */ |
| 1635 | /* returns the length on match, 0 otherwise */ |
| 1636 | static size_t htmlblock_end(struct html_tag *tag, char *data, size_t size){ |
| 1637 | size_t i, w; |
| 1638 | |
| 1639 | /* assuming data[0]=='<' && data[1]=='/' already tested */ |
| 1640 | |
| 1641 | /* checking tag is a match */ |
| @@ -1668,11 +1668,11 @@ | |
| 1668 | struct render *rndr, |
| 1669 | char *data, |
| 1670 | size_t size |
| 1671 | ){ |
| 1672 | size_t i, j = 0; |
| 1673 | struct html_tag *curtag; |
| 1674 | int found; |
| 1675 | size_t work_size = 0; |
| 1676 | struct Blob work = BLOB_INITIALIZER; |
| 1677 | |
| 1678 | /* identification of the opening tag */ |
| 1679 |
| --- src/markdown.c | |
| +++ src/markdown.c | |
| @@ -161,11 +161,11 @@ | |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | /* html_tag -- structure for quick HTML tag search (inspired from discount) */ |
| 165 | struct html_tag { |
| 166 | const char *text; |
| 167 | int size; |
| 168 | }; |
| 169 | |
| 170 | |
| 171 | |
| @@ -172,11 +172,11 @@ | |
| 172 | /******************** |
| 173 | * GLOBAL VARIABLES * |
| 174 | ********************/ |
| 175 | |
| 176 | /* block_tags -- recognised block tags, sorted by cmp_html_tag */ |
| 177 | static const struct html_tag block_tags[] = { |
| 178 | { "p", 1 }, |
| 179 | { "dl", 2 }, |
| 180 | { "h1", 2 }, |
| 181 | { "h2", 2 }, |
| 182 | { "h3", 2 }, |
| @@ -276,11 +276,11 @@ | |
| 276 | return fossil_strnicmp(hta->text, htb->text, hta->size); |
| 277 | } |
| 278 | |
| 279 | |
| 280 | /* find_block_tag -- returns the current block tag */ |
| 281 | static const struct html_tag *find_block_tag(const char *data, size_t size){ |
| 282 | size_t i = 0; |
| 283 | struct html_tag key; |
| 284 | |
| 285 | /* looking for the word end */ |
| 286 | while( i<size |
| @@ -1070,11 +1070,11 @@ | |
| 1070 | /********************************* |
| 1071 | * BLOCK-LEVEL PARSING FUNCTIONS * |
| 1072 | *********************************/ |
| 1073 | |
| 1074 | /* is_empty -- returns the line length when it is empty, 0 otherwise */ |
| 1075 | static size_t is_empty(const char *data, size_t size){ |
| 1076 | size_t i; |
| 1077 | for(i=0; i<size && data[i]!='\n'; i++){ |
| 1078 | if( data[i]!=' ' && data[i]!='\t' ) return 0; |
| 1079 | } |
| 1080 | return i+1; |
| @@ -1631,11 +1631,11 @@ | |
| 1631 | } |
| 1632 | |
| 1633 | |
| 1634 | /* htmlblock_end -- checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */ |
| 1635 | /* returns the length on match, 0 otherwise */ |
| 1636 | static size_t htmlblock_end(const struct html_tag *tag, const char *data, size_t size){ |
| 1637 | size_t i, w; |
| 1638 | |
| 1639 | /* assuming data[0]=='<' && data[1]=='/' already tested */ |
| 1640 | |
| 1641 | /* checking tag is a match */ |
| @@ -1668,11 +1668,11 @@ | |
| 1668 | struct render *rndr, |
| 1669 | char *data, |
| 1670 | size_t size |
| 1671 | ){ |
| 1672 | size_t i, j = 0; |
| 1673 | const struct html_tag *curtag; |
| 1674 | int found; |
| 1675 | size_t work_size = 0; |
| 1676 | struct Blob work = BLOB_INITIALIZER; |
| 1677 | |
| 1678 | /* identification of the opening tag */ |
| 1679 |
+3
-11
| --- src/merge.c | ||
| +++ src/merge.c | ||
| @@ -258,21 +258,13 @@ | ||
| 258 | 258 | if( !forceFlag && mid==pid ){ |
| 259 | 259 | fossil_print("Merge skipped because it is a no-op. " |
| 260 | 260 | " Use --force to override.\n"); |
| 261 | 261 | return; |
| 262 | 262 | } |
| 263 | - if( integrateFlag ){ | |
| 264 | - if( db_exists("SELECT 1 FROM vmerge WHERE id=-4")) { | |
| 265 | - /* Fossil earlier than [55cacfcace] cannot handle this, | |
| 266 | - * therefore disallow it. */ | |
| 267 | - fossil_fatal("Integration of another branch already in progress." | |
| 268 | - " Commit or Undo needed first", g.argv[2]); | |
| 269 | - } | |
| 270 | - if( !is_a_leaf(mid) ){ | |
| 271 | - fossil_warning("ignoring --integrate: %s is not a leaf", g.argv[2]); | |
| 272 | - integrateFlag = 0; | |
| 273 | - } | |
| 263 | + if( integrateFlag && !is_a_leaf(mid)){ | |
| 264 | + fossil_warning("ignoring --integrate: %s is not a leaf", g.argv[2]); | |
| 265 | + integrateFlag = 0; | |
| 274 | 266 | } |
| 275 | 267 | if( verboseFlag ){ |
| 276 | 268 | print_checkin_description(mid, 12, integrateFlag?"integrate:":"merge-from:"); |
| 277 | 269 | print_checkin_description(pid, 12, "baseline:"); |
| 278 | 270 | } |
| 279 | 271 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -258,21 +258,13 @@ | |
| 258 | if( !forceFlag && mid==pid ){ |
| 259 | fossil_print("Merge skipped because it is a no-op. " |
| 260 | " Use --force to override.\n"); |
| 261 | return; |
| 262 | } |
| 263 | if( integrateFlag ){ |
| 264 | if( db_exists("SELECT 1 FROM vmerge WHERE id=-4")) { |
| 265 | /* Fossil earlier than [55cacfcace] cannot handle this, |
| 266 | * therefore disallow it. */ |
| 267 | fossil_fatal("Integration of another branch already in progress." |
| 268 | " Commit or Undo needed first", g.argv[2]); |
| 269 | } |
| 270 | if( !is_a_leaf(mid) ){ |
| 271 | fossil_warning("ignoring --integrate: %s is not a leaf", g.argv[2]); |
| 272 | integrateFlag = 0; |
| 273 | } |
| 274 | } |
| 275 | if( verboseFlag ){ |
| 276 | print_checkin_description(mid, 12, integrateFlag?"integrate:":"merge-from:"); |
| 277 | print_checkin_description(pid, 12, "baseline:"); |
| 278 | } |
| 279 |
| --- src/merge.c | |
| +++ src/merge.c | |
| @@ -258,21 +258,13 @@ | |
| 258 | if( !forceFlag && mid==pid ){ |
| 259 | fossil_print("Merge skipped because it is a no-op. " |
| 260 | " Use --force to override.\n"); |
| 261 | return; |
| 262 | } |
| 263 | if( integrateFlag && !is_a_leaf(mid)){ |
| 264 | fossil_warning("ignoring --integrate: %s is not a leaf", g.argv[2]); |
| 265 | integrateFlag = 0; |
| 266 | } |
| 267 | if( verboseFlag ){ |
| 268 | print_checkin_description(mid, 12, integrateFlag?"integrate:":"merge-from:"); |
| 269 | print_checkin_description(pid, 12, "baseline:"); |
| 270 | } |
| 271 |
+1
-1
| --- src/merge3.c | ||
| +++ src/merge3.c | ||
| @@ -364,11 +364,11 @@ | ||
| 364 | 364 | ** |
| 365 | 365 | ** fossil 3-way-merge Xbase.c Xlocal.c Xup.c Xlocal.c |
| 366 | 366 | ** cp Xup.c Xbase.c |
| 367 | 367 | ** # Verify that everything still works |
| 368 | 368 | ** fossil commit |
| 369 | -** | |
| 369 | +** | |
| 370 | 370 | */ |
| 371 | 371 | void delta_3waymerge_cmd(void){ |
| 372 | 372 | Blob pivot, v1, v2, merged; |
| 373 | 373 | if( g.argc!=6 ){ |
| 374 | 374 | usage("PIVOT V1 V2 MERGED"); |
| 375 | 375 |
| --- src/merge3.c | |
| +++ src/merge3.c | |
| @@ -364,11 +364,11 @@ | |
| 364 | ** |
| 365 | ** fossil 3-way-merge Xbase.c Xlocal.c Xup.c Xlocal.c |
| 366 | ** cp Xup.c Xbase.c |
| 367 | ** # Verify that everything still works |
| 368 | ** fossil commit |
| 369 | ** |
| 370 | */ |
| 371 | void delta_3waymerge_cmd(void){ |
| 372 | Blob pivot, v1, v2, merged; |
| 373 | if( g.argc!=6 ){ |
| 374 | usage("PIVOT V1 V2 MERGED"); |
| 375 |
| --- src/merge3.c | |
| +++ src/merge3.c | |
| @@ -364,11 +364,11 @@ | |
| 364 | ** |
| 365 | ** fossil 3-way-merge Xbase.c Xlocal.c Xup.c Xlocal.c |
| 366 | ** cp Xup.c Xbase.c |
| 367 | ** # Verify that everything still works |
| 368 | ** fossil commit |
| 369 | ** |
| 370 | */ |
| 371 | void delta_3waymerge_cmd(void){ |
| 372 | Blob pivot, v1, v2, merged; |
| 373 | if( g.argc!=6 ){ |
| 374 | usage("PIVOT V1 V2 MERGED"); |
| 375 |
+1
-1
| --- src/moderate.c | ||
| +++ src/moderate.c | ||
| @@ -64,11 +64,11 @@ | ||
| 64 | 64 | |
| 65 | 65 | /* |
| 66 | 66 | ** Check to see if the object identified by RID is used for anything. |
| 67 | 67 | */ |
| 68 | 68 | static int object_used(int rid){ |
| 69 | - static const char *aTabField[] = { | |
| 69 | + static const char *const aTabField[] = { | |
| 70 | 70 | "modreq", "attachRid", |
| 71 | 71 | "mlink", "mid", |
| 72 | 72 | "mlink", "fid", |
| 73 | 73 | "tagxref", "srcid", |
| 74 | 74 | "tagxref", "rid", |
| 75 | 75 |
| --- src/moderate.c | |
| +++ src/moderate.c | |
| @@ -64,11 +64,11 @@ | |
| 64 | |
| 65 | /* |
| 66 | ** Check to see if the object identified by RID is used for anything. |
| 67 | */ |
| 68 | static int object_used(int rid){ |
| 69 | static const char *aTabField[] = { |
| 70 | "modreq", "attachRid", |
| 71 | "mlink", "mid", |
| 72 | "mlink", "fid", |
| 73 | "tagxref", "srcid", |
| 74 | "tagxref", "rid", |
| 75 |
| --- src/moderate.c | |
| +++ src/moderate.c | |
| @@ -64,11 +64,11 @@ | |
| 64 | |
| 65 | /* |
| 66 | ** Check to see if the object identified by RID is used for anything. |
| 67 | */ |
| 68 | static int object_used(int rid){ |
| 69 | static const char *const aTabField[] = { |
| 70 | "modreq", "attachRid", |
| 71 | "mlink", "mid", |
| 72 | "mlink", "fid", |
| 73 | "tagxref", "srcid", |
| 74 | "tagxref", "rid", |
| 75 |
+15
-15
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -17,11 +17,11 @@ | ||
| 17 | 17 | ** |
| 18 | 18 | ** This file contains code used to convert user-supplied object names into |
| 19 | 19 | ** canonical UUIDs. |
| 20 | 20 | ** |
| 21 | 21 | ** A user-supplied object name is any unique prefix of a valid UUID but |
| 22 | -** not necessarily in canonical form. | |
| 22 | +** not necessarily in canonical form. | |
| 23 | 23 | */ |
| 24 | 24 | #include "config.h" |
| 25 | 25 | #include "name.h" |
| 26 | 26 | #include <assert.h> |
| 27 | 27 | |
| @@ -50,11 +50,11 @@ | ||
| 50 | 50 | ** |
| 51 | 51 | ** * SHA1 hash |
| 52 | 52 | ** * SHA1 hash prefix of at least 4 characters |
| 53 | 53 | ** * Symbolic Name |
| 54 | 54 | ** * "tag:" + symbolic name |
| 55 | -** * Date or date-time | |
| 55 | +** * Date or date-time | |
| 56 | 56 | ** * "date:" + Date or date-time |
| 57 | 57 | ** * symbolic-name ":" date-time |
| 58 | 58 | ** * "tip" |
| 59 | 59 | ** |
| 60 | 60 | ** The following additional forms are available in local checkouts: |
| @@ -64,11 +64,11 @@ | ||
| 64 | 64 | ** * "next" |
| 65 | 65 | ** |
| 66 | 66 | ** Return the RID of the matching artifact. Or return 0 if the name does not |
| 67 | 67 | ** match any known object. Or return -1 if the name is ambiguous. |
| 68 | 68 | ** |
| 69 | -** The zType parameter specifies the type of artifact: ci, t, w, e, g. | |
| 69 | +** The zType parameter specifies the type of artifact: ci, t, w, e, g. | |
| 70 | 70 | ** If zType is NULL or "" or "*" then any type of artifact will serve. |
| 71 | 71 | ** zType is "ci" in most use cases since we are usually searching for |
| 72 | 72 | ** a check-in. |
| 73 | 73 | */ |
| 74 | 74 | int symbolic_name_to_rid(const char *zTag, const char *zType){ |
| @@ -93,11 +93,11 @@ | ||
| 93 | 93 | |
| 94 | 94 | /* special keywords: "prev", "previous", "current", and "next" */ |
| 95 | 95 | if( g.localOpen && (vid=db_lget_int("checkout",0))!=0 ){ |
| 96 | 96 | if( fossil_strcmp(zTag, "current")==0 ){ |
| 97 | 97 | rid = vid; |
| 98 | - }else if( fossil_strcmp(zTag, "prev")==0 | |
| 98 | + }else if( fossil_strcmp(zTag, "prev")==0 | |
| 99 | 99 | || fossil_strcmp(zTag, "previous")==0 ){ |
| 100 | 100 | rid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", vid); |
| 101 | 101 | }else if( fossil_strcmp(zTag, "next")==0 ){ |
| 102 | 102 | rid = db_int(0, "SELECT cid FROM plink WHERE pid=%d" |
| 103 | 103 | " ORDER BY isprim DESC, mtime DESC", vid); |
| @@ -105,19 +105,19 @@ | ||
| 105 | 105 | if( rid ) return rid; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /* Date and times */ |
| 109 | 109 | if( memcmp(zTag, "date:", 5)==0 ){ |
| 110 | - rid = db_int(0, | |
| 110 | + rid = db_int(0, | |
| 111 | 111 | "SELECT objid FROM event" |
| 112 | 112 | " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'" |
| 113 | 113 | " ORDER BY mtime DESC LIMIT 1", |
| 114 | 114 | &zTag[5], zType); |
| 115 | 115 | return rid; |
| 116 | 116 | } |
| 117 | 117 | if( fossil_isdate(zTag) ){ |
| 118 | - rid = db_int(0, | |
| 118 | + rid = db_int(0, | |
| 119 | 119 | "SELECT objid FROM event" |
| 120 | 120 | " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'" |
| 121 | 121 | " ORDER BY mtime DESC LIMIT 1", |
| 122 | 122 | zTag, zType); |
| 123 | 123 | if( rid) return rid; |
| @@ -124,19 +124,19 @@ | ||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /* Deprecated date & time formats: "local:" + date-time and |
| 127 | 127 | ** "utc:" + date-time */ |
| 128 | 128 | if( memcmp(zTag, "local:", 6)==0 ){ |
| 129 | - rid = db_int(0, | |
| 129 | + rid = db_int(0, | |
| 130 | 130 | "SELECT objid FROM event" |
| 131 | 131 | " WHERE mtime<=julianday(%Q) AND type GLOB '%q'" |
| 132 | 132 | " ORDER BY mtime DESC LIMIT 1", |
| 133 | 133 | &zTag[6], zType); |
| 134 | 134 | return rid; |
| 135 | 135 | } |
| 136 | 136 | if( memcmp(zTag, "utc:", 4)==0 ){ |
| 137 | - rid = db_int(0, | |
| 137 | + rid = db_int(0, | |
| 138 | 138 | "SELECT objid FROM event" |
| 139 | 139 | " WHERE mtime<=julianday('%qz') AND type GLOB '%q'" |
| 140 | 140 | " ORDER BY mtime DESC LIMIT 1", |
| 141 | 141 | &zTag[4], zType); |
| 142 | 142 | return rid; |
| @@ -153,11 +153,11 @@ | ||
| 153 | 153 | " AND event.type GLOB '%q'", |
| 154 | 154 | &zTag[4], zType |
| 155 | 155 | ); |
| 156 | 156 | return rid; |
| 157 | 157 | } |
| 158 | - | |
| 158 | + | |
| 159 | 159 | /* root:TAG -> The origin of the branch */ |
| 160 | 160 | if( memcmp(zTag, "root:", 5)==0 ){ |
| 161 | 161 | Stmt q; |
| 162 | 162 | int rc; |
| 163 | 163 | char *zBr; |
| @@ -255,11 +255,11 @@ | ||
| 255 | 255 | for(i=0; fossil_isdigit(zTag[i]); i++){} |
| 256 | 256 | if( zTag[i]==0 ){ |
| 257 | 257 | if( strcmp(zType,"*")==0 ){ |
| 258 | 258 | rid = atoi(zTag); |
| 259 | 259 | }else{ |
| 260 | - rid = db_int(0, | |
| 260 | + rid = db_int(0, | |
| 261 | 261 | "SELECT event.objid" |
| 262 | 262 | " FROM event" |
| 263 | 263 | " WHERE event.objid=%s" |
| 264 | 264 | " AND event.type GLOB '%q'", zTag, zType); |
| 265 | 265 | } |
| @@ -278,12 +278,12 @@ | ||
| 278 | 278 | ** the name as a tag. If multiple tags match, pick the latest. |
| 279 | 279 | ** If the input name matches "tag:*" then always resolve as a tag. |
| 280 | 280 | ** |
| 281 | 281 | ** If the input is not a tag, then try to match it as an ISO-8601 date |
| 282 | 282 | ** string YYYY-MM-DD HH:MM:SS and pick the nearest check-in to that date. |
| 283 | -** If the input is of the form "date:*" or "localtime:*" or "utc:*" then | |
| 284 | -** always resolve the name as a date. | |
| 283 | +** If the input is of the form "date:*" then always resolve the name as | |
| 284 | +** a date. The forms "utc:*" and "local:" are deprecated. | |
| 285 | 285 | ** |
| 286 | 286 | ** Return 0 on success. Return 1 if the name cannot be resolved. |
| 287 | 287 | ** Return 2 name is ambiguous. |
| 288 | 288 | */ |
| 289 | 289 | int name_to_uuid(Blob *pName, int iErrPriority, const char *zType){ |
| @@ -379,20 +379,20 @@ | ||
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /* |
| 382 | 382 | ** WEBPAGE: ambiguous |
| 383 | 383 | ** URL: /ambiguous?name=UUID&src=WEBPAGE |
| 384 | -** | |
| 384 | +** | |
| 385 | 385 | ** The UUID given by the name parameter is ambiguous. Display a page |
| 386 | 386 | ** that shows all possible choices and let the user select between them. |
| 387 | 387 | */ |
| 388 | 388 | void ambiguous_page(void){ |
| 389 | 389 | Stmt q; |
| 390 | - const char *zName = P("name"); | |
| 390 | + const char *zName = P("name"); | |
| 391 | 391 | const char *zSrc = P("src"); |
| 392 | 392 | char *z; |
| 393 | - | |
| 393 | + | |
| 394 | 394 | if( zName==0 || zName[0]==0 || zSrc==0 || zSrc[0]==0 ){ |
| 395 | 395 | fossil_redirect_home(); |
| 396 | 396 | } |
| 397 | 397 | style_header("Ambiguous Artifact ID"); |
| 398 | 398 | @ <p>The artifact id <b>%h(zName)</b> is ambiguous and might |
| 399 | 399 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -17,11 +17,11 @@ | |
| 17 | ** |
| 18 | ** This file contains code used to convert user-supplied object names into |
| 19 | ** canonical UUIDs. |
| 20 | ** |
| 21 | ** A user-supplied object name is any unique prefix of a valid UUID but |
| 22 | ** not necessarily in canonical form. |
| 23 | */ |
| 24 | #include "config.h" |
| 25 | #include "name.h" |
| 26 | #include <assert.h> |
| 27 | |
| @@ -50,11 +50,11 @@ | |
| 50 | ** |
| 51 | ** * SHA1 hash |
| 52 | ** * SHA1 hash prefix of at least 4 characters |
| 53 | ** * Symbolic Name |
| 54 | ** * "tag:" + symbolic name |
| 55 | ** * Date or date-time |
| 56 | ** * "date:" + Date or date-time |
| 57 | ** * symbolic-name ":" date-time |
| 58 | ** * "tip" |
| 59 | ** |
| 60 | ** The following additional forms are available in local checkouts: |
| @@ -64,11 +64,11 @@ | |
| 64 | ** * "next" |
| 65 | ** |
| 66 | ** Return the RID of the matching artifact. Or return 0 if the name does not |
| 67 | ** match any known object. Or return -1 if the name is ambiguous. |
| 68 | ** |
| 69 | ** The zType parameter specifies the type of artifact: ci, t, w, e, g. |
| 70 | ** If zType is NULL or "" or "*" then any type of artifact will serve. |
| 71 | ** zType is "ci" in most use cases since we are usually searching for |
| 72 | ** a check-in. |
| 73 | */ |
| 74 | int symbolic_name_to_rid(const char *zTag, const char *zType){ |
| @@ -93,11 +93,11 @@ | |
| 93 | |
| 94 | /* special keywords: "prev", "previous", "current", and "next" */ |
| 95 | if( g.localOpen && (vid=db_lget_int("checkout",0))!=0 ){ |
| 96 | if( fossil_strcmp(zTag, "current")==0 ){ |
| 97 | rid = vid; |
| 98 | }else if( fossil_strcmp(zTag, "prev")==0 |
| 99 | || fossil_strcmp(zTag, "previous")==0 ){ |
| 100 | rid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", vid); |
| 101 | }else if( fossil_strcmp(zTag, "next")==0 ){ |
| 102 | rid = db_int(0, "SELECT cid FROM plink WHERE pid=%d" |
| 103 | " ORDER BY isprim DESC, mtime DESC", vid); |
| @@ -105,19 +105,19 @@ | |
| 105 | if( rid ) return rid; |
| 106 | } |
| 107 | |
| 108 | /* Date and times */ |
| 109 | if( memcmp(zTag, "date:", 5)==0 ){ |
| 110 | rid = db_int(0, |
| 111 | "SELECT objid FROM event" |
| 112 | " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'" |
| 113 | " ORDER BY mtime DESC LIMIT 1", |
| 114 | &zTag[5], zType); |
| 115 | return rid; |
| 116 | } |
| 117 | if( fossil_isdate(zTag) ){ |
| 118 | rid = db_int(0, |
| 119 | "SELECT objid FROM event" |
| 120 | " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'" |
| 121 | " ORDER BY mtime DESC LIMIT 1", |
| 122 | zTag, zType); |
| 123 | if( rid) return rid; |
| @@ -124,19 +124,19 @@ | |
| 124 | } |
| 125 | |
| 126 | /* Deprecated date & time formats: "local:" + date-time and |
| 127 | ** "utc:" + date-time */ |
| 128 | if( memcmp(zTag, "local:", 6)==0 ){ |
| 129 | rid = db_int(0, |
| 130 | "SELECT objid FROM event" |
| 131 | " WHERE mtime<=julianday(%Q) AND type GLOB '%q'" |
| 132 | " ORDER BY mtime DESC LIMIT 1", |
| 133 | &zTag[6], zType); |
| 134 | return rid; |
| 135 | } |
| 136 | if( memcmp(zTag, "utc:", 4)==0 ){ |
| 137 | rid = db_int(0, |
| 138 | "SELECT objid FROM event" |
| 139 | " WHERE mtime<=julianday('%qz') AND type GLOB '%q'" |
| 140 | " ORDER BY mtime DESC LIMIT 1", |
| 141 | &zTag[4], zType); |
| 142 | return rid; |
| @@ -153,11 +153,11 @@ | |
| 153 | " AND event.type GLOB '%q'", |
| 154 | &zTag[4], zType |
| 155 | ); |
| 156 | return rid; |
| 157 | } |
| 158 | |
| 159 | /* root:TAG -> The origin of the branch */ |
| 160 | if( memcmp(zTag, "root:", 5)==0 ){ |
| 161 | Stmt q; |
| 162 | int rc; |
| 163 | char *zBr; |
| @@ -255,11 +255,11 @@ | |
| 255 | for(i=0; fossil_isdigit(zTag[i]); i++){} |
| 256 | if( zTag[i]==0 ){ |
| 257 | if( strcmp(zType,"*")==0 ){ |
| 258 | rid = atoi(zTag); |
| 259 | }else{ |
| 260 | rid = db_int(0, |
| 261 | "SELECT event.objid" |
| 262 | " FROM event" |
| 263 | " WHERE event.objid=%s" |
| 264 | " AND event.type GLOB '%q'", zTag, zType); |
| 265 | } |
| @@ -278,12 +278,12 @@ | |
| 278 | ** the name as a tag. If multiple tags match, pick the latest. |
| 279 | ** If the input name matches "tag:*" then always resolve as a tag. |
| 280 | ** |
| 281 | ** If the input is not a tag, then try to match it as an ISO-8601 date |
| 282 | ** string YYYY-MM-DD HH:MM:SS and pick the nearest check-in to that date. |
| 283 | ** If the input is of the form "date:*" or "localtime:*" or "utc:*" then |
| 284 | ** always resolve the name as a date. |
| 285 | ** |
| 286 | ** Return 0 on success. Return 1 if the name cannot be resolved. |
| 287 | ** Return 2 name is ambiguous. |
| 288 | */ |
| 289 | int name_to_uuid(Blob *pName, int iErrPriority, const char *zType){ |
| @@ -379,20 +379,20 @@ | |
| 379 | } |
| 380 | |
| 381 | /* |
| 382 | ** WEBPAGE: ambiguous |
| 383 | ** URL: /ambiguous?name=UUID&src=WEBPAGE |
| 384 | ** |
| 385 | ** The UUID given by the name parameter is ambiguous. Display a page |
| 386 | ** that shows all possible choices and let the user select between them. |
| 387 | */ |
| 388 | void ambiguous_page(void){ |
| 389 | Stmt q; |
| 390 | const char *zName = P("name"); |
| 391 | const char *zSrc = P("src"); |
| 392 | char *z; |
| 393 | |
| 394 | if( zName==0 || zName[0]==0 || zSrc==0 || zSrc[0]==0 ){ |
| 395 | fossil_redirect_home(); |
| 396 | } |
| 397 | style_header("Ambiguous Artifact ID"); |
| 398 | @ <p>The artifact id <b>%h(zName)</b> is ambiguous and might |
| 399 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -17,11 +17,11 @@ | |
| 17 | ** |
| 18 | ** This file contains code used to convert user-supplied object names into |
| 19 | ** canonical UUIDs. |
| 20 | ** |
| 21 | ** A user-supplied object name is any unique prefix of a valid UUID but |
| 22 | ** not necessarily in canonical form. |
| 23 | */ |
| 24 | #include "config.h" |
| 25 | #include "name.h" |
| 26 | #include <assert.h> |
| 27 | |
| @@ -50,11 +50,11 @@ | |
| 50 | ** |
| 51 | ** * SHA1 hash |
| 52 | ** * SHA1 hash prefix of at least 4 characters |
| 53 | ** * Symbolic Name |
| 54 | ** * "tag:" + symbolic name |
| 55 | ** * Date or date-time |
| 56 | ** * "date:" + Date or date-time |
| 57 | ** * symbolic-name ":" date-time |
| 58 | ** * "tip" |
| 59 | ** |
| 60 | ** The following additional forms are available in local checkouts: |
| @@ -64,11 +64,11 @@ | |
| 64 | ** * "next" |
| 65 | ** |
| 66 | ** Return the RID of the matching artifact. Or return 0 if the name does not |
| 67 | ** match any known object. Or return -1 if the name is ambiguous. |
| 68 | ** |
| 69 | ** The zType parameter specifies the type of artifact: ci, t, w, e, g. |
| 70 | ** If zType is NULL or "" or "*" then any type of artifact will serve. |
| 71 | ** zType is "ci" in most use cases since we are usually searching for |
| 72 | ** a check-in. |
| 73 | */ |
| 74 | int symbolic_name_to_rid(const char *zTag, const char *zType){ |
| @@ -93,11 +93,11 @@ | |
| 93 | |
| 94 | /* special keywords: "prev", "previous", "current", and "next" */ |
| 95 | if( g.localOpen && (vid=db_lget_int("checkout",0))!=0 ){ |
| 96 | if( fossil_strcmp(zTag, "current")==0 ){ |
| 97 | rid = vid; |
| 98 | }else if( fossil_strcmp(zTag, "prev")==0 |
| 99 | || fossil_strcmp(zTag, "previous")==0 ){ |
| 100 | rid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", vid); |
| 101 | }else if( fossil_strcmp(zTag, "next")==0 ){ |
| 102 | rid = db_int(0, "SELECT cid FROM plink WHERE pid=%d" |
| 103 | " ORDER BY isprim DESC, mtime DESC", vid); |
| @@ -105,19 +105,19 @@ | |
| 105 | if( rid ) return rid; |
| 106 | } |
| 107 | |
| 108 | /* Date and times */ |
| 109 | if( memcmp(zTag, "date:", 5)==0 ){ |
| 110 | rid = db_int(0, |
| 111 | "SELECT objid FROM event" |
| 112 | " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'" |
| 113 | " ORDER BY mtime DESC LIMIT 1", |
| 114 | &zTag[5], zType); |
| 115 | return rid; |
| 116 | } |
| 117 | if( fossil_isdate(zTag) ){ |
| 118 | rid = db_int(0, |
| 119 | "SELECT objid FROM event" |
| 120 | " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'" |
| 121 | " ORDER BY mtime DESC LIMIT 1", |
| 122 | zTag, zType); |
| 123 | if( rid) return rid; |
| @@ -124,19 +124,19 @@ | |
| 124 | } |
| 125 | |
| 126 | /* Deprecated date & time formats: "local:" + date-time and |
| 127 | ** "utc:" + date-time */ |
| 128 | if( memcmp(zTag, "local:", 6)==0 ){ |
| 129 | rid = db_int(0, |
| 130 | "SELECT objid FROM event" |
| 131 | " WHERE mtime<=julianday(%Q) AND type GLOB '%q'" |
| 132 | " ORDER BY mtime DESC LIMIT 1", |
| 133 | &zTag[6], zType); |
| 134 | return rid; |
| 135 | } |
| 136 | if( memcmp(zTag, "utc:", 4)==0 ){ |
| 137 | rid = db_int(0, |
| 138 | "SELECT objid FROM event" |
| 139 | " WHERE mtime<=julianday('%qz') AND type GLOB '%q'" |
| 140 | " ORDER BY mtime DESC LIMIT 1", |
| 141 | &zTag[4], zType); |
| 142 | return rid; |
| @@ -153,11 +153,11 @@ | |
| 153 | " AND event.type GLOB '%q'", |
| 154 | &zTag[4], zType |
| 155 | ); |
| 156 | return rid; |
| 157 | } |
| 158 | |
| 159 | /* root:TAG -> The origin of the branch */ |
| 160 | if( memcmp(zTag, "root:", 5)==0 ){ |
| 161 | Stmt q; |
| 162 | int rc; |
| 163 | char *zBr; |
| @@ -255,11 +255,11 @@ | |
| 255 | for(i=0; fossil_isdigit(zTag[i]); i++){} |
| 256 | if( zTag[i]==0 ){ |
| 257 | if( strcmp(zType,"*")==0 ){ |
| 258 | rid = atoi(zTag); |
| 259 | }else{ |
| 260 | rid = db_int(0, |
| 261 | "SELECT event.objid" |
| 262 | " FROM event" |
| 263 | " WHERE event.objid=%s" |
| 264 | " AND event.type GLOB '%q'", zTag, zType); |
| 265 | } |
| @@ -278,12 +278,12 @@ | |
| 278 | ** the name as a tag. If multiple tags match, pick the latest. |
| 279 | ** If the input name matches "tag:*" then always resolve as a tag. |
| 280 | ** |
| 281 | ** If the input is not a tag, then try to match it as an ISO-8601 date |
| 282 | ** string YYYY-MM-DD HH:MM:SS and pick the nearest check-in to that date. |
| 283 | ** If the input is of the form "date:*" then always resolve the name as |
| 284 | ** a date. The forms "utc:*" and "local:" are deprecated. |
| 285 | ** |
| 286 | ** Return 0 on success. Return 1 if the name cannot be resolved. |
| 287 | ** Return 2 name is ambiguous. |
| 288 | */ |
| 289 | int name_to_uuid(Blob *pName, int iErrPriority, const char *zType){ |
| @@ -379,20 +379,20 @@ | |
| 379 | } |
| 380 | |
| 381 | /* |
| 382 | ** WEBPAGE: ambiguous |
| 383 | ** URL: /ambiguous?name=UUID&src=WEBPAGE |
| 384 | ** |
| 385 | ** The UUID given by the name parameter is ambiguous. Display a page |
| 386 | ** that shows all possible choices and let the user select between them. |
| 387 | */ |
| 388 | void ambiguous_page(void){ |
| 389 | Stmt q; |
| 390 | const char *zName = P("name"); |
| 391 | const char *zSrc = P("src"); |
| 392 | char *z; |
| 393 | |
| 394 | if( zName==0 || zName[0]==0 || zSrc==0 || zSrc[0]==0 ){ |
| 395 | fossil_redirect_home(); |
| 396 | } |
| 397 | style_header("Ambiguous Artifact ID"); |
| 398 | @ <p>The artifact id <b>%h(zName)</b> is ambiguous and might |
| 399 |
+2
-2
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -859,11 +859,11 @@ | ||
| 859 | 859 | fwrite(z, 1, n, toStdErr ? stderr : stdout); |
| 860 | 860 | fflush(toStdErr ? stderr : stdout); |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | /* |
| 864 | -** Force the standard output cursor to move to the beginning | |
| 864 | +** Force the standard output cursor to move to the beginning | |
| 865 | 865 | ** of a line, if it is not there already. |
| 866 | 866 | */ |
| 867 | 867 | void fossil_force_newline(void){ |
| 868 | 868 | if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); |
| 869 | 869 | } |
| @@ -918,11 +918,11 @@ | ||
| 918 | 918 | time_t now; |
| 919 | 919 | FILE *out; |
| 920 | 920 | const char *z; |
| 921 | 921 | int i; |
| 922 | 922 | va_list ap; |
| 923 | - static const char *azEnv[] = { "HTTP_HOST", "HTTP_USER_AGENT", | |
| 923 | + static const char *const azEnv[] = { "HTTP_HOST", "HTTP_USER_AGENT", | |
| 924 | 924 | "PATH_INFO", "QUERY_STRING", "REMOTE_ADDR", "REQUEST_METHOD", |
| 925 | 925 | "REQUEST_URI", "SCRIPT_NAME" }; |
| 926 | 926 | if( g.zErrlog==0 ) return; |
| 927 | 927 | out = fossil_fopen(g.zErrlog, "a"); |
| 928 | 928 | if( out==0 ) return; |
| 929 | 929 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -859,11 +859,11 @@ | |
| 859 | fwrite(z, 1, n, toStdErr ? stderr : stdout); |
| 860 | fflush(toStdErr ? stderr : stdout); |
| 861 | } |
| 862 | |
| 863 | /* |
| 864 | ** Force the standard output cursor to move to the beginning |
| 865 | ** of a line, if it is not there already. |
| 866 | */ |
| 867 | void fossil_force_newline(void){ |
| 868 | if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); |
| 869 | } |
| @@ -918,11 +918,11 @@ | |
| 918 | time_t now; |
| 919 | FILE *out; |
| 920 | const char *z; |
| 921 | int i; |
| 922 | va_list ap; |
| 923 | static const char *azEnv[] = { "HTTP_HOST", "HTTP_USER_AGENT", |
| 924 | "PATH_INFO", "QUERY_STRING", "REMOTE_ADDR", "REQUEST_METHOD", |
| 925 | "REQUEST_URI", "SCRIPT_NAME" }; |
| 926 | if( g.zErrlog==0 ) return; |
| 927 | out = fossil_fopen(g.zErrlog, "a"); |
| 928 | if( out==0 ) return; |
| 929 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -859,11 +859,11 @@ | |
| 859 | fwrite(z, 1, n, toStdErr ? stderr : stdout); |
| 860 | fflush(toStdErr ? stderr : stdout); |
| 861 | } |
| 862 | |
| 863 | /* |
| 864 | ** Force the standard output cursor to move to the beginning |
| 865 | ** of a line, if it is not there already. |
| 866 | */ |
| 867 | void fossil_force_newline(void){ |
| 868 | if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); |
| 869 | } |
| @@ -918,11 +918,11 @@ | |
| 918 | time_t now; |
| 919 | FILE *out; |
| 920 | const char *z; |
| 921 | int i; |
| 922 | va_list ap; |
| 923 | static const char *const azEnv[] = { "HTTP_HOST", "HTTP_USER_AGENT", |
| 924 | "PATH_INFO", "QUERY_STRING", "REMOTE_ADDR", "REQUEST_METHOD", |
| 925 | "REQUEST_URI", "SCRIPT_NAME" }; |
| 926 | if( g.zErrlog==0 ) return; |
| 927 | out = fossil_fopen(g.zErrlog, "a"); |
| 928 | if( out==0 ) return; |
| 929 |
+26
-25
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -47,18 +47,18 @@ | ||
| 47 | 47 | @ mtime INTEGER, -- When added. Seconds since 1970 |
| 48 | 48 | @ scom TEXT -- Optional text explaining why the shun occurred |
| 49 | 49 | @ ); |
| 50 | 50 | @ |
| 51 | 51 | @ -- Artifacts that should not be pushed are stored in the "private" |
| 52 | -@ -- table. | |
| 52 | +@ -- table. | |
| 53 | 53 | @ -- |
| 54 | 54 | @ CREATE TABLE IF NOT EXISTS private(rid INTEGER PRIMARY KEY); |
| 55 | 55 | @ |
| 56 | 56 | @ -- Some ticket content (such as the originators email address or contact |
| 57 | 57 | @ -- information) needs to be obscured to protect privacy. This is achieved |
| 58 | 58 | @ -- by storing an SHA1 hash of the content. For display, the hash is |
| 59 | -@ -- mapped back into the original text using this table. | |
| 59 | +@ -- mapped back into the original text using this table. | |
| 60 | 60 | @ -- |
| 61 | 61 | @ -- This table contains sensitive information and should not be shared |
| 62 | 62 | @ -- with unauthorized users. |
| 63 | 63 | @ -- |
| 64 | 64 | @ CREATE TABLE IF NOT EXISTS concealed( |
| @@ -153,11 +153,11 @@ | ||
| 153 | 153 | db_multi_exec( |
| 154 | 154 | "ALTER TABLE concealed ADD COLUMN mtime INTEGER;" |
| 155 | 155 | "UPDATE concealed SET mtime=now();" |
| 156 | 156 | ); |
| 157 | 157 | } |
| 158 | -} | |
| 158 | +} | |
| 159 | 159 | |
| 160 | 160 | /* |
| 161 | 161 | ** Variables used to store state information about an on-going "rebuild" |
| 162 | 162 | ** or "deconstruct". |
| 163 | 163 | */ |
| @@ -227,11 +227,11 @@ | ||
| 227 | 227 | if( size!=blob_size(pBase) ){ |
| 228 | 228 | db_multi_exec( |
| 229 | 229 | "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid |
| 230 | 230 | ); |
| 231 | 231 | } |
| 232 | - | |
| 232 | + | |
| 233 | 233 | /* Find all children of artifact rid */ |
| 234 | 234 | db_static_prepare(&q1, "SELECT rid FROM delta WHERE srcid=:rid"); |
| 235 | 235 | db_bind_int(&q1, ":rid", rid); |
| 236 | 236 | bag_init(&children); |
| 237 | 237 | while( db_step(&q1)==SQLITE_ROW ){ |
| @@ -240,11 +240,11 @@ | ||
| 240 | 240 | bag_insert(&children, cid); |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | nChild = bag_count(&children); |
| 244 | 244 | db_reset(&q1); |
| 245 | - | |
| 245 | + | |
| 246 | 246 | /* Crosslink the artifact */ |
| 247 | 247 | if( nChild==0 ){ |
| 248 | 248 | pUse = pBase; |
| 249 | 249 | }else{ |
| 250 | 250 | blob_copy(©, pBase); |
| @@ -262,11 +262,11 @@ | ||
| 262 | 262 | free(zUuid); |
| 263 | 263 | blob_reset(pUse); |
| 264 | 264 | } |
| 265 | 265 | assert( blob_is_reset(pUse) ); |
| 266 | 266 | rebuild_step_done(rid); |
| 267 | - | |
| 267 | + | |
| 268 | 268 | /* Call all children recursively */ |
| 269 | 269 | rid = 0; |
| 270 | 270 | for(cid=bag_first(&children), i=1; cid; cid=bag_next(&children, cid), i++){ |
| 271 | 271 | static Stmt q2; |
| 272 | 272 | int sz; |
| @@ -626,11 +626,11 @@ | ||
| 626 | 626 | if( activateWal ){ |
| 627 | 627 | db_multi_exec("PRAGMA journal_mode=WAL;"); |
| 628 | 628 | } |
| 629 | 629 | } |
| 630 | 630 | if( showStats ){ |
| 631 | - static struct { int idx; const char *zLabel; } aStat[] = { | |
| 631 | + static const struct { int idx; const char *zLabel; } aStat[] = { | |
| 632 | 632 | { CFTYPE_ANY, "Artifacts:" }, |
| 633 | 633 | { CFTYPE_MANIFEST, "Manifests:" }, |
| 634 | 634 | { CFTYPE_CLUSTER, "Clusters:" }, |
| 635 | 635 | { CFTYPE_CONTROL, "Tags:" }, |
| 636 | 636 | { CFTYPE_WIKI, "Wikis:" }, |
| @@ -687,11 +687,11 @@ | ||
| 687 | 687 | db_close(1); |
| 688 | 688 | db_open_repository(g.zRepositoryName); |
| 689 | 689 | } |
| 690 | 690 | db_begin_transaction(); |
| 691 | 691 | create_cluster(); |
| 692 | - db_end_transaction(0); | |
| 692 | + db_end_transaction(0); | |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /* |
| 696 | 696 | ** COMMAND: test-clusters |
| 697 | 697 | ** |
| @@ -700,11 +700,11 @@ | ||
| 700 | 700 | */ |
| 701 | 701 | void test_clusters_cmd(void){ |
| 702 | 702 | Bag pending; |
| 703 | 703 | Stmt q; |
| 704 | 704 | int n; |
| 705 | - | |
| 705 | + | |
| 706 | 706 | db_find_and_open_repository(0, 2); |
| 707 | 707 | bag_init(&pending); |
| 708 | 708 | db_multi_exec( |
| 709 | 709 | "CREATE TEMP TABLE xdone(x INTEGER PRIMARY KEY);" |
| 710 | 710 | "INSERT INTO xdone SELECT rid FROM unclustered;" |
| @@ -722,11 +722,11 @@ | ||
| 722 | 722 | db_finalize(&q); |
| 723 | 723 | while( bag_count(&pending)>0 ){ |
| 724 | 724 | Manifest *p; |
| 725 | 725 | int rid = bag_first(&pending); |
| 726 | 726 | int i; |
| 727 | - | |
| 727 | + | |
| 728 | 728 | bag_remove(&pending, rid); |
| 729 | 729 | p = manifest_get(rid, CFTYPE_CLUSTER, 0); |
| 730 | 730 | if( p==0 ){ |
| 731 | 731 | fossil_fatal("bad cluster: rid=%d", rid); |
| 732 | 732 | } |
| @@ -861,23 +861,24 @@ | ||
| 861 | 861 | zUtf8Name = fossil_filename_to_utf8(pEntry->d_name); |
| 862 | 862 | zSubpath = mprintf("%s/%s", zPath, zUtf8Name); |
| 863 | 863 | fossil_filename_free(zUtf8Name); |
| 864 | 864 | if( file_isdir(zSubpath)==1 ){ |
| 865 | 865 | recon_read_dir(zSubpath); |
| 866 | - } | |
| 867 | - blob_init(&path, 0, 0); | |
| 868 | - blob_appendf(&path, "%s", zSubpath); | |
| 869 | - if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ | |
| 870 | - fossil_fatal("some unknown error occurred while reading \"%s\"", | |
| 871 | - blob_str(&path)); | |
| 872 | - } | |
| 873 | - content_put(&aContent); | |
| 874 | - blob_reset(&path); | |
| 875 | - blob_reset(&aContent); | |
| 876 | - free(zSubpath); | |
| 877 | - fossil_print("\r%d", ++nFileRead); | |
| 878 | - fflush(stdout); | |
| 866 | + }else{ | |
| 867 | + blob_init(&path, 0, 0); | |
| 868 | + blob_appendf(&path, "%s", zSubpath); | |
| 869 | + if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ | |
| 870 | + fossil_fatal("some unknown error occurred while reading \"%s\"", | |
| 871 | + blob_str(&path)); | |
| 872 | + } | |
| 873 | + content_put(&aContent); | |
| 874 | + blob_reset(&path); | |
| 875 | + blob_reset(&aContent); | |
| 876 | + fossil_print("\r%d", ++nFileRead); | |
| 877 | + fflush(stdout); | |
| 878 | + } | |
| 879 | + free(zSubpath); | |
| 879 | 880 | } |
| 880 | 881 | closedir(d); |
| 881 | 882 | }else { |
| 882 | 883 | fossil_fatal("encountered error %d while trying to open \"%s\".", |
| 883 | 884 | errno, g.argv[3]); |
| @@ -922,11 +923,11 @@ | ||
| 922 | 923 | /* Skip the verify_before_commit() step on a reconstruct. Most artifacts |
| 923 | 924 | ** will have been changed and verification therefore takes a really, really |
| 924 | 925 | ** long time. |
| 925 | 926 | */ |
| 926 | 927 | verify_cancel(); |
| 927 | - | |
| 928 | + | |
| 928 | 929 | db_end_transaction(0); |
| 929 | 930 | fossil_print("project-id: %s\n", db_get("project-code", 0)); |
| 930 | 931 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 931 | 932 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 932 | 933 | fossil_print("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword); |
| @@ -942,11 +943,11 @@ | ||
| 942 | 943 | ** writes all artifacts to the file system. The DESTINATION directory |
| 943 | 944 | ** will be populated with subdirectories AA and files AA/BBBBBBBBB.., where |
| 944 | 945 | ** AABBBBBBBBB.. is the 40 character artifact ID, AA the first 2 characters. |
| 945 | 946 | ** If -L|--prefixlength is given, the length (default 2) of the directory |
| 946 | 947 | ** prefix can be set to 0,1,..,9 characters. |
| 947 | -** | |
| 948 | +** | |
| 948 | 949 | ** Options: |
| 949 | 950 | ** -R|--repository REPOSITORY deconstruct given REPOSITORY |
| 950 | 951 | ** -L|--prefixlength N set the length of the names of the DESTINATION |
| 951 | 952 | ** subdirectories to N |
| 952 | 953 | ** --private Include private artifacts. |
| 953 | 954 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -47,18 +47,18 @@ | |
| 47 | @ mtime INTEGER, -- When added. Seconds since 1970 |
| 48 | @ scom TEXT -- Optional text explaining why the shun occurred |
| 49 | @ ); |
| 50 | @ |
| 51 | @ -- Artifacts that should not be pushed are stored in the "private" |
| 52 | @ -- table. |
| 53 | @ -- |
| 54 | @ CREATE TABLE IF NOT EXISTS private(rid INTEGER PRIMARY KEY); |
| 55 | @ |
| 56 | @ -- Some ticket content (such as the originators email address or contact |
| 57 | @ -- information) needs to be obscured to protect privacy. This is achieved |
| 58 | @ -- by storing an SHA1 hash of the content. For display, the hash is |
| 59 | @ -- mapped back into the original text using this table. |
| 60 | @ -- |
| 61 | @ -- This table contains sensitive information and should not be shared |
| 62 | @ -- with unauthorized users. |
| 63 | @ -- |
| 64 | @ CREATE TABLE IF NOT EXISTS concealed( |
| @@ -153,11 +153,11 @@ | |
| 153 | db_multi_exec( |
| 154 | "ALTER TABLE concealed ADD COLUMN mtime INTEGER;" |
| 155 | "UPDATE concealed SET mtime=now();" |
| 156 | ); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | ** Variables used to store state information about an on-going "rebuild" |
| 162 | ** or "deconstruct". |
| 163 | */ |
| @@ -227,11 +227,11 @@ | |
| 227 | if( size!=blob_size(pBase) ){ |
| 228 | db_multi_exec( |
| 229 | "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid |
| 230 | ); |
| 231 | } |
| 232 | |
| 233 | /* Find all children of artifact rid */ |
| 234 | db_static_prepare(&q1, "SELECT rid FROM delta WHERE srcid=:rid"); |
| 235 | db_bind_int(&q1, ":rid", rid); |
| 236 | bag_init(&children); |
| 237 | while( db_step(&q1)==SQLITE_ROW ){ |
| @@ -240,11 +240,11 @@ | |
| 240 | bag_insert(&children, cid); |
| 241 | } |
| 242 | } |
| 243 | nChild = bag_count(&children); |
| 244 | db_reset(&q1); |
| 245 | |
| 246 | /* Crosslink the artifact */ |
| 247 | if( nChild==0 ){ |
| 248 | pUse = pBase; |
| 249 | }else{ |
| 250 | blob_copy(©, pBase); |
| @@ -262,11 +262,11 @@ | |
| 262 | free(zUuid); |
| 263 | blob_reset(pUse); |
| 264 | } |
| 265 | assert( blob_is_reset(pUse) ); |
| 266 | rebuild_step_done(rid); |
| 267 | |
| 268 | /* Call all children recursively */ |
| 269 | rid = 0; |
| 270 | for(cid=bag_first(&children), i=1; cid; cid=bag_next(&children, cid), i++){ |
| 271 | static Stmt q2; |
| 272 | int sz; |
| @@ -626,11 +626,11 @@ | |
| 626 | if( activateWal ){ |
| 627 | db_multi_exec("PRAGMA journal_mode=WAL;"); |
| 628 | } |
| 629 | } |
| 630 | if( showStats ){ |
| 631 | static struct { int idx; const char *zLabel; } aStat[] = { |
| 632 | { CFTYPE_ANY, "Artifacts:" }, |
| 633 | { CFTYPE_MANIFEST, "Manifests:" }, |
| 634 | { CFTYPE_CLUSTER, "Clusters:" }, |
| 635 | { CFTYPE_CONTROL, "Tags:" }, |
| 636 | { CFTYPE_WIKI, "Wikis:" }, |
| @@ -687,11 +687,11 @@ | |
| 687 | db_close(1); |
| 688 | db_open_repository(g.zRepositoryName); |
| 689 | } |
| 690 | db_begin_transaction(); |
| 691 | create_cluster(); |
| 692 | db_end_transaction(0); |
| 693 | } |
| 694 | |
| 695 | /* |
| 696 | ** COMMAND: test-clusters |
| 697 | ** |
| @@ -700,11 +700,11 @@ | |
| 700 | */ |
| 701 | void test_clusters_cmd(void){ |
| 702 | Bag pending; |
| 703 | Stmt q; |
| 704 | int n; |
| 705 | |
| 706 | db_find_and_open_repository(0, 2); |
| 707 | bag_init(&pending); |
| 708 | db_multi_exec( |
| 709 | "CREATE TEMP TABLE xdone(x INTEGER PRIMARY KEY);" |
| 710 | "INSERT INTO xdone SELECT rid FROM unclustered;" |
| @@ -722,11 +722,11 @@ | |
| 722 | db_finalize(&q); |
| 723 | while( bag_count(&pending)>0 ){ |
| 724 | Manifest *p; |
| 725 | int rid = bag_first(&pending); |
| 726 | int i; |
| 727 | |
| 728 | bag_remove(&pending, rid); |
| 729 | p = manifest_get(rid, CFTYPE_CLUSTER, 0); |
| 730 | if( p==0 ){ |
| 731 | fossil_fatal("bad cluster: rid=%d", rid); |
| 732 | } |
| @@ -861,23 +861,24 @@ | |
| 861 | zUtf8Name = fossil_filename_to_utf8(pEntry->d_name); |
| 862 | zSubpath = mprintf("%s/%s", zPath, zUtf8Name); |
| 863 | fossil_filename_free(zUtf8Name); |
| 864 | if( file_isdir(zSubpath)==1 ){ |
| 865 | recon_read_dir(zSubpath); |
| 866 | } |
| 867 | blob_init(&path, 0, 0); |
| 868 | blob_appendf(&path, "%s", zSubpath); |
| 869 | if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ |
| 870 | fossil_fatal("some unknown error occurred while reading \"%s\"", |
| 871 | blob_str(&path)); |
| 872 | } |
| 873 | content_put(&aContent); |
| 874 | blob_reset(&path); |
| 875 | blob_reset(&aContent); |
| 876 | free(zSubpath); |
| 877 | fossil_print("\r%d", ++nFileRead); |
| 878 | fflush(stdout); |
| 879 | } |
| 880 | closedir(d); |
| 881 | }else { |
| 882 | fossil_fatal("encountered error %d while trying to open \"%s\".", |
| 883 | errno, g.argv[3]); |
| @@ -922,11 +923,11 @@ | |
| 922 | /* Skip the verify_before_commit() step on a reconstruct. Most artifacts |
| 923 | ** will have been changed and verification therefore takes a really, really |
| 924 | ** long time. |
| 925 | */ |
| 926 | verify_cancel(); |
| 927 | |
| 928 | db_end_transaction(0); |
| 929 | fossil_print("project-id: %s\n", db_get("project-code", 0)); |
| 930 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 931 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 932 | fossil_print("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword); |
| @@ -942,11 +943,11 @@ | |
| 942 | ** writes all artifacts to the file system. The DESTINATION directory |
| 943 | ** will be populated with subdirectories AA and files AA/BBBBBBBBB.., where |
| 944 | ** AABBBBBBBBB.. is the 40 character artifact ID, AA the first 2 characters. |
| 945 | ** If -L|--prefixlength is given, the length (default 2) of the directory |
| 946 | ** prefix can be set to 0,1,..,9 characters. |
| 947 | ** |
| 948 | ** Options: |
| 949 | ** -R|--repository REPOSITORY deconstruct given REPOSITORY |
| 950 | ** -L|--prefixlength N set the length of the names of the DESTINATION |
| 951 | ** subdirectories to N |
| 952 | ** --private Include private artifacts. |
| 953 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -47,18 +47,18 @@ | |
| 47 | @ mtime INTEGER, -- When added. Seconds since 1970 |
| 48 | @ scom TEXT -- Optional text explaining why the shun occurred |
| 49 | @ ); |
| 50 | @ |
| 51 | @ -- Artifacts that should not be pushed are stored in the "private" |
| 52 | @ -- table. |
| 53 | @ -- |
| 54 | @ CREATE TABLE IF NOT EXISTS private(rid INTEGER PRIMARY KEY); |
| 55 | @ |
| 56 | @ -- Some ticket content (such as the originators email address or contact |
| 57 | @ -- information) needs to be obscured to protect privacy. This is achieved |
| 58 | @ -- by storing an SHA1 hash of the content. For display, the hash is |
| 59 | @ -- mapped back into the original text using this table. |
| 60 | @ -- |
| 61 | @ -- This table contains sensitive information and should not be shared |
| 62 | @ -- with unauthorized users. |
| 63 | @ -- |
| 64 | @ CREATE TABLE IF NOT EXISTS concealed( |
| @@ -153,11 +153,11 @@ | |
| 153 | db_multi_exec( |
| 154 | "ALTER TABLE concealed ADD COLUMN mtime INTEGER;" |
| 155 | "UPDATE concealed SET mtime=now();" |
| 156 | ); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | ** Variables used to store state information about an on-going "rebuild" |
| 162 | ** or "deconstruct". |
| 163 | */ |
| @@ -227,11 +227,11 @@ | |
| 227 | if( size!=blob_size(pBase) ){ |
| 228 | db_multi_exec( |
| 229 | "UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid |
| 230 | ); |
| 231 | } |
| 232 | |
| 233 | /* Find all children of artifact rid */ |
| 234 | db_static_prepare(&q1, "SELECT rid FROM delta WHERE srcid=:rid"); |
| 235 | db_bind_int(&q1, ":rid", rid); |
| 236 | bag_init(&children); |
| 237 | while( db_step(&q1)==SQLITE_ROW ){ |
| @@ -240,11 +240,11 @@ | |
| 240 | bag_insert(&children, cid); |
| 241 | } |
| 242 | } |
| 243 | nChild = bag_count(&children); |
| 244 | db_reset(&q1); |
| 245 | |
| 246 | /* Crosslink the artifact */ |
| 247 | if( nChild==0 ){ |
| 248 | pUse = pBase; |
| 249 | }else{ |
| 250 | blob_copy(©, pBase); |
| @@ -262,11 +262,11 @@ | |
| 262 | free(zUuid); |
| 263 | blob_reset(pUse); |
| 264 | } |
| 265 | assert( blob_is_reset(pUse) ); |
| 266 | rebuild_step_done(rid); |
| 267 | |
| 268 | /* Call all children recursively */ |
| 269 | rid = 0; |
| 270 | for(cid=bag_first(&children), i=1; cid; cid=bag_next(&children, cid), i++){ |
| 271 | static Stmt q2; |
| 272 | int sz; |
| @@ -626,11 +626,11 @@ | |
| 626 | if( activateWal ){ |
| 627 | db_multi_exec("PRAGMA journal_mode=WAL;"); |
| 628 | } |
| 629 | } |
| 630 | if( showStats ){ |
| 631 | static const struct { int idx; const char *zLabel; } aStat[] = { |
| 632 | { CFTYPE_ANY, "Artifacts:" }, |
| 633 | { CFTYPE_MANIFEST, "Manifests:" }, |
| 634 | { CFTYPE_CLUSTER, "Clusters:" }, |
| 635 | { CFTYPE_CONTROL, "Tags:" }, |
| 636 | { CFTYPE_WIKI, "Wikis:" }, |
| @@ -687,11 +687,11 @@ | |
| 687 | db_close(1); |
| 688 | db_open_repository(g.zRepositoryName); |
| 689 | } |
| 690 | db_begin_transaction(); |
| 691 | create_cluster(); |
| 692 | db_end_transaction(0); |
| 693 | } |
| 694 | |
| 695 | /* |
| 696 | ** COMMAND: test-clusters |
| 697 | ** |
| @@ -700,11 +700,11 @@ | |
| 700 | */ |
| 701 | void test_clusters_cmd(void){ |
| 702 | Bag pending; |
| 703 | Stmt q; |
| 704 | int n; |
| 705 | |
| 706 | db_find_and_open_repository(0, 2); |
| 707 | bag_init(&pending); |
| 708 | db_multi_exec( |
| 709 | "CREATE TEMP TABLE xdone(x INTEGER PRIMARY KEY);" |
| 710 | "INSERT INTO xdone SELECT rid FROM unclustered;" |
| @@ -722,11 +722,11 @@ | |
| 722 | db_finalize(&q); |
| 723 | while( bag_count(&pending)>0 ){ |
| 724 | Manifest *p; |
| 725 | int rid = bag_first(&pending); |
| 726 | int i; |
| 727 | |
| 728 | bag_remove(&pending, rid); |
| 729 | p = manifest_get(rid, CFTYPE_CLUSTER, 0); |
| 730 | if( p==0 ){ |
| 731 | fossil_fatal("bad cluster: rid=%d", rid); |
| 732 | } |
| @@ -861,23 +861,24 @@ | |
| 861 | zUtf8Name = fossil_filename_to_utf8(pEntry->d_name); |
| 862 | zSubpath = mprintf("%s/%s", zPath, zUtf8Name); |
| 863 | fossil_filename_free(zUtf8Name); |
| 864 | if( file_isdir(zSubpath)==1 ){ |
| 865 | recon_read_dir(zSubpath); |
| 866 | }else{ |
| 867 | blob_init(&path, 0, 0); |
| 868 | blob_appendf(&path, "%s", zSubpath); |
| 869 | if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ |
| 870 | fossil_fatal("some unknown error occurred while reading \"%s\"", |
| 871 | blob_str(&path)); |
| 872 | } |
| 873 | content_put(&aContent); |
| 874 | blob_reset(&path); |
| 875 | blob_reset(&aContent); |
| 876 | fossil_print("\r%d", ++nFileRead); |
| 877 | fflush(stdout); |
| 878 | } |
| 879 | free(zSubpath); |
| 880 | } |
| 881 | closedir(d); |
| 882 | }else { |
| 883 | fossil_fatal("encountered error %d while trying to open \"%s\".", |
| 884 | errno, g.argv[3]); |
| @@ -922,11 +923,11 @@ | |
| 923 | /* Skip the verify_before_commit() step on a reconstruct. Most artifacts |
| 924 | ** will have been changed and verification therefore takes a really, really |
| 925 | ** long time. |
| 926 | */ |
| 927 | verify_cancel(); |
| 928 | |
| 929 | db_end_transaction(0); |
| 930 | fossil_print("project-id: %s\n", db_get("project-code", 0)); |
| 931 | fossil_print("server-id: %s\n", db_get("server-code", 0)); |
| 932 | zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin); |
| 933 | fossil_print("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword); |
| @@ -942,11 +943,11 @@ | |
| 943 | ** writes all artifacts to the file system. The DESTINATION directory |
| 944 | ** will be populated with subdirectories AA and files AA/BBBBBBBBB.., where |
| 945 | ** AABBBBBBBBB.. is the 40 character artifact ID, AA the first 2 characters. |
| 946 | ** If -L|--prefixlength is given, the length (default 2) of the directory |
| 947 | ** prefix can be set to 0,1,..,9 characters. |
| 948 | ** |
| 949 | ** Options: |
| 950 | ** -R|--repository REPOSITORY deconstruct given REPOSITORY |
| 951 | ** -L|--prefixlength N set the length of the names of the DESTINATION |
| 952 | ** subdirectories to N |
| 953 | ** --private Include private artifacts. |
| 954 |
+37
-35
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -12,11 +12,11 @@ | ||
| 12 | 12 | ** Author contact information: |
| 13 | 13 | ** [email protected] |
| 14 | 14 | ** http://www.hwaci.com/drh/ |
| 15 | 15 | ** |
| 16 | 16 | ******************************************************************************* |
| 17 | -** | |
| 17 | +** | |
| 18 | 18 | ** Code to generate the ticket listings |
| 19 | 19 | */ |
| 20 | 20 | #include "config.h" |
| 21 | 21 | #include <time.h> |
| 22 | 22 | #include "report.h" |
| @@ -43,11 +43,11 @@ | ||
| 43 | 43 | if( !g.perm.RdTkt && !g.perm.NewTkt ){ login_needed(); return; } |
| 44 | 44 | style_header("Ticket Main Menu"); |
| 45 | 45 | if( g.thTrace ) Th_Trace("BEGIN_REPORTLIST<br />\n", -1); |
| 46 | 46 | zScript = ticket_reportlist_code(); |
| 47 | 47 | if( g.thTrace ) Th_Trace("BEGIN_REPORTLIST_SCRIPT<br />\n", -1); |
| 48 | - | |
| 48 | + | |
| 49 | 49 | blob_zero(&ril); |
| 50 | 50 | ticket_init(); |
| 51 | 51 | |
| 52 | 52 | db_prepare(&q, "SELECT rn, title, owner FROM reportfmt ORDER BY title"); |
| 53 | 53 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -70,14 +70,14 @@ | ||
| 70 | 70 | } |
| 71 | 71 | if( g.perm.TktFmt ){ |
| 72 | 72 | blob_appendf(&ril, "[%zcopy</a>] ", |
| 73 | 73 | href("%R/rptedit?rn=%d©=1", rn)); |
| 74 | 74 | } |
| 75 | - if( g.perm.Admin | |
| 75 | + if( g.perm.Admin | |
| 76 | 76 | || (g.perm.WrTkt && zOwner && fossil_strcmp(g.zLogin,zOwner)==0) |
| 77 | 77 | ){ |
| 78 | - blob_appendf(&ril, "[%zedit</a>]", | |
| 78 | + blob_appendf(&ril, "[%zedit</a>]", | |
| 79 | 79 | href("%R/rptedit?rn=%d", rn)); |
| 80 | 80 | } |
| 81 | 81 | if( g.perm.TktFmt ){ |
| 82 | 82 | blob_appendf(&ril, "[%zsql</a>]", |
| 83 | 83 | href("%R/rptsql?rn=%d", rn)); |
| @@ -85,13 +85,13 @@ | ||
| 85 | 85 | blob_appendf(&ril, "</li>\n"); |
| 86 | 86 | } |
| 87 | 87 | db_finalize(&q); |
| 88 | 88 | |
| 89 | 89 | Th_Store("report_items", blob_str(&ril)); |
| 90 | - | |
| 90 | + | |
| 91 | 91 | Th_Render(zScript); |
| 92 | - | |
| 92 | + | |
| 93 | 93 | blob_reset(&ril); |
| 94 | 94 | if( g.thTrace ) Th_Trace("END_REPORTLIST<br />\n", -1); |
| 95 | 95 | |
| 96 | 96 | style_footer(); |
| 97 | 97 | } |
| @@ -205,11 +205,11 @@ | ||
| 205 | 205 | } |
| 206 | 206 | case SQLITE_RECURSIVE: { |
| 207 | 207 | *(char**)pError = mprintf("recursive queries are not allowed"); |
| 208 | 208 | rc = SQLITE_DENY; |
| 209 | 209 | break; |
| 210 | - } | |
| 210 | + } | |
| 211 | 211 | default: { |
| 212 | 212 | *(char**)pError = mprintf("only SELECT statements are allowed"); |
| 213 | 213 | rc = SQLITE_DENY; |
| 214 | 214 | break; |
| 215 | 215 | } |
| @@ -262,14 +262,14 @@ | ||
| 262 | 262 | return mprintf("Semi-colon detected! " |
| 263 | 263 | "Only a single SQL statement is allowed"); |
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | - | |
| 267 | + | |
| 268 | 268 | /* Compile the statement and check for illegal accesses or syntax errors. */ |
| 269 | 269 | report_restrict_sql(&zErr); |
| 270 | - rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, &zTail); | |
| 270 | + rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt, &zTail); | |
| 271 | 271 | if( rc!=SQLITE_OK ){ |
| 272 | 272 | zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db)); |
| 273 | 273 | } |
| 274 | 274 | if( !sqlite3_stmt_readonly(pStmt) ){ |
| 275 | 275 | zErr = mprintf("SQL must not modify the database"); |
| @@ -383,11 +383,11 @@ | ||
| 383 | 383 | } |
| 384 | 384 | if( zTitle && zSQL ){ |
| 385 | 385 | if( zSQL[0]==0 ){ |
| 386 | 386 | zErr = "Please supply an SQL query statement"; |
| 387 | 387 | }else if( (zTitle = trim_string(zTitle))[0]==0 ){ |
| 388 | - zErr = "Please supply a title"; | |
| 388 | + zErr = "Please supply a title"; | |
| 389 | 389 | }else{ |
| 390 | 390 | zErr = verify_sql_statement(zSQL); |
| 391 | 391 | } |
| 392 | 392 | if( zErr==0 |
| 393 | 393 | && db_exists("SELECT 1 FROM reportfmt WHERE title=%Q and rn<>%d", |
| @@ -650,17 +650,17 @@ | ||
| 650 | 650 | ** The callback function for db_query |
| 651 | 651 | */ |
| 652 | 652 | static int generate_html( |
| 653 | 653 | void *pUser, /* Pointer to output state */ |
| 654 | 654 | int nArg, /* Number of columns in this result row */ |
| 655 | - char **azArg, /* Text of data in all columns */ | |
| 656 | - char **azName /* Names of the columns */ | |
| 655 | + const char **azArg, /* Text of data in all columns */ | |
| 656 | + const char **azName /* Names of the columns */ | |
| 657 | 657 | ){ |
| 658 | 658 | struct GenerateHTML *pState = (struct GenerateHTML*)pUser; |
| 659 | 659 | int i; |
| 660 | 660 | const char *zTid; /* Ticket UUID. (value of column named '#') */ |
| 661 | - char *zBg = 0; /* Use this background color */ | |
| 661 | + const char *zBg = 0; /* Use this background color */ | |
| 662 | 662 | |
| 663 | 663 | /* Do initialization |
| 664 | 664 | */ |
| 665 | 665 | if( pState->nCount==0 ){ |
| 666 | 666 | /* Turn off the authorizer. It is no longer doing anything since the |
| @@ -710,11 +710,11 @@ | ||
| 710 | 710 | /* The first time this routine is called, output a table header |
| 711 | 711 | */ |
| 712 | 712 | @ <thead><tr> |
| 713 | 713 | zTid = 0; |
| 714 | 714 | for(i=0; i<nArg; i++){ |
| 715 | - char *zName = azName[i]; | |
| 715 | + const char *zName = azName[i]; | |
| 716 | 716 | if( i==pState->iBg ) continue; |
| 717 | 717 | if( pState->iNewRow>=0 && i>=pState->iNewRow ){ |
| 718 | 718 | if( g.perm.Write && zTid ){ |
| 719 | 719 | @ <th> </th> |
| 720 | 720 | zTid = 0; |
| @@ -753,11 +753,11 @@ | ||
| 753 | 753 | zBg = pState->iBg>=0 ? azArg[pState->iBg] : 0; |
| 754 | 754 | if( zBg==0 ) zBg = "white"; |
| 755 | 755 | @ <tr style="background-color:%h(zBg)"> |
| 756 | 756 | zTid = 0; |
| 757 | 757 | for(i=0; i<nArg; i++){ |
| 758 | - char *zData; | |
| 758 | + const char *zData; | |
| 759 | 759 | if( i==pState->iBg ) continue; |
| 760 | 760 | zData = azArg[i]; |
| 761 | 761 | if( zData==0 ) zData = ""; |
| 762 | 762 | if( pState->iNewRow>=0 && i>=pState->iNewRow ){ |
| 763 | 763 | if( zTid && g.perm.Write ){ |
| @@ -815,12 +815,12 @@ | ||
| 815 | 815 | ** Output a row as a tab-separated line of text. |
| 816 | 816 | */ |
| 817 | 817 | static int output_tab_separated( |
| 818 | 818 | void *pUser, /* Pointer to row-count integer */ |
| 819 | 819 | int nArg, /* Number of columns in this result row */ |
| 820 | - char **azArg, /* Text of data in all columns */ | |
| 821 | - char **azName /* Names of the columns */ | |
| 820 | + const char **azArg, /* Text of data in all columns */ | |
| 821 | + const char **azName /* Names of the columns */ | |
| 822 | 822 | ){ |
| 823 | 823 | int *pCount = (int*)pUser; |
| 824 | 824 | int i; |
| 825 | 825 | |
| 826 | 826 | if( *pCount==0 ){ |
| @@ -840,18 +840,19 @@ | ||
| 840 | 840 | /* |
| 841 | 841 | ** Generate HTML that describes a color key. |
| 842 | 842 | */ |
| 843 | 843 | void output_color_key(const char *zClrKey, int horiz, char *zTabArgs){ |
| 844 | 844 | int i, j, k; |
| 845 | - char *zSafeKey, *zToFree; | |
| 845 | + const char *zSafeKey; | |
| 846 | + char *zToFree; | |
| 846 | 847 | while( fossil_isspace(*zClrKey) ) zClrKey++; |
| 847 | 848 | if( zClrKey[0]==0 ) return; |
| 848 | 849 | @ <table %s(zTabArgs)> |
| 849 | 850 | if( horiz ){ |
| 850 | 851 | @ <tr> |
| 851 | 852 | } |
| 852 | - zToFree = zSafeKey = mprintf("%h", zClrKey); | |
| 853 | + zSafeKey = zToFree = mprintf("%h", zClrKey); | |
| 853 | 854 | while( zSafeKey[0] ){ |
| 854 | 855 | while( fossil_isspace(*zSafeKey) ) zSafeKey++; |
| 855 | 856 | for(i=0; zSafeKey[i] && !fossil_isspace(zSafeKey[i]); i++){} |
| 856 | 857 | for(j=i; fossil_isspace(zSafeKey[j]); j++){} |
| 857 | 858 | for(k=j; zSafeKey[k] && zSafeKey[k]!='\n' && zSafeKey[k]!='\r'; k++){} |
| @@ -873,23 +874,24 @@ | ||
| 873 | 874 | |
| 874 | 875 | /* |
| 875 | 876 | ** Execute a single read-only SQL statement. Invoke xCallback() on each |
| 876 | 877 | ** row. |
| 877 | 878 | */ |
| 878 | -int sqlite3_exec_readonly( | |
| 879 | +static int db_exec_readonly( | |
| 879 | 880 | sqlite3 *db, /* The database on which the SQL executes */ |
| 880 | 881 | const char *zSql, /* The SQL to be executed */ |
| 881 | - sqlite3_callback xCallback, /* Invoke this callback routine */ | |
| 882 | + int (*xCallback)(void*,int,const char**, const char**), | |
| 883 | + /* Invoke this callback routine */ | |
| 882 | 884 | void *pArg, /* First argument to xCallback() */ |
| 883 | 885 | char **pzErrMsg /* Write error messages here */ |
| 884 | 886 | ){ |
| 885 | 887 | int rc = SQLITE_OK; /* Return code */ |
| 886 | 888 | const char *zLeftover; /* Tail of unprocessed SQL */ |
| 887 | 889 | sqlite3_stmt *pStmt = 0; /* The current SQL statement */ |
| 888 | - char **azCols = 0; /* Names of result columns */ | |
| 890 | + const char **azCols = 0; /* Names of result columns */ | |
| 889 | 891 | int nCol; /* Number of columns of output */ |
| 890 | - char **azVals = 0; /* Text of all output columns */ | |
| 892 | + const char **azVals = 0; /* Text of all output columns */ | |
| 891 | 893 | int i; /* Loop counter */ |
| 892 | 894 | |
| 893 | 895 | pStmt = 0; |
| 894 | 896 | rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover); |
| 895 | 897 | assert( rc==SQLITE_OK || pStmt==0 ); |
| @@ -912,15 +914,15 @@ | ||
| 912 | 914 | azVals = fossil_malloc(2*nCol*sizeof(const char*) + 1); |
| 913 | 915 | while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){ |
| 914 | 916 | if( azCols==0 ){ |
| 915 | 917 | azCols = &azVals[nCol]; |
| 916 | 918 | for(i=0; i<nCol; i++){ |
| 917 | - azCols[i] = (char *)sqlite3_column_name(pStmt, i); | |
| 919 | + azCols[i] = sqlite3_column_name(pStmt, i); | |
| 918 | 920 | } |
| 919 | 921 | } |
| 920 | 922 | for(i=0; i<nCol; i++){ |
| 921 | - azVals[i] = (char *)sqlite3_column_text(pStmt, i); | |
| 923 | + azVals[i] = (const char *)sqlite3_column_text(pStmt, i); | |
| 922 | 924 | } |
| 923 | 925 | if( xCallback(pArg, nCol, azVals, azCols) ){ |
| 924 | 926 | break; |
| 925 | 927 | } |
| 926 | 928 | } |
| @@ -1065,13 +1067,13 @@ | ||
| 1065 | 1067 | count = 0; |
| 1066 | 1068 | if( !tabs ){ |
| 1067 | 1069 | struct GenerateHTML sState; |
| 1068 | 1070 | |
| 1069 | 1071 | db_multi_exec("PRAGMA empty_result_callbacks=ON"); |
| 1070 | - style_submenu_element("Raw", "Raw", | |
| 1072 | + style_submenu_element("Raw", "Raw", | |
| 1071 | 1073 | "rptview?tablist=1&%h", PD("QUERY_STRING","")); |
| 1072 | - if( g.perm.Admin | |
| 1074 | + if( g.perm.Admin | |
| 1073 | 1075 | || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){ |
| 1074 | 1076 | style_submenu_element("Edit", "Edit", "rptedit?rn=%d", rn); |
| 1075 | 1077 | } |
| 1076 | 1078 | if( g.perm.TktFmt ){ |
| 1077 | 1079 | style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn); |
| @@ -1079,18 +1081,18 @@ | ||
| 1079 | 1081 | if( g.perm.NewTkt ){ |
| 1080 | 1082 | style_submenu_element("New Ticket", "Create a new ticket", |
| 1081 | 1083 | "%s/tktnew", g.zTop); |
| 1082 | 1084 | } |
| 1083 | 1085 | style_header(zTitle); |
| 1084 | - output_color_key(zClrKey, 1, | |
| 1086 | + output_color_key(zClrKey, 1, | |
| 1085 | 1087 | "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\""); |
| 1086 | 1088 | @ <table border="1" cellpadding="2" cellspacing="0" class="report" |
| 1087 | 1089 | @ id="reportTable"> |
| 1088 | 1090 | sState.rn = rn; |
| 1089 | 1091 | sState.nCount = 0; |
| 1090 | 1092 | report_restrict_sql(&zErr1); |
| 1091 | - sqlite3_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2); | |
| 1093 | + db_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2); | |
| 1092 | 1094 | report_unrestrict_sql(); |
| 1093 | 1095 | @ </tbody></table> |
| 1094 | 1096 | if( zErr1 ){ |
| 1095 | 1097 | @ <p class="reportError">Error: %h(zErr1)</p> |
| 1096 | 1098 | }else if( zErr2 ){ |
| @@ -1098,11 +1100,11 @@ | ||
| 1098 | 1100 | } |
| 1099 | 1101 | output_table_sorting_javascript("reportTable",""); |
| 1100 | 1102 | style_footer(); |
| 1101 | 1103 | }else{ |
| 1102 | 1104 | report_restrict_sql(&zErr1); |
| 1103 | - sqlite3_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2); | |
| 1105 | + db_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2); | |
| 1104 | 1106 | report_unrestrict_sql(); |
| 1105 | 1107 | cgi_set_content_type("text/plain"); |
| 1106 | 1108 | } |
| 1107 | 1109 | } |
| 1108 | 1110 | |
| @@ -1177,22 +1179,22 @@ | ||
| 1177 | 1179 | if( j>i ){ |
| 1178 | 1180 | fossil_print("%*s", j-i, ""); |
| 1179 | 1181 | } |
| 1180 | 1182 | z += j; |
| 1181 | 1183 | } |
| 1182 | - break; | |
| 1184 | + break; | |
| 1183 | 1185 | } |
| 1184 | 1186 | } |
| 1185 | 1187 | |
| 1186 | 1188 | /* |
| 1187 | 1189 | ** Output a row as a tab-separated line of text. |
| 1188 | 1190 | */ |
| 1189 | 1191 | int output_separated_file( |
| 1190 | 1192 | void *pUser, /* Pointer to row-count integer */ |
| 1191 | 1193 | int nArg, /* Number of columns in this result row */ |
| 1192 | - char **azArg, /* Text of data in all columns */ | |
| 1193 | - char **azName /* Names of the columns */ | |
| 1194 | + const char **azArg, /* Text of data in all columns */ | |
| 1195 | + const char **azName /* Names of the columns */ | |
| 1194 | 1196 | ){ |
| 1195 | 1197 | int *pCount = (int*)pUser; |
| 1196 | 1198 | int i; |
| 1197 | 1199 | |
| 1198 | 1200 | if( *pCount==0 ){ |
| @@ -1212,11 +1214,11 @@ | ||
| 1212 | 1214 | /* |
| 1213 | 1215 | ** Generate a report. The rn query parameter is the report number. |
| 1214 | 1216 | ** The output is written to stdout as flat file. The zFilter parameter |
| 1215 | 1217 | ** is a full WHERE-condition. |
| 1216 | 1218 | */ |
| 1217 | -void rptshow( | |
| 1219 | +void rptshow( | |
| 1218 | 1220 | const char *zRep, |
| 1219 | 1221 | const char *zSepIn, |
| 1220 | 1222 | const char *zFilter, |
| 1221 | 1223 | tTktShowEncoding enc |
| 1222 | 1224 | ){ |
| @@ -1251,11 +1253,11 @@ | ||
| 1251 | 1253 | } |
| 1252 | 1254 | count = 0; |
| 1253 | 1255 | tktEncode = enc; |
| 1254 | 1256 | zSep = zSepIn; |
| 1255 | 1257 | report_restrict_sql(&zErr1); |
| 1256 | - sqlite3_exec_readonly(g.db, zSql, output_separated_file, &count, &zErr2); | |
| 1258 | + db_exec_readonly(g.db, zSql, output_separated_file, &count, &zErr2); | |
| 1257 | 1259 | report_unrestrict_sql(); |
| 1258 | 1260 | if( zFilter ){ |
| 1259 | 1261 | free(zSql); |
| 1260 | 1262 | } |
| 1261 | 1263 | } |
| 1262 | 1264 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -12,11 +12,11 @@ | |
| 12 | ** Author contact information: |
| 13 | ** [email protected] |
| 14 | ** http://www.hwaci.com/drh/ |
| 15 | ** |
| 16 | ******************************************************************************* |
| 17 | ** |
| 18 | ** Code to generate the ticket listings |
| 19 | */ |
| 20 | #include "config.h" |
| 21 | #include <time.h> |
| 22 | #include "report.h" |
| @@ -43,11 +43,11 @@ | |
| 43 | if( !g.perm.RdTkt && !g.perm.NewTkt ){ login_needed(); return; } |
| 44 | style_header("Ticket Main Menu"); |
| 45 | if( g.thTrace ) Th_Trace("BEGIN_REPORTLIST<br />\n", -1); |
| 46 | zScript = ticket_reportlist_code(); |
| 47 | if( g.thTrace ) Th_Trace("BEGIN_REPORTLIST_SCRIPT<br />\n", -1); |
| 48 | |
| 49 | blob_zero(&ril); |
| 50 | ticket_init(); |
| 51 | |
| 52 | db_prepare(&q, "SELECT rn, title, owner FROM reportfmt ORDER BY title"); |
| 53 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -70,14 +70,14 @@ | |
| 70 | } |
| 71 | if( g.perm.TktFmt ){ |
| 72 | blob_appendf(&ril, "[%zcopy</a>] ", |
| 73 | href("%R/rptedit?rn=%d©=1", rn)); |
| 74 | } |
| 75 | if( g.perm.Admin |
| 76 | || (g.perm.WrTkt && zOwner && fossil_strcmp(g.zLogin,zOwner)==0) |
| 77 | ){ |
| 78 | blob_appendf(&ril, "[%zedit</a>]", |
| 79 | href("%R/rptedit?rn=%d", rn)); |
| 80 | } |
| 81 | if( g.perm.TktFmt ){ |
| 82 | blob_appendf(&ril, "[%zsql</a>]", |
| 83 | href("%R/rptsql?rn=%d", rn)); |
| @@ -85,13 +85,13 @@ | |
| 85 | blob_appendf(&ril, "</li>\n"); |
| 86 | } |
| 87 | db_finalize(&q); |
| 88 | |
| 89 | Th_Store("report_items", blob_str(&ril)); |
| 90 | |
| 91 | Th_Render(zScript); |
| 92 | |
| 93 | blob_reset(&ril); |
| 94 | if( g.thTrace ) Th_Trace("END_REPORTLIST<br />\n", -1); |
| 95 | |
| 96 | style_footer(); |
| 97 | } |
| @@ -205,11 +205,11 @@ | |
| 205 | } |
| 206 | case SQLITE_RECURSIVE: { |
| 207 | *(char**)pError = mprintf("recursive queries are not allowed"); |
| 208 | rc = SQLITE_DENY; |
| 209 | break; |
| 210 | } |
| 211 | default: { |
| 212 | *(char**)pError = mprintf("only SELECT statements are allowed"); |
| 213 | rc = SQLITE_DENY; |
| 214 | break; |
| 215 | } |
| @@ -262,14 +262,14 @@ | |
| 262 | return mprintf("Semi-colon detected! " |
| 263 | "Only a single SQL statement is allowed"); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | /* Compile the statement and check for illegal accesses or syntax errors. */ |
| 269 | report_restrict_sql(&zErr); |
| 270 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, &zTail); |
| 271 | if( rc!=SQLITE_OK ){ |
| 272 | zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db)); |
| 273 | } |
| 274 | if( !sqlite3_stmt_readonly(pStmt) ){ |
| 275 | zErr = mprintf("SQL must not modify the database"); |
| @@ -383,11 +383,11 @@ | |
| 383 | } |
| 384 | if( zTitle && zSQL ){ |
| 385 | if( zSQL[0]==0 ){ |
| 386 | zErr = "Please supply an SQL query statement"; |
| 387 | }else if( (zTitle = trim_string(zTitle))[0]==0 ){ |
| 388 | zErr = "Please supply a title"; |
| 389 | }else{ |
| 390 | zErr = verify_sql_statement(zSQL); |
| 391 | } |
| 392 | if( zErr==0 |
| 393 | && db_exists("SELECT 1 FROM reportfmt WHERE title=%Q and rn<>%d", |
| @@ -650,17 +650,17 @@ | |
| 650 | ** The callback function for db_query |
| 651 | */ |
| 652 | static int generate_html( |
| 653 | void *pUser, /* Pointer to output state */ |
| 654 | int nArg, /* Number of columns in this result row */ |
| 655 | char **azArg, /* Text of data in all columns */ |
| 656 | char **azName /* Names of the columns */ |
| 657 | ){ |
| 658 | struct GenerateHTML *pState = (struct GenerateHTML*)pUser; |
| 659 | int i; |
| 660 | const char *zTid; /* Ticket UUID. (value of column named '#') */ |
| 661 | char *zBg = 0; /* Use this background color */ |
| 662 | |
| 663 | /* Do initialization |
| 664 | */ |
| 665 | if( pState->nCount==0 ){ |
| 666 | /* Turn off the authorizer. It is no longer doing anything since the |
| @@ -710,11 +710,11 @@ | |
| 710 | /* The first time this routine is called, output a table header |
| 711 | */ |
| 712 | @ <thead><tr> |
| 713 | zTid = 0; |
| 714 | for(i=0; i<nArg; i++){ |
| 715 | char *zName = azName[i]; |
| 716 | if( i==pState->iBg ) continue; |
| 717 | if( pState->iNewRow>=0 && i>=pState->iNewRow ){ |
| 718 | if( g.perm.Write && zTid ){ |
| 719 | @ <th> </th> |
| 720 | zTid = 0; |
| @@ -753,11 +753,11 @@ | |
| 753 | zBg = pState->iBg>=0 ? azArg[pState->iBg] : 0; |
| 754 | if( zBg==0 ) zBg = "white"; |
| 755 | @ <tr style="background-color:%h(zBg)"> |
| 756 | zTid = 0; |
| 757 | for(i=0; i<nArg; i++){ |
| 758 | char *zData; |
| 759 | if( i==pState->iBg ) continue; |
| 760 | zData = azArg[i]; |
| 761 | if( zData==0 ) zData = ""; |
| 762 | if( pState->iNewRow>=0 && i>=pState->iNewRow ){ |
| 763 | if( zTid && g.perm.Write ){ |
| @@ -815,12 +815,12 @@ | |
| 815 | ** Output a row as a tab-separated line of text. |
| 816 | */ |
| 817 | static int output_tab_separated( |
| 818 | void *pUser, /* Pointer to row-count integer */ |
| 819 | int nArg, /* Number of columns in this result row */ |
| 820 | char **azArg, /* Text of data in all columns */ |
| 821 | char **azName /* Names of the columns */ |
| 822 | ){ |
| 823 | int *pCount = (int*)pUser; |
| 824 | int i; |
| 825 | |
| 826 | if( *pCount==0 ){ |
| @@ -840,18 +840,19 @@ | |
| 840 | /* |
| 841 | ** Generate HTML that describes a color key. |
| 842 | */ |
| 843 | void output_color_key(const char *zClrKey, int horiz, char *zTabArgs){ |
| 844 | int i, j, k; |
| 845 | char *zSafeKey, *zToFree; |
| 846 | while( fossil_isspace(*zClrKey) ) zClrKey++; |
| 847 | if( zClrKey[0]==0 ) return; |
| 848 | @ <table %s(zTabArgs)> |
| 849 | if( horiz ){ |
| 850 | @ <tr> |
| 851 | } |
| 852 | zToFree = zSafeKey = mprintf("%h", zClrKey); |
| 853 | while( zSafeKey[0] ){ |
| 854 | while( fossil_isspace(*zSafeKey) ) zSafeKey++; |
| 855 | for(i=0; zSafeKey[i] && !fossil_isspace(zSafeKey[i]); i++){} |
| 856 | for(j=i; fossil_isspace(zSafeKey[j]); j++){} |
| 857 | for(k=j; zSafeKey[k] && zSafeKey[k]!='\n' && zSafeKey[k]!='\r'; k++){} |
| @@ -873,23 +874,24 @@ | |
| 873 | |
| 874 | /* |
| 875 | ** Execute a single read-only SQL statement. Invoke xCallback() on each |
| 876 | ** row. |
| 877 | */ |
| 878 | int sqlite3_exec_readonly( |
| 879 | sqlite3 *db, /* The database on which the SQL executes */ |
| 880 | const char *zSql, /* The SQL to be executed */ |
| 881 | sqlite3_callback xCallback, /* Invoke this callback routine */ |
| 882 | void *pArg, /* First argument to xCallback() */ |
| 883 | char **pzErrMsg /* Write error messages here */ |
| 884 | ){ |
| 885 | int rc = SQLITE_OK; /* Return code */ |
| 886 | const char *zLeftover; /* Tail of unprocessed SQL */ |
| 887 | sqlite3_stmt *pStmt = 0; /* The current SQL statement */ |
| 888 | char **azCols = 0; /* Names of result columns */ |
| 889 | int nCol; /* Number of columns of output */ |
| 890 | char **azVals = 0; /* Text of all output columns */ |
| 891 | int i; /* Loop counter */ |
| 892 | |
| 893 | pStmt = 0; |
| 894 | rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover); |
| 895 | assert( rc==SQLITE_OK || pStmt==0 ); |
| @@ -912,15 +914,15 @@ | |
| 912 | azVals = fossil_malloc(2*nCol*sizeof(const char*) + 1); |
| 913 | while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){ |
| 914 | if( azCols==0 ){ |
| 915 | azCols = &azVals[nCol]; |
| 916 | for(i=0; i<nCol; i++){ |
| 917 | azCols[i] = (char *)sqlite3_column_name(pStmt, i); |
| 918 | } |
| 919 | } |
| 920 | for(i=0; i<nCol; i++){ |
| 921 | azVals[i] = (char *)sqlite3_column_text(pStmt, i); |
| 922 | } |
| 923 | if( xCallback(pArg, nCol, azVals, azCols) ){ |
| 924 | break; |
| 925 | } |
| 926 | } |
| @@ -1065,13 +1067,13 @@ | |
| 1065 | count = 0; |
| 1066 | if( !tabs ){ |
| 1067 | struct GenerateHTML sState; |
| 1068 | |
| 1069 | db_multi_exec("PRAGMA empty_result_callbacks=ON"); |
| 1070 | style_submenu_element("Raw", "Raw", |
| 1071 | "rptview?tablist=1&%h", PD("QUERY_STRING","")); |
| 1072 | if( g.perm.Admin |
| 1073 | || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){ |
| 1074 | style_submenu_element("Edit", "Edit", "rptedit?rn=%d", rn); |
| 1075 | } |
| 1076 | if( g.perm.TktFmt ){ |
| 1077 | style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn); |
| @@ -1079,18 +1081,18 @@ | |
| 1079 | if( g.perm.NewTkt ){ |
| 1080 | style_submenu_element("New Ticket", "Create a new ticket", |
| 1081 | "%s/tktnew", g.zTop); |
| 1082 | } |
| 1083 | style_header(zTitle); |
| 1084 | output_color_key(zClrKey, 1, |
| 1085 | "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\""); |
| 1086 | @ <table border="1" cellpadding="2" cellspacing="0" class="report" |
| 1087 | @ id="reportTable"> |
| 1088 | sState.rn = rn; |
| 1089 | sState.nCount = 0; |
| 1090 | report_restrict_sql(&zErr1); |
| 1091 | sqlite3_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2); |
| 1092 | report_unrestrict_sql(); |
| 1093 | @ </tbody></table> |
| 1094 | if( zErr1 ){ |
| 1095 | @ <p class="reportError">Error: %h(zErr1)</p> |
| 1096 | }else if( zErr2 ){ |
| @@ -1098,11 +1100,11 @@ | |
| 1098 | } |
| 1099 | output_table_sorting_javascript("reportTable",""); |
| 1100 | style_footer(); |
| 1101 | }else{ |
| 1102 | report_restrict_sql(&zErr1); |
| 1103 | sqlite3_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2); |
| 1104 | report_unrestrict_sql(); |
| 1105 | cgi_set_content_type("text/plain"); |
| 1106 | } |
| 1107 | } |
| 1108 | |
| @@ -1177,22 +1179,22 @@ | |
| 1177 | if( j>i ){ |
| 1178 | fossil_print("%*s", j-i, ""); |
| 1179 | } |
| 1180 | z += j; |
| 1181 | } |
| 1182 | break; |
| 1183 | } |
| 1184 | } |
| 1185 | |
| 1186 | /* |
| 1187 | ** Output a row as a tab-separated line of text. |
| 1188 | */ |
| 1189 | int output_separated_file( |
| 1190 | void *pUser, /* Pointer to row-count integer */ |
| 1191 | int nArg, /* Number of columns in this result row */ |
| 1192 | char **azArg, /* Text of data in all columns */ |
| 1193 | char **azName /* Names of the columns */ |
| 1194 | ){ |
| 1195 | int *pCount = (int*)pUser; |
| 1196 | int i; |
| 1197 | |
| 1198 | if( *pCount==0 ){ |
| @@ -1212,11 +1214,11 @@ | |
| 1212 | /* |
| 1213 | ** Generate a report. The rn query parameter is the report number. |
| 1214 | ** The output is written to stdout as flat file. The zFilter parameter |
| 1215 | ** is a full WHERE-condition. |
| 1216 | */ |
| 1217 | void rptshow( |
| 1218 | const char *zRep, |
| 1219 | const char *zSepIn, |
| 1220 | const char *zFilter, |
| 1221 | tTktShowEncoding enc |
| 1222 | ){ |
| @@ -1251,11 +1253,11 @@ | |
| 1251 | } |
| 1252 | count = 0; |
| 1253 | tktEncode = enc; |
| 1254 | zSep = zSepIn; |
| 1255 | report_restrict_sql(&zErr1); |
| 1256 | sqlite3_exec_readonly(g.db, zSql, output_separated_file, &count, &zErr2); |
| 1257 | report_unrestrict_sql(); |
| 1258 | if( zFilter ){ |
| 1259 | free(zSql); |
| 1260 | } |
| 1261 | } |
| 1262 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -12,11 +12,11 @@ | |
| 12 | ** Author contact information: |
| 13 | ** [email protected] |
| 14 | ** http://www.hwaci.com/drh/ |
| 15 | ** |
| 16 | ******************************************************************************* |
| 17 | ** |
| 18 | ** Code to generate the ticket listings |
| 19 | */ |
| 20 | #include "config.h" |
| 21 | #include <time.h> |
| 22 | #include "report.h" |
| @@ -43,11 +43,11 @@ | |
| 43 | if( !g.perm.RdTkt && !g.perm.NewTkt ){ login_needed(); return; } |
| 44 | style_header("Ticket Main Menu"); |
| 45 | if( g.thTrace ) Th_Trace("BEGIN_REPORTLIST<br />\n", -1); |
| 46 | zScript = ticket_reportlist_code(); |
| 47 | if( g.thTrace ) Th_Trace("BEGIN_REPORTLIST_SCRIPT<br />\n", -1); |
| 48 | |
| 49 | blob_zero(&ril); |
| 50 | ticket_init(); |
| 51 | |
| 52 | db_prepare(&q, "SELECT rn, title, owner FROM reportfmt ORDER BY title"); |
| 53 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -70,14 +70,14 @@ | |
| 70 | } |
| 71 | if( g.perm.TktFmt ){ |
| 72 | blob_appendf(&ril, "[%zcopy</a>] ", |
| 73 | href("%R/rptedit?rn=%d©=1", rn)); |
| 74 | } |
| 75 | if( g.perm.Admin |
| 76 | || (g.perm.WrTkt && zOwner && fossil_strcmp(g.zLogin,zOwner)==0) |
| 77 | ){ |
| 78 | blob_appendf(&ril, "[%zedit</a>]", |
| 79 | href("%R/rptedit?rn=%d", rn)); |
| 80 | } |
| 81 | if( g.perm.TktFmt ){ |
| 82 | blob_appendf(&ril, "[%zsql</a>]", |
| 83 | href("%R/rptsql?rn=%d", rn)); |
| @@ -85,13 +85,13 @@ | |
| 85 | blob_appendf(&ril, "</li>\n"); |
| 86 | } |
| 87 | db_finalize(&q); |
| 88 | |
| 89 | Th_Store("report_items", blob_str(&ril)); |
| 90 | |
| 91 | Th_Render(zScript); |
| 92 | |
| 93 | blob_reset(&ril); |
| 94 | if( g.thTrace ) Th_Trace("END_REPORTLIST<br />\n", -1); |
| 95 | |
| 96 | style_footer(); |
| 97 | } |
| @@ -205,11 +205,11 @@ | |
| 205 | } |
| 206 | case SQLITE_RECURSIVE: { |
| 207 | *(char**)pError = mprintf("recursive queries are not allowed"); |
| 208 | rc = SQLITE_DENY; |
| 209 | break; |
| 210 | } |
| 211 | default: { |
| 212 | *(char**)pError = mprintf("only SELECT statements are allowed"); |
| 213 | rc = SQLITE_DENY; |
| 214 | break; |
| 215 | } |
| @@ -262,14 +262,14 @@ | |
| 262 | return mprintf("Semi-colon detected! " |
| 263 | "Only a single SQL statement is allowed"); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | /* Compile the statement and check for illegal accesses or syntax errors. */ |
| 269 | report_restrict_sql(&zErr); |
| 270 | rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt, &zTail); |
| 271 | if( rc!=SQLITE_OK ){ |
| 272 | zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db)); |
| 273 | } |
| 274 | if( !sqlite3_stmt_readonly(pStmt) ){ |
| 275 | zErr = mprintf("SQL must not modify the database"); |
| @@ -383,11 +383,11 @@ | |
| 383 | } |
| 384 | if( zTitle && zSQL ){ |
| 385 | if( zSQL[0]==0 ){ |
| 386 | zErr = "Please supply an SQL query statement"; |
| 387 | }else if( (zTitle = trim_string(zTitle))[0]==0 ){ |
| 388 | zErr = "Please supply a title"; |
| 389 | }else{ |
| 390 | zErr = verify_sql_statement(zSQL); |
| 391 | } |
| 392 | if( zErr==0 |
| 393 | && db_exists("SELECT 1 FROM reportfmt WHERE title=%Q and rn<>%d", |
| @@ -650,17 +650,17 @@ | |
| 650 | ** The callback function for db_query |
| 651 | */ |
| 652 | static int generate_html( |
| 653 | void *pUser, /* Pointer to output state */ |
| 654 | int nArg, /* Number of columns in this result row */ |
| 655 | const char **azArg, /* Text of data in all columns */ |
| 656 | const char **azName /* Names of the columns */ |
| 657 | ){ |
| 658 | struct GenerateHTML *pState = (struct GenerateHTML*)pUser; |
| 659 | int i; |
| 660 | const char *zTid; /* Ticket UUID. (value of column named '#') */ |
| 661 | const char *zBg = 0; /* Use this background color */ |
| 662 | |
| 663 | /* Do initialization |
| 664 | */ |
| 665 | if( pState->nCount==0 ){ |
| 666 | /* Turn off the authorizer. It is no longer doing anything since the |
| @@ -710,11 +710,11 @@ | |
| 710 | /* The first time this routine is called, output a table header |
| 711 | */ |
| 712 | @ <thead><tr> |
| 713 | zTid = 0; |
| 714 | for(i=0; i<nArg; i++){ |
| 715 | const char *zName = azName[i]; |
| 716 | if( i==pState->iBg ) continue; |
| 717 | if( pState->iNewRow>=0 && i>=pState->iNewRow ){ |
| 718 | if( g.perm.Write && zTid ){ |
| 719 | @ <th> </th> |
| 720 | zTid = 0; |
| @@ -753,11 +753,11 @@ | |
| 753 | zBg = pState->iBg>=0 ? azArg[pState->iBg] : 0; |
| 754 | if( zBg==0 ) zBg = "white"; |
| 755 | @ <tr style="background-color:%h(zBg)"> |
| 756 | zTid = 0; |
| 757 | for(i=0; i<nArg; i++){ |
| 758 | const char *zData; |
| 759 | if( i==pState->iBg ) continue; |
| 760 | zData = azArg[i]; |
| 761 | if( zData==0 ) zData = ""; |
| 762 | if( pState->iNewRow>=0 && i>=pState->iNewRow ){ |
| 763 | if( zTid && g.perm.Write ){ |
| @@ -815,12 +815,12 @@ | |
| 815 | ** Output a row as a tab-separated line of text. |
| 816 | */ |
| 817 | static int output_tab_separated( |
| 818 | void *pUser, /* Pointer to row-count integer */ |
| 819 | int nArg, /* Number of columns in this result row */ |
| 820 | const char **azArg, /* Text of data in all columns */ |
| 821 | const char **azName /* Names of the columns */ |
| 822 | ){ |
| 823 | int *pCount = (int*)pUser; |
| 824 | int i; |
| 825 | |
| 826 | if( *pCount==0 ){ |
| @@ -840,18 +840,19 @@ | |
| 840 | /* |
| 841 | ** Generate HTML that describes a color key. |
| 842 | */ |
| 843 | void output_color_key(const char *zClrKey, int horiz, char *zTabArgs){ |
| 844 | int i, j, k; |
| 845 | const char *zSafeKey; |
| 846 | char *zToFree; |
| 847 | while( fossil_isspace(*zClrKey) ) zClrKey++; |
| 848 | if( zClrKey[0]==0 ) return; |
| 849 | @ <table %s(zTabArgs)> |
| 850 | if( horiz ){ |
| 851 | @ <tr> |
| 852 | } |
| 853 | zSafeKey = zToFree = mprintf("%h", zClrKey); |
| 854 | while( zSafeKey[0] ){ |
| 855 | while( fossil_isspace(*zSafeKey) ) zSafeKey++; |
| 856 | for(i=0; zSafeKey[i] && !fossil_isspace(zSafeKey[i]); i++){} |
| 857 | for(j=i; fossil_isspace(zSafeKey[j]); j++){} |
| 858 | for(k=j; zSafeKey[k] && zSafeKey[k]!='\n' && zSafeKey[k]!='\r'; k++){} |
| @@ -873,23 +874,24 @@ | |
| 874 | |
| 875 | /* |
| 876 | ** Execute a single read-only SQL statement. Invoke xCallback() on each |
| 877 | ** row. |
| 878 | */ |
| 879 | static int db_exec_readonly( |
| 880 | sqlite3 *db, /* The database on which the SQL executes */ |
| 881 | const char *zSql, /* The SQL to be executed */ |
| 882 | int (*xCallback)(void*,int,const char**, const char**), |
| 883 | /* Invoke this callback routine */ |
| 884 | void *pArg, /* First argument to xCallback() */ |
| 885 | char **pzErrMsg /* Write error messages here */ |
| 886 | ){ |
| 887 | int rc = SQLITE_OK; /* Return code */ |
| 888 | const char *zLeftover; /* Tail of unprocessed SQL */ |
| 889 | sqlite3_stmt *pStmt = 0; /* The current SQL statement */ |
| 890 | const char **azCols = 0; /* Names of result columns */ |
| 891 | int nCol; /* Number of columns of output */ |
| 892 | const char **azVals = 0; /* Text of all output columns */ |
| 893 | int i; /* Loop counter */ |
| 894 | |
| 895 | pStmt = 0; |
| 896 | rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover); |
| 897 | assert( rc==SQLITE_OK || pStmt==0 ); |
| @@ -912,15 +914,15 @@ | |
| 914 | azVals = fossil_malloc(2*nCol*sizeof(const char*) + 1); |
| 915 | while( (rc = sqlite3_step(pStmt))==SQLITE_ROW ){ |
| 916 | if( azCols==0 ){ |
| 917 | azCols = &azVals[nCol]; |
| 918 | for(i=0; i<nCol; i++){ |
| 919 | azCols[i] = sqlite3_column_name(pStmt, i); |
| 920 | } |
| 921 | } |
| 922 | for(i=0; i<nCol; i++){ |
| 923 | azVals[i] = (const char *)sqlite3_column_text(pStmt, i); |
| 924 | } |
| 925 | if( xCallback(pArg, nCol, azVals, azCols) ){ |
| 926 | break; |
| 927 | } |
| 928 | } |
| @@ -1065,13 +1067,13 @@ | |
| 1067 | count = 0; |
| 1068 | if( !tabs ){ |
| 1069 | struct GenerateHTML sState; |
| 1070 | |
| 1071 | db_multi_exec("PRAGMA empty_result_callbacks=ON"); |
| 1072 | style_submenu_element("Raw", "Raw", |
| 1073 | "rptview?tablist=1&%h", PD("QUERY_STRING","")); |
| 1074 | if( g.perm.Admin |
| 1075 | || (g.perm.TktFmt && g.zLogin && fossil_strcmp(g.zLogin,zOwner)==0) ){ |
| 1076 | style_submenu_element("Edit", "Edit", "rptedit?rn=%d", rn); |
| 1077 | } |
| 1078 | if( g.perm.TktFmt ){ |
| 1079 | style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn); |
| @@ -1079,18 +1081,18 @@ | |
| 1081 | if( g.perm.NewTkt ){ |
| 1082 | style_submenu_element("New Ticket", "Create a new ticket", |
| 1083 | "%s/tktnew", g.zTop); |
| 1084 | } |
| 1085 | style_header(zTitle); |
| 1086 | output_color_key(zClrKey, 1, |
| 1087 | "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\""); |
| 1088 | @ <table border="1" cellpadding="2" cellspacing="0" class="report" |
| 1089 | @ id="reportTable"> |
| 1090 | sState.rn = rn; |
| 1091 | sState.nCount = 0; |
| 1092 | report_restrict_sql(&zErr1); |
| 1093 | db_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2); |
| 1094 | report_unrestrict_sql(); |
| 1095 | @ </tbody></table> |
| 1096 | if( zErr1 ){ |
| 1097 | @ <p class="reportError">Error: %h(zErr1)</p> |
| 1098 | }else if( zErr2 ){ |
| @@ -1098,11 +1100,11 @@ | |
| 1100 | } |
| 1101 | output_table_sorting_javascript("reportTable",""); |
| 1102 | style_footer(); |
| 1103 | }else{ |
| 1104 | report_restrict_sql(&zErr1); |
| 1105 | db_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2); |
| 1106 | report_unrestrict_sql(); |
| 1107 | cgi_set_content_type("text/plain"); |
| 1108 | } |
| 1109 | } |
| 1110 | |
| @@ -1177,22 +1179,22 @@ | |
| 1179 | if( j>i ){ |
| 1180 | fossil_print("%*s", j-i, ""); |
| 1181 | } |
| 1182 | z += j; |
| 1183 | } |
| 1184 | break; |
| 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | /* |
| 1189 | ** Output a row as a tab-separated line of text. |
| 1190 | */ |
| 1191 | int output_separated_file( |
| 1192 | void *pUser, /* Pointer to row-count integer */ |
| 1193 | int nArg, /* Number of columns in this result row */ |
| 1194 | const char **azArg, /* Text of data in all columns */ |
| 1195 | const char **azName /* Names of the columns */ |
| 1196 | ){ |
| 1197 | int *pCount = (int*)pUser; |
| 1198 | int i; |
| 1199 | |
| 1200 | if( *pCount==0 ){ |
| @@ -1212,11 +1214,11 @@ | |
| 1214 | /* |
| 1215 | ** Generate a report. The rn query parameter is the report number. |
| 1216 | ** The output is written to stdout as flat file. The zFilter parameter |
| 1217 | ** is a full WHERE-condition. |
| 1218 | */ |
| 1219 | void rptshow( |
| 1220 | const char *zRep, |
| 1221 | const char *zSepIn, |
| 1222 | const char *zFilter, |
| 1223 | tTktShowEncoding enc |
| 1224 | ){ |
| @@ -1251,11 +1253,11 @@ | |
| 1253 | } |
| 1254 | count = 0; |
| 1255 | tktEncode = enc; |
| 1256 | zSep = zSepIn; |
| 1257 | report_restrict_sql(&zErr1); |
| 1258 | db_exec_readonly(g.db, zSql, output_separated_file, &count, &zErr2); |
| 1259 | report_unrestrict_sql(); |
| 1260 | if( zFilter ){ |
| 1261 | free(zSql); |
| 1262 | } |
| 1263 | } |
| 1264 |
+1
-1
| --- src/search.c | ||
| +++ src/search.c | ||
| @@ -135,11 +135,11 @@ | ||
| 135 | 135 | |
| 136 | 136 | /* Every term must be seen or else the score is zero */ |
| 137 | 137 | for(j=0; j<p->nTerm; j++){ |
| 138 | 138 | if( !seen[j] ) return 0; |
| 139 | 139 | } |
| 140 | - | |
| 140 | + | |
| 141 | 141 | return score; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /* |
| 145 | 145 | ** This is an SQLite function that scores its input using |
| 146 | 146 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -135,11 +135,11 @@ | |
| 135 | |
| 136 | /* Every term must be seen or else the score is zero */ |
| 137 | for(j=0; j<p->nTerm; j++){ |
| 138 | if( !seen[j] ) return 0; |
| 139 | } |
| 140 | |
| 141 | return score; |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | ** This is an SQLite function that scores its input using |
| 146 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -135,11 +135,11 @@ | |
| 135 | |
| 136 | /* Every term must be seen or else the score is zero */ |
| 137 | for(j=0; j<p->nTerm; j++){ |
| 138 | if( !seen[j] ) return 0; |
| 139 | } |
| 140 | |
| 141 | return score; |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | ** This is an SQLite function that scores its input using |
| 146 |
+8
-10
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -249,14 +249,11 @@ | ||
| 249 | 249 | @ <tr><th valign="top">w</th> |
| 250 | 250 | @ <td><i>Write-Tkt:</i> Edit tickets</td></tr> |
| 251 | 251 | @ <tr><th valign="top">x</th> |
| 252 | 252 | @ <td><i>Private:</i> Push and/or pull private branches</td></tr> |
| 253 | 253 | @ <tr><th valign="top">z</th> |
| 254 | - @ <td><i>Zip download:</i> Download a baseline via the | |
| 255 | - @ <tt>/zip</tt> URL even without | |
| 256 | - @ check<span class="capability">o</span>ut | |
| 257 | - @ and <span class="capability">h</span>istory permissions</td></tr> | |
| 254 | + @ <td><i>Zip download:</i> Download a ZIP archive or tarball</td></tr> | |
| 258 | 255 | @ </table> |
| 259 | 256 | @ </li> |
| 260 | 257 | @ |
| 261 | 258 | @ <li><p> |
| 262 | 259 | @ Every user, logged in or not, inherits the privileges of |
| @@ -859,11 +856,11 @@ | ||
| 859 | 856 | const char *zLabel, /* The text label on the menu */ |
| 860 | 857 | const char *zVar, /* The corresponding row in the VAR table */ |
| 861 | 858 | const char *zQP, /* The query parameter */ |
| 862 | 859 | const char *zDflt, /* Default value if VAR table entry does not exist */ |
| 863 | 860 | int nChoice, /* Number of choices */ |
| 864 | - const char **azChoice /* Choices. 2 per choice: (VAR value, Display) */ | |
| 861 | + const char *const *azChoice /* Choices. 2 per choice: (VAR value, Display) */ | |
| 865 | 862 | ){ |
| 866 | 863 | const char *z = db_get(zVar, (char*)zDflt); |
| 867 | 864 | const char *zQ = P(zQP); |
| 868 | 865 | int i; |
| 869 | 866 | if( zQ && fossil_strcmp(zQ,z)!=0){ |
| @@ -874,11 +871,11 @@ | ||
| 874 | 871 | @ <select size="1" name="%s(zQP)" id="id%s(zQP)"> |
| 875 | 872 | for(i=0; i<nChoice*2; i+=2){ |
| 876 | 873 | const char *zSel = fossil_strcmp(azChoice[i],z)==0 ? " selected" : ""; |
| 877 | 874 | @ <option value="%h(azChoice[i])"%s(zSel)>%h(azChoice[i+1])</option> |
| 878 | 875 | } |
| 879 | - @ </select> | |
| 876 | + @ </select> <b>%h(zLabel)</b> | |
| 880 | 877 | } |
| 881 | 878 | |
| 882 | 879 | |
| 883 | 880 | /* |
| 884 | 881 | ** WEBPAGE: setup_access |
| @@ -975,19 +972,19 @@ | ||
| 975 | 972 | @ including user "nobody", as long as (1) the User-Agent string in the |
| 976 | 973 | @ HTTP header indicates that the request is coming from an actual human |
| 977 | 974 | @ being and not a a robot or spider and (2) the user agent is able to |
| 978 | 975 | @ run Javascript in order to set the href= attribute of hyperlinks. Bots |
| 979 | 976 | @ and spiders can forge a User-Agent string that makes them seem to be a |
| 980 | - @ normal browser and they can run javascript just like browsers. But most | |
| 977 | + @ normal browser and they can run javascript just like browsers. But most | |
| 981 | 978 | @ bots do not go to that much trouble so this is normally an effective defense.</p> |
| 982 | 979 | @ |
| 983 | 980 | @ <p>You do not normally want a bot to walk your entire repository because |
| 984 | 981 | @ if it does, your server will end up computing diffs and annotations for |
| 985 | 982 | @ every historical version of every file and creating ZIPs and tarballs of |
| 986 | 983 | @ every historical check-in, which can use a lot of CPU and bandwidth |
| 987 | 984 | @ even for relatively small projects.</p> |
| 988 | - @ | |
| 985 | + @ | |
| 989 | 986 | @ <p>Additional parameters that control this behavior:</p> |
| 990 | 987 | @ <blockquote> |
| 991 | 988 | onoff_attribute("Require mouse movement before enabling hyperlinks", |
| 992 | 989 | "auto-hyperlink-mouseover", "ahmo", 0, 0); |
| 993 | 990 | @ <br> |
| @@ -1151,11 +1148,11 @@ | ||
| 1151 | 1148 | ** WEBPAGE: setup_timeline |
| 1152 | 1149 | */ |
| 1153 | 1150 | void setup_timeline(void){ |
| 1154 | 1151 | double tmDiff; |
| 1155 | 1152 | char zTmDiff[20]; |
| 1156 | - static const char *azTimeFormats[] = { | |
| 1153 | + static const char *const azTimeFormats[] = { | |
| 1157 | 1154 | "0", "HH:MM", |
| 1158 | 1155 | "1", "HH:MM:SS", |
| 1159 | 1156 | "2", "YYYY-MM-DD HH:MM", |
| 1160 | 1157 | "3", "YYMMDD HH:MM" |
| 1161 | 1158 | }; |
| @@ -1177,11 +1174,12 @@ | ||
| 1177 | 1174 | |
| 1178 | 1175 | @ <hr /> |
| 1179 | 1176 | onoff_attribute("Plaintext comments on timelines", |
| 1180 | 1177 | "timeline-plaintext", "tpt", 0, 0); |
| 1181 | 1178 | @ <p>In timeline displays, check-in comments are displayed literally, |
| 1182 | - @ without any wiki or HTML interpretation.</p> | |
| 1179 | + @ without any wiki or HTML interpretation. (Note: Use CSS to change | |
| 1180 | + @ display formatting features such as fonts and line-wrapping behavior.)</p> | |
| 1183 | 1181 | |
| 1184 | 1182 | @ <hr /> |
| 1185 | 1183 | onoff_attribute("Use Universal Coordinated Time (UTC)", |
| 1186 | 1184 | "timeline-utc", "utc", 1, 0); |
| 1187 | 1185 | @ <p>Show times as UTC (also sometimes called Greenwich Mean Time (GMT) or |
| 1188 | 1186 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -249,14 +249,11 @@ | |
| 249 | @ <tr><th valign="top">w</th> |
| 250 | @ <td><i>Write-Tkt:</i> Edit tickets</td></tr> |
| 251 | @ <tr><th valign="top">x</th> |
| 252 | @ <td><i>Private:</i> Push and/or pull private branches</td></tr> |
| 253 | @ <tr><th valign="top">z</th> |
| 254 | @ <td><i>Zip download:</i> Download a baseline via the |
| 255 | @ <tt>/zip</tt> URL even without |
| 256 | @ check<span class="capability">o</span>ut |
| 257 | @ and <span class="capability">h</span>istory permissions</td></tr> |
| 258 | @ </table> |
| 259 | @ </li> |
| 260 | @ |
| 261 | @ <li><p> |
| 262 | @ Every user, logged in or not, inherits the privileges of |
| @@ -859,11 +856,11 @@ | |
| 859 | const char *zLabel, /* The text label on the menu */ |
| 860 | const char *zVar, /* The corresponding row in the VAR table */ |
| 861 | const char *zQP, /* The query parameter */ |
| 862 | const char *zDflt, /* Default value if VAR table entry does not exist */ |
| 863 | int nChoice, /* Number of choices */ |
| 864 | const char **azChoice /* Choices. 2 per choice: (VAR value, Display) */ |
| 865 | ){ |
| 866 | const char *z = db_get(zVar, (char*)zDflt); |
| 867 | const char *zQ = P(zQP); |
| 868 | int i; |
| 869 | if( zQ && fossil_strcmp(zQ,z)!=0){ |
| @@ -874,11 +871,11 @@ | |
| 874 | @ <select size="1" name="%s(zQP)" id="id%s(zQP)"> |
| 875 | for(i=0; i<nChoice*2; i+=2){ |
| 876 | const char *zSel = fossil_strcmp(azChoice[i],z)==0 ? " selected" : ""; |
| 877 | @ <option value="%h(azChoice[i])"%s(zSel)>%h(azChoice[i+1])</option> |
| 878 | } |
| 879 | @ </select> |
| 880 | } |
| 881 | |
| 882 | |
| 883 | /* |
| 884 | ** WEBPAGE: setup_access |
| @@ -975,19 +972,19 @@ | |
| 975 | @ including user "nobody", as long as (1) the User-Agent string in the |
| 976 | @ HTTP header indicates that the request is coming from an actual human |
| 977 | @ being and not a a robot or spider and (2) the user agent is able to |
| 978 | @ run Javascript in order to set the href= attribute of hyperlinks. Bots |
| 979 | @ and spiders can forge a User-Agent string that makes them seem to be a |
| 980 | @ normal browser and they can run javascript just like browsers. But most |
| 981 | @ bots do not go to that much trouble so this is normally an effective defense.</p> |
| 982 | @ |
| 983 | @ <p>You do not normally want a bot to walk your entire repository because |
| 984 | @ if it does, your server will end up computing diffs and annotations for |
| 985 | @ every historical version of every file and creating ZIPs and tarballs of |
| 986 | @ every historical check-in, which can use a lot of CPU and bandwidth |
| 987 | @ even for relatively small projects.</p> |
| 988 | @ |
| 989 | @ <p>Additional parameters that control this behavior:</p> |
| 990 | @ <blockquote> |
| 991 | onoff_attribute("Require mouse movement before enabling hyperlinks", |
| 992 | "auto-hyperlink-mouseover", "ahmo", 0, 0); |
| 993 | @ <br> |
| @@ -1151,11 +1148,11 @@ | |
| 1151 | ** WEBPAGE: setup_timeline |
| 1152 | */ |
| 1153 | void setup_timeline(void){ |
| 1154 | double tmDiff; |
| 1155 | char zTmDiff[20]; |
| 1156 | static const char *azTimeFormats[] = { |
| 1157 | "0", "HH:MM", |
| 1158 | "1", "HH:MM:SS", |
| 1159 | "2", "YYYY-MM-DD HH:MM", |
| 1160 | "3", "YYMMDD HH:MM" |
| 1161 | }; |
| @@ -1177,11 +1174,12 @@ | |
| 1177 | |
| 1178 | @ <hr /> |
| 1179 | onoff_attribute("Plaintext comments on timelines", |
| 1180 | "timeline-plaintext", "tpt", 0, 0); |
| 1181 | @ <p>In timeline displays, check-in comments are displayed literally, |
| 1182 | @ without any wiki or HTML interpretation.</p> |
| 1183 | |
| 1184 | @ <hr /> |
| 1185 | onoff_attribute("Use Universal Coordinated Time (UTC)", |
| 1186 | "timeline-utc", "utc", 1, 0); |
| 1187 | @ <p>Show times as UTC (also sometimes called Greenwich Mean Time (GMT) or |
| 1188 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -249,14 +249,11 @@ | |
| 249 | @ <tr><th valign="top">w</th> |
| 250 | @ <td><i>Write-Tkt:</i> Edit tickets</td></tr> |
| 251 | @ <tr><th valign="top">x</th> |
| 252 | @ <td><i>Private:</i> Push and/or pull private branches</td></tr> |
| 253 | @ <tr><th valign="top">z</th> |
| 254 | @ <td><i>Zip download:</i> Download a ZIP archive or tarball</td></tr> |
| 255 | @ </table> |
| 256 | @ </li> |
| 257 | @ |
| 258 | @ <li><p> |
| 259 | @ Every user, logged in or not, inherits the privileges of |
| @@ -859,11 +856,11 @@ | |
| 856 | const char *zLabel, /* The text label on the menu */ |
| 857 | const char *zVar, /* The corresponding row in the VAR table */ |
| 858 | const char *zQP, /* The query parameter */ |
| 859 | const char *zDflt, /* Default value if VAR table entry does not exist */ |
| 860 | int nChoice, /* Number of choices */ |
| 861 | const char *const *azChoice /* Choices. 2 per choice: (VAR value, Display) */ |
| 862 | ){ |
| 863 | const char *z = db_get(zVar, (char*)zDflt); |
| 864 | const char *zQ = P(zQP); |
| 865 | int i; |
| 866 | if( zQ && fossil_strcmp(zQ,z)!=0){ |
| @@ -874,11 +871,11 @@ | |
| 871 | @ <select size="1" name="%s(zQP)" id="id%s(zQP)"> |
| 872 | for(i=0; i<nChoice*2; i+=2){ |
| 873 | const char *zSel = fossil_strcmp(azChoice[i],z)==0 ? " selected" : ""; |
| 874 | @ <option value="%h(azChoice[i])"%s(zSel)>%h(azChoice[i+1])</option> |
| 875 | } |
| 876 | @ </select> <b>%h(zLabel)</b> |
| 877 | } |
| 878 | |
| 879 | |
| 880 | /* |
| 881 | ** WEBPAGE: setup_access |
| @@ -975,19 +972,19 @@ | |
| 972 | @ including user "nobody", as long as (1) the User-Agent string in the |
| 973 | @ HTTP header indicates that the request is coming from an actual human |
| 974 | @ being and not a a robot or spider and (2) the user agent is able to |
| 975 | @ run Javascript in order to set the href= attribute of hyperlinks. Bots |
| 976 | @ and spiders can forge a User-Agent string that makes them seem to be a |
| 977 | @ normal browser and they can run javascript just like browsers. But most |
| 978 | @ bots do not go to that much trouble so this is normally an effective defense.</p> |
| 979 | @ |
| 980 | @ <p>You do not normally want a bot to walk your entire repository because |
| 981 | @ if it does, your server will end up computing diffs and annotations for |
| 982 | @ every historical version of every file and creating ZIPs and tarballs of |
| 983 | @ every historical check-in, which can use a lot of CPU and bandwidth |
| 984 | @ even for relatively small projects.</p> |
| 985 | @ |
| 986 | @ <p>Additional parameters that control this behavior:</p> |
| 987 | @ <blockquote> |
| 988 | onoff_attribute("Require mouse movement before enabling hyperlinks", |
| 989 | "auto-hyperlink-mouseover", "ahmo", 0, 0); |
| 990 | @ <br> |
| @@ -1151,11 +1148,11 @@ | |
| 1148 | ** WEBPAGE: setup_timeline |
| 1149 | */ |
| 1150 | void setup_timeline(void){ |
| 1151 | double tmDiff; |
| 1152 | char zTmDiff[20]; |
| 1153 | static const char *const azTimeFormats[] = { |
| 1154 | "0", "HH:MM", |
| 1155 | "1", "HH:MM:SS", |
| 1156 | "2", "YYYY-MM-DD HH:MM", |
| 1157 | "3", "YYMMDD HH:MM" |
| 1158 | }; |
| @@ -1177,11 +1174,12 @@ | |
| 1174 | |
| 1175 | @ <hr /> |
| 1176 | onoff_attribute("Plaintext comments on timelines", |
| 1177 | "timeline-plaintext", "tpt", 0, 0); |
| 1178 | @ <p>In timeline displays, check-in comments are displayed literally, |
| 1179 | @ without any wiki or HTML interpretation. (Note: Use CSS to change |
| 1180 | @ display formatting features such as fonts and line-wrapping behavior.)</p> |
| 1181 | |
| 1182 | @ <hr /> |
| 1183 | onoff_attribute("Use Universal Coordinated Time (UTC)", |
| 1184 | "timeline-utc", "utc", 1, 0); |
| 1185 | @ <p>Show times as UTC (also sometimes called Greenwich Mean Time (GMT) or |
| 1186 |
+267
-15
| --- src/shell.c | ||
| +++ src/shell.c | ||
| @@ -43,18 +43,21 @@ | ||
| 43 | 43 | # endif |
| 44 | 44 | # include <unistd.h> |
| 45 | 45 | # include <sys/types.h> |
| 46 | 46 | #endif |
| 47 | 47 | |
| 48 | -#ifdef HAVE_EDITLINE | |
| 49 | -# include <editline/editline.h> | |
| 50 | -#endif | |
| 51 | -#if defined(HAVE_READLINE) && HAVE_READLINE==1 | |
| 48 | +#if defined(HAVE_READLINE) && HAVE_READLINE!=0 | |
| 52 | 49 | # include <readline/readline.h> |
| 53 | 50 | # include <readline/history.h> |
| 51 | +#else | |
| 52 | +# undef HAVE_READLINE | |
| 53 | +#endif | |
| 54 | +#if defined(HAVE_EDITLINE) && !defined(HAVE_READLINE) | |
| 55 | +# define HAVE_READLINE 1 | |
| 56 | +# include <editline/readline.h> | |
| 54 | 57 | #endif |
| 55 | -#if !defined(HAVE_EDITLINE) && (!defined(HAVE_READLINE) || HAVE_READLINE!=1) | |
| 58 | +#if !defined(HAVE_READLINE) | |
| 56 | 59 | # define add_history(X) |
| 57 | 60 | # define read_history(X) |
| 58 | 61 | # define write_history(X) |
| 59 | 62 | # define stifle_history(X) |
| 60 | 63 | #endif |
| @@ -411,11 +414,11 @@ | ||
| 411 | 414 | char *zResult; |
| 412 | 415 | if( in!=0 ){ |
| 413 | 416 | zResult = local_getline(zPrior, in); |
| 414 | 417 | }else{ |
| 415 | 418 | zPrompt = isContinuation ? continuePrompt : mainPrompt; |
| 416 | -#if defined(HAVE_READLINE) && HAVE_READLINE==1 | |
| 419 | +#if defined(HAVE_READLINE) | |
| 417 | 420 | free(zPrior); |
| 418 | 421 | zResult = readline(zPrompt); |
| 419 | 422 | if( zResult && *zResult ) add_history(zResult); |
| 420 | 423 | #else |
| 421 | 424 | printf("%s", zPrompt); |
| @@ -1003,11 +1006,11 @@ | ||
| 1003 | 1006 | sqlite3_stmt *pSelect; |
| 1004 | 1007 | int rc; |
| 1005 | 1008 | int nResult; |
| 1006 | 1009 | int i; |
| 1007 | 1010 | const char *z; |
| 1008 | - rc = sqlite3_prepare(p->db, zSelect, -1, &pSelect, 0); | |
| 1011 | + rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0); | |
| 1009 | 1012 | if( rc!=SQLITE_OK || !pSelect ){ |
| 1010 | 1013 | fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); |
| 1011 | 1014 | if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++; |
| 1012 | 1015 | return rc; |
| 1013 | 1016 | } |
| @@ -1451,11 +1454,11 @@ | ||
| 1451 | 1454 | |
| 1452 | 1455 | zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0); |
| 1453 | 1456 | zTableInfo = appendText(zTableInfo, zTable, '"'); |
| 1454 | 1457 | zTableInfo = appendText(zTableInfo, ");", 0); |
| 1455 | 1458 | |
| 1456 | - rc = sqlite3_prepare(p->db, zTableInfo, -1, &pTableInfo, 0); | |
| 1459 | + rc = sqlite3_prepare_v2(p->db, zTableInfo, -1, &pTableInfo, 0); | |
| 1457 | 1460 | free(zTableInfo); |
| 1458 | 1461 | if( rc!=SQLITE_OK || !pTableInfo ){ |
| 1459 | 1462 | return 1; |
| 1460 | 1463 | } |
| 1461 | 1464 | |
| @@ -1541,10 +1544,11 @@ | ||
| 1541 | 1544 | ** Text of a help message |
| 1542 | 1545 | */ |
| 1543 | 1546 | static char zHelp[] = |
| 1544 | 1547 | ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" |
| 1545 | 1548 | ".bail ON|OFF Stop after hitting an error. Default OFF\n" |
| 1549 | + ".clone NEWDB Clone data into NEWDB from the existing database\n" | |
| 1546 | 1550 | ".databases List names and files of attached databases\n" |
| 1547 | 1551 | ".dump ?TABLE? ... Dump the database in an SQL text format\n" |
| 1548 | 1552 | " If TABLE specified, only dump tables matching\n" |
| 1549 | 1553 | " LIKE pattern TABLE.\n" |
| 1550 | 1554 | ".echo ON|OFF Turn command echo on or off\n" |
| @@ -1580,10 +1584,11 @@ | ||
| 1580 | 1584 | ".print STRING... Print literal STRING\n" |
| 1581 | 1585 | ".prompt MAIN CONTINUE Replace the standard prompts\n" |
| 1582 | 1586 | ".quit Exit this program\n" |
| 1583 | 1587 | ".read FILENAME Execute SQL in FILENAME\n" |
| 1584 | 1588 | ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n" |
| 1589 | + ".save FILE Write in-memory database into FILE\n" | |
| 1585 | 1590 | ".schema ?TABLE? Show the CREATE statements\n" |
| 1586 | 1591 | " If TABLE specified, only show tables matching\n" |
| 1587 | 1592 | " LIKE pattern TABLE.\n" |
| 1588 | 1593 | ".separator STRING Change separator used by output mode and .import\n" |
| 1589 | 1594 | ".show Show the current values for various settings\n" |
| @@ -1893,10 +1898,223 @@ | ||
| 1893 | 1898 | p->cTerm = c; |
| 1894 | 1899 | } |
| 1895 | 1900 | if( p->z ) p->z[p->n] = 0; |
| 1896 | 1901 | return p->z; |
| 1897 | 1902 | } |
| 1903 | + | |
| 1904 | +/* | |
| 1905 | +** Try to transfer data for table zTable. If an error is seen while | |
| 1906 | +** moving forward, try to go backwards. The backwards movement won't | |
| 1907 | +** work for WITHOUT ROWID tables. | |
| 1908 | +*/ | |
| 1909 | +static void tryToCloneData( | |
| 1910 | + struct callback_data *p, | |
| 1911 | + sqlite3 *newDb, | |
| 1912 | + const char *zTable | |
| 1913 | +){ | |
| 1914 | + sqlite3_stmt *pQuery = 0; | |
| 1915 | + sqlite3_stmt *pInsert = 0; | |
| 1916 | + char *zQuery = 0; | |
| 1917 | + char *zInsert = 0; | |
| 1918 | + int rc; | |
| 1919 | + int i, j, n; | |
| 1920 | + int nTable = (int)strlen(zTable); | |
| 1921 | + int k = 0; | |
| 1922 | + int cnt = 0; | |
| 1923 | + const int spinRate = 10000; | |
| 1924 | + | |
| 1925 | + zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable); | |
| 1926 | + rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); | |
| 1927 | + if( rc ){ | |
| 1928 | + fprintf(stderr, "Error %d: %s on [%s]\n", | |
| 1929 | + sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), | |
| 1930 | + zQuery); | |
| 1931 | + goto end_data_xfer; | |
| 1932 | + } | |
| 1933 | + n = sqlite3_column_count(pQuery); | |
| 1934 | + zInsert = sqlite3_malloc(200 + nTable + n*3); | |
| 1935 | + if( zInsert==0 ){ | |
| 1936 | + fprintf(stderr, "out of memory\n"); | |
| 1937 | + goto end_data_xfer; | |
| 1938 | + } | |
| 1939 | + sqlite3_snprintf(200+nTable,zInsert, | |
| 1940 | + "INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable); | |
| 1941 | + i = (int)strlen(zInsert); | |
| 1942 | + for(j=1; j<n; j++){ | |
| 1943 | + memcpy(zInsert+i, ",?", 2); | |
| 1944 | + i += 2; | |
| 1945 | + } | |
| 1946 | + memcpy(zInsert+i, ");", 3); | |
| 1947 | + rc = sqlite3_prepare_v2(newDb, zInsert, -1, &pInsert, 0); | |
| 1948 | + if( rc ){ | |
| 1949 | + fprintf(stderr, "Error %d: %s on [%s]\n", | |
| 1950 | + sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb), | |
| 1951 | + zQuery); | |
| 1952 | + goto end_data_xfer; | |
| 1953 | + } | |
| 1954 | + for(k=0; k<2; k++){ | |
| 1955 | + while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){ | |
| 1956 | + for(i=0; i<n; i++){ | |
| 1957 | + switch( sqlite3_column_type(pQuery, i) ){ | |
| 1958 | + case SQLITE_NULL: { | |
| 1959 | + sqlite3_bind_null(pInsert, i+1); | |
| 1960 | + break; | |
| 1961 | + } | |
| 1962 | + case SQLITE_INTEGER: { | |
| 1963 | + sqlite3_bind_int64(pInsert, i+1, sqlite3_column_int64(pQuery,i)); | |
| 1964 | + break; | |
| 1965 | + } | |
| 1966 | + case SQLITE_FLOAT: { | |
| 1967 | + sqlite3_bind_double(pInsert, i+1, sqlite3_column_double(pQuery,i)); | |
| 1968 | + break; | |
| 1969 | + } | |
| 1970 | + case SQLITE_TEXT: { | |
| 1971 | + sqlite3_bind_text(pInsert, i+1, | |
| 1972 | + (const char*)sqlite3_column_text(pQuery,i), | |
| 1973 | + -1, SQLITE_STATIC); | |
| 1974 | + break; | |
| 1975 | + } | |
| 1976 | + case SQLITE_BLOB: { | |
| 1977 | + sqlite3_bind_blob(pInsert, i+1, sqlite3_column_blob(pQuery,i), | |
| 1978 | + sqlite3_column_bytes(pQuery,i), | |
| 1979 | + SQLITE_STATIC); | |
| 1980 | + break; | |
| 1981 | + } | |
| 1982 | + } | |
| 1983 | + } /* End for */ | |
| 1984 | + rc = sqlite3_step(pInsert); | |
| 1985 | + if( rc!=SQLITE_OK && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ | |
| 1986 | + fprintf(stderr, "Error %d: %s\n", sqlite3_extended_errcode(newDb), | |
| 1987 | + sqlite3_errmsg(newDb)); | |
| 1988 | + } | |
| 1989 | + sqlite3_reset(pInsert); | |
| 1990 | + cnt++; | |
| 1991 | + if( (cnt%spinRate)==0 ){ | |
| 1992 | + printf("%c\b", "|/-\\"[(cnt/spinRate)%4]); | |
| 1993 | + fflush(stdout); | |
| 1994 | + } | |
| 1995 | + } /* End while */ | |
| 1996 | + if( rc==SQLITE_DONE ) break; | |
| 1997 | + sqlite3_finalize(pQuery); | |
| 1998 | + sqlite3_free(zQuery); | |
| 1999 | + zQuery = sqlite3_mprintf("SELECT * FROM \"%w\" ORDER BY rowid DESC;", | |
| 2000 | + zTable); | |
| 2001 | + rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); | |
| 2002 | + if( rc ){ | |
| 2003 | + fprintf(stderr, "Warning: cannot step \"%s\" backwards", zTable); | |
| 2004 | + break; | |
| 2005 | + } | |
| 2006 | + } /* End for(k=0...) */ | |
| 2007 | + | |
| 2008 | +end_data_xfer: | |
| 2009 | + sqlite3_finalize(pQuery); | |
| 2010 | + sqlite3_finalize(pInsert); | |
| 2011 | + sqlite3_free(zQuery); | |
| 2012 | + sqlite3_free(zInsert); | |
| 2013 | +} | |
| 2014 | + | |
| 2015 | + | |
| 2016 | +/* | |
| 2017 | +** Try to transfer all rows of the schema that match zWhere. For | |
| 2018 | +** each row, invoke xForEach() on the object defined by that row. | |
| 2019 | +** If an error is encountered while moving forward through the | |
| 2020 | +** sqlite_master table, try again moving backwards. | |
| 2021 | +*/ | |
| 2022 | +static void tryToCloneSchema( | |
| 2023 | + struct callback_data *p, | |
| 2024 | + sqlite3 *newDb, | |
| 2025 | + const char *zWhere, | |
| 2026 | + void (*xForEach)(struct callback_data*,sqlite3*,const char*) | |
| 2027 | +){ | |
| 2028 | + sqlite3_stmt *pQuery = 0; | |
| 2029 | + char *zQuery = 0; | |
| 2030 | + int rc; | |
| 2031 | + const unsigned char *zName; | |
| 2032 | + const unsigned char *zSql; | |
| 2033 | + char *zErrMsg = 0; | |
| 2034 | + | |
| 2035 | + zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_master" | |
| 2036 | + " WHERE %s", zWhere); | |
| 2037 | + rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); | |
| 2038 | + if( rc ){ | |
| 2039 | + fprintf(stderr, "Error: (%d) %s on [%s]\n", | |
| 2040 | + sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), | |
| 2041 | + zQuery); | |
| 2042 | + goto end_schema_xfer; | |
| 2043 | + } | |
| 2044 | + while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){ | |
| 2045 | + zName = sqlite3_column_text(pQuery, 0); | |
| 2046 | + zSql = sqlite3_column_text(pQuery, 1); | |
| 2047 | + printf("%s... ", zName); fflush(stdout); | |
| 2048 | + sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); | |
| 2049 | + if( zErrMsg ){ | |
| 2050 | + fprintf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); | |
| 2051 | + sqlite3_free(zErrMsg); | |
| 2052 | + zErrMsg = 0; | |
| 2053 | + } | |
| 2054 | + if( xForEach ){ | |
| 2055 | + xForEach(p, newDb, (const char*)zName); | |
| 2056 | + } | |
| 2057 | + printf("done\n"); | |
| 2058 | + } | |
| 2059 | + if( rc!=SQLITE_DONE ){ | |
| 2060 | + sqlite3_finalize(pQuery); | |
| 2061 | + sqlite3_free(zQuery); | |
| 2062 | + zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_master" | |
| 2063 | + " WHERE %s ORDER BY rowid DESC", zWhere); | |
| 2064 | + rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); | |
| 2065 | + if( rc ){ | |
| 2066 | + fprintf(stderr, "Error: (%d) %s on [%s]\n", | |
| 2067 | + sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), | |
| 2068 | + zQuery); | |
| 2069 | + goto end_schema_xfer; | |
| 2070 | + } | |
| 2071 | + while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){ | |
| 2072 | + zName = sqlite3_column_text(pQuery, 0); | |
| 2073 | + zSql = sqlite3_column_text(pQuery, 1); | |
| 2074 | + printf("%s... ", zName); fflush(stdout); | |
| 2075 | + sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); | |
| 2076 | + if( zErrMsg ){ | |
| 2077 | + fprintf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); | |
| 2078 | + sqlite3_free(zErrMsg); | |
| 2079 | + zErrMsg = 0; | |
| 2080 | + } | |
| 2081 | + if( xForEach ){ | |
| 2082 | + xForEach(p, newDb, (const char*)zName); | |
| 2083 | + } | |
| 2084 | + printf("done\n"); | |
| 2085 | + } | |
| 2086 | + } | |
| 2087 | +end_schema_xfer: | |
| 2088 | + sqlite3_finalize(pQuery); | |
| 2089 | + sqlite3_free(zQuery); | |
| 2090 | +} | |
| 2091 | + | |
| 2092 | +/* | |
| 2093 | +** Open a new database file named "zNewDb". Try to recover as much information | |
| 2094 | +** as possible out of the main database (which might be corrupt) and write it | |
| 2095 | +** into zNewDb. | |
| 2096 | +*/ | |
| 2097 | +static void tryToClone(struct callback_data *p, const char *zNewDb){ | |
| 2098 | + int rc; | |
| 2099 | + sqlite3 *newDb = 0; | |
| 2100 | + if( access(zNewDb,0)==0 ){ | |
| 2101 | + fprintf(stderr, "File \"%s\" already exists.\n", zNewDb); | |
| 2102 | + return; | |
| 2103 | + } | |
| 2104 | + rc = sqlite3_open(zNewDb, &newDb); | |
| 2105 | + if( rc ){ | |
| 2106 | + fprintf(stderr, "Cannot create output database: %s\n", | |
| 2107 | + sqlite3_errmsg(newDb)); | |
| 2108 | + }else{ | |
| 2109 | + sqlite3_exec(newDb, "BEGIN EXCLUSIVE;", 0, 0, 0); | |
| 2110 | + tryToCloneSchema(p, newDb, "type='table'", tryToCloneData); | |
| 2111 | + tryToCloneSchema(p, newDb, "type!='table'", 0); | |
| 2112 | + sqlite3_exec(newDb, "COMMIT;", 0, 0, 0); | |
| 2113 | + } | |
| 2114 | + sqlite3_close(newDb); | |
| 2115 | +} | |
| 1898 | 2116 | |
| 1899 | 2117 | /* |
| 1900 | 2118 | ** If an input line begins with "." then invoke this routine to |
| 1901 | 2119 | ** process that line. |
| 1902 | 2120 | ** |
| @@ -1936,11 +2154,13 @@ | ||
| 1936 | 2154 | /* Process the input line. |
| 1937 | 2155 | */ |
| 1938 | 2156 | if( nArg==0 ) return 0; /* no tokens, no error */ |
| 1939 | 2157 | n = strlen30(azArg[0]); |
| 1940 | 2158 | c = azArg[0][0]; |
| 1941 | - if( c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0 ){ | |
| 2159 | + if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0) | |
| 2160 | + || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0) | |
| 2161 | + ){ | |
| 1942 | 2162 | const char *zDestFile = 0; |
| 1943 | 2163 | const char *zDb = 0; |
| 1944 | 2164 | sqlite3 *pDest; |
| 1945 | 2165 | sqlite3_backup *pBackup; |
| 1946 | 2166 | int j; |
| @@ -2000,10 +2220,14 @@ | ||
| 2000 | 2220 | ** routine named test_breakpoint(). |
| 2001 | 2221 | */ |
| 2002 | 2222 | if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){ |
| 2003 | 2223 | test_breakpoint(); |
| 2004 | 2224 | }else |
| 2225 | + | |
| 2226 | + if( c=='c' && strncmp(azArg[0], "clone", n)==0 && nArg>1 && nArg<3 ){ | |
| 2227 | + tryToClone(p, azArg[1]); | |
| 2228 | + }else | |
| 2005 | 2229 | |
| 2006 | 2230 | if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 && nArg==1 ){ |
| 2007 | 2231 | struct callback_data data; |
| 2008 | 2232 | char *zErrMsg = 0; |
| 2009 | 2233 | open_db(p, 0); |
| @@ -2173,11 +2397,11 @@ | ||
| 2173 | 2397 | fprintf(stderr, "Error: out of memory\n"); |
| 2174 | 2398 | xCloser(sCsv.in); |
| 2175 | 2399 | return 1; |
| 2176 | 2400 | } |
| 2177 | 2401 | nByte = strlen30(zSql); |
| 2178 | - rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); | |
| 2402 | + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); | |
| 2179 | 2403 | if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){ |
| 2180 | 2404 | char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable); |
| 2181 | 2405 | char cSep = '('; |
| 2182 | 2406 | while( csv_read_one_field(&sCsv) ){ |
| 2183 | 2407 | zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z); |
| @@ -2199,11 +2423,11 @@ | ||
| 2199 | 2423 | sqlite3_errmsg(db)); |
| 2200 | 2424 | sqlite3_free(sCsv.z); |
| 2201 | 2425 | xCloser(sCsv.in); |
| 2202 | 2426 | return 1; |
| 2203 | 2427 | } |
| 2204 | - rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); | |
| 2428 | + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); | |
| 2205 | 2429 | } |
| 2206 | 2430 | sqlite3_free(zSql); |
| 2207 | 2431 | if( rc ){ |
| 2208 | 2432 | if (pStmt) sqlite3_finalize(pStmt); |
| 2209 | 2433 | fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db)); |
| @@ -2226,11 +2450,11 @@ | ||
| 2226 | 2450 | zSql[j++] = ','; |
| 2227 | 2451 | zSql[j++] = '?'; |
| 2228 | 2452 | } |
| 2229 | 2453 | zSql[j++] = ')'; |
| 2230 | 2454 | zSql[j] = 0; |
| 2231 | - rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); | |
| 2455 | + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); | |
| 2232 | 2456 | sqlite3_free(zSql); |
| 2233 | 2457 | if( rc ){ |
| 2234 | 2458 | fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db)); |
| 2235 | 2459 | if (pStmt) sqlite3_finalize(pStmt); |
| 2236 | 2460 | xCloser(sCsv.in); |
| @@ -3280,10 +3504,30 @@ | ||
| 3280 | 3504 | sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); |
| 3281 | 3505 | sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); |
| 3282 | 3506 | sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); |
| 3283 | 3507 | } |
| 3284 | 3508 | |
| 3509 | +/* | |
| 3510 | +** Output text to the console in a font that attracts extra attention. | |
| 3511 | +*/ | |
| 3512 | +#ifdef _WIN32 | |
| 3513 | +static void printBold(const char *zText){ | |
| 3514 | + HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE); | |
| 3515 | + CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo; | |
| 3516 | + GetConsoleScreenBufferInfo(out, &defaultScreenInfo); | |
| 3517 | + SetConsoleTextAttribute(out, | |
| 3518 | + FOREGROUND_RED|FOREGROUND_INTENSITY | |
| 3519 | + ); | |
| 3520 | + printf("%s", zText); | |
| 3521 | + SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes); | |
| 3522 | +} | |
| 3523 | +#else | |
| 3524 | +static void printBold(const char *zText){ | |
| 3525 | + printf("\033[1m%s\033[0m", zText); | |
| 3526 | +} | |
| 3527 | +#endif | |
| 3528 | + | |
| 3285 | 3529 | /* |
| 3286 | 3530 | ** Get the argument to an --option. Throw an error and die if no argument |
| 3287 | 3531 | ** is available. |
| 3288 | 3532 | */ |
| 3289 | 3533 | static char *cmdline_option_value(int argc, char **argv, int i){ |
| @@ -3300,10 +3544,11 @@ | ||
| 3300 | 3544 | struct callback_data data; |
| 3301 | 3545 | const char *zInitFile = 0; |
| 3302 | 3546 | char *zFirstCmd = 0; |
| 3303 | 3547 | int i; |
| 3304 | 3548 | int rc = 0; |
| 3549 | + int warnInmemoryDb = 0; | |
| 3305 | 3550 | |
| 3306 | 3551 | if( sqlite3_libversion_number()<3008003 ){ |
| 3307 | 3552 | fprintf(stderr, "Unsuitable SQLite version %s, must be at least 3.8.3", |
| 3308 | 3553 | sqlite3_libversion()); |
| 3309 | 3554 | exit(1); |
| @@ -3394,18 +3639,20 @@ | ||
| 3394 | 3639 | } |
| 3395 | 3640 | } |
| 3396 | 3641 | if( data.zDbFilename==0 ){ |
| 3397 | 3642 | #ifndef SQLITE_OMIT_MEMORYDB |
| 3398 | 3643 | data.zDbFilename = ":memory:"; |
| 3644 | + warnInmemoryDb = argc==1; | |
| 3399 | 3645 | #else |
| 3400 | 3646 | fprintf(stderr,"%s: Error: no database filename specified\n", Argv0); |
| 3401 | 3647 | return 1; |
| 3402 | 3648 | #endif |
| 3403 | 3649 | /***** Begin Fossil Patch *****/ |
| 3404 | 3650 | { |
| 3405 | 3651 | extern void fossil_open(const char **); |
| 3406 | 3652 | fossil_open(&data.zDbFilename); |
| 3653 | + warnInmemoryDb = 0; | |
| 3407 | 3654 | } |
| 3408 | 3655 | /***** End Fossil Patch *****/ |
| 3409 | 3656 | } |
| 3410 | 3657 | data.out = stdout; |
| 3411 | 3658 | |
| @@ -3536,22 +3783,27 @@ | ||
| 3536 | 3783 | char *zHome; |
| 3537 | 3784 | char *zHistory = 0; |
| 3538 | 3785 | int nHistory; |
| 3539 | 3786 | printf( |
| 3540 | 3787 | "SQLite version %s %.19s\n" /*extra-version-info*/ |
| 3541 | - "Enter \".help\" for instructions\n" | |
| 3542 | - "Enter SQL statements terminated with a \";\"\n", | |
| 3788 | + "Enter \".help\" for usage hints.\n", | |
| 3543 | 3789 | sqlite3_libversion(), sqlite3_sourceid() |
| 3544 | 3790 | ); |
| 3791 | + if( warnInmemoryDb ){ | |
| 3792 | + printf("Connected to a "); | |
| 3793 | + printBold("transient in-memory database."); | |
| 3794 | + printf("\nUse \".open FILENAME\" to reopen on a " | |
| 3795 | + "persistent database.\n"); | |
| 3796 | + } | |
| 3545 | 3797 | zHome = find_home_dir(); |
| 3546 | 3798 | if( zHome ){ |
| 3547 | 3799 | nHistory = strlen30(zHome) + 20; |
| 3548 | 3800 | if( (zHistory = malloc(nHistory))!=0 ){ |
| 3549 | 3801 | sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome); |
| 3550 | 3802 | } |
| 3551 | 3803 | } |
| 3552 | -#if defined(HAVE_READLINE) && HAVE_READLINE==1 | |
| 3804 | +#if defined(HAVE_READLINE) | |
| 3553 | 3805 | if( zHistory ) read_history(zHistory); |
| 3554 | 3806 | #endif |
| 3555 | 3807 | rc = process_input(&data, 0); |
| 3556 | 3808 | if( zHistory ){ |
| 3557 | 3809 | stifle_history(100); |
| 3558 | 3810 |
| --- src/shell.c | |
| +++ src/shell.c | |
| @@ -43,18 +43,21 @@ | |
| 43 | # endif |
| 44 | # include <unistd.h> |
| 45 | # include <sys/types.h> |
| 46 | #endif |
| 47 | |
| 48 | #ifdef HAVE_EDITLINE |
| 49 | # include <editline/editline.h> |
| 50 | #endif |
| 51 | #if defined(HAVE_READLINE) && HAVE_READLINE==1 |
| 52 | # include <readline/readline.h> |
| 53 | # include <readline/history.h> |
| 54 | #endif |
| 55 | #if !defined(HAVE_EDITLINE) && (!defined(HAVE_READLINE) || HAVE_READLINE!=1) |
| 56 | # define add_history(X) |
| 57 | # define read_history(X) |
| 58 | # define write_history(X) |
| 59 | # define stifle_history(X) |
| 60 | #endif |
| @@ -411,11 +414,11 @@ | |
| 411 | char *zResult; |
| 412 | if( in!=0 ){ |
| 413 | zResult = local_getline(zPrior, in); |
| 414 | }else{ |
| 415 | zPrompt = isContinuation ? continuePrompt : mainPrompt; |
| 416 | #if defined(HAVE_READLINE) && HAVE_READLINE==1 |
| 417 | free(zPrior); |
| 418 | zResult = readline(zPrompt); |
| 419 | if( zResult && *zResult ) add_history(zResult); |
| 420 | #else |
| 421 | printf("%s", zPrompt); |
| @@ -1003,11 +1006,11 @@ | |
| 1003 | sqlite3_stmt *pSelect; |
| 1004 | int rc; |
| 1005 | int nResult; |
| 1006 | int i; |
| 1007 | const char *z; |
| 1008 | rc = sqlite3_prepare(p->db, zSelect, -1, &pSelect, 0); |
| 1009 | if( rc!=SQLITE_OK || !pSelect ){ |
| 1010 | fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); |
| 1011 | if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++; |
| 1012 | return rc; |
| 1013 | } |
| @@ -1451,11 +1454,11 @@ | |
| 1451 | |
| 1452 | zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0); |
| 1453 | zTableInfo = appendText(zTableInfo, zTable, '"'); |
| 1454 | zTableInfo = appendText(zTableInfo, ");", 0); |
| 1455 | |
| 1456 | rc = sqlite3_prepare(p->db, zTableInfo, -1, &pTableInfo, 0); |
| 1457 | free(zTableInfo); |
| 1458 | if( rc!=SQLITE_OK || !pTableInfo ){ |
| 1459 | return 1; |
| 1460 | } |
| 1461 | |
| @@ -1541,10 +1544,11 @@ | |
| 1541 | ** Text of a help message |
| 1542 | */ |
| 1543 | static char zHelp[] = |
| 1544 | ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" |
| 1545 | ".bail ON|OFF Stop after hitting an error. Default OFF\n" |
| 1546 | ".databases List names and files of attached databases\n" |
| 1547 | ".dump ?TABLE? ... Dump the database in an SQL text format\n" |
| 1548 | " If TABLE specified, only dump tables matching\n" |
| 1549 | " LIKE pattern TABLE.\n" |
| 1550 | ".echo ON|OFF Turn command echo on or off\n" |
| @@ -1580,10 +1584,11 @@ | |
| 1580 | ".print STRING... Print literal STRING\n" |
| 1581 | ".prompt MAIN CONTINUE Replace the standard prompts\n" |
| 1582 | ".quit Exit this program\n" |
| 1583 | ".read FILENAME Execute SQL in FILENAME\n" |
| 1584 | ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n" |
| 1585 | ".schema ?TABLE? Show the CREATE statements\n" |
| 1586 | " If TABLE specified, only show tables matching\n" |
| 1587 | " LIKE pattern TABLE.\n" |
| 1588 | ".separator STRING Change separator used by output mode and .import\n" |
| 1589 | ".show Show the current values for various settings\n" |
| @@ -1893,10 +1898,223 @@ | |
| 1893 | p->cTerm = c; |
| 1894 | } |
| 1895 | if( p->z ) p->z[p->n] = 0; |
| 1896 | return p->z; |
| 1897 | } |
| 1898 | |
| 1899 | /* |
| 1900 | ** If an input line begins with "." then invoke this routine to |
| 1901 | ** process that line. |
| 1902 | ** |
| @@ -1936,11 +2154,13 @@ | |
| 1936 | /* Process the input line. |
| 1937 | */ |
| 1938 | if( nArg==0 ) return 0; /* no tokens, no error */ |
| 1939 | n = strlen30(azArg[0]); |
| 1940 | c = azArg[0][0]; |
| 1941 | if( c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0 ){ |
| 1942 | const char *zDestFile = 0; |
| 1943 | const char *zDb = 0; |
| 1944 | sqlite3 *pDest; |
| 1945 | sqlite3_backup *pBackup; |
| 1946 | int j; |
| @@ -2000,10 +2220,14 @@ | |
| 2000 | ** routine named test_breakpoint(). |
| 2001 | */ |
| 2002 | if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){ |
| 2003 | test_breakpoint(); |
| 2004 | }else |
| 2005 | |
| 2006 | if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 && nArg==1 ){ |
| 2007 | struct callback_data data; |
| 2008 | char *zErrMsg = 0; |
| 2009 | open_db(p, 0); |
| @@ -2173,11 +2397,11 @@ | |
| 2173 | fprintf(stderr, "Error: out of memory\n"); |
| 2174 | xCloser(sCsv.in); |
| 2175 | return 1; |
| 2176 | } |
| 2177 | nByte = strlen30(zSql); |
| 2178 | rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); |
| 2179 | if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){ |
| 2180 | char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable); |
| 2181 | char cSep = '('; |
| 2182 | while( csv_read_one_field(&sCsv) ){ |
| 2183 | zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z); |
| @@ -2199,11 +2423,11 @@ | |
| 2199 | sqlite3_errmsg(db)); |
| 2200 | sqlite3_free(sCsv.z); |
| 2201 | xCloser(sCsv.in); |
| 2202 | return 1; |
| 2203 | } |
| 2204 | rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); |
| 2205 | } |
| 2206 | sqlite3_free(zSql); |
| 2207 | if( rc ){ |
| 2208 | if (pStmt) sqlite3_finalize(pStmt); |
| 2209 | fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db)); |
| @@ -2226,11 +2450,11 @@ | |
| 2226 | zSql[j++] = ','; |
| 2227 | zSql[j++] = '?'; |
| 2228 | } |
| 2229 | zSql[j++] = ')'; |
| 2230 | zSql[j] = 0; |
| 2231 | rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0); |
| 2232 | sqlite3_free(zSql); |
| 2233 | if( rc ){ |
| 2234 | fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db)); |
| 2235 | if (pStmt) sqlite3_finalize(pStmt); |
| 2236 | xCloser(sCsv.in); |
| @@ -3280,10 +3504,30 @@ | |
| 3280 | sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); |
| 3281 | sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); |
| 3282 | sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); |
| 3283 | } |
| 3284 | |
| 3285 | /* |
| 3286 | ** Get the argument to an --option. Throw an error and die if no argument |
| 3287 | ** is available. |
| 3288 | */ |
| 3289 | static char *cmdline_option_value(int argc, char **argv, int i){ |
| @@ -3300,10 +3544,11 @@ | |
| 3300 | struct callback_data data; |
| 3301 | const char *zInitFile = 0; |
| 3302 | char *zFirstCmd = 0; |
| 3303 | int i; |
| 3304 | int rc = 0; |
| 3305 | |
| 3306 | if( sqlite3_libversion_number()<3008003 ){ |
| 3307 | fprintf(stderr, "Unsuitable SQLite version %s, must be at least 3.8.3", |
| 3308 | sqlite3_libversion()); |
| 3309 | exit(1); |
| @@ -3394,18 +3639,20 @@ | |
| 3394 | } |
| 3395 | } |
| 3396 | if( data.zDbFilename==0 ){ |
| 3397 | #ifndef SQLITE_OMIT_MEMORYDB |
| 3398 | data.zDbFilename = ":memory:"; |
| 3399 | #else |
| 3400 | fprintf(stderr,"%s: Error: no database filename specified\n", Argv0); |
| 3401 | return 1; |
| 3402 | #endif |
| 3403 | /***** Begin Fossil Patch *****/ |
| 3404 | { |
| 3405 | extern void fossil_open(const char **); |
| 3406 | fossil_open(&data.zDbFilename); |
| 3407 | } |
| 3408 | /***** End Fossil Patch *****/ |
| 3409 | } |
| 3410 | data.out = stdout; |
| 3411 | |
| @@ -3536,22 +3783,27 @@ | |
| 3536 | char *zHome; |
| 3537 | char *zHistory = 0; |
| 3538 | int nHistory; |
| 3539 | printf( |
| 3540 | "SQLite version %s %.19s\n" /*extra-version-info*/ |
| 3541 | "Enter \".help\" for instructions\n" |
| 3542 | "Enter SQL statements terminated with a \";\"\n", |
| 3543 | sqlite3_libversion(), sqlite3_sourceid() |
| 3544 | ); |
| 3545 | zHome = find_home_dir(); |
| 3546 | if( zHome ){ |
| 3547 | nHistory = strlen30(zHome) + 20; |
| 3548 | if( (zHistory = malloc(nHistory))!=0 ){ |
| 3549 | sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome); |
| 3550 | } |
| 3551 | } |
| 3552 | #if defined(HAVE_READLINE) && HAVE_READLINE==1 |
| 3553 | if( zHistory ) read_history(zHistory); |
| 3554 | #endif |
| 3555 | rc = process_input(&data, 0); |
| 3556 | if( zHistory ){ |
| 3557 | stifle_history(100); |
| 3558 |
| --- src/shell.c | |
| +++ src/shell.c | |
| @@ -43,18 +43,21 @@ | |
| 43 | # endif |
| 44 | # include <unistd.h> |
| 45 | # include <sys/types.h> |
| 46 | #endif |
| 47 | |
| 48 | #if defined(HAVE_READLINE) && HAVE_READLINE!=0 |
| 49 | # include <readline/readline.h> |
| 50 | # include <readline/history.h> |
| 51 | #else |
| 52 | # undef HAVE_READLINE |
| 53 | #endif |
| 54 | #if defined(HAVE_EDITLINE) && !defined(HAVE_READLINE) |
| 55 | # define HAVE_READLINE 1 |
| 56 | # include <editline/readline.h> |
| 57 | #endif |
| 58 | #if !defined(HAVE_READLINE) |
| 59 | # define add_history(X) |
| 60 | # define read_history(X) |
| 61 | # define write_history(X) |
| 62 | # define stifle_history(X) |
| 63 | #endif |
| @@ -411,11 +414,11 @@ | |
| 414 | char *zResult; |
| 415 | if( in!=0 ){ |
| 416 | zResult = local_getline(zPrior, in); |
| 417 | }else{ |
| 418 | zPrompt = isContinuation ? continuePrompt : mainPrompt; |
| 419 | #if defined(HAVE_READLINE) |
| 420 | free(zPrior); |
| 421 | zResult = readline(zPrompt); |
| 422 | if( zResult && *zResult ) add_history(zResult); |
| 423 | #else |
| 424 | printf("%s", zPrompt); |
| @@ -1003,11 +1006,11 @@ | |
| 1006 | sqlite3_stmt *pSelect; |
| 1007 | int rc; |
| 1008 | int nResult; |
| 1009 | int i; |
| 1010 | const char *z; |
| 1011 | rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0); |
| 1012 | if( rc!=SQLITE_OK || !pSelect ){ |
| 1013 | fprintf(p->out, "/**** ERROR: (%d) %s *****/\n", rc, sqlite3_errmsg(p->db)); |
| 1014 | if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++; |
| 1015 | return rc; |
| 1016 | } |
| @@ -1451,11 +1454,11 @@ | |
| 1454 | |
| 1455 | zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0); |
| 1456 | zTableInfo = appendText(zTableInfo, zTable, '"'); |
| 1457 | zTableInfo = appendText(zTableInfo, ");", 0); |
| 1458 | |
| 1459 | rc = sqlite3_prepare_v2(p->db, zTableInfo, -1, &pTableInfo, 0); |
| 1460 | free(zTableInfo); |
| 1461 | if( rc!=SQLITE_OK || !pTableInfo ){ |
| 1462 | return 1; |
| 1463 | } |
| 1464 | |
| @@ -1541,10 +1544,11 @@ | |
| 1544 | ** Text of a help message |
| 1545 | */ |
| 1546 | static char zHelp[] = |
| 1547 | ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n" |
| 1548 | ".bail ON|OFF Stop after hitting an error. Default OFF\n" |
| 1549 | ".clone NEWDB Clone data into NEWDB from the existing database\n" |
| 1550 | ".databases List names and files of attached databases\n" |
| 1551 | ".dump ?TABLE? ... Dump the database in an SQL text format\n" |
| 1552 | " If TABLE specified, only dump tables matching\n" |
| 1553 | " LIKE pattern TABLE.\n" |
| 1554 | ".echo ON|OFF Turn command echo on or off\n" |
| @@ -1580,10 +1584,11 @@ | |
| 1584 | ".print STRING... Print literal STRING\n" |
| 1585 | ".prompt MAIN CONTINUE Replace the standard prompts\n" |
| 1586 | ".quit Exit this program\n" |
| 1587 | ".read FILENAME Execute SQL in FILENAME\n" |
| 1588 | ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n" |
| 1589 | ".save FILE Write in-memory database into FILE\n" |
| 1590 | ".schema ?TABLE? Show the CREATE statements\n" |
| 1591 | " If TABLE specified, only show tables matching\n" |
| 1592 | " LIKE pattern TABLE.\n" |
| 1593 | ".separator STRING Change separator used by output mode and .import\n" |
| 1594 | ".show Show the current values for various settings\n" |
| @@ -1893,10 +1898,223 @@ | |
| 1898 | p->cTerm = c; |
| 1899 | } |
| 1900 | if( p->z ) p->z[p->n] = 0; |
| 1901 | return p->z; |
| 1902 | } |
| 1903 | |
| 1904 | /* |
| 1905 | ** Try to transfer data for table zTable. If an error is seen while |
| 1906 | ** moving forward, try to go backwards. The backwards movement won't |
| 1907 | ** work for WITHOUT ROWID tables. |
| 1908 | */ |
| 1909 | static void tryToCloneData( |
| 1910 | struct callback_data *p, |
| 1911 | sqlite3 *newDb, |
| 1912 | const char *zTable |
| 1913 | ){ |
| 1914 | sqlite3_stmt *pQuery = 0; |
| 1915 | sqlite3_stmt *pInsert = 0; |
| 1916 | char *zQuery = 0; |
| 1917 | char *zInsert = 0; |
| 1918 | int rc; |
| 1919 | int i, j, n; |
| 1920 | int nTable = (int)strlen(zTable); |
| 1921 | int k = 0; |
| 1922 | int cnt = 0; |
| 1923 | const int spinRate = 10000; |
| 1924 | |
| 1925 | zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable); |
| 1926 | rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); |
| 1927 | if( rc ){ |
| 1928 | fprintf(stderr, "Error %d: %s on [%s]\n", |
| 1929 | sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), |
| 1930 | zQuery); |
| 1931 | goto end_data_xfer; |
| 1932 | } |
| 1933 | n = sqlite3_column_count(pQuery); |
| 1934 | zInsert = sqlite3_malloc(200 + nTable + n*3); |
| 1935 | if( zInsert==0 ){ |
| 1936 | fprintf(stderr, "out of memory\n"); |
| 1937 | goto end_data_xfer; |
| 1938 | } |
| 1939 | sqlite3_snprintf(200+nTable,zInsert, |
| 1940 | "INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable); |
| 1941 | i = (int)strlen(zInsert); |
| 1942 | for(j=1; j<n; j++){ |
| 1943 | memcpy(zInsert+i, ",?", 2); |
| 1944 | i += 2; |
| 1945 | } |
| 1946 | memcpy(zInsert+i, ");", 3); |
| 1947 | rc = sqlite3_prepare_v2(newDb, zInsert, -1, &pInsert, 0); |
| 1948 | if( rc ){ |
| 1949 | fprintf(stderr, "Error %d: %s on [%s]\n", |
| 1950 | sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb), |
| 1951 | zQuery); |
| 1952 | goto end_data_xfer; |
| 1953 | } |
| 1954 | for(k=0; k<2; k++){ |
| 1955 | while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){ |
| 1956 | for(i=0; i<n; i++){ |
| 1957 | switch( sqlite3_column_type(pQuery, i) ){ |
| 1958 | case SQLITE_NULL: { |
| 1959 | sqlite3_bind_null(pInsert, i+1); |
| 1960 | break; |
| 1961 | } |
| 1962 | case SQLITE_INTEGER: { |
| 1963 | sqlite3_bind_int64(pInsert, i+1, sqlite3_column_int64(pQuery,i)); |
| 1964 | break; |
| 1965 | } |
| 1966 | case SQLITE_FLOAT: { |
| 1967 | sqlite3_bind_double(pInsert, i+1, sqlite3_column_double(pQuery,i)); |
| 1968 | break; |
| 1969 | } |
| 1970 | case SQLITE_TEXT: { |
| 1971 | sqlite3_bind_text(pInsert, i+1, |
| 1972 | (const char*)sqlite3_column_text(pQuery,i), |
| 1973 | -1, SQLITE_STATIC); |
| 1974 | break; |
| 1975 | } |
| 1976 | case SQLITE_BLOB: { |
| 1977 | sqlite3_bind_blob(pInsert, i+1, sqlite3_column_blob(pQuery,i), |
| 1978 | sqlite3_column_bytes(pQuery,i), |
| 1979 | SQLITE_STATIC); |
| 1980 | break; |
| 1981 | } |
| 1982 | } |
| 1983 | } /* End for */ |
| 1984 | rc = sqlite3_step(pInsert); |
| 1985 | if( rc!=SQLITE_OK && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ |
| 1986 | fprintf(stderr, "Error %d: %s\n", sqlite3_extended_errcode(newDb), |
| 1987 | sqlite3_errmsg(newDb)); |
| 1988 | } |
| 1989 | sqlite3_reset(pInsert); |
| 1990 | cnt++; |
| 1991 | if( (cnt%spinRate)==0 ){ |
| 1992 | printf("%c\b", "|/-\\"[(cnt/spinRate)%4]); |
| 1993 | fflush(stdout); |
| 1994 | } |
| 1995 | } /* End while */ |
| 1996 | if( rc==SQLITE_DONE ) break; |
| 1997 | sqlite3_finalize(pQuery); |
| 1998 | sqlite3_free(zQuery); |
| 1999 | zQuery = sqlite3_mprintf("SELECT * FROM \"%w\" ORDER BY rowid DESC;", |
| 2000 | zTable); |
| 2001 | rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); |
| 2002 | if( rc ){ |
| 2003 | fprintf(stderr, "Warning: cannot step \"%s\" backwards", zTable); |
| 2004 | break; |
| 2005 | } |
| 2006 | } /* End for(k=0...) */ |
| 2007 | |
| 2008 | end_data_xfer: |
| 2009 | sqlite3_finalize(pQuery); |
| 2010 | sqlite3_finalize(pInsert); |
| 2011 | sqlite3_free(zQuery); |
| 2012 | sqlite3_free(zInsert); |
| 2013 | } |
| 2014 | |
| 2015 | |
| 2016 | /* |
| 2017 | ** Try to transfer all rows of the schema that match zWhere. For |
| 2018 | ** each row, invoke xForEach() on the object defined by that row. |
| 2019 | ** If an error is encountered while moving forward through the |
| 2020 | ** sqlite_master table, try again moving backwards. |
| 2021 | */ |
| 2022 | static void tryToCloneSchema( |
| 2023 | struct callback_data *p, |
| 2024 | sqlite3 *newDb, |
| 2025 | const char *zWhere, |
| 2026 | void (*xForEach)(struct callback_data*,sqlite3*,const char*) |
| 2027 | ){ |
| 2028 | sqlite3_stmt *pQuery = 0; |
| 2029 | char *zQuery = 0; |
| 2030 | int rc; |
| 2031 | const unsigned char *zName; |
| 2032 | const unsigned char *zSql; |
| 2033 | char *zErrMsg = 0; |
| 2034 | |
| 2035 | zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_master" |
| 2036 | " WHERE %s", zWhere); |
| 2037 | rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); |
| 2038 | if( rc ){ |
| 2039 | fprintf(stderr, "Error: (%d) %s on [%s]\n", |
| 2040 | sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), |
| 2041 | zQuery); |
| 2042 | goto end_schema_xfer; |
| 2043 | } |
| 2044 | while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){ |
| 2045 | zName = sqlite3_column_text(pQuery, 0); |
| 2046 | zSql = sqlite3_column_text(pQuery, 1); |
| 2047 | printf("%s... ", zName); fflush(stdout); |
| 2048 | sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); |
| 2049 | if( zErrMsg ){ |
| 2050 | fprintf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); |
| 2051 | sqlite3_free(zErrMsg); |
| 2052 | zErrMsg = 0; |
| 2053 | } |
| 2054 | if( xForEach ){ |
| 2055 | xForEach(p, newDb, (const char*)zName); |
| 2056 | } |
| 2057 | printf("done\n"); |
| 2058 | } |
| 2059 | if( rc!=SQLITE_DONE ){ |
| 2060 | sqlite3_finalize(pQuery); |
| 2061 | sqlite3_free(zQuery); |
| 2062 | zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_master" |
| 2063 | " WHERE %s ORDER BY rowid DESC", zWhere); |
| 2064 | rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0); |
| 2065 | if( rc ){ |
| 2066 | fprintf(stderr, "Error: (%d) %s on [%s]\n", |
| 2067 | sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), |
| 2068 | zQuery); |
| 2069 | goto end_schema_xfer; |
| 2070 | } |
| 2071 | while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){ |
| 2072 | zName = sqlite3_column_text(pQuery, 0); |
| 2073 | zSql = sqlite3_column_text(pQuery, 1); |
| 2074 | printf("%s... ", zName); fflush(stdout); |
| 2075 | sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg); |
| 2076 | if( zErrMsg ){ |
| 2077 | fprintf(stderr, "Error: %s\nSQL: [%s]\n", zErrMsg, zSql); |
| 2078 | sqlite3_free(zErrMsg); |
| 2079 | zErrMsg = 0; |
| 2080 | } |
| 2081 | if( xForEach ){ |
| 2082 | xForEach(p, newDb, (const char*)zName); |
| 2083 | } |
| 2084 | printf("done\n"); |
| 2085 | } |
| 2086 | } |
| 2087 | end_schema_xfer: |
| 2088 | sqlite3_finalize(pQuery); |
| 2089 | sqlite3_free(zQuery); |
| 2090 | } |
| 2091 | |
| 2092 | /* |
| 2093 | ** Open a new database file named "zNewDb". Try to recover as much information |
| 2094 | ** as possible out of the main database (which might be corrupt) and write it |
| 2095 | ** into zNewDb. |
| 2096 | */ |
| 2097 | static void tryToClone(struct callback_data *p, const char *zNewDb){ |
| 2098 | int rc; |
| 2099 | sqlite3 *newDb = 0; |
| 2100 | if( access(zNewDb,0)==0 ){ |
| 2101 | fprintf(stderr, "File \"%s\" already exists.\n", zNewDb); |
| 2102 | return; |
| 2103 | } |
| 2104 | rc = sqlite3_open(zNewDb, &newDb); |
| 2105 | if( rc ){ |
| 2106 | fprintf(stderr, "Cannot create output database: %s\n", |
| 2107 | sqlite3_errmsg(newDb)); |
| 2108 | }else{ |
| 2109 | sqlite3_exec(newDb, "BEGIN EXCLUSIVE;", 0, 0, 0); |
| 2110 | tryToCloneSchema(p, newDb, "type='table'", tryToCloneData); |
| 2111 | tryToCloneSchema(p, newDb, "type!='table'", 0); |
| 2112 | sqlite3_exec(newDb, "COMMIT;", 0, 0, 0); |
| 2113 | } |
| 2114 | sqlite3_close(newDb); |
| 2115 | } |
| 2116 | |
| 2117 | /* |
| 2118 | ** If an input line begins with "." then invoke this routine to |
| 2119 | ** process that line. |
| 2120 | ** |
| @@ -1936,11 +2154,13 @@ | |
| 2154 | /* Process the input line. |
| 2155 | */ |
| 2156 | if( nArg==0 ) return 0; /* no tokens, no error */ |
| 2157 | n = strlen30(azArg[0]); |
| 2158 | c = azArg[0][0]; |
| 2159 | if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0) |
| 2160 | || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0) |
| 2161 | ){ |
| 2162 | const char *zDestFile = 0; |
| 2163 | const char *zDb = 0; |
| 2164 | sqlite3 *pDest; |
| 2165 | sqlite3_backup *pBackup; |
| 2166 | int j; |
| @@ -2000,10 +2220,14 @@ | |
| 2220 | ** routine named test_breakpoint(). |
| 2221 | */ |
| 2222 | if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){ |
| 2223 | test_breakpoint(); |
| 2224 | }else |
| 2225 | |
| 2226 | if( c=='c' && strncmp(azArg[0], "clone", n)==0 && nArg>1 && nArg<3 ){ |
| 2227 | tryToClone(p, azArg[1]); |
| 2228 | }else |
| 2229 | |
| 2230 | if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 && nArg==1 ){ |
| 2231 | struct callback_data data; |
| 2232 | char *zErrMsg = 0; |
| 2233 | open_db(p, 0); |
| @@ -2173,11 +2397,11 @@ | |
| 2397 | fprintf(stderr, "Error: out of memory\n"); |
| 2398 | xCloser(sCsv.in); |
| 2399 | return 1; |
| 2400 | } |
| 2401 | nByte = strlen30(zSql); |
| 2402 | rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 2403 | if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){ |
| 2404 | char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable); |
| 2405 | char cSep = '('; |
| 2406 | while( csv_read_one_field(&sCsv) ){ |
| 2407 | zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z); |
| @@ -2199,11 +2423,11 @@ | |
| 2423 | sqlite3_errmsg(db)); |
| 2424 | sqlite3_free(sCsv.z); |
| 2425 | xCloser(sCsv.in); |
| 2426 | return 1; |
| 2427 | } |
| 2428 | rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 2429 | } |
| 2430 | sqlite3_free(zSql); |
| 2431 | if( rc ){ |
| 2432 | if (pStmt) sqlite3_finalize(pStmt); |
| 2433 | fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db)); |
| @@ -2226,11 +2450,11 @@ | |
| 2450 | zSql[j++] = ','; |
| 2451 | zSql[j++] = '?'; |
| 2452 | } |
| 2453 | zSql[j++] = ')'; |
| 2454 | zSql[j] = 0; |
| 2455 | rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 2456 | sqlite3_free(zSql); |
| 2457 | if( rc ){ |
| 2458 | fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db)); |
| 2459 | if (pStmt) sqlite3_finalize(pStmt); |
| 2460 | xCloser(sCsv.in); |
| @@ -3280,10 +3504,30 @@ | |
| 3504 | sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); |
| 3505 | sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); |
| 3506 | sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); |
| 3507 | } |
| 3508 | |
| 3509 | /* |
| 3510 | ** Output text to the console in a font that attracts extra attention. |
| 3511 | */ |
| 3512 | #ifdef _WIN32 |
| 3513 | static void printBold(const char *zText){ |
| 3514 | HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE); |
| 3515 | CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo; |
| 3516 | GetConsoleScreenBufferInfo(out, &defaultScreenInfo); |
| 3517 | SetConsoleTextAttribute(out, |
| 3518 | FOREGROUND_RED|FOREGROUND_INTENSITY |
| 3519 | ); |
| 3520 | printf("%s", zText); |
| 3521 | SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes); |
| 3522 | } |
| 3523 | #else |
| 3524 | static void printBold(const char *zText){ |
| 3525 | printf("\033[1m%s\033[0m", zText); |
| 3526 | } |
| 3527 | #endif |
| 3528 | |
| 3529 | /* |
| 3530 | ** Get the argument to an --option. Throw an error and die if no argument |
| 3531 | ** is available. |
| 3532 | */ |
| 3533 | static char *cmdline_option_value(int argc, char **argv, int i){ |
| @@ -3300,10 +3544,11 @@ | |
| 3544 | struct callback_data data; |
| 3545 | const char *zInitFile = 0; |
| 3546 | char *zFirstCmd = 0; |
| 3547 | int i; |
| 3548 | int rc = 0; |
| 3549 | int warnInmemoryDb = 0; |
| 3550 | |
| 3551 | if( sqlite3_libversion_number()<3008003 ){ |
| 3552 | fprintf(stderr, "Unsuitable SQLite version %s, must be at least 3.8.3", |
| 3553 | sqlite3_libversion()); |
| 3554 | exit(1); |
| @@ -3394,18 +3639,20 @@ | |
| 3639 | } |
| 3640 | } |
| 3641 | if( data.zDbFilename==0 ){ |
| 3642 | #ifndef SQLITE_OMIT_MEMORYDB |
| 3643 | data.zDbFilename = ":memory:"; |
| 3644 | warnInmemoryDb = argc==1; |
| 3645 | #else |
| 3646 | fprintf(stderr,"%s: Error: no database filename specified\n", Argv0); |
| 3647 | return 1; |
| 3648 | #endif |
| 3649 | /***** Begin Fossil Patch *****/ |
| 3650 | { |
| 3651 | extern void fossil_open(const char **); |
| 3652 | fossil_open(&data.zDbFilename); |
| 3653 | warnInmemoryDb = 0; |
| 3654 | } |
| 3655 | /***** End Fossil Patch *****/ |
| 3656 | } |
| 3657 | data.out = stdout; |
| 3658 | |
| @@ -3536,22 +3783,27 @@ | |
| 3783 | char *zHome; |
| 3784 | char *zHistory = 0; |
| 3785 | int nHistory; |
| 3786 | printf( |
| 3787 | "SQLite version %s %.19s\n" /*extra-version-info*/ |
| 3788 | "Enter \".help\" for usage hints.\n", |
| 3789 | sqlite3_libversion(), sqlite3_sourceid() |
| 3790 | ); |
| 3791 | if( warnInmemoryDb ){ |
| 3792 | printf("Connected to a "); |
| 3793 | printBold("transient in-memory database."); |
| 3794 | printf("\nUse \".open FILENAME\" to reopen on a " |
| 3795 | "persistent database.\n"); |
| 3796 | } |
| 3797 | zHome = find_home_dir(); |
| 3798 | if( zHome ){ |
| 3799 | nHistory = strlen30(zHome) + 20; |
| 3800 | if( (zHistory = malloc(nHistory))!=0 ){ |
| 3801 | sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome); |
| 3802 | } |
| 3803 | } |
| 3804 | #if defined(HAVE_READLINE) |
| 3805 | if( zHistory ) read_history(zHistory); |
| 3806 | #endif |
| 3807 | rc = process_input(&data, 0); |
| 3808 | if( zHistory ){ |
| 3809 | stifle_history(100); |
| 3810 |
+2
-2
| --- src/sqlcmd.c | ||
| +++ src/sqlcmd.c | ||
| @@ -42,11 +42,11 @@ | ||
| 42 | 42 | g.db = sqlite3_context_db_handle(context); |
| 43 | 43 | g.repositoryOpen = 1; |
| 44 | 44 | rid = name_to_rid(zName); |
| 45 | 45 | if( rid==0 ) return; |
| 46 | 46 | if( content_get(rid, &cx) ){ |
| 47 | - sqlite3_result_blob(context, blob_buffer(&cx), blob_size(&cx), | |
| 47 | + sqlite3_result_blob(context, blob_buffer(&cx), blob_size(&cx), | |
| 48 | 48 | SQLITE_TRANSIENT); |
| 49 | 49 | blob_reset(&cx); |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| @@ -137,11 +137,11 @@ | ||
| 137 | 137 | ** |
| 138 | 138 | ** WARNING: Careless use of this command can corrupt a Fossil repository |
| 139 | 139 | ** in ways that are unrecoverable. Be sure you know what you are doing before |
| 140 | 140 | ** running any SQL commands that modifies the repository database. |
| 141 | 141 | */ |
| 142 | -void sqlite3_cmd(void){ | |
| 142 | +void cmd_sqlite3(void){ | |
| 143 | 143 | extern int sqlite3_shell(int, char**); |
| 144 | 144 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 145 | 145 | db_close(1); |
| 146 | 146 | sqlite3_shutdown(); |
| 147 | 147 | sqlite3_shell(g.argc-1, g.argv+1); |
| 148 | 148 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -42,11 +42,11 @@ | |
| 42 | g.db = sqlite3_context_db_handle(context); |
| 43 | g.repositoryOpen = 1; |
| 44 | rid = name_to_rid(zName); |
| 45 | if( rid==0 ) return; |
| 46 | if( content_get(rid, &cx) ){ |
| 47 | sqlite3_result_blob(context, blob_buffer(&cx), blob_size(&cx), |
| 48 | SQLITE_TRANSIENT); |
| 49 | blob_reset(&cx); |
| 50 | } |
| 51 | } |
| 52 | |
| @@ -137,11 +137,11 @@ | |
| 137 | ** |
| 138 | ** WARNING: Careless use of this command can corrupt a Fossil repository |
| 139 | ** in ways that are unrecoverable. Be sure you know what you are doing before |
| 140 | ** running any SQL commands that modifies the repository database. |
| 141 | */ |
| 142 | void sqlite3_cmd(void){ |
| 143 | extern int sqlite3_shell(int, char**); |
| 144 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 145 | db_close(1); |
| 146 | sqlite3_shutdown(); |
| 147 | sqlite3_shell(g.argc-1, g.argv+1); |
| 148 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -42,11 +42,11 @@ | |
| 42 | g.db = sqlite3_context_db_handle(context); |
| 43 | g.repositoryOpen = 1; |
| 44 | rid = name_to_rid(zName); |
| 45 | if( rid==0 ) return; |
| 46 | if( content_get(rid, &cx) ){ |
| 47 | sqlite3_result_blob(context, blob_buffer(&cx), blob_size(&cx), |
| 48 | SQLITE_TRANSIENT); |
| 49 | blob_reset(&cx); |
| 50 | } |
| 51 | } |
| 52 | |
| @@ -137,11 +137,11 @@ | |
| 137 | ** |
| 138 | ** WARNING: Careless use of this command can corrupt a Fossil repository |
| 139 | ** in ways that are unrecoverable. Be sure you know what you are doing before |
| 140 | ** running any SQL commands that modifies the repository database. |
| 141 | */ |
| 142 | void cmd_sqlite3(void){ |
| 143 | extern int sqlite3_shell(int, char**); |
| 144 | db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); |
| 145 | db_close(1); |
| 146 | sqlite3_shutdown(); |
| 147 | sqlite3_shell(g.argc-1, g.argv+1); |
| 148 |
+119
-115
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | -** version 3.8.3. By combining all the individual C code files into this | |
| 3 | +** version 3.8.3.1. By combining all the individual C code files into this | |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -133,13 +133,13 @@ | ||
| 133 | 133 | ** |
| 134 | 134 | ** See also: [sqlite3_libversion()], |
| 135 | 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | 137 | */ |
| 138 | -#define SQLITE_VERSION "3.8.3" | |
| 138 | +#define SQLITE_VERSION "3.8.3.1" | |
| 139 | 139 | #define SQLITE_VERSION_NUMBER 3008003 |
| 140 | -#define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc" | |
| 140 | +#define SQLITE_SOURCE_ID "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e" | |
| 141 | 141 | |
| 142 | 142 | /* |
| 143 | 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | 145 | ** |
| @@ -11303,10 +11303,11 @@ | ||
| 11303 | 11303 | |
| 11304 | 11304 | /* |
| 11305 | 11305 | ** A bit in a Bitmask |
| 11306 | 11306 | */ |
| 11307 | 11307 | #define MASKBIT(n) (((Bitmask)1)<<(n)) |
| 11308 | +#define MASKBIT32(n) (((unsigned int)1)<<(n)) | |
| 11308 | 11309 | |
| 11309 | 11310 | /* |
| 11310 | 11311 | ** The following structure describes the FROM clause of a SELECT statement. |
| 11311 | 11312 | ** Each table or subquery in the FROM clause is a separate element of |
| 11312 | 11313 | ** the SrcList.a[] array. |
| @@ -22605,11 +22606,12 @@ | ||
| 22605 | 22606 | |
| 22606 | 22607 | /* |
| 22607 | 22608 | ** Read or write a four-byte big-endian integer value. |
| 22608 | 22609 | */ |
| 22609 | 22610 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 22610 | - return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 22611 | + testcase( p[0]&0x80 ); | |
| 22612 | + return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 22611 | 22613 | } |
| 22612 | 22614 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 22613 | 22615 | p[0] = (u8)(v>>24); |
| 22614 | 22616 | p[1] = (u8)(v>>16); |
| 22615 | 22617 | p[2] = (u8)(v>>8); |
| @@ -22946,11 +22948,11 @@ | ||
| 22946 | 22948 | |
| 22947 | 22949 | /* |
| 22948 | 22950 | ** The hashing function. |
| 22949 | 22951 | */ |
| 22950 | 22952 | static unsigned int strHash(const char *z, int nKey){ |
| 22951 | - int h = 0; | |
| 22953 | + unsigned int h = 0; | |
| 22952 | 22954 | assert( nKey>=0 ); |
| 22953 | 22955 | while( nKey > 0 ){ |
| 22954 | 22956 | h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; |
| 22955 | 22957 | nKey--; |
| 22956 | 22958 | } |
| @@ -27650,11 +27652,11 @@ | ||
| 27650 | 27652 | |
| 27651 | 27653 | /* Update the global lock state and do debug tracing */ |
| 27652 | 27654 | #ifdef SQLITE_DEBUG |
| 27653 | 27655 | { u16 mask; |
| 27654 | 27656 | OSTRACE(("SHM-LOCK ")); |
| 27655 | - mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<<ofst); | |
| 27657 | + mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst); | |
| 27656 | 27658 | if( rc==SQLITE_OK ){ |
| 27657 | 27659 | if( lockType==F_UNLCK ){ |
| 27658 | 27660 | OSTRACE(("unlock %d ok", ofst)); |
| 27659 | 27661 | pShmNode->exclMask &= ~mask; |
| 27660 | 27662 | pShmNode->sharedMask &= ~mask; |
| @@ -35374,11 +35376,34 @@ | ||
| 35374 | 35376 | ** function. |
| 35375 | 35377 | */ |
| 35376 | 35378 | static void *winConvertFromUtf8Filename(const char *zFilename){ |
| 35377 | 35379 | void *zConverted = 0; |
| 35378 | 35380 | if( osIsNT() ){ |
| 35379 | - zConverted = winUtf8ToUnicode(zFilename); | |
| 35381 | + int nChar; | |
| 35382 | + LPWSTR zWideFilename; | |
| 35383 | + | |
| 35384 | + nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); | |
| 35385 | + if( nChar==0 ){ | |
| 35386 | + return 0; | |
| 35387 | + } | |
| 35388 | + zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR)+8 ); | |
| 35389 | + if( zWideFilename==0 ){ | |
| 35390 | + return 0; | |
| 35391 | + } | |
| 35392 | + nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, | |
| 35393 | + zWideFilename+4, nChar); | |
| 35394 | + if( nChar==0 ){ | |
| 35395 | + sqlite3_free(zWideFilename); | |
| 35396 | + return 0; | |
| 35397 | + }else if( nChar>SQLITE_WIN32_MAX_PATH_CHARS | |
| 35398 | + && winIsDriveLetterAndColon(zFilename) | |
| 35399 | + && zFilename[2] == '\\' ){ | |
| 35400 | + memcpy(zWideFilename, L"\\\\?\\", 8); | |
| 35401 | + }else{ | |
| 35402 | + memmove(zWideFilename, zWideFilename+4, nChar*sizeof(WCHAR)); | |
| 35403 | + } | |
| 35404 | + zConverted = zWideFilename; | |
| 35380 | 35405 | } |
| 35381 | 35406 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 35382 | 35407 | else{ |
| 35383 | 35408 | zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); |
| 35384 | 35409 | } |
| @@ -36305,67 +36330,14 @@ | ||
| 36305 | 36330 | */ |
| 36306 | 36331 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 36307 | 36332 | sqlite3_data_directory, winGetDirSep(), zRelative); |
| 36308 | 36333 | return SQLITE_OK; |
| 36309 | 36334 | } |
| 36310 | - nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, NULL, 0); | |
| 36311 | - if( nByte==0 ){ | |
| 36312 | - return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)osGetLastError(), | |
| 36313 | - "winFullPathname", zRelative); | |
| 36314 | - } | |
| 36315 | - if( osIsNT() ){ | |
| 36316 | - LPWSTR zWideFilename; | |
| 36317 | - | |
| 36318 | - if( nByte>SQLITE_WIN32_MAX_PATH_CHARS ){ | |
| 36319 | - /* No Win32 API functions can handle such long paths. Let's see if | |
| 36320 | - * we can do something about it. If not, just leave it as is. */ | |
| 36321 | - if( winIsDirSep(zRelative[0]) && winIsDirSep(zRelative[1]) | |
| 36322 | - && zRelative[2]!='?' ){ | |
| 36323 | - /* It's an UNC path, convert it to an extended UNC path. */ | |
| 36324 | - zWideFilename = sqlite3MallocZero( (nByte+6)*sizeof(WCHAR) ); | |
| 36325 | - if( zWideFilename==0 ){ | |
| 36326 | - return SQLITE_IOERR_NOMEM; | |
| 36327 | - } | |
| 36328 | - memcpy(zWideFilename, L"\\\\?\\UNC\\", 16); | |
| 36329 | - nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative+2, -1, | |
| 36330 | - zWideFilename+8, nByte); | |
| 36331 | - goto finished; | |
| 36332 | - }else if( winIsDriveLetterAndColon(zRelative) | |
| 36333 | - && winIsDirSep(zRelative[2]) ){ | |
| 36334 | - /* It has a correct drive prefix, convert to extended form. */ | |
| 36335 | - zWideFilename = sqlite3MallocZero( (nByte+4)*sizeof(WCHAR) ); | |
| 36336 | - if( zWideFilename==0 ){ | |
| 36337 | - return SQLITE_IOERR_NOMEM; | |
| 36338 | - } | |
| 36339 | - memcpy(zWideFilename, L"\\\\?\\", 8); | |
| 36340 | - nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, | |
| 36341 | - zWideFilename+4, nByte); | |
| 36342 | - zWideFilename[6] = '\\'; | |
| 36343 | - goto finished; | |
| 36344 | - } | |
| 36345 | - /* Another form, e.g. relative path or maybe it already | |
| 36346 | - * has the '\\?\' prefix. Just leave it as-is. */ | |
| 36347 | - } | |
| 36348 | - zWideFilename = sqlite3Malloc( nByte*sizeof(WCHAR) ); | |
| 36349 | - if( zWideFilename==0 ){ | |
| 36350 | - return SQLITE_IOERR_NOMEM; | |
| 36351 | - } | |
| 36352 | - nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, | |
| 36353 | - zWideFilename, nByte); | |
| 36354 | - if( nByte==0 ){ | |
| 36355 | - sqlite3_free(zWideFilename); | |
| 36356 | - return SQLITE_IOERR_NOMEM; | |
| 36357 | - } | |
| 36358 | - finished: | |
| 36359 | - zConverted = zWideFilename; | |
| 36360 | - }else{ | |
| 36361 | - zConverted = sqlite3_win32_utf8_to_mbcs(zRelative); | |
| 36362 | - if( zConverted==0 ){ | |
| 36363 | - return SQLITE_IOERR_NOMEM; | |
| 36364 | - } | |
| 36365 | - } | |
| 36366 | - | |
| 36335 | + zConverted = winConvertFromUtf8Filename(zRelative); | |
| 36336 | + if( zConverted==0 ){ | |
| 36337 | + return SQLITE_IOERR_NOMEM; | |
| 36338 | + } | |
| 36367 | 36339 | if( osIsNT() ){ |
| 36368 | 36340 | LPWSTR zTemp; |
| 36369 | 36341 | nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); |
| 36370 | 36342 | if( nByte==0 ){ |
| 36371 | 36343 | sqlite3_free(zConverted); |
| @@ -38479,10 +38451,11 @@ | ||
| 38479 | 38451 | unsigned int nPinned; |
| 38480 | 38452 | PCache1 *pCache = (PCache1 *)p; |
| 38481 | 38453 | PGroup *pGroup; |
| 38482 | 38454 | PgHdr1 *pPage = 0; |
| 38483 | 38455 | |
| 38456 | + assert( offsetof(PgHdr1,page)==0 ); | |
| 38484 | 38457 | assert( pCache->bPurgeable || createFlag!=1 ); |
| 38485 | 38458 | assert( pCache->bPurgeable || pCache->nMin==0 ); |
| 38486 | 38459 | assert( pCache->bPurgeable==0 || pCache->nMin==10 ); |
| 38487 | 38460 | assert( pCache->nMin==0 || pCache->bPurgeable ); |
| 38488 | 38461 | pcache1EnterMutex(pGroup = pCache->pGroup); |
| @@ -38584,11 +38557,11 @@ | ||
| 38584 | 38557 | fetch_out: |
| 38585 | 38558 | if( pPage && iKey>pCache->iMaxKey ){ |
| 38586 | 38559 | pCache->iMaxKey = iKey; |
| 38587 | 38560 | } |
| 38588 | 38561 | pcache1LeaveMutex(pGroup); |
| 38589 | - return &pPage->page; | |
| 38562 | + return (sqlite3_pcache_page*)pPage; | |
| 38590 | 38563 | } |
| 38591 | 38564 | |
| 38592 | 38565 | |
| 38593 | 38566 | /* |
| 38594 | 38567 | ** Implementation of the sqlite3_pcache.xUnpin method. |
| @@ -41124,11 +41097,11 @@ | ||
| 41124 | 41097 | ** Find a page in the hash table given its page number. Return |
| 41125 | 41098 | ** a pointer to the page or NULL if the requested page is not |
| 41126 | 41099 | ** already in memory. |
| 41127 | 41100 | */ |
| 41128 | 41101 | static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){ |
| 41129 | - PgHdr *p; /* Return value */ | |
| 41102 | + PgHdr *p = 0; /* Return value */ | |
| 41130 | 41103 | |
| 41131 | 41104 | /* It is not possible for a call to PcacheFetch() with createFlag==0 to |
| 41132 | 41105 | ** fail, since no attempt to allocate dynamic memory will be made. |
| 41133 | 41106 | */ |
| 41134 | 41107 | (void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &p); |
| @@ -60551,11 +60524,11 @@ | ||
| 60551 | 60524 | #endif /* SQLITE_DEBUG */ |
| 60552 | 60525 | |
| 60553 | 60526 | /* |
| 60554 | 60527 | ** Size of struct Mem not including the Mem.zMalloc member. |
| 60555 | 60528 | */ |
| 60556 | -#define MEMCELLSIZE (size_t)(&(((Mem *)0)->zMalloc)) | |
| 60529 | +#define MEMCELLSIZE offsetof(Mem,zMalloc) | |
| 60557 | 60530 | |
| 60558 | 60531 | /* |
| 60559 | 60532 | ** Make an shallow copy of pFrom into pTo. Prior contents of |
| 60560 | 60533 | ** pTo are freed. The pFrom->z field is not duplicated. If |
| 60561 | 60534 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| @@ -63955,12 +63928,13 @@ | ||
| 63955 | 63928 | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ |
| 63956 | 63929 | AuxData **pp = &pVdbe->pAuxData; |
| 63957 | 63930 | while( *pp ){ |
| 63958 | 63931 | AuxData *pAux = *pp; |
| 63959 | 63932 | if( (iOp<0) |
| 63960 | - || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg)))) | |
| 63933 | + || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg)))) | |
| 63961 | 63934 | ){ |
| 63935 | + testcase( pAux->iArg==31 ); | |
| 63962 | 63936 | if( pAux->xDelete ){ |
| 63963 | 63937 | pAux->xDelete(pAux->pAux); |
| 63964 | 63938 | } |
| 63965 | 63939 | *pp = pAux->pNext; |
| 63966 | 63940 | sqlite3DbFree(pVdbe->db, pAux); |
| @@ -64271,10 +64245,13 @@ | ||
| 64271 | 64245 | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet( |
| 64272 | 64246 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 64273 | 64247 | u32 serial_type, /* Serial type to deserialize */ |
| 64274 | 64248 | Mem *pMem /* Memory cell to write value into */ |
| 64275 | 64249 | ){ |
| 64250 | + u64 x; | |
| 64251 | + u32 y; | |
| 64252 | + int i; | |
| 64276 | 64253 | switch( serial_type ){ |
| 64277 | 64254 | case 10: /* Reserved for future use */ |
| 64278 | 64255 | case 11: /* Reserved for future use */ |
| 64279 | 64256 | case 0: { /* NULL */ |
| 64280 | 64257 | pMem->flags = MEM_Null; |
| @@ -64284,36 +64261,37 @@ | ||
| 64284 | 64261 | pMem->u.i = (signed char)buf[0]; |
| 64285 | 64262 | pMem->flags = MEM_Int; |
| 64286 | 64263 | return 1; |
| 64287 | 64264 | } |
| 64288 | 64265 | case 2: { /* 2-byte signed integer */ |
| 64289 | - pMem->u.i = (((signed char)buf[0])<<8) | buf[1]; | |
| 64266 | + i = 256*(signed char)buf[0] | buf[1]; | |
| 64267 | + pMem->u.i = (i64)i; | |
| 64290 | 64268 | pMem->flags = MEM_Int; |
| 64291 | 64269 | return 2; |
| 64292 | 64270 | } |
| 64293 | 64271 | case 3: { /* 3-byte signed integer */ |
| 64294 | - pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2]; | |
| 64272 | + i = 65536*(signed char)buf[0] | (buf[1]<<8) | buf[2]; | |
| 64273 | + pMem->u.i = (i64)i; | |
| 64295 | 64274 | pMem->flags = MEM_Int; |
| 64296 | 64275 | return 3; |
| 64297 | 64276 | } |
| 64298 | 64277 | case 4: { /* 4-byte signed integer */ |
| 64299 | - pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; | |
| 64278 | + y = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; | |
| 64279 | + pMem->u.i = (i64)*(int*)&y; | |
| 64300 | 64280 | pMem->flags = MEM_Int; |
| 64301 | 64281 | return 4; |
| 64302 | 64282 | } |
| 64303 | 64283 | case 5: { /* 6-byte signed integer */ |
| 64304 | - u64 x = (((signed char)buf[0])<<8) | buf[1]; | |
| 64305 | - u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; | |
| 64284 | + x = 256*(signed char)buf[0] + buf[1]; | |
| 64285 | + y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; | |
| 64306 | 64286 | x = (x<<32) | y; |
| 64307 | 64287 | pMem->u.i = *(i64*)&x; |
| 64308 | 64288 | pMem->flags = MEM_Int; |
| 64309 | 64289 | return 6; |
| 64310 | 64290 | } |
| 64311 | 64291 | case 6: /* 8-byte signed integer */ |
| 64312 | 64292 | case 7: { /* IEEE floating point */ |
| 64313 | - u64 x; | |
| 64314 | - u32 y; | |
| 64315 | 64293 | #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) |
| 64316 | 64294 | /* Verify that integers and floating point values use the same |
| 64317 | 64295 | ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is |
| 64318 | 64296 | ** defined that 64-bit floating point values really are mixed |
| 64319 | 64297 | ** endian. |
| @@ -64322,13 +64300,12 @@ | ||
| 64322 | 64300 | static const double r1 = 1.0; |
| 64323 | 64301 | u64 t2 = t1; |
| 64324 | 64302 | swapMixedEndianFloat(t2); |
| 64325 | 64303 | assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); |
| 64326 | 64304 | #endif |
| 64327 | - | |
| 64328 | - x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; | |
| 64329 | - y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; | |
| 64305 | + x = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; | |
| 64306 | + y = ((unsigned)buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; | |
| 64330 | 64307 | x = (x<<32) | y; |
| 64331 | 64308 | if( serial_type==6 ){ |
| 64332 | 64309 | pMem->u.i = *(i64*)&x; |
| 64333 | 64310 | pMem->flags = MEM_Int; |
| 64334 | 64311 | }else{ |
| @@ -72653,11 +72630,11 @@ | ||
| 72653 | 72630 | #ifdef SQLITE_USE_FCNTL_TRACE |
| 72654 | 72631 | zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 72655 | 72632 | if( zTrace ){ |
| 72656 | 72633 | int i; |
| 72657 | 72634 | for(i=0; i<db->nDb; i++){ |
| 72658 | - if( ((1<<i) & p->btreeMask)==0 ) continue; | |
| 72635 | + if( MASKBIT(i) & p->btreeMask)==0 ) continue; | |
| 72659 | 72636 | sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace); |
| 72660 | 72637 | } |
| 72661 | 72638 | } |
| 72662 | 72639 | #endif /* SQLITE_USE_FCNTL_TRACE */ |
| 72663 | 72640 | #ifdef SQLITE_DEBUG |
| @@ -77499,10 +77476,11 @@ | ||
| 77499 | 77476 | pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; |
| 77500 | 77477 | pNew->pRightmost = 0; |
| 77501 | 77478 | pNew->addrOpenEphm[0] = -1; |
| 77502 | 77479 | pNew->addrOpenEphm[1] = -1; |
| 77503 | 77480 | pNew->addrOpenEphm[2] = -1; |
| 77481 | + pNew->nSelectRow = p->nSelectRow; | |
| 77504 | 77482 | pNew->pWith = withDup(db, p->pWith); |
| 77505 | 77483 | return pNew; |
| 77506 | 77484 | } |
| 77507 | 77485 | #else |
| 77508 | 77486 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ |
| @@ -79120,11 +79098,11 @@ | ||
| 79120 | 79098 | ExprList *pFarg; /* List of function arguments */ |
| 79121 | 79099 | int nFarg; /* Number of function arguments */ |
| 79122 | 79100 | FuncDef *pDef; /* The function definition object */ |
| 79123 | 79101 | int nId; /* Length of the function name in bytes */ |
| 79124 | 79102 | const char *zId; /* The function name */ |
| 79125 | - int constMask = 0; /* Mask of function arguments that are constant */ | |
| 79103 | + u32 constMask = 0; /* Mask of function arguments that are constant */ | |
| 79126 | 79104 | int i; /* Loop counter */ |
| 79127 | 79105 | u8 enc = ENC(db); /* The text encoding used by this database */ |
| 79128 | 79106 | CollSeq *pColl = 0; /* A collating sequence */ |
| 79129 | 79107 | |
| 79130 | 79108 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| @@ -79171,11 +79149,12 @@ | ||
| 79171 | 79149 | break; |
| 79172 | 79150 | } |
| 79173 | 79151 | |
| 79174 | 79152 | for(i=0; i<nFarg; i++){ |
| 79175 | 79153 | if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){ |
| 79176 | - constMask |= (1<<i); | |
| 79154 | + testcase( i==31 ); | |
| 79155 | + constMask |= MASKBIT32(i); | |
| 79177 | 79156 | } |
| 79178 | 79157 | if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){ |
| 79179 | 79158 | pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr); |
| 79180 | 79159 | } |
| 79181 | 79160 | } |
| @@ -89527,11 +89506,13 @@ | ||
| 89527 | 89506 | |
| 89528 | 89507 | /* Populate the OLD.* pseudo-table register array. These values will be |
| 89529 | 89508 | ** used by any BEFORE and AFTER triggers that exist. */ |
| 89530 | 89509 | sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); |
| 89531 | 89510 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 89532 | - if( mask==0xffffffff || mask&(1<<iCol) ){ | |
| 89511 | + testcase( mask!=0xffffffff && iCol==31 ); | |
| 89512 | + testcase( mask!=0xffffffff && iCol==32 ); | |
| 89513 | + if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){ | |
| 89533 | 89514 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1); |
| 89534 | 89515 | } |
| 89535 | 89516 | } |
| 89536 | 89517 | |
| 89537 | 89518 | /* Invoke BEFORE DELETE trigger programs. */ |
| @@ -89847,11 +89828,11 @@ | ||
| 89847 | 89828 | UNUSED_PARAMETER(argc); |
| 89848 | 89829 | switch( sqlite3_value_type(argv[0]) ){ |
| 89849 | 89830 | case SQLITE_INTEGER: { |
| 89850 | 89831 | i64 iVal = sqlite3_value_int64(argv[0]); |
| 89851 | 89832 | if( iVal<0 ){ |
| 89852 | - if( (iVal<<1)==0 ){ | |
| 89833 | + if( iVal==SMALLEST_INT64 ){ | |
| 89853 | 89834 | /* IMP: R-31676-45509 If X is the integer -9223372036854775808 |
| 89854 | 89835 | ** then abs(X) throws an integer overflow error since there is no |
| 89855 | 89836 | ** equivalent positive 64-bit two complement value. */ |
| 89856 | 89837 | sqlite3_result_error(context, "integer overflow", -1); |
| 89857 | 89838 | return; |
| @@ -100310,10 +100291,11 @@ | ||
| 100310 | 100291 | ** on a second ephemeral index that holds all values every previously |
| 100311 | 100292 | ** added to the queue. Only add this new value if it has never before |
| 100312 | 100293 | ** been added */ |
| 100313 | 100294 | addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0); |
| 100314 | 100295 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3); |
| 100296 | + sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); | |
| 100315 | 100297 | } |
| 100316 | 100298 | for(i=0; i<nKey; i++){ |
| 100317 | 100299 | sqlite3VdbeAddOp2(v, OP_SCopy, |
| 100318 | 100300 | regResult + pSO->a[i].u.x.iOrderByCol - 1, |
| 100319 | 100301 | r2+i); |
| @@ -101220,11 +101202,48 @@ | ||
| 101220 | 101202 | if( pRet==0 && iCol<p->pEList->nExpr ){ |
| 101221 | 101203 | pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr); |
| 101222 | 101204 | } |
| 101223 | 101205 | return pRet; |
| 101224 | 101206 | } |
| 101225 | -#endif /* SQLITE_OMIT_COMPOUND_SELECT */ | |
| 101207 | + | |
| 101208 | +/* | |
| 101209 | +** The select statement passed as the second parameter is a compound SELECT | |
| 101210 | +** with an ORDER BY clause. This function allocates and returns a KeyInfo | |
| 101211 | +** structure suitable for implementing the ORDER BY. | |
| 101212 | +** | |
| 101213 | +** Space to hold the KeyInfo structure is obtained from malloc. The calling | |
| 101214 | +** function is responsible for ensuring that this structure is eventually | |
| 101215 | +** freed. | |
| 101216 | +*/ | |
| 101217 | +static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ | |
| 101218 | + ExprList *pOrderBy = p->pOrderBy; | |
| 101219 | + int nOrderBy = p->pOrderBy->nExpr; | |
| 101220 | + sqlite3 *db = pParse->db; | |
| 101221 | + KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1); | |
| 101222 | + if( pRet ){ | |
| 101223 | + int i; | |
| 101224 | + for(i=0; i<nOrderBy; i++){ | |
| 101225 | + struct ExprList_item *pItem = &pOrderBy->a[i]; | |
| 101226 | + Expr *pTerm = pItem->pExpr; | |
| 101227 | + CollSeq *pColl; | |
| 101228 | + | |
| 101229 | + if( pTerm->flags & EP_Collate ){ | |
| 101230 | + pColl = sqlite3ExprCollSeq(pParse, pTerm); | |
| 101231 | + }else{ | |
| 101232 | + pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1); | |
| 101233 | + if( pColl==0 ) pColl = db->pDfltColl; | |
| 101234 | + pOrderBy->a[i].pExpr = | |
| 101235 | + sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); | |
| 101236 | + } | |
| 101237 | + assert( sqlite3KeyInfoIsWriteable(pRet) ); | |
| 101238 | + pRet->aColl[i] = pColl; | |
| 101239 | + pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder; | |
| 101240 | + } | |
| 101241 | + } | |
| 101242 | + | |
| 101243 | + return pRet; | |
| 101244 | +} | |
| 101226 | 101245 | |
| 101227 | 101246 | #ifndef SQLITE_OMIT_CTE |
| 101228 | 101247 | /* |
| 101229 | 101248 | ** This routine generates VDBE code to compute the content of a WITH RECURSIVE |
| 101230 | 101249 | ** query of the form: |
| @@ -101294,23 +101313,20 @@ | ||
| 101294 | 101313 | pOffset = p->pOffset; |
| 101295 | 101314 | regLimit = p->iLimit; |
| 101296 | 101315 | regOffset = p->iOffset; |
| 101297 | 101316 | p->pLimit = p->pOffset = 0; |
| 101298 | 101317 | p->iLimit = p->iOffset = 0; |
| 101318 | + pOrderBy = p->pOrderBy; | |
| 101299 | 101319 | |
| 101300 | 101320 | /* Locate the cursor number of the Current table */ |
| 101301 | 101321 | for(i=0; ALWAYS(i<pSrc->nSrc); i++){ |
| 101302 | 101322 | if( pSrc->a[i].isRecursive ){ |
| 101303 | 101323 | iCurrent = pSrc->a[i].iCursor; |
| 101304 | 101324 | break; |
| 101305 | 101325 | } |
| 101306 | 101326 | } |
| 101307 | 101327 | |
| 101308 | - /* Detach the ORDER BY clause from the compound SELECT */ | |
| 101309 | - pOrderBy = p->pOrderBy; | |
| 101310 | - p->pOrderBy = 0; | |
| 101311 | - | |
| 101312 | 101328 | /* Allocate cursors numbers for Queue and Distinct. The cursor number for |
| 101313 | 101329 | ** the Distinct table must be exactly one greater than Queue in order |
| 101314 | 101330 | ** for the SRT_DistTable and SRT_DistQueue destinations to work. */ |
| 101315 | 101331 | iQueue = pParse->nTab++; |
| 101316 | 101332 | if( p->op==TK_UNION ){ |
| @@ -101323,11 +101339,11 @@ | ||
| 101323 | 101339 | |
| 101324 | 101340 | /* Allocate cursors for Current, Queue, and Distinct. */ |
| 101325 | 101341 | regCurrent = ++pParse->nMem; |
| 101326 | 101342 | sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol); |
| 101327 | 101343 | if( pOrderBy ){ |
| 101328 | - KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pOrderBy, 1); | |
| 101344 | + KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1); | |
| 101329 | 101345 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0, |
| 101330 | 101346 | (char*)pKeyInfo, P4_KEYINFO); |
| 101331 | 101347 | destQueue.pOrderBy = pOrderBy; |
| 101332 | 101348 | }else{ |
| 101333 | 101349 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol); |
| @@ -101335,10 +101351,13 @@ | ||
| 101335 | 101351 | VdbeComment((v, "Queue table")); |
| 101336 | 101352 | if( iDistinct ){ |
| 101337 | 101353 | p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0); |
| 101338 | 101354 | p->selFlags |= SF_UsesEphemeral; |
| 101339 | 101355 | } |
| 101356 | + | |
| 101357 | + /* Detach the ORDER BY clause from the compound SELECT */ | |
| 101358 | + p->pOrderBy = 0; | |
| 101340 | 101359 | |
| 101341 | 101360 | /* Store the results of the setup-query in Queue. */ |
| 101342 | 101361 | rc = sqlite3Select(pParse, pSetup, &destQueue); |
| 101343 | 101362 | if( rc ) goto end_of_recursive_query; |
| 101344 | 101363 | |
| @@ -101378,21 +101397,20 @@ | ||
| 101378 | 101397 | p->pOrderBy = pOrderBy; |
| 101379 | 101398 | p->pLimit = pLimit; |
| 101380 | 101399 | p->pOffset = pOffset; |
| 101381 | 101400 | return; |
| 101382 | 101401 | } |
| 101383 | -#endif | |
| 101402 | +#endif /* SQLITE_OMIT_CTE */ | |
| 101384 | 101403 | |
| 101385 | 101404 | /* Forward references */ |
| 101386 | 101405 | static int multiSelectOrderBy( |
| 101387 | 101406 | Parse *pParse, /* Parsing context */ |
| 101388 | 101407 | Select *p, /* The right-most of SELECTs to be coded */ |
| 101389 | 101408 | SelectDest *pDest /* What to do with query results */ |
| 101390 | 101409 | ); |
| 101391 | 101410 | |
| 101392 | 101411 | |
| 101393 | -#ifndef SQLITE_OMIT_COMPOUND_SELECT | |
| 101394 | 101412 | /* |
| 101395 | 101413 | ** This routine is called to process a compound query form from |
| 101396 | 101414 | ** two or more separate queries using UNION, UNION ALL, EXCEPT, or |
| 101397 | 101415 | ** INTERSECT |
| 101398 | 101416 | ** |
| @@ -102120,28 +102138,11 @@ | ||
| 102120 | 102138 | for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ |
| 102121 | 102139 | assert( pItem->u.x.iOrderByCol>0 |
| 102122 | 102140 | && pItem->u.x.iOrderByCol<=p->pEList->nExpr ); |
| 102123 | 102141 | aPermute[i] = pItem->u.x.iOrderByCol - 1; |
| 102124 | 102142 | } |
| 102125 | - pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy, 1); | |
| 102126 | - if( pKeyMerge ){ | |
| 102127 | - for(i=0; i<nOrderBy; i++){ | |
| 102128 | - CollSeq *pColl; | |
| 102129 | - Expr *pTerm = pOrderBy->a[i].pExpr; | |
| 102130 | - if( pTerm->flags & EP_Collate ){ | |
| 102131 | - pColl = sqlite3ExprCollSeq(pParse, pTerm); | |
| 102132 | - }else{ | |
| 102133 | - pColl = multiSelectCollSeq(pParse, p, aPermute[i]); | |
| 102134 | - if( pColl==0 ) pColl = db->pDfltColl; | |
| 102135 | - pOrderBy->a[i].pExpr = | |
| 102136 | - sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); | |
| 102137 | - } | |
| 102138 | - assert( sqlite3KeyInfoIsWriteable(pKeyMerge) ); | |
| 102139 | - pKeyMerge->aColl[i] = pColl; | |
| 102140 | - pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder; | |
| 102141 | - } | |
| 102142 | - } | |
| 102143 | + pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1); | |
| 102143 | 102144 | }else{ |
| 102144 | 102145 | pKeyMerge = 0; |
| 102145 | 102146 | } |
| 102146 | 102147 | |
| 102147 | 102148 | /* Reattach the ORDER BY clause to the query. |
| @@ -106614,13 +106615,14 @@ | ||
| 106614 | 106615 | oldmask |= sqlite3TriggerColmask(pParse, |
| 106615 | 106616 | pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError |
| 106616 | 106617 | ); |
| 106617 | 106618 | for(i=0; i<pTab->nCol; i++){ |
| 106618 | 106619 | if( oldmask==0xffffffff |
| 106619 | - || (i<32 && (oldmask & (1<<i))) | |
| 106620 | + || (i<32 && (oldmask & MASKBIT32(i))!=0) | |
| 106620 | 106621 | || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 |
| 106621 | 106622 | ){ |
| 106623 | + testcase( oldmask!=0xffffffff && i==31 ); | |
| 106622 | 106624 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); |
| 106623 | 106625 | }else{ |
| 106624 | 106626 | sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); |
| 106625 | 106627 | } |
| 106626 | 106628 | } |
| @@ -106651,11 +106653,11 @@ | ||
| 106651 | 106653 | sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); |
| 106652 | 106654 | }else{ |
| 106653 | 106655 | j = aXRef[i]; |
| 106654 | 106656 | if( j>=0 ){ |
| 106655 | 106657 | sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i); |
| 106656 | - }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){ | |
| 106658 | + }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){ | |
| 106657 | 106659 | /* This branch loads the value of a column that will not be changed |
| 106658 | 106660 | ** into a register. This is done if there are no BEFORE triggers, or |
| 106659 | 106661 | ** if there are one or more BEFORE triggers that use this value via |
| 106660 | 106662 | ** a new.* reference in a trigger program. |
| 106661 | 106663 | */ |
| @@ -112160,11 +112162,13 @@ | ||
| 112160 | 112162 | int iTerm; |
| 112161 | 112163 | for(iTerm=0; iTerm<pWC->nTerm; iTerm++){ |
| 112162 | 112164 | Expr *pExpr = pWC->a[iTerm].pExpr; |
| 112163 | 112165 | if( &pWC->a[iTerm] == pTerm ) continue; |
| 112164 | 112166 | if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; |
| 112165 | - if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue; | |
| 112167 | + testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO ); | |
| 112168 | + testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL ); | |
| 112169 | + if( pWC->a[iTerm].wtFlags & (TERM_ORINFO|TERM_VIRTUAL) ) continue; | |
| 112166 | 112170 | if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; |
| 112167 | 112171 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 112168 | 112172 | pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr); |
| 112169 | 112173 | } |
| 112170 | 112174 | if( pAndExpr ){ |
| @@ -122726,11 +122730,11 @@ | ||
| 122726 | 122730 | ** database files might have arbitrary corruption. Setting the flag during |
| 122727 | 122731 | ** testing causes certain assert() statements in the code to be activated |
| 122728 | 122732 | ** that demonstrat invariants on well-formed database files. |
| 122729 | 122733 | */ |
| 122730 | 122734 | case SQLITE_TESTCTRL_NEVER_CORRUPT: { |
| 122731 | - sqlite3Config.neverCorrupt = va_arg(ap, int); | |
| 122735 | + sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int); | |
| 122732 | 122736 | break; |
| 122733 | 122737 | } |
| 122734 | 122738 | |
| 122735 | 122739 | } |
| 122736 | 122740 | va_end(ap); |
| @@ -131724,17 +131728,17 @@ | ||
| 131724 | 131728 | /* |
| 131725 | 131729 | ** Hash and comparison functions when the mode is FTS3_HASH_STRING |
| 131726 | 131730 | */ |
| 131727 | 131731 | static int fts3StrHash(const void *pKey, int nKey){ |
| 131728 | 131732 | const char *z = (const char *)pKey; |
| 131729 | - int h = 0; | |
| 131733 | + unsigned h = 0; | |
| 131730 | 131734 | if( nKey<=0 ) nKey = (int) strlen(z); |
| 131731 | 131735 | while( nKey > 0 ){ |
| 131732 | 131736 | h = (h<<3) ^ h ^ *z++; |
| 131733 | 131737 | nKey--; |
| 131734 | 131738 | } |
| 131735 | - return h & 0x7fffffff; | |
| 131739 | + return (int)(h & 0x7fffffff); | |
| 131736 | 131740 | } |
| 131737 | 131741 | static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ |
| 131738 | 131742 | if( n1!=n2 ) return 1; |
| 131739 | 131743 | return strncmp((const char*)pKey1,(const char*)pKey2,n1); |
| 131740 | 131744 | } |
| 131741 | 131745 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.8.3. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -133,13 +133,13 @@ | |
| 133 | ** |
| 134 | ** See also: [sqlite3_libversion()], |
| 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | */ |
| 138 | #define SQLITE_VERSION "3.8.3" |
| 139 | #define SQLITE_VERSION_NUMBER 3008003 |
| 140 | #define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc" |
| 141 | |
| 142 | /* |
| 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | ** |
| @@ -11303,10 +11303,11 @@ | |
| 11303 | |
| 11304 | /* |
| 11305 | ** A bit in a Bitmask |
| 11306 | */ |
| 11307 | #define MASKBIT(n) (((Bitmask)1)<<(n)) |
| 11308 | |
| 11309 | /* |
| 11310 | ** The following structure describes the FROM clause of a SELECT statement. |
| 11311 | ** Each table or subquery in the FROM clause is a separate element of |
| 11312 | ** the SrcList.a[] array. |
| @@ -22605,11 +22606,12 @@ | |
| 22605 | |
| 22606 | /* |
| 22607 | ** Read or write a four-byte big-endian integer value. |
| 22608 | */ |
| 22609 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 22610 | return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; |
| 22611 | } |
| 22612 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 22613 | p[0] = (u8)(v>>24); |
| 22614 | p[1] = (u8)(v>>16); |
| 22615 | p[2] = (u8)(v>>8); |
| @@ -22946,11 +22948,11 @@ | |
| 22946 | |
| 22947 | /* |
| 22948 | ** The hashing function. |
| 22949 | */ |
| 22950 | static unsigned int strHash(const char *z, int nKey){ |
| 22951 | int h = 0; |
| 22952 | assert( nKey>=0 ); |
| 22953 | while( nKey > 0 ){ |
| 22954 | h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; |
| 22955 | nKey--; |
| 22956 | } |
| @@ -27650,11 +27652,11 @@ | |
| 27650 | |
| 27651 | /* Update the global lock state and do debug tracing */ |
| 27652 | #ifdef SQLITE_DEBUG |
| 27653 | { u16 mask; |
| 27654 | OSTRACE(("SHM-LOCK ")); |
| 27655 | mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<<ofst); |
| 27656 | if( rc==SQLITE_OK ){ |
| 27657 | if( lockType==F_UNLCK ){ |
| 27658 | OSTRACE(("unlock %d ok", ofst)); |
| 27659 | pShmNode->exclMask &= ~mask; |
| 27660 | pShmNode->sharedMask &= ~mask; |
| @@ -35374,11 +35376,34 @@ | |
| 35374 | ** function. |
| 35375 | */ |
| 35376 | static void *winConvertFromUtf8Filename(const char *zFilename){ |
| 35377 | void *zConverted = 0; |
| 35378 | if( osIsNT() ){ |
| 35379 | zConverted = winUtf8ToUnicode(zFilename); |
| 35380 | } |
| 35381 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 35382 | else{ |
| 35383 | zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); |
| 35384 | } |
| @@ -36305,67 +36330,14 @@ | |
| 36305 | */ |
| 36306 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 36307 | sqlite3_data_directory, winGetDirSep(), zRelative); |
| 36308 | return SQLITE_OK; |
| 36309 | } |
| 36310 | nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, NULL, 0); |
| 36311 | if( nByte==0 ){ |
| 36312 | return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)osGetLastError(), |
| 36313 | "winFullPathname", zRelative); |
| 36314 | } |
| 36315 | if( osIsNT() ){ |
| 36316 | LPWSTR zWideFilename; |
| 36317 | |
| 36318 | if( nByte>SQLITE_WIN32_MAX_PATH_CHARS ){ |
| 36319 | /* No Win32 API functions can handle such long paths. Let's see if |
| 36320 | * we can do something about it. If not, just leave it as is. */ |
| 36321 | if( winIsDirSep(zRelative[0]) && winIsDirSep(zRelative[1]) |
| 36322 | && zRelative[2]!='?' ){ |
| 36323 | /* It's an UNC path, convert it to an extended UNC path. */ |
| 36324 | zWideFilename = sqlite3MallocZero( (nByte+6)*sizeof(WCHAR) ); |
| 36325 | if( zWideFilename==0 ){ |
| 36326 | return SQLITE_IOERR_NOMEM; |
| 36327 | } |
| 36328 | memcpy(zWideFilename, L"\\\\?\\UNC\\", 16); |
| 36329 | nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative+2, -1, |
| 36330 | zWideFilename+8, nByte); |
| 36331 | goto finished; |
| 36332 | }else if( winIsDriveLetterAndColon(zRelative) |
| 36333 | && winIsDirSep(zRelative[2]) ){ |
| 36334 | /* It has a correct drive prefix, convert to extended form. */ |
| 36335 | zWideFilename = sqlite3MallocZero( (nByte+4)*sizeof(WCHAR) ); |
| 36336 | if( zWideFilename==0 ){ |
| 36337 | return SQLITE_IOERR_NOMEM; |
| 36338 | } |
| 36339 | memcpy(zWideFilename, L"\\\\?\\", 8); |
| 36340 | nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, |
| 36341 | zWideFilename+4, nByte); |
| 36342 | zWideFilename[6] = '\\'; |
| 36343 | goto finished; |
| 36344 | } |
| 36345 | /* Another form, e.g. relative path or maybe it already |
| 36346 | * has the '\\?\' prefix. Just leave it as-is. */ |
| 36347 | } |
| 36348 | zWideFilename = sqlite3Malloc( nByte*sizeof(WCHAR) ); |
| 36349 | if( zWideFilename==0 ){ |
| 36350 | return SQLITE_IOERR_NOMEM; |
| 36351 | } |
| 36352 | nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, |
| 36353 | zWideFilename, nByte); |
| 36354 | if( nByte==0 ){ |
| 36355 | sqlite3_free(zWideFilename); |
| 36356 | return SQLITE_IOERR_NOMEM; |
| 36357 | } |
| 36358 | finished: |
| 36359 | zConverted = zWideFilename; |
| 36360 | }else{ |
| 36361 | zConverted = sqlite3_win32_utf8_to_mbcs(zRelative); |
| 36362 | if( zConverted==0 ){ |
| 36363 | return SQLITE_IOERR_NOMEM; |
| 36364 | } |
| 36365 | } |
| 36366 | |
| 36367 | if( osIsNT() ){ |
| 36368 | LPWSTR zTemp; |
| 36369 | nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); |
| 36370 | if( nByte==0 ){ |
| 36371 | sqlite3_free(zConverted); |
| @@ -38479,10 +38451,11 @@ | |
| 38479 | unsigned int nPinned; |
| 38480 | PCache1 *pCache = (PCache1 *)p; |
| 38481 | PGroup *pGroup; |
| 38482 | PgHdr1 *pPage = 0; |
| 38483 | |
| 38484 | assert( pCache->bPurgeable || createFlag!=1 ); |
| 38485 | assert( pCache->bPurgeable || pCache->nMin==0 ); |
| 38486 | assert( pCache->bPurgeable==0 || pCache->nMin==10 ); |
| 38487 | assert( pCache->nMin==0 || pCache->bPurgeable ); |
| 38488 | pcache1EnterMutex(pGroup = pCache->pGroup); |
| @@ -38584,11 +38557,11 @@ | |
| 38584 | fetch_out: |
| 38585 | if( pPage && iKey>pCache->iMaxKey ){ |
| 38586 | pCache->iMaxKey = iKey; |
| 38587 | } |
| 38588 | pcache1LeaveMutex(pGroup); |
| 38589 | return &pPage->page; |
| 38590 | } |
| 38591 | |
| 38592 | |
| 38593 | /* |
| 38594 | ** Implementation of the sqlite3_pcache.xUnpin method. |
| @@ -41124,11 +41097,11 @@ | |
| 41124 | ** Find a page in the hash table given its page number. Return |
| 41125 | ** a pointer to the page or NULL if the requested page is not |
| 41126 | ** already in memory. |
| 41127 | */ |
| 41128 | static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){ |
| 41129 | PgHdr *p; /* Return value */ |
| 41130 | |
| 41131 | /* It is not possible for a call to PcacheFetch() with createFlag==0 to |
| 41132 | ** fail, since no attempt to allocate dynamic memory will be made. |
| 41133 | */ |
| 41134 | (void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &p); |
| @@ -60551,11 +60524,11 @@ | |
| 60551 | #endif /* SQLITE_DEBUG */ |
| 60552 | |
| 60553 | /* |
| 60554 | ** Size of struct Mem not including the Mem.zMalloc member. |
| 60555 | */ |
| 60556 | #define MEMCELLSIZE (size_t)(&(((Mem *)0)->zMalloc)) |
| 60557 | |
| 60558 | /* |
| 60559 | ** Make an shallow copy of pFrom into pTo. Prior contents of |
| 60560 | ** pTo are freed. The pFrom->z field is not duplicated. If |
| 60561 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| @@ -63955,12 +63928,13 @@ | |
| 63955 | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ |
| 63956 | AuxData **pp = &pVdbe->pAuxData; |
| 63957 | while( *pp ){ |
| 63958 | AuxData *pAux = *pp; |
| 63959 | if( (iOp<0) |
| 63960 | || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg)))) |
| 63961 | ){ |
| 63962 | if( pAux->xDelete ){ |
| 63963 | pAux->xDelete(pAux->pAux); |
| 63964 | } |
| 63965 | *pp = pAux->pNext; |
| 63966 | sqlite3DbFree(pVdbe->db, pAux); |
| @@ -64271,10 +64245,13 @@ | |
| 64271 | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet( |
| 64272 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 64273 | u32 serial_type, /* Serial type to deserialize */ |
| 64274 | Mem *pMem /* Memory cell to write value into */ |
| 64275 | ){ |
| 64276 | switch( serial_type ){ |
| 64277 | case 10: /* Reserved for future use */ |
| 64278 | case 11: /* Reserved for future use */ |
| 64279 | case 0: { /* NULL */ |
| 64280 | pMem->flags = MEM_Null; |
| @@ -64284,36 +64261,37 @@ | |
| 64284 | pMem->u.i = (signed char)buf[0]; |
| 64285 | pMem->flags = MEM_Int; |
| 64286 | return 1; |
| 64287 | } |
| 64288 | case 2: { /* 2-byte signed integer */ |
| 64289 | pMem->u.i = (((signed char)buf[0])<<8) | buf[1]; |
| 64290 | pMem->flags = MEM_Int; |
| 64291 | return 2; |
| 64292 | } |
| 64293 | case 3: { /* 3-byte signed integer */ |
| 64294 | pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2]; |
| 64295 | pMem->flags = MEM_Int; |
| 64296 | return 3; |
| 64297 | } |
| 64298 | case 4: { /* 4-byte signed integer */ |
| 64299 | pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; |
| 64300 | pMem->flags = MEM_Int; |
| 64301 | return 4; |
| 64302 | } |
| 64303 | case 5: { /* 6-byte signed integer */ |
| 64304 | u64 x = (((signed char)buf[0])<<8) | buf[1]; |
| 64305 | u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; |
| 64306 | x = (x<<32) | y; |
| 64307 | pMem->u.i = *(i64*)&x; |
| 64308 | pMem->flags = MEM_Int; |
| 64309 | return 6; |
| 64310 | } |
| 64311 | case 6: /* 8-byte signed integer */ |
| 64312 | case 7: { /* IEEE floating point */ |
| 64313 | u64 x; |
| 64314 | u32 y; |
| 64315 | #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) |
| 64316 | /* Verify that integers and floating point values use the same |
| 64317 | ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is |
| 64318 | ** defined that 64-bit floating point values really are mixed |
| 64319 | ** endian. |
| @@ -64322,13 +64300,12 @@ | |
| 64322 | static const double r1 = 1.0; |
| 64323 | u64 t2 = t1; |
| 64324 | swapMixedEndianFloat(t2); |
| 64325 | assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); |
| 64326 | #endif |
| 64327 | |
| 64328 | x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; |
| 64329 | y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; |
| 64330 | x = (x<<32) | y; |
| 64331 | if( serial_type==6 ){ |
| 64332 | pMem->u.i = *(i64*)&x; |
| 64333 | pMem->flags = MEM_Int; |
| 64334 | }else{ |
| @@ -72653,11 +72630,11 @@ | |
| 72653 | #ifdef SQLITE_USE_FCNTL_TRACE |
| 72654 | zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 72655 | if( zTrace ){ |
| 72656 | int i; |
| 72657 | for(i=0; i<db->nDb; i++){ |
| 72658 | if( ((1<<i) & p->btreeMask)==0 ) continue; |
| 72659 | sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace); |
| 72660 | } |
| 72661 | } |
| 72662 | #endif /* SQLITE_USE_FCNTL_TRACE */ |
| 72663 | #ifdef SQLITE_DEBUG |
| @@ -77499,10 +77476,11 @@ | |
| 77499 | pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; |
| 77500 | pNew->pRightmost = 0; |
| 77501 | pNew->addrOpenEphm[0] = -1; |
| 77502 | pNew->addrOpenEphm[1] = -1; |
| 77503 | pNew->addrOpenEphm[2] = -1; |
| 77504 | pNew->pWith = withDup(db, p->pWith); |
| 77505 | return pNew; |
| 77506 | } |
| 77507 | #else |
| 77508 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ |
| @@ -79120,11 +79098,11 @@ | |
| 79120 | ExprList *pFarg; /* List of function arguments */ |
| 79121 | int nFarg; /* Number of function arguments */ |
| 79122 | FuncDef *pDef; /* The function definition object */ |
| 79123 | int nId; /* Length of the function name in bytes */ |
| 79124 | const char *zId; /* The function name */ |
| 79125 | int constMask = 0; /* Mask of function arguments that are constant */ |
| 79126 | int i; /* Loop counter */ |
| 79127 | u8 enc = ENC(db); /* The text encoding used by this database */ |
| 79128 | CollSeq *pColl = 0; /* A collating sequence */ |
| 79129 | |
| 79130 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| @@ -79171,11 +79149,12 @@ | |
| 79171 | break; |
| 79172 | } |
| 79173 | |
| 79174 | for(i=0; i<nFarg; i++){ |
| 79175 | if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){ |
| 79176 | constMask |= (1<<i); |
| 79177 | } |
| 79178 | if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){ |
| 79179 | pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr); |
| 79180 | } |
| 79181 | } |
| @@ -89527,11 +89506,13 @@ | |
| 89527 | |
| 89528 | /* Populate the OLD.* pseudo-table register array. These values will be |
| 89529 | ** used by any BEFORE and AFTER triggers that exist. */ |
| 89530 | sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); |
| 89531 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 89532 | if( mask==0xffffffff || mask&(1<<iCol) ){ |
| 89533 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1); |
| 89534 | } |
| 89535 | } |
| 89536 | |
| 89537 | /* Invoke BEFORE DELETE trigger programs. */ |
| @@ -89847,11 +89828,11 @@ | |
| 89847 | UNUSED_PARAMETER(argc); |
| 89848 | switch( sqlite3_value_type(argv[0]) ){ |
| 89849 | case SQLITE_INTEGER: { |
| 89850 | i64 iVal = sqlite3_value_int64(argv[0]); |
| 89851 | if( iVal<0 ){ |
| 89852 | if( (iVal<<1)==0 ){ |
| 89853 | /* IMP: R-31676-45509 If X is the integer -9223372036854775808 |
| 89854 | ** then abs(X) throws an integer overflow error since there is no |
| 89855 | ** equivalent positive 64-bit two complement value. */ |
| 89856 | sqlite3_result_error(context, "integer overflow", -1); |
| 89857 | return; |
| @@ -100310,10 +100291,11 @@ | |
| 100310 | ** on a second ephemeral index that holds all values every previously |
| 100311 | ** added to the queue. Only add this new value if it has never before |
| 100312 | ** been added */ |
| 100313 | addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0); |
| 100314 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3); |
| 100315 | } |
| 100316 | for(i=0; i<nKey; i++){ |
| 100317 | sqlite3VdbeAddOp2(v, OP_SCopy, |
| 100318 | regResult + pSO->a[i].u.x.iOrderByCol - 1, |
| 100319 | r2+i); |
| @@ -101220,11 +101202,48 @@ | |
| 101220 | if( pRet==0 && iCol<p->pEList->nExpr ){ |
| 101221 | pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr); |
| 101222 | } |
| 101223 | return pRet; |
| 101224 | } |
| 101225 | #endif /* SQLITE_OMIT_COMPOUND_SELECT */ |
| 101226 | |
| 101227 | #ifndef SQLITE_OMIT_CTE |
| 101228 | /* |
| 101229 | ** This routine generates VDBE code to compute the content of a WITH RECURSIVE |
| 101230 | ** query of the form: |
| @@ -101294,23 +101313,20 @@ | |
| 101294 | pOffset = p->pOffset; |
| 101295 | regLimit = p->iLimit; |
| 101296 | regOffset = p->iOffset; |
| 101297 | p->pLimit = p->pOffset = 0; |
| 101298 | p->iLimit = p->iOffset = 0; |
| 101299 | |
| 101300 | /* Locate the cursor number of the Current table */ |
| 101301 | for(i=0; ALWAYS(i<pSrc->nSrc); i++){ |
| 101302 | if( pSrc->a[i].isRecursive ){ |
| 101303 | iCurrent = pSrc->a[i].iCursor; |
| 101304 | break; |
| 101305 | } |
| 101306 | } |
| 101307 | |
| 101308 | /* Detach the ORDER BY clause from the compound SELECT */ |
| 101309 | pOrderBy = p->pOrderBy; |
| 101310 | p->pOrderBy = 0; |
| 101311 | |
| 101312 | /* Allocate cursors numbers for Queue and Distinct. The cursor number for |
| 101313 | ** the Distinct table must be exactly one greater than Queue in order |
| 101314 | ** for the SRT_DistTable and SRT_DistQueue destinations to work. */ |
| 101315 | iQueue = pParse->nTab++; |
| 101316 | if( p->op==TK_UNION ){ |
| @@ -101323,11 +101339,11 @@ | |
| 101323 | |
| 101324 | /* Allocate cursors for Current, Queue, and Distinct. */ |
| 101325 | regCurrent = ++pParse->nMem; |
| 101326 | sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol); |
| 101327 | if( pOrderBy ){ |
| 101328 | KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pOrderBy, 1); |
| 101329 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0, |
| 101330 | (char*)pKeyInfo, P4_KEYINFO); |
| 101331 | destQueue.pOrderBy = pOrderBy; |
| 101332 | }else{ |
| 101333 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol); |
| @@ -101335,10 +101351,13 @@ | |
| 101335 | VdbeComment((v, "Queue table")); |
| 101336 | if( iDistinct ){ |
| 101337 | p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0); |
| 101338 | p->selFlags |= SF_UsesEphemeral; |
| 101339 | } |
| 101340 | |
| 101341 | /* Store the results of the setup-query in Queue. */ |
| 101342 | rc = sqlite3Select(pParse, pSetup, &destQueue); |
| 101343 | if( rc ) goto end_of_recursive_query; |
| 101344 | |
| @@ -101378,21 +101397,20 @@ | |
| 101378 | p->pOrderBy = pOrderBy; |
| 101379 | p->pLimit = pLimit; |
| 101380 | p->pOffset = pOffset; |
| 101381 | return; |
| 101382 | } |
| 101383 | #endif |
| 101384 | |
| 101385 | /* Forward references */ |
| 101386 | static int multiSelectOrderBy( |
| 101387 | Parse *pParse, /* Parsing context */ |
| 101388 | Select *p, /* The right-most of SELECTs to be coded */ |
| 101389 | SelectDest *pDest /* What to do with query results */ |
| 101390 | ); |
| 101391 | |
| 101392 | |
| 101393 | #ifndef SQLITE_OMIT_COMPOUND_SELECT |
| 101394 | /* |
| 101395 | ** This routine is called to process a compound query form from |
| 101396 | ** two or more separate queries using UNION, UNION ALL, EXCEPT, or |
| 101397 | ** INTERSECT |
| 101398 | ** |
| @@ -102120,28 +102138,11 @@ | |
| 102120 | for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ |
| 102121 | assert( pItem->u.x.iOrderByCol>0 |
| 102122 | && pItem->u.x.iOrderByCol<=p->pEList->nExpr ); |
| 102123 | aPermute[i] = pItem->u.x.iOrderByCol - 1; |
| 102124 | } |
| 102125 | pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy, 1); |
| 102126 | if( pKeyMerge ){ |
| 102127 | for(i=0; i<nOrderBy; i++){ |
| 102128 | CollSeq *pColl; |
| 102129 | Expr *pTerm = pOrderBy->a[i].pExpr; |
| 102130 | if( pTerm->flags & EP_Collate ){ |
| 102131 | pColl = sqlite3ExprCollSeq(pParse, pTerm); |
| 102132 | }else{ |
| 102133 | pColl = multiSelectCollSeq(pParse, p, aPermute[i]); |
| 102134 | if( pColl==0 ) pColl = db->pDfltColl; |
| 102135 | pOrderBy->a[i].pExpr = |
| 102136 | sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); |
| 102137 | } |
| 102138 | assert( sqlite3KeyInfoIsWriteable(pKeyMerge) ); |
| 102139 | pKeyMerge->aColl[i] = pColl; |
| 102140 | pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder; |
| 102141 | } |
| 102142 | } |
| 102143 | }else{ |
| 102144 | pKeyMerge = 0; |
| 102145 | } |
| 102146 | |
| 102147 | /* Reattach the ORDER BY clause to the query. |
| @@ -106614,13 +106615,14 @@ | |
| 106614 | oldmask |= sqlite3TriggerColmask(pParse, |
| 106615 | pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError |
| 106616 | ); |
| 106617 | for(i=0; i<pTab->nCol; i++){ |
| 106618 | if( oldmask==0xffffffff |
| 106619 | || (i<32 && (oldmask & (1<<i))) |
| 106620 | || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 |
| 106621 | ){ |
| 106622 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); |
| 106623 | }else{ |
| 106624 | sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); |
| 106625 | } |
| 106626 | } |
| @@ -106651,11 +106653,11 @@ | |
| 106651 | sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); |
| 106652 | }else{ |
| 106653 | j = aXRef[i]; |
| 106654 | if( j>=0 ){ |
| 106655 | sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i); |
| 106656 | }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){ |
| 106657 | /* This branch loads the value of a column that will not be changed |
| 106658 | ** into a register. This is done if there are no BEFORE triggers, or |
| 106659 | ** if there are one or more BEFORE triggers that use this value via |
| 106660 | ** a new.* reference in a trigger program. |
| 106661 | */ |
| @@ -112160,11 +112162,13 @@ | |
| 112160 | int iTerm; |
| 112161 | for(iTerm=0; iTerm<pWC->nTerm; iTerm++){ |
| 112162 | Expr *pExpr = pWC->a[iTerm].pExpr; |
| 112163 | if( &pWC->a[iTerm] == pTerm ) continue; |
| 112164 | if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; |
| 112165 | if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue; |
| 112166 | if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; |
| 112167 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 112168 | pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr); |
| 112169 | } |
| 112170 | if( pAndExpr ){ |
| @@ -122726,11 +122730,11 @@ | |
| 122726 | ** database files might have arbitrary corruption. Setting the flag during |
| 122727 | ** testing causes certain assert() statements in the code to be activated |
| 122728 | ** that demonstrat invariants on well-formed database files. |
| 122729 | */ |
| 122730 | case SQLITE_TESTCTRL_NEVER_CORRUPT: { |
| 122731 | sqlite3Config.neverCorrupt = va_arg(ap, int); |
| 122732 | break; |
| 122733 | } |
| 122734 | |
| 122735 | } |
| 122736 | va_end(ap); |
| @@ -131724,17 +131728,17 @@ | |
| 131724 | /* |
| 131725 | ** Hash and comparison functions when the mode is FTS3_HASH_STRING |
| 131726 | */ |
| 131727 | static int fts3StrHash(const void *pKey, int nKey){ |
| 131728 | const char *z = (const char *)pKey; |
| 131729 | int h = 0; |
| 131730 | if( nKey<=0 ) nKey = (int) strlen(z); |
| 131731 | while( nKey > 0 ){ |
| 131732 | h = (h<<3) ^ h ^ *z++; |
| 131733 | nKey--; |
| 131734 | } |
| 131735 | return h & 0x7fffffff; |
| 131736 | } |
| 131737 | static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ |
| 131738 | if( n1!=n2 ) return 1; |
| 131739 | return strncmp((const char*)pKey1,(const char*)pKey2,n1); |
| 131740 | } |
| 131741 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.8.3.1. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -133,13 +133,13 @@ | |
| 133 | ** |
| 134 | ** See also: [sqlite3_libversion()], |
| 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | */ |
| 138 | #define SQLITE_VERSION "3.8.3.1" |
| 139 | #define SQLITE_VERSION_NUMBER 3008003 |
| 140 | #define SQLITE_SOURCE_ID "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e" |
| 141 | |
| 142 | /* |
| 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | ** |
| @@ -11303,10 +11303,11 @@ | |
| 11303 | |
| 11304 | /* |
| 11305 | ** A bit in a Bitmask |
| 11306 | */ |
| 11307 | #define MASKBIT(n) (((Bitmask)1)<<(n)) |
| 11308 | #define MASKBIT32(n) (((unsigned int)1)<<(n)) |
| 11309 | |
| 11310 | /* |
| 11311 | ** The following structure describes the FROM clause of a SELECT statement. |
| 11312 | ** Each table or subquery in the FROM clause is a separate element of |
| 11313 | ** the SrcList.a[] array. |
| @@ -22605,11 +22606,12 @@ | |
| 22606 | |
| 22607 | /* |
| 22608 | ** Read or write a four-byte big-endian integer value. |
| 22609 | */ |
| 22610 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 22611 | testcase( p[0]&0x80 ); |
| 22612 | return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; |
| 22613 | } |
| 22614 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 22615 | p[0] = (u8)(v>>24); |
| 22616 | p[1] = (u8)(v>>16); |
| 22617 | p[2] = (u8)(v>>8); |
| @@ -22946,11 +22948,11 @@ | |
| 22948 | |
| 22949 | /* |
| 22950 | ** The hashing function. |
| 22951 | */ |
| 22952 | static unsigned int strHash(const char *z, int nKey){ |
| 22953 | unsigned int h = 0; |
| 22954 | assert( nKey>=0 ); |
| 22955 | while( nKey > 0 ){ |
| 22956 | h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; |
| 22957 | nKey--; |
| 22958 | } |
| @@ -27650,11 +27652,11 @@ | |
| 27652 | |
| 27653 | /* Update the global lock state and do debug tracing */ |
| 27654 | #ifdef SQLITE_DEBUG |
| 27655 | { u16 mask; |
| 27656 | OSTRACE(("SHM-LOCK ")); |
| 27657 | mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst); |
| 27658 | if( rc==SQLITE_OK ){ |
| 27659 | if( lockType==F_UNLCK ){ |
| 27660 | OSTRACE(("unlock %d ok", ofst)); |
| 27661 | pShmNode->exclMask &= ~mask; |
| 27662 | pShmNode->sharedMask &= ~mask; |
| @@ -35374,11 +35376,34 @@ | |
| 35376 | ** function. |
| 35377 | */ |
| 35378 | static void *winConvertFromUtf8Filename(const char *zFilename){ |
| 35379 | void *zConverted = 0; |
| 35380 | if( osIsNT() ){ |
| 35381 | int nChar; |
| 35382 | LPWSTR zWideFilename; |
| 35383 | |
| 35384 | nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); |
| 35385 | if( nChar==0 ){ |
| 35386 | return 0; |
| 35387 | } |
| 35388 | zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR)+8 ); |
| 35389 | if( zWideFilename==0 ){ |
| 35390 | return 0; |
| 35391 | } |
| 35392 | nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, |
| 35393 | zWideFilename+4, nChar); |
| 35394 | if( nChar==0 ){ |
| 35395 | sqlite3_free(zWideFilename); |
| 35396 | return 0; |
| 35397 | }else if( nChar>SQLITE_WIN32_MAX_PATH_CHARS |
| 35398 | && winIsDriveLetterAndColon(zFilename) |
| 35399 | && zFilename[2] == '\\' ){ |
| 35400 | memcpy(zWideFilename, L"\\\\?\\", 8); |
| 35401 | }else{ |
| 35402 | memmove(zWideFilename, zWideFilename+4, nChar*sizeof(WCHAR)); |
| 35403 | } |
| 35404 | zConverted = zWideFilename; |
| 35405 | } |
| 35406 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 35407 | else{ |
| 35408 | zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); |
| 35409 | } |
| @@ -36305,67 +36330,14 @@ | |
| 36330 | */ |
| 36331 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 36332 | sqlite3_data_directory, winGetDirSep(), zRelative); |
| 36333 | return SQLITE_OK; |
| 36334 | } |
| 36335 | zConverted = winConvertFromUtf8Filename(zRelative); |
| 36336 | if( zConverted==0 ){ |
| 36337 | return SQLITE_IOERR_NOMEM; |
| 36338 | } |
| 36339 | if( osIsNT() ){ |
| 36340 | LPWSTR zTemp; |
| 36341 | nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); |
| 36342 | if( nByte==0 ){ |
| 36343 | sqlite3_free(zConverted); |
| @@ -38479,10 +38451,11 @@ | |
| 38451 | unsigned int nPinned; |
| 38452 | PCache1 *pCache = (PCache1 *)p; |
| 38453 | PGroup *pGroup; |
| 38454 | PgHdr1 *pPage = 0; |
| 38455 | |
| 38456 | assert( offsetof(PgHdr1,page)==0 ); |
| 38457 | assert( pCache->bPurgeable || createFlag!=1 ); |
| 38458 | assert( pCache->bPurgeable || pCache->nMin==0 ); |
| 38459 | assert( pCache->bPurgeable==0 || pCache->nMin==10 ); |
| 38460 | assert( pCache->nMin==0 || pCache->bPurgeable ); |
| 38461 | pcache1EnterMutex(pGroup = pCache->pGroup); |
| @@ -38584,11 +38557,11 @@ | |
| 38557 | fetch_out: |
| 38558 | if( pPage && iKey>pCache->iMaxKey ){ |
| 38559 | pCache->iMaxKey = iKey; |
| 38560 | } |
| 38561 | pcache1LeaveMutex(pGroup); |
| 38562 | return (sqlite3_pcache_page*)pPage; |
| 38563 | } |
| 38564 | |
| 38565 | |
| 38566 | /* |
| 38567 | ** Implementation of the sqlite3_pcache.xUnpin method. |
| @@ -41124,11 +41097,11 @@ | |
| 41097 | ** Find a page in the hash table given its page number. Return |
| 41098 | ** a pointer to the page or NULL if the requested page is not |
| 41099 | ** already in memory. |
| 41100 | */ |
| 41101 | static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){ |
| 41102 | PgHdr *p = 0; /* Return value */ |
| 41103 | |
| 41104 | /* It is not possible for a call to PcacheFetch() with createFlag==0 to |
| 41105 | ** fail, since no attempt to allocate dynamic memory will be made. |
| 41106 | */ |
| 41107 | (void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &p); |
| @@ -60551,11 +60524,11 @@ | |
| 60524 | #endif /* SQLITE_DEBUG */ |
| 60525 | |
| 60526 | /* |
| 60527 | ** Size of struct Mem not including the Mem.zMalloc member. |
| 60528 | */ |
| 60529 | #define MEMCELLSIZE offsetof(Mem,zMalloc) |
| 60530 | |
| 60531 | /* |
| 60532 | ** Make an shallow copy of pFrom into pTo. Prior contents of |
| 60533 | ** pTo are freed. The pFrom->z field is not duplicated. If |
| 60534 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| @@ -63955,12 +63928,13 @@ | |
| 63928 | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ |
| 63929 | AuxData **pp = &pVdbe->pAuxData; |
| 63930 | while( *pp ){ |
| 63931 | AuxData *pAux = *pp; |
| 63932 | if( (iOp<0) |
| 63933 | || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg)))) |
| 63934 | ){ |
| 63935 | testcase( pAux->iArg==31 ); |
| 63936 | if( pAux->xDelete ){ |
| 63937 | pAux->xDelete(pAux->pAux); |
| 63938 | } |
| 63939 | *pp = pAux->pNext; |
| 63940 | sqlite3DbFree(pVdbe->db, pAux); |
| @@ -64271,10 +64245,13 @@ | |
| 64245 | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet( |
| 64246 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 64247 | u32 serial_type, /* Serial type to deserialize */ |
| 64248 | Mem *pMem /* Memory cell to write value into */ |
| 64249 | ){ |
| 64250 | u64 x; |
| 64251 | u32 y; |
| 64252 | int i; |
| 64253 | switch( serial_type ){ |
| 64254 | case 10: /* Reserved for future use */ |
| 64255 | case 11: /* Reserved for future use */ |
| 64256 | case 0: { /* NULL */ |
| 64257 | pMem->flags = MEM_Null; |
| @@ -64284,36 +64261,37 @@ | |
| 64261 | pMem->u.i = (signed char)buf[0]; |
| 64262 | pMem->flags = MEM_Int; |
| 64263 | return 1; |
| 64264 | } |
| 64265 | case 2: { /* 2-byte signed integer */ |
| 64266 | i = 256*(signed char)buf[0] | buf[1]; |
| 64267 | pMem->u.i = (i64)i; |
| 64268 | pMem->flags = MEM_Int; |
| 64269 | return 2; |
| 64270 | } |
| 64271 | case 3: { /* 3-byte signed integer */ |
| 64272 | i = 65536*(signed char)buf[0] | (buf[1]<<8) | buf[2]; |
| 64273 | pMem->u.i = (i64)i; |
| 64274 | pMem->flags = MEM_Int; |
| 64275 | return 3; |
| 64276 | } |
| 64277 | case 4: { /* 4-byte signed integer */ |
| 64278 | y = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; |
| 64279 | pMem->u.i = (i64)*(int*)&y; |
| 64280 | pMem->flags = MEM_Int; |
| 64281 | return 4; |
| 64282 | } |
| 64283 | case 5: { /* 6-byte signed integer */ |
| 64284 | x = 256*(signed char)buf[0] + buf[1]; |
| 64285 | y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; |
| 64286 | x = (x<<32) | y; |
| 64287 | pMem->u.i = *(i64*)&x; |
| 64288 | pMem->flags = MEM_Int; |
| 64289 | return 6; |
| 64290 | } |
| 64291 | case 6: /* 8-byte signed integer */ |
| 64292 | case 7: { /* IEEE floating point */ |
| 64293 | #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) |
| 64294 | /* Verify that integers and floating point values use the same |
| 64295 | ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is |
| 64296 | ** defined that 64-bit floating point values really are mixed |
| 64297 | ** endian. |
| @@ -64322,13 +64300,12 @@ | |
| 64300 | static const double r1 = 1.0; |
| 64301 | u64 t2 = t1; |
| 64302 | swapMixedEndianFloat(t2); |
| 64303 | assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); |
| 64304 | #endif |
| 64305 | x = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; |
| 64306 | y = ((unsigned)buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; |
| 64307 | x = (x<<32) | y; |
| 64308 | if( serial_type==6 ){ |
| 64309 | pMem->u.i = *(i64*)&x; |
| 64310 | pMem->flags = MEM_Int; |
| 64311 | }else{ |
| @@ -72653,11 +72630,11 @@ | |
| 72630 | #ifdef SQLITE_USE_FCNTL_TRACE |
| 72631 | zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 72632 | if( zTrace ){ |
| 72633 | int i; |
| 72634 | for(i=0; i<db->nDb; i++){ |
| 72635 | if( MASKBIT(i) & p->btreeMask)==0 ) continue; |
| 72636 | sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace); |
| 72637 | } |
| 72638 | } |
| 72639 | #endif /* SQLITE_USE_FCNTL_TRACE */ |
| 72640 | #ifdef SQLITE_DEBUG |
| @@ -77499,10 +77476,11 @@ | |
| 77476 | pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; |
| 77477 | pNew->pRightmost = 0; |
| 77478 | pNew->addrOpenEphm[0] = -1; |
| 77479 | pNew->addrOpenEphm[1] = -1; |
| 77480 | pNew->addrOpenEphm[2] = -1; |
| 77481 | pNew->nSelectRow = p->nSelectRow; |
| 77482 | pNew->pWith = withDup(db, p->pWith); |
| 77483 | return pNew; |
| 77484 | } |
| 77485 | #else |
| 77486 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ |
| @@ -79120,11 +79098,11 @@ | |
| 79098 | ExprList *pFarg; /* List of function arguments */ |
| 79099 | int nFarg; /* Number of function arguments */ |
| 79100 | FuncDef *pDef; /* The function definition object */ |
| 79101 | int nId; /* Length of the function name in bytes */ |
| 79102 | const char *zId; /* The function name */ |
| 79103 | u32 constMask = 0; /* Mask of function arguments that are constant */ |
| 79104 | int i; /* Loop counter */ |
| 79105 | u8 enc = ENC(db); /* The text encoding used by this database */ |
| 79106 | CollSeq *pColl = 0; /* A collating sequence */ |
| 79107 | |
| 79108 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| @@ -79171,11 +79149,12 @@ | |
| 79149 | break; |
| 79150 | } |
| 79151 | |
| 79152 | for(i=0; i<nFarg; i++){ |
| 79153 | if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){ |
| 79154 | testcase( i==31 ); |
| 79155 | constMask |= MASKBIT32(i); |
| 79156 | } |
| 79157 | if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){ |
| 79158 | pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr); |
| 79159 | } |
| 79160 | } |
| @@ -89527,11 +89506,13 @@ | |
| 89506 | |
| 89507 | /* Populate the OLD.* pseudo-table register array. These values will be |
| 89508 | ** used by any BEFORE and AFTER triggers that exist. */ |
| 89509 | sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); |
| 89510 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 89511 | testcase( mask!=0xffffffff && iCol==31 ); |
| 89512 | testcase( mask!=0xffffffff && iCol==32 ); |
| 89513 | if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){ |
| 89514 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1); |
| 89515 | } |
| 89516 | } |
| 89517 | |
| 89518 | /* Invoke BEFORE DELETE trigger programs. */ |
| @@ -89847,11 +89828,11 @@ | |
| 89828 | UNUSED_PARAMETER(argc); |
| 89829 | switch( sqlite3_value_type(argv[0]) ){ |
| 89830 | case SQLITE_INTEGER: { |
| 89831 | i64 iVal = sqlite3_value_int64(argv[0]); |
| 89832 | if( iVal<0 ){ |
| 89833 | if( iVal==SMALLEST_INT64 ){ |
| 89834 | /* IMP: R-31676-45509 If X is the integer -9223372036854775808 |
| 89835 | ** then abs(X) throws an integer overflow error since there is no |
| 89836 | ** equivalent positive 64-bit two complement value. */ |
| 89837 | sqlite3_result_error(context, "integer overflow", -1); |
| 89838 | return; |
| @@ -100310,10 +100291,11 @@ | |
| 100291 | ** on a second ephemeral index that holds all values every previously |
| 100292 | ** added to the queue. Only add this new value if it has never before |
| 100293 | ** been added */ |
| 100294 | addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0); |
| 100295 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3); |
| 100296 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 100297 | } |
| 100298 | for(i=0; i<nKey; i++){ |
| 100299 | sqlite3VdbeAddOp2(v, OP_SCopy, |
| 100300 | regResult + pSO->a[i].u.x.iOrderByCol - 1, |
| 100301 | r2+i); |
| @@ -101220,11 +101202,48 @@ | |
| 101202 | if( pRet==0 && iCol<p->pEList->nExpr ){ |
| 101203 | pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr); |
| 101204 | } |
| 101205 | return pRet; |
| 101206 | } |
| 101207 | |
| 101208 | /* |
| 101209 | ** The select statement passed as the second parameter is a compound SELECT |
| 101210 | ** with an ORDER BY clause. This function allocates and returns a KeyInfo |
| 101211 | ** structure suitable for implementing the ORDER BY. |
| 101212 | ** |
| 101213 | ** Space to hold the KeyInfo structure is obtained from malloc. The calling |
| 101214 | ** function is responsible for ensuring that this structure is eventually |
| 101215 | ** freed. |
| 101216 | */ |
| 101217 | static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ |
| 101218 | ExprList *pOrderBy = p->pOrderBy; |
| 101219 | int nOrderBy = p->pOrderBy->nExpr; |
| 101220 | sqlite3 *db = pParse->db; |
| 101221 | KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1); |
| 101222 | if( pRet ){ |
| 101223 | int i; |
| 101224 | for(i=0; i<nOrderBy; i++){ |
| 101225 | struct ExprList_item *pItem = &pOrderBy->a[i]; |
| 101226 | Expr *pTerm = pItem->pExpr; |
| 101227 | CollSeq *pColl; |
| 101228 | |
| 101229 | if( pTerm->flags & EP_Collate ){ |
| 101230 | pColl = sqlite3ExprCollSeq(pParse, pTerm); |
| 101231 | }else{ |
| 101232 | pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1); |
| 101233 | if( pColl==0 ) pColl = db->pDfltColl; |
| 101234 | pOrderBy->a[i].pExpr = |
| 101235 | sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); |
| 101236 | } |
| 101237 | assert( sqlite3KeyInfoIsWriteable(pRet) ); |
| 101238 | pRet->aColl[i] = pColl; |
| 101239 | pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder; |
| 101240 | } |
| 101241 | } |
| 101242 | |
| 101243 | return pRet; |
| 101244 | } |
| 101245 | |
| 101246 | #ifndef SQLITE_OMIT_CTE |
| 101247 | /* |
| 101248 | ** This routine generates VDBE code to compute the content of a WITH RECURSIVE |
| 101249 | ** query of the form: |
| @@ -101294,23 +101313,20 @@ | |
| 101313 | pOffset = p->pOffset; |
| 101314 | regLimit = p->iLimit; |
| 101315 | regOffset = p->iOffset; |
| 101316 | p->pLimit = p->pOffset = 0; |
| 101317 | p->iLimit = p->iOffset = 0; |
| 101318 | pOrderBy = p->pOrderBy; |
| 101319 | |
| 101320 | /* Locate the cursor number of the Current table */ |
| 101321 | for(i=0; ALWAYS(i<pSrc->nSrc); i++){ |
| 101322 | if( pSrc->a[i].isRecursive ){ |
| 101323 | iCurrent = pSrc->a[i].iCursor; |
| 101324 | break; |
| 101325 | } |
| 101326 | } |
| 101327 | |
| 101328 | /* Allocate cursors numbers for Queue and Distinct. The cursor number for |
| 101329 | ** the Distinct table must be exactly one greater than Queue in order |
| 101330 | ** for the SRT_DistTable and SRT_DistQueue destinations to work. */ |
| 101331 | iQueue = pParse->nTab++; |
| 101332 | if( p->op==TK_UNION ){ |
| @@ -101323,11 +101339,11 @@ | |
| 101339 | |
| 101340 | /* Allocate cursors for Current, Queue, and Distinct. */ |
| 101341 | regCurrent = ++pParse->nMem; |
| 101342 | sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol); |
| 101343 | if( pOrderBy ){ |
| 101344 | KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1); |
| 101345 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0, |
| 101346 | (char*)pKeyInfo, P4_KEYINFO); |
| 101347 | destQueue.pOrderBy = pOrderBy; |
| 101348 | }else{ |
| 101349 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol); |
| @@ -101335,10 +101351,13 @@ | |
| 101351 | VdbeComment((v, "Queue table")); |
| 101352 | if( iDistinct ){ |
| 101353 | p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0); |
| 101354 | p->selFlags |= SF_UsesEphemeral; |
| 101355 | } |
| 101356 | |
| 101357 | /* Detach the ORDER BY clause from the compound SELECT */ |
| 101358 | p->pOrderBy = 0; |
| 101359 | |
| 101360 | /* Store the results of the setup-query in Queue. */ |
| 101361 | rc = sqlite3Select(pParse, pSetup, &destQueue); |
| 101362 | if( rc ) goto end_of_recursive_query; |
| 101363 | |
| @@ -101378,21 +101397,20 @@ | |
| 101397 | p->pOrderBy = pOrderBy; |
| 101398 | p->pLimit = pLimit; |
| 101399 | p->pOffset = pOffset; |
| 101400 | return; |
| 101401 | } |
| 101402 | #endif /* SQLITE_OMIT_CTE */ |
| 101403 | |
| 101404 | /* Forward references */ |
| 101405 | static int multiSelectOrderBy( |
| 101406 | Parse *pParse, /* Parsing context */ |
| 101407 | Select *p, /* The right-most of SELECTs to be coded */ |
| 101408 | SelectDest *pDest /* What to do with query results */ |
| 101409 | ); |
| 101410 | |
| 101411 | |
| 101412 | /* |
| 101413 | ** This routine is called to process a compound query form from |
| 101414 | ** two or more separate queries using UNION, UNION ALL, EXCEPT, or |
| 101415 | ** INTERSECT |
| 101416 | ** |
| @@ -102120,28 +102138,11 @@ | |
| 102138 | for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ |
| 102139 | assert( pItem->u.x.iOrderByCol>0 |
| 102140 | && pItem->u.x.iOrderByCol<=p->pEList->nExpr ); |
| 102141 | aPermute[i] = pItem->u.x.iOrderByCol - 1; |
| 102142 | } |
| 102143 | pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1); |
| 102144 | }else{ |
| 102145 | pKeyMerge = 0; |
| 102146 | } |
| 102147 | |
| 102148 | /* Reattach the ORDER BY clause to the query. |
| @@ -106614,13 +106615,14 @@ | |
| 106615 | oldmask |= sqlite3TriggerColmask(pParse, |
| 106616 | pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError |
| 106617 | ); |
| 106618 | for(i=0; i<pTab->nCol; i++){ |
| 106619 | if( oldmask==0xffffffff |
| 106620 | || (i<32 && (oldmask & MASKBIT32(i))!=0) |
| 106621 | || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 |
| 106622 | ){ |
| 106623 | testcase( oldmask!=0xffffffff && i==31 ); |
| 106624 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); |
| 106625 | }else{ |
| 106626 | sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); |
| 106627 | } |
| 106628 | } |
| @@ -106651,11 +106653,11 @@ | |
| 106653 | sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); |
| 106654 | }else{ |
| 106655 | j = aXRef[i]; |
| 106656 | if( j>=0 ){ |
| 106657 | sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i); |
| 106658 | }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){ |
| 106659 | /* This branch loads the value of a column that will not be changed |
| 106660 | ** into a register. This is done if there are no BEFORE triggers, or |
| 106661 | ** if there are one or more BEFORE triggers that use this value via |
| 106662 | ** a new.* reference in a trigger program. |
| 106663 | */ |
| @@ -112160,11 +112162,13 @@ | |
| 112162 | int iTerm; |
| 112163 | for(iTerm=0; iTerm<pWC->nTerm; iTerm++){ |
| 112164 | Expr *pExpr = pWC->a[iTerm].pExpr; |
| 112165 | if( &pWC->a[iTerm] == pTerm ) continue; |
| 112166 | if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; |
| 112167 | testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO ); |
| 112168 | testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL ); |
| 112169 | if( pWC->a[iTerm].wtFlags & (TERM_ORINFO|TERM_VIRTUAL) ) continue; |
| 112170 | if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; |
| 112171 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 112172 | pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr); |
| 112173 | } |
| 112174 | if( pAndExpr ){ |
| @@ -122726,11 +122730,11 @@ | |
| 122730 | ** database files might have arbitrary corruption. Setting the flag during |
| 122731 | ** testing causes certain assert() statements in the code to be activated |
| 122732 | ** that demonstrat invariants on well-formed database files. |
| 122733 | */ |
| 122734 | case SQLITE_TESTCTRL_NEVER_CORRUPT: { |
| 122735 | sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int); |
| 122736 | break; |
| 122737 | } |
| 122738 | |
| 122739 | } |
| 122740 | va_end(ap); |
| @@ -131724,17 +131728,17 @@ | |
| 131728 | /* |
| 131729 | ** Hash and comparison functions when the mode is FTS3_HASH_STRING |
| 131730 | */ |
| 131731 | static int fts3StrHash(const void *pKey, int nKey){ |
| 131732 | const char *z = (const char *)pKey; |
| 131733 | unsigned h = 0; |
| 131734 | if( nKey<=0 ) nKey = (int) strlen(z); |
| 131735 | while( nKey > 0 ){ |
| 131736 | h = (h<<3) ^ h ^ *z++; |
| 131737 | nKey--; |
| 131738 | } |
| 131739 | return (int)(h & 0x7fffffff); |
| 131740 | } |
| 131741 | static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ |
| 131742 | if( n1!=n2 ) return 1; |
| 131743 | return strncmp((const char*)pKey1,(const char*)pKey2,n1); |
| 131744 | } |
| 131745 |
+119
-115
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | -** version 3.8.3. By combining all the individual C code files into this | |
| 3 | +** version 3.8.3.1. By combining all the individual C code files into this | |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -133,13 +133,13 @@ | ||
| 133 | 133 | ** |
| 134 | 134 | ** See also: [sqlite3_libversion()], |
| 135 | 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | 137 | */ |
| 138 | -#define SQLITE_VERSION "3.8.3" | |
| 138 | +#define SQLITE_VERSION "3.8.3.1" | |
| 139 | 139 | #define SQLITE_VERSION_NUMBER 3008003 |
| 140 | -#define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc" | |
| 140 | +#define SQLITE_SOURCE_ID "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e" | |
| 141 | 141 | |
| 142 | 142 | /* |
| 143 | 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | 145 | ** |
| @@ -11303,10 +11303,11 @@ | ||
| 11303 | 11303 | |
| 11304 | 11304 | /* |
| 11305 | 11305 | ** A bit in a Bitmask |
| 11306 | 11306 | */ |
| 11307 | 11307 | #define MASKBIT(n) (((Bitmask)1)<<(n)) |
| 11308 | +#define MASKBIT32(n) (((unsigned int)1)<<(n)) | |
| 11308 | 11309 | |
| 11309 | 11310 | /* |
| 11310 | 11311 | ** The following structure describes the FROM clause of a SELECT statement. |
| 11311 | 11312 | ** Each table or subquery in the FROM clause is a separate element of |
| 11312 | 11313 | ** the SrcList.a[] array. |
| @@ -22605,11 +22606,12 @@ | ||
| 22605 | 22606 | |
| 22606 | 22607 | /* |
| 22607 | 22608 | ** Read or write a four-byte big-endian integer value. |
| 22608 | 22609 | */ |
| 22609 | 22610 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 22610 | - return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 22611 | + testcase( p[0]&0x80 ); | |
| 22612 | + return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; | |
| 22611 | 22613 | } |
| 22612 | 22614 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 22613 | 22615 | p[0] = (u8)(v>>24); |
| 22614 | 22616 | p[1] = (u8)(v>>16); |
| 22615 | 22617 | p[2] = (u8)(v>>8); |
| @@ -22946,11 +22948,11 @@ | ||
| 22946 | 22948 | |
| 22947 | 22949 | /* |
| 22948 | 22950 | ** The hashing function. |
| 22949 | 22951 | */ |
| 22950 | 22952 | static unsigned int strHash(const char *z, int nKey){ |
| 22951 | - int h = 0; | |
| 22953 | + unsigned int h = 0; | |
| 22952 | 22954 | assert( nKey>=0 ); |
| 22953 | 22955 | while( nKey > 0 ){ |
| 22954 | 22956 | h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; |
| 22955 | 22957 | nKey--; |
| 22956 | 22958 | } |
| @@ -27650,11 +27652,11 @@ | ||
| 27650 | 27652 | |
| 27651 | 27653 | /* Update the global lock state and do debug tracing */ |
| 27652 | 27654 | #ifdef SQLITE_DEBUG |
| 27653 | 27655 | { u16 mask; |
| 27654 | 27656 | OSTRACE(("SHM-LOCK ")); |
| 27655 | - mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<<ofst); | |
| 27657 | + mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst); | |
| 27656 | 27658 | if( rc==SQLITE_OK ){ |
| 27657 | 27659 | if( lockType==F_UNLCK ){ |
| 27658 | 27660 | OSTRACE(("unlock %d ok", ofst)); |
| 27659 | 27661 | pShmNode->exclMask &= ~mask; |
| 27660 | 27662 | pShmNode->sharedMask &= ~mask; |
| @@ -35374,11 +35376,34 @@ | ||
| 35374 | 35376 | ** function. |
| 35375 | 35377 | */ |
| 35376 | 35378 | static void *winConvertFromUtf8Filename(const char *zFilename){ |
| 35377 | 35379 | void *zConverted = 0; |
| 35378 | 35380 | if( osIsNT() ){ |
| 35379 | - zConverted = winUtf8ToUnicode(zFilename); | |
| 35381 | + int nChar; | |
| 35382 | + LPWSTR zWideFilename; | |
| 35383 | + | |
| 35384 | + nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); | |
| 35385 | + if( nChar==0 ){ | |
| 35386 | + return 0; | |
| 35387 | + } | |
| 35388 | + zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR)+8 ); | |
| 35389 | + if( zWideFilename==0 ){ | |
| 35390 | + return 0; | |
| 35391 | + } | |
| 35392 | + nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, | |
| 35393 | + zWideFilename+4, nChar); | |
| 35394 | + if( nChar==0 ){ | |
| 35395 | + sqlite3_free(zWideFilename); | |
| 35396 | + return 0; | |
| 35397 | + }else if( nChar>SQLITE_WIN32_MAX_PATH_CHARS | |
| 35398 | + && winIsDriveLetterAndColon(zFilename) | |
| 35399 | + && zFilename[2] == '\\' ){ | |
| 35400 | + memcpy(zWideFilename, L"\\\\?\\", 8); | |
| 35401 | + }else{ | |
| 35402 | + memmove(zWideFilename, zWideFilename+4, nChar*sizeof(WCHAR)); | |
| 35403 | + } | |
| 35404 | + zConverted = zWideFilename; | |
| 35380 | 35405 | } |
| 35381 | 35406 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 35382 | 35407 | else{ |
| 35383 | 35408 | zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); |
| 35384 | 35409 | } |
| @@ -36305,67 +36330,14 @@ | ||
| 36305 | 36330 | */ |
| 36306 | 36331 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 36307 | 36332 | sqlite3_data_directory, winGetDirSep(), zRelative); |
| 36308 | 36333 | return SQLITE_OK; |
| 36309 | 36334 | } |
| 36310 | - nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, NULL, 0); | |
| 36311 | - if( nByte==0 ){ | |
| 36312 | - return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)osGetLastError(), | |
| 36313 | - "winFullPathname", zRelative); | |
| 36314 | - } | |
| 36315 | - if( osIsNT() ){ | |
| 36316 | - LPWSTR zWideFilename; | |
| 36317 | - | |
| 36318 | - if( nByte>SQLITE_WIN32_MAX_PATH_CHARS ){ | |
| 36319 | - /* No Win32 API functions can handle such long paths. Let's see if | |
| 36320 | - * we can do something about it. If not, just leave it as is. */ | |
| 36321 | - if( winIsDirSep(zRelative[0]) && winIsDirSep(zRelative[1]) | |
| 36322 | - && zRelative[2]!='?' ){ | |
| 36323 | - /* It's an UNC path, convert it to an extended UNC path. */ | |
| 36324 | - zWideFilename = sqlite3MallocZero( (nByte+6)*sizeof(WCHAR) ); | |
| 36325 | - if( zWideFilename==0 ){ | |
| 36326 | - return SQLITE_IOERR_NOMEM; | |
| 36327 | - } | |
| 36328 | - memcpy(zWideFilename, L"\\\\?\\UNC\\", 16); | |
| 36329 | - nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative+2, -1, | |
| 36330 | - zWideFilename+8, nByte); | |
| 36331 | - goto finished; | |
| 36332 | - }else if( winIsDriveLetterAndColon(zRelative) | |
| 36333 | - && winIsDirSep(zRelative[2]) ){ | |
| 36334 | - /* It has a correct drive prefix, convert to extended form. */ | |
| 36335 | - zWideFilename = sqlite3MallocZero( (nByte+4)*sizeof(WCHAR) ); | |
| 36336 | - if( zWideFilename==0 ){ | |
| 36337 | - return SQLITE_IOERR_NOMEM; | |
| 36338 | - } | |
| 36339 | - memcpy(zWideFilename, L"\\\\?\\", 8); | |
| 36340 | - nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, | |
| 36341 | - zWideFilename+4, nByte); | |
| 36342 | - zWideFilename[6] = '\\'; | |
| 36343 | - goto finished; | |
| 36344 | - } | |
| 36345 | - /* Another form, e.g. relative path or maybe it already | |
| 36346 | - * has the '\\?\' prefix. Just leave it as-is. */ | |
| 36347 | - } | |
| 36348 | - zWideFilename = sqlite3Malloc( nByte*sizeof(WCHAR) ); | |
| 36349 | - if( zWideFilename==0 ){ | |
| 36350 | - return SQLITE_IOERR_NOMEM; | |
| 36351 | - } | |
| 36352 | - nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, | |
| 36353 | - zWideFilename, nByte); | |
| 36354 | - if( nByte==0 ){ | |
| 36355 | - sqlite3_free(zWideFilename); | |
| 36356 | - return SQLITE_IOERR_NOMEM; | |
| 36357 | - } | |
| 36358 | - finished: | |
| 36359 | - zConverted = zWideFilename; | |
| 36360 | - }else{ | |
| 36361 | - zConverted = sqlite3_win32_utf8_to_mbcs(zRelative); | |
| 36362 | - if( zConverted==0 ){ | |
| 36363 | - return SQLITE_IOERR_NOMEM; | |
| 36364 | - } | |
| 36365 | - } | |
| 36366 | - | |
| 36335 | + zConverted = winConvertFromUtf8Filename(zRelative); | |
| 36336 | + if( zConverted==0 ){ | |
| 36337 | + return SQLITE_IOERR_NOMEM; | |
| 36338 | + } | |
| 36367 | 36339 | if( osIsNT() ){ |
| 36368 | 36340 | LPWSTR zTemp; |
| 36369 | 36341 | nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); |
| 36370 | 36342 | if( nByte==0 ){ |
| 36371 | 36343 | sqlite3_free(zConverted); |
| @@ -38479,10 +38451,11 @@ | ||
| 38479 | 38451 | unsigned int nPinned; |
| 38480 | 38452 | PCache1 *pCache = (PCache1 *)p; |
| 38481 | 38453 | PGroup *pGroup; |
| 38482 | 38454 | PgHdr1 *pPage = 0; |
| 38483 | 38455 | |
| 38456 | + assert( offsetof(PgHdr1,page)==0 ); | |
| 38484 | 38457 | assert( pCache->bPurgeable || createFlag!=1 ); |
| 38485 | 38458 | assert( pCache->bPurgeable || pCache->nMin==0 ); |
| 38486 | 38459 | assert( pCache->bPurgeable==0 || pCache->nMin==10 ); |
| 38487 | 38460 | assert( pCache->nMin==0 || pCache->bPurgeable ); |
| 38488 | 38461 | pcache1EnterMutex(pGroup = pCache->pGroup); |
| @@ -38584,11 +38557,11 @@ | ||
| 38584 | 38557 | fetch_out: |
| 38585 | 38558 | if( pPage && iKey>pCache->iMaxKey ){ |
| 38586 | 38559 | pCache->iMaxKey = iKey; |
| 38587 | 38560 | } |
| 38588 | 38561 | pcache1LeaveMutex(pGroup); |
| 38589 | - return &pPage->page; | |
| 38562 | + return (sqlite3_pcache_page*)pPage; | |
| 38590 | 38563 | } |
| 38591 | 38564 | |
| 38592 | 38565 | |
| 38593 | 38566 | /* |
| 38594 | 38567 | ** Implementation of the sqlite3_pcache.xUnpin method. |
| @@ -41124,11 +41097,11 @@ | ||
| 41124 | 41097 | ** Find a page in the hash table given its page number. Return |
| 41125 | 41098 | ** a pointer to the page or NULL if the requested page is not |
| 41126 | 41099 | ** already in memory. |
| 41127 | 41100 | */ |
| 41128 | 41101 | static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){ |
| 41129 | - PgHdr *p; /* Return value */ | |
| 41102 | + PgHdr *p = 0; /* Return value */ | |
| 41130 | 41103 | |
| 41131 | 41104 | /* It is not possible for a call to PcacheFetch() with createFlag==0 to |
| 41132 | 41105 | ** fail, since no attempt to allocate dynamic memory will be made. |
| 41133 | 41106 | */ |
| 41134 | 41107 | (void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &p); |
| @@ -60551,11 +60524,11 @@ | ||
| 60551 | 60524 | #endif /* SQLITE_DEBUG */ |
| 60552 | 60525 | |
| 60553 | 60526 | /* |
| 60554 | 60527 | ** Size of struct Mem not including the Mem.zMalloc member. |
| 60555 | 60528 | */ |
| 60556 | -#define MEMCELLSIZE (size_t)(&(((Mem *)0)->zMalloc)) | |
| 60529 | +#define MEMCELLSIZE offsetof(Mem,zMalloc) | |
| 60557 | 60530 | |
| 60558 | 60531 | /* |
| 60559 | 60532 | ** Make an shallow copy of pFrom into pTo. Prior contents of |
| 60560 | 60533 | ** pTo are freed. The pFrom->z field is not duplicated. If |
| 60561 | 60534 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| @@ -63955,12 +63928,13 @@ | ||
| 63955 | 63928 | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ |
| 63956 | 63929 | AuxData **pp = &pVdbe->pAuxData; |
| 63957 | 63930 | while( *pp ){ |
| 63958 | 63931 | AuxData *pAux = *pp; |
| 63959 | 63932 | if( (iOp<0) |
| 63960 | - || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg)))) | |
| 63933 | + || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg)))) | |
| 63961 | 63934 | ){ |
| 63935 | + testcase( pAux->iArg==31 ); | |
| 63962 | 63936 | if( pAux->xDelete ){ |
| 63963 | 63937 | pAux->xDelete(pAux->pAux); |
| 63964 | 63938 | } |
| 63965 | 63939 | *pp = pAux->pNext; |
| 63966 | 63940 | sqlite3DbFree(pVdbe->db, pAux); |
| @@ -64271,10 +64245,13 @@ | ||
| 64271 | 64245 | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet( |
| 64272 | 64246 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 64273 | 64247 | u32 serial_type, /* Serial type to deserialize */ |
| 64274 | 64248 | Mem *pMem /* Memory cell to write value into */ |
| 64275 | 64249 | ){ |
| 64250 | + u64 x; | |
| 64251 | + u32 y; | |
| 64252 | + int i; | |
| 64276 | 64253 | switch( serial_type ){ |
| 64277 | 64254 | case 10: /* Reserved for future use */ |
| 64278 | 64255 | case 11: /* Reserved for future use */ |
| 64279 | 64256 | case 0: { /* NULL */ |
| 64280 | 64257 | pMem->flags = MEM_Null; |
| @@ -64284,36 +64261,37 @@ | ||
| 64284 | 64261 | pMem->u.i = (signed char)buf[0]; |
| 64285 | 64262 | pMem->flags = MEM_Int; |
| 64286 | 64263 | return 1; |
| 64287 | 64264 | } |
| 64288 | 64265 | case 2: { /* 2-byte signed integer */ |
| 64289 | - pMem->u.i = (((signed char)buf[0])<<8) | buf[1]; | |
| 64266 | + i = 256*(signed char)buf[0] | buf[1]; | |
| 64267 | + pMem->u.i = (i64)i; | |
| 64290 | 64268 | pMem->flags = MEM_Int; |
| 64291 | 64269 | return 2; |
| 64292 | 64270 | } |
| 64293 | 64271 | case 3: { /* 3-byte signed integer */ |
| 64294 | - pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2]; | |
| 64272 | + i = 65536*(signed char)buf[0] | (buf[1]<<8) | buf[2]; | |
| 64273 | + pMem->u.i = (i64)i; | |
| 64295 | 64274 | pMem->flags = MEM_Int; |
| 64296 | 64275 | return 3; |
| 64297 | 64276 | } |
| 64298 | 64277 | case 4: { /* 4-byte signed integer */ |
| 64299 | - pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; | |
| 64278 | + y = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; | |
| 64279 | + pMem->u.i = (i64)*(int*)&y; | |
| 64300 | 64280 | pMem->flags = MEM_Int; |
| 64301 | 64281 | return 4; |
| 64302 | 64282 | } |
| 64303 | 64283 | case 5: { /* 6-byte signed integer */ |
| 64304 | - u64 x = (((signed char)buf[0])<<8) | buf[1]; | |
| 64305 | - u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; | |
| 64284 | + x = 256*(signed char)buf[0] + buf[1]; | |
| 64285 | + y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; | |
| 64306 | 64286 | x = (x<<32) | y; |
| 64307 | 64287 | pMem->u.i = *(i64*)&x; |
| 64308 | 64288 | pMem->flags = MEM_Int; |
| 64309 | 64289 | return 6; |
| 64310 | 64290 | } |
| 64311 | 64291 | case 6: /* 8-byte signed integer */ |
| 64312 | 64292 | case 7: { /* IEEE floating point */ |
| 64313 | - u64 x; | |
| 64314 | - u32 y; | |
| 64315 | 64293 | #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) |
| 64316 | 64294 | /* Verify that integers and floating point values use the same |
| 64317 | 64295 | ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is |
| 64318 | 64296 | ** defined that 64-bit floating point values really are mixed |
| 64319 | 64297 | ** endian. |
| @@ -64322,13 +64300,12 @@ | ||
| 64322 | 64300 | static const double r1 = 1.0; |
| 64323 | 64301 | u64 t2 = t1; |
| 64324 | 64302 | swapMixedEndianFloat(t2); |
| 64325 | 64303 | assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); |
| 64326 | 64304 | #endif |
| 64327 | - | |
| 64328 | - x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; | |
| 64329 | - y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; | |
| 64305 | + x = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; | |
| 64306 | + y = ((unsigned)buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; | |
| 64330 | 64307 | x = (x<<32) | y; |
| 64331 | 64308 | if( serial_type==6 ){ |
| 64332 | 64309 | pMem->u.i = *(i64*)&x; |
| 64333 | 64310 | pMem->flags = MEM_Int; |
| 64334 | 64311 | }else{ |
| @@ -72653,11 +72630,11 @@ | ||
| 72653 | 72630 | #ifdef SQLITE_USE_FCNTL_TRACE |
| 72654 | 72631 | zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 72655 | 72632 | if( zTrace ){ |
| 72656 | 72633 | int i; |
| 72657 | 72634 | for(i=0; i<db->nDb; i++){ |
| 72658 | - if( ((1<<i) & p->btreeMask)==0 ) continue; | |
| 72635 | + if( MASKBIT(i) & p->btreeMask)==0 ) continue; | |
| 72659 | 72636 | sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace); |
| 72660 | 72637 | } |
| 72661 | 72638 | } |
| 72662 | 72639 | #endif /* SQLITE_USE_FCNTL_TRACE */ |
| 72663 | 72640 | #ifdef SQLITE_DEBUG |
| @@ -77499,10 +77476,11 @@ | ||
| 77499 | 77476 | pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; |
| 77500 | 77477 | pNew->pRightmost = 0; |
| 77501 | 77478 | pNew->addrOpenEphm[0] = -1; |
| 77502 | 77479 | pNew->addrOpenEphm[1] = -1; |
| 77503 | 77480 | pNew->addrOpenEphm[2] = -1; |
| 77481 | + pNew->nSelectRow = p->nSelectRow; | |
| 77504 | 77482 | pNew->pWith = withDup(db, p->pWith); |
| 77505 | 77483 | return pNew; |
| 77506 | 77484 | } |
| 77507 | 77485 | #else |
| 77508 | 77486 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ |
| @@ -79120,11 +79098,11 @@ | ||
| 79120 | 79098 | ExprList *pFarg; /* List of function arguments */ |
| 79121 | 79099 | int nFarg; /* Number of function arguments */ |
| 79122 | 79100 | FuncDef *pDef; /* The function definition object */ |
| 79123 | 79101 | int nId; /* Length of the function name in bytes */ |
| 79124 | 79102 | const char *zId; /* The function name */ |
| 79125 | - int constMask = 0; /* Mask of function arguments that are constant */ | |
| 79103 | + u32 constMask = 0; /* Mask of function arguments that are constant */ | |
| 79126 | 79104 | int i; /* Loop counter */ |
| 79127 | 79105 | u8 enc = ENC(db); /* The text encoding used by this database */ |
| 79128 | 79106 | CollSeq *pColl = 0; /* A collating sequence */ |
| 79129 | 79107 | |
| 79130 | 79108 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| @@ -79171,11 +79149,12 @@ | ||
| 79171 | 79149 | break; |
| 79172 | 79150 | } |
| 79173 | 79151 | |
| 79174 | 79152 | for(i=0; i<nFarg; i++){ |
| 79175 | 79153 | if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){ |
| 79176 | - constMask |= (1<<i); | |
| 79154 | + testcase( i==31 ); | |
| 79155 | + constMask |= MASKBIT32(i); | |
| 79177 | 79156 | } |
| 79178 | 79157 | if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){ |
| 79179 | 79158 | pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr); |
| 79180 | 79159 | } |
| 79181 | 79160 | } |
| @@ -89527,11 +89506,13 @@ | ||
| 89527 | 89506 | |
| 89528 | 89507 | /* Populate the OLD.* pseudo-table register array. These values will be |
| 89529 | 89508 | ** used by any BEFORE and AFTER triggers that exist. */ |
| 89530 | 89509 | sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); |
| 89531 | 89510 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 89532 | - if( mask==0xffffffff || mask&(1<<iCol) ){ | |
| 89511 | + testcase( mask!=0xffffffff && iCol==31 ); | |
| 89512 | + testcase( mask!=0xffffffff && iCol==32 ); | |
| 89513 | + if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){ | |
| 89533 | 89514 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1); |
| 89534 | 89515 | } |
| 89535 | 89516 | } |
| 89536 | 89517 | |
| 89537 | 89518 | /* Invoke BEFORE DELETE trigger programs. */ |
| @@ -89847,11 +89828,11 @@ | ||
| 89847 | 89828 | UNUSED_PARAMETER(argc); |
| 89848 | 89829 | switch( sqlite3_value_type(argv[0]) ){ |
| 89849 | 89830 | case SQLITE_INTEGER: { |
| 89850 | 89831 | i64 iVal = sqlite3_value_int64(argv[0]); |
| 89851 | 89832 | if( iVal<0 ){ |
| 89852 | - if( (iVal<<1)==0 ){ | |
| 89833 | + if( iVal==SMALLEST_INT64 ){ | |
| 89853 | 89834 | /* IMP: R-31676-45509 If X is the integer -9223372036854775808 |
| 89854 | 89835 | ** then abs(X) throws an integer overflow error since there is no |
| 89855 | 89836 | ** equivalent positive 64-bit two complement value. */ |
| 89856 | 89837 | sqlite3_result_error(context, "integer overflow", -1); |
| 89857 | 89838 | return; |
| @@ -100310,10 +100291,11 @@ | ||
| 100310 | 100291 | ** on a second ephemeral index that holds all values every previously |
| 100311 | 100292 | ** added to the queue. Only add this new value if it has never before |
| 100312 | 100293 | ** been added */ |
| 100313 | 100294 | addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0); |
| 100314 | 100295 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3); |
| 100296 | + sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); | |
| 100315 | 100297 | } |
| 100316 | 100298 | for(i=0; i<nKey; i++){ |
| 100317 | 100299 | sqlite3VdbeAddOp2(v, OP_SCopy, |
| 100318 | 100300 | regResult + pSO->a[i].u.x.iOrderByCol - 1, |
| 100319 | 100301 | r2+i); |
| @@ -101220,11 +101202,48 @@ | ||
| 101220 | 101202 | if( pRet==0 && iCol<p->pEList->nExpr ){ |
| 101221 | 101203 | pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr); |
| 101222 | 101204 | } |
| 101223 | 101205 | return pRet; |
| 101224 | 101206 | } |
| 101225 | -#endif /* SQLITE_OMIT_COMPOUND_SELECT */ | |
| 101207 | + | |
| 101208 | +/* | |
| 101209 | +** The select statement passed as the second parameter is a compound SELECT | |
| 101210 | +** with an ORDER BY clause. This function allocates and returns a KeyInfo | |
| 101211 | +** structure suitable for implementing the ORDER BY. | |
| 101212 | +** | |
| 101213 | +** Space to hold the KeyInfo structure is obtained from malloc. The calling | |
| 101214 | +** function is responsible for ensuring that this structure is eventually | |
| 101215 | +** freed. | |
| 101216 | +*/ | |
| 101217 | +static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ | |
| 101218 | + ExprList *pOrderBy = p->pOrderBy; | |
| 101219 | + int nOrderBy = p->pOrderBy->nExpr; | |
| 101220 | + sqlite3 *db = pParse->db; | |
| 101221 | + KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1); | |
| 101222 | + if( pRet ){ | |
| 101223 | + int i; | |
| 101224 | + for(i=0; i<nOrderBy; i++){ | |
| 101225 | + struct ExprList_item *pItem = &pOrderBy->a[i]; | |
| 101226 | + Expr *pTerm = pItem->pExpr; | |
| 101227 | + CollSeq *pColl; | |
| 101228 | + | |
| 101229 | + if( pTerm->flags & EP_Collate ){ | |
| 101230 | + pColl = sqlite3ExprCollSeq(pParse, pTerm); | |
| 101231 | + }else{ | |
| 101232 | + pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1); | |
| 101233 | + if( pColl==0 ) pColl = db->pDfltColl; | |
| 101234 | + pOrderBy->a[i].pExpr = | |
| 101235 | + sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); | |
| 101236 | + } | |
| 101237 | + assert( sqlite3KeyInfoIsWriteable(pRet) ); | |
| 101238 | + pRet->aColl[i] = pColl; | |
| 101239 | + pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder; | |
| 101240 | + } | |
| 101241 | + } | |
| 101242 | + | |
| 101243 | + return pRet; | |
| 101244 | +} | |
| 101226 | 101245 | |
| 101227 | 101246 | #ifndef SQLITE_OMIT_CTE |
| 101228 | 101247 | /* |
| 101229 | 101248 | ** This routine generates VDBE code to compute the content of a WITH RECURSIVE |
| 101230 | 101249 | ** query of the form: |
| @@ -101294,23 +101313,20 @@ | ||
| 101294 | 101313 | pOffset = p->pOffset; |
| 101295 | 101314 | regLimit = p->iLimit; |
| 101296 | 101315 | regOffset = p->iOffset; |
| 101297 | 101316 | p->pLimit = p->pOffset = 0; |
| 101298 | 101317 | p->iLimit = p->iOffset = 0; |
| 101318 | + pOrderBy = p->pOrderBy; | |
| 101299 | 101319 | |
| 101300 | 101320 | /* Locate the cursor number of the Current table */ |
| 101301 | 101321 | for(i=0; ALWAYS(i<pSrc->nSrc); i++){ |
| 101302 | 101322 | if( pSrc->a[i].isRecursive ){ |
| 101303 | 101323 | iCurrent = pSrc->a[i].iCursor; |
| 101304 | 101324 | break; |
| 101305 | 101325 | } |
| 101306 | 101326 | } |
| 101307 | 101327 | |
| 101308 | - /* Detach the ORDER BY clause from the compound SELECT */ | |
| 101309 | - pOrderBy = p->pOrderBy; | |
| 101310 | - p->pOrderBy = 0; | |
| 101311 | - | |
| 101312 | 101328 | /* Allocate cursors numbers for Queue and Distinct. The cursor number for |
| 101313 | 101329 | ** the Distinct table must be exactly one greater than Queue in order |
| 101314 | 101330 | ** for the SRT_DistTable and SRT_DistQueue destinations to work. */ |
| 101315 | 101331 | iQueue = pParse->nTab++; |
| 101316 | 101332 | if( p->op==TK_UNION ){ |
| @@ -101323,11 +101339,11 @@ | ||
| 101323 | 101339 | |
| 101324 | 101340 | /* Allocate cursors for Current, Queue, and Distinct. */ |
| 101325 | 101341 | regCurrent = ++pParse->nMem; |
| 101326 | 101342 | sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol); |
| 101327 | 101343 | if( pOrderBy ){ |
| 101328 | - KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pOrderBy, 1); | |
| 101344 | + KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1); | |
| 101329 | 101345 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0, |
| 101330 | 101346 | (char*)pKeyInfo, P4_KEYINFO); |
| 101331 | 101347 | destQueue.pOrderBy = pOrderBy; |
| 101332 | 101348 | }else{ |
| 101333 | 101349 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol); |
| @@ -101335,10 +101351,13 @@ | ||
| 101335 | 101351 | VdbeComment((v, "Queue table")); |
| 101336 | 101352 | if( iDistinct ){ |
| 101337 | 101353 | p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0); |
| 101338 | 101354 | p->selFlags |= SF_UsesEphemeral; |
| 101339 | 101355 | } |
| 101356 | + | |
| 101357 | + /* Detach the ORDER BY clause from the compound SELECT */ | |
| 101358 | + p->pOrderBy = 0; | |
| 101340 | 101359 | |
| 101341 | 101360 | /* Store the results of the setup-query in Queue. */ |
| 101342 | 101361 | rc = sqlite3Select(pParse, pSetup, &destQueue); |
| 101343 | 101362 | if( rc ) goto end_of_recursive_query; |
| 101344 | 101363 | |
| @@ -101378,21 +101397,20 @@ | ||
| 101378 | 101397 | p->pOrderBy = pOrderBy; |
| 101379 | 101398 | p->pLimit = pLimit; |
| 101380 | 101399 | p->pOffset = pOffset; |
| 101381 | 101400 | return; |
| 101382 | 101401 | } |
| 101383 | -#endif | |
| 101402 | +#endif /* SQLITE_OMIT_CTE */ | |
| 101384 | 101403 | |
| 101385 | 101404 | /* Forward references */ |
| 101386 | 101405 | static int multiSelectOrderBy( |
| 101387 | 101406 | Parse *pParse, /* Parsing context */ |
| 101388 | 101407 | Select *p, /* The right-most of SELECTs to be coded */ |
| 101389 | 101408 | SelectDest *pDest /* What to do with query results */ |
| 101390 | 101409 | ); |
| 101391 | 101410 | |
| 101392 | 101411 | |
| 101393 | -#ifndef SQLITE_OMIT_COMPOUND_SELECT | |
| 101394 | 101412 | /* |
| 101395 | 101413 | ** This routine is called to process a compound query form from |
| 101396 | 101414 | ** two or more separate queries using UNION, UNION ALL, EXCEPT, or |
| 101397 | 101415 | ** INTERSECT |
| 101398 | 101416 | ** |
| @@ -102120,28 +102138,11 @@ | ||
| 102120 | 102138 | for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ |
| 102121 | 102139 | assert( pItem->u.x.iOrderByCol>0 |
| 102122 | 102140 | && pItem->u.x.iOrderByCol<=p->pEList->nExpr ); |
| 102123 | 102141 | aPermute[i] = pItem->u.x.iOrderByCol - 1; |
| 102124 | 102142 | } |
| 102125 | - pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy, 1); | |
| 102126 | - if( pKeyMerge ){ | |
| 102127 | - for(i=0; i<nOrderBy; i++){ | |
| 102128 | - CollSeq *pColl; | |
| 102129 | - Expr *pTerm = pOrderBy->a[i].pExpr; | |
| 102130 | - if( pTerm->flags & EP_Collate ){ | |
| 102131 | - pColl = sqlite3ExprCollSeq(pParse, pTerm); | |
| 102132 | - }else{ | |
| 102133 | - pColl = multiSelectCollSeq(pParse, p, aPermute[i]); | |
| 102134 | - if( pColl==0 ) pColl = db->pDfltColl; | |
| 102135 | - pOrderBy->a[i].pExpr = | |
| 102136 | - sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); | |
| 102137 | - } | |
| 102138 | - assert( sqlite3KeyInfoIsWriteable(pKeyMerge) ); | |
| 102139 | - pKeyMerge->aColl[i] = pColl; | |
| 102140 | - pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder; | |
| 102141 | - } | |
| 102142 | - } | |
| 102143 | + pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1); | |
| 102143 | 102144 | }else{ |
| 102144 | 102145 | pKeyMerge = 0; |
| 102145 | 102146 | } |
| 102146 | 102147 | |
| 102147 | 102148 | /* Reattach the ORDER BY clause to the query. |
| @@ -106614,13 +106615,14 @@ | ||
| 106614 | 106615 | oldmask |= sqlite3TriggerColmask(pParse, |
| 106615 | 106616 | pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError |
| 106616 | 106617 | ); |
| 106617 | 106618 | for(i=0; i<pTab->nCol; i++){ |
| 106618 | 106619 | if( oldmask==0xffffffff |
| 106619 | - || (i<32 && (oldmask & (1<<i))) | |
| 106620 | + || (i<32 && (oldmask & MASKBIT32(i))!=0) | |
| 106620 | 106621 | || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 |
| 106621 | 106622 | ){ |
| 106623 | + testcase( oldmask!=0xffffffff && i==31 ); | |
| 106622 | 106624 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); |
| 106623 | 106625 | }else{ |
| 106624 | 106626 | sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); |
| 106625 | 106627 | } |
| 106626 | 106628 | } |
| @@ -106651,11 +106653,11 @@ | ||
| 106651 | 106653 | sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); |
| 106652 | 106654 | }else{ |
| 106653 | 106655 | j = aXRef[i]; |
| 106654 | 106656 | if( j>=0 ){ |
| 106655 | 106657 | sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i); |
| 106656 | - }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){ | |
| 106658 | + }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){ | |
| 106657 | 106659 | /* This branch loads the value of a column that will not be changed |
| 106658 | 106660 | ** into a register. This is done if there are no BEFORE triggers, or |
| 106659 | 106661 | ** if there are one or more BEFORE triggers that use this value via |
| 106660 | 106662 | ** a new.* reference in a trigger program. |
| 106661 | 106663 | */ |
| @@ -112160,11 +112162,13 @@ | ||
| 112160 | 112162 | int iTerm; |
| 112161 | 112163 | for(iTerm=0; iTerm<pWC->nTerm; iTerm++){ |
| 112162 | 112164 | Expr *pExpr = pWC->a[iTerm].pExpr; |
| 112163 | 112165 | if( &pWC->a[iTerm] == pTerm ) continue; |
| 112164 | 112166 | if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; |
| 112165 | - if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue; | |
| 112167 | + testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO ); | |
| 112168 | + testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL ); | |
| 112169 | + if( pWC->a[iTerm].wtFlags & (TERM_ORINFO|TERM_VIRTUAL) ) continue; | |
| 112166 | 112170 | if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; |
| 112167 | 112171 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 112168 | 112172 | pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr); |
| 112169 | 112173 | } |
| 112170 | 112174 | if( pAndExpr ){ |
| @@ -122726,11 +122730,11 @@ | ||
| 122726 | 122730 | ** database files might have arbitrary corruption. Setting the flag during |
| 122727 | 122731 | ** testing causes certain assert() statements in the code to be activated |
| 122728 | 122732 | ** that demonstrat invariants on well-formed database files. |
| 122729 | 122733 | */ |
| 122730 | 122734 | case SQLITE_TESTCTRL_NEVER_CORRUPT: { |
| 122731 | - sqlite3Config.neverCorrupt = va_arg(ap, int); | |
| 122735 | + sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int); | |
| 122732 | 122736 | break; |
| 122733 | 122737 | } |
| 122734 | 122738 | |
| 122735 | 122739 | } |
| 122736 | 122740 | va_end(ap); |
| @@ -131724,17 +131728,17 @@ | ||
| 131724 | 131728 | /* |
| 131725 | 131729 | ** Hash and comparison functions when the mode is FTS3_HASH_STRING |
| 131726 | 131730 | */ |
| 131727 | 131731 | static int fts3StrHash(const void *pKey, int nKey){ |
| 131728 | 131732 | const char *z = (const char *)pKey; |
| 131729 | - int h = 0; | |
| 131733 | + unsigned h = 0; | |
| 131730 | 131734 | if( nKey<=0 ) nKey = (int) strlen(z); |
| 131731 | 131735 | while( nKey > 0 ){ |
| 131732 | 131736 | h = (h<<3) ^ h ^ *z++; |
| 131733 | 131737 | nKey--; |
| 131734 | 131738 | } |
| 131735 | - return h & 0x7fffffff; | |
| 131739 | + return (int)(h & 0x7fffffff); | |
| 131736 | 131740 | } |
| 131737 | 131741 | static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ |
| 131738 | 131742 | if( n1!=n2 ) return 1; |
| 131739 | 131743 | return strncmp((const char*)pKey1,(const char*)pKey2,n1); |
| 131740 | 131744 | } |
| 131741 | 131745 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.8.3. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -133,13 +133,13 @@ | |
| 133 | ** |
| 134 | ** See also: [sqlite3_libversion()], |
| 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | */ |
| 138 | #define SQLITE_VERSION "3.8.3" |
| 139 | #define SQLITE_VERSION_NUMBER 3008003 |
| 140 | #define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc" |
| 141 | |
| 142 | /* |
| 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | ** |
| @@ -11303,10 +11303,11 @@ | |
| 11303 | |
| 11304 | /* |
| 11305 | ** A bit in a Bitmask |
| 11306 | */ |
| 11307 | #define MASKBIT(n) (((Bitmask)1)<<(n)) |
| 11308 | |
| 11309 | /* |
| 11310 | ** The following structure describes the FROM clause of a SELECT statement. |
| 11311 | ** Each table or subquery in the FROM clause is a separate element of |
| 11312 | ** the SrcList.a[] array. |
| @@ -22605,11 +22606,12 @@ | |
| 22605 | |
| 22606 | /* |
| 22607 | ** Read or write a four-byte big-endian integer value. |
| 22608 | */ |
| 22609 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 22610 | return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; |
| 22611 | } |
| 22612 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 22613 | p[0] = (u8)(v>>24); |
| 22614 | p[1] = (u8)(v>>16); |
| 22615 | p[2] = (u8)(v>>8); |
| @@ -22946,11 +22948,11 @@ | |
| 22946 | |
| 22947 | /* |
| 22948 | ** The hashing function. |
| 22949 | */ |
| 22950 | static unsigned int strHash(const char *z, int nKey){ |
| 22951 | int h = 0; |
| 22952 | assert( nKey>=0 ); |
| 22953 | while( nKey > 0 ){ |
| 22954 | h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; |
| 22955 | nKey--; |
| 22956 | } |
| @@ -27650,11 +27652,11 @@ | |
| 27650 | |
| 27651 | /* Update the global lock state and do debug tracing */ |
| 27652 | #ifdef SQLITE_DEBUG |
| 27653 | { u16 mask; |
| 27654 | OSTRACE(("SHM-LOCK ")); |
| 27655 | mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<<ofst); |
| 27656 | if( rc==SQLITE_OK ){ |
| 27657 | if( lockType==F_UNLCK ){ |
| 27658 | OSTRACE(("unlock %d ok", ofst)); |
| 27659 | pShmNode->exclMask &= ~mask; |
| 27660 | pShmNode->sharedMask &= ~mask; |
| @@ -35374,11 +35376,34 @@ | |
| 35374 | ** function. |
| 35375 | */ |
| 35376 | static void *winConvertFromUtf8Filename(const char *zFilename){ |
| 35377 | void *zConverted = 0; |
| 35378 | if( osIsNT() ){ |
| 35379 | zConverted = winUtf8ToUnicode(zFilename); |
| 35380 | } |
| 35381 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 35382 | else{ |
| 35383 | zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); |
| 35384 | } |
| @@ -36305,67 +36330,14 @@ | |
| 36305 | */ |
| 36306 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 36307 | sqlite3_data_directory, winGetDirSep(), zRelative); |
| 36308 | return SQLITE_OK; |
| 36309 | } |
| 36310 | nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, NULL, 0); |
| 36311 | if( nByte==0 ){ |
| 36312 | return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)osGetLastError(), |
| 36313 | "winFullPathname", zRelative); |
| 36314 | } |
| 36315 | if( osIsNT() ){ |
| 36316 | LPWSTR zWideFilename; |
| 36317 | |
| 36318 | if( nByte>SQLITE_WIN32_MAX_PATH_CHARS ){ |
| 36319 | /* No Win32 API functions can handle such long paths. Let's see if |
| 36320 | * we can do something about it. If not, just leave it as is. */ |
| 36321 | if( winIsDirSep(zRelative[0]) && winIsDirSep(zRelative[1]) |
| 36322 | && zRelative[2]!='?' ){ |
| 36323 | /* It's an UNC path, convert it to an extended UNC path. */ |
| 36324 | zWideFilename = sqlite3MallocZero( (nByte+6)*sizeof(WCHAR) ); |
| 36325 | if( zWideFilename==0 ){ |
| 36326 | return SQLITE_IOERR_NOMEM; |
| 36327 | } |
| 36328 | memcpy(zWideFilename, L"\\\\?\\UNC\\", 16); |
| 36329 | nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative+2, -1, |
| 36330 | zWideFilename+8, nByte); |
| 36331 | goto finished; |
| 36332 | }else if( winIsDriveLetterAndColon(zRelative) |
| 36333 | && winIsDirSep(zRelative[2]) ){ |
| 36334 | /* It has a correct drive prefix, convert to extended form. */ |
| 36335 | zWideFilename = sqlite3MallocZero( (nByte+4)*sizeof(WCHAR) ); |
| 36336 | if( zWideFilename==0 ){ |
| 36337 | return SQLITE_IOERR_NOMEM; |
| 36338 | } |
| 36339 | memcpy(zWideFilename, L"\\\\?\\", 8); |
| 36340 | nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, |
| 36341 | zWideFilename+4, nByte); |
| 36342 | zWideFilename[6] = '\\'; |
| 36343 | goto finished; |
| 36344 | } |
| 36345 | /* Another form, e.g. relative path or maybe it already |
| 36346 | * has the '\\?\' prefix. Just leave it as-is. */ |
| 36347 | } |
| 36348 | zWideFilename = sqlite3Malloc( nByte*sizeof(WCHAR) ); |
| 36349 | if( zWideFilename==0 ){ |
| 36350 | return SQLITE_IOERR_NOMEM; |
| 36351 | } |
| 36352 | nByte = osMultiByteToWideChar(CP_UTF8, 0, zRelative, -1, |
| 36353 | zWideFilename, nByte); |
| 36354 | if( nByte==0 ){ |
| 36355 | sqlite3_free(zWideFilename); |
| 36356 | return SQLITE_IOERR_NOMEM; |
| 36357 | } |
| 36358 | finished: |
| 36359 | zConverted = zWideFilename; |
| 36360 | }else{ |
| 36361 | zConverted = sqlite3_win32_utf8_to_mbcs(zRelative); |
| 36362 | if( zConverted==0 ){ |
| 36363 | return SQLITE_IOERR_NOMEM; |
| 36364 | } |
| 36365 | } |
| 36366 | |
| 36367 | if( osIsNT() ){ |
| 36368 | LPWSTR zTemp; |
| 36369 | nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); |
| 36370 | if( nByte==0 ){ |
| 36371 | sqlite3_free(zConverted); |
| @@ -38479,10 +38451,11 @@ | |
| 38479 | unsigned int nPinned; |
| 38480 | PCache1 *pCache = (PCache1 *)p; |
| 38481 | PGroup *pGroup; |
| 38482 | PgHdr1 *pPage = 0; |
| 38483 | |
| 38484 | assert( pCache->bPurgeable || createFlag!=1 ); |
| 38485 | assert( pCache->bPurgeable || pCache->nMin==0 ); |
| 38486 | assert( pCache->bPurgeable==0 || pCache->nMin==10 ); |
| 38487 | assert( pCache->nMin==0 || pCache->bPurgeable ); |
| 38488 | pcache1EnterMutex(pGroup = pCache->pGroup); |
| @@ -38584,11 +38557,11 @@ | |
| 38584 | fetch_out: |
| 38585 | if( pPage && iKey>pCache->iMaxKey ){ |
| 38586 | pCache->iMaxKey = iKey; |
| 38587 | } |
| 38588 | pcache1LeaveMutex(pGroup); |
| 38589 | return &pPage->page; |
| 38590 | } |
| 38591 | |
| 38592 | |
| 38593 | /* |
| 38594 | ** Implementation of the sqlite3_pcache.xUnpin method. |
| @@ -41124,11 +41097,11 @@ | |
| 41124 | ** Find a page in the hash table given its page number. Return |
| 41125 | ** a pointer to the page or NULL if the requested page is not |
| 41126 | ** already in memory. |
| 41127 | */ |
| 41128 | static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){ |
| 41129 | PgHdr *p; /* Return value */ |
| 41130 | |
| 41131 | /* It is not possible for a call to PcacheFetch() with createFlag==0 to |
| 41132 | ** fail, since no attempt to allocate dynamic memory will be made. |
| 41133 | */ |
| 41134 | (void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &p); |
| @@ -60551,11 +60524,11 @@ | |
| 60551 | #endif /* SQLITE_DEBUG */ |
| 60552 | |
| 60553 | /* |
| 60554 | ** Size of struct Mem not including the Mem.zMalloc member. |
| 60555 | */ |
| 60556 | #define MEMCELLSIZE (size_t)(&(((Mem *)0)->zMalloc)) |
| 60557 | |
| 60558 | /* |
| 60559 | ** Make an shallow copy of pFrom into pTo. Prior contents of |
| 60560 | ** pTo are freed. The pFrom->z field is not duplicated. If |
| 60561 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| @@ -63955,12 +63928,13 @@ | |
| 63955 | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ |
| 63956 | AuxData **pp = &pVdbe->pAuxData; |
| 63957 | while( *pp ){ |
| 63958 | AuxData *pAux = *pp; |
| 63959 | if( (iOp<0) |
| 63960 | || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg)))) |
| 63961 | ){ |
| 63962 | if( pAux->xDelete ){ |
| 63963 | pAux->xDelete(pAux->pAux); |
| 63964 | } |
| 63965 | *pp = pAux->pNext; |
| 63966 | sqlite3DbFree(pVdbe->db, pAux); |
| @@ -64271,10 +64245,13 @@ | |
| 64271 | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet( |
| 64272 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 64273 | u32 serial_type, /* Serial type to deserialize */ |
| 64274 | Mem *pMem /* Memory cell to write value into */ |
| 64275 | ){ |
| 64276 | switch( serial_type ){ |
| 64277 | case 10: /* Reserved for future use */ |
| 64278 | case 11: /* Reserved for future use */ |
| 64279 | case 0: { /* NULL */ |
| 64280 | pMem->flags = MEM_Null; |
| @@ -64284,36 +64261,37 @@ | |
| 64284 | pMem->u.i = (signed char)buf[0]; |
| 64285 | pMem->flags = MEM_Int; |
| 64286 | return 1; |
| 64287 | } |
| 64288 | case 2: { /* 2-byte signed integer */ |
| 64289 | pMem->u.i = (((signed char)buf[0])<<8) | buf[1]; |
| 64290 | pMem->flags = MEM_Int; |
| 64291 | return 2; |
| 64292 | } |
| 64293 | case 3: { /* 3-byte signed integer */ |
| 64294 | pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2]; |
| 64295 | pMem->flags = MEM_Int; |
| 64296 | return 3; |
| 64297 | } |
| 64298 | case 4: { /* 4-byte signed integer */ |
| 64299 | pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; |
| 64300 | pMem->flags = MEM_Int; |
| 64301 | return 4; |
| 64302 | } |
| 64303 | case 5: { /* 6-byte signed integer */ |
| 64304 | u64 x = (((signed char)buf[0])<<8) | buf[1]; |
| 64305 | u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; |
| 64306 | x = (x<<32) | y; |
| 64307 | pMem->u.i = *(i64*)&x; |
| 64308 | pMem->flags = MEM_Int; |
| 64309 | return 6; |
| 64310 | } |
| 64311 | case 6: /* 8-byte signed integer */ |
| 64312 | case 7: { /* IEEE floating point */ |
| 64313 | u64 x; |
| 64314 | u32 y; |
| 64315 | #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) |
| 64316 | /* Verify that integers and floating point values use the same |
| 64317 | ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is |
| 64318 | ** defined that 64-bit floating point values really are mixed |
| 64319 | ** endian. |
| @@ -64322,13 +64300,12 @@ | |
| 64322 | static const double r1 = 1.0; |
| 64323 | u64 t2 = t1; |
| 64324 | swapMixedEndianFloat(t2); |
| 64325 | assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); |
| 64326 | #endif |
| 64327 | |
| 64328 | x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; |
| 64329 | y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; |
| 64330 | x = (x<<32) | y; |
| 64331 | if( serial_type==6 ){ |
| 64332 | pMem->u.i = *(i64*)&x; |
| 64333 | pMem->flags = MEM_Int; |
| 64334 | }else{ |
| @@ -72653,11 +72630,11 @@ | |
| 72653 | #ifdef SQLITE_USE_FCNTL_TRACE |
| 72654 | zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 72655 | if( zTrace ){ |
| 72656 | int i; |
| 72657 | for(i=0; i<db->nDb; i++){ |
| 72658 | if( ((1<<i) & p->btreeMask)==0 ) continue; |
| 72659 | sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace); |
| 72660 | } |
| 72661 | } |
| 72662 | #endif /* SQLITE_USE_FCNTL_TRACE */ |
| 72663 | #ifdef SQLITE_DEBUG |
| @@ -77499,10 +77476,11 @@ | |
| 77499 | pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; |
| 77500 | pNew->pRightmost = 0; |
| 77501 | pNew->addrOpenEphm[0] = -1; |
| 77502 | pNew->addrOpenEphm[1] = -1; |
| 77503 | pNew->addrOpenEphm[2] = -1; |
| 77504 | pNew->pWith = withDup(db, p->pWith); |
| 77505 | return pNew; |
| 77506 | } |
| 77507 | #else |
| 77508 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ |
| @@ -79120,11 +79098,11 @@ | |
| 79120 | ExprList *pFarg; /* List of function arguments */ |
| 79121 | int nFarg; /* Number of function arguments */ |
| 79122 | FuncDef *pDef; /* The function definition object */ |
| 79123 | int nId; /* Length of the function name in bytes */ |
| 79124 | const char *zId; /* The function name */ |
| 79125 | int constMask = 0; /* Mask of function arguments that are constant */ |
| 79126 | int i; /* Loop counter */ |
| 79127 | u8 enc = ENC(db); /* The text encoding used by this database */ |
| 79128 | CollSeq *pColl = 0; /* A collating sequence */ |
| 79129 | |
| 79130 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| @@ -79171,11 +79149,12 @@ | |
| 79171 | break; |
| 79172 | } |
| 79173 | |
| 79174 | for(i=0; i<nFarg; i++){ |
| 79175 | if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){ |
| 79176 | constMask |= (1<<i); |
| 79177 | } |
| 79178 | if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){ |
| 79179 | pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr); |
| 79180 | } |
| 79181 | } |
| @@ -89527,11 +89506,13 @@ | |
| 89527 | |
| 89528 | /* Populate the OLD.* pseudo-table register array. These values will be |
| 89529 | ** used by any BEFORE and AFTER triggers that exist. */ |
| 89530 | sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); |
| 89531 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 89532 | if( mask==0xffffffff || mask&(1<<iCol) ){ |
| 89533 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1); |
| 89534 | } |
| 89535 | } |
| 89536 | |
| 89537 | /* Invoke BEFORE DELETE trigger programs. */ |
| @@ -89847,11 +89828,11 @@ | |
| 89847 | UNUSED_PARAMETER(argc); |
| 89848 | switch( sqlite3_value_type(argv[0]) ){ |
| 89849 | case SQLITE_INTEGER: { |
| 89850 | i64 iVal = sqlite3_value_int64(argv[0]); |
| 89851 | if( iVal<0 ){ |
| 89852 | if( (iVal<<1)==0 ){ |
| 89853 | /* IMP: R-31676-45509 If X is the integer -9223372036854775808 |
| 89854 | ** then abs(X) throws an integer overflow error since there is no |
| 89855 | ** equivalent positive 64-bit two complement value. */ |
| 89856 | sqlite3_result_error(context, "integer overflow", -1); |
| 89857 | return; |
| @@ -100310,10 +100291,11 @@ | |
| 100310 | ** on a second ephemeral index that holds all values every previously |
| 100311 | ** added to the queue. Only add this new value if it has never before |
| 100312 | ** been added */ |
| 100313 | addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0); |
| 100314 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3); |
| 100315 | } |
| 100316 | for(i=0; i<nKey; i++){ |
| 100317 | sqlite3VdbeAddOp2(v, OP_SCopy, |
| 100318 | regResult + pSO->a[i].u.x.iOrderByCol - 1, |
| 100319 | r2+i); |
| @@ -101220,11 +101202,48 @@ | |
| 101220 | if( pRet==0 && iCol<p->pEList->nExpr ){ |
| 101221 | pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr); |
| 101222 | } |
| 101223 | return pRet; |
| 101224 | } |
| 101225 | #endif /* SQLITE_OMIT_COMPOUND_SELECT */ |
| 101226 | |
| 101227 | #ifndef SQLITE_OMIT_CTE |
| 101228 | /* |
| 101229 | ** This routine generates VDBE code to compute the content of a WITH RECURSIVE |
| 101230 | ** query of the form: |
| @@ -101294,23 +101313,20 @@ | |
| 101294 | pOffset = p->pOffset; |
| 101295 | regLimit = p->iLimit; |
| 101296 | regOffset = p->iOffset; |
| 101297 | p->pLimit = p->pOffset = 0; |
| 101298 | p->iLimit = p->iOffset = 0; |
| 101299 | |
| 101300 | /* Locate the cursor number of the Current table */ |
| 101301 | for(i=0; ALWAYS(i<pSrc->nSrc); i++){ |
| 101302 | if( pSrc->a[i].isRecursive ){ |
| 101303 | iCurrent = pSrc->a[i].iCursor; |
| 101304 | break; |
| 101305 | } |
| 101306 | } |
| 101307 | |
| 101308 | /* Detach the ORDER BY clause from the compound SELECT */ |
| 101309 | pOrderBy = p->pOrderBy; |
| 101310 | p->pOrderBy = 0; |
| 101311 | |
| 101312 | /* Allocate cursors numbers for Queue and Distinct. The cursor number for |
| 101313 | ** the Distinct table must be exactly one greater than Queue in order |
| 101314 | ** for the SRT_DistTable and SRT_DistQueue destinations to work. */ |
| 101315 | iQueue = pParse->nTab++; |
| 101316 | if( p->op==TK_UNION ){ |
| @@ -101323,11 +101339,11 @@ | |
| 101323 | |
| 101324 | /* Allocate cursors for Current, Queue, and Distinct. */ |
| 101325 | regCurrent = ++pParse->nMem; |
| 101326 | sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol); |
| 101327 | if( pOrderBy ){ |
| 101328 | KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pOrderBy, 1); |
| 101329 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0, |
| 101330 | (char*)pKeyInfo, P4_KEYINFO); |
| 101331 | destQueue.pOrderBy = pOrderBy; |
| 101332 | }else{ |
| 101333 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol); |
| @@ -101335,10 +101351,13 @@ | |
| 101335 | VdbeComment((v, "Queue table")); |
| 101336 | if( iDistinct ){ |
| 101337 | p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0); |
| 101338 | p->selFlags |= SF_UsesEphemeral; |
| 101339 | } |
| 101340 | |
| 101341 | /* Store the results of the setup-query in Queue. */ |
| 101342 | rc = sqlite3Select(pParse, pSetup, &destQueue); |
| 101343 | if( rc ) goto end_of_recursive_query; |
| 101344 | |
| @@ -101378,21 +101397,20 @@ | |
| 101378 | p->pOrderBy = pOrderBy; |
| 101379 | p->pLimit = pLimit; |
| 101380 | p->pOffset = pOffset; |
| 101381 | return; |
| 101382 | } |
| 101383 | #endif |
| 101384 | |
| 101385 | /* Forward references */ |
| 101386 | static int multiSelectOrderBy( |
| 101387 | Parse *pParse, /* Parsing context */ |
| 101388 | Select *p, /* The right-most of SELECTs to be coded */ |
| 101389 | SelectDest *pDest /* What to do with query results */ |
| 101390 | ); |
| 101391 | |
| 101392 | |
| 101393 | #ifndef SQLITE_OMIT_COMPOUND_SELECT |
| 101394 | /* |
| 101395 | ** This routine is called to process a compound query form from |
| 101396 | ** two or more separate queries using UNION, UNION ALL, EXCEPT, or |
| 101397 | ** INTERSECT |
| 101398 | ** |
| @@ -102120,28 +102138,11 @@ | |
| 102120 | for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ |
| 102121 | assert( pItem->u.x.iOrderByCol>0 |
| 102122 | && pItem->u.x.iOrderByCol<=p->pEList->nExpr ); |
| 102123 | aPermute[i] = pItem->u.x.iOrderByCol - 1; |
| 102124 | } |
| 102125 | pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy, 1); |
| 102126 | if( pKeyMerge ){ |
| 102127 | for(i=0; i<nOrderBy; i++){ |
| 102128 | CollSeq *pColl; |
| 102129 | Expr *pTerm = pOrderBy->a[i].pExpr; |
| 102130 | if( pTerm->flags & EP_Collate ){ |
| 102131 | pColl = sqlite3ExprCollSeq(pParse, pTerm); |
| 102132 | }else{ |
| 102133 | pColl = multiSelectCollSeq(pParse, p, aPermute[i]); |
| 102134 | if( pColl==0 ) pColl = db->pDfltColl; |
| 102135 | pOrderBy->a[i].pExpr = |
| 102136 | sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); |
| 102137 | } |
| 102138 | assert( sqlite3KeyInfoIsWriteable(pKeyMerge) ); |
| 102139 | pKeyMerge->aColl[i] = pColl; |
| 102140 | pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder; |
| 102141 | } |
| 102142 | } |
| 102143 | }else{ |
| 102144 | pKeyMerge = 0; |
| 102145 | } |
| 102146 | |
| 102147 | /* Reattach the ORDER BY clause to the query. |
| @@ -106614,13 +106615,14 @@ | |
| 106614 | oldmask |= sqlite3TriggerColmask(pParse, |
| 106615 | pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError |
| 106616 | ); |
| 106617 | for(i=0; i<pTab->nCol; i++){ |
| 106618 | if( oldmask==0xffffffff |
| 106619 | || (i<32 && (oldmask & (1<<i))) |
| 106620 | || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 |
| 106621 | ){ |
| 106622 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); |
| 106623 | }else{ |
| 106624 | sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); |
| 106625 | } |
| 106626 | } |
| @@ -106651,11 +106653,11 @@ | |
| 106651 | sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); |
| 106652 | }else{ |
| 106653 | j = aXRef[i]; |
| 106654 | if( j>=0 ){ |
| 106655 | sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i); |
| 106656 | }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){ |
| 106657 | /* This branch loads the value of a column that will not be changed |
| 106658 | ** into a register. This is done if there are no BEFORE triggers, or |
| 106659 | ** if there are one or more BEFORE triggers that use this value via |
| 106660 | ** a new.* reference in a trigger program. |
| 106661 | */ |
| @@ -112160,11 +112162,13 @@ | |
| 112160 | int iTerm; |
| 112161 | for(iTerm=0; iTerm<pWC->nTerm; iTerm++){ |
| 112162 | Expr *pExpr = pWC->a[iTerm].pExpr; |
| 112163 | if( &pWC->a[iTerm] == pTerm ) continue; |
| 112164 | if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; |
| 112165 | if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue; |
| 112166 | if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; |
| 112167 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 112168 | pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr); |
| 112169 | } |
| 112170 | if( pAndExpr ){ |
| @@ -122726,11 +122730,11 @@ | |
| 122726 | ** database files might have arbitrary corruption. Setting the flag during |
| 122727 | ** testing causes certain assert() statements in the code to be activated |
| 122728 | ** that demonstrat invariants on well-formed database files. |
| 122729 | */ |
| 122730 | case SQLITE_TESTCTRL_NEVER_CORRUPT: { |
| 122731 | sqlite3Config.neverCorrupt = va_arg(ap, int); |
| 122732 | break; |
| 122733 | } |
| 122734 | |
| 122735 | } |
| 122736 | va_end(ap); |
| @@ -131724,17 +131728,17 @@ | |
| 131724 | /* |
| 131725 | ** Hash and comparison functions when the mode is FTS3_HASH_STRING |
| 131726 | */ |
| 131727 | static int fts3StrHash(const void *pKey, int nKey){ |
| 131728 | const char *z = (const char *)pKey; |
| 131729 | int h = 0; |
| 131730 | if( nKey<=0 ) nKey = (int) strlen(z); |
| 131731 | while( nKey > 0 ){ |
| 131732 | h = (h<<3) ^ h ^ *z++; |
| 131733 | nKey--; |
| 131734 | } |
| 131735 | return h & 0x7fffffff; |
| 131736 | } |
| 131737 | static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ |
| 131738 | if( n1!=n2 ) return 1; |
| 131739 | return strncmp((const char*)pKey1,(const char*)pKey2,n1); |
| 131740 | } |
| 131741 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.8.3.1. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -133,13 +133,13 @@ | |
| 133 | ** |
| 134 | ** See also: [sqlite3_libversion()], |
| 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | */ |
| 138 | #define SQLITE_VERSION "3.8.3.1" |
| 139 | #define SQLITE_VERSION_NUMBER 3008003 |
| 140 | #define SQLITE_SOURCE_ID "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e" |
| 141 | |
| 142 | /* |
| 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | ** |
| @@ -11303,10 +11303,11 @@ | |
| 11303 | |
| 11304 | /* |
| 11305 | ** A bit in a Bitmask |
| 11306 | */ |
| 11307 | #define MASKBIT(n) (((Bitmask)1)<<(n)) |
| 11308 | #define MASKBIT32(n) (((unsigned int)1)<<(n)) |
| 11309 | |
| 11310 | /* |
| 11311 | ** The following structure describes the FROM clause of a SELECT statement. |
| 11312 | ** Each table or subquery in the FROM clause is a separate element of |
| 11313 | ** the SrcList.a[] array. |
| @@ -22605,11 +22606,12 @@ | |
| 22606 | |
| 22607 | /* |
| 22608 | ** Read or write a four-byte big-endian integer value. |
| 22609 | */ |
| 22610 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 22611 | testcase( p[0]&0x80 ); |
| 22612 | return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; |
| 22613 | } |
| 22614 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 22615 | p[0] = (u8)(v>>24); |
| 22616 | p[1] = (u8)(v>>16); |
| 22617 | p[2] = (u8)(v>>8); |
| @@ -22946,11 +22948,11 @@ | |
| 22948 | |
| 22949 | /* |
| 22950 | ** The hashing function. |
| 22951 | */ |
| 22952 | static unsigned int strHash(const char *z, int nKey){ |
| 22953 | unsigned int h = 0; |
| 22954 | assert( nKey>=0 ); |
| 22955 | while( nKey > 0 ){ |
| 22956 | h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; |
| 22957 | nKey--; |
| 22958 | } |
| @@ -27650,11 +27652,11 @@ | |
| 27652 | |
| 27653 | /* Update the global lock state and do debug tracing */ |
| 27654 | #ifdef SQLITE_DEBUG |
| 27655 | { u16 mask; |
| 27656 | OSTRACE(("SHM-LOCK ")); |
| 27657 | mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst); |
| 27658 | if( rc==SQLITE_OK ){ |
| 27659 | if( lockType==F_UNLCK ){ |
| 27660 | OSTRACE(("unlock %d ok", ofst)); |
| 27661 | pShmNode->exclMask &= ~mask; |
| 27662 | pShmNode->sharedMask &= ~mask; |
| @@ -35374,11 +35376,34 @@ | |
| 35376 | ** function. |
| 35377 | */ |
| 35378 | static void *winConvertFromUtf8Filename(const char *zFilename){ |
| 35379 | void *zConverted = 0; |
| 35380 | if( osIsNT() ){ |
| 35381 | int nChar; |
| 35382 | LPWSTR zWideFilename; |
| 35383 | |
| 35384 | nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); |
| 35385 | if( nChar==0 ){ |
| 35386 | return 0; |
| 35387 | } |
| 35388 | zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR)+8 ); |
| 35389 | if( zWideFilename==0 ){ |
| 35390 | return 0; |
| 35391 | } |
| 35392 | nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, |
| 35393 | zWideFilename+4, nChar); |
| 35394 | if( nChar==0 ){ |
| 35395 | sqlite3_free(zWideFilename); |
| 35396 | return 0; |
| 35397 | }else if( nChar>SQLITE_WIN32_MAX_PATH_CHARS |
| 35398 | && winIsDriveLetterAndColon(zFilename) |
| 35399 | && zFilename[2] == '\\' ){ |
| 35400 | memcpy(zWideFilename, L"\\\\?\\", 8); |
| 35401 | }else{ |
| 35402 | memmove(zWideFilename, zWideFilename+4, nChar*sizeof(WCHAR)); |
| 35403 | } |
| 35404 | zConverted = zWideFilename; |
| 35405 | } |
| 35406 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 35407 | else{ |
| 35408 | zConverted = sqlite3_win32_utf8_to_mbcs(zFilename); |
| 35409 | } |
| @@ -36305,67 +36330,14 @@ | |
| 36330 | */ |
| 36331 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 36332 | sqlite3_data_directory, winGetDirSep(), zRelative); |
| 36333 | return SQLITE_OK; |
| 36334 | } |
| 36335 | zConverted = winConvertFromUtf8Filename(zRelative); |
| 36336 | if( zConverted==0 ){ |
| 36337 | return SQLITE_IOERR_NOMEM; |
| 36338 | } |
| 36339 | if( osIsNT() ){ |
| 36340 | LPWSTR zTemp; |
| 36341 | nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); |
| 36342 | if( nByte==0 ){ |
| 36343 | sqlite3_free(zConverted); |
| @@ -38479,10 +38451,11 @@ | |
| 38451 | unsigned int nPinned; |
| 38452 | PCache1 *pCache = (PCache1 *)p; |
| 38453 | PGroup *pGroup; |
| 38454 | PgHdr1 *pPage = 0; |
| 38455 | |
| 38456 | assert( offsetof(PgHdr1,page)==0 ); |
| 38457 | assert( pCache->bPurgeable || createFlag!=1 ); |
| 38458 | assert( pCache->bPurgeable || pCache->nMin==0 ); |
| 38459 | assert( pCache->bPurgeable==0 || pCache->nMin==10 ); |
| 38460 | assert( pCache->nMin==0 || pCache->bPurgeable ); |
| 38461 | pcache1EnterMutex(pGroup = pCache->pGroup); |
| @@ -38584,11 +38557,11 @@ | |
| 38557 | fetch_out: |
| 38558 | if( pPage && iKey>pCache->iMaxKey ){ |
| 38559 | pCache->iMaxKey = iKey; |
| 38560 | } |
| 38561 | pcache1LeaveMutex(pGroup); |
| 38562 | return (sqlite3_pcache_page*)pPage; |
| 38563 | } |
| 38564 | |
| 38565 | |
| 38566 | /* |
| 38567 | ** Implementation of the sqlite3_pcache.xUnpin method. |
| @@ -41124,11 +41097,11 @@ | |
| 41097 | ** Find a page in the hash table given its page number. Return |
| 41098 | ** a pointer to the page or NULL if the requested page is not |
| 41099 | ** already in memory. |
| 41100 | */ |
| 41101 | static PgHdr *pager_lookup(Pager *pPager, Pgno pgno){ |
| 41102 | PgHdr *p = 0; /* Return value */ |
| 41103 | |
| 41104 | /* It is not possible for a call to PcacheFetch() with createFlag==0 to |
| 41105 | ** fail, since no attempt to allocate dynamic memory will be made. |
| 41106 | */ |
| 41107 | (void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &p); |
| @@ -60551,11 +60524,11 @@ | |
| 60524 | #endif /* SQLITE_DEBUG */ |
| 60525 | |
| 60526 | /* |
| 60527 | ** Size of struct Mem not including the Mem.zMalloc member. |
| 60528 | */ |
| 60529 | #define MEMCELLSIZE offsetof(Mem,zMalloc) |
| 60530 | |
| 60531 | /* |
| 60532 | ** Make an shallow copy of pFrom into pTo. Prior contents of |
| 60533 | ** pTo are freed. The pFrom->z field is not duplicated. If |
| 60534 | ** pFrom->z is used, then pTo->z points to the same thing as pFrom->z |
| @@ -63955,12 +63928,13 @@ | |
| 63928 | SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ |
| 63929 | AuxData **pp = &pVdbe->pAuxData; |
| 63930 | while( *pp ){ |
| 63931 | AuxData *pAux = *pp; |
| 63932 | if( (iOp<0) |
| 63933 | || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg)))) |
| 63934 | ){ |
| 63935 | testcase( pAux->iArg==31 ); |
| 63936 | if( pAux->xDelete ){ |
| 63937 | pAux->xDelete(pAux->pAux); |
| 63938 | } |
| 63939 | *pp = pAux->pNext; |
| 63940 | sqlite3DbFree(pVdbe->db, pAux); |
| @@ -64271,10 +64245,13 @@ | |
| 64245 | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet( |
| 64246 | const unsigned char *buf, /* Buffer to deserialize from */ |
| 64247 | u32 serial_type, /* Serial type to deserialize */ |
| 64248 | Mem *pMem /* Memory cell to write value into */ |
| 64249 | ){ |
| 64250 | u64 x; |
| 64251 | u32 y; |
| 64252 | int i; |
| 64253 | switch( serial_type ){ |
| 64254 | case 10: /* Reserved for future use */ |
| 64255 | case 11: /* Reserved for future use */ |
| 64256 | case 0: { /* NULL */ |
| 64257 | pMem->flags = MEM_Null; |
| @@ -64284,36 +64261,37 @@ | |
| 64261 | pMem->u.i = (signed char)buf[0]; |
| 64262 | pMem->flags = MEM_Int; |
| 64263 | return 1; |
| 64264 | } |
| 64265 | case 2: { /* 2-byte signed integer */ |
| 64266 | i = 256*(signed char)buf[0] | buf[1]; |
| 64267 | pMem->u.i = (i64)i; |
| 64268 | pMem->flags = MEM_Int; |
| 64269 | return 2; |
| 64270 | } |
| 64271 | case 3: { /* 3-byte signed integer */ |
| 64272 | i = 65536*(signed char)buf[0] | (buf[1]<<8) | buf[2]; |
| 64273 | pMem->u.i = (i64)i; |
| 64274 | pMem->flags = MEM_Int; |
| 64275 | return 3; |
| 64276 | } |
| 64277 | case 4: { /* 4-byte signed integer */ |
| 64278 | y = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; |
| 64279 | pMem->u.i = (i64)*(int*)&y; |
| 64280 | pMem->flags = MEM_Int; |
| 64281 | return 4; |
| 64282 | } |
| 64283 | case 5: { /* 6-byte signed integer */ |
| 64284 | x = 256*(signed char)buf[0] + buf[1]; |
| 64285 | y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; |
| 64286 | x = (x<<32) | y; |
| 64287 | pMem->u.i = *(i64*)&x; |
| 64288 | pMem->flags = MEM_Int; |
| 64289 | return 6; |
| 64290 | } |
| 64291 | case 6: /* 8-byte signed integer */ |
| 64292 | case 7: { /* IEEE floating point */ |
| 64293 | #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) |
| 64294 | /* Verify that integers and floating point values use the same |
| 64295 | ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is |
| 64296 | ** defined that 64-bit floating point values really are mixed |
| 64297 | ** endian. |
| @@ -64322,13 +64300,12 @@ | |
| 64300 | static const double r1 = 1.0; |
| 64301 | u64 t2 = t1; |
| 64302 | swapMixedEndianFloat(t2); |
| 64303 | assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); |
| 64304 | #endif |
| 64305 | x = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; |
| 64306 | y = ((unsigned)buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; |
| 64307 | x = (x<<32) | y; |
| 64308 | if( serial_type==6 ){ |
| 64309 | pMem->u.i = *(i64*)&x; |
| 64310 | pMem->flags = MEM_Int; |
| 64311 | }else{ |
| @@ -72653,11 +72630,11 @@ | |
| 72630 | #ifdef SQLITE_USE_FCNTL_TRACE |
| 72631 | zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 72632 | if( zTrace ){ |
| 72633 | int i; |
| 72634 | for(i=0; i<db->nDb; i++){ |
| 72635 | if( MASKBIT(i) & p->btreeMask)==0 ) continue; |
| 72636 | sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace); |
| 72637 | } |
| 72638 | } |
| 72639 | #endif /* SQLITE_USE_FCNTL_TRACE */ |
| 72640 | #ifdef SQLITE_DEBUG |
| @@ -77499,10 +77476,11 @@ | |
| 77476 | pNew->selFlags = p->selFlags & ~SF_UsesEphemeral; |
| 77477 | pNew->pRightmost = 0; |
| 77478 | pNew->addrOpenEphm[0] = -1; |
| 77479 | pNew->addrOpenEphm[1] = -1; |
| 77480 | pNew->addrOpenEphm[2] = -1; |
| 77481 | pNew->nSelectRow = p->nSelectRow; |
| 77482 | pNew->pWith = withDup(db, p->pWith); |
| 77483 | return pNew; |
| 77484 | } |
| 77485 | #else |
| 77486 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ |
| @@ -79120,11 +79098,11 @@ | |
| 79098 | ExprList *pFarg; /* List of function arguments */ |
| 79099 | int nFarg; /* Number of function arguments */ |
| 79100 | FuncDef *pDef; /* The function definition object */ |
| 79101 | int nId; /* Length of the function name in bytes */ |
| 79102 | const char *zId; /* The function name */ |
| 79103 | u32 constMask = 0; /* Mask of function arguments that are constant */ |
| 79104 | int i; /* Loop counter */ |
| 79105 | u8 enc = ENC(db); /* The text encoding used by this database */ |
| 79106 | CollSeq *pColl = 0; /* A collating sequence */ |
| 79107 | |
| 79108 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| @@ -79171,11 +79149,12 @@ | |
| 79149 | break; |
| 79150 | } |
| 79151 | |
| 79152 | for(i=0; i<nFarg; i++){ |
| 79153 | if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){ |
| 79154 | testcase( i==31 ); |
| 79155 | constMask |= MASKBIT32(i); |
| 79156 | } |
| 79157 | if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){ |
| 79158 | pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr); |
| 79159 | } |
| 79160 | } |
| @@ -89527,11 +89506,13 @@ | |
| 89506 | |
| 89507 | /* Populate the OLD.* pseudo-table register array. These values will be |
| 89508 | ** used by any BEFORE and AFTER triggers that exist. */ |
| 89509 | sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); |
| 89510 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 89511 | testcase( mask!=0xffffffff && iCol==31 ); |
| 89512 | testcase( mask!=0xffffffff && iCol==32 ); |
| 89513 | if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){ |
| 89514 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1); |
| 89515 | } |
| 89516 | } |
| 89517 | |
| 89518 | /* Invoke BEFORE DELETE trigger programs. */ |
| @@ -89847,11 +89828,11 @@ | |
| 89828 | UNUSED_PARAMETER(argc); |
| 89829 | switch( sqlite3_value_type(argv[0]) ){ |
| 89830 | case SQLITE_INTEGER: { |
| 89831 | i64 iVal = sqlite3_value_int64(argv[0]); |
| 89832 | if( iVal<0 ){ |
| 89833 | if( iVal==SMALLEST_INT64 ){ |
| 89834 | /* IMP: R-31676-45509 If X is the integer -9223372036854775808 |
| 89835 | ** then abs(X) throws an integer overflow error since there is no |
| 89836 | ** equivalent positive 64-bit two complement value. */ |
| 89837 | sqlite3_result_error(context, "integer overflow", -1); |
| 89838 | return; |
| @@ -100310,10 +100291,11 @@ | |
| 100291 | ** on a second ephemeral index that holds all values every previously |
| 100292 | ** added to the queue. Only add this new value if it has never before |
| 100293 | ** been added */ |
| 100294 | addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, r3, 0); |
| 100295 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3); |
| 100296 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 100297 | } |
| 100298 | for(i=0; i<nKey; i++){ |
| 100299 | sqlite3VdbeAddOp2(v, OP_SCopy, |
| 100300 | regResult + pSO->a[i].u.x.iOrderByCol - 1, |
| 100301 | r2+i); |
| @@ -101220,11 +101202,48 @@ | |
| 101202 | if( pRet==0 && iCol<p->pEList->nExpr ){ |
| 101203 | pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr); |
| 101204 | } |
| 101205 | return pRet; |
| 101206 | } |
| 101207 | |
| 101208 | /* |
| 101209 | ** The select statement passed as the second parameter is a compound SELECT |
| 101210 | ** with an ORDER BY clause. This function allocates and returns a KeyInfo |
| 101211 | ** structure suitable for implementing the ORDER BY. |
| 101212 | ** |
| 101213 | ** Space to hold the KeyInfo structure is obtained from malloc. The calling |
| 101214 | ** function is responsible for ensuring that this structure is eventually |
| 101215 | ** freed. |
| 101216 | */ |
| 101217 | static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ |
| 101218 | ExprList *pOrderBy = p->pOrderBy; |
| 101219 | int nOrderBy = p->pOrderBy->nExpr; |
| 101220 | sqlite3 *db = pParse->db; |
| 101221 | KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1); |
| 101222 | if( pRet ){ |
| 101223 | int i; |
| 101224 | for(i=0; i<nOrderBy; i++){ |
| 101225 | struct ExprList_item *pItem = &pOrderBy->a[i]; |
| 101226 | Expr *pTerm = pItem->pExpr; |
| 101227 | CollSeq *pColl; |
| 101228 | |
| 101229 | if( pTerm->flags & EP_Collate ){ |
| 101230 | pColl = sqlite3ExprCollSeq(pParse, pTerm); |
| 101231 | }else{ |
| 101232 | pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1); |
| 101233 | if( pColl==0 ) pColl = db->pDfltColl; |
| 101234 | pOrderBy->a[i].pExpr = |
| 101235 | sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); |
| 101236 | } |
| 101237 | assert( sqlite3KeyInfoIsWriteable(pRet) ); |
| 101238 | pRet->aColl[i] = pColl; |
| 101239 | pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder; |
| 101240 | } |
| 101241 | } |
| 101242 | |
| 101243 | return pRet; |
| 101244 | } |
| 101245 | |
| 101246 | #ifndef SQLITE_OMIT_CTE |
| 101247 | /* |
| 101248 | ** This routine generates VDBE code to compute the content of a WITH RECURSIVE |
| 101249 | ** query of the form: |
| @@ -101294,23 +101313,20 @@ | |
| 101313 | pOffset = p->pOffset; |
| 101314 | regLimit = p->iLimit; |
| 101315 | regOffset = p->iOffset; |
| 101316 | p->pLimit = p->pOffset = 0; |
| 101317 | p->iLimit = p->iOffset = 0; |
| 101318 | pOrderBy = p->pOrderBy; |
| 101319 | |
| 101320 | /* Locate the cursor number of the Current table */ |
| 101321 | for(i=0; ALWAYS(i<pSrc->nSrc); i++){ |
| 101322 | if( pSrc->a[i].isRecursive ){ |
| 101323 | iCurrent = pSrc->a[i].iCursor; |
| 101324 | break; |
| 101325 | } |
| 101326 | } |
| 101327 | |
| 101328 | /* Allocate cursors numbers for Queue and Distinct. The cursor number for |
| 101329 | ** the Distinct table must be exactly one greater than Queue in order |
| 101330 | ** for the SRT_DistTable and SRT_DistQueue destinations to work. */ |
| 101331 | iQueue = pParse->nTab++; |
| 101332 | if( p->op==TK_UNION ){ |
| @@ -101323,11 +101339,11 @@ | |
| 101339 | |
| 101340 | /* Allocate cursors for Current, Queue, and Distinct. */ |
| 101341 | regCurrent = ++pParse->nMem; |
| 101342 | sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol); |
| 101343 | if( pOrderBy ){ |
| 101344 | KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1); |
| 101345 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0, |
| 101346 | (char*)pKeyInfo, P4_KEYINFO); |
| 101347 | destQueue.pOrderBy = pOrderBy; |
| 101348 | }else{ |
| 101349 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol); |
| @@ -101335,10 +101351,13 @@ | |
| 101351 | VdbeComment((v, "Queue table")); |
| 101352 | if( iDistinct ){ |
| 101353 | p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0); |
| 101354 | p->selFlags |= SF_UsesEphemeral; |
| 101355 | } |
| 101356 | |
| 101357 | /* Detach the ORDER BY clause from the compound SELECT */ |
| 101358 | p->pOrderBy = 0; |
| 101359 | |
| 101360 | /* Store the results of the setup-query in Queue. */ |
| 101361 | rc = sqlite3Select(pParse, pSetup, &destQueue); |
| 101362 | if( rc ) goto end_of_recursive_query; |
| 101363 | |
| @@ -101378,21 +101397,20 @@ | |
| 101397 | p->pOrderBy = pOrderBy; |
| 101398 | p->pLimit = pLimit; |
| 101399 | p->pOffset = pOffset; |
| 101400 | return; |
| 101401 | } |
| 101402 | #endif /* SQLITE_OMIT_CTE */ |
| 101403 | |
| 101404 | /* Forward references */ |
| 101405 | static int multiSelectOrderBy( |
| 101406 | Parse *pParse, /* Parsing context */ |
| 101407 | Select *p, /* The right-most of SELECTs to be coded */ |
| 101408 | SelectDest *pDest /* What to do with query results */ |
| 101409 | ); |
| 101410 | |
| 101411 | |
| 101412 | /* |
| 101413 | ** This routine is called to process a compound query form from |
| 101414 | ** two or more separate queries using UNION, UNION ALL, EXCEPT, or |
| 101415 | ** INTERSECT |
| 101416 | ** |
| @@ -102120,28 +102138,11 @@ | |
| 102138 | for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ |
| 102139 | assert( pItem->u.x.iOrderByCol>0 |
| 102140 | && pItem->u.x.iOrderByCol<=p->pEList->nExpr ); |
| 102141 | aPermute[i] = pItem->u.x.iOrderByCol - 1; |
| 102142 | } |
| 102143 | pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1); |
| 102144 | }else{ |
| 102145 | pKeyMerge = 0; |
| 102146 | } |
| 102147 | |
| 102148 | /* Reattach the ORDER BY clause to the query. |
| @@ -106614,13 +106615,14 @@ | |
| 106615 | oldmask |= sqlite3TriggerColmask(pParse, |
| 106616 | pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError |
| 106617 | ); |
| 106618 | for(i=0; i<pTab->nCol; i++){ |
| 106619 | if( oldmask==0xffffffff |
| 106620 | || (i<32 && (oldmask & MASKBIT32(i))!=0) |
| 106621 | || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 |
| 106622 | ){ |
| 106623 | testcase( oldmask!=0xffffffff && i==31 ); |
| 106624 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); |
| 106625 | }else{ |
| 106626 | sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); |
| 106627 | } |
| 106628 | } |
| @@ -106651,11 +106653,11 @@ | |
| 106653 | sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); |
| 106654 | }else{ |
| 106655 | j = aXRef[i]; |
| 106656 | if( j>=0 ){ |
| 106657 | sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i); |
| 106658 | }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){ |
| 106659 | /* This branch loads the value of a column that will not be changed |
| 106660 | ** into a register. This is done if there are no BEFORE triggers, or |
| 106661 | ** if there are one or more BEFORE triggers that use this value via |
| 106662 | ** a new.* reference in a trigger program. |
| 106663 | */ |
| @@ -112160,11 +112162,13 @@ | |
| 112162 | int iTerm; |
| 112163 | for(iTerm=0; iTerm<pWC->nTerm; iTerm++){ |
| 112164 | Expr *pExpr = pWC->a[iTerm].pExpr; |
| 112165 | if( &pWC->a[iTerm] == pTerm ) continue; |
| 112166 | if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; |
| 112167 | testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO ); |
| 112168 | testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL ); |
| 112169 | if( pWC->a[iTerm].wtFlags & (TERM_ORINFO|TERM_VIRTUAL) ) continue; |
| 112170 | if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; |
| 112171 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 112172 | pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr); |
| 112173 | } |
| 112174 | if( pAndExpr ){ |
| @@ -122726,11 +122730,11 @@ | |
| 122730 | ** database files might have arbitrary corruption. Setting the flag during |
| 122731 | ** testing causes certain assert() statements in the code to be activated |
| 122732 | ** that demonstrat invariants on well-formed database files. |
| 122733 | */ |
| 122734 | case SQLITE_TESTCTRL_NEVER_CORRUPT: { |
| 122735 | sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int); |
| 122736 | break; |
| 122737 | } |
| 122738 | |
| 122739 | } |
| 122740 | va_end(ap); |
| @@ -131724,17 +131728,17 @@ | |
| 131728 | /* |
| 131729 | ** Hash and comparison functions when the mode is FTS3_HASH_STRING |
| 131730 | */ |
| 131731 | static int fts3StrHash(const void *pKey, int nKey){ |
| 131732 | const char *z = (const char *)pKey; |
| 131733 | unsigned h = 0; |
| 131734 | if( nKey<=0 ) nKey = (int) strlen(z); |
| 131735 | while( nKey > 0 ){ |
| 131736 | h = (h<<3) ^ h ^ *z++; |
| 131737 | nKey--; |
| 131738 | } |
| 131739 | return (int)(h & 0x7fffffff); |
| 131740 | } |
| 131741 | static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ |
| 131742 | if( n1!=n2 ) return 1; |
| 131743 | return strncmp((const char*)pKey1,(const char*)pKey2,n1); |
| 131744 | } |
| 131745 |
+2
-2
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -105,13 +105,13 @@ | ||
| 105 | 105 | ** |
| 106 | 106 | ** See also: [sqlite3_libversion()], |
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | -#define SQLITE_VERSION "3.8.3" | |
| 110 | +#define SQLITE_VERSION "3.8.3.1" | |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3008003 |
| 112 | -#define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc" | |
| 112 | +#define SQLITE_SOURCE_ID "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -105,13 +105,13 @@ | |
| 105 | ** |
| 106 | ** See also: [sqlite3_libversion()], |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.8.3" |
| 111 | #define SQLITE_VERSION_NUMBER 3008003 |
| 112 | #define SQLITE_SOURCE_ID "2014-01-22 18:31:27 dea2ca6a159d5dcfd8deceedf1c2a73fb4ac1cfc" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -105,13 +105,13 @@ | |
| 105 | ** |
| 106 | ** See also: [sqlite3_libversion()], |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.8.3.1" |
| 111 | #define SQLITE_VERSION_NUMBER 3008003 |
| 112 | #define SQLITE_SOURCE_ID "2014-02-11 14:52:19 ea3317a4803d71d88183b29f1d3086f46d68a00e" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
+1
-1
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -168,11 +168,11 @@ | ||
| 168 | 168 | blob_zero(&prompt); |
| 169 | 169 | #endif |
| 170 | 170 | blob_append(&prompt, |
| 171 | 171 | "\n" |
| 172 | 172 | "# Enter a description of what is being stashed. Lines beginning\n" |
| 173 | - "# with \"#\" are ignored. Stash comments are plain text except.\n" | |
| 173 | + "# with \"#\" are ignored. Stash comments are plain text except\n" | |
| 174 | 174 | "# newlines are not preserved.\n", |
| 175 | 175 | -1); |
| 176 | 176 | prompt_for_user_comment(&comment, &prompt); |
| 177 | 177 | blob_reset(&prompt); |
| 178 | 178 | zComment = blob_str(&comment); |
| 179 | 179 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -168,11 +168,11 @@ | |
| 168 | blob_zero(&prompt); |
| 169 | #endif |
| 170 | blob_append(&prompt, |
| 171 | "\n" |
| 172 | "# Enter a description of what is being stashed. Lines beginning\n" |
| 173 | "# with \"#\" are ignored. Stash comments are plain text except.\n" |
| 174 | "# newlines are not preserved.\n", |
| 175 | -1); |
| 176 | prompt_for_user_comment(&comment, &prompt); |
| 177 | blob_reset(&prompt); |
| 178 | zComment = blob_str(&comment); |
| 179 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -168,11 +168,11 @@ | |
| 168 | blob_zero(&prompt); |
| 169 | #endif |
| 170 | blob_append(&prompt, |
| 171 | "\n" |
| 172 | "# Enter a description of what is being stashed. Lines beginning\n" |
| 173 | "# with \"#\" are ignored. Stash comments are plain text except\n" |
| 174 | "# newlines are not preserved.\n", |
| 175 | -1); |
| 176 | prompt_for_user_comment(&comment, &prompt); |
| 177 | blob_reset(&prompt); |
| 178 | zComment = blob_str(&comment); |
| 179 |
+5
-9
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -163,12 +163,11 @@ | ||
| 163 | 163 | void style_resolve_href(void){ |
| 164 | 164 | int i; |
| 165 | 165 | int nDelay = db_get_int("auto-hyperlink-delay",10); |
| 166 | 166 | if( !g.perm.Hyperlink ) return; |
| 167 | 167 | if( nHref==0 && nFormAction==0 ) return; |
| 168 | - @ <script type="text/JavaScript"> | |
| 169 | - @ /* <![CDATA[ */ | |
| 168 | + @ <script> | |
| 170 | 169 | @ function setAllHrefs(){ |
| 171 | 170 | if( g.javascriptHyperlink ){ |
| 172 | 171 | for(i=0; i<nHref; i++){ |
| 173 | 172 | @ gebi("a%d(i+1)").href="%s(aHref[i])"; |
| 174 | 173 | } |
| @@ -192,11 +191,10 @@ | ||
| 192 | 191 | @ } |
| 193 | 192 | }else{ |
| 194 | 193 | /* Active hyperlinks right away */ |
| 195 | 194 | @ setTimeout("setAllHrefs();",%d(nDelay)); |
| 196 | 195 | } |
| 197 | - @ /* ]]> */ | |
| 198 | 196 | @ </script> |
| 199 | 197 | } |
| 200 | 198 | |
| 201 | 199 | /* |
| 202 | 200 | ** Add a new element to the submenu |
| @@ -794,10 +792,12 @@ | ||
| 794 | 792 | @ margin: 0 0 0 21px; |
| 795 | 793 | }, |
| 796 | 794 | { ".filetree li", |
| 797 | 795 | "tree-view lists items", |
| 798 | 796 | @ position: relative; |
| 797 | + @ margin: 0; | |
| 798 | + @ padding: 0; | |
| 799 | 799 | }, |
| 800 | 800 | { ".filetree li li:before", |
| 801 | 801 | "tree-view node lines", |
| 802 | 802 | @ content: ''; |
| 803 | 803 | @ position: absolute; |
| @@ -1156,11 +1156,11 @@ | ||
| 1156 | 1156 | @ vertical-align: top; |
| 1157 | 1157 | @ text-align: right; |
| 1158 | 1158 | @ padding: 0.2ex 2ex; |
| 1159 | 1159 | }, |
| 1160 | 1160 | { ".statistics-report-graph-line", |
| 1161 | - "for the /stats_report views", | |
| 1161 | + "for the /reports views", | |
| 1162 | 1162 | @ background-color: #446979; |
| 1163 | 1163 | }, |
| 1164 | 1164 | { ".statistics-report-table-events th", |
| 1165 | 1165 | "", |
| 1166 | 1166 | @ padding: 0 1em 0 1em; |
| @@ -1171,14 +1171,10 @@ | ||
| 1171 | 1171 | }, |
| 1172 | 1172 | { ".statistics-report-row-year", |
| 1173 | 1173 | "", |
| 1174 | 1174 | @ text-align: left; |
| 1175 | 1175 | }, |
| 1176 | - { ".statistics-report-graph-line", | |
| 1177 | - "for the /stats_report views", | |
| 1178 | - @ background-color: #446979; | |
| 1179 | - }, | |
| 1180 | 1176 | { ".statistics-report-week-number-label", |
| 1181 | 1177 | "for the /stats_report views", |
| 1182 | 1178 | @ text-align: right; |
| 1183 | 1179 | @ font-size: 0.8em; |
| 1184 | 1180 | }, |
| @@ -1264,11 +1260,11 @@ | ||
| 1264 | 1260 | void page_test_env(void){ |
| 1265 | 1261 | char c; |
| 1266 | 1262 | int i; |
| 1267 | 1263 | int showAll; |
| 1268 | 1264 | char zCap[30]; |
| 1269 | - static const char *azCgiVars[] = { | |
| 1265 | + static const char *const azCgiVars[] = { | |
| 1270 | 1266 | "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", |
| 1271 | 1267 | "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING", |
| 1272 | 1268 | "HTTP_ACCEPT_LANGUAGE", "HTTP_CONNECTION", "HTTP_HOST", |
| 1273 | 1269 | "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED", |
| 1274 | 1270 | "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT", "REQUEST_METHOD", |
| 1275 | 1271 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -163,12 +163,11 @@ | |
| 163 | void style_resolve_href(void){ |
| 164 | int i; |
| 165 | int nDelay = db_get_int("auto-hyperlink-delay",10); |
| 166 | if( !g.perm.Hyperlink ) return; |
| 167 | if( nHref==0 && nFormAction==0 ) return; |
| 168 | @ <script type="text/JavaScript"> |
| 169 | @ /* <![CDATA[ */ |
| 170 | @ function setAllHrefs(){ |
| 171 | if( g.javascriptHyperlink ){ |
| 172 | for(i=0; i<nHref; i++){ |
| 173 | @ gebi("a%d(i+1)").href="%s(aHref[i])"; |
| 174 | } |
| @@ -192,11 +191,10 @@ | |
| 192 | @ } |
| 193 | }else{ |
| 194 | /* Active hyperlinks right away */ |
| 195 | @ setTimeout("setAllHrefs();",%d(nDelay)); |
| 196 | } |
| 197 | @ /* ]]> */ |
| 198 | @ </script> |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | ** Add a new element to the submenu |
| @@ -794,10 +792,12 @@ | |
| 794 | @ margin: 0 0 0 21px; |
| 795 | }, |
| 796 | { ".filetree li", |
| 797 | "tree-view lists items", |
| 798 | @ position: relative; |
| 799 | }, |
| 800 | { ".filetree li li:before", |
| 801 | "tree-view node lines", |
| 802 | @ content: ''; |
| 803 | @ position: absolute; |
| @@ -1156,11 +1156,11 @@ | |
| 1156 | @ vertical-align: top; |
| 1157 | @ text-align: right; |
| 1158 | @ padding: 0.2ex 2ex; |
| 1159 | }, |
| 1160 | { ".statistics-report-graph-line", |
| 1161 | "for the /stats_report views", |
| 1162 | @ background-color: #446979; |
| 1163 | }, |
| 1164 | { ".statistics-report-table-events th", |
| 1165 | "", |
| 1166 | @ padding: 0 1em 0 1em; |
| @@ -1171,14 +1171,10 @@ | |
| 1171 | }, |
| 1172 | { ".statistics-report-row-year", |
| 1173 | "", |
| 1174 | @ text-align: left; |
| 1175 | }, |
| 1176 | { ".statistics-report-graph-line", |
| 1177 | "for the /stats_report views", |
| 1178 | @ background-color: #446979; |
| 1179 | }, |
| 1180 | { ".statistics-report-week-number-label", |
| 1181 | "for the /stats_report views", |
| 1182 | @ text-align: right; |
| 1183 | @ font-size: 0.8em; |
| 1184 | }, |
| @@ -1264,11 +1260,11 @@ | |
| 1264 | void page_test_env(void){ |
| 1265 | char c; |
| 1266 | int i; |
| 1267 | int showAll; |
| 1268 | char zCap[30]; |
| 1269 | static const char *azCgiVars[] = { |
| 1270 | "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", |
| 1271 | "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING", |
| 1272 | "HTTP_ACCEPT_LANGUAGE", "HTTP_CONNECTION", "HTTP_HOST", |
| 1273 | "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED", |
| 1274 | "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT", "REQUEST_METHOD", |
| 1275 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -163,12 +163,11 @@ | |
| 163 | void style_resolve_href(void){ |
| 164 | int i; |
| 165 | int nDelay = db_get_int("auto-hyperlink-delay",10); |
| 166 | if( !g.perm.Hyperlink ) return; |
| 167 | if( nHref==0 && nFormAction==0 ) return; |
| 168 | @ <script> |
| 169 | @ function setAllHrefs(){ |
| 170 | if( g.javascriptHyperlink ){ |
| 171 | for(i=0; i<nHref; i++){ |
| 172 | @ gebi("a%d(i+1)").href="%s(aHref[i])"; |
| 173 | } |
| @@ -192,11 +191,10 @@ | |
| 191 | @ } |
| 192 | }else{ |
| 193 | /* Active hyperlinks right away */ |
| 194 | @ setTimeout("setAllHrefs();",%d(nDelay)); |
| 195 | } |
| 196 | @ </script> |
| 197 | } |
| 198 | |
| 199 | /* |
| 200 | ** Add a new element to the submenu |
| @@ -794,10 +792,12 @@ | |
| 792 | @ margin: 0 0 0 21px; |
| 793 | }, |
| 794 | { ".filetree li", |
| 795 | "tree-view lists items", |
| 796 | @ position: relative; |
| 797 | @ margin: 0; |
| 798 | @ padding: 0; |
| 799 | }, |
| 800 | { ".filetree li li:before", |
| 801 | "tree-view node lines", |
| 802 | @ content: ''; |
| 803 | @ position: absolute; |
| @@ -1156,11 +1156,11 @@ | |
| 1156 | @ vertical-align: top; |
| 1157 | @ text-align: right; |
| 1158 | @ padding: 0.2ex 2ex; |
| 1159 | }, |
| 1160 | { ".statistics-report-graph-line", |
| 1161 | "for the /reports views", |
| 1162 | @ background-color: #446979; |
| 1163 | }, |
| 1164 | { ".statistics-report-table-events th", |
| 1165 | "", |
| 1166 | @ padding: 0 1em 0 1em; |
| @@ -1171,14 +1171,10 @@ | |
| 1171 | }, |
| 1172 | { ".statistics-report-row-year", |
| 1173 | "", |
| 1174 | @ text-align: left; |
| 1175 | }, |
| 1176 | { ".statistics-report-week-number-label", |
| 1177 | "for the /stats_report views", |
| 1178 | @ text-align: right; |
| 1179 | @ font-size: 0.8em; |
| 1180 | }, |
| @@ -1264,11 +1260,11 @@ | |
| 1260 | void page_test_env(void){ |
| 1261 | char c; |
| 1262 | int i; |
| 1263 | int showAll; |
| 1264 | char zCap[30]; |
| 1265 | static const char *const azCgiVars[] = { |
| 1266 | "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", |
| 1267 | "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING", |
| 1268 | "HTTP_ACCEPT_LANGUAGE", "HTTP_CONNECTION", "HTTP_HOST", |
| 1269 | "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED", |
| 1270 | "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT", "REQUEST_METHOD", |
| 1271 |
-6
| --- src/tag.c | ||
| +++ src/tag.c | ||
| @@ -595,13 +595,7 @@ | ||
| 595 | 595 | timeline_query_for_www() |
| 596 | 596 | ); |
| 597 | 597 | www_print_timeline(&q, 0, 0, 0, 0); |
| 598 | 598 | db_finalize(&q); |
| 599 | 599 | @ <br /> |
| 600 | - @ <script type="text/JavaScript"> | |
| 601 | - @ function xin(id){ | |
| 602 | - @ } | |
| 603 | - @ function xout(id){ | |
| 604 | - @ } | |
| 605 | - @ </script> | |
| 606 | 600 | style_footer(); |
| 607 | 601 | } |
| 608 | 602 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -595,13 +595,7 @@ | |
| 595 | timeline_query_for_www() |
| 596 | ); |
| 597 | www_print_timeline(&q, 0, 0, 0, 0); |
| 598 | db_finalize(&q); |
| 599 | @ <br /> |
| 600 | @ <script type="text/JavaScript"> |
| 601 | @ function xin(id){ |
| 602 | @ } |
| 603 | @ function xout(id){ |
| 604 | @ } |
| 605 | @ </script> |
| 606 | style_footer(); |
| 607 | } |
| 608 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -595,13 +595,7 @@ | |
| 595 | timeline_query_for_www() |
| 596 | ); |
| 597 | www_print_timeline(&q, 0, 0, 0, 0); |
| 598 | db_finalize(&q); |
| 599 | @ <br /> |
| 600 | style_footer(); |
| 601 | } |
| 602 |
M
src/th.c
+14
-12
| --- src/th.c | ||
| +++ src/th.c | ||
| @@ -2002,27 +2002,29 @@ | ||
| 2002 | 2002 | default: assert(!"Internal error"); |
| 2003 | 2003 | } |
| 2004 | 2004 | Th_SetResultInt(interp, iRes); |
| 2005 | 2005 | }else if( rc==TH_OK && eArgType==ARG_NUMBER ){ |
| 2006 | 2006 | switch( pExpr->pOp->eOp ) { |
| 2007 | - case OP_MULTIPLY: Th_SetResultDouble(interp, fLeft*fRight); break; | |
| 2007 | + case OP_MULTIPLY: Th_SetResultDouble(interp, fLeft*fRight); break; | |
| 2008 | 2008 | case OP_DIVIDE: |
| 2009 | 2009 | if( fRight==0.0 ){ |
| 2010 | 2010 | Th_ErrorMessage(interp, "Divide by 0:", zLeft, nLeft); |
| 2011 | 2011 | rc = TH_ERROR; |
| 2012 | 2012 | goto finish; |
| 2013 | 2013 | } |
| 2014 | 2014 | Th_SetResultDouble(interp, fLeft/fRight); |
| 2015 | 2015 | break; |
| 2016 | - case OP_ADD: Th_SetResultDouble(interp, fLeft+fRight); break; | |
| 2017 | - case OP_SUBTRACT: Th_SetResultDouble(interp, fLeft-fRight); break; | |
| 2018 | - case OP_LT: Th_SetResultInt(interp, fLeft<fRight); break; | |
| 2019 | - case OP_GT: Th_SetResultInt(interp, fLeft>fRight); break; | |
| 2020 | - case OP_LE: Th_SetResultInt(interp, fLeft<=fRight); break; | |
| 2021 | - case OP_GE: Th_SetResultInt(interp, fLeft>=fRight); break; | |
| 2022 | - case OP_EQ: Th_SetResultInt(interp, fLeft==fRight); break; | |
| 2023 | - case OP_NE: Th_SetResultInt(interp, fLeft!=fRight); break; | |
| 2016 | + case OP_ADD: Th_SetResultDouble(interp, fLeft+fRight); break; | |
| 2017 | + case OP_SUBTRACT: Th_SetResultDouble(interp, fLeft-fRight); break; | |
| 2018 | + case OP_LT: Th_SetResultInt(interp, fLeft<fRight); break; | |
| 2019 | + case OP_GT: Th_SetResultInt(interp, fLeft>fRight); break; | |
| 2020 | + case OP_LE: Th_SetResultInt(interp, fLeft<=fRight); break; | |
| 2021 | + case OP_GE: Th_SetResultInt(interp, fLeft>=fRight); break; | |
| 2022 | + case OP_EQ: Th_SetResultInt(interp, fLeft==fRight); break; | |
| 2023 | + case OP_NE: Th_SetResultInt(interp, fLeft!=fRight); break; | |
| 2024 | + case OP_UNARY_MINUS: Th_SetResultDouble(interp, -fLeft); break; | |
| 2025 | + case OP_UNARY_PLUS: Th_SetResultDouble(interp, +fLeft); break; | |
| 2024 | 2026 | default: assert(!"Internal error"); |
| 2025 | 2027 | } |
| 2026 | 2028 | }else if( rc==TH_OK ){ |
| 2027 | 2029 | int iEqual = 0; |
| 2028 | 2030 | assert( eArgType==ARG_STRING ); |
| @@ -2629,13 +2631,13 @@ | ||
| 2629 | 2631 | if( iVal<0 ){ |
| 2630 | 2632 | isNegative = 1; |
| 2631 | 2633 | iVal = iVal * -1; |
| 2632 | 2634 | } |
| 2633 | 2635 | *(--z) = '\0'; |
| 2634 | - *(--z) = (char)(48+(iVal%10)); | |
| 2635 | - while( (iVal = (iVal/10))>0 ){ | |
| 2636 | - *(--z) = (char)(48+(iVal%10)); | |
| 2636 | + *(--z) = (char)(48+((unsigned)iVal%10)); | |
| 2637 | + while( (iVal = ((unsigned)iVal/10))>0 ){ | |
| 2638 | + *(--z) = (char)(48+((unsigned)iVal%10)); | |
| 2637 | 2639 | assert(z>zBuf); |
| 2638 | 2640 | } |
| 2639 | 2641 | if( isNegative ){ |
| 2640 | 2642 | *(--z) = '-'; |
| 2641 | 2643 | } |
| 2642 | 2644 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -2002,27 +2002,29 @@ | |
| 2002 | default: assert(!"Internal error"); |
| 2003 | } |
| 2004 | Th_SetResultInt(interp, iRes); |
| 2005 | }else if( rc==TH_OK && eArgType==ARG_NUMBER ){ |
| 2006 | switch( pExpr->pOp->eOp ) { |
| 2007 | case OP_MULTIPLY: Th_SetResultDouble(interp, fLeft*fRight); break; |
| 2008 | case OP_DIVIDE: |
| 2009 | if( fRight==0.0 ){ |
| 2010 | Th_ErrorMessage(interp, "Divide by 0:", zLeft, nLeft); |
| 2011 | rc = TH_ERROR; |
| 2012 | goto finish; |
| 2013 | } |
| 2014 | Th_SetResultDouble(interp, fLeft/fRight); |
| 2015 | break; |
| 2016 | case OP_ADD: Th_SetResultDouble(interp, fLeft+fRight); break; |
| 2017 | case OP_SUBTRACT: Th_SetResultDouble(interp, fLeft-fRight); break; |
| 2018 | case OP_LT: Th_SetResultInt(interp, fLeft<fRight); break; |
| 2019 | case OP_GT: Th_SetResultInt(interp, fLeft>fRight); break; |
| 2020 | case OP_LE: Th_SetResultInt(interp, fLeft<=fRight); break; |
| 2021 | case OP_GE: Th_SetResultInt(interp, fLeft>=fRight); break; |
| 2022 | case OP_EQ: Th_SetResultInt(interp, fLeft==fRight); break; |
| 2023 | case OP_NE: Th_SetResultInt(interp, fLeft!=fRight); break; |
| 2024 | default: assert(!"Internal error"); |
| 2025 | } |
| 2026 | }else if( rc==TH_OK ){ |
| 2027 | int iEqual = 0; |
| 2028 | assert( eArgType==ARG_STRING ); |
| @@ -2629,13 +2631,13 @@ | |
| 2629 | if( iVal<0 ){ |
| 2630 | isNegative = 1; |
| 2631 | iVal = iVal * -1; |
| 2632 | } |
| 2633 | *(--z) = '\0'; |
| 2634 | *(--z) = (char)(48+(iVal%10)); |
| 2635 | while( (iVal = (iVal/10))>0 ){ |
| 2636 | *(--z) = (char)(48+(iVal%10)); |
| 2637 | assert(z>zBuf); |
| 2638 | } |
| 2639 | if( isNegative ){ |
| 2640 | *(--z) = '-'; |
| 2641 | } |
| 2642 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -2002,27 +2002,29 @@ | |
| 2002 | default: assert(!"Internal error"); |
| 2003 | } |
| 2004 | Th_SetResultInt(interp, iRes); |
| 2005 | }else if( rc==TH_OK && eArgType==ARG_NUMBER ){ |
| 2006 | switch( pExpr->pOp->eOp ) { |
| 2007 | case OP_MULTIPLY: Th_SetResultDouble(interp, fLeft*fRight); break; |
| 2008 | case OP_DIVIDE: |
| 2009 | if( fRight==0.0 ){ |
| 2010 | Th_ErrorMessage(interp, "Divide by 0:", zLeft, nLeft); |
| 2011 | rc = TH_ERROR; |
| 2012 | goto finish; |
| 2013 | } |
| 2014 | Th_SetResultDouble(interp, fLeft/fRight); |
| 2015 | break; |
| 2016 | case OP_ADD: Th_SetResultDouble(interp, fLeft+fRight); break; |
| 2017 | case OP_SUBTRACT: Th_SetResultDouble(interp, fLeft-fRight); break; |
| 2018 | case OP_LT: Th_SetResultInt(interp, fLeft<fRight); break; |
| 2019 | case OP_GT: Th_SetResultInt(interp, fLeft>fRight); break; |
| 2020 | case OP_LE: Th_SetResultInt(interp, fLeft<=fRight); break; |
| 2021 | case OP_GE: Th_SetResultInt(interp, fLeft>=fRight); break; |
| 2022 | case OP_EQ: Th_SetResultInt(interp, fLeft==fRight); break; |
| 2023 | case OP_NE: Th_SetResultInt(interp, fLeft!=fRight); break; |
| 2024 | case OP_UNARY_MINUS: Th_SetResultDouble(interp, -fLeft); break; |
| 2025 | case OP_UNARY_PLUS: Th_SetResultDouble(interp, +fLeft); break; |
| 2026 | default: assert(!"Internal error"); |
| 2027 | } |
| 2028 | }else if( rc==TH_OK ){ |
| 2029 | int iEqual = 0; |
| 2030 | assert( eArgType==ARG_STRING ); |
| @@ -2629,13 +2631,13 @@ | |
| 2631 | if( iVal<0 ){ |
| 2632 | isNegative = 1; |
| 2633 | iVal = iVal * -1; |
| 2634 | } |
| 2635 | *(--z) = '\0'; |
| 2636 | *(--z) = (char)(48+((unsigned)iVal%10)); |
| 2637 | while( (iVal = ((unsigned)iVal/10))>0 ){ |
| 2638 | *(--z) = (char)(48+((unsigned)iVal%10)); |
| 2639 | assert(z>zBuf); |
| 2640 | } |
| 2641 | if( isNegative ){ |
| 2642 | *(--z) = '-'; |
| 2643 | } |
| 2644 |
M
src/th.h
+8
-4
| --- src/th.h | ||
| +++ src/th.h | ||
| @@ -157,12 +157,16 @@ | ||
| 157 | 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | 160 | |
| 161 | 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | -int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 163 | -int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ | |
| 162 | +/* | |
| 163 | +** Interfaces to the full Tcl core library from "th_tcl.c". | |
| 164 | +*/ | |
| 165 | +int th_register_tcl(Th_Interp *, void *); | |
| 166 | +int unloadTcl(Th_Interp *, void *); | |
| 167 | +int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); | |
| 164 | 168 | #endif |
| 165 | 169 | |
| 166 | 170 | /* |
| 167 | 171 | ** General purpose hash table from th_lang.c. |
| 168 | 172 | */ |
| @@ -182,7 +186,7 @@ | ||
| 182 | 186 | /* |
| 183 | 187 | ** Useful functions from th_lang.c. |
| 184 | 188 | */ |
| 185 | 189 | int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg); |
| 186 | 190 | |
| 187 | -typedef struct Th_SubCommand {char *zName; Th_CommandProc xProc;} Th_SubCommand; | |
| 188 | -int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,Th_SubCommand*); | |
| 191 | +typedef struct Th_SubCommand {const char *zName; Th_CommandProc xProc;} Th_SubCommand; | |
| 192 | +int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,const Th_SubCommand*); | |
| 189 | 193 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 163 | int unloadTcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 164 | #endif |
| 165 | |
| 166 | /* |
| 167 | ** General purpose hash table from th_lang.c. |
| 168 | */ |
| @@ -182,7 +186,7 @@ | |
| 182 | /* |
| 183 | ** Useful functions from th_lang.c. |
| 184 | */ |
| 185 | int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg); |
| 186 | |
| 187 | typedef struct Th_SubCommand {char *zName; Th_CommandProc xProc;} Th_SubCommand; |
| 188 | int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,Th_SubCommand*); |
| 189 |
| --- src/th.h | |
| +++ src/th.h | |
| @@ -157,12 +157,16 @@ | |
| 157 | int th_register_sqlite(Th_Interp *interp); /* th_sqlite.c */ |
| 158 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 159 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 160 | |
| 161 | #ifdef FOSSIL_ENABLE_TCL |
| 162 | /* |
| 163 | ** Interfaces to the full Tcl core library from "th_tcl.c". |
| 164 | */ |
| 165 | int th_register_tcl(Th_Interp *, void *); |
| 166 | int unloadTcl(Th_Interp *, void *); |
| 167 | int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int); |
| 168 | #endif |
| 169 | |
| 170 | /* |
| 171 | ** General purpose hash table from th_lang.c. |
| 172 | */ |
| @@ -182,7 +186,7 @@ | |
| 186 | /* |
| 187 | ** Useful functions from th_lang.c. |
| 188 | */ |
| 189 | int Th_WrongNumArgs(Th_Interp *interp, const char *zMsg); |
| 190 | |
| 191 | typedef struct Th_SubCommand {const char *zName; Th_CommandProc xProc;} Th_SubCommand; |
| 192 | int Th_CallSubCommand(Th_Interp*,void*,int,const char**,int*,const Th_SubCommand*); |
| 193 |
+7
-7
| --- src/th_lang.c | ||
| +++ src/th_lang.c | ||
| @@ -425,11 +425,11 @@ | ||
| 425 | 425 | int argc, |
| 426 | 426 | const char **argv, |
| 427 | 427 | int *argl |
| 428 | 428 | ){ |
| 429 | 429 | int rc; |
| 430 | - char *zName; | |
| 430 | + const char *zName; | |
| 431 | 431 | |
| 432 | 432 | ProcDefn *p; |
| 433 | 433 | int nByte; |
| 434 | 434 | int i; |
| 435 | 435 | char *zSpace; |
| @@ -521,11 +521,11 @@ | ||
| 521 | 521 | } |
| 522 | 522 | p->zUsage = zUsage; |
| 523 | 523 | p->nUsage = nUsage; |
| 524 | 524 | |
| 525 | 525 | /* Register the new command with the th1 interpreter. */ |
| 526 | - zName = (char *)argv[1]; | |
| 526 | + zName = argv[1]; | |
| 527 | 527 | rc = Th_CreateCommand(interp, zName, proc_call1, (void *)p, proc_del); |
| 528 | 528 | if( rc==TH_OK ){ |
| 529 | 529 | Th_SetResult(interp, 0, 0); |
| 530 | 530 | } |
| 531 | 531 | |
| @@ -887,16 +887,16 @@ | ||
| 887 | 887 | Th_Interp *interp, |
| 888 | 888 | void *ctx, |
| 889 | 889 | int argc, |
| 890 | 890 | const char **argv, |
| 891 | 891 | int *argl, |
| 892 | - Th_SubCommand *aSub | |
| 892 | + const Th_SubCommand *aSub | |
| 893 | 893 | ){ |
| 894 | 894 | if( argc>1 ){ |
| 895 | 895 | int i; |
| 896 | 896 | for(i=0; aSub[i].zName; i++){ |
| 897 | - char *zName = (char *)aSub[i].zName; | |
| 897 | + const char *zName = aSub[i].zName; | |
| 898 | 898 | if( th_strlen(zName)==argl[1] && 0==memcmp(zName, argv[1], argl[1]) ){ |
| 899 | 899 | return aSub[i].xProc(interp, ctx, argc, argv, argl); |
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | 902 | } |
| @@ -924,11 +924,11 @@ | ||
| 924 | 924 | void *ctx, |
| 925 | 925 | int argc, |
| 926 | 926 | const char **argv, |
| 927 | 927 | int *argl |
| 928 | 928 | ){ |
| 929 | - Th_SubCommand aSub[] = { | |
| 929 | + static const Th_SubCommand aSub[] = { | |
| 930 | 930 | { "compare", string_compare_command }, |
| 931 | 931 | { "first", string_first_command }, |
| 932 | 932 | { "is", string_is_command }, |
| 933 | 933 | { "last", string_last_command }, |
| 934 | 934 | { "length", string_length_command }, |
| @@ -952,11 +952,11 @@ | ||
| 952 | 952 | void *ctx, |
| 953 | 953 | int argc, |
| 954 | 954 | const char **argv, |
| 955 | 955 | int *argl |
| 956 | 956 | ){ |
| 957 | - Th_SubCommand aSub[] = { | |
| 957 | + static const Th_SubCommand aSub[] = { | |
| 958 | 958 | { "exists", info_exists_command }, |
| 959 | 959 | { 0, 0 } |
| 960 | 960 | }; |
| 961 | 961 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 962 | 962 | } |
| @@ -1097,11 +1097,11 @@ | ||
| 1097 | 1097 | {"continue", simple_command, (void *)TH_CONTINUE}, |
| 1098 | 1098 | {"error", simple_command, (void *)TH_ERROR}, |
| 1099 | 1099 | |
| 1100 | 1100 | {0, 0, 0} |
| 1101 | 1101 | }; |
| 1102 | - int i; | |
| 1102 | + size_t i; | |
| 1103 | 1103 | |
| 1104 | 1104 | /* Add the language commands. */ |
| 1105 | 1105 | for(i=0; i<(sizeof(aCommand)/sizeof(aCommand[0])); i++){ |
| 1106 | 1106 | void *ctx; |
| 1107 | 1107 | if ( !aCommand[i].zName || !aCommand[i].xProc ) continue; |
| 1108 | 1108 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -425,11 +425,11 @@ | |
| 425 | int argc, |
| 426 | const char **argv, |
| 427 | int *argl |
| 428 | ){ |
| 429 | int rc; |
| 430 | char *zName; |
| 431 | |
| 432 | ProcDefn *p; |
| 433 | int nByte; |
| 434 | int i; |
| 435 | char *zSpace; |
| @@ -521,11 +521,11 @@ | |
| 521 | } |
| 522 | p->zUsage = zUsage; |
| 523 | p->nUsage = nUsage; |
| 524 | |
| 525 | /* Register the new command with the th1 interpreter. */ |
| 526 | zName = (char *)argv[1]; |
| 527 | rc = Th_CreateCommand(interp, zName, proc_call1, (void *)p, proc_del); |
| 528 | if( rc==TH_OK ){ |
| 529 | Th_SetResult(interp, 0, 0); |
| 530 | } |
| 531 | |
| @@ -887,16 +887,16 @@ | |
| 887 | Th_Interp *interp, |
| 888 | void *ctx, |
| 889 | int argc, |
| 890 | const char **argv, |
| 891 | int *argl, |
| 892 | Th_SubCommand *aSub |
| 893 | ){ |
| 894 | if( argc>1 ){ |
| 895 | int i; |
| 896 | for(i=0; aSub[i].zName; i++){ |
| 897 | char *zName = (char *)aSub[i].zName; |
| 898 | if( th_strlen(zName)==argl[1] && 0==memcmp(zName, argv[1], argl[1]) ){ |
| 899 | return aSub[i].xProc(interp, ctx, argc, argv, argl); |
| 900 | } |
| 901 | } |
| 902 | } |
| @@ -924,11 +924,11 @@ | |
| 924 | void *ctx, |
| 925 | int argc, |
| 926 | const char **argv, |
| 927 | int *argl |
| 928 | ){ |
| 929 | Th_SubCommand aSub[] = { |
| 930 | { "compare", string_compare_command }, |
| 931 | { "first", string_first_command }, |
| 932 | { "is", string_is_command }, |
| 933 | { "last", string_last_command }, |
| 934 | { "length", string_length_command }, |
| @@ -952,11 +952,11 @@ | |
| 952 | void *ctx, |
| 953 | int argc, |
| 954 | const char **argv, |
| 955 | int *argl |
| 956 | ){ |
| 957 | Th_SubCommand aSub[] = { |
| 958 | { "exists", info_exists_command }, |
| 959 | { 0, 0 } |
| 960 | }; |
| 961 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 962 | } |
| @@ -1097,11 +1097,11 @@ | |
| 1097 | {"continue", simple_command, (void *)TH_CONTINUE}, |
| 1098 | {"error", simple_command, (void *)TH_ERROR}, |
| 1099 | |
| 1100 | {0, 0, 0} |
| 1101 | }; |
| 1102 | int i; |
| 1103 | |
| 1104 | /* Add the language commands. */ |
| 1105 | for(i=0; i<(sizeof(aCommand)/sizeof(aCommand[0])); i++){ |
| 1106 | void *ctx; |
| 1107 | if ( !aCommand[i].zName || !aCommand[i].xProc ) continue; |
| 1108 |
| --- src/th_lang.c | |
| +++ src/th_lang.c | |
| @@ -425,11 +425,11 @@ | |
| 425 | int argc, |
| 426 | const char **argv, |
| 427 | int *argl |
| 428 | ){ |
| 429 | int rc; |
| 430 | const char *zName; |
| 431 | |
| 432 | ProcDefn *p; |
| 433 | int nByte; |
| 434 | int i; |
| 435 | char *zSpace; |
| @@ -521,11 +521,11 @@ | |
| 521 | } |
| 522 | p->zUsage = zUsage; |
| 523 | p->nUsage = nUsage; |
| 524 | |
| 525 | /* Register the new command with the th1 interpreter. */ |
| 526 | zName = argv[1]; |
| 527 | rc = Th_CreateCommand(interp, zName, proc_call1, (void *)p, proc_del); |
| 528 | if( rc==TH_OK ){ |
| 529 | Th_SetResult(interp, 0, 0); |
| 530 | } |
| 531 | |
| @@ -887,16 +887,16 @@ | |
| 887 | Th_Interp *interp, |
| 888 | void *ctx, |
| 889 | int argc, |
| 890 | const char **argv, |
| 891 | int *argl, |
| 892 | const Th_SubCommand *aSub |
| 893 | ){ |
| 894 | if( argc>1 ){ |
| 895 | int i; |
| 896 | for(i=0; aSub[i].zName; i++){ |
| 897 | const char *zName = aSub[i].zName; |
| 898 | if( th_strlen(zName)==argl[1] && 0==memcmp(zName, argv[1], argl[1]) ){ |
| 899 | return aSub[i].xProc(interp, ctx, argc, argv, argl); |
| 900 | } |
| 901 | } |
| 902 | } |
| @@ -924,11 +924,11 @@ | |
| 924 | void *ctx, |
| 925 | int argc, |
| 926 | const char **argv, |
| 927 | int *argl |
| 928 | ){ |
| 929 | static const Th_SubCommand aSub[] = { |
| 930 | { "compare", string_compare_command }, |
| 931 | { "first", string_first_command }, |
| 932 | { "is", string_is_command }, |
| 933 | { "last", string_last_command }, |
| 934 | { "length", string_length_command }, |
| @@ -952,11 +952,11 @@ | |
| 952 | void *ctx, |
| 953 | int argc, |
| 954 | const char **argv, |
| 955 | int *argl |
| 956 | ){ |
| 957 | static const Th_SubCommand aSub[] = { |
| 958 | { "exists", info_exists_command }, |
| 959 | { 0, 0 } |
| 960 | }; |
| 961 | return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub); |
| 962 | } |
| @@ -1097,11 +1097,11 @@ | |
| 1097 | {"continue", simple_command, (void *)TH_CONTINUE}, |
| 1098 | {"error", simple_command, (void *)TH_ERROR}, |
| 1099 | |
| 1100 | {0, 0, 0} |
| 1101 | }; |
| 1102 | size_t i; |
| 1103 | |
| 1104 | /* Add the language commands. */ |
| 1105 | for(i=0; i<(sizeof(aCommand)/sizeof(aCommand[0])); i++){ |
| 1106 | void *ctx; |
| 1107 | if ( !aCommand[i].zName || !aCommand[i].xProc ) continue; |
| 1108 |
+24
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -97,10 +97,33 @@ | ||
| 97 | 97 | fossil_print("\n------------------ BEGIN TRACE LOG ------------------\n"); |
| 98 | 98 | fossil_print("%s", blob_str(&g.thLog)); |
| 99 | 99 | fossil_print("\n------------------- END TRACE LOG -------------------\n"); |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | + | |
| 103 | +/* | |
| 104 | +** TH command: httpize STRING | |
| 105 | +** | |
| 106 | +** Escape all characters of STRING which have special meaning in URI | |
| 107 | +** components. Return a new string result. | |
| 108 | +*/ | |
| 109 | +static int httpizeCmd( | |
| 110 | + Th_Interp *interp, | |
| 111 | + void *p, | |
| 112 | + int argc, | |
| 113 | + const char **argv, | |
| 114 | + int *argl | |
| 115 | +){ | |
| 116 | + char *zOut; | |
| 117 | + if( argc!=2 ){ | |
| 118 | + return Th_WrongNumArgs(interp, "httpize STRING"); | |
| 119 | + } | |
| 120 | + zOut = httpize((char*)argv[1], argl[1]); | |
| 121 | + Th_SetResult(interp, zOut, -1); | |
| 122 | + free(zOut); | |
| 123 | + return TH_OK; | |
| 124 | +} | |
| 102 | 125 | |
| 103 | 126 | /* |
| 104 | 127 | ** True if output is enabled. False if disabled. |
| 105 | 128 | */ |
| 106 | 129 | static int enableOutput = 1; |
| @@ -972,10 +995,11 @@ | ||
| 972 | 995 | {"anycap", anycapCmd, 0}, |
| 973 | 996 | {"combobox", comboboxCmd, 0}, |
| 974 | 997 | {"date", dateCmd, 0}, |
| 975 | 998 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 976 | 999 | {"enable_output", enableOutputCmd, 0}, |
| 1000 | + {"httpize", httpizeCmd, 0}, | |
| 977 | 1001 | {"hascap", hascapCmd, 0}, |
| 978 | 1002 | {"hasfeature", hasfeatureCmd, 0}, |
| 979 | 1003 | {"html", putsCmd, (void*)&aFlags[0]}, |
| 980 | 1004 | {"htmlize", htmlizeCmd, 0}, |
| 981 | 1005 | {"http", httpCmd, 0}, |
| 982 | 1006 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -97,10 +97,33 @@ | |
| 97 | fossil_print("\n------------------ BEGIN TRACE LOG ------------------\n"); |
| 98 | fossil_print("%s", blob_str(&g.thLog)); |
| 99 | fossil_print("\n------------------- END TRACE LOG -------------------\n"); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /* |
| 104 | ** True if output is enabled. False if disabled. |
| 105 | */ |
| 106 | static int enableOutput = 1; |
| @@ -972,10 +995,11 @@ | |
| 972 | {"anycap", anycapCmd, 0}, |
| 973 | {"combobox", comboboxCmd, 0}, |
| 974 | {"date", dateCmd, 0}, |
| 975 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 976 | {"enable_output", enableOutputCmd, 0}, |
| 977 | {"hascap", hascapCmd, 0}, |
| 978 | {"hasfeature", hasfeatureCmd, 0}, |
| 979 | {"html", putsCmd, (void*)&aFlags[0]}, |
| 980 | {"htmlize", htmlizeCmd, 0}, |
| 981 | {"http", httpCmd, 0}, |
| 982 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -97,10 +97,33 @@ | |
| 97 | fossil_print("\n------------------ BEGIN TRACE LOG ------------------\n"); |
| 98 | fossil_print("%s", blob_str(&g.thLog)); |
| 99 | fossil_print("\n------------------- END TRACE LOG -------------------\n"); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /* |
| 104 | ** TH command: httpize STRING |
| 105 | ** |
| 106 | ** Escape all characters of STRING which have special meaning in URI |
| 107 | ** components. Return a new string result. |
| 108 | */ |
| 109 | static int httpizeCmd( |
| 110 | Th_Interp *interp, |
| 111 | void *p, |
| 112 | int argc, |
| 113 | const char **argv, |
| 114 | int *argl |
| 115 | ){ |
| 116 | char *zOut; |
| 117 | if( argc!=2 ){ |
| 118 | return Th_WrongNumArgs(interp, "httpize STRING"); |
| 119 | } |
| 120 | zOut = httpize((char*)argv[1], argl[1]); |
| 121 | Th_SetResult(interp, zOut, -1); |
| 122 | free(zOut); |
| 123 | return TH_OK; |
| 124 | } |
| 125 | |
| 126 | /* |
| 127 | ** True if output is enabled. False if disabled. |
| 128 | */ |
| 129 | static int enableOutput = 1; |
| @@ -972,10 +995,11 @@ | |
| 995 | {"anycap", anycapCmd, 0}, |
| 996 | {"combobox", comboboxCmd, 0}, |
| 997 | {"date", dateCmd, 0}, |
| 998 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 999 | {"enable_output", enableOutputCmd, 0}, |
| 1000 | {"httpize", httpizeCmd, 0}, |
| 1001 | {"hascap", hascapCmd, 0}, |
| 1002 | {"hasfeature", hasfeatureCmd, 0}, |
| 1003 | {"html", putsCmd, (void*)&aFlags[0]}, |
| 1004 | {"htmlize", htmlizeCmd, 0}, |
| 1005 | {"http", httpCmd, 0}, |
| 1006 |
+32
| --- src/th_tcl.c | ||
| +++ src/th_tcl.c | ||
| @@ -766,10 +766,42 @@ | ||
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | Tcl_DecrRefCount(listPtr); |
| 769 | 769 | return rc; |
| 770 | 770 | } |
| 771 | + | |
| 772 | +/* | |
| 773 | +** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the | |
| 774 | +** Tcl script succeeds, start a Tcl event loop until there are no more events | |
| 775 | +** remaining to process -OR- the script calls [exit]. If the bWait argument | |
| 776 | +** is zero, only process events that are already in the queue; otherwise, | |
| 777 | +** process events until the script terminates the Tcl event loop. | |
| 778 | +*/ | |
| 779 | +int evaluateTclWithEvents( | |
| 780 | + Th_Interp *interp, | |
| 781 | + void *pContext, | |
| 782 | + const char *zScript, | |
| 783 | + int nScript, | |
| 784 | + int bWait | |
| 785 | +){ | |
| 786 | + struct TclContext *tclContext = (struct TclContext *)pContext; | |
| 787 | + Tcl_Interp *tclInterp; | |
| 788 | + int rc; | |
| 789 | + int flags = TCL_ALL_EVENTS; | |
| 790 | + | |
| 791 | + if( createTclInterp(interp, pContext)!=TH_OK ){ | |
| 792 | + return TH_ERROR; | |
| 793 | + } | |
| 794 | + tclInterp = tclContext->interp; | |
| 795 | + rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); | |
| 796 | + if( rc!=TCL_OK ) return rc; | |
| 797 | + if( !bWait ) flags |= TCL_DONT_WAIT; | |
| 798 | + while( Tcl_DoOneEvent(flags) ){ | |
| 799 | + /* do nothing */ | |
| 800 | + } | |
| 801 | + return rc; | |
| 802 | +} | |
| 771 | 803 | |
| 772 | 804 | /* |
| 773 | 805 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 774 | 806 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 775 | 807 | ** by the caller. |
| 776 | 808 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -766,10 +766,42 @@ | |
| 766 | } |
| 767 | } |
| 768 | Tcl_DecrRefCount(listPtr); |
| 769 | return rc; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 774 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 775 | ** by the caller. |
| 776 |
| --- src/th_tcl.c | |
| +++ src/th_tcl.c | |
| @@ -766,10 +766,42 @@ | |
| 766 | } |
| 767 | } |
| 768 | Tcl_DecrRefCount(listPtr); |
| 769 | return rc; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the |
| 774 | ** Tcl script succeeds, start a Tcl event loop until there are no more events |
| 775 | ** remaining to process -OR- the script calls [exit]. If the bWait argument |
| 776 | ** is zero, only process events that are already in the queue; otherwise, |
| 777 | ** process events until the script terminates the Tcl event loop. |
| 778 | */ |
| 779 | int evaluateTclWithEvents( |
| 780 | Th_Interp *interp, |
| 781 | void *pContext, |
| 782 | const char *zScript, |
| 783 | int nScript, |
| 784 | int bWait |
| 785 | ){ |
| 786 | struct TclContext *tclContext = (struct TclContext *)pContext; |
| 787 | Tcl_Interp *tclInterp; |
| 788 | int rc; |
| 789 | int flags = TCL_ALL_EVENTS; |
| 790 | |
| 791 | if( createTclInterp(interp, pContext)!=TH_OK ){ |
| 792 | return TH_ERROR; |
| 793 | } |
| 794 | tclInterp = tclContext->interp; |
| 795 | rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL); |
| 796 | if( rc!=TCL_OK ) return rc; |
| 797 | if( !bWait ) flags |= TCL_DONT_WAIT; |
| 798 | while( Tcl_DoOneEvent(flags) ){ |
| 799 | /* do nothing */ |
| 800 | } |
| 801 | return rc; |
| 802 | } |
| 803 | |
| 804 | /* |
| 805 | ** Creates and initializes a Tcl interpreter for use with the specified TH1 |
| 806 | ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied |
| 807 | ** by the caller. |
| 808 |
+39
-24
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -247,14 +247,14 @@ | ||
| 247 | 247 | int fchngQueryInit = 0; /* True if fchngQuery is initialized */ |
| 248 | 248 | Stmt fchngQuery; /* Query for file changes on check-ins */ |
| 249 | 249 | static Stmt qbranch; |
| 250 | 250 | int pendingEndTr = 0; /* True if a </td></tr> is needed */ |
| 251 | 251 | int vid = 0; /* Current checkout version */ |
| 252 | - int dateFormat = 0; /* 0: HH:MM 1: HH:MM:SS | |
| 252 | + int dateFormat = 0; /* 0: HH:MM 1: HH:MM:SS | |
| 253 | 253 | 2: YYYY-MM-DD HH:MM |
| 254 | 254 | 3: YYMMDD HH:MM */ |
| 255 | - | |
| 255 | + | |
| 256 | 256 | if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){ |
| 257 | 257 | vid = db_lget_int("checkout", 0); |
| 258 | 258 | } |
| 259 | 259 | zPrevDate[0] = 0; |
| 260 | 260 | mxWikiLen = db_get_int("timeline-max-comment", 0); |
| @@ -591,13 +591,12 @@ | ||
| 591 | 591 | ){ |
| 592 | 592 | if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){ |
| 593 | 593 | GraphRow *pRow; |
| 594 | 594 | int i; |
| 595 | 595 | char cSep; |
| 596 | - | |
| 597 | - @ <script type="text/JavaScript"> | |
| 598 | - @ /* <![CDATA[ */ | |
| 596 | + | |
| 597 | + @ <script> | |
| 599 | 598 | @ var railPitch=%d(pGraph->iRailPitch); |
| 600 | 599 | |
| 601 | 600 | /* the rowinfo[] array contains all the information needed to generate |
| 602 | 601 | ** the graph. Each entry contains information for a single row: |
| 603 | 602 | ** |
| @@ -872,11 +871,10 @@ | ||
| 872 | 871 | @ lastY = h; |
| 873 | 872 | @ } |
| 874 | 873 | @ setTimeout("checkHeight();", 1000); |
| 875 | 874 | @ } |
| 876 | 875 | @ checkHeight(); |
| 877 | - @ /* ]]> */ | |
| 878 | 876 | @ </script> |
| 879 | 877 | } |
| 880 | 878 | } |
| 881 | 879 | |
| 882 | 880 | /* |
| @@ -2077,16 +2075,24 @@ | ||
| 2077 | 2075 | } |
| 2078 | 2076 | |
| 2079 | 2077 | /* |
| 2080 | 2078 | ** A helper for the /reports family of pages which prints out a menu |
| 2081 | 2079 | ** of links for the various type=XXX flags. zCurrentViewName must be |
| 2082 | -** the name/value of the 'view' parameter which is in effect at | |
| 2083 | -** the time this is called. e.g. if called from the 'byuser' view | |
| 2084 | -** then zCurrentViewName must be "byuser". | |
| 2085 | -*/ | |
| 2086 | -static void stats_report_event_types_menu(char const * zCurrentViewName){ | |
| 2087 | - char * zTop = mprintf("%s/reports?view=%s", g.zTop, zCurrentViewName); | |
| 2080 | +** the name/value of the 'view' parameter which is in effect at the | |
| 2081 | +** time this is called. e.g. if called from the 'byuser' view then | |
| 2082 | +** zCurrentViewName must be "byuser". Any URL parameters which need to | |
| 2083 | +** be added to the generated URLs should be passed in zParam. The | |
| 2084 | +** caller is expected to have already encoded any zParam in the %T or | |
| 2085 | +** %t encoding. */ | |
| 2086 | +static void stats_report_event_types_menu(char const * zCurrentViewName, | |
| 2087 | + char const * zParam){ | |
| 2088 | + char * zTop; | |
| 2089 | + if(zParam && !*zParam){ | |
| 2090 | + zParam = NULL; | |
| 2091 | + } | |
| 2092 | + zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName, | |
| 2093 | + zParam ? "&" : "", zParam); | |
| 2088 | 2094 | cgi_printf("<div>"); |
| 2089 | 2095 | cgi_printf("<span>Event types:</span> "); |
| 2090 | 2096 | if('*' == statsReportType){ |
| 2091 | 2097 | cgi_printf(" <strong>all</strong>", zTop); |
| 2092 | 2098 | }else{ |
| @@ -2173,11 +2179,11 @@ | ||
| 2173 | 2179 | int nMaxEvents = 1; /* for calculating length of graph |
| 2174 | 2180 | bars. */ |
| 2175 | 2181 | int iterations = 0; /* number of weeks/months we iterate |
| 2176 | 2182 | over */ |
| 2177 | 2183 | stats_report_init_view(); |
| 2178 | - stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear" ); | |
| 2184 | + stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear", NULL ); | |
| 2179 | 2185 | blob_appendf(&header, "Timeline Events (%s) by year%s", |
| 2180 | 2186 | stats_report_label_for_type(), |
| 2181 | 2187 | (includeMonth ? "/month" : "")); |
| 2182 | 2188 | blob_appendf(&sql, |
| 2183 | 2189 | "SELECT substr(date(mtime),1,%d) AS timeframe, " |
| @@ -2232,11 +2238,11 @@ | ||
| 2232 | 2238 | if(showYearTotal){ |
| 2233 | 2239 | rowClass = ++nRowNumber % 2; |
| 2234 | 2240 | @ <tr class='row%d(rowClass)'> |
| 2235 | 2241 | @ <td></td> |
| 2236 | 2242 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2237 | - @</tr> | |
| 2243 | + @</tr> | |
| 2238 | 2244 | } |
| 2239 | 2245 | nEventsPerYear = 0; |
| 2240 | 2246 | memcpy(zPrevYear,zTimeframe,4); |
| 2241 | 2247 | rowClass = ++nRowNumber % 2; |
| 2242 | 2248 | @ <tr class='row%d(rowClass)'> |
| @@ -2270,12 +2276,12 @@ | ||
| 2270 | 2276 | cgi_printf("'>%s</a>", zTimeframe); |
| 2271 | 2277 | } |
| 2272 | 2278 | @ </td><td>%d(nCount)</td> |
| 2273 | 2279 | @ <td> |
| 2274 | 2280 | @ <div class='statistics-report-graph-line' |
| 2275 | - @ style='height:16px;width:%d(nSize)%%;'> | |
| 2276 | - @ </div></td> | |
| 2281 | + @ style='width:%d(nSize)%%;'> </div> | |
| 2282 | + @ </td> | |
| 2277 | 2283 | @</tr> |
| 2278 | 2284 | if(includeWeeks){ |
| 2279 | 2285 | /* This part works fine for months but it terribly slow (4.5s on my PC), |
| 2280 | 2286 | so it's only shown for by-year for now. Suggestions/patches for |
| 2281 | 2287 | a better/faster layout are welcomed. */ |
| @@ -2296,11 +2302,11 @@ | ||
| 2296 | 2302 | /* Add final year total separator. */ |
| 2297 | 2303 | rowClass = ++nRowNumber % 2; |
| 2298 | 2304 | @ <tr class='row%d(rowClass)'> |
| 2299 | 2305 | @ <td></td> |
| 2300 | 2306 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2301 | - @</tr> | |
| 2307 | + @</tr> | |
| 2302 | 2308 | } |
| 2303 | 2309 | @ </tbody></table> |
| 2304 | 2310 | if(nEventTotal){ |
| 2305 | 2311 | char const * zAvgLabel = includeMonth ? "month" : "year"; |
| 2306 | 2312 | int nAvg = iterations ? (nEventTotal/iterations) : 0; |
| @@ -2324,11 +2330,11 @@ | ||
| 2324 | 2330 | row colors */ |
| 2325 | 2331 | Blob sql = empty_blob; /* SQL */ |
| 2326 | 2332 | int nMaxEvents = 1; /* max number of events for |
| 2327 | 2333 | all rows. */ |
| 2328 | 2334 | stats_report_init_view(); |
| 2329 | - stats_report_event_types_menu("byuser"); | |
| 2335 | + stats_report_event_types_menu("byuser", NULL); | |
| 2330 | 2336 | blob_append(&sql, |
| 2331 | 2337 | "SELECT user, " |
| 2332 | 2338 | "COUNT(*) AS eventCount " |
| 2333 | 2339 | "FROM v_reports " |
| 2334 | 2340 | "GROUP BY user ORDER BY eventCount DESC", |
| @@ -2365,12 +2371,12 @@ | ||
| 2365 | 2371 | @ <td> |
| 2366 | 2372 | @ <a href="?view=bymonth&user=%h(zUser)&type=%c((char)statsReportType)">%h(zUser)</a> |
| 2367 | 2373 | @ </td><td>%d(nCount)</td> |
| 2368 | 2374 | @ <td> |
| 2369 | 2375 | @ <div class='statistics-report-graph-line' |
| 2370 | - @ style='height:16px;width:%d(nSize)%%;'> | |
| 2371 | - @ </div></td> | |
| 2376 | + @ style='width:%d(nSize)%%;'> </div> | |
| 2377 | + @ </td> | |
| 2372 | 2378 | @</tr> |
| 2373 | 2379 | /* |
| 2374 | 2380 | Potential improvement: calculate the min/max event counts and |
| 2375 | 2381 | use percent-based graph bars. |
| 2376 | 2382 | */ |
| @@ -2395,21 +2401,28 @@ | ||
| 2395 | 2401 | Blob sql = empty_blob; |
| 2396 | 2402 | int nMaxEvents = 1; /* max number of events for |
| 2397 | 2403 | all rows. */ |
| 2398 | 2404 | int iterations = 0; /* # of active time periods. */ |
| 2399 | 2405 | stats_report_init_view(); |
| 2400 | - stats_report_event_types_menu("byweek"); | |
| 2401 | - cgi_printf("Select year: "); | |
| 2406 | + if(4==nYear){ | |
| 2407 | + Blob urlParams = empty_blob; | |
| 2408 | + blob_appendf(&urlParams, "y=%T", zYear); | |
| 2409 | + stats_report_event_types_menu("byweek", blob_str(&urlParams)); | |
| 2410 | + blob_reset(&urlParams); | |
| 2411 | + }else{ | |
| 2412 | + stats_report_event_types_menu("byweek", NULL); | |
| 2413 | + } | |
| 2402 | 2414 | blob_append(&sql, |
| 2403 | 2415 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2404 | 2416 | "FROM v_reports WHERE 1 ", -1); |
| 2405 | 2417 | if(zUserName&&*zUserName){ |
| 2406 | 2418 | blob_appendf(&sql,"AND user=%Q ", zUserName); |
| 2407 | 2419 | } |
| 2408 | 2420 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2409 | 2421 | db_prepare(&qYears, blob_str(&sql)); |
| 2410 | 2422 | blob_reset(&sql); |
| 2423 | + cgi_printf("Select year: "); | |
| 2411 | 2424 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2412 | 2425 | const char * zT = db_column_text(&qYears, 0); |
| 2413 | 2426 | if( i++ ){ |
| 2414 | 2427 | cgi_printf(" "); |
| 2415 | 2428 | } |
| @@ -2487,11 +2500,11 @@ | ||
| 2487 | 2500 | |
| 2488 | 2501 | cgi_printf("<td>%d</td>",nCount); |
| 2489 | 2502 | cgi_printf("<td>"); |
| 2490 | 2503 | if(nCount){ |
| 2491 | 2504 | cgi_printf("<div class='statistics-report-graph-line'" |
| 2492 | - "style='height:16px;width:%d%%;'></div>", | |
| 2505 | + "style='width:%d%%;'> </div>", | |
| 2493 | 2506 | nSize); |
| 2494 | 2507 | } |
| 2495 | 2508 | cgi_printf("</td></tr>"); |
| 2496 | 2509 | } |
| 2497 | 2510 | db_finalize(&stWeek); |
| @@ -2529,13 +2542,15 @@ | ||
| 2529 | 2542 | */ |
| 2530 | 2543 | void stats_report_page(){ |
| 2531 | 2544 | HQuery url; /* URL for various branch links */ |
| 2532 | 2545 | const char * zView = P("view"); /* Which view/report to show. */ |
| 2533 | 2546 | const char *zUserName = P("user"); |
| 2547 | + | |
| 2548 | + login_check_credentials(); | |
| 2549 | + if( !g.perm.Read ){ login_needed(); return; } | |
| 2534 | 2550 | if(!zUserName) zUserName = P("u"); |
| 2535 | 2551 | url_initialize(&url, "reports"); |
| 2536 | - | |
| 2537 | 2552 | if(zUserName && *zUserName){ |
| 2538 | 2553 | url_add_parameter(&url,"user", zUserName); |
| 2539 | 2554 | timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user"); |
| 2540 | 2555 | } |
| 2541 | 2556 | timeline_submenu(&url, "By Year", "view", "byyear", 0); |
| 2542 | 2557 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -247,14 +247,14 @@ | |
| 247 | int fchngQueryInit = 0; /* True if fchngQuery is initialized */ |
| 248 | Stmt fchngQuery; /* Query for file changes on check-ins */ |
| 249 | static Stmt qbranch; |
| 250 | int pendingEndTr = 0; /* True if a </td></tr> is needed */ |
| 251 | int vid = 0; /* Current checkout version */ |
| 252 | int dateFormat = 0; /* 0: HH:MM 1: HH:MM:SS |
| 253 | 2: YYYY-MM-DD HH:MM |
| 254 | 3: YYMMDD HH:MM */ |
| 255 | |
| 256 | if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){ |
| 257 | vid = db_lget_int("checkout", 0); |
| 258 | } |
| 259 | zPrevDate[0] = 0; |
| 260 | mxWikiLen = db_get_int("timeline-max-comment", 0); |
| @@ -591,13 +591,12 @@ | |
| 591 | ){ |
| 592 | if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){ |
| 593 | GraphRow *pRow; |
| 594 | int i; |
| 595 | char cSep; |
| 596 | |
| 597 | @ <script type="text/JavaScript"> |
| 598 | @ /* <![CDATA[ */ |
| 599 | @ var railPitch=%d(pGraph->iRailPitch); |
| 600 | |
| 601 | /* the rowinfo[] array contains all the information needed to generate |
| 602 | ** the graph. Each entry contains information for a single row: |
| 603 | ** |
| @@ -872,11 +871,10 @@ | |
| 872 | @ lastY = h; |
| 873 | @ } |
| 874 | @ setTimeout("checkHeight();", 1000); |
| 875 | @ } |
| 876 | @ checkHeight(); |
| 877 | @ /* ]]> */ |
| 878 | @ </script> |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | /* |
| @@ -2077,16 +2075,24 @@ | |
| 2077 | } |
| 2078 | |
| 2079 | /* |
| 2080 | ** A helper for the /reports family of pages which prints out a menu |
| 2081 | ** of links for the various type=XXX flags. zCurrentViewName must be |
| 2082 | ** the name/value of the 'view' parameter which is in effect at |
| 2083 | ** the time this is called. e.g. if called from the 'byuser' view |
| 2084 | ** then zCurrentViewName must be "byuser". |
| 2085 | */ |
| 2086 | static void stats_report_event_types_menu(char const * zCurrentViewName){ |
| 2087 | char * zTop = mprintf("%s/reports?view=%s", g.zTop, zCurrentViewName); |
| 2088 | cgi_printf("<div>"); |
| 2089 | cgi_printf("<span>Event types:</span> "); |
| 2090 | if('*' == statsReportType){ |
| 2091 | cgi_printf(" <strong>all</strong>", zTop); |
| 2092 | }else{ |
| @@ -2173,11 +2179,11 @@ | |
| 2173 | int nMaxEvents = 1; /* for calculating length of graph |
| 2174 | bars. */ |
| 2175 | int iterations = 0; /* number of weeks/months we iterate |
| 2176 | over */ |
| 2177 | stats_report_init_view(); |
| 2178 | stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear" ); |
| 2179 | blob_appendf(&header, "Timeline Events (%s) by year%s", |
| 2180 | stats_report_label_for_type(), |
| 2181 | (includeMonth ? "/month" : "")); |
| 2182 | blob_appendf(&sql, |
| 2183 | "SELECT substr(date(mtime),1,%d) AS timeframe, " |
| @@ -2232,11 +2238,11 @@ | |
| 2232 | if(showYearTotal){ |
| 2233 | rowClass = ++nRowNumber % 2; |
| 2234 | @ <tr class='row%d(rowClass)'> |
| 2235 | @ <td></td> |
| 2236 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2237 | @</tr> |
| 2238 | } |
| 2239 | nEventsPerYear = 0; |
| 2240 | memcpy(zPrevYear,zTimeframe,4); |
| 2241 | rowClass = ++nRowNumber % 2; |
| 2242 | @ <tr class='row%d(rowClass)'> |
| @@ -2270,12 +2276,12 @@ | |
| 2270 | cgi_printf("'>%s</a>", zTimeframe); |
| 2271 | } |
| 2272 | @ </td><td>%d(nCount)</td> |
| 2273 | @ <td> |
| 2274 | @ <div class='statistics-report-graph-line' |
| 2275 | @ style='height:16px;width:%d(nSize)%%;'> |
| 2276 | @ </div></td> |
| 2277 | @</tr> |
| 2278 | if(includeWeeks){ |
| 2279 | /* This part works fine for months but it terribly slow (4.5s on my PC), |
| 2280 | so it's only shown for by-year for now. Suggestions/patches for |
| 2281 | a better/faster layout are welcomed. */ |
| @@ -2296,11 +2302,11 @@ | |
| 2296 | /* Add final year total separator. */ |
| 2297 | rowClass = ++nRowNumber % 2; |
| 2298 | @ <tr class='row%d(rowClass)'> |
| 2299 | @ <td></td> |
| 2300 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2301 | @</tr> |
| 2302 | } |
| 2303 | @ </tbody></table> |
| 2304 | if(nEventTotal){ |
| 2305 | char const * zAvgLabel = includeMonth ? "month" : "year"; |
| 2306 | int nAvg = iterations ? (nEventTotal/iterations) : 0; |
| @@ -2324,11 +2330,11 @@ | |
| 2324 | row colors */ |
| 2325 | Blob sql = empty_blob; /* SQL */ |
| 2326 | int nMaxEvents = 1; /* max number of events for |
| 2327 | all rows. */ |
| 2328 | stats_report_init_view(); |
| 2329 | stats_report_event_types_menu("byuser"); |
| 2330 | blob_append(&sql, |
| 2331 | "SELECT user, " |
| 2332 | "COUNT(*) AS eventCount " |
| 2333 | "FROM v_reports " |
| 2334 | "GROUP BY user ORDER BY eventCount DESC", |
| @@ -2365,12 +2371,12 @@ | |
| 2365 | @ <td> |
| 2366 | @ <a href="?view=bymonth&user=%h(zUser)&type=%c((char)statsReportType)">%h(zUser)</a> |
| 2367 | @ </td><td>%d(nCount)</td> |
| 2368 | @ <td> |
| 2369 | @ <div class='statistics-report-graph-line' |
| 2370 | @ style='height:16px;width:%d(nSize)%%;'> |
| 2371 | @ </div></td> |
| 2372 | @</tr> |
| 2373 | /* |
| 2374 | Potential improvement: calculate the min/max event counts and |
| 2375 | use percent-based graph bars. |
| 2376 | */ |
| @@ -2395,21 +2401,28 @@ | |
| 2395 | Blob sql = empty_blob; |
| 2396 | int nMaxEvents = 1; /* max number of events for |
| 2397 | all rows. */ |
| 2398 | int iterations = 0; /* # of active time periods. */ |
| 2399 | stats_report_init_view(); |
| 2400 | stats_report_event_types_menu("byweek"); |
| 2401 | cgi_printf("Select year: "); |
| 2402 | blob_append(&sql, |
| 2403 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2404 | "FROM v_reports WHERE 1 ", -1); |
| 2405 | if(zUserName&&*zUserName){ |
| 2406 | blob_appendf(&sql,"AND user=%Q ", zUserName); |
| 2407 | } |
| 2408 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2409 | db_prepare(&qYears, blob_str(&sql)); |
| 2410 | blob_reset(&sql); |
| 2411 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2412 | const char * zT = db_column_text(&qYears, 0); |
| 2413 | if( i++ ){ |
| 2414 | cgi_printf(" "); |
| 2415 | } |
| @@ -2487,11 +2500,11 @@ | |
| 2487 | |
| 2488 | cgi_printf("<td>%d</td>",nCount); |
| 2489 | cgi_printf("<td>"); |
| 2490 | if(nCount){ |
| 2491 | cgi_printf("<div class='statistics-report-graph-line'" |
| 2492 | "style='height:16px;width:%d%%;'></div>", |
| 2493 | nSize); |
| 2494 | } |
| 2495 | cgi_printf("</td></tr>"); |
| 2496 | } |
| 2497 | db_finalize(&stWeek); |
| @@ -2529,13 +2542,15 @@ | |
| 2529 | */ |
| 2530 | void stats_report_page(){ |
| 2531 | HQuery url; /* URL for various branch links */ |
| 2532 | const char * zView = P("view"); /* Which view/report to show. */ |
| 2533 | const char *zUserName = P("user"); |
| 2534 | if(!zUserName) zUserName = P("u"); |
| 2535 | url_initialize(&url, "reports"); |
| 2536 | |
| 2537 | if(zUserName && *zUserName){ |
| 2538 | url_add_parameter(&url,"user", zUserName); |
| 2539 | timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user"); |
| 2540 | } |
| 2541 | timeline_submenu(&url, "By Year", "view", "byyear", 0); |
| 2542 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -247,14 +247,14 @@ | |
| 247 | int fchngQueryInit = 0; /* True if fchngQuery is initialized */ |
| 248 | Stmt fchngQuery; /* Query for file changes on check-ins */ |
| 249 | static Stmt qbranch; |
| 250 | int pendingEndTr = 0; /* True if a </td></tr> is needed */ |
| 251 | int vid = 0; /* Current checkout version */ |
| 252 | int dateFormat = 0; /* 0: HH:MM 1: HH:MM:SS |
| 253 | 2: YYYY-MM-DD HH:MM |
| 254 | 3: YYMMDD HH:MM */ |
| 255 | |
| 256 | if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){ |
| 257 | vid = db_lget_int("checkout", 0); |
| 258 | } |
| 259 | zPrevDate[0] = 0; |
| 260 | mxWikiLen = db_get_int("timeline-max-comment", 0); |
| @@ -591,13 +591,12 @@ | |
| 591 | ){ |
| 592 | if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){ |
| 593 | GraphRow *pRow; |
| 594 | int i; |
| 595 | char cSep; |
| 596 | |
| 597 | @ <script> |
| 598 | @ var railPitch=%d(pGraph->iRailPitch); |
| 599 | |
| 600 | /* the rowinfo[] array contains all the information needed to generate |
| 601 | ** the graph. Each entry contains information for a single row: |
| 602 | ** |
| @@ -872,11 +871,10 @@ | |
| 871 | @ lastY = h; |
| 872 | @ } |
| 873 | @ setTimeout("checkHeight();", 1000); |
| 874 | @ } |
| 875 | @ checkHeight(); |
| 876 | @ </script> |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | /* |
| @@ -2077,16 +2075,24 @@ | |
| 2075 | } |
| 2076 | |
| 2077 | /* |
| 2078 | ** A helper for the /reports family of pages which prints out a menu |
| 2079 | ** of links for the various type=XXX flags. zCurrentViewName must be |
| 2080 | ** the name/value of the 'view' parameter which is in effect at the |
| 2081 | ** time this is called. e.g. if called from the 'byuser' view then |
| 2082 | ** zCurrentViewName must be "byuser". Any URL parameters which need to |
| 2083 | ** be added to the generated URLs should be passed in zParam. The |
| 2084 | ** caller is expected to have already encoded any zParam in the %T or |
| 2085 | ** %t encoding. */ |
| 2086 | static void stats_report_event_types_menu(char const * zCurrentViewName, |
| 2087 | char const * zParam){ |
| 2088 | char * zTop; |
| 2089 | if(zParam && !*zParam){ |
| 2090 | zParam = NULL; |
| 2091 | } |
| 2092 | zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName, |
| 2093 | zParam ? "&" : "", zParam); |
| 2094 | cgi_printf("<div>"); |
| 2095 | cgi_printf("<span>Event types:</span> "); |
| 2096 | if('*' == statsReportType){ |
| 2097 | cgi_printf(" <strong>all</strong>", zTop); |
| 2098 | }else{ |
| @@ -2173,11 +2179,11 @@ | |
| 2179 | int nMaxEvents = 1; /* for calculating length of graph |
| 2180 | bars. */ |
| 2181 | int iterations = 0; /* number of weeks/months we iterate |
| 2182 | over */ |
| 2183 | stats_report_init_view(); |
| 2184 | stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear", NULL ); |
| 2185 | blob_appendf(&header, "Timeline Events (%s) by year%s", |
| 2186 | stats_report_label_for_type(), |
| 2187 | (includeMonth ? "/month" : "")); |
| 2188 | blob_appendf(&sql, |
| 2189 | "SELECT substr(date(mtime),1,%d) AS timeframe, " |
| @@ -2232,11 +2238,11 @@ | |
| 2238 | if(showYearTotal){ |
| 2239 | rowClass = ++nRowNumber % 2; |
| 2240 | @ <tr class='row%d(rowClass)'> |
| 2241 | @ <td></td> |
| 2242 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2243 | @</tr> |
| 2244 | } |
| 2245 | nEventsPerYear = 0; |
| 2246 | memcpy(zPrevYear,zTimeframe,4); |
| 2247 | rowClass = ++nRowNumber % 2; |
| 2248 | @ <tr class='row%d(rowClass)'> |
| @@ -2270,12 +2276,12 @@ | |
| 2276 | cgi_printf("'>%s</a>", zTimeframe); |
| 2277 | } |
| 2278 | @ </td><td>%d(nCount)</td> |
| 2279 | @ <td> |
| 2280 | @ <div class='statistics-report-graph-line' |
| 2281 | @ style='width:%d(nSize)%%;'> </div> |
| 2282 | @ </td> |
| 2283 | @</tr> |
| 2284 | if(includeWeeks){ |
| 2285 | /* This part works fine for months but it terribly slow (4.5s on my PC), |
| 2286 | so it's only shown for by-year for now. Suggestions/patches for |
| 2287 | a better/faster layout are welcomed. */ |
| @@ -2296,11 +2302,11 @@ | |
| 2302 | /* Add final year total separator. */ |
| 2303 | rowClass = ++nRowNumber % 2; |
| 2304 | @ <tr class='row%d(rowClass)'> |
| 2305 | @ <td></td> |
| 2306 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2307 | @</tr> |
| 2308 | } |
| 2309 | @ </tbody></table> |
| 2310 | if(nEventTotal){ |
| 2311 | char const * zAvgLabel = includeMonth ? "month" : "year"; |
| 2312 | int nAvg = iterations ? (nEventTotal/iterations) : 0; |
| @@ -2324,11 +2330,11 @@ | |
| 2330 | row colors */ |
| 2331 | Blob sql = empty_blob; /* SQL */ |
| 2332 | int nMaxEvents = 1; /* max number of events for |
| 2333 | all rows. */ |
| 2334 | stats_report_init_view(); |
| 2335 | stats_report_event_types_menu("byuser", NULL); |
| 2336 | blob_append(&sql, |
| 2337 | "SELECT user, " |
| 2338 | "COUNT(*) AS eventCount " |
| 2339 | "FROM v_reports " |
| 2340 | "GROUP BY user ORDER BY eventCount DESC", |
| @@ -2365,12 +2371,12 @@ | |
| 2371 | @ <td> |
| 2372 | @ <a href="?view=bymonth&user=%h(zUser)&type=%c((char)statsReportType)">%h(zUser)</a> |
| 2373 | @ </td><td>%d(nCount)</td> |
| 2374 | @ <td> |
| 2375 | @ <div class='statistics-report-graph-line' |
| 2376 | @ style='width:%d(nSize)%%;'> </div> |
| 2377 | @ </td> |
| 2378 | @</tr> |
| 2379 | /* |
| 2380 | Potential improvement: calculate the min/max event counts and |
| 2381 | use percent-based graph bars. |
| 2382 | */ |
| @@ -2395,21 +2401,28 @@ | |
| 2401 | Blob sql = empty_blob; |
| 2402 | int nMaxEvents = 1; /* max number of events for |
| 2403 | all rows. */ |
| 2404 | int iterations = 0; /* # of active time periods. */ |
| 2405 | stats_report_init_view(); |
| 2406 | if(4==nYear){ |
| 2407 | Blob urlParams = empty_blob; |
| 2408 | blob_appendf(&urlParams, "y=%T", zYear); |
| 2409 | stats_report_event_types_menu("byweek", blob_str(&urlParams)); |
| 2410 | blob_reset(&urlParams); |
| 2411 | }else{ |
| 2412 | stats_report_event_types_menu("byweek", NULL); |
| 2413 | } |
| 2414 | blob_append(&sql, |
| 2415 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2416 | "FROM v_reports WHERE 1 ", -1); |
| 2417 | if(zUserName&&*zUserName){ |
| 2418 | blob_appendf(&sql,"AND user=%Q ", zUserName); |
| 2419 | } |
| 2420 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2421 | db_prepare(&qYears, blob_str(&sql)); |
| 2422 | blob_reset(&sql); |
| 2423 | cgi_printf("Select year: "); |
| 2424 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2425 | const char * zT = db_column_text(&qYears, 0); |
| 2426 | if( i++ ){ |
| 2427 | cgi_printf(" "); |
| 2428 | } |
| @@ -2487,11 +2500,11 @@ | |
| 2500 | |
| 2501 | cgi_printf("<td>%d</td>",nCount); |
| 2502 | cgi_printf("<td>"); |
| 2503 | if(nCount){ |
| 2504 | cgi_printf("<div class='statistics-report-graph-line'" |
| 2505 | "style='width:%d%%;'> </div>", |
| 2506 | nSize); |
| 2507 | } |
| 2508 | cgi_printf("</td></tr>"); |
| 2509 | } |
| 2510 | db_finalize(&stWeek); |
| @@ -2529,13 +2542,15 @@ | |
| 2542 | */ |
| 2543 | void stats_report_page(){ |
| 2544 | HQuery url; /* URL for various branch links */ |
| 2545 | const char * zView = P("view"); /* Which view/report to show. */ |
| 2546 | const char *zUserName = P("user"); |
| 2547 | |
| 2548 | login_check_credentials(); |
| 2549 | if( !g.perm.Read ){ login_needed(); return; } |
| 2550 | if(!zUserName) zUserName = P("u"); |
| 2551 | url_initialize(&url, "reports"); |
| 2552 | if(zUserName && *zUserName){ |
| 2553 | url_add_parameter(&url,"user", zUserName); |
| 2554 | timeline_submenu(&url, "(Remove User Flag)", "view", zView, "user"); |
| 2555 | } |
| 2556 | timeline_submenu(&url, "By Year", "view", "byyear", 0); |
| 2557 |
+11
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -62,10 +62,13 @@ | ||
| 62 | 62 | char *passwd; /* Password for http: */ |
| 63 | 63 | char *canonical; /* Canonical representation of the URL */ |
| 64 | 64 | char *proxyAuth; /* Proxy-Authorizer: string */ |
| 65 | 65 | char *fossil; /* The fossil query parameter on ssh: */ |
| 66 | 66 | unsigned flags; /* Boolean flags controlling URL processing */ |
| 67 | + int useProxy; /* Used to remember that a proxy is in use */ | |
| 68 | + char *proxyUrlPath; | |
| 69 | + int proxyOrigPort; /* Tunneled port number for https through proxy */ | |
| 67 | 70 | }; |
| 68 | 71 | #endif /* INTERFACE */ |
| 69 | 72 | |
| 70 | 73 | |
| 71 | 74 | /* |
| @@ -120,10 +123,11 @@ | ||
| 120 | 123 | char *zLogin; |
| 121 | 124 | char *zExe; |
| 122 | 125 | char cQuerySep = '?'; |
| 123 | 126 | |
| 124 | 127 | pUrlData->isFile = 0; |
| 128 | + pUrlData->useProxy = 0; | |
| 125 | 129 | if( zUrl[4]=='s' ){ |
| 126 | 130 | pUrlData->isHttps = 1; |
| 127 | 131 | pUrlData->protocol = "https"; |
| 128 | 132 | pUrlData->dfltPort = 443; |
| 129 | 133 | iStart = 8; |
| @@ -384,12 +388,15 @@ | ||
| 384 | 388 | } |
| 385 | 389 | if( zProxy && zProxy[0] && !is_false(zProxy) |
| 386 | 390 | && !g.urlIsSsh && !g.urlIsFile ){ |
| 387 | 391 | char *zOriginalUrl = g.urlCanonical; |
| 388 | 392 | char *zOriginalHost = g.urlHostname; |
| 393 | + int fOriginalIsHttps = g.urlIsHttps; | |
| 389 | 394 | char *zOriginalUser = g.urlUser; |
| 390 | 395 | char *zOriginalPasswd = g.urlPasswd; |
| 396 | + char *zOriginalUrlPath = g.urlPath; | |
| 397 | + int iOriginalPort = g.urlPort; | |
| 391 | 398 | unsigned uOriginalFlags = g.urlFlags; |
| 392 | 399 | g.urlUser = 0; |
| 393 | 400 | g.urlPasswd = ""; |
| 394 | 401 | url_parse(zProxy, 0); |
| 395 | 402 | if( zMsg ) fossil_print("%s%s\n", zMsg, g.urlCanonical); |
| @@ -401,10 +408,14 @@ | ||
| 401 | 408 | g.urlProxyAuth = mprintf("Basic %z", zCredentials2); |
| 402 | 409 | free(zCredentials1); |
| 403 | 410 | } |
| 404 | 411 | g.urlUser = zOriginalUser; |
| 405 | 412 | g.urlPasswd = zOriginalPasswd; |
| 413 | + g.urlIsHttps = fOriginalIsHttps; | |
| 414 | + g.useProxy = 1; | |
| 415 | + g.proxyUrlPath = zOriginalUrlPath; | |
| 416 | + g.proxyOrigPort = iOriginalPort; | |
| 406 | 417 | g.urlFlags = uOriginalFlags; |
| 407 | 418 | } |
| 408 | 419 | } |
| 409 | 420 | |
| 410 | 421 | #if INTERFACE |
| 411 | 422 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -62,10 +62,13 @@ | |
| 62 | char *passwd; /* Password for http: */ |
| 63 | char *canonical; /* Canonical representation of the URL */ |
| 64 | char *proxyAuth; /* Proxy-Authorizer: string */ |
| 65 | char *fossil; /* The fossil query parameter on ssh: */ |
| 66 | unsigned flags; /* Boolean flags controlling URL processing */ |
| 67 | }; |
| 68 | #endif /* INTERFACE */ |
| 69 | |
| 70 | |
| 71 | /* |
| @@ -120,10 +123,11 @@ | |
| 120 | char *zLogin; |
| 121 | char *zExe; |
| 122 | char cQuerySep = '?'; |
| 123 | |
| 124 | pUrlData->isFile = 0; |
| 125 | if( zUrl[4]=='s' ){ |
| 126 | pUrlData->isHttps = 1; |
| 127 | pUrlData->protocol = "https"; |
| 128 | pUrlData->dfltPort = 443; |
| 129 | iStart = 8; |
| @@ -384,12 +388,15 @@ | |
| 384 | } |
| 385 | if( zProxy && zProxy[0] && !is_false(zProxy) |
| 386 | && !g.urlIsSsh && !g.urlIsFile ){ |
| 387 | char *zOriginalUrl = g.urlCanonical; |
| 388 | char *zOriginalHost = g.urlHostname; |
| 389 | char *zOriginalUser = g.urlUser; |
| 390 | char *zOriginalPasswd = g.urlPasswd; |
| 391 | unsigned uOriginalFlags = g.urlFlags; |
| 392 | g.urlUser = 0; |
| 393 | g.urlPasswd = ""; |
| 394 | url_parse(zProxy, 0); |
| 395 | if( zMsg ) fossil_print("%s%s\n", zMsg, g.urlCanonical); |
| @@ -401,10 +408,14 @@ | |
| 401 | g.urlProxyAuth = mprintf("Basic %z", zCredentials2); |
| 402 | free(zCredentials1); |
| 403 | } |
| 404 | g.urlUser = zOriginalUser; |
| 405 | g.urlPasswd = zOriginalPasswd; |
| 406 | g.urlFlags = uOriginalFlags; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | #if INTERFACE |
| 411 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -62,10 +62,13 @@ | |
| 62 | char *passwd; /* Password for http: */ |
| 63 | char *canonical; /* Canonical representation of the URL */ |
| 64 | char *proxyAuth; /* Proxy-Authorizer: string */ |
| 65 | char *fossil; /* The fossil query parameter on ssh: */ |
| 66 | unsigned flags; /* Boolean flags controlling URL processing */ |
| 67 | int useProxy; /* Used to remember that a proxy is in use */ |
| 68 | char *proxyUrlPath; |
| 69 | int proxyOrigPort; /* Tunneled port number for https through proxy */ |
| 70 | }; |
| 71 | #endif /* INTERFACE */ |
| 72 | |
| 73 | |
| 74 | /* |
| @@ -120,10 +123,11 @@ | |
| 123 | char *zLogin; |
| 124 | char *zExe; |
| 125 | char cQuerySep = '?'; |
| 126 | |
| 127 | pUrlData->isFile = 0; |
| 128 | pUrlData->useProxy = 0; |
| 129 | if( zUrl[4]=='s' ){ |
| 130 | pUrlData->isHttps = 1; |
| 131 | pUrlData->protocol = "https"; |
| 132 | pUrlData->dfltPort = 443; |
| 133 | iStart = 8; |
| @@ -384,12 +388,15 @@ | |
| 388 | } |
| 389 | if( zProxy && zProxy[0] && !is_false(zProxy) |
| 390 | && !g.urlIsSsh && !g.urlIsFile ){ |
| 391 | char *zOriginalUrl = g.urlCanonical; |
| 392 | char *zOriginalHost = g.urlHostname; |
| 393 | int fOriginalIsHttps = g.urlIsHttps; |
| 394 | char *zOriginalUser = g.urlUser; |
| 395 | char *zOriginalPasswd = g.urlPasswd; |
| 396 | char *zOriginalUrlPath = g.urlPath; |
| 397 | int iOriginalPort = g.urlPort; |
| 398 | unsigned uOriginalFlags = g.urlFlags; |
| 399 | g.urlUser = 0; |
| 400 | g.urlPasswd = ""; |
| 401 | url_parse(zProxy, 0); |
| 402 | if( zMsg ) fossil_print("%s%s\n", zMsg, g.urlCanonical); |
| @@ -401,10 +408,14 @@ | |
| 408 | g.urlProxyAuth = mprintf("Basic %z", zCredentials2); |
| 409 | free(zCredentials1); |
| 410 | } |
| 411 | g.urlUser = zOriginalUser; |
| 412 | g.urlPasswd = zOriginalPasswd; |
| 413 | g.urlIsHttps = fOriginalIsHttps; |
| 414 | g.useProxy = 1; |
| 415 | g.proxyUrlPath = zOriginalUrlPath; |
| 416 | g.proxyOrigPort = iOriginalPort; |
| 417 | g.urlFlags = uOriginalFlags; |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | #if INTERFACE |
| 422 |
+40
-33
| --- src/utf8.c | ||
| +++ src/utf8.c | ||
| @@ -177,11 +177,12 @@ | ||
| 177 | 177 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 178 | 178 | ** returned pointer when done. |
| 179 | 179 | ** |
| 180 | 180 | ** On Windows, characters in the range U+0001 to U+0031 and the |
| 181 | 181 | ** characters '"', '*', ':', '<', '>', '?' and '|' are invalid |
| 182 | -** to be used. Therefore, translate those to characters in the | |
| 182 | +** to be used, except in the 'extended path' prefix ('?') and | |
| 183 | +** as drive specifier (':'). Therefore, translate those to characters | |
| 183 | 184 | ** in the range U+F001 - U+F07F (private use area), so those |
| 184 | 185 | ** characters never arrive in any Windows API. The filenames might |
| 185 | 186 | ** look strange in Windows explorer, but in the cygwin shell |
| 186 | 187 | ** everything looks as expected. |
| 187 | 188 | ** |
| @@ -189,48 +190,54 @@ | ||
| 189 | 190 | ** |
| 190 | 191 | */ |
| 191 | 192 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 192 | 193 | #ifdef _WIN32 |
| 193 | 194 | int nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 194 | - /* Overallocate 6 chars, making some room for extended paths */ | |
| 195 | - wchar_t *zUnicode = sqlite3_malloc( (nChar+6) * sizeof(wchar_t) ); | |
| 195 | + /* Overallocate 4 chars, making some room for extended paths */ | |
| 196 | + wchar_t *zUnicode = sqlite3_malloc( (nChar+4) * sizeof(wchar_t) ); | |
| 196 | 197 | wchar_t *wUnicode = zUnicode; |
| 197 | 198 | if( zUnicode==0 ){ |
| 198 | 199 | return 0; |
| 199 | 200 | } |
| 201 | + MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); | |
| 202 | + /* | |
| 203 | + ** If path starts with "//?/" or "\\?\" (extended path), translate | |
| 204 | + ** any slashes to backslashes but leave the '?' intact | |
| 205 | + */ | |
| 206 | + if( (zUtf8[0]=='\\' || zUtf8[0]=='/') && (zUtf8[1]=='\\' || zUtf8[1]=='/') | |
| 207 | + && zUtf8[2]=='?' && (zUtf8[3]=='\\' || zUtf8[3]=='/')) { | |
| 208 | + wUnicode[0] = wUnicode[1] = wUnicode[3] = '\\'; | |
| 209 | + zUtf8 += 4; | |
| 210 | + wUnicode += 4; | |
| 211 | + } | |
| 212 | + /* | |
| 213 | + ** If (remainder of) path starts with "<drive>:/" or "<drive>:\", | |
| 214 | + ** leave the ':' intact | |
| 215 | + */ | |
| 200 | 216 | if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':' |
| 201 | 217 | && (zUtf8[2]=='\\' || zUtf8[2]=='/')) { |
| 202 | - /* If path starts with "<drive>:[/\]", don't process the ':' */ | |
| 203 | - if( nChar>MAX_PATH ) { | |
| 204 | - memcpy(zUnicode, L"\\\\?\\", 8); | |
| 205 | - wUnicode += 4; | |
| 206 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar); | |
| 207 | - wUnicode[2] = '\\'; | |
| 208 | - wUnicode += 3; | |
| 209 | - }else{ | |
| 210 | - zUnicode[0] = zUtf8[0]; | |
| 211 | - memcpy(&zUnicode[1], L":\\", 2 * sizeof(wchar_t)); | |
| 212 | - wUnicode += 3; | |
| 213 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8+3, -1, wUnicode, nChar-3); | |
| 214 | - } | |
| 215 | - }else if( (zUtf8[0]=='\\' || zUtf8[0]=='/') && | |
| 216 | - (zUtf8[1]=='\\' || zUtf8[1]=='/') ) { | |
| 217 | - if( zUtf8[2]=='?' && nChar>7 ){ | |
| 218 | - /* Don't postprocess [?:] in extended path, but do '/' -> '\' */ | |
| 219 | - memcpy(zUnicode, L"\\\\", 2 * sizeof(wchar_t)); | |
| 220 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, zUnicode+2, nChar-2); | |
| 221 | - if( zUtf8[3]=='/' ) zUnicode[3]='\\'; | |
| 222 | - wUnicode += 6; | |
| 223 | - }else if( nChar>MAX_PATH ){ | |
| 224 | - /* Convert to extended UNC path. */ | |
| 225 | - memcpy(zUnicode, L"\\\\?\\UNC\\", 16); | |
| 226 | - wUnicode += 8; | |
| 227 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, wUnicode, nChar-2); | |
| 228 | - }else{ | |
| 229 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); | |
| 230 | - } | |
| 231 | - } | |
| 218 | + if( wUnicode==zUnicode && nChar>MAX_PATH){ | |
| 219 | + /* | |
| 220 | + ** If there is no "\\?\" prefix but there is a drive | |
| 221 | + ** prefix and the path is larger than MAX_PATH chars, | |
| 222 | + ** no Win32 API function can handle that unless it is | |
| 223 | + ** prefixed with the extended path prefix. See: | |
| 224 | + ** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath> | |
| 225 | + **/ | |
| 226 | + memmove(wUnicode+4, wUnicode, nChar*sizeof(wchar_t)); | |
| 227 | + memcpy(wUnicode, L"\\\\?\\", 4*sizeof(wchar_t)); | |
| 228 | + wUnicode += 4; | |
| 229 | + } | |
| 230 | + wUnicode[2] = '\\'; | |
| 231 | + wUnicode += 3; | |
| 232 | + } | |
| 233 | + /* | |
| 234 | + ** In the remainder of the path, translate invalid characters to | |
| 235 | + ** characters in the Unicode private use area. This is what makes | |
| 236 | + ** Win32 fossil.exe work well in a Cygwin environment even when a | |
| 237 | + ** filename contains characters which are invalid for Win32. | |
| 238 | + */ | |
| 232 | 239 | while( *wUnicode != '\0' ){ |
| 233 | 240 | if ( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){ |
| 234 | 241 | *wUnicode |= 0xF000; |
| 235 | 242 | }else if( *wUnicode == '/' ){ |
| 236 | 243 | *wUnicode = '\\'; |
| 237 | 244 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -177,11 +177,12 @@ | |
| 177 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 178 | ** returned pointer when done. |
| 179 | ** |
| 180 | ** On Windows, characters in the range U+0001 to U+0031 and the |
| 181 | ** characters '"', '*', ':', '<', '>', '?' and '|' are invalid |
| 182 | ** to be used. Therefore, translate those to characters in the |
| 183 | ** in the range U+F001 - U+F07F (private use area), so those |
| 184 | ** characters never arrive in any Windows API. The filenames might |
| 185 | ** look strange in Windows explorer, but in the cygwin shell |
| 186 | ** everything looks as expected. |
| 187 | ** |
| @@ -189,48 +190,54 @@ | |
| 189 | ** |
| 190 | */ |
| 191 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 192 | #ifdef _WIN32 |
| 193 | int nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 194 | /* Overallocate 6 chars, making some room for extended paths */ |
| 195 | wchar_t *zUnicode = sqlite3_malloc( (nChar+6) * sizeof(wchar_t) ); |
| 196 | wchar_t *wUnicode = zUnicode; |
| 197 | if( zUnicode==0 ){ |
| 198 | return 0; |
| 199 | } |
| 200 | if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':' |
| 201 | && (zUtf8[2]=='\\' || zUtf8[2]=='/')) { |
| 202 | /* If path starts with "<drive>:[/\]", don't process the ':' */ |
| 203 | if( nChar>MAX_PATH ) { |
| 204 | memcpy(zUnicode, L"\\\\?\\", 8); |
| 205 | wUnicode += 4; |
| 206 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar); |
| 207 | wUnicode[2] = '\\'; |
| 208 | wUnicode += 3; |
| 209 | }else{ |
| 210 | zUnicode[0] = zUtf8[0]; |
| 211 | memcpy(&zUnicode[1], L":\\", 2 * sizeof(wchar_t)); |
| 212 | wUnicode += 3; |
| 213 | MultiByteToWideChar(CP_UTF8, 0, zUtf8+3, -1, wUnicode, nChar-3); |
| 214 | } |
| 215 | }else if( (zUtf8[0]=='\\' || zUtf8[0]=='/') && |
| 216 | (zUtf8[1]=='\\' || zUtf8[1]=='/') ) { |
| 217 | if( zUtf8[2]=='?' && nChar>7 ){ |
| 218 | /* Don't postprocess [?:] in extended path, but do '/' -> '\' */ |
| 219 | memcpy(zUnicode, L"\\\\", 2 * sizeof(wchar_t)); |
| 220 | MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, zUnicode+2, nChar-2); |
| 221 | if( zUtf8[3]=='/' ) zUnicode[3]='\\'; |
| 222 | wUnicode += 6; |
| 223 | }else if( nChar>MAX_PATH ){ |
| 224 | /* Convert to extended UNC path. */ |
| 225 | memcpy(zUnicode, L"\\\\?\\UNC\\", 16); |
| 226 | wUnicode += 8; |
| 227 | MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, wUnicode, nChar-2); |
| 228 | }else{ |
| 229 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); |
| 230 | } |
| 231 | } |
| 232 | while( *wUnicode != '\0' ){ |
| 233 | if ( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){ |
| 234 | *wUnicode |= 0xF000; |
| 235 | }else if( *wUnicode == '/' ){ |
| 236 | *wUnicode = '\\'; |
| 237 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -177,11 +177,12 @@ | |
| 177 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 178 | ** returned pointer when done. |
| 179 | ** |
| 180 | ** On Windows, characters in the range U+0001 to U+0031 and the |
| 181 | ** characters '"', '*', ':', '<', '>', '?' and '|' are invalid |
| 182 | ** to be used, except in the 'extended path' prefix ('?') and |
| 183 | ** as drive specifier (':'). Therefore, translate those to characters |
| 184 | ** in the range U+F001 - U+F07F (private use area), so those |
| 185 | ** characters never arrive in any Windows API. The filenames might |
| 186 | ** look strange in Windows explorer, but in the cygwin shell |
| 187 | ** everything looks as expected. |
| 188 | ** |
| @@ -189,48 +190,54 @@ | |
| 190 | ** |
| 191 | */ |
| 192 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 193 | #ifdef _WIN32 |
| 194 | int nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 195 | /* Overallocate 4 chars, making some room for extended paths */ |
| 196 | wchar_t *zUnicode = sqlite3_malloc( (nChar+4) * sizeof(wchar_t) ); |
| 197 | wchar_t *wUnicode = zUnicode; |
| 198 | if( zUnicode==0 ){ |
| 199 | return 0; |
| 200 | } |
| 201 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); |
| 202 | /* |
| 203 | ** If path starts with "//?/" or "\\?\" (extended path), translate |
| 204 | ** any slashes to backslashes but leave the '?' intact |
| 205 | */ |
| 206 | if( (zUtf8[0]=='\\' || zUtf8[0]=='/') && (zUtf8[1]=='\\' || zUtf8[1]=='/') |
| 207 | && zUtf8[2]=='?' && (zUtf8[3]=='\\' || zUtf8[3]=='/')) { |
| 208 | wUnicode[0] = wUnicode[1] = wUnicode[3] = '\\'; |
| 209 | zUtf8 += 4; |
| 210 | wUnicode += 4; |
| 211 | } |
| 212 | /* |
| 213 | ** If (remainder of) path starts with "<drive>:/" or "<drive>:\", |
| 214 | ** leave the ':' intact |
| 215 | */ |
| 216 | if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':' |
| 217 | && (zUtf8[2]=='\\' || zUtf8[2]=='/')) { |
| 218 | if( wUnicode==zUnicode && nChar>MAX_PATH){ |
| 219 | /* |
| 220 | ** If there is no "\\?\" prefix but there is a drive |
| 221 | ** prefix and the path is larger than MAX_PATH chars, |
| 222 | ** no Win32 API function can handle that unless it is |
| 223 | ** prefixed with the extended path prefix. See: |
| 224 | ** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath> |
| 225 | **/ |
| 226 | memmove(wUnicode+4, wUnicode, nChar*sizeof(wchar_t)); |
| 227 | memcpy(wUnicode, L"\\\\?\\", 4*sizeof(wchar_t)); |
| 228 | wUnicode += 4; |
| 229 | } |
| 230 | wUnicode[2] = '\\'; |
| 231 | wUnicode += 3; |
| 232 | } |
| 233 | /* |
| 234 | ** In the remainder of the path, translate invalid characters to |
| 235 | ** characters in the Unicode private use area. This is what makes |
| 236 | ** Win32 fossil.exe work well in a Cygwin environment even when a |
| 237 | ** filename contains characters which are invalid for Win32. |
| 238 | */ |
| 239 | while( *wUnicode != '\0' ){ |
| 240 | if ( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){ |
| 241 | *wUnicode |= 0xF000; |
| 242 | }else if( *wUnicode == '/' ){ |
| 243 | *wUnicode = '\\'; |
| 244 |
+40
-33
| --- src/utf8.c | ||
| +++ src/utf8.c | ||
| @@ -177,11 +177,12 @@ | ||
| 177 | 177 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 178 | 178 | ** returned pointer when done. |
| 179 | 179 | ** |
| 180 | 180 | ** On Windows, characters in the range U+0001 to U+0031 and the |
| 181 | 181 | ** characters '"', '*', ':', '<', '>', '?' and '|' are invalid |
| 182 | -** to be used. Therefore, translate those to characters in the | |
| 182 | +** to be used, except in the 'extended path' prefix ('?') and | |
| 183 | +** as drive specifier (':'). Therefore, translate those to characters | |
| 183 | 184 | ** in the range U+F001 - U+F07F (private use area), so those |
| 184 | 185 | ** characters never arrive in any Windows API. The filenames might |
| 185 | 186 | ** look strange in Windows explorer, but in the cygwin shell |
| 186 | 187 | ** everything looks as expected. |
| 187 | 188 | ** |
| @@ -189,48 +190,54 @@ | ||
| 189 | 190 | ** |
| 190 | 191 | */ |
| 191 | 192 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 192 | 193 | #ifdef _WIN32 |
| 193 | 194 | int nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 194 | - /* Overallocate 6 chars, making some room for extended paths */ | |
| 195 | - wchar_t *zUnicode = sqlite3_malloc( (nChar+6) * sizeof(wchar_t) ); | |
| 195 | + /* Overallocate 4 chars, making some room for extended paths */ | |
| 196 | + wchar_t *zUnicode = sqlite3_malloc( (nChar+4) * sizeof(wchar_t) ); | |
| 196 | 197 | wchar_t *wUnicode = zUnicode; |
| 197 | 198 | if( zUnicode==0 ){ |
| 198 | 199 | return 0; |
| 199 | 200 | } |
| 201 | + MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); | |
| 202 | + /* | |
| 203 | + ** If path starts with "//?/" or "\\?\" (extended path), translate | |
| 204 | + ** any slashes to backslashes but leave the '?' intact | |
| 205 | + */ | |
| 206 | + if( (zUtf8[0]=='\\' || zUtf8[0]=='/') && (zUtf8[1]=='\\' || zUtf8[1]=='/') | |
| 207 | + && zUtf8[2]=='?' && (zUtf8[3]=='\\' || zUtf8[3]=='/')) { | |
| 208 | + wUnicode[0] = wUnicode[1] = wUnicode[3] = '\\'; | |
| 209 | + zUtf8 += 4; | |
| 210 | + wUnicode += 4; | |
| 211 | + } | |
| 212 | + /* | |
| 213 | + ** If (remainder of) path starts with "<drive>:/" or "<drive>:\", | |
| 214 | + ** leave the ':' intact | |
| 215 | + */ | |
| 200 | 216 | if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':' |
| 201 | 217 | && (zUtf8[2]=='\\' || zUtf8[2]=='/')) { |
| 202 | - /* If path starts with "<drive>:[/\]", don't process the ':' */ | |
| 203 | - if( nChar>MAX_PATH ) { | |
| 204 | - memcpy(zUnicode, L"\\\\?\\", 8); | |
| 205 | - wUnicode += 4; | |
| 206 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar); | |
| 207 | - wUnicode[2] = '\\'; | |
| 208 | - wUnicode += 3; | |
| 209 | - }else{ | |
| 210 | - zUnicode[0] = zUtf8[0]; | |
| 211 | - memcpy(&zUnicode[1], L":\\", 2 * sizeof(wchar_t)); | |
| 212 | - wUnicode += 3; | |
| 213 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8+3, -1, wUnicode, nChar-3); | |
| 214 | - } | |
| 215 | - }else if( (zUtf8[0]=='\\' || zUtf8[0]=='/') && | |
| 216 | - (zUtf8[1]=='\\' || zUtf8[1]=='/') ) { | |
| 217 | - if( zUtf8[2]=='?' && nChar>7 ){ | |
| 218 | - /* Don't postprocess [?:] in extended path, but do '/' -> '\' */ | |
| 219 | - memcpy(zUnicode, L"\\\\", 2 * sizeof(wchar_t)); | |
| 220 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, zUnicode+2, nChar-2); | |
| 221 | - if( zUtf8[3]=='/' ) zUnicode[3]='\\'; | |
| 222 | - wUnicode += 6; | |
| 223 | - }else if( nChar>MAX_PATH ){ | |
| 224 | - /* Convert to extended UNC path. */ | |
| 225 | - memcpy(zUnicode, L"\\\\?\\UNC\\", 16); | |
| 226 | - wUnicode += 8; | |
| 227 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, wUnicode, nChar-2); | |
| 228 | - }else{ | |
| 229 | - MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); | |
| 230 | - } | |
| 231 | - } | |
| 218 | + if( wUnicode==zUnicode && nChar>MAX_PATH){ | |
| 219 | + /* | |
| 220 | + ** If there is no "\\?\" prefix but there is a drive | |
| 221 | + ** prefix and the path is larger than MAX_PATH chars, | |
| 222 | + ** no Win32 API function can handle that unless it is | |
| 223 | + ** prefixed with the extended path prefix. See: | |
| 224 | + ** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath> | |
| 225 | + **/ | |
| 226 | + memmove(wUnicode+4, wUnicode, nChar*sizeof(wchar_t)); | |
| 227 | + memcpy(wUnicode, L"\\\\?\\", 4*sizeof(wchar_t)); | |
| 228 | + wUnicode += 4; | |
| 229 | + } | |
| 230 | + wUnicode[2] = '\\'; | |
| 231 | + wUnicode += 3; | |
| 232 | + } | |
| 233 | + /* | |
| 234 | + ** In the remainder of the path, translate invalid characters to | |
| 235 | + ** characters in the Unicode private use area. This is what makes | |
| 236 | + ** Win32 fossil.exe work well in a Cygwin environment even when a | |
| 237 | + ** filename contains characters which are invalid for Win32. | |
| 238 | + */ | |
| 232 | 239 | while( *wUnicode != '\0' ){ |
| 233 | 240 | if ( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){ |
| 234 | 241 | *wUnicode |= 0xF000; |
| 235 | 242 | }else if( *wUnicode == '/' ){ |
| 236 | 243 | *wUnicode = '\\'; |
| 237 | 244 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -177,11 +177,12 @@ | |
| 177 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 178 | ** returned pointer when done. |
| 179 | ** |
| 180 | ** On Windows, characters in the range U+0001 to U+0031 and the |
| 181 | ** characters '"', '*', ':', '<', '>', '?' and '|' are invalid |
| 182 | ** to be used. Therefore, translate those to characters in the |
| 183 | ** in the range U+F001 - U+F07F (private use area), so those |
| 184 | ** characters never arrive in any Windows API. The filenames might |
| 185 | ** look strange in Windows explorer, but in the cygwin shell |
| 186 | ** everything looks as expected. |
| 187 | ** |
| @@ -189,48 +190,54 @@ | |
| 189 | ** |
| 190 | */ |
| 191 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 192 | #ifdef _WIN32 |
| 193 | int nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 194 | /* Overallocate 6 chars, making some room for extended paths */ |
| 195 | wchar_t *zUnicode = sqlite3_malloc( (nChar+6) * sizeof(wchar_t) ); |
| 196 | wchar_t *wUnicode = zUnicode; |
| 197 | if( zUnicode==0 ){ |
| 198 | return 0; |
| 199 | } |
| 200 | if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':' |
| 201 | && (zUtf8[2]=='\\' || zUtf8[2]=='/')) { |
| 202 | /* If path starts with "<drive>:[/\]", don't process the ':' */ |
| 203 | if( nChar>MAX_PATH ) { |
| 204 | memcpy(zUnicode, L"\\\\?\\", 8); |
| 205 | wUnicode += 4; |
| 206 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, wUnicode, nChar); |
| 207 | wUnicode[2] = '\\'; |
| 208 | wUnicode += 3; |
| 209 | }else{ |
| 210 | zUnicode[0] = zUtf8[0]; |
| 211 | memcpy(&zUnicode[1], L":\\", 2 * sizeof(wchar_t)); |
| 212 | wUnicode += 3; |
| 213 | MultiByteToWideChar(CP_UTF8, 0, zUtf8+3, -1, wUnicode, nChar-3); |
| 214 | } |
| 215 | }else if( (zUtf8[0]=='\\' || zUtf8[0]=='/') && |
| 216 | (zUtf8[1]=='\\' || zUtf8[1]=='/') ) { |
| 217 | if( zUtf8[2]=='?' && nChar>7 ){ |
| 218 | /* Don't postprocess [?:] in extended path, but do '/' -> '\' */ |
| 219 | memcpy(zUnicode, L"\\\\", 2 * sizeof(wchar_t)); |
| 220 | MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, zUnicode+2, nChar-2); |
| 221 | if( zUtf8[3]=='/' ) zUnicode[3]='\\'; |
| 222 | wUnicode += 6; |
| 223 | }else if( nChar>MAX_PATH ){ |
| 224 | /* Convert to extended UNC path. */ |
| 225 | memcpy(zUnicode, L"\\\\?\\UNC\\", 16); |
| 226 | wUnicode += 8; |
| 227 | MultiByteToWideChar(CP_UTF8, 0, zUtf8+2, -1, wUnicode, nChar-2); |
| 228 | }else{ |
| 229 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); |
| 230 | } |
| 231 | } |
| 232 | while( *wUnicode != '\0' ){ |
| 233 | if ( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){ |
| 234 | *wUnicode |= 0xF000; |
| 235 | }else if( *wUnicode == '/' ){ |
| 236 | *wUnicode = '\\'; |
| 237 |
| --- src/utf8.c | |
| +++ src/utf8.c | |
| @@ -177,11 +177,12 @@ | |
| 177 | ** Call fossil_filename_free() to deallocate any memory used to store the |
| 178 | ** returned pointer when done. |
| 179 | ** |
| 180 | ** On Windows, characters in the range U+0001 to U+0031 and the |
| 181 | ** characters '"', '*', ':', '<', '>', '?' and '|' are invalid |
| 182 | ** to be used, except in the 'extended path' prefix ('?') and |
| 183 | ** as drive specifier (':'). Therefore, translate those to characters |
| 184 | ** in the range U+F001 - U+F07F (private use area), so those |
| 185 | ** characters never arrive in any Windows API. The filenames might |
| 186 | ** look strange in Windows explorer, but in the cygwin shell |
| 187 | ** everything looks as expected. |
| 188 | ** |
| @@ -189,48 +190,54 @@ | |
| 190 | ** |
| 191 | */ |
| 192 | void *fossil_utf8_to_filename(const char *zUtf8){ |
| 193 | #ifdef _WIN32 |
| 194 | int nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, 0, 0); |
| 195 | /* Overallocate 4 chars, making some room for extended paths */ |
| 196 | wchar_t *zUnicode = sqlite3_malloc( (nChar+4) * sizeof(wchar_t) ); |
| 197 | wchar_t *wUnicode = zUnicode; |
| 198 | if( zUnicode==0 ){ |
| 199 | return 0; |
| 200 | } |
| 201 | MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar); |
| 202 | /* |
| 203 | ** If path starts with "//?/" or "\\?\" (extended path), translate |
| 204 | ** any slashes to backslashes but leave the '?' intact |
| 205 | */ |
| 206 | if( (zUtf8[0]=='\\' || zUtf8[0]=='/') && (zUtf8[1]=='\\' || zUtf8[1]=='/') |
| 207 | && zUtf8[2]=='?' && (zUtf8[3]=='\\' || zUtf8[3]=='/')) { |
| 208 | wUnicode[0] = wUnicode[1] = wUnicode[3] = '\\'; |
| 209 | zUtf8 += 4; |
| 210 | wUnicode += 4; |
| 211 | } |
| 212 | /* |
| 213 | ** If (remainder of) path starts with "<drive>:/" or "<drive>:\", |
| 214 | ** leave the ':' intact |
| 215 | */ |
| 216 | if( fossil_isalpha(zUtf8[0]) && zUtf8[1]==':' |
| 217 | && (zUtf8[2]=='\\' || zUtf8[2]=='/')) { |
| 218 | if( wUnicode==zUnicode && nChar>MAX_PATH){ |
| 219 | /* |
| 220 | ** If there is no "\\?\" prefix but there is a drive |
| 221 | ** prefix and the path is larger than MAX_PATH chars, |
| 222 | ** no Win32 API function can handle that unless it is |
| 223 | ** prefixed with the extended path prefix. See: |
| 224 | ** <http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath> |
| 225 | **/ |
| 226 | memmove(wUnicode+4, wUnicode, nChar*sizeof(wchar_t)); |
| 227 | memcpy(wUnicode, L"\\\\?\\", 4*sizeof(wchar_t)); |
| 228 | wUnicode += 4; |
| 229 | } |
| 230 | wUnicode[2] = '\\'; |
| 231 | wUnicode += 3; |
| 232 | } |
| 233 | /* |
| 234 | ** In the remainder of the path, translate invalid characters to |
| 235 | ** characters in the Unicode private use area. This is what makes |
| 236 | ** Win32 fossil.exe work well in a Cygwin environment even when a |
| 237 | ** filename contains characters which are invalid for Win32. |
| 238 | */ |
| 239 | while( *wUnicode != '\0' ){ |
| 240 | if ( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){ |
| 241 | *wUnicode |= 0xF000; |
| 242 | }else if( *wUnicode == '/' ){ |
| 243 | *wUnicode = '\\'; |
| 244 |
+12
-12
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -45,18 +45,18 @@ | ||
| 45 | 45 | ** does not exist, then return 0. |
| 46 | 46 | ** |
| 47 | 47 | ** For this routine, the UUID must be exact. For a match against |
| 48 | 48 | ** user input with mixed case, use resolve_uuid(). |
| 49 | 49 | ** |
| 50 | -** If the UUID is not found and phantomize is 1 or 2, then attempt to | |
| 50 | +** If the UUID is not found and phantomize is 1 or 2, then attempt to | |
| 51 | 51 | ** create a phantom record. A private phantom is created for 2 and |
| 52 | 52 | ** a public phantom is created for 1. |
| 53 | 53 | */ |
| 54 | 54 | int uuid_to_rid(const char *zUuid, int phantomize){ |
| 55 | 55 | int rid, sz; |
| 56 | 56 | char z[UUID_SIZE+1]; |
| 57 | - | |
| 57 | + | |
| 58 | 58 | sz = strlen(zUuid); |
| 59 | 59 | if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){ |
| 60 | 60 | return 0; |
| 61 | 61 | } |
| 62 | 62 | memcpy(z, zUuid, UUID_SIZE+1); |
| @@ -140,11 +140,11 @@ | ||
| 140 | 140 | ** the file has changed due to a merge. 3 means the file was added |
| 141 | 141 | ** by a merge. |
| 142 | 142 | ** |
| 143 | 143 | ** If VFILE.DELETED is true or if VFILE.RID is zero, then the file was either |
| 144 | 144 | ** removed from configuration management via "fossil rm" or added via |
| 145 | -** "fossil add", respectively, and in both cases we always know that | |
| 145 | +** "fossil add", respectively, and in both cases we always know that | |
| 146 | 146 | ** the file has changed without having the check the size, mtime, |
| 147 | 147 | ** or on-disk content. |
| 148 | 148 | ** |
| 149 | 149 | ** If the size of the file has changed, then we always know that the file |
| 150 | 150 | ** changed without having to look at the mtime or on-disk content. |
| @@ -315,11 +315,11 @@ | ||
| 315 | 315 | } |
| 316 | 316 | if( verbose ) fossil_print("%s\n", &zName[nRepos]); |
| 317 | 317 | if( file_wd_isdir(zName) == 1 ){ |
| 318 | 318 | /*TODO(dchest): remove directories? */ |
| 319 | 319 | fossil_fatal("%s is directory, cannot overwrite\n", zName); |
| 320 | - } | |
| 320 | + } | |
| 321 | 321 | if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(zName)) ){ |
| 322 | 322 | file_delete(zName); |
| 323 | 323 | } |
| 324 | 324 | if( isLink ){ |
| 325 | 325 | symlink_create(blob_str(&content), zName); |
| @@ -392,11 +392,11 @@ | ||
| 392 | 392 | "merge", |
| 393 | 393 | "original", |
| 394 | 394 | "output", |
| 395 | 395 | }; |
| 396 | 396 | int i, j, n; |
| 397 | - | |
| 397 | + | |
| 398 | 398 | if( strglob("ci-comment-????????????.txt", zName) ) return 1; |
| 399 | 399 | for(; zName[0]!=0; zName++){ |
| 400 | 400 | if( zName[0]=='/' && strglob("/ci-comment-????????????.txt", zName) ){ |
| 401 | 401 | return 1; |
| 402 | 402 | } |
| @@ -407,11 +407,11 @@ | ||
| 407 | 407 | if( zName[n+1]==0 ) return 1; |
| 408 | 408 | if( zName[n+1]=='-' ){ |
| 409 | 409 | for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){} |
| 410 | 410 | if( zName[j]==0 ) return 1; |
| 411 | 411 | } |
| 412 | - } | |
| 412 | + } | |
| 413 | 413 | } |
| 414 | 414 | return 0; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | #if INTERFACE |
| @@ -654,11 +654,11 @@ | ||
| 654 | 654 | FILE *in; |
| 655 | 655 | Stmt q; |
| 656 | 656 | char zBuf[4096]; |
| 657 | 657 | |
| 658 | 658 | db_must_be_within_tree(); |
| 659 | - db_prepare(&q, | |
| 659 | + db_prepare(&q, | |
| 660 | 660 | "SELECT %Q || pathname, pathname, origname, is_selected(id), rid" |
| 661 | 661 | " FROM vfile" |
| 662 | 662 | " WHERE (NOT deleted OR NOT is_selected(id)) AND vid=%d" |
| 663 | 663 | " ORDER BY if_selected(id, pathname, origname) /*scan*/", |
| 664 | 664 | g.zLocalRoot, vid |
| @@ -673,11 +673,11 @@ | ||
| 673 | 673 | md5sum_step_text(zName, -1); |
| 674 | 674 | if( file_wd_islink(zFullpath) ){ |
| 675 | 675 | /* Instead of file content, use link destination path */ |
| 676 | 676 | Blob pathBuf; |
| 677 | 677 | |
| 678 | - sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", | |
| 678 | + sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", | |
| 679 | 679 | blob_read_link(&pathBuf, zFullpath)); |
| 680 | 680 | md5sum_step_text(zBuf, -1); |
| 681 | 681 | md5sum_step_text(blob_str(&pathBuf), -1); |
| 682 | 682 | blob_reset(&pathBuf); |
| 683 | 683 | }else{ |
| @@ -743,13 +743,13 @@ | ||
| 743 | 743 | void vfile_compare_repository_to_disk(int vid){ |
| 744 | 744 | int rc; |
| 745 | 745 | Stmt q; |
| 746 | 746 | Blob disk, repo; |
| 747 | 747 | char *zOut; |
| 748 | - | |
| 748 | + | |
| 749 | 749 | db_must_be_within_tree(); |
| 750 | - db_prepare(&q, | |
| 750 | + db_prepare(&q, | |
| 751 | 751 | "SELECT %Q || pathname, pathname, rid FROM vfile" |
| 752 | 752 | " WHERE NOT deleted AND vid=%d AND is_selected(id)" |
| 753 | 753 | " ORDER BY if_selected(id, pathname, origname) /*scan*/", |
| 754 | 754 | g.zLocalRoot, vid |
| 755 | 755 | ); |
| @@ -809,11 +809,11 @@ | ||
| 809 | 809 | Blob file; |
| 810 | 810 | Stmt q; |
| 811 | 811 | char zBuf[100]; |
| 812 | 812 | |
| 813 | 813 | db_must_be_within_tree(); |
| 814 | - | |
| 814 | + | |
| 815 | 815 | db_prepare(&q, "SELECT pathname, origname, rid, is_selected(id)" |
| 816 | 816 | " FROM vfile" |
| 817 | 817 | " WHERE (NOT deleted OR NOT is_selected(id))" |
| 818 | 818 | " AND rid>0 AND vid=%d" |
| 819 | 819 | " ORDER BY if_selected(id,pathname,origname) /*scan*/", |
| @@ -847,11 +847,11 @@ | ||
| 847 | 847 | ** |
| 848 | 848 | ** If pManOut is not NULL then fill it with the checksum found in the |
| 849 | 849 | ** "R" card near the end of the manifest. |
| 850 | 850 | ** |
| 851 | 851 | ** In a well-formed manifest, the two checksums computed here, pOut and |
| 852 | -** pManOut, should be identical. | |
| 852 | +** pManOut, should be identical. | |
| 853 | 853 | */ |
| 854 | 854 | void vfile_aggregate_checksum_manifest(int vid, Blob *pOut, Blob *pManOut){ |
| 855 | 855 | int fid; |
| 856 | 856 | Blob file; |
| 857 | 857 | Blob err; |
| 858 | 858 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -45,18 +45,18 @@ | |
| 45 | ** does not exist, then return 0. |
| 46 | ** |
| 47 | ** For this routine, the UUID must be exact. For a match against |
| 48 | ** user input with mixed case, use resolve_uuid(). |
| 49 | ** |
| 50 | ** If the UUID is not found and phantomize is 1 or 2, then attempt to |
| 51 | ** create a phantom record. A private phantom is created for 2 and |
| 52 | ** a public phantom is created for 1. |
| 53 | */ |
| 54 | int uuid_to_rid(const char *zUuid, int phantomize){ |
| 55 | int rid, sz; |
| 56 | char z[UUID_SIZE+1]; |
| 57 | |
| 58 | sz = strlen(zUuid); |
| 59 | if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){ |
| 60 | return 0; |
| 61 | } |
| 62 | memcpy(z, zUuid, UUID_SIZE+1); |
| @@ -140,11 +140,11 @@ | |
| 140 | ** the file has changed due to a merge. 3 means the file was added |
| 141 | ** by a merge. |
| 142 | ** |
| 143 | ** If VFILE.DELETED is true or if VFILE.RID is zero, then the file was either |
| 144 | ** removed from configuration management via "fossil rm" or added via |
| 145 | ** "fossil add", respectively, and in both cases we always know that |
| 146 | ** the file has changed without having the check the size, mtime, |
| 147 | ** or on-disk content. |
| 148 | ** |
| 149 | ** If the size of the file has changed, then we always know that the file |
| 150 | ** changed without having to look at the mtime or on-disk content. |
| @@ -315,11 +315,11 @@ | |
| 315 | } |
| 316 | if( verbose ) fossil_print("%s\n", &zName[nRepos]); |
| 317 | if( file_wd_isdir(zName) == 1 ){ |
| 318 | /*TODO(dchest): remove directories? */ |
| 319 | fossil_fatal("%s is directory, cannot overwrite\n", zName); |
| 320 | } |
| 321 | if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(zName)) ){ |
| 322 | file_delete(zName); |
| 323 | } |
| 324 | if( isLink ){ |
| 325 | symlink_create(blob_str(&content), zName); |
| @@ -392,11 +392,11 @@ | |
| 392 | "merge", |
| 393 | "original", |
| 394 | "output", |
| 395 | }; |
| 396 | int i, j, n; |
| 397 | |
| 398 | if( strglob("ci-comment-????????????.txt", zName) ) return 1; |
| 399 | for(; zName[0]!=0; zName++){ |
| 400 | if( zName[0]=='/' && strglob("/ci-comment-????????????.txt", zName) ){ |
| 401 | return 1; |
| 402 | } |
| @@ -407,11 +407,11 @@ | |
| 407 | if( zName[n+1]==0 ) return 1; |
| 408 | if( zName[n+1]=='-' ){ |
| 409 | for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){} |
| 410 | if( zName[j]==0 ) return 1; |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | #if INTERFACE |
| @@ -654,11 +654,11 @@ | |
| 654 | FILE *in; |
| 655 | Stmt q; |
| 656 | char zBuf[4096]; |
| 657 | |
| 658 | db_must_be_within_tree(); |
| 659 | db_prepare(&q, |
| 660 | "SELECT %Q || pathname, pathname, origname, is_selected(id), rid" |
| 661 | " FROM vfile" |
| 662 | " WHERE (NOT deleted OR NOT is_selected(id)) AND vid=%d" |
| 663 | " ORDER BY if_selected(id, pathname, origname) /*scan*/", |
| 664 | g.zLocalRoot, vid |
| @@ -673,11 +673,11 @@ | |
| 673 | md5sum_step_text(zName, -1); |
| 674 | if( file_wd_islink(zFullpath) ){ |
| 675 | /* Instead of file content, use link destination path */ |
| 676 | Blob pathBuf; |
| 677 | |
| 678 | sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", |
| 679 | blob_read_link(&pathBuf, zFullpath)); |
| 680 | md5sum_step_text(zBuf, -1); |
| 681 | md5sum_step_text(blob_str(&pathBuf), -1); |
| 682 | blob_reset(&pathBuf); |
| 683 | }else{ |
| @@ -743,13 +743,13 @@ | |
| 743 | void vfile_compare_repository_to_disk(int vid){ |
| 744 | int rc; |
| 745 | Stmt q; |
| 746 | Blob disk, repo; |
| 747 | char *zOut; |
| 748 | |
| 749 | db_must_be_within_tree(); |
| 750 | db_prepare(&q, |
| 751 | "SELECT %Q || pathname, pathname, rid FROM vfile" |
| 752 | " WHERE NOT deleted AND vid=%d AND is_selected(id)" |
| 753 | " ORDER BY if_selected(id, pathname, origname) /*scan*/", |
| 754 | g.zLocalRoot, vid |
| 755 | ); |
| @@ -809,11 +809,11 @@ | |
| 809 | Blob file; |
| 810 | Stmt q; |
| 811 | char zBuf[100]; |
| 812 | |
| 813 | db_must_be_within_tree(); |
| 814 | |
| 815 | db_prepare(&q, "SELECT pathname, origname, rid, is_selected(id)" |
| 816 | " FROM vfile" |
| 817 | " WHERE (NOT deleted OR NOT is_selected(id))" |
| 818 | " AND rid>0 AND vid=%d" |
| 819 | " ORDER BY if_selected(id,pathname,origname) /*scan*/", |
| @@ -847,11 +847,11 @@ | |
| 847 | ** |
| 848 | ** If pManOut is not NULL then fill it with the checksum found in the |
| 849 | ** "R" card near the end of the manifest. |
| 850 | ** |
| 851 | ** In a well-formed manifest, the two checksums computed here, pOut and |
| 852 | ** pManOut, should be identical. |
| 853 | */ |
| 854 | void vfile_aggregate_checksum_manifest(int vid, Blob *pOut, Blob *pManOut){ |
| 855 | int fid; |
| 856 | Blob file; |
| 857 | Blob err; |
| 858 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -45,18 +45,18 @@ | |
| 45 | ** does not exist, then return 0. |
| 46 | ** |
| 47 | ** For this routine, the UUID must be exact. For a match against |
| 48 | ** user input with mixed case, use resolve_uuid(). |
| 49 | ** |
| 50 | ** If the UUID is not found and phantomize is 1 or 2, then attempt to |
| 51 | ** create a phantom record. A private phantom is created for 2 and |
| 52 | ** a public phantom is created for 1. |
| 53 | */ |
| 54 | int uuid_to_rid(const char *zUuid, int phantomize){ |
| 55 | int rid, sz; |
| 56 | char z[UUID_SIZE+1]; |
| 57 | |
| 58 | sz = strlen(zUuid); |
| 59 | if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){ |
| 60 | return 0; |
| 61 | } |
| 62 | memcpy(z, zUuid, UUID_SIZE+1); |
| @@ -140,11 +140,11 @@ | |
| 140 | ** the file has changed due to a merge. 3 means the file was added |
| 141 | ** by a merge. |
| 142 | ** |
| 143 | ** If VFILE.DELETED is true or if VFILE.RID is zero, then the file was either |
| 144 | ** removed from configuration management via "fossil rm" or added via |
| 145 | ** "fossil add", respectively, and in both cases we always know that |
| 146 | ** the file has changed without having the check the size, mtime, |
| 147 | ** or on-disk content. |
| 148 | ** |
| 149 | ** If the size of the file has changed, then we always know that the file |
| 150 | ** changed without having to look at the mtime or on-disk content. |
| @@ -315,11 +315,11 @@ | |
| 315 | } |
| 316 | if( verbose ) fossil_print("%s\n", &zName[nRepos]); |
| 317 | if( file_wd_isdir(zName) == 1 ){ |
| 318 | /*TODO(dchest): remove directories? */ |
| 319 | fossil_fatal("%s is directory, cannot overwrite\n", zName); |
| 320 | } |
| 321 | if( file_wd_size(zName)>=0 && (isLink || file_wd_islink(zName)) ){ |
| 322 | file_delete(zName); |
| 323 | } |
| 324 | if( isLink ){ |
| 325 | symlink_create(blob_str(&content), zName); |
| @@ -392,11 +392,11 @@ | |
| 392 | "merge", |
| 393 | "original", |
| 394 | "output", |
| 395 | }; |
| 396 | int i, j, n; |
| 397 | |
| 398 | if( strglob("ci-comment-????????????.txt", zName) ) return 1; |
| 399 | for(; zName[0]!=0; zName++){ |
| 400 | if( zName[0]=='/' && strglob("/ci-comment-????????????.txt", zName) ){ |
| 401 | return 1; |
| 402 | } |
| @@ -407,11 +407,11 @@ | |
| 407 | if( zName[n+1]==0 ) return 1; |
| 408 | if( zName[n+1]=='-' ){ |
| 409 | for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){} |
| 410 | if( zName[j]==0 ) return 1; |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | #if INTERFACE |
| @@ -654,11 +654,11 @@ | |
| 654 | FILE *in; |
| 655 | Stmt q; |
| 656 | char zBuf[4096]; |
| 657 | |
| 658 | db_must_be_within_tree(); |
| 659 | db_prepare(&q, |
| 660 | "SELECT %Q || pathname, pathname, origname, is_selected(id), rid" |
| 661 | " FROM vfile" |
| 662 | " WHERE (NOT deleted OR NOT is_selected(id)) AND vid=%d" |
| 663 | " ORDER BY if_selected(id, pathname, origname) /*scan*/", |
| 664 | g.zLocalRoot, vid |
| @@ -673,11 +673,11 @@ | |
| 673 | md5sum_step_text(zName, -1); |
| 674 | if( file_wd_islink(zFullpath) ){ |
| 675 | /* Instead of file content, use link destination path */ |
| 676 | Blob pathBuf; |
| 677 | |
| 678 | sqlite3_snprintf(sizeof(zBuf), zBuf, " %ld\n", |
| 679 | blob_read_link(&pathBuf, zFullpath)); |
| 680 | md5sum_step_text(zBuf, -1); |
| 681 | md5sum_step_text(blob_str(&pathBuf), -1); |
| 682 | blob_reset(&pathBuf); |
| 683 | }else{ |
| @@ -743,13 +743,13 @@ | |
| 743 | void vfile_compare_repository_to_disk(int vid){ |
| 744 | int rc; |
| 745 | Stmt q; |
| 746 | Blob disk, repo; |
| 747 | char *zOut; |
| 748 | |
| 749 | db_must_be_within_tree(); |
| 750 | db_prepare(&q, |
| 751 | "SELECT %Q || pathname, pathname, rid FROM vfile" |
| 752 | " WHERE NOT deleted AND vid=%d AND is_selected(id)" |
| 753 | " ORDER BY if_selected(id, pathname, origname) /*scan*/", |
| 754 | g.zLocalRoot, vid |
| 755 | ); |
| @@ -809,11 +809,11 @@ | |
| 809 | Blob file; |
| 810 | Stmt q; |
| 811 | char zBuf[100]; |
| 812 | |
| 813 | db_must_be_within_tree(); |
| 814 | |
| 815 | db_prepare(&q, "SELECT pathname, origname, rid, is_selected(id)" |
| 816 | " FROM vfile" |
| 817 | " WHERE (NOT deleted OR NOT is_selected(id))" |
| 818 | " AND rid>0 AND vid=%d" |
| 819 | " ORDER BY if_selected(id,pathname,origname) /*scan*/", |
| @@ -847,11 +847,11 @@ | |
| 847 | ** |
| 848 | ** If pManOut is not NULL then fill it with the checksum found in the |
| 849 | ** "R" card near the end of the manifest. |
| 850 | ** |
| 851 | ** In a well-formed manifest, the two checksums computed here, pOut and |
| 852 | ** pManOut, should be identical. |
| 853 | */ |
| 854 | void vfile_aggregate_checksum_manifest(int vid, Blob *pOut, Blob *pManOut){ |
| 855 | int fid; |
| 856 | Blob file; |
| 857 | Blob err; |
| 858 |
+14
-14
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -222,11 +222,11 @@ | ||
| 222 | 222 | zBody = db_get("sandbox",zBody); |
| 223 | 223 | zMimetype = db_get("sandbox-mimetype","text/x-fossil-wiki"); |
| 224 | 224 | rid = 0; |
| 225 | 225 | }else{ |
| 226 | 226 | zTag = mprintf("wiki-%s", zPageName); |
| 227 | - rid = db_int(0, | |
| 227 | + rid = db_int(0, | |
| 228 | 228 | "SELECT rid FROM tagxref" |
| 229 | 229 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 230 | 230 | " ORDER BY mtime DESC", zTag |
| 231 | 231 | ); |
| 232 | 232 | free(zTag); |
| @@ -260,11 +260,11 @@ | ||
| 260 | 260 | style_submenu_element("Attach", "Add An Attachment", |
| 261 | 261 | "%s/attachadd?page=%T&from=%s/wiki%%3fname=%T", |
| 262 | 262 | g.zTop, zPageName, g.zTop, zPageName); |
| 263 | 263 | } |
| 264 | 264 | if( rid && g.perm.ApndWiki ){ |
| 265 | - style_submenu_element("Append", "Add A Comment", | |
| 265 | + style_submenu_element("Append", "Add A Comment", | |
| 266 | 266 | "%s/wikiappend?name=%T&mimetype=%s", |
| 267 | 267 | g.zTop, zPageName, zMimetype); |
| 268 | 268 | } |
| 269 | 269 | if( g.perm.Hyperlink ){ |
| 270 | 270 | style_submenu_element("History", "History", "%s/whistory?name=%T", |
| @@ -300,11 +300,11 @@ | ||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /* |
| 303 | 303 | ** Formal names and common names for the various wiki styles. |
| 304 | 304 | */ |
| 305 | -static const char *azStyles[] = { | |
| 305 | +static const char *const azStyles[] = { | |
| 306 | 306 | "text/x-fossil-wiki", "Fossil Wiki", |
| 307 | 307 | "text/x-markdown", "Markdown", |
| 308 | 308 | "text/plain", "Plain Text" |
| 309 | 309 | }; |
| 310 | 310 | |
| @@ -381,11 +381,11 @@ | ||
| 381 | 381 | zBody = db_get("sandbox",""); |
| 382 | 382 | zMimetype = db_get("sandbox-mimetype","text/x-fossil-wiki"); |
| 383 | 383 | } |
| 384 | 384 | }else{ |
| 385 | 385 | zTag = mprintf("wiki-%s", zPageName); |
| 386 | - rid = db_int(0, | |
| 386 | + rid = db_int(0, | |
| 387 | 387 | "SELECT rid FROM tagxref" |
| 388 | 388 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 389 | 389 | " ORDER BY mtime DESC", zTag |
| 390 | 390 | ); |
| 391 | 391 | free(zTag); |
| @@ -462,11 +462,11 @@ | ||
| 462 | 462 | if( !isWysiwyg ){ |
| 463 | 463 | /* Traditional markup-only editing */ |
| 464 | 464 | form_begin(0, "%R/wikiedit"); |
| 465 | 465 | @ <div> |
| 466 | 466 | mimetype_option_menu(zMimetype); |
| 467 | - @ <br /><textarea name="w" class="wikiedit" cols="80" | |
| 467 | + @ <br /><textarea name="w" class="wikiedit" cols="80" | |
| 468 | 468 | @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea> |
| 469 | 469 | @ <br /> |
| 470 | 470 | if( db_get_boolean("wysiwyg-wiki", 0) ){ |
| 471 | 471 | @ <input type="submit" name="edit-wysiwyg" value="Wysiwyg Editor" |
| 472 | 472 | @ onclick='return confirm("Switching to WYSIWYG-mode\nwill erase your markup\nedits. Continue?")' /> |
| @@ -514,11 +514,11 @@ | ||
| 514 | 514 | const char *zMimetype; |
| 515 | 515 | login_check_credentials(); |
| 516 | 516 | if( !g.perm.NewWiki ){ |
| 517 | 517 | login_needed(); |
| 518 | 518 | return; |
| 519 | - } | |
| 519 | + } | |
| 520 | 520 | zName = PD("name",""); |
| 521 | 521 | zMimetype = wiki_filter_mimetypes(P("mimetype")); |
| 522 | 522 | if( zName[0] && wiki_name_is_wellformed((const unsigned char *)zName) ){ |
| 523 | 523 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 |
| 524 | 524 | && db_get_boolean("wysiwyg-wiki", 0) |
| @@ -557,11 +557,11 @@ | ||
| 557 | 557 | zDate = db_text(0, "SELECT datetime('now')"); |
| 558 | 558 | zRemark = PD("r",""); |
| 559 | 559 | zUser = PD("u",g.zLogin); |
| 560 | 560 | if( fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0 ){ |
| 561 | 561 | zId = db_text(0, "SELECT lower(hex(randomblob(8)))"); |
| 562 | - blob_appendf(p, "\n\n<hr><div id=\"%s\"><i>On %s UTC %h", | |
| 562 | + blob_appendf(p, "\n\n<hr><div id=\"%s\"><i>On %s UTC %h", | |
| 563 | 563 | zId, zDate, g.zLogin); |
| 564 | 564 | if( zUser[0] && fossil_strcmp(zUser,g.zLogin) ){ |
| 565 | 565 | blob_appendf(p, " (claiming to be %h)", zUser); |
| 566 | 566 | } |
| 567 | 567 | blob_appendf(p, " added:</i><br />\n%s</div id=\"%s\">", zRemark, zId); |
| @@ -601,11 +601,11 @@ | ||
| 601 | 601 | zMimetype = wiki_filter_mimetypes(P("mimetype")); |
| 602 | 602 | if( check_name(zPageName) ) return; |
| 603 | 603 | isSandbox = is_sandbox(zPageName); |
| 604 | 604 | if( !isSandbox ){ |
| 605 | 605 | zTag = mprintf("wiki-%s", zPageName); |
| 606 | - rid = db_int(0, | |
| 606 | + rid = db_int(0, | |
| 607 | 607 | "SELECT rid FROM tagxref" |
| 608 | 608 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 609 | 609 | " ORDER BY mtime DESC", zTag |
| 610 | 610 | ); |
| 611 | 611 | free(zTag); |
| @@ -690,11 +690,11 @@ | ||
| 690 | 690 | @ <input type="hidden" name="mimetype" value="%h(zMimetype)" /> |
| 691 | 691 | @ Your Name: |
| 692 | 692 | @ <input type="text" name="u" size="20" value="%h(zUser)" /><br /> |
| 693 | 693 | zFormat = mimetype_common_name(zMimetype); |
| 694 | 694 | @ Comment to append (formatted as %s(zFormat)):<br /> |
| 695 | - @ <textarea name="r" class="wikiedit" cols="80" | |
| 695 | + @ <textarea name="r" class="wikiedit" cols="80" | |
| 696 | 696 | @ rows="10" wrap="virtual">%h(PD("r",""))</textarea> |
| 697 | 697 | @ <br /> |
| 698 | 698 | @ <input type="submit" name="preview" value="Preview Your Comment" /> |
| 699 | 699 | @ <input type="submit" name="submit" value="Append Your Changes" /> |
| 700 | 700 | @ <input type="submit" name="cancel" value="Cancel" /> |
| @@ -809,11 +809,11 @@ | ||
| 809 | 809 | ** - tagxref (whatever that really is!) |
| 810 | 810 | ** |
| 811 | 811 | ** Used by wcontent_page() and the JSON wiki code. |
| 812 | 812 | */ |
| 813 | 813 | void wiki_prepare_page_list( Stmt * pStmt ){ |
| 814 | - db_prepare(pStmt, | |
| 814 | + db_prepare(pStmt, | |
| 815 | 815 | "SELECT" |
| 816 | 816 | " substr(tagname, 6) as name," |
| 817 | 817 | " (SELECT value FROM tagxref WHERE tagid=tag.tagid ORDER BY mtime DESC) as tagXref" |
| 818 | 818 | " FROM tag WHERE tagname GLOB 'wiki-*'" |
| 819 | 819 | " ORDER BY lower(tagname) /*sort*/" |
| @@ -866,11 +866,11 @@ | ||
| 866 | 866 | login_check_credentials(); |
| 867 | 867 | if( !g.perm.RdWiki ){ login_needed(); return; } |
| 868 | 868 | zTitle = PD("title","*"); |
| 869 | 869 | style_header("Wiki Pages Found"); |
| 870 | 870 | @ <ul> |
| 871 | - db_prepare(&q, | |
| 871 | + db_prepare(&q, | |
| 872 | 872 | "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'" |
| 873 | 873 | " ORDER BY lower(tagname) /*sort*/" , |
| 874 | 874 | zTitle); |
| 875 | 875 | while( db_step(&q)==SQLITE_ROW ){ |
| 876 | 876 | const char *zName = db_column_text(&q, 0); |
| @@ -917,11 +917,11 @@ | ||
| 917 | 917 | @ surrounded on both sides by two or more spaces or by a tab. Only a single |
| 918 | 918 | @ level of enumeration list is supported by wiki. For nested lists or for |
| 919 | 919 | @ enumerations that count using letters or roman numerials, use HTML.</p></li> |
| 920 | 920 | @ <li> <p><span class="wikiruleHead">Indented Paragraphs</span>. |
| 921 | 921 | @ Any paragraph that begins with two or more spaces or a tab and |
| 922 | - @ which is not a bullet or enumeration list item is rendered | |
| 922 | + @ which is not a bullet or enumeration list item is rendered | |
| 923 | 923 | @ indented. Only a single level of indentation is supported by wiki; use |
| 924 | 924 | @ HTML for deeper indentation.</p></li> |
| 925 | 925 | @ <li> <p><span class="wikiruleHead">Hyperlinks</span>. |
| 926 | 926 | @ Text within square brackets ("[...]") becomes a hyperlink. The |
| 927 | 927 | @ target can be a wiki page name, the artifact ID of a check-in or ticket, |
| @@ -1062,11 +1062,11 @@ | ||
| 1062 | 1062 | } |
| 1063 | 1063 | zPageName = g.argv[3]; |
| 1064 | 1064 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| 1065 | 1065 | " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" |
| 1066 | 1066 | " ORDER BY x.mtime DESC LIMIT 1", |
| 1067 | - zPageName | |
| 1067 | + zPageName | |
| 1068 | 1068 | ); |
| 1069 | 1069 | if( (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0 ){ |
| 1070 | 1070 | zBody = pWiki->zWiki; |
| 1071 | 1071 | } |
| 1072 | 1072 | if( zBody==0 ){ |
| @@ -1110,11 +1110,11 @@ | ||
| 1110 | 1110 | } |
| 1111 | 1111 | fossil_fatal("delete not yet implemented."); |
| 1112 | 1112 | }else |
| 1113 | 1113 | if( strncmp(g.argv[2],"list",n)==0 ){ |
| 1114 | 1114 | Stmt q; |
| 1115 | - db_prepare(&q, | |
| 1115 | + db_prepare(&q, | |
| 1116 | 1116 | "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 1117 | 1117 | " ORDER BY lower(tagname) /*sort*/" |
| 1118 | 1118 | ); |
| 1119 | 1119 | while( db_step(&q)==SQLITE_ROW ){ |
| 1120 | 1120 | const char *zName = db_column_text(&q, 0); |
| 1121 | 1121 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -222,11 +222,11 @@ | |
| 222 | zBody = db_get("sandbox",zBody); |
| 223 | zMimetype = db_get("sandbox-mimetype","text/x-fossil-wiki"); |
| 224 | rid = 0; |
| 225 | }else{ |
| 226 | zTag = mprintf("wiki-%s", zPageName); |
| 227 | rid = db_int(0, |
| 228 | "SELECT rid FROM tagxref" |
| 229 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 230 | " ORDER BY mtime DESC", zTag |
| 231 | ); |
| 232 | free(zTag); |
| @@ -260,11 +260,11 @@ | |
| 260 | style_submenu_element("Attach", "Add An Attachment", |
| 261 | "%s/attachadd?page=%T&from=%s/wiki%%3fname=%T", |
| 262 | g.zTop, zPageName, g.zTop, zPageName); |
| 263 | } |
| 264 | if( rid && g.perm.ApndWiki ){ |
| 265 | style_submenu_element("Append", "Add A Comment", |
| 266 | "%s/wikiappend?name=%T&mimetype=%s", |
| 267 | g.zTop, zPageName, zMimetype); |
| 268 | } |
| 269 | if( g.perm.Hyperlink ){ |
| 270 | style_submenu_element("History", "History", "%s/whistory?name=%T", |
| @@ -300,11 +300,11 @@ | |
| 300 | } |
| 301 | |
| 302 | /* |
| 303 | ** Formal names and common names for the various wiki styles. |
| 304 | */ |
| 305 | static const char *azStyles[] = { |
| 306 | "text/x-fossil-wiki", "Fossil Wiki", |
| 307 | "text/x-markdown", "Markdown", |
| 308 | "text/plain", "Plain Text" |
| 309 | }; |
| 310 | |
| @@ -381,11 +381,11 @@ | |
| 381 | zBody = db_get("sandbox",""); |
| 382 | zMimetype = db_get("sandbox-mimetype","text/x-fossil-wiki"); |
| 383 | } |
| 384 | }else{ |
| 385 | zTag = mprintf("wiki-%s", zPageName); |
| 386 | rid = db_int(0, |
| 387 | "SELECT rid FROM tagxref" |
| 388 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 389 | " ORDER BY mtime DESC", zTag |
| 390 | ); |
| 391 | free(zTag); |
| @@ -462,11 +462,11 @@ | |
| 462 | if( !isWysiwyg ){ |
| 463 | /* Traditional markup-only editing */ |
| 464 | form_begin(0, "%R/wikiedit"); |
| 465 | @ <div> |
| 466 | mimetype_option_menu(zMimetype); |
| 467 | @ <br /><textarea name="w" class="wikiedit" cols="80" |
| 468 | @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea> |
| 469 | @ <br /> |
| 470 | if( db_get_boolean("wysiwyg-wiki", 0) ){ |
| 471 | @ <input type="submit" name="edit-wysiwyg" value="Wysiwyg Editor" |
| 472 | @ onclick='return confirm("Switching to WYSIWYG-mode\nwill erase your markup\nedits. Continue?")' /> |
| @@ -514,11 +514,11 @@ | |
| 514 | const char *zMimetype; |
| 515 | login_check_credentials(); |
| 516 | if( !g.perm.NewWiki ){ |
| 517 | login_needed(); |
| 518 | return; |
| 519 | } |
| 520 | zName = PD("name",""); |
| 521 | zMimetype = wiki_filter_mimetypes(P("mimetype")); |
| 522 | if( zName[0] && wiki_name_is_wellformed((const unsigned char *)zName) ){ |
| 523 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 |
| 524 | && db_get_boolean("wysiwyg-wiki", 0) |
| @@ -557,11 +557,11 @@ | |
| 557 | zDate = db_text(0, "SELECT datetime('now')"); |
| 558 | zRemark = PD("r",""); |
| 559 | zUser = PD("u",g.zLogin); |
| 560 | if( fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0 ){ |
| 561 | zId = db_text(0, "SELECT lower(hex(randomblob(8)))"); |
| 562 | blob_appendf(p, "\n\n<hr><div id=\"%s\"><i>On %s UTC %h", |
| 563 | zId, zDate, g.zLogin); |
| 564 | if( zUser[0] && fossil_strcmp(zUser,g.zLogin) ){ |
| 565 | blob_appendf(p, " (claiming to be %h)", zUser); |
| 566 | } |
| 567 | blob_appendf(p, " added:</i><br />\n%s</div id=\"%s\">", zRemark, zId); |
| @@ -601,11 +601,11 @@ | |
| 601 | zMimetype = wiki_filter_mimetypes(P("mimetype")); |
| 602 | if( check_name(zPageName) ) return; |
| 603 | isSandbox = is_sandbox(zPageName); |
| 604 | if( !isSandbox ){ |
| 605 | zTag = mprintf("wiki-%s", zPageName); |
| 606 | rid = db_int(0, |
| 607 | "SELECT rid FROM tagxref" |
| 608 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 609 | " ORDER BY mtime DESC", zTag |
| 610 | ); |
| 611 | free(zTag); |
| @@ -690,11 +690,11 @@ | |
| 690 | @ <input type="hidden" name="mimetype" value="%h(zMimetype)" /> |
| 691 | @ Your Name: |
| 692 | @ <input type="text" name="u" size="20" value="%h(zUser)" /><br /> |
| 693 | zFormat = mimetype_common_name(zMimetype); |
| 694 | @ Comment to append (formatted as %s(zFormat)):<br /> |
| 695 | @ <textarea name="r" class="wikiedit" cols="80" |
| 696 | @ rows="10" wrap="virtual">%h(PD("r",""))</textarea> |
| 697 | @ <br /> |
| 698 | @ <input type="submit" name="preview" value="Preview Your Comment" /> |
| 699 | @ <input type="submit" name="submit" value="Append Your Changes" /> |
| 700 | @ <input type="submit" name="cancel" value="Cancel" /> |
| @@ -809,11 +809,11 @@ | |
| 809 | ** - tagxref (whatever that really is!) |
| 810 | ** |
| 811 | ** Used by wcontent_page() and the JSON wiki code. |
| 812 | */ |
| 813 | void wiki_prepare_page_list( Stmt * pStmt ){ |
| 814 | db_prepare(pStmt, |
| 815 | "SELECT" |
| 816 | " substr(tagname, 6) as name," |
| 817 | " (SELECT value FROM tagxref WHERE tagid=tag.tagid ORDER BY mtime DESC) as tagXref" |
| 818 | " FROM tag WHERE tagname GLOB 'wiki-*'" |
| 819 | " ORDER BY lower(tagname) /*sort*/" |
| @@ -866,11 +866,11 @@ | |
| 866 | login_check_credentials(); |
| 867 | if( !g.perm.RdWiki ){ login_needed(); return; } |
| 868 | zTitle = PD("title","*"); |
| 869 | style_header("Wiki Pages Found"); |
| 870 | @ <ul> |
| 871 | db_prepare(&q, |
| 872 | "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'" |
| 873 | " ORDER BY lower(tagname) /*sort*/" , |
| 874 | zTitle); |
| 875 | while( db_step(&q)==SQLITE_ROW ){ |
| 876 | const char *zName = db_column_text(&q, 0); |
| @@ -917,11 +917,11 @@ | |
| 917 | @ surrounded on both sides by two or more spaces or by a tab. Only a single |
| 918 | @ level of enumeration list is supported by wiki. For nested lists or for |
| 919 | @ enumerations that count using letters or roman numerials, use HTML.</p></li> |
| 920 | @ <li> <p><span class="wikiruleHead">Indented Paragraphs</span>. |
| 921 | @ Any paragraph that begins with two or more spaces or a tab and |
| 922 | @ which is not a bullet or enumeration list item is rendered |
| 923 | @ indented. Only a single level of indentation is supported by wiki; use |
| 924 | @ HTML for deeper indentation.</p></li> |
| 925 | @ <li> <p><span class="wikiruleHead">Hyperlinks</span>. |
| 926 | @ Text within square brackets ("[...]") becomes a hyperlink. The |
| 927 | @ target can be a wiki page name, the artifact ID of a check-in or ticket, |
| @@ -1062,11 +1062,11 @@ | |
| 1062 | } |
| 1063 | zPageName = g.argv[3]; |
| 1064 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| 1065 | " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" |
| 1066 | " ORDER BY x.mtime DESC LIMIT 1", |
| 1067 | zPageName |
| 1068 | ); |
| 1069 | if( (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0 ){ |
| 1070 | zBody = pWiki->zWiki; |
| 1071 | } |
| 1072 | if( zBody==0 ){ |
| @@ -1110,11 +1110,11 @@ | |
| 1110 | } |
| 1111 | fossil_fatal("delete not yet implemented."); |
| 1112 | }else |
| 1113 | if( strncmp(g.argv[2],"list",n)==0 ){ |
| 1114 | Stmt q; |
| 1115 | db_prepare(&q, |
| 1116 | "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 1117 | " ORDER BY lower(tagname) /*sort*/" |
| 1118 | ); |
| 1119 | while( db_step(&q)==SQLITE_ROW ){ |
| 1120 | const char *zName = db_column_text(&q, 0); |
| 1121 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -222,11 +222,11 @@ | |
| 222 | zBody = db_get("sandbox",zBody); |
| 223 | zMimetype = db_get("sandbox-mimetype","text/x-fossil-wiki"); |
| 224 | rid = 0; |
| 225 | }else{ |
| 226 | zTag = mprintf("wiki-%s", zPageName); |
| 227 | rid = db_int(0, |
| 228 | "SELECT rid FROM tagxref" |
| 229 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 230 | " ORDER BY mtime DESC", zTag |
| 231 | ); |
| 232 | free(zTag); |
| @@ -260,11 +260,11 @@ | |
| 260 | style_submenu_element("Attach", "Add An Attachment", |
| 261 | "%s/attachadd?page=%T&from=%s/wiki%%3fname=%T", |
| 262 | g.zTop, zPageName, g.zTop, zPageName); |
| 263 | } |
| 264 | if( rid && g.perm.ApndWiki ){ |
| 265 | style_submenu_element("Append", "Add A Comment", |
| 266 | "%s/wikiappend?name=%T&mimetype=%s", |
| 267 | g.zTop, zPageName, zMimetype); |
| 268 | } |
| 269 | if( g.perm.Hyperlink ){ |
| 270 | style_submenu_element("History", "History", "%s/whistory?name=%T", |
| @@ -300,11 +300,11 @@ | |
| 300 | } |
| 301 | |
| 302 | /* |
| 303 | ** Formal names and common names for the various wiki styles. |
| 304 | */ |
| 305 | static const char *const azStyles[] = { |
| 306 | "text/x-fossil-wiki", "Fossil Wiki", |
| 307 | "text/x-markdown", "Markdown", |
| 308 | "text/plain", "Plain Text" |
| 309 | }; |
| 310 | |
| @@ -381,11 +381,11 @@ | |
| 381 | zBody = db_get("sandbox",""); |
| 382 | zMimetype = db_get("sandbox-mimetype","text/x-fossil-wiki"); |
| 383 | } |
| 384 | }else{ |
| 385 | zTag = mprintf("wiki-%s", zPageName); |
| 386 | rid = db_int(0, |
| 387 | "SELECT rid FROM tagxref" |
| 388 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 389 | " ORDER BY mtime DESC", zTag |
| 390 | ); |
| 391 | free(zTag); |
| @@ -462,11 +462,11 @@ | |
| 462 | if( !isWysiwyg ){ |
| 463 | /* Traditional markup-only editing */ |
| 464 | form_begin(0, "%R/wikiedit"); |
| 465 | @ <div> |
| 466 | mimetype_option_menu(zMimetype); |
| 467 | @ <br /><textarea name="w" class="wikiedit" cols="80" |
| 468 | @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea> |
| 469 | @ <br /> |
| 470 | if( db_get_boolean("wysiwyg-wiki", 0) ){ |
| 471 | @ <input type="submit" name="edit-wysiwyg" value="Wysiwyg Editor" |
| 472 | @ onclick='return confirm("Switching to WYSIWYG-mode\nwill erase your markup\nedits. Continue?")' /> |
| @@ -514,11 +514,11 @@ | |
| 514 | const char *zMimetype; |
| 515 | login_check_credentials(); |
| 516 | if( !g.perm.NewWiki ){ |
| 517 | login_needed(); |
| 518 | return; |
| 519 | } |
| 520 | zName = PD("name",""); |
| 521 | zMimetype = wiki_filter_mimetypes(P("mimetype")); |
| 522 | if( zName[0] && wiki_name_is_wellformed((const unsigned char *)zName) ){ |
| 523 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 |
| 524 | && db_get_boolean("wysiwyg-wiki", 0) |
| @@ -557,11 +557,11 @@ | |
| 557 | zDate = db_text(0, "SELECT datetime('now')"); |
| 558 | zRemark = PD("r",""); |
| 559 | zUser = PD("u",g.zLogin); |
| 560 | if( fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0 ){ |
| 561 | zId = db_text(0, "SELECT lower(hex(randomblob(8)))"); |
| 562 | blob_appendf(p, "\n\n<hr><div id=\"%s\"><i>On %s UTC %h", |
| 563 | zId, zDate, g.zLogin); |
| 564 | if( zUser[0] && fossil_strcmp(zUser,g.zLogin) ){ |
| 565 | blob_appendf(p, " (claiming to be %h)", zUser); |
| 566 | } |
| 567 | blob_appendf(p, " added:</i><br />\n%s</div id=\"%s\">", zRemark, zId); |
| @@ -601,11 +601,11 @@ | |
| 601 | zMimetype = wiki_filter_mimetypes(P("mimetype")); |
| 602 | if( check_name(zPageName) ) return; |
| 603 | isSandbox = is_sandbox(zPageName); |
| 604 | if( !isSandbox ){ |
| 605 | zTag = mprintf("wiki-%s", zPageName); |
| 606 | rid = db_int(0, |
| 607 | "SELECT rid FROM tagxref" |
| 608 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" |
| 609 | " ORDER BY mtime DESC", zTag |
| 610 | ); |
| 611 | free(zTag); |
| @@ -690,11 +690,11 @@ | |
| 690 | @ <input type="hidden" name="mimetype" value="%h(zMimetype)" /> |
| 691 | @ Your Name: |
| 692 | @ <input type="text" name="u" size="20" value="%h(zUser)" /><br /> |
| 693 | zFormat = mimetype_common_name(zMimetype); |
| 694 | @ Comment to append (formatted as %s(zFormat)):<br /> |
| 695 | @ <textarea name="r" class="wikiedit" cols="80" |
| 696 | @ rows="10" wrap="virtual">%h(PD("r",""))</textarea> |
| 697 | @ <br /> |
| 698 | @ <input type="submit" name="preview" value="Preview Your Comment" /> |
| 699 | @ <input type="submit" name="submit" value="Append Your Changes" /> |
| 700 | @ <input type="submit" name="cancel" value="Cancel" /> |
| @@ -809,11 +809,11 @@ | |
| 809 | ** - tagxref (whatever that really is!) |
| 810 | ** |
| 811 | ** Used by wcontent_page() and the JSON wiki code. |
| 812 | */ |
| 813 | void wiki_prepare_page_list( Stmt * pStmt ){ |
| 814 | db_prepare(pStmt, |
| 815 | "SELECT" |
| 816 | " substr(tagname, 6) as name," |
| 817 | " (SELECT value FROM tagxref WHERE tagid=tag.tagid ORDER BY mtime DESC) as tagXref" |
| 818 | " FROM tag WHERE tagname GLOB 'wiki-*'" |
| 819 | " ORDER BY lower(tagname) /*sort*/" |
| @@ -866,11 +866,11 @@ | |
| 866 | login_check_credentials(); |
| 867 | if( !g.perm.RdWiki ){ login_needed(); return; } |
| 868 | zTitle = PD("title","*"); |
| 869 | style_header("Wiki Pages Found"); |
| 870 | @ <ul> |
| 871 | db_prepare(&q, |
| 872 | "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'" |
| 873 | " ORDER BY lower(tagname) /*sort*/" , |
| 874 | zTitle); |
| 875 | while( db_step(&q)==SQLITE_ROW ){ |
| 876 | const char *zName = db_column_text(&q, 0); |
| @@ -917,11 +917,11 @@ | |
| 917 | @ surrounded on both sides by two or more spaces or by a tab. Only a single |
| 918 | @ level of enumeration list is supported by wiki. For nested lists or for |
| 919 | @ enumerations that count using letters or roman numerials, use HTML.</p></li> |
| 920 | @ <li> <p><span class="wikiruleHead">Indented Paragraphs</span>. |
| 921 | @ Any paragraph that begins with two or more spaces or a tab and |
| 922 | @ which is not a bullet or enumeration list item is rendered |
| 923 | @ indented. Only a single level of indentation is supported by wiki; use |
| 924 | @ HTML for deeper indentation.</p></li> |
| 925 | @ <li> <p><span class="wikiruleHead">Hyperlinks</span>. |
| 926 | @ Text within square brackets ("[...]") becomes a hyperlink. The |
| 927 | @ target can be a wiki page name, the artifact ID of a check-in or ticket, |
| @@ -1062,11 +1062,11 @@ | |
| 1062 | } |
| 1063 | zPageName = g.argv[3]; |
| 1064 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| 1065 | " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" |
| 1066 | " ORDER BY x.mtime DESC LIMIT 1", |
| 1067 | zPageName |
| 1068 | ); |
| 1069 | if( (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0 ){ |
| 1070 | zBody = pWiki->zWiki; |
| 1071 | } |
| 1072 | if( zBody==0 ){ |
| @@ -1110,11 +1110,11 @@ | |
| 1110 | } |
| 1111 | fossil_fatal("delete not yet implemented."); |
| 1112 | }else |
| 1113 | if( strncmp(g.argv[2],"list",n)==0 ){ |
| 1114 | Stmt q; |
| 1115 | db_prepare(&q, |
| 1116 | "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 1117 | " ORDER BY lower(tagname) /*sort*/" |
| 1118 | ); |
| 1119 | while( db_step(&q)==SQLITE_ROW ){ |
| 1120 | const char *zName = db_column_text(&q, 0); |
| 1121 |
+15
-3
| --- src/winhttp.c | ||
| +++ src/winhttp.c | ||
| @@ -67,15 +67,18 @@ | ||
| 67 | 67 | HttpRequest *p = (HttpRequest*)pAppData; |
| 68 | 68 | FILE *in = 0, *out = 0; |
| 69 | 69 | int amt, got; |
| 70 | 70 | int wanted = 0; |
| 71 | 71 | char *z; |
| 72 | + char zCmdFName[MAX_PATH]; | |
| 72 | 73 | char zRequestFName[MAX_PATH]; |
| 73 | 74 | char zReplyFName[MAX_PATH]; |
| 74 | 75 | char zCmd[2000]; /* Command-line to process the request */ |
| 75 | 76 | char zHdr[2000]; /* The HTTP request header */ |
| 76 | 77 | |
| 78 | + sqlite3_snprintf(MAX_PATH, zCmdFName, | |
| 79 | + "%s_cmd%d.txt", zTempPrefix, p->id); | |
| 77 | 80 | sqlite3_snprintf(MAX_PATH, zRequestFName, |
| 78 | 81 | "%s_in%d.txt", zTempPrefix, p->id); |
| 79 | 82 | sqlite3_snprintf(MAX_PATH, zReplyFName, |
| 80 | 83 | "%s_out%d.txt", zTempPrefix, p->id); |
| 81 | 84 | amt = 0; |
| @@ -108,13 +111,21 @@ | ||
| 108 | 111 | } |
| 109 | 112 | wanted -= got; |
| 110 | 113 | } |
| 111 | 114 | fclose(out); |
| 112 | 115 | out = 0; |
| 113 | - sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s", | |
| 114 | - g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName, | |
| 115 | - inet_ntoa(p->addr.sin_addr), p->zOptions | |
| 116 | + sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s\n%s", | |
| 117 | + get_utf8_bom(0), g.zRepositoryName, zRequestFName, zReplyFName, | |
| 118 | + inet_ntoa(p->addr.sin_addr) | |
| 119 | + ); | |
| 120 | + out = fossil_fopen(zCmdFName, "wb"); | |
| 121 | + if( out==0 ) goto end_request; | |
| 122 | + fwrite(zCmd, 1, strlen(zCmd), out); | |
| 123 | + fclose(out); | |
| 124 | + | |
| 125 | + sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http -args \"%s\" --nossl%s", | |
| 126 | + g.nameOfExe, zCmdFName, p->zOptions | |
| 116 | 127 | ); |
| 117 | 128 | fossil_system(zCmd); |
| 118 | 129 | in = fossil_fopen(zReplyFName, "rb"); |
| 119 | 130 | if( in ){ |
| 120 | 131 | while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){ |
| @@ -126,10 +137,11 @@ | ||
| 126 | 137 | if( out ) fclose(out); |
| 127 | 138 | if( in ) fclose(in); |
| 128 | 139 | closesocket(p->s); |
| 129 | 140 | file_delete(zRequestFName); |
| 130 | 141 | file_delete(zReplyFName); |
| 142 | + file_delete(zCmdFName); | |
| 131 | 143 | free(p); |
| 132 | 144 | } |
| 133 | 145 | |
| 134 | 146 | /* |
| 135 | 147 | ** Process a single incoming SCGI request. |
| 136 | 148 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -67,15 +67,18 @@ | |
| 67 | HttpRequest *p = (HttpRequest*)pAppData; |
| 68 | FILE *in = 0, *out = 0; |
| 69 | int amt, got; |
| 70 | int wanted = 0; |
| 71 | char *z; |
| 72 | char zRequestFName[MAX_PATH]; |
| 73 | char zReplyFName[MAX_PATH]; |
| 74 | char zCmd[2000]; /* Command-line to process the request */ |
| 75 | char zHdr[2000]; /* The HTTP request header */ |
| 76 | |
| 77 | sqlite3_snprintf(MAX_PATH, zRequestFName, |
| 78 | "%s_in%d.txt", zTempPrefix, p->id); |
| 79 | sqlite3_snprintf(MAX_PATH, zReplyFName, |
| 80 | "%s_out%d.txt", zTempPrefix, p->id); |
| 81 | amt = 0; |
| @@ -108,13 +111,21 @@ | |
| 108 | } |
| 109 | wanted -= got; |
| 110 | } |
| 111 | fclose(out); |
| 112 | out = 0; |
| 113 | sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s", |
| 114 | g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName, |
| 115 | inet_ntoa(p->addr.sin_addr), p->zOptions |
| 116 | ); |
| 117 | fossil_system(zCmd); |
| 118 | in = fossil_fopen(zReplyFName, "rb"); |
| 119 | if( in ){ |
| 120 | while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){ |
| @@ -126,10 +137,11 @@ | |
| 126 | if( out ) fclose(out); |
| 127 | if( in ) fclose(in); |
| 128 | closesocket(p->s); |
| 129 | file_delete(zRequestFName); |
| 130 | file_delete(zReplyFName); |
| 131 | free(p); |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | ** Process a single incoming SCGI request. |
| 136 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -67,15 +67,18 @@ | |
| 67 | HttpRequest *p = (HttpRequest*)pAppData; |
| 68 | FILE *in = 0, *out = 0; |
| 69 | int amt, got; |
| 70 | int wanted = 0; |
| 71 | char *z; |
| 72 | char zCmdFName[MAX_PATH]; |
| 73 | char zRequestFName[MAX_PATH]; |
| 74 | char zReplyFName[MAX_PATH]; |
| 75 | char zCmd[2000]; /* Command-line to process the request */ |
| 76 | char zHdr[2000]; /* The HTTP request header */ |
| 77 | |
| 78 | sqlite3_snprintf(MAX_PATH, zCmdFName, |
| 79 | "%s_cmd%d.txt", zTempPrefix, p->id); |
| 80 | sqlite3_snprintf(MAX_PATH, zRequestFName, |
| 81 | "%s_in%d.txt", zTempPrefix, p->id); |
| 82 | sqlite3_snprintf(MAX_PATH, zReplyFName, |
| 83 | "%s_out%d.txt", zTempPrefix, p->id); |
| 84 | amt = 0; |
| @@ -108,13 +111,21 @@ | |
| 111 | } |
| 112 | wanted -= got; |
| 113 | } |
| 114 | fclose(out); |
| 115 | out = 0; |
| 116 | sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s\n%s", |
| 117 | get_utf8_bom(0), g.zRepositoryName, zRequestFName, zReplyFName, |
| 118 | inet_ntoa(p->addr.sin_addr) |
| 119 | ); |
| 120 | out = fossil_fopen(zCmdFName, "wb"); |
| 121 | if( out==0 ) goto end_request; |
| 122 | fwrite(zCmd, 1, strlen(zCmd), out); |
| 123 | fclose(out); |
| 124 | |
| 125 | sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http -args \"%s\" --nossl%s", |
| 126 | g.nameOfExe, zCmdFName, p->zOptions |
| 127 | ); |
| 128 | fossil_system(zCmd); |
| 129 | in = fossil_fopen(zReplyFName, "rb"); |
| 130 | if( in ){ |
| 131 | while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){ |
| @@ -126,10 +137,11 @@ | |
| 137 | if( out ) fclose(out); |
| 138 | if( in ) fclose(in); |
| 139 | closesocket(p->s); |
| 140 | file_delete(zRequestFName); |
| 141 | file_delete(zReplyFName); |
| 142 | file_delete(zCmdFName); |
| 143 | free(p); |
| 144 | } |
| 145 | |
| 146 | /* |
| 147 | ** Process a single incoming SCGI request. |
| 148 |
+7
-7
| --- src/wysiwyg.c | ||
| +++ src/wysiwyg.c | ||
| @@ -228,18 +228,18 @@ | ||
| 228 | 228 | @ <div id="wysiwygBox" |
| 229 | 229 | @ style="resize:both; overflow:auto; width: %d(w)em; height: %d(h)em;" |
| 230 | 230 | @ contenteditable="true">%s(zContent)</div> |
| 231 | 231 | @ <script> |
| 232 | 232 | @ var oDoc; |
| 233 | - @ | |
| 233 | + @ | |
| 234 | 234 | @ /* Initialize the document editor */ |
| 235 | 235 | @ function initDoc() { |
| 236 | 236 | @ oDoc = document.getElementById("wysiwygBox"); |
| 237 | 237 | @ if (!isWysiwyg()) { setDocMode(true); } |
| 238 | 238 | @ } |
| 239 | - @ | |
| 240 | - @ /* Return true if the document editor is in WYSIWYG mode. Return | |
| 239 | + @ | |
| 240 | + @ /* Return true if the document editor is in WYSIWYG mode. Return | |
| 241 | 241 | @ ** false if it is in Markup mode */ |
| 242 | 242 | @ function isWysiwyg() { |
| 243 | 243 | @ return document.getElementById("editMode").selectedIndex==0; |
| 244 | 244 | @ } |
| 245 | 245 | @ |
| @@ -247,22 +247,22 @@ | ||
| 247 | 247 | @ ** to the server */ |
| 248 | 248 | @ function wysiwygSubmit() { |
| 249 | 249 | @ if(oDoc.style.whiteSpace=="pre-wrap"){setDocMode(0);} |
| 250 | 250 | @ document.getElementById("wysiwygValue").value=oDoc.innerHTML; |
| 251 | 251 | @ } |
| 252 | - @ | |
| 253 | - @ /* Run the editing command if in WYSIWYG mode */ | |
| 252 | + @ | |
| 253 | + @ /* Run the editing command if in WYSIWYG mode */ | |
| 254 | 254 | @ function formatDoc(sCmd, sValue) { |
| 255 | 255 | @ if (isWysiwyg()){ |
| 256 | 256 | @ document.execCommand("styleWithCSS", false, false); |
| 257 | 257 | @ document.execCommand(sCmd, false, sValue); |
| 258 | 258 | @ oDoc.focus(); |
| 259 | 259 | @ } |
| 260 | 260 | @ } |
| 261 | - @ | |
| 261 | + @ | |
| 262 | 262 | @ /* Change the editing mode. Convert to markup if the argument |
| 263 | - @ ** is true and wysiwyg if the argument is false. */ | |
| 263 | + @ ** is true and wysiwyg if the argument is false. */ | |
| 264 | 264 | @ function setDocMode(bToMarkup) { |
| 265 | 265 | @ var oContent; |
| 266 | 266 | @ if (bToMarkup) { |
| 267 | 267 | @ /* WYSIWYG -> Markup */ |
| 268 | 268 | @ var linebreak = new RegExp("</p><p>","ig"); |
| 269 | 269 |
| --- src/wysiwyg.c | |
| +++ src/wysiwyg.c | |
| @@ -228,18 +228,18 @@ | |
| 228 | @ <div id="wysiwygBox" |
| 229 | @ style="resize:both; overflow:auto; width: %d(w)em; height: %d(h)em;" |
| 230 | @ contenteditable="true">%s(zContent)</div> |
| 231 | @ <script> |
| 232 | @ var oDoc; |
| 233 | @ |
| 234 | @ /* Initialize the document editor */ |
| 235 | @ function initDoc() { |
| 236 | @ oDoc = document.getElementById("wysiwygBox"); |
| 237 | @ if (!isWysiwyg()) { setDocMode(true); } |
| 238 | @ } |
| 239 | @ |
| 240 | @ /* Return true if the document editor is in WYSIWYG mode. Return |
| 241 | @ ** false if it is in Markup mode */ |
| 242 | @ function isWysiwyg() { |
| 243 | @ return document.getElementById("editMode").selectedIndex==0; |
| 244 | @ } |
| 245 | @ |
| @@ -247,22 +247,22 @@ | |
| 247 | @ ** to the server */ |
| 248 | @ function wysiwygSubmit() { |
| 249 | @ if(oDoc.style.whiteSpace=="pre-wrap"){setDocMode(0);} |
| 250 | @ document.getElementById("wysiwygValue").value=oDoc.innerHTML; |
| 251 | @ } |
| 252 | @ |
| 253 | @ /* Run the editing command if in WYSIWYG mode */ |
| 254 | @ function formatDoc(sCmd, sValue) { |
| 255 | @ if (isWysiwyg()){ |
| 256 | @ document.execCommand("styleWithCSS", false, false); |
| 257 | @ document.execCommand(sCmd, false, sValue); |
| 258 | @ oDoc.focus(); |
| 259 | @ } |
| 260 | @ } |
| 261 | @ |
| 262 | @ /* Change the editing mode. Convert to markup if the argument |
| 263 | @ ** is true and wysiwyg if the argument is false. */ |
| 264 | @ function setDocMode(bToMarkup) { |
| 265 | @ var oContent; |
| 266 | @ if (bToMarkup) { |
| 267 | @ /* WYSIWYG -> Markup */ |
| 268 | @ var linebreak = new RegExp("</p><p>","ig"); |
| 269 |
| --- src/wysiwyg.c | |
| +++ src/wysiwyg.c | |
| @@ -228,18 +228,18 @@ | |
| 228 | @ <div id="wysiwygBox" |
| 229 | @ style="resize:both; overflow:auto; width: %d(w)em; height: %d(h)em;" |
| 230 | @ contenteditable="true">%s(zContent)</div> |
| 231 | @ <script> |
| 232 | @ var oDoc; |
| 233 | @ |
| 234 | @ /* Initialize the document editor */ |
| 235 | @ function initDoc() { |
| 236 | @ oDoc = document.getElementById("wysiwygBox"); |
| 237 | @ if (!isWysiwyg()) { setDocMode(true); } |
| 238 | @ } |
| 239 | @ |
| 240 | @ /* Return true if the document editor is in WYSIWYG mode. Return |
| 241 | @ ** false if it is in Markup mode */ |
| 242 | @ function isWysiwyg() { |
| 243 | @ return document.getElementById("editMode").selectedIndex==0; |
| 244 | @ } |
| 245 | @ |
| @@ -247,22 +247,22 @@ | |
| 247 | @ ** to the server */ |
| 248 | @ function wysiwygSubmit() { |
| 249 | @ if(oDoc.style.whiteSpace=="pre-wrap"){setDocMode(0);} |
| 250 | @ document.getElementById("wysiwygValue").value=oDoc.innerHTML; |
| 251 | @ } |
| 252 | @ |
| 253 | @ /* Run the editing command if in WYSIWYG mode */ |
| 254 | @ function formatDoc(sCmd, sValue) { |
| 255 | @ if (isWysiwyg()){ |
| 256 | @ document.execCommand("styleWithCSS", false, false); |
| 257 | @ document.execCommand(sCmd, false, sValue); |
| 258 | @ oDoc.focus(); |
| 259 | @ } |
| 260 | @ } |
| 261 | @ |
| 262 | @ /* Change the editing mode. Convert to markup if the argument |
| 263 | @ ** is true and wysiwyg if the argument is false. */ |
| 264 | @ function setDocMode(bToMarkup) { |
| 265 | @ var oContent; |
| 266 | @ if (bToMarkup) { |
| 267 | @ /* WYSIWYG -> Markup */ |
| 268 | @ var linebreak = new RegExp("</p><p>","ig"); |
| 269 |
+39
-39
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -94,11 +94,11 @@ | ||
| 94 | 94 | db_reset(&q); |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /* |
| 99 | -** The aToken[0..nToken-1] blob array is a parse of a "file" line | |
| 99 | +** The aToken[0..nToken-1] blob array is a parse of a "file" line | |
| 100 | 100 | ** message. This routine finishes parsing that message and does |
| 101 | 101 | ** a record insert of the file. |
| 102 | 102 | ** |
| 103 | 103 | ** The file line is in one of the following two forms: |
| 104 | 104 | ** |
| @@ -119,14 +119,14 @@ | ||
| 119 | 119 | int n; |
| 120 | 120 | int rid; |
| 121 | 121 | int srcid = 0; |
| 122 | 122 | Blob content, hash; |
| 123 | 123 | int isPriv; |
| 124 | - | |
| 124 | + | |
| 125 | 125 | isPriv = pXfer->nextIsPrivate; |
| 126 | 126 | pXfer->nextIsPrivate = 0; |
| 127 | - if( pXfer->nToken<3 | |
| 127 | + if( pXfer->nToken<3 | |
| 128 | 128 | || pXfer->nToken>4 |
| 129 | 129 | || !blob_is_uuid(&pXfer->aToken[1]) |
| 130 | 130 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-1], &n) |
| 131 | 131 | || n<0 |
| 132 | 132 | || (pXfer->nToken==4 && !blob_is_uuid(&pXfer->aToken[2])) |
| @@ -198,11 +198,11 @@ | ||
| 198 | 198 | assert( blob_is_reset(&content) ); |
| 199 | 199 | remote_has(rid); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /* |
| 203 | -** The aToken[0..nToken-1] blob array is a parse of a "cfile" line | |
| 203 | +** The aToken[0..nToken-1] blob array is a parse of a "cfile" line | |
| 204 | 204 | ** message. This routine finishes parsing that message and does |
| 205 | 205 | ** a record insert of the file. The difference between "file" and |
| 206 | 206 | ** "cfile" is that with "cfile" the content is already compressed. |
| 207 | 207 | ** |
| 208 | 208 | ** The file line is in one of the following two forms: |
| @@ -227,14 +227,14 @@ | ||
| 227 | 227 | int szU; /* USIZE */ |
| 228 | 228 | int rid; |
| 229 | 229 | int srcid = 0; |
| 230 | 230 | Blob content; |
| 231 | 231 | int isPriv; |
| 232 | - | |
| 232 | + | |
| 233 | 233 | isPriv = pXfer->nextIsPrivate; |
| 234 | 234 | pXfer->nextIsPrivate = 0; |
| 235 | - if( pXfer->nToken<4 | |
| 235 | + if( pXfer->nToken<4 | |
| 236 | 236 | || pXfer->nToken>5 |
| 237 | 237 | || !blob_is_uuid(&pXfer->aToken[1]) |
| 238 | 238 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-2], &szU) |
| 239 | 239 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-1], &szC) |
| 240 | 240 | || szC<0 || szU<0 |
| @@ -284,11 +284,11 @@ | ||
| 284 | 284 | ){ |
| 285 | 285 | static const char *const azQuery[] = { |
| 286 | 286 | "SELECT pid FROM plink x" |
| 287 | 287 | " WHERE cid=%d" |
| 288 | 288 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)", |
| 289 | - | |
| 289 | + | |
| 290 | 290 | "SELECT pid, min(mtime) FROM mlink, event ON mlink.mid=event.objid" |
| 291 | 291 | " WHERE fid=%d" |
| 292 | 292 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)" |
| 293 | 293 | }; |
| 294 | 294 | int i; |
| @@ -321,11 +321,11 @@ | ||
| 321 | 321 | } |
| 322 | 322 | return size; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /* |
| 326 | -** Try to send a file as a native delta. | |
| 326 | +** Try to send a file as a native delta. | |
| 327 | 327 | ** If successful, return the number of bytes in the delta. |
| 328 | 328 | ** If we cannot generate an appropriate delta, then send |
| 329 | 329 | ** nothing and return zero. |
| 330 | 330 | ** |
| 331 | 331 | ** Never send a delta against a private artifact. |
| @@ -403,11 +403,11 @@ | ||
| 403 | 403 | } |
| 404 | 404 | if( uuid_is_shunned(blob_str(pUuid)) ){ |
| 405 | 405 | blob_reset(&uuid); |
| 406 | 406 | return; |
| 407 | 407 | } |
| 408 | - if( (pXfer->maxTime != -1 && time(NULL) >= pXfer->maxTime) || | |
| 408 | + if( (pXfer->maxTime != -1 && time(NULL) >= pXfer->maxTime) || | |
| 409 | 409 | pXfer->mxSend<=blob_size(pXfer->pOut) ){ |
| 410 | 410 | const char *zFormat = isPriv ? "igot %b 1\n" : "igot %b\n"; |
| 411 | 411 | blob_appendf(pXfer->pOut, zFormat, pUuid); |
| 412 | 412 | pXfer->nIGotSent++; |
| 413 | 413 | blob_reset(&uuid); |
| @@ -445,11 +445,11 @@ | ||
| 445 | 445 | #endif |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /* |
| 449 | 449 | ** Send the file identified by rid as a compressed artifact. Basically, |
| 450 | -** send the content exactly as it appears in the BLOB table using | |
| 450 | +** send the content exactly as it appears in the BLOB table using | |
| 451 | 451 | ** a "cfile" card. |
| 452 | 452 | */ |
| 453 | 453 | static void send_compressed_file(Xfer *pXfer, int rid){ |
| 454 | 454 | const char *zContent; |
| 455 | 455 | const char *zUuid; |
| @@ -515,11 +515,11 @@ | ||
| 515 | 515 | ** Except: do not request shunned artifacts. And do not request |
| 516 | 516 | ** private artifacts if we are not doing a private transfer. |
| 517 | 517 | */ |
| 518 | 518 | static void request_phantoms(Xfer *pXfer, int maxReq){ |
| 519 | 519 | Stmt q; |
| 520 | - db_prepare(&q, | |
| 520 | + db_prepare(&q, | |
| 521 | 521 | "SELECT uuid FROM phantom JOIN blob USING(rid)" |
| 522 | 522 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid) %s", |
| 523 | 523 | (pXfer->syncPrivate ? "" : |
| 524 | 524 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)") |
| 525 | 525 | ); |
| @@ -551,12 +551,12 @@ | ||
| 551 | 551 | ** Check the signature on an application/x-fossil payload received by |
| 552 | 552 | ** the HTTP server. The signature is a line of the following form: |
| 553 | 553 | ** |
| 554 | 554 | ** login LOGIN NONCE SIGNATURE |
| 555 | 555 | ** |
| 556 | -** The NONCE is the SHA1 hash of the remainder of the input. | |
| 557 | -** SIGNATURE is the SHA1 checksum of the NONCE concatenated | |
| 556 | +** The NONCE is the SHA1 hash of the remainder of the input. | |
| 557 | +** SIGNATURE is the SHA1 checksum of the NONCE concatenated | |
| 558 | 558 | ** with the users password. |
| 559 | 559 | ** |
| 560 | 560 | ** The parameters to this routine are ephemeral blobs holding the |
| 561 | 561 | ** LOGIN, NONCE and SIGNATURE. |
| 562 | 562 | ** |
| @@ -564,11 +564,11 @@ | ||
| 564 | 564 | ** If everything checks out, the USER.CAP column for the USER table |
| 565 | 565 | ** is consulted to set privileges in the global g variable. |
| 566 | 566 | ** |
| 567 | 567 | ** If anything fails to check out, no changes are made to privileges. |
| 568 | 568 | ** |
| 569 | -** Signature generation on the client side is handled by the | |
| 569 | +** Signature generation on the client side is handled by the | |
| 570 | 570 | ** http_exchange() routine. |
| 571 | 571 | ** |
| 572 | 572 | ** Return non-zero for a login failure and zero for success. |
| 573 | 573 | */ |
| 574 | 574 | int check_login(Blob *pLogin, Blob *pNonce, Blob *pSig){ |
| @@ -699,11 +699,11 @@ | ||
| 699 | 699 | blob_appendf(&deleteWhere, ",%d", rid); |
| 700 | 700 | } |
| 701 | 701 | } |
| 702 | 702 | db_finalize(&q); |
| 703 | 703 | db_multi_exec( |
| 704 | - "DELETE FROM unclustered WHERE rid NOT IN (0 %s)", | |
| 704 | + "DELETE FROM unclustered WHERE rid NOT IN (0 %s)", | |
| 705 | 705 | blob_str(&deleteWhere) |
| 706 | 706 | ); |
| 707 | 707 | blob_reset(&deleteWhere); |
| 708 | 708 | if( nRow>0 ){ |
| 709 | 709 | md5sum_blob(&cluster, &cksum); |
| @@ -738,21 +738,21 @@ | ||
| 738 | 738 | */ |
| 739 | 739 | static int send_unclustered(Xfer *pXfer){ |
| 740 | 740 | Stmt q; |
| 741 | 741 | int cnt = 0; |
| 742 | 742 | if( pXfer->resync ){ |
| 743 | - db_prepare(&q, | |
| 743 | + db_prepare(&q, | |
| 744 | 744 | "SELECT uuid, rid FROM blob" |
| 745 | 745 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 746 | 746 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 747 | 747 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 748 | 748 | " AND blob.rid<=%d" |
| 749 | 749 | " ORDER BY blob.rid DESC", |
| 750 | 750 | pXfer->resync |
| 751 | 751 | ); |
| 752 | 752 | }else{ |
| 753 | - db_prepare(&q, | |
| 753 | + db_prepare(&q, | |
| 754 | 754 | "SELECT uuid FROM unclustered JOIN blob USING(rid)" |
| 755 | 755 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 756 | 756 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 757 | 757 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 758 | 758 | ); |
| @@ -772,11 +772,11 @@ | ||
| 772 | 772 | /* |
| 773 | 773 | ** Send an igot message for every artifact. |
| 774 | 774 | */ |
| 775 | 775 | static void send_all(Xfer *pXfer){ |
| 776 | 776 | Stmt q; |
| 777 | - db_prepare(&q, | |
| 777 | + db_prepare(&q, | |
| 778 | 778 | "SELECT uuid FROM blob " |
| 779 | 779 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 780 | 780 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 781 | 781 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 782 | 782 | ); |
| @@ -1033,12 +1033,12 @@ | ||
| 1033 | 1033 | }else{ |
| 1034 | 1034 | server_private_xfer_not_authorized(); |
| 1035 | 1035 | } |
| 1036 | 1036 | } |
| 1037 | 1037 | }else |
| 1038 | - | |
| 1039 | - | |
| 1038 | + | |
| 1039 | + | |
| 1040 | 1040 | /* pull SERVERCODE PROJECTCODE |
| 1041 | 1041 | ** push SERVERCODE PROJECTCODE |
| 1042 | 1042 | ** |
| 1043 | 1043 | ** The client wants either send or receive. The server should |
| 1044 | 1044 | ** verify that the project code matches. |
| @@ -1142,14 +1142,14 @@ | ||
| 1142 | 1142 | ){ |
| 1143 | 1143 | cgi_reset_content(); |
| 1144 | 1144 | @ error login\sfailed |
| 1145 | 1145 | nErr++; |
| 1146 | 1146 | break; |
| 1147 | - } | |
| 1147 | + } | |
| 1148 | 1148 | } |
| 1149 | 1149 | }else |
| 1150 | - | |
| 1150 | + | |
| 1151 | 1151 | /* reqconfig NAME |
| 1152 | 1152 | ** |
| 1153 | 1153 | ** Request a configuration value |
| 1154 | 1154 | */ |
| 1155 | 1155 | if( blob_eq(&xfer.aToken[0], "reqconfig") |
| @@ -1167,11 +1167,11 @@ | ||
| 1167 | 1167 | /* Old style configuration transfer */ |
| 1168 | 1168 | send_legacy_config_card(&xfer, zName); |
| 1169 | 1169 | } |
| 1170 | 1170 | } |
| 1171 | 1171 | }else |
| 1172 | - | |
| 1172 | + | |
| 1173 | 1173 | /* config NAME SIZE \n CONTENT |
| 1174 | 1174 | ** |
| 1175 | 1175 | ** Receive a configuration value from the client. This is only |
| 1176 | 1176 | ** permitted for high-privilege users. |
| 1177 | 1177 | */ |
| @@ -1194,11 +1194,11 @@ | ||
| 1194 | 1194 | configure_receive(zName, &content, CONFIGSET_ALL); |
| 1195 | 1195 | blob_reset(&content); |
| 1196 | 1196 | blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR); |
| 1197 | 1197 | }else |
| 1198 | 1198 | |
| 1199 | - | |
| 1199 | + | |
| 1200 | 1200 | |
| 1201 | 1201 | /* cookie TEXT |
| 1202 | 1202 | ** |
| 1203 | 1203 | ** A cookie contains a arbitrary-length argument that is server-defined. |
| 1204 | 1204 | ** The argument must be encoded so as not to contain any whitespace. |
| @@ -1413,11 +1413,11 @@ | ||
| 1413 | 1413 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1414 | 1414 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1415 | 1415 | double rSkew = 0.0; /* Maximum time skew */ |
| 1416 | 1416 | |
| 1417 | 1417 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1418 | - if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 | |
| 1418 | + if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 | |
| 1419 | 1419 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1420 | 1420 | |
| 1421 | 1421 | transport_stats(0, 0, 1); |
| 1422 | 1422 | socket_global_init(); |
| 1423 | 1423 | memset(&xfer, 0, sizeof(xfer)); |
| @@ -1487,11 +1487,11 @@ | ||
| 1487 | 1487 | */ |
| 1488 | 1488 | zCookie = db_get("cookie", 0); |
| 1489 | 1489 | if( zCookie ){ |
| 1490 | 1490 | blob_appendf(&send, "cookie %s\n", zCookie); |
| 1491 | 1491 | } |
| 1492 | - | |
| 1492 | + | |
| 1493 | 1493 | /* Generate gimme cards for phantoms and leaf cards |
| 1494 | 1494 | ** for all leaves. |
| 1495 | 1495 | */ |
| 1496 | 1496 | if( (syncFlags & SYNC_PULL)!=0 |
| 1497 | 1497 | || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1) |
| @@ -1503,11 +1503,11 @@ | ||
| 1503 | 1503 | nCardSent += send_unclustered(&xfer); |
| 1504 | 1504 | if( syncFlags & SYNC_PRIVATE ) send_private(&xfer); |
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | /* Send configuration parameter requests. On a clone, delay sending |
| 1508 | - ** this until the second cycle since the login card might fail on | |
| 1508 | + ** this until the second cycle since the login card might fail on | |
| 1509 | 1509 | ** the first cycle. |
| 1510 | 1510 | */ |
| 1511 | 1511 | if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){ |
| 1512 | 1512 | const char *zName; |
| 1513 | 1513 | if( zOpType==0 ) zOpType = "Pull"; |
| @@ -1663,20 +1663,20 @@ | ||
| 1663 | 1663 | if( syncFlags & SYNC_PUSH ){ |
| 1664 | 1664 | int rid = rid_from_uuid(&xfer.aToken[1], 0, 0); |
| 1665 | 1665 | if( rid ) send_file(&xfer, rid, &xfer.aToken[1], 0); |
| 1666 | 1666 | } |
| 1667 | 1667 | }else |
| 1668 | - | |
| 1668 | + | |
| 1669 | 1669 | /* igot UUID ?PRIVATEFLAG? |
| 1670 | 1670 | ** |
| 1671 | 1671 | ** Server announces that it has a particular file. If this is |
| 1672 | 1672 | ** not a file that we have and we are pulling, then create a |
| 1673 | 1673 | ** phantom to cause this file to be requested on the next cycle. |
| 1674 | 1674 | ** Always remember that the server has this file so that we do |
| 1675 | 1675 | ** not transmit it by accident. |
| 1676 | 1676 | ** |
| 1677 | - ** If the PRIVATE argument exists and is 1, then the file is | |
| 1677 | + ** If the PRIVATE argument exists and is 1, then the file is | |
| 1678 | 1678 | ** private. Pretend it does not exists if we are not pulling |
| 1679 | 1679 | ** private files. |
| 1680 | 1680 | */ |
| 1681 | 1681 | if( xfer.nToken>=2 |
| 1682 | 1682 | && blob_eq(&xfer.aToken[0], "igot") |
| @@ -1693,12 +1693,12 @@ | ||
| 1693 | 1693 | rid = content_new(blob_str(&xfer.aToken[1]), isPriv); |
| 1694 | 1694 | if( rid ) newPhantom = 1; |
| 1695 | 1695 | } |
| 1696 | 1696 | remote_has(rid); |
| 1697 | 1697 | }else |
| 1698 | - | |
| 1699 | - | |
| 1698 | + | |
| 1699 | + | |
| 1700 | 1700 | /* push SERVERCODE PRODUCTCODE |
| 1701 | 1701 | ** |
| 1702 | 1702 | ** Should only happen in response to a clone. This message tells |
| 1703 | 1703 | ** the client what product to use for the new database. |
| 1704 | 1704 | */ |
| @@ -1716,11 +1716,11 @@ | ||
| 1716 | 1716 | db_set("project-code", zPCode, 0); |
| 1717 | 1717 | } |
| 1718 | 1718 | if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno); |
| 1719 | 1719 | nCardSent++; |
| 1720 | 1720 | }else |
| 1721 | - | |
| 1721 | + | |
| 1722 | 1722 | /* config NAME SIZE \n CONTENT |
| 1723 | 1723 | ** |
| 1724 | 1724 | ** Receive a configuration value from the server. |
| 1725 | 1725 | ** |
| 1726 | 1726 | ** The received configuration setting is silently ignored if it was |
| @@ -1738,11 +1738,11 @@ | ||
| 1738 | 1738 | nArtifactRcvd++; |
| 1739 | 1739 | blob_reset(&content); |
| 1740 | 1740 | blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR); |
| 1741 | 1741 | }else |
| 1742 | 1742 | |
| 1743 | - | |
| 1743 | + | |
| 1744 | 1744 | /* cookie TEXT |
| 1745 | 1745 | ** |
| 1746 | 1746 | ** The server might include a cookie in its reply. The client |
| 1747 | 1747 | ** should remember this cookie and send it back to the server |
| 1748 | 1748 | ** in its next query. |
| @@ -1780,11 +1780,11 @@ | ||
| 1780 | 1780 | ** |
| 1781 | 1781 | ** Print a message. Similar to "error" but does not stop processing. |
| 1782 | 1782 | ** |
| 1783 | 1783 | ** If the "login failed" message is seen, clear the sync password prior |
| 1784 | 1784 | ** to the next cycle. |
| 1785 | - */ | |
| 1785 | + */ | |
| 1786 | 1786 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| 1787 | 1787 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1788 | 1788 | defossilize(zMsg); |
| 1789 | 1789 | if( (syncFlags & SYNC_PUSH) && zMsg && strglob("pull only *", zMsg) ){ |
| 1790 | 1790 | syncFlags &= ~SYNC_PUSH; |
| @@ -1797,11 +1797,11 @@ | ||
| 1797 | 1797 | }else |
| 1798 | 1798 | |
| 1799 | 1799 | /* pragma NAME VALUE... |
| 1800 | 1800 | ** |
| 1801 | 1801 | ** The server can send pragmas to try to convey meta-information to |
| 1802 | - ** the client. These are informational only. Unknown pragmas are | |
| 1802 | + ** the client. These are informational only. Unknown pragmas are | |
| 1803 | 1803 | ** silently ignored. |
| 1804 | 1804 | */ |
| 1805 | 1805 | if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){ |
| 1806 | 1806 | }else |
| 1807 | 1807 | |
| @@ -1810,14 +1810,14 @@ | ||
| 1810 | 1810 | ** Report an error and abandon the sync session. |
| 1811 | 1811 | ** |
| 1812 | 1812 | ** Except, when cloning we will sometimes get an error on the |
| 1813 | 1813 | ** first message exchange because the project-code is unknown |
| 1814 | 1814 | ** and so the login card on the request was invalid. The project-code |
| 1815 | - ** is returned in the reply before the error card, so second and | |
| 1815 | + ** is returned in the reply before the error card, so second and | |
| 1816 | 1816 | ** subsequent messages should be OK. Nevertheless, we need to ignore |
| 1817 | 1817 | ** the error card on the first message of a clone. |
| 1818 | - */ | |
| 1818 | + */ | |
| 1819 | 1819 | if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){ |
| 1820 | 1820 | if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){ |
| 1821 | 1821 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1822 | 1822 | defossilize(zMsg); |
| 1823 | 1823 | fossil_force_newline(); |
| @@ -1894,11 +1894,11 @@ | ||
| 1894 | 1894 | xfer.nFileRcvd = 0; |
| 1895 | 1895 | xfer.nDeltaRcvd = 0; |
| 1896 | 1896 | xfer.nDanglingFile = 0; |
| 1897 | 1897 | |
| 1898 | 1898 | /* If we have one or more files queued to send, then go |
| 1899 | - ** another round | |
| 1899 | + ** another round | |
| 1900 | 1900 | */ |
| 1901 | 1901 | if( xfer.nFileSent+xfer.nDeltaSent>0 ){ |
| 1902 | 1902 | go = 1; |
| 1903 | 1903 | } |
| 1904 | 1904 | |
| @@ -1908,11 +1908,11 @@ | ||
| 1908 | 1908 | /* Stop the cycle if the server sends a "clone_seqno 0" card and |
| 1909 | 1909 | ** we have gone at least two rounds. Always go at least two rounds |
| 1910 | 1910 | ** on a clone in order to be sure to retrieve the configuration |
| 1911 | 1911 | ** information which is only sent on the second round. |
| 1912 | 1912 | */ |
| 1913 | - if( cloneSeqno<=0 && nCycle>1 ) go = 0; | |
| 1913 | + if( cloneSeqno<=0 && nCycle>1 ) go = 0; | |
| 1914 | 1914 | }; |
| 1915 | 1915 | transport_stats(&nSent, &nRcvd, 1); |
| 1916 | 1916 | if( (rSkew*24.0*3600.0) > 10.0 ){ |
| 1917 | 1917 | fossil_warning("*** time skew *** server is fast by %s", |
| 1918 | 1918 | db_timespan_name(rSkew)); |
| 1919 | 1919 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -94,11 +94,11 @@ | |
| 94 | db_reset(&q); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /* |
| 99 | ** The aToken[0..nToken-1] blob array is a parse of a "file" line |
| 100 | ** message. This routine finishes parsing that message and does |
| 101 | ** a record insert of the file. |
| 102 | ** |
| 103 | ** The file line is in one of the following two forms: |
| 104 | ** |
| @@ -119,14 +119,14 @@ | |
| 119 | int n; |
| 120 | int rid; |
| 121 | int srcid = 0; |
| 122 | Blob content, hash; |
| 123 | int isPriv; |
| 124 | |
| 125 | isPriv = pXfer->nextIsPrivate; |
| 126 | pXfer->nextIsPrivate = 0; |
| 127 | if( pXfer->nToken<3 |
| 128 | || pXfer->nToken>4 |
| 129 | || !blob_is_uuid(&pXfer->aToken[1]) |
| 130 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-1], &n) |
| 131 | || n<0 |
| 132 | || (pXfer->nToken==4 && !blob_is_uuid(&pXfer->aToken[2])) |
| @@ -198,11 +198,11 @@ | |
| 198 | assert( blob_is_reset(&content) ); |
| 199 | remote_has(rid); |
| 200 | } |
| 201 | |
| 202 | /* |
| 203 | ** The aToken[0..nToken-1] blob array is a parse of a "cfile" line |
| 204 | ** message. This routine finishes parsing that message and does |
| 205 | ** a record insert of the file. The difference between "file" and |
| 206 | ** "cfile" is that with "cfile" the content is already compressed. |
| 207 | ** |
| 208 | ** The file line is in one of the following two forms: |
| @@ -227,14 +227,14 @@ | |
| 227 | int szU; /* USIZE */ |
| 228 | int rid; |
| 229 | int srcid = 0; |
| 230 | Blob content; |
| 231 | int isPriv; |
| 232 | |
| 233 | isPriv = pXfer->nextIsPrivate; |
| 234 | pXfer->nextIsPrivate = 0; |
| 235 | if( pXfer->nToken<4 |
| 236 | || pXfer->nToken>5 |
| 237 | || !blob_is_uuid(&pXfer->aToken[1]) |
| 238 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-2], &szU) |
| 239 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-1], &szC) |
| 240 | || szC<0 || szU<0 |
| @@ -284,11 +284,11 @@ | |
| 284 | ){ |
| 285 | static const char *const azQuery[] = { |
| 286 | "SELECT pid FROM plink x" |
| 287 | " WHERE cid=%d" |
| 288 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)", |
| 289 | |
| 290 | "SELECT pid, min(mtime) FROM mlink, event ON mlink.mid=event.objid" |
| 291 | " WHERE fid=%d" |
| 292 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)" |
| 293 | }; |
| 294 | int i; |
| @@ -321,11 +321,11 @@ | |
| 321 | } |
| 322 | return size; |
| 323 | } |
| 324 | |
| 325 | /* |
| 326 | ** Try to send a file as a native delta. |
| 327 | ** If successful, return the number of bytes in the delta. |
| 328 | ** If we cannot generate an appropriate delta, then send |
| 329 | ** nothing and return zero. |
| 330 | ** |
| 331 | ** Never send a delta against a private artifact. |
| @@ -403,11 +403,11 @@ | |
| 403 | } |
| 404 | if( uuid_is_shunned(blob_str(pUuid)) ){ |
| 405 | blob_reset(&uuid); |
| 406 | return; |
| 407 | } |
| 408 | if( (pXfer->maxTime != -1 && time(NULL) >= pXfer->maxTime) || |
| 409 | pXfer->mxSend<=blob_size(pXfer->pOut) ){ |
| 410 | const char *zFormat = isPriv ? "igot %b 1\n" : "igot %b\n"; |
| 411 | blob_appendf(pXfer->pOut, zFormat, pUuid); |
| 412 | pXfer->nIGotSent++; |
| 413 | blob_reset(&uuid); |
| @@ -445,11 +445,11 @@ | |
| 445 | #endif |
| 446 | } |
| 447 | |
| 448 | /* |
| 449 | ** Send the file identified by rid as a compressed artifact. Basically, |
| 450 | ** send the content exactly as it appears in the BLOB table using |
| 451 | ** a "cfile" card. |
| 452 | */ |
| 453 | static void send_compressed_file(Xfer *pXfer, int rid){ |
| 454 | const char *zContent; |
| 455 | const char *zUuid; |
| @@ -515,11 +515,11 @@ | |
| 515 | ** Except: do not request shunned artifacts. And do not request |
| 516 | ** private artifacts if we are not doing a private transfer. |
| 517 | */ |
| 518 | static void request_phantoms(Xfer *pXfer, int maxReq){ |
| 519 | Stmt q; |
| 520 | db_prepare(&q, |
| 521 | "SELECT uuid FROM phantom JOIN blob USING(rid)" |
| 522 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid) %s", |
| 523 | (pXfer->syncPrivate ? "" : |
| 524 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)") |
| 525 | ); |
| @@ -551,12 +551,12 @@ | |
| 551 | ** Check the signature on an application/x-fossil payload received by |
| 552 | ** the HTTP server. The signature is a line of the following form: |
| 553 | ** |
| 554 | ** login LOGIN NONCE SIGNATURE |
| 555 | ** |
| 556 | ** The NONCE is the SHA1 hash of the remainder of the input. |
| 557 | ** SIGNATURE is the SHA1 checksum of the NONCE concatenated |
| 558 | ** with the users password. |
| 559 | ** |
| 560 | ** The parameters to this routine are ephemeral blobs holding the |
| 561 | ** LOGIN, NONCE and SIGNATURE. |
| 562 | ** |
| @@ -564,11 +564,11 @@ | |
| 564 | ** If everything checks out, the USER.CAP column for the USER table |
| 565 | ** is consulted to set privileges in the global g variable. |
| 566 | ** |
| 567 | ** If anything fails to check out, no changes are made to privileges. |
| 568 | ** |
| 569 | ** Signature generation on the client side is handled by the |
| 570 | ** http_exchange() routine. |
| 571 | ** |
| 572 | ** Return non-zero for a login failure and zero for success. |
| 573 | */ |
| 574 | int check_login(Blob *pLogin, Blob *pNonce, Blob *pSig){ |
| @@ -699,11 +699,11 @@ | |
| 699 | blob_appendf(&deleteWhere, ",%d", rid); |
| 700 | } |
| 701 | } |
| 702 | db_finalize(&q); |
| 703 | db_multi_exec( |
| 704 | "DELETE FROM unclustered WHERE rid NOT IN (0 %s)", |
| 705 | blob_str(&deleteWhere) |
| 706 | ); |
| 707 | blob_reset(&deleteWhere); |
| 708 | if( nRow>0 ){ |
| 709 | md5sum_blob(&cluster, &cksum); |
| @@ -738,21 +738,21 @@ | |
| 738 | */ |
| 739 | static int send_unclustered(Xfer *pXfer){ |
| 740 | Stmt q; |
| 741 | int cnt = 0; |
| 742 | if( pXfer->resync ){ |
| 743 | db_prepare(&q, |
| 744 | "SELECT uuid, rid FROM blob" |
| 745 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 746 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 747 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 748 | " AND blob.rid<=%d" |
| 749 | " ORDER BY blob.rid DESC", |
| 750 | pXfer->resync |
| 751 | ); |
| 752 | }else{ |
| 753 | db_prepare(&q, |
| 754 | "SELECT uuid FROM unclustered JOIN blob USING(rid)" |
| 755 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 756 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 757 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 758 | ); |
| @@ -772,11 +772,11 @@ | |
| 772 | /* |
| 773 | ** Send an igot message for every artifact. |
| 774 | */ |
| 775 | static void send_all(Xfer *pXfer){ |
| 776 | Stmt q; |
| 777 | db_prepare(&q, |
| 778 | "SELECT uuid FROM blob " |
| 779 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 780 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 781 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 782 | ); |
| @@ -1033,12 +1033,12 @@ | |
| 1033 | }else{ |
| 1034 | server_private_xfer_not_authorized(); |
| 1035 | } |
| 1036 | } |
| 1037 | }else |
| 1038 | |
| 1039 | |
| 1040 | /* pull SERVERCODE PROJECTCODE |
| 1041 | ** push SERVERCODE PROJECTCODE |
| 1042 | ** |
| 1043 | ** The client wants either send or receive. The server should |
| 1044 | ** verify that the project code matches. |
| @@ -1142,14 +1142,14 @@ | |
| 1142 | ){ |
| 1143 | cgi_reset_content(); |
| 1144 | @ error login\sfailed |
| 1145 | nErr++; |
| 1146 | break; |
| 1147 | } |
| 1148 | } |
| 1149 | }else |
| 1150 | |
| 1151 | /* reqconfig NAME |
| 1152 | ** |
| 1153 | ** Request a configuration value |
| 1154 | */ |
| 1155 | if( blob_eq(&xfer.aToken[0], "reqconfig") |
| @@ -1167,11 +1167,11 @@ | |
| 1167 | /* Old style configuration transfer */ |
| 1168 | send_legacy_config_card(&xfer, zName); |
| 1169 | } |
| 1170 | } |
| 1171 | }else |
| 1172 | |
| 1173 | /* config NAME SIZE \n CONTENT |
| 1174 | ** |
| 1175 | ** Receive a configuration value from the client. This is only |
| 1176 | ** permitted for high-privilege users. |
| 1177 | */ |
| @@ -1194,11 +1194,11 @@ | |
| 1194 | configure_receive(zName, &content, CONFIGSET_ALL); |
| 1195 | blob_reset(&content); |
| 1196 | blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR); |
| 1197 | }else |
| 1198 | |
| 1199 | |
| 1200 | |
| 1201 | /* cookie TEXT |
| 1202 | ** |
| 1203 | ** A cookie contains a arbitrary-length argument that is server-defined. |
| 1204 | ** The argument must be encoded so as not to contain any whitespace. |
| @@ -1413,11 +1413,11 @@ | |
| 1413 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1414 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1415 | double rSkew = 0.0; /* Maximum time skew */ |
| 1416 | |
| 1417 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1418 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 |
| 1419 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1420 | |
| 1421 | transport_stats(0, 0, 1); |
| 1422 | socket_global_init(); |
| 1423 | memset(&xfer, 0, sizeof(xfer)); |
| @@ -1487,11 +1487,11 @@ | |
| 1487 | */ |
| 1488 | zCookie = db_get("cookie", 0); |
| 1489 | if( zCookie ){ |
| 1490 | blob_appendf(&send, "cookie %s\n", zCookie); |
| 1491 | } |
| 1492 | |
| 1493 | /* Generate gimme cards for phantoms and leaf cards |
| 1494 | ** for all leaves. |
| 1495 | */ |
| 1496 | if( (syncFlags & SYNC_PULL)!=0 |
| 1497 | || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1) |
| @@ -1503,11 +1503,11 @@ | |
| 1503 | nCardSent += send_unclustered(&xfer); |
| 1504 | if( syncFlags & SYNC_PRIVATE ) send_private(&xfer); |
| 1505 | } |
| 1506 | |
| 1507 | /* Send configuration parameter requests. On a clone, delay sending |
| 1508 | ** this until the second cycle since the login card might fail on |
| 1509 | ** the first cycle. |
| 1510 | */ |
| 1511 | if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){ |
| 1512 | const char *zName; |
| 1513 | if( zOpType==0 ) zOpType = "Pull"; |
| @@ -1663,20 +1663,20 @@ | |
| 1663 | if( syncFlags & SYNC_PUSH ){ |
| 1664 | int rid = rid_from_uuid(&xfer.aToken[1], 0, 0); |
| 1665 | if( rid ) send_file(&xfer, rid, &xfer.aToken[1], 0); |
| 1666 | } |
| 1667 | }else |
| 1668 | |
| 1669 | /* igot UUID ?PRIVATEFLAG? |
| 1670 | ** |
| 1671 | ** Server announces that it has a particular file. If this is |
| 1672 | ** not a file that we have and we are pulling, then create a |
| 1673 | ** phantom to cause this file to be requested on the next cycle. |
| 1674 | ** Always remember that the server has this file so that we do |
| 1675 | ** not transmit it by accident. |
| 1676 | ** |
| 1677 | ** If the PRIVATE argument exists and is 1, then the file is |
| 1678 | ** private. Pretend it does not exists if we are not pulling |
| 1679 | ** private files. |
| 1680 | */ |
| 1681 | if( xfer.nToken>=2 |
| 1682 | && blob_eq(&xfer.aToken[0], "igot") |
| @@ -1693,12 +1693,12 @@ | |
| 1693 | rid = content_new(blob_str(&xfer.aToken[1]), isPriv); |
| 1694 | if( rid ) newPhantom = 1; |
| 1695 | } |
| 1696 | remote_has(rid); |
| 1697 | }else |
| 1698 | |
| 1699 | |
| 1700 | /* push SERVERCODE PRODUCTCODE |
| 1701 | ** |
| 1702 | ** Should only happen in response to a clone. This message tells |
| 1703 | ** the client what product to use for the new database. |
| 1704 | */ |
| @@ -1716,11 +1716,11 @@ | |
| 1716 | db_set("project-code", zPCode, 0); |
| 1717 | } |
| 1718 | if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno); |
| 1719 | nCardSent++; |
| 1720 | }else |
| 1721 | |
| 1722 | /* config NAME SIZE \n CONTENT |
| 1723 | ** |
| 1724 | ** Receive a configuration value from the server. |
| 1725 | ** |
| 1726 | ** The received configuration setting is silently ignored if it was |
| @@ -1738,11 +1738,11 @@ | |
| 1738 | nArtifactRcvd++; |
| 1739 | blob_reset(&content); |
| 1740 | blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR); |
| 1741 | }else |
| 1742 | |
| 1743 | |
| 1744 | /* cookie TEXT |
| 1745 | ** |
| 1746 | ** The server might include a cookie in its reply. The client |
| 1747 | ** should remember this cookie and send it back to the server |
| 1748 | ** in its next query. |
| @@ -1780,11 +1780,11 @@ | |
| 1780 | ** |
| 1781 | ** Print a message. Similar to "error" but does not stop processing. |
| 1782 | ** |
| 1783 | ** If the "login failed" message is seen, clear the sync password prior |
| 1784 | ** to the next cycle. |
| 1785 | */ |
| 1786 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| 1787 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1788 | defossilize(zMsg); |
| 1789 | if( (syncFlags & SYNC_PUSH) && zMsg && strglob("pull only *", zMsg) ){ |
| 1790 | syncFlags &= ~SYNC_PUSH; |
| @@ -1797,11 +1797,11 @@ | |
| 1797 | }else |
| 1798 | |
| 1799 | /* pragma NAME VALUE... |
| 1800 | ** |
| 1801 | ** The server can send pragmas to try to convey meta-information to |
| 1802 | ** the client. These are informational only. Unknown pragmas are |
| 1803 | ** silently ignored. |
| 1804 | */ |
| 1805 | if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){ |
| 1806 | }else |
| 1807 | |
| @@ -1810,14 +1810,14 @@ | |
| 1810 | ** Report an error and abandon the sync session. |
| 1811 | ** |
| 1812 | ** Except, when cloning we will sometimes get an error on the |
| 1813 | ** first message exchange because the project-code is unknown |
| 1814 | ** and so the login card on the request was invalid. The project-code |
| 1815 | ** is returned in the reply before the error card, so second and |
| 1816 | ** subsequent messages should be OK. Nevertheless, we need to ignore |
| 1817 | ** the error card on the first message of a clone. |
| 1818 | */ |
| 1819 | if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){ |
| 1820 | if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){ |
| 1821 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1822 | defossilize(zMsg); |
| 1823 | fossil_force_newline(); |
| @@ -1894,11 +1894,11 @@ | |
| 1894 | xfer.nFileRcvd = 0; |
| 1895 | xfer.nDeltaRcvd = 0; |
| 1896 | xfer.nDanglingFile = 0; |
| 1897 | |
| 1898 | /* If we have one or more files queued to send, then go |
| 1899 | ** another round |
| 1900 | */ |
| 1901 | if( xfer.nFileSent+xfer.nDeltaSent>0 ){ |
| 1902 | go = 1; |
| 1903 | } |
| 1904 | |
| @@ -1908,11 +1908,11 @@ | |
| 1908 | /* Stop the cycle if the server sends a "clone_seqno 0" card and |
| 1909 | ** we have gone at least two rounds. Always go at least two rounds |
| 1910 | ** on a clone in order to be sure to retrieve the configuration |
| 1911 | ** information which is only sent on the second round. |
| 1912 | */ |
| 1913 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 1914 | }; |
| 1915 | transport_stats(&nSent, &nRcvd, 1); |
| 1916 | if( (rSkew*24.0*3600.0) > 10.0 ){ |
| 1917 | fossil_warning("*** time skew *** server is fast by %s", |
| 1918 | db_timespan_name(rSkew)); |
| 1919 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -94,11 +94,11 @@ | |
| 94 | db_reset(&q); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /* |
| 99 | ** The aToken[0..nToken-1] blob array is a parse of a "file" line |
| 100 | ** message. This routine finishes parsing that message and does |
| 101 | ** a record insert of the file. |
| 102 | ** |
| 103 | ** The file line is in one of the following two forms: |
| 104 | ** |
| @@ -119,14 +119,14 @@ | |
| 119 | int n; |
| 120 | int rid; |
| 121 | int srcid = 0; |
| 122 | Blob content, hash; |
| 123 | int isPriv; |
| 124 | |
| 125 | isPriv = pXfer->nextIsPrivate; |
| 126 | pXfer->nextIsPrivate = 0; |
| 127 | if( pXfer->nToken<3 |
| 128 | || pXfer->nToken>4 |
| 129 | || !blob_is_uuid(&pXfer->aToken[1]) |
| 130 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-1], &n) |
| 131 | || n<0 |
| 132 | || (pXfer->nToken==4 && !blob_is_uuid(&pXfer->aToken[2])) |
| @@ -198,11 +198,11 @@ | |
| 198 | assert( blob_is_reset(&content) ); |
| 199 | remote_has(rid); |
| 200 | } |
| 201 | |
| 202 | /* |
| 203 | ** The aToken[0..nToken-1] blob array is a parse of a "cfile" line |
| 204 | ** message. This routine finishes parsing that message and does |
| 205 | ** a record insert of the file. The difference between "file" and |
| 206 | ** "cfile" is that with "cfile" the content is already compressed. |
| 207 | ** |
| 208 | ** The file line is in one of the following two forms: |
| @@ -227,14 +227,14 @@ | |
| 227 | int szU; /* USIZE */ |
| 228 | int rid; |
| 229 | int srcid = 0; |
| 230 | Blob content; |
| 231 | int isPriv; |
| 232 | |
| 233 | isPriv = pXfer->nextIsPrivate; |
| 234 | pXfer->nextIsPrivate = 0; |
| 235 | if( pXfer->nToken<4 |
| 236 | || pXfer->nToken>5 |
| 237 | || !blob_is_uuid(&pXfer->aToken[1]) |
| 238 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-2], &szU) |
| 239 | || !blob_is_int(&pXfer->aToken[pXfer->nToken-1], &szC) |
| 240 | || szC<0 || szU<0 |
| @@ -284,11 +284,11 @@ | |
| 284 | ){ |
| 285 | static const char *const azQuery[] = { |
| 286 | "SELECT pid FROM plink x" |
| 287 | " WHERE cid=%d" |
| 288 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)", |
| 289 | |
| 290 | "SELECT pid, min(mtime) FROM mlink, event ON mlink.mid=event.objid" |
| 291 | " WHERE fid=%d" |
| 292 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)" |
| 293 | }; |
| 294 | int i; |
| @@ -321,11 +321,11 @@ | |
| 321 | } |
| 322 | return size; |
| 323 | } |
| 324 | |
| 325 | /* |
| 326 | ** Try to send a file as a native delta. |
| 327 | ** If successful, return the number of bytes in the delta. |
| 328 | ** If we cannot generate an appropriate delta, then send |
| 329 | ** nothing and return zero. |
| 330 | ** |
| 331 | ** Never send a delta against a private artifact. |
| @@ -403,11 +403,11 @@ | |
| 403 | } |
| 404 | if( uuid_is_shunned(blob_str(pUuid)) ){ |
| 405 | blob_reset(&uuid); |
| 406 | return; |
| 407 | } |
| 408 | if( (pXfer->maxTime != -1 && time(NULL) >= pXfer->maxTime) || |
| 409 | pXfer->mxSend<=blob_size(pXfer->pOut) ){ |
| 410 | const char *zFormat = isPriv ? "igot %b 1\n" : "igot %b\n"; |
| 411 | blob_appendf(pXfer->pOut, zFormat, pUuid); |
| 412 | pXfer->nIGotSent++; |
| 413 | blob_reset(&uuid); |
| @@ -445,11 +445,11 @@ | |
| 445 | #endif |
| 446 | } |
| 447 | |
| 448 | /* |
| 449 | ** Send the file identified by rid as a compressed artifact. Basically, |
| 450 | ** send the content exactly as it appears in the BLOB table using |
| 451 | ** a "cfile" card. |
| 452 | */ |
| 453 | static void send_compressed_file(Xfer *pXfer, int rid){ |
| 454 | const char *zContent; |
| 455 | const char *zUuid; |
| @@ -515,11 +515,11 @@ | |
| 515 | ** Except: do not request shunned artifacts. And do not request |
| 516 | ** private artifacts if we are not doing a private transfer. |
| 517 | */ |
| 518 | static void request_phantoms(Xfer *pXfer, int maxReq){ |
| 519 | Stmt q; |
| 520 | db_prepare(&q, |
| 521 | "SELECT uuid FROM phantom JOIN blob USING(rid)" |
| 522 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid) %s", |
| 523 | (pXfer->syncPrivate ? "" : |
| 524 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)") |
| 525 | ); |
| @@ -551,12 +551,12 @@ | |
| 551 | ** Check the signature on an application/x-fossil payload received by |
| 552 | ** the HTTP server. The signature is a line of the following form: |
| 553 | ** |
| 554 | ** login LOGIN NONCE SIGNATURE |
| 555 | ** |
| 556 | ** The NONCE is the SHA1 hash of the remainder of the input. |
| 557 | ** SIGNATURE is the SHA1 checksum of the NONCE concatenated |
| 558 | ** with the users password. |
| 559 | ** |
| 560 | ** The parameters to this routine are ephemeral blobs holding the |
| 561 | ** LOGIN, NONCE and SIGNATURE. |
| 562 | ** |
| @@ -564,11 +564,11 @@ | |
| 564 | ** If everything checks out, the USER.CAP column for the USER table |
| 565 | ** is consulted to set privileges in the global g variable. |
| 566 | ** |
| 567 | ** If anything fails to check out, no changes are made to privileges. |
| 568 | ** |
| 569 | ** Signature generation on the client side is handled by the |
| 570 | ** http_exchange() routine. |
| 571 | ** |
| 572 | ** Return non-zero for a login failure and zero for success. |
| 573 | */ |
| 574 | int check_login(Blob *pLogin, Blob *pNonce, Blob *pSig){ |
| @@ -699,11 +699,11 @@ | |
| 699 | blob_appendf(&deleteWhere, ",%d", rid); |
| 700 | } |
| 701 | } |
| 702 | db_finalize(&q); |
| 703 | db_multi_exec( |
| 704 | "DELETE FROM unclustered WHERE rid NOT IN (0 %s)", |
| 705 | blob_str(&deleteWhere) |
| 706 | ); |
| 707 | blob_reset(&deleteWhere); |
| 708 | if( nRow>0 ){ |
| 709 | md5sum_blob(&cluster, &cksum); |
| @@ -738,21 +738,21 @@ | |
| 738 | */ |
| 739 | static int send_unclustered(Xfer *pXfer){ |
| 740 | Stmt q; |
| 741 | int cnt = 0; |
| 742 | if( pXfer->resync ){ |
| 743 | db_prepare(&q, |
| 744 | "SELECT uuid, rid FROM blob" |
| 745 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 746 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 747 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 748 | " AND blob.rid<=%d" |
| 749 | " ORDER BY blob.rid DESC", |
| 750 | pXfer->resync |
| 751 | ); |
| 752 | }else{ |
| 753 | db_prepare(&q, |
| 754 | "SELECT uuid FROM unclustered JOIN blob USING(rid)" |
| 755 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 756 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 757 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 758 | ); |
| @@ -772,11 +772,11 @@ | |
| 772 | /* |
| 773 | ** Send an igot message for every artifact. |
| 774 | */ |
| 775 | static void send_all(Xfer *pXfer){ |
| 776 | Stmt q; |
| 777 | db_prepare(&q, |
| 778 | "SELECT uuid FROM blob " |
| 779 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 780 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 781 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 782 | ); |
| @@ -1033,12 +1033,12 @@ | |
| 1033 | }else{ |
| 1034 | server_private_xfer_not_authorized(); |
| 1035 | } |
| 1036 | } |
| 1037 | }else |
| 1038 | |
| 1039 | |
| 1040 | /* pull SERVERCODE PROJECTCODE |
| 1041 | ** push SERVERCODE PROJECTCODE |
| 1042 | ** |
| 1043 | ** The client wants either send or receive. The server should |
| 1044 | ** verify that the project code matches. |
| @@ -1142,14 +1142,14 @@ | |
| 1142 | ){ |
| 1143 | cgi_reset_content(); |
| 1144 | @ error login\sfailed |
| 1145 | nErr++; |
| 1146 | break; |
| 1147 | } |
| 1148 | } |
| 1149 | }else |
| 1150 | |
| 1151 | /* reqconfig NAME |
| 1152 | ** |
| 1153 | ** Request a configuration value |
| 1154 | */ |
| 1155 | if( blob_eq(&xfer.aToken[0], "reqconfig") |
| @@ -1167,11 +1167,11 @@ | |
| 1167 | /* Old style configuration transfer */ |
| 1168 | send_legacy_config_card(&xfer, zName); |
| 1169 | } |
| 1170 | } |
| 1171 | }else |
| 1172 | |
| 1173 | /* config NAME SIZE \n CONTENT |
| 1174 | ** |
| 1175 | ** Receive a configuration value from the client. This is only |
| 1176 | ** permitted for high-privilege users. |
| 1177 | */ |
| @@ -1194,11 +1194,11 @@ | |
| 1194 | configure_receive(zName, &content, CONFIGSET_ALL); |
| 1195 | blob_reset(&content); |
| 1196 | blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR); |
| 1197 | }else |
| 1198 | |
| 1199 | |
| 1200 | |
| 1201 | /* cookie TEXT |
| 1202 | ** |
| 1203 | ** A cookie contains a arbitrary-length argument that is server-defined. |
| 1204 | ** The argument must be encoded so as not to contain any whitespace. |
| @@ -1413,11 +1413,11 @@ | |
| 1413 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1414 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1415 | double rSkew = 0.0; /* Maximum time skew */ |
| 1416 | |
| 1417 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1418 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 |
| 1419 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1420 | |
| 1421 | transport_stats(0, 0, 1); |
| 1422 | socket_global_init(); |
| 1423 | memset(&xfer, 0, sizeof(xfer)); |
| @@ -1487,11 +1487,11 @@ | |
| 1487 | */ |
| 1488 | zCookie = db_get("cookie", 0); |
| 1489 | if( zCookie ){ |
| 1490 | blob_appendf(&send, "cookie %s\n", zCookie); |
| 1491 | } |
| 1492 | |
| 1493 | /* Generate gimme cards for phantoms and leaf cards |
| 1494 | ** for all leaves. |
| 1495 | */ |
| 1496 | if( (syncFlags & SYNC_PULL)!=0 |
| 1497 | || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1) |
| @@ -1503,11 +1503,11 @@ | |
| 1503 | nCardSent += send_unclustered(&xfer); |
| 1504 | if( syncFlags & SYNC_PRIVATE ) send_private(&xfer); |
| 1505 | } |
| 1506 | |
| 1507 | /* Send configuration parameter requests. On a clone, delay sending |
| 1508 | ** this until the second cycle since the login card might fail on |
| 1509 | ** the first cycle. |
| 1510 | */ |
| 1511 | if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){ |
| 1512 | const char *zName; |
| 1513 | if( zOpType==0 ) zOpType = "Pull"; |
| @@ -1663,20 +1663,20 @@ | |
| 1663 | if( syncFlags & SYNC_PUSH ){ |
| 1664 | int rid = rid_from_uuid(&xfer.aToken[1], 0, 0); |
| 1665 | if( rid ) send_file(&xfer, rid, &xfer.aToken[1], 0); |
| 1666 | } |
| 1667 | }else |
| 1668 | |
| 1669 | /* igot UUID ?PRIVATEFLAG? |
| 1670 | ** |
| 1671 | ** Server announces that it has a particular file. If this is |
| 1672 | ** not a file that we have and we are pulling, then create a |
| 1673 | ** phantom to cause this file to be requested on the next cycle. |
| 1674 | ** Always remember that the server has this file so that we do |
| 1675 | ** not transmit it by accident. |
| 1676 | ** |
| 1677 | ** If the PRIVATE argument exists and is 1, then the file is |
| 1678 | ** private. Pretend it does not exists if we are not pulling |
| 1679 | ** private files. |
| 1680 | */ |
| 1681 | if( xfer.nToken>=2 |
| 1682 | && blob_eq(&xfer.aToken[0], "igot") |
| @@ -1693,12 +1693,12 @@ | |
| 1693 | rid = content_new(blob_str(&xfer.aToken[1]), isPriv); |
| 1694 | if( rid ) newPhantom = 1; |
| 1695 | } |
| 1696 | remote_has(rid); |
| 1697 | }else |
| 1698 | |
| 1699 | |
| 1700 | /* push SERVERCODE PRODUCTCODE |
| 1701 | ** |
| 1702 | ** Should only happen in response to a clone. This message tells |
| 1703 | ** the client what product to use for the new database. |
| 1704 | */ |
| @@ -1716,11 +1716,11 @@ | |
| 1716 | db_set("project-code", zPCode, 0); |
| 1717 | } |
| 1718 | if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno); |
| 1719 | nCardSent++; |
| 1720 | }else |
| 1721 | |
| 1722 | /* config NAME SIZE \n CONTENT |
| 1723 | ** |
| 1724 | ** Receive a configuration value from the server. |
| 1725 | ** |
| 1726 | ** The received configuration setting is silently ignored if it was |
| @@ -1738,11 +1738,11 @@ | |
| 1738 | nArtifactRcvd++; |
| 1739 | blob_reset(&content); |
| 1740 | blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR); |
| 1741 | }else |
| 1742 | |
| 1743 | |
| 1744 | /* cookie TEXT |
| 1745 | ** |
| 1746 | ** The server might include a cookie in its reply. The client |
| 1747 | ** should remember this cookie and send it back to the server |
| 1748 | ** in its next query. |
| @@ -1780,11 +1780,11 @@ | |
| 1780 | ** |
| 1781 | ** Print a message. Similar to "error" but does not stop processing. |
| 1782 | ** |
| 1783 | ** If the "login failed" message is seen, clear the sync password prior |
| 1784 | ** to the next cycle. |
| 1785 | */ |
| 1786 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| 1787 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1788 | defossilize(zMsg); |
| 1789 | if( (syncFlags & SYNC_PUSH) && zMsg && strglob("pull only *", zMsg) ){ |
| 1790 | syncFlags &= ~SYNC_PUSH; |
| @@ -1797,11 +1797,11 @@ | |
| 1797 | }else |
| 1798 | |
| 1799 | /* pragma NAME VALUE... |
| 1800 | ** |
| 1801 | ** The server can send pragmas to try to convey meta-information to |
| 1802 | ** the client. These are informational only. Unknown pragmas are |
| 1803 | ** silently ignored. |
| 1804 | */ |
| 1805 | if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){ |
| 1806 | }else |
| 1807 | |
| @@ -1810,14 +1810,14 @@ | |
| 1810 | ** Report an error and abandon the sync session. |
| 1811 | ** |
| 1812 | ** Except, when cloning we will sometimes get an error on the |
| 1813 | ** first message exchange because the project-code is unknown |
| 1814 | ** and so the login card on the request was invalid. The project-code |
| 1815 | ** is returned in the reply before the error card, so second and |
| 1816 | ** subsequent messages should be OK. Nevertheless, we need to ignore |
| 1817 | ** the error card on the first message of a clone. |
| 1818 | */ |
| 1819 | if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){ |
| 1820 | if( (syncFlags & SYNC_CLONE)==0 || nCycle>0 ){ |
| 1821 | char *zMsg = blob_terminate(&xfer.aToken[1]); |
| 1822 | defossilize(zMsg); |
| 1823 | fossil_force_newline(); |
| @@ -1894,11 +1894,11 @@ | |
| 1894 | xfer.nFileRcvd = 0; |
| 1895 | xfer.nDeltaRcvd = 0; |
| 1896 | xfer.nDanglingFile = 0; |
| 1897 | |
| 1898 | /* If we have one or more files queued to send, then go |
| 1899 | ** another round |
| 1900 | */ |
| 1901 | if( xfer.nFileSent+xfer.nDeltaSent>0 ){ |
| 1902 | go = 1; |
| 1903 | } |
| 1904 | |
| @@ -1908,11 +1908,11 @@ | |
| 1908 | /* Stop the cycle if the server sends a "clone_seqno 0" card and |
| 1909 | ** we have gone at least two rounds. Always go at least two rounds |
| 1910 | ** on a clone in order to be sure to retrieve the configuration |
| 1911 | ** information which is only sent on the second round. |
| 1912 | */ |
| 1913 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 1914 | }; |
| 1915 | transport_stats(&nSent, &nRcvd, 1); |
| 1916 | if( (rSkew*24.0*3600.0) > 10.0 ){ |
| 1917 | fossil_warning("*** time skew *** server is fast by %s", |
| 1918 | db_timespan_name(rSkew)); |
| 1919 |
+5
-5
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -158,17 +158,17 @@ | ||
| 158 | 158 | put16(&zHdr[8], iMethod); |
| 159 | 159 | put16(&zHdr[10], dosTime); |
| 160 | 160 | put16(&zHdr[12], dosDate); |
| 161 | 161 | put16(&zHdr[26], nameLen); |
| 162 | 162 | put16(&zHdr[28], 13); |
| 163 | - | |
| 163 | + | |
| 164 | 164 | put16(&zExTime[0], 0x5455); |
| 165 | 165 | put16(&zExTime[2], 9); |
| 166 | 166 | zExTime[4] = 3; |
| 167 | 167 | put32(&zExTime[5], unixTime); |
| 168 | 168 | put32(&zExTime[9], unixTime); |
| 169 | - | |
| 169 | + | |
| 170 | 170 | |
| 171 | 171 | /* Write the header and filename. |
| 172 | 172 | */ |
| 173 | 173 | iStart = blob_size(&body); |
| 174 | 174 | blob_append(&body, zHdr, 30); |
| @@ -202,19 +202,19 @@ | ||
| 202 | 202 | blob_append(&body, zOutBuf, toOut); |
| 203 | 203 | }while( stream.avail_out==0 ); |
| 204 | 204 | nByte = stream.total_in; |
| 205 | 205 | nByteCompr = stream.total_out; |
| 206 | 206 | deflateEnd(&stream); |
| 207 | - | |
| 207 | + | |
| 208 | 208 | /* Go back and write the header, now that we know the compressed file size. |
| 209 | 209 | */ |
| 210 | 210 | z = &blob_buffer(&body)[iStart]; |
| 211 | 211 | put32(&z[14], iCRC); |
| 212 | 212 | put32(&z[18], nByteCompr); |
| 213 | 213 | put32(&z[22], nByte); |
| 214 | 214 | } |
| 215 | - | |
| 215 | + | |
| 216 | 216 | /* Make an entry in the tables of contents |
| 217 | 217 | */ |
| 218 | 218 | memset(zBuf, 0, sizeof(zBuf)); |
| 219 | 219 | put32(&zBuf[0], 0x02014b50); |
| 220 | 220 | put16(&zBuf[4], 0x0317); |
| @@ -322,11 +322,11 @@ | ||
| 322 | 322 | Blob mfile, hash, file; |
| 323 | 323 | Manifest *pManifest; |
| 324 | 324 | ManifestFile *pFile; |
| 325 | 325 | Blob filename; |
| 326 | 326 | int nPrefix; |
| 327 | - | |
| 327 | + | |
| 328 | 328 | content_get(rid, &mfile); |
| 329 | 329 | if( blob_size(&mfile)==0 ){ |
| 330 | 330 | blob_zero(pZip); |
| 331 | 331 | return; |
| 332 | 332 | } |
| 333 | 333 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -158,17 +158,17 @@ | |
| 158 | put16(&zHdr[8], iMethod); |
| 159 | put16(&zHdr[10], dosTime); |
| 160 | put16(&zHdr[12], dosDate); |
| 161 | put16(&zHdr[26], nameLen); |
| 162 | put16(&zHdr[28], 13); |
| 163 | |
| 164 | put16(&zExTime[0], 0x5455); |
| 165 | put16(&zExTime[2], 9); |
| 166 | zExTime[4] = 3; |
| 167 | put32(&zExTime[5], unixTime); |
| 168 | put32(&zExTime[9], unixTime); |
| 169 | |
| 170 | |
| 171 | /* Write the header and filename. |
| 172 | */ |
| 173 | iStart = blob_size(&body); |
| 174 | blob_append(&body, zHdr, 30); |
| @@ -202,19 +202,19 @@ | |
| 202 | blob_append(&body, zOutBuf, toOut); |
| 203 | }while( stream.avail_out==0 ); |
| 204 | nByte = stream.total_in; |
| 205 | nByteCompr = stream.total_out; |
| 206 | deflateEnd(&stream); |
| 207 | |
| 208 | /* Go back and write the header, now that we know the compressed file size. |
| 209 | */ |
| 210 | z = &blob_buffer(&body)[iStart]; |
| 211 | put32(&z[14], iCRC); |
| 212 | put32(&z[18], nByteCompr); |
| 213 | put32(&z[22], nByte); |
| 214 | } |
| 215 | |
| 216 | /* Make an entry in the tables of contents |
| 217 | */ |
| 218 | memset(zBuf, 0, sizeof(zBuf)); |
| 219 | put32(&zBuf[0], 0x02014b50); |
| 220 | put16(&zBuf[4], 0x0317); |
| @@ -322,11 +322,11 @@ | |
| 322 | Blob mfile, hash, file; |
| 323 | Manifest *pManifest; |
| 324 | ManifestFile *pFile; |
| 325 | Blob filename; |
| 326 | int nPrefix; |
| 327 | |
| 328 | content_get(rid, &mfile); |
| 329 | if( blob_size(&mfile)==0 ){ |
| 330 | blob_zero(pZip); |
| 331 | return; |
| 332 | } |
| 333 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -158,17 +158,17 @@ | |
| 158 | put16(&zHdr[8], iMethod); |
| 159 | put16(&zHdr[10], dosTime); |
| 160 | put16(&zHdr[12], dosDate); |
| 161 | put16(&zHdr[26], nameLen); |
| 162 | put16(&zHdr[28], 13); |
| 163 | |
| 164 | put16(&zExTime[0], 0x5455); |
| 165 | put16(&zExTime[2], 9); |
| 166 | zExTime[4] = 3; |
| 167 | put32(&zExTime[5], unixTime); |
| 168 | put32(&zExTime[9], unixTime); |
| 169 | |
| 170 | |
| 171 | /* Write the header and filename. |
| 172 | */ |
| 173 | iStart = blob_size(&body); |
| 174 | blob_append(&body, zHdr, 30); |
| @@ -202,19 +202,19 @@ | |
| 202 | blob_append(&body, zOutBuf, toOut); |
| 203 | }while( stream.avail_out==0 ); |
| 204 | nByte = stream.total_in; |
| 205 | nByteCompr = stream.total_out; |
| 206 | deflateEnd(&stream); |
| 207 | |
| 208 | /* Go back and write the header, now that we know the compressed file size. |
| 209 | */ |
| 210 | z = &blob_buffer(&body)[iStart]; |
| 211 | put32(&z[14], iCRC); |
| 212 | put32(&z[18], nByteCompr); |
| 213 | put32(&z[22], nByte); |
| 214 | } |
| 215 | |
| 216 | /* Make an entry in the tables of contents |
| 217 | */ |
| 218 | memset(zBuf, 0, sizeof(zBuf)); |
| 219 | put32(&zBuf[0], 0x02014b50); |
| 220 | put16(&zBuf[4], 0x0317); |
| @@ -322,11 +322,11 @@ | |
| 322 | Blob mfile, hash, file; |
| 323 | Manifest *pManifest; |
| 324 | ManifestFile *pFile; |
| 325 | Blob filename; |
| 326 | int nPrefix; |
| 327 | |
| 328 | content_get(rid, &mfile); |
| 329 | if( blob_size(&mfile)==0 ){ |
| 330 | blob_zero(pZip); |
| 331 | return; |
| 332 | } |
| 333 |
+6
-6
| --- test/merge_renames.test | ||
| +++ test/merge_renames.test | ||
| @@ -44,11 +44,11 @@ | ||
| 44 | 44 | write_file f1 "line6" |
| 45 | 45 | fossil commit -m "c4" |
| 46 | 46 | |
| 47 | 47 | fossil update pivot |
| 48 | 48 | fossil mv f1 f2 |
| 49 | -exec mv f1 f2 | |
| 49 | +file rename -force f1 f2 | |
| 50 | 50 | fossil commit -b rename -m "c5" |
| 51 | 51 | |
| 52 | 52 | fossil merge trunk |
| 53 | 53 | fossil commit -m "trunk merged" |
| 54 | 54 | |
| @@ -74,11 +74,11 @@ | ||
| 74 | 74 | } else { |
| 75 | 75 | test merge_renames-1 1 |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | fossil close -f |
| 79 | -exec rm rep.fossil | |
| 79 | +file delete rep.fossil | |
| 80 | 80 | |
| 81 | 81 | ###################################### |
| 82 | 82 | # Test 2 # |
| 83 | 83 | # Reported: Ticket [74413366fe5067] # |
| 84 | 84 | ###################################### |
| @@ -94,11 +94,11 @@ | ||
| 94 | 94 | write_file f2 "line2" |
| 95 | 95 | fossil add f2 |
| 96 | 96 | fossil commit -m "newfile" |
| 97 | 97 | |
| 98 | 98 | fossil mv f2 f2new |
| 99 | -exec mv f2 f2new | |
| 99 | +file rename -force f2 f2new | |
| 100 | 100 | fossil commit -m "rename" |
| 101 | 101 | |
| 102 | 102 | fossil update pivot |
| 103 | 103 | write_file f1 "line3" |
| 104 | 104 | fossil commit -b branch -m "change" |
| @@ -126,11 +126,11 @@ | ||
| 126 | 126 | } else { |
| 127 | 127 | test merge_renames-2 1 |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | fossil close -f |
| 131 | -exec rm rep.fossil | |
| 131 | +file delete rep.fossil | |
| 132 | 132 | |
| 133 | 133 | ###################################### |
| 134 | 134 | # Test 3 # |
| 135 | 135 | # Reported: Ticket [30b28cf351] # |
| 136 | 136 | ###################################### |
| @@ -146,11 +146,11 @@ | ||
| 146 | 146 | write_file f2 "line2" |
| 147 | 147 | fossil add f2 |
| 148 | 148 | fossil commit -m "newfile" |
| 149 | 149 | |
| 150 | 150 | fossil mv f2 f2new |
| 151 | -exec mv f2 f2new | |
| 151 | +file rename -force f2 f2new | |
| 152 | 152 | fossil commit -m "rename" |
| 153 | 153 | |
| 154 | 154 | fossil update pivot |
| 155 | 155 | write_file f1 "line3" |
| 156 | 156 | fossil commit -b branch -m "change" |
| @@ -178,11 +178,11 @@ | ||
| 178 | 178 | } else { |
| 179 | 179 | test merge_renames-2 1 |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | fossil close -f |
| 183 | -exec rm rep.fossil | |
| 183 | +file delete rep.fossil | |
| 184 | 184 | |
| 185 | 185 | ###################################### |
| 186 | 186 | # Test 4 # |
| 187 | 187 | # Reported: Ticket [67176c3aa4] # |
| 188 | 188 | ###################################### |
| 189 | 189 |
| --- test/merge_renames.test | |
| +++ test/merge_renames.test | |
| @@ -44,11 +44,11 @@ | |
| 44 | write_file f1 "line6" |
| 45 | fossil commit -m "c4" |
| 46 | |
| 47 | fossil update pivot |
| 48 | fossil mv f1 f2 |
| 49 | exec mv f1 f2 |
| 50 | fossil commit -b rename -m "c5" |
| 51 | |
| 52 | fossil merge trunk |
| 53 | fossil commit -m "trunk merged" |
| 54 | |
| @@ -74,11 +74,11 @@ | |
| 74 | } else { |
| 75 | test merge_renames-1 1 |
| 76 | } |
| 77 | |
| 78 | fossil close -f |
| 79 | exec rm rep.fossil |
| 80 | |
| 81 | ###################################### |
| 82 | # Test 2 # |
| 83 | # Reported: Ticket [74413366fe5067] # |
| 84 | ###################################### |
| @@ -94,11 +94,11 @@ | |
| 94 | write_file f2 "line2" |
| 95 | fossil add f2 |
| 96 | fossil commit -m "newfile" |
| 97 | |
| 98 | fossil mv f2 f2new |
| 99 | exec mv f2 f2new |
| 100 | fossil commit -m "rename" |
| 101 | |
| 102 | fossil update pivot |
| 103 | write_file f1 "line3" |
| 104 | fossil commit -b branch -m "change" |
| @@ -126,11 +126,11 @@ | |
| 126 | } else { |
| 127 | test merge_renames-2 1 |
| 128 | } |
| 129 | |
| 130 | fossil close -f |
| 131 | exec rm rep.fossil |
| 132 | |
| 133 | ###################################### |
| 134 | # Test 3 # |
| 135 | # Reported: Ticket [30b28cf351] # |
| 136 | ###################################### |
| @@ -146,11 +146,11 @@ | |
| 146 | write_file f2 "line2" |
| 147 | fossil add f2 |
| 148 | fossil commit -m "newfile" |
| 149 | |
| 150 | fossil mv f2 f2new |
| 151 | exec mv f2 f2new |
| 152 | fossil commit -m "rename" |
| 153 | |
| 154 | fossil update pivot |
| 155 | write_file f1 "line3" |
| 156 | fossil commit -b branch -m "change" |
| @@ -178,11 +178,11 @@ | |
| 178 | } else { |
| 179 | test merge_renames-2 1 |
| 180 | } |
| 181 | |
| 182 | fossil close -f |
| 183 | exec rm rep.fossil |
| 184 | |
| 185 | ###################################### |
| 186 | # Test 4 # |
| 187 | # Reported: Ticket [67176c3aa4] # |
| 188 | ###################################### |
| 189 |
| --- test/merge_renames.test | |
| +++ test/merge_renames.test | |
| @@ -44,11 +44,11 @@ | |
| 44 | write_file f1 "line6" |
| 45 | fossil commit -m "c4" |
| 46 | |
| 47 | fossil update pivot |
| 48 | fossil mv f1 f2 |
| 49 | file rename -force f1 f2 |
| 50 | fossil commit -b rename -m "c5" |
| 51 | |
| 52 | fossil merge trunk |
| 53 | fossil commit -m "trunk merged" |
| 54 | |
| @@ -74,11 +74,11 @@ | |
| 74 | } else { |
| 75 | test merge_renames-1 1 |
| 76 | } |
| 77 | |
| 78 | fossil close -f |
| 79 | file delete rep.fossil |
| 80 | |
| 81 | ###################################### |
| 82 | # Test 2 # |
| 83 | # Reported: Ticket [74413366fe5067] # |
| 84 | ###################################### |
| @@ -94,11 +94,11 @@ | |
| 94 | write_file f2 "line2" |
| 95 | fossil add f2 |
| 96 | fossil commit -m "newfile" |
| 97 | |
| 98 | fossil mv f2 f2new |
| 99 | file rename -force f2 f2new |
| 100 | fossil commit -m "rename" |
| 101 | |
| 102 | fossil update pivot |
| 103 | write_file f1 "line3" |
| 104 | fossil commit -b branch -m "change" |
| @@ -126,11 +126,11 @@ | |
| 126 | } else { |
| 127 | test merge_renames-2 1 |
| 128 | } |
| 129 | |
| 130 | fossil close -f |
| 131 | file delete rep.fossil |
| 132 | |
| 133 | ###################################### |
| 134 | # Test 3 # |
| 135 | # Reported: Ticket [30b28cf351] # |
| 136 | ###################################### |
| @@ -146,11 +146,11 @@ | |
| 146 | write_file f2 "line2" |
| 147 | fossil add f2 |
| 148 | fossil commit -m "newfile" |
| 149 | |
| 150 | fossil mv f2 f2new |
| 151 | file rename -force f2 f2new |
| 152 | fossil commit -m "rename" |
| 153 | |
| 154 | fossil update pivot |
| 155 | write_file f1 "line3" |
| 156 | fossil commit -b branch -m "change" |
| @@ -178,11 +178,11 @@ | |
| 178 | } else { |
| 179 | test merge_renames-2 1 |
| 180 | } |
| 181 | |
| 182 | fossil close -f |
| 183 | file delete rep.fossil |
| 184 | |
| 185 | ###################################### |
| 186 | # Test 4 # |
| 187 | # Reported: Ticket [67176c3aa4] # |
| 188 | ###################################### |
| 189 |
+6
-6
| --- test/merge_renames.test | ||
| +++ test/merge_renames.test | ||
| @@ -44,11 +44,11 @@ | ||
| 44 | 44 | write_file f1 "line6" |
| 45 | 45 | fossil commit -m "c4" |
| 46 | 46 | |
| 47 | 47 | fossil update pivot |
| 48 | 48 | fossil mv f1 f2 |
| 49 | -exec mv f1 f2 | |
| 49 | +file rename -force f1 f2 | |
| 50 | 50 | fossil commit -b rename -m "c5" |
| 51 | 51 | |
| 52 | 52 | fossil merge trunk |
| 53 | 53 | fossil commit -m "trunk merged" |
| 54 | 54 | |
| @@ -74,11 +74,11 @@ | ||
| 74 | 74 | } else { |
| 75 | 75 | test merge_renames-1 1 |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | fossil close -f |
| 79 | -exec rm rep.fossil | |
| 79 | +file delete rep.fossil | |
| 80 | 80 | |
| 81 | 81 | ###################################### |
| 82 | 82 | # Test 2 # |
| 83 | 83 | # Reported: Ticket [74413366fe5067] # |
| 84 | 84 | ###################################### |
| @@ -94,11 +94,11 @@ | ||
| 94 | 94 | write_file f2 "line2" |
| 95 | 95 | fossil add f2 |
| 96 | 96 | fossil commit -m "newfile" |
| 97 | 97 | |
| 98 | 98 | fossil mv f2 f2new |
| 99 | -exec mv f2 f2new | |
| 99 | +file rename -force f2 f2new | |
| 100 | 100 | fossil commit -m "rename" |
| 101 | 101 | |
| 102 | 102 | fossil update pivot |
| 103 | 103 | write_file f1 "line3" |
| 104 | 104 | fossil commit -b branch -m "change" |
| @@ -126,11 +126,11 @@ | ||
| 126 | 126 | } else { |
| 127 | 127 | test merge_renames-2 1 |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | fossil close -f |
| 131 | -exec rm rep.fossil | |
| 131 | +file delete rep.fossil | |
| 132 | 132 | |
| 133 | 133 | ###################################### |
| 134 | 134 | # Test 3 # |
| 135 | 135 | # Reported: Ticket [30b28cf351] # |
| 136 | 136 | ###################################### |
| @@ -146,11 +146,11 @@ | ||
| 146 | 146 | write_file f2 "line2" |
| 147 | 147 | fossil add f2 |
| 148 | 148 | fossil commit -m "newfile" |
| 149 | 149 | |
| 150 | 150 | fossil mv f2 f2new |
| 151 | -exec mv f2 f2new | |
| 151 | +file rename -force f2 f2new | |
| 152 | 152 | fossil commit -m "rename" |
| 153 | 153 | |
| 154 | 154 | fossil update pivot |
| 155 | 155 | write_file f1 "line3" |
| 156 | 156 | fossil commit -b branch -m "change" |
| @@ -178,11 +178,11 @@ | ||
| 178 | 178 | } else { |
| 179 | 179 | test merge_renames-2 1 |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | fossil close -f |
| 183 | -exec rm rep.fossil | |
| 183 | +file delete rep.fossil | |
| 184 | 184 | |
| 185 | 185 | ###################################### |
| 186 | 186 | # Test 4 # |
| 187 | 187 | # Reported: Ticket [67176c3aa4] # |
| 188 | 188 | ###################################### |
| 189 | 189 |
| --- test/merge_renames.test | |
| +++ test/merge_renames.test | |
| @@ -44,11 +44,11 @@ | |
| 44 | write_file f1 "line6" |
| 45 | fossil commit -m "c4" |
| 46 | |
| 47 | fossil update pivot |
| 48 | fossil mv f1 f2 |
| 49 | exec mv f1 f2 |
| 50 | fossil commit -b rename -m "c5" |
| 51 | |
| 52 | fossil merge trunk |
| 53 | fossil commit -m "trunk merged" |
| 54 | |
| @@ -74,11 +74,11 @@ | |
| 74 | } else { |
| 75 | test merge_renames-1 1 |
| 76 | } |
| 77 | |
| 78 | fossil close -f |
| 79 | exec rm rep.fossil |
| 80 | |
| 81 | ###################################### |
| 82 | # Test 2 # |
| 83 | # Reported: Ticket [74413366fe5067] # |
| 84 | ###################################### |
| @@ -94,11 +94,11 @@ | |
| 94 | write_file f2 "line2" |
| 95 | fossil add f2 |
| 96 | fossil commit -m "newfile" |
| 97 | |
| 98 | fossil mv f2 f2new |
| 99 | exec mv f2 f2new |
| 100 | fossil commit -m "rename" |
| 101 | |
| 102 | fossil update pivot |
| 103 | write_file f1 "line3" |
| 104 | fossil commit -b branch -m "change" |
| @@ -126,11 +126,11 @@ | |
| 126 | } else { |
| 127 | test merge_renames-2 1 |
| 128 | } |
| 129 | |
| 130 | fossil close -f |
| 131 | exec rm rep.fossil |
| 132 | |
| 133 | ###################################### |
| 134 | # Test 3 # |
| 135 | # Reported: Ticket [30b28cf351] # |
| 136 | ###################################### |
| @@ -146,11 +146,11 @@ | |
| 146 | write_file f2 "line2" |
| 147 | fossil add f2 |
| 148 | fossil commit -m "newfile" |
| 149 | |
| 150 | fossil mv f2 f2new |
| 151 | exec mv f2 f2new |
| 152 | fossil commit -m "rename" |
| 153 | |
| 154 | fossil update pivot |
| 155 | write_file f1 "line3" |
| 156 | fossil commit -b branch -m "change" |
| @@ -178,11 +178,11 @@ | |
| 178 | } else { |
| 179 | test merge_renames-2 1 |
| 180 | } |
| 181 | |
| 182 | fossil close -f |
| 183 | exec rm rep.fossil |
| 184 | |
| 185 | ###################################### |
| 186 | # Test 4 # |
| 187 | # Reported: Ticket [67176c3aa4] # |
| 188 | ###################################### |
| 189 |
| --- test/merge_renames.test | |
| +++ test/merge_renames.test | |
| @@ -44,11 +44,11 @@ | |
| 44 | write_file f1 "line6" |
| 45 | fossil commit -m "c4" |
| 46 | |
| 47 | fossil update pivot |
| 48 | fossil mv f1 f2 |
| 49 | file rename -force f1 f2 |
| 50 | fossil commit -b rename -m "c5" |
| 51 | |
| 52 | fossil merge trunk |
| 53 | fossil commit -m "trunk merged" |
| 54 | |
| @@ -74,11 +74,11 @@ | |
| 74 | } else { |
| 75 | test merge_renames-1 1 |
| 76 | } |
| 77 | |
| 78 | fossil close -f |
| 79 | file delete rep.fossil |
| 80 | |
| 81 | ###################################### |
| 82 | # Test 2 # |
| 83 | # Reported: Ticket [74413366fe5067] # |
| 84 | ###################################### |
| @@ -94,11 +94,11 @@ | |
| 94 | write_file f2 "line2" |
| 95 | fossil add f2 |
| 96 | fossil commit -m "newfile" |
| 97 | |
| 98 | fossil mv f2 f2new |
| 99 | file rename -force f2 f2new |
| 100 | fossil commit -m "rename" |
| 101 | |
| 102 | fossil update pivot |
| 103 | write_file f1 "line3" |
| 104 | fossil commit -b branch -m "change" |
| @@ -126,11 +126,11 @@ | |
| 126 | } else { |
| 127 | test merge_renames-2 1 |
| 128 | } |
| 129 | |
| 130 | fossil close -f |
| 131 | file delete rep.fossil |
| 132 | |
| 133 | ###################################### |
| 134 | # Test 3 # |
| 135 | # Reported: Ticket [30b28cf351] # |
| 136 | ###################################### |
| @@ -146,11 +146,11 @@ | |
| 146 | write_file f2 "line2" |
| 147 | fossil add f2 |
| 148 | fossil commit -m "newfile" |
| 149 | |
| 150 | fossil mv f2 f2new |
| 151 | file rename -force f2 f2new |
| 152 | fossil commit -m "rename" |
| 153 | |
| 154 | fossil update pivot |
| 155 | write_file f1 "line3" |
| 156 | fossil commit -b branch -m "change" |
| @@ -178,11 +178,11 @@ | |
| 178 | } else { |
| 179 | test merge_renames-2 1 |
| 180 | } |
| 181 | |
| 182 | fossil close -f |
| 183 | file delete rep.fossil |
| 184 | |
| 185 | ###################################### |
| 186 | # Test 4 # |
| 187 | # Reported: Ticket [67176c3aa4] # |
| 188 | ###################################### |
| 189 |
+2
-2
| --- test/revert.test | ||
| +++ test/revert.test | ||
| @@ -91,16 +91,16 @@ | ||
| 91 | 91 | # |
| 92 | 92 | # Add f0 |
| 93 | 93 | write_file f0 "f0" |
| 94 | 94 | fossil add f0 |
| 95 | 95 | # Remove f1 |
| 96 | -exec rm f1 | |
| 96 | +file delete f1 | |
| 97 | 97 | fossil rm f1 |
| 98 | 98 | # Edit f2 |
| 99 | 99 | write_file f2 "f2.1" |
| 100 | 100 | # Rename f3 to f3n |
| 101 | -exec mv f3 f3n | |
| 101 | +file rename -force f3 f3n | |
| 102 | 102 | fossil mv f3 f3n |
| 103 | 103 | |
| 104 | 104 | # Test 'fossil revert' with no arguments |
| 105 | 105 | # |
| 106 | 106 | revert-test 1 -addremove { |
| 107 | 107 |
| --- test/revert.test | |
| +++ test/revert.test | |
| @@ -91,16 +91,16 @@ | |
| 91 | # |
| 92 | # Add f0 |
| 93 | write_file f0 "f0" |
| 94 | fossil add f0 |
| 95 | # Remove f1 |
| 96 | exec rm f1 |
| 97 | fossil rm f1 |
| 98 | # Edit f2 |
| 99 | write_file f2 "f2.1" |
| 100 | # Rename f3 to f3n |
| 101 | exec mv f3 f3n |
| 102 | fossil mv f3 f3n |
| 103 | |
| 104 | # Test 'fossil revert' with no arguments |
| 105 | # |
| 106 | revert-test 1 -addremove { |
| 107 |
| --- test/revert.test | |
| +++ test/revert.test | |
| @@ -91,16 +91,16 @@ | |
| 91 | # |
| 92 | # Add f0 |
| 93 | write_file f0 "f0" |
| 94 | fossil add f0 |
| 95 | # Remove f1 |
| 96 | file delete f1 |
| 97 | fossil rm f1 |
| 98 | # Edit f2 |
| 99 | write_file f2 "f2.1" |
| 100 | # Rename f3 to f3n |
| 101 | file rename -force f3 f3n |
| 102 | fossil mv f3 f3n |
| 103 | |
| 104 | # Test 'fossil revert' with no arguments |
| 105 | # |
| 106 | revert-test 1 -addremove { |
| 107 |
+2
-2
| --- test/revert.test | ||
| +++ test/revert.test | ||
| @@ -91,16 +91,16 @@ | ||
| 91 | 91 | # |
| 92 | 92 | # Add f0 |
| 93 | 93 | write_file f0 "f0" |
| 94 | 94 | fossil add f0 |
| 95 | 95 | # Remove f1 |
| 96 | -exec rm f1 | |
| 96 | +file delete f1 | |
| 97 | 97 | fossil rm f1 |
| 98 | 98 | # Edit f2 |
| 99 | 99 | write_file f2 "f2.1" |
| 100 | 100 | # Rename f3 to f3n |
| 101 | -exec mv f3 f3n | |
| 101 | +file rename -force f3 f3n | |
| 102 | 102 | fossil mv f3 f3n |
| 103 | 103 | |
| 104 | 104 | # Test 'fossil revert' with no arguments |
| 105 | 105 | # |
| 106 | 106 | revert-test 1 -addremove { |
| 107 | 107 |
| --- test/revert.test | |
| +++ test/revert.test | |
| @@ -91,16 +91,16 @@ | |
| 91 | # |
| 92 | # Add f0 |
| 93 | write_file f0 "f0" |
| 94 | fossil add f0 |
| 95 | # Remove f1 |
| 96 | exec rm f1 |
| 97 | fossil rm f1 |
| 98 | # Edit f2 |
| 99 | write_file f2 "f2.1" |
| 100 | # Rename f3 to f3n |
| 101 | exec mv f3 f3n |
| 102 | fossil mv f3 f3n |
| 103 | |
| 104 | # Test 'fossil revert' with no arguments |
| 105 | # |
| 106 | revert-test 1 -addremove { |
| 107 |
| --- test/revert.test | |
| +++ test/revert.test | |
| @@ -91,16 +91,16 @@ | |
| 91 | # |
| 92 | # Add f0 |
| 93 | write_file f0 "f0" |
| 94 | fossil add f0 |
| 95 | # Remove f1 |
| 96 | file delete f1 |
| 97 | fossil rm f1 |
| 98 | # Edit f2 |
| 99 | write_file f2 "f2.1" |
| 100 | # Rename f3 to f3n |
| 101 | file rename -force f3 f3n |
| 102 | fossil mv f3 f3n |
| 103 | |
| 104 | # Test 'fossil revert' with no arguments |
| 105 | # |
| 106 | revert-test 1 -addremove { |
| 107 |
+65
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -297,5 +297,70 @@ | ||
| 297 | 297 | |
| 298 | 298 | ############################################################################### |
| 299 | 299 | |
| 300 | 300 | fossil test-th-eval "string last {AB} {abc}" |
| 301 | 301 | test th1-string-last-9 {$RESULT eq {-1}} |
| 302 | + | |
| 303 | +############################################################################### | |
| 304 | + | |
| 305 | +fossil test-th-eval "expr -2147483649.0" | |
| 306 | +test th1-expr-1 {$RESULT eq {-2147483649.0}} | |
| 307 | + | |
| 308 | +############################################################################### | |
| 309 | + | |
| 310 | +fossil test-th-eval "expr -2147483649" | |
| 311 | +test th1-expr-2 {$RESULT eq {2147483647}} | |
| 312 | + | |
| 313 | +############################################################################### | |
| 314 | + | |
| 315 | +fossil test-th-eval "expr -2147483648" | |
| 316 | +test th1-expr-3 {$RESULT eq {-2147483648}} | |
| 317 | + | |
| 318 | +############################################################################### | |
| 319 | + | |
| 320 | +fossil test-th-eval "expr -2147483647" | |
| 321 | +test th1-expr-4 {$RESULT eq {-2147483647}} | |
| 322 | + | |
| 323 | +############################################################################### | |
| 324 | + | |
| 325 | +fossil test-th-eval "expr -1" | |
| 326 | +test th1-expr-5 {$RESULT eq {-1}} | |
| 327 | + | |
| 328 | +############################################################################### | |
| 329 | + | |
| 330 | +fossil test-th-eval "expr 0" | |
| 331 | +test th1-expr-6 {$RESULT eq {0}} | |
| 332 | + | |
| 333 | +############################################################################### | |
| 334 | + | |
| 335 | +fossil test-th-eval "expr 0.0" | |
| 336 | +test th1-expr-7 {$RESULT eq {0.0}} | |
| 337 | + | |
| 338 | +############################################################################### | |
| 339 | + | |
| 340 | +fossil test-th-eval "expr 1" | |
| 341 | +test th1-expr-8 {$RESULT eq {1}} | |
| 342 | + | |
| 343 | +############################################################################### | |
| 344 | + | |
| 345 | +fossil test-th-eval "expr 2147483647" | |
| 346 | +test th1-expr-9 {$RESULT eq {2147483647}} | |
| 347 | + | |
| 348 | +############################################################################### | |
| 349 | + | |
| 350 | +fossil test-th-eval "expr 2147483648" | |
| 351 | +test th1-expr-10 {$RESULT eq {2147483648}} | |
| 352 | + | |
| 353 | +############################################################################### | |
| 354 | + | |
| 355 | +fossil test-th-eval "expr 2147483649" | |
| 356 | +test th1-expr-11 {$RESULT eq {2147483649}} | |
| 357 | + | |
| 358 | +############################################################################### | |
| 359 | + | |
| 360 | +fossil test-th-eval "expr +2147483649" | |
| 361 | +test th1-expr-12 {$RESULT eq {-2147483647}} | |
| 362 | + | |
| 363 | +############################################################################### | |
| 364 | + | |
| 365 | +fossil test-th-eval "expr +2147483649.0" | |
| 366 | +test th1-expr-13 {$RESULT eq {2147483649.0}} | |
| 302 | 367 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -297,5 +297,70 @@ | |
| 297 | |
| 298 | ############################################################################### |
| 299 | |
| 300 | fossil test-th-eval "string last {AB} {abc}" |
| 301 | test th1-string-last-9 {$RESULT eq {-1}} |
| 302 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -297,5 +297,70 @@ | |
| 297 | |
| 298 | ############################################################################### |
| 299 | |
| 300 | fossil test-th-eval "string last {AB} {abc}" |
| 301 | test th1-string-last-9 {$RESULT eq {-1}} |
| 302 | |
| 303 | ############################################################################### |
| 304 | |
| 305 | fossil test-th-eval "expr -2147483649.0" |
| 306 | test th1-expr-1 {$RESULT eq {-2147483649.0}} |
| 307 | |
| 308 | ############################################################################### |
| 309 | |
| 310 | fossil test-th-eval "expr -2147483649" |
| 311 | test th1-expr-2 {$RESULT eq {2147483647}} |
| 312 | |
| 313 | ############################################################################### |
| 314 | |
| 315 | fossil test-th-eval "expr -2147483648" |
| 316 | test th1-expr-3 {$RESULT eq {-2147483648}} |
| 317 | |
| 318 | ############################################################################### |
| 319 | |
| 320 | fossil test-th-eval "expr -2147483647" |
| 321 | test th1-expr-4 {$RESULT eq {-2147483647}} |
| 322 | |
| 323 | ############################################################################### |
| 324 | |
| 325 | fossil test-th-eval "expr -1" |
| 326 | test th1-expr-5 {$RESULT eq {-1}} |
| 327 | |
| 328 | ############################################################################### |
| 329 | |
| 330 | fossil test-th-eval "expr 0" |
| 331 | test th1-expr-6 {$RESULT eq {0}} |
| 332 | |
| 333 | ############################################################################### |
| 334 | |
| 335 | fossil test-th-eval "expr 0.0" |
| 336 | test th1-expr-7 {$RESULT eq {0.0}} |
| 337 | |
| 338 | ############################################################################### |
| 339 | |
| 340 | fossil test-th-eval "expr 1" |
| 341 | test th1-expr-8 {$RESULT eq {1}} |
| 342 | |
| 343 | ############################################################################### |
| 344 | |
| 345 | fossil test-th-eval "expr 2147483647" |
| 346 | test th1-expr-9 {$RESULT eq {2147483647}} |
| 347 | |
| 348 | ############################################################################### |
| 349 | |
| 350 | fossil test-th-eval "expr 2147483648" |
| 351 | test th1-expr-10 {$RESULT eq {2147483648}} |
| 352 | |
| 353 | ############################################################################### |
| 354 | |
| 355 | fossil test-th-eval "expr 2147483649" |
| 356 | test th1-expr-11 {$RESULT eq {2147483649}} |
| 357 | |
| 358 | ############################################################################### |
| 359 | |
| 360 | fossil test-th-eval "expr +2147483649" |
| 361 | test th1-expr-12 {$RESULT eq {-2147483647}} |
| 362 | |
| 363 | ############################################################################### |
| 364 | |
| 365 | fossil test-th-eval "expr +2147483649.0" |
| 366 | test th1-expr-13 {$RESULT eq {2147483649.0}} |
| 367 |
+65
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -297,5 +297,70 @@ | ||
| 297 | 297 | |
| 298 | 298 | ############################################################################### |
| 299 | 299 | |
| 300 | 300 | fossil test-th-eval "string last {AB} {abc}" |
| 301 | 301 | test th1-string-last-9 {$RESULT eq {-1}} |
| 302 | + | |
| 303 | +############################################################################### | |
| 304 | + | |
| 305 | +fossil test-th-eval "expr -2147483649.0" | |
| 306 | +test th1-expr-1 {$RESULT eq {-2147483649.0}} | |
| 307 | + | |
| 308 | +############################################################################### | |
| 309 | + | |
| 310 | +fossil test-th-eval "expr -2147483649" | |
| 311 | +test th1-expr-2 {$RESULT eq {2147483647}} | |
| 312 | + | |
| 313 | +############################################################################### | |
| 314 | + | |
| 315 | +fossil test-th-eval "expr -2147483648" | |
| 316 | +test th1-expr-3 {$RESULT eq {-2147483648}} | |
| 317 | + | |
| 318 | +############################################################################### | |
| 319 | + | |
| 320 | +fossil test-th-eval "expr -2147483647" | |
| 321 | +test th1-expr-4 {$RESULT eq {-2147483647}} | |
| 322 | + | |
| 323 | +############################################################################### | |
| 324 | + | |
| 325 | +fossil test-th-eval "expr -1" | |
| 326 | +test th1-expr-5 {$RESULT eq {-1}} | |
| 327 | + | |
| 328 | +############################################################################### | |
| 329 | + | |
| 330 | +fossil test-th-eval "expr 0" | |
| 331 | +test th1-expr-6 {$RESULT eq {0}} | |
| 332 | + | |
| 333 | +############################################################################### | |
| 334 | + | |
| 335 | +fossil test-th-eval "expr 0.0" | |
| 336 | +test th1-expr-7 {$RESULT eq {0.0}} | |
| 337 | + | |
| 338 | +############################################################################### | |
| 339 | + | |
| 340 | +fossil test-th-eval "expr 1" | |
| 341 | +test th1-expr-8 {$RESULT eq {1}} | |
| 342 | + | |
| 343 | +############################################################################### | |
| 344 | + | |
| 345 | +fossil test-th-eval "expr 2147483647" | |
| 346 | +test th1-expr-9 {$RESULT eq {2147483647}} | |
| 347 | + | |
| 348 | +############################################################################### | |
| 349 | + | |
| 350 | +fossil test-th-eval "expr 2147483648" | |
| 351 | +test th1-expr-10 {$RESULT eq {2147483648}} | |
| 352 | + | |
| 353 | +############################################################################### | |
| 354 | + | |
| 355 | +fossil test-th-eval "expr 2147483649" | |
| 356 | +test th1-expr-11 {$RESULT eq {2147483649}} | |
| 357 | + | |
| 358 | +############################################################################### | |
| 359 | + | |
| 360 | +fossil test-th-eval "expr +2147483649" | |
| 361 | +test th1-expr-12 {$RESULT eq {-2147483647}} | |
| 362 | + | |
| 363 | +############################################################################### | |
| 364 | + | |
| 365 | +fossil test-th-eval "expr +2147483649.0" | |
| 366 | +test th1-expr-13 {$RESULT eq {2147483649.0}} | |
| 302 | 367 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -297,5 +297,70 @@ | |
| 297 | |
| 298 | ############################################################################### |
| 299 | |
| 300 | fossil test-th-eval "string last {AB} {abc}" |
| 301 | test th1-string-last-9 {$RESULT eq {-1}} |
| 302 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -297,5 +297,70 @@ | |
| 297 | |
| 298 | ############################################################################### |
| 299 | |
| 300 | fossil test-th-eval "string last {AB} {abc}" |
| 301 | test th1-string-last-9 {$RESULT eq {-1}} |
| 302 | |
| 303 | ############################################################################### |
| 304 | |
| 305 | fossil test-th-eval "expr -2147483649.0" |
| 306 | test th1-expr-1 {$RESULT eq {-2147483649.0}} |
| 307 | |
| 308 | ############################################################################### |
| 309 | |
| 310 | fossil test-th-eval "expr -2147483649" |
| 311 | test th1-expr-2 {$RESULT eq {2147483647}} |
| 312 | |
| 313 | ############################################################################### |
| 314 | |
| 315 | fossil test-th-eval "expr -2147483648" |
| 316 | test th1-expr-3 {$RESULT eq {-2147483648}} |
| 317 | |
| 318 | ############################################################################### |
| 319 | |
| 320 | fossil test-th-eval "expr -2147483647" |
| 321 | test th1-expr-4 {$RESULT eq {-2147483647}} |
| 322 | |
| 323 | ############################################################################### |
| 324 | |
| 325 | fossil test-th-eval "expr -1" |
| 326 | test th1-expr-5 {$RESULT eq {-1}} |
| 327 | |
| 328 | ############################################################################### |
| 329 | |
| 330 | fossil test-th-eval "expr 0" |
| 331 | test th1-expr-6 {$RESULT eq {0}} |
| 332 | |
| 333 | ############################################################################### |
| 334 | |
| 335 | fossil test-th-eval "expr 0.0" |
| 336 | test th1-expr-7 {$RESULT eq {0.0}} |
| 337 | |
| 338 | ############################################################################### |
| 339 | |
| 340 | fossil test-th-eval "expr 1" |
| 341 | test th1-expr-8 {$RESULT eq {1}} |
| 342 | |
| 343 | ############################################################################### |
| 344 | |
| 345 | fossil test-th-eval "expr 2147483647" |
| 346 | test th1-expr-9 {$RESULT eq {2147483647}} |
| 347 | |
| 348 | ############################################################################### |
| 349 | |
| 350 | fossil test-th-eval "expr 2147483648" |
| 351 | test th1-expr-10 {$RESULT eq {2147483648}} |
| 352 | |
| 353 | ############################################################################### |
| 354 | |
| 355 | fossil test-th-eval "expr 2147483649" |
| 356 | test th1-expr-11 {$RESULT eq {2147483649}} |
| 357 | |
| 358 | ############################################################################### |
| 359 | |
| 360 | fossil test-th-eval "expr +2147483649" |
| 361 | test th1-expr-12 {$RESULT eq {-2147483647}} |
| 362 | |
| 363 | ############################################################################### |
| 364 | |
| 365 | fossil test-th-eval "expr +2147483649.0" |
| 366 | test th1-expr-13 {$RESULT eq {2147483649.0}} |
| 367 |
+2
-2
| --- win/Makefile.mingw.mistachkin | ||
| +++ win/Makefile.mingw.mistachkin | ||
| @@ -13,14 +13,14 @@ | ||
| 13 | 13 | # |
| 14 | 14 | |
| 15 | 15 | #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | 17 | # |
| 18 | -PREFIX = | |
| 18 | +# PREFIX = | |
| 19 | 19 | # PREFIX = mingw32- |
| 20 | 20 | # PREFIX = i686-pc-mingw32- |
| 21 | -# PREFIX = i686-w64-mingw32- | |
| 21 | +PREFIX = i686-w64-mingw32- | |
| 22 | 22 | # PREFIX = x86_64-w64-mingw32- |
| 23 | 23 | |
| 24 | 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | 25 | # in a directory that is separate from the source tree. Just change |
| 26 | 26 | # the following to point from the build directory to the src/ folder. |
| 27 | 27 |
| --- win/Makefile.mingw.mistachkin | |
| +++ win/Makefile.mingw.mistachkin | |
| @@ -13,14 +13,14 @@ | |
| 13 | # |
| 14 | |
| 15 | #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | # |
| 18 | PREFIX = |
| 19 | # PREFIX = mingw32- |
| 20 | # PREFIX = i686-pc-mingw32- |
| 21 | # PREFIX = i686-w64-mingw32- |
| 22 | # PREFIX = x86_64-w64-mingw32- |
| 23 | |
| 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | # in a directory that is separate from the source tree. Just change |
| 26 | # the following to point from the build directory to the src/ folder. |
| 27 |
| --- win/Makefile.mingw.mistachkin | |
| +++ win/Makefile.mingw.mistachkin | |
| @@ -13,14 +13,14 @@ | |
| 13 | # |
| 14 | |
| 15 | #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | # |
| 18 | # PREFIX = |
| 19 | # PREFIX = mingw32- |
| 20 | # PREFIX = i686-pc-mingw32- |
| 21 | PREFIX = i686-w64-mingw32- |
| 22 | # PREFIX = x86_64-w64-mingw32- |
| 23 | |
| 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | # in a directory that is separate from the source tree. Just change |
| 26 | # the following to point from the build directory to the src/ folder. |
| 27 |
+2
-2
| --- win/Makefile.mingw.mistachkin | ||
| +++ win/Makefile.mingw.mistachkin | ||
| @@ -13,14 +13,14 @@ | ||
| 13 | 13 | # |
| 14 | 14 | |
| 15 | 15 | #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | 17 | # |
| 18 | -PREFIX = | |
| 18 | +# PREFIX = | |
| 19 | 19 | # PREFIX = mingw32- |
| 20 | 20 | # PREFIX = i686-pc-mingw32- |
| 21 | -# PREFIX = i686-w64-mingw32- | |
| 21 | +PREFIX = i686-w64-mingw32- | |
| 22 | 22 | # PREFIX = x86_64-w64-mingw32- |
| 23 | 23 | |
| 24 | 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | 25 | # in a directory that is separate from the source tree. Just change |
| 26 | 26 | # the following to point from the build directory to the src/ folder. |
| 27 | 27 |
| --- win/Makefile.mingw.mistachkin | |
| +++ win/Makefile.mingw.mistachkin | |
| @@ -13,14 +13,14 @@ | |
| 13 | # |
| 14 | |
| 15 | #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | # |
| 18 | PREFIX = |
| 19 | # PREFIX = mingw32- |
| 20 | # PREFIX = i686-pc-mingw32- |
| 21 | # PREFIX = i686-w64-mingw32- |
| 22 | # PREFIX = x86_64-w64-mingw32- |
| 23 | |
| 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | # in a directory that is separate from the source tree. Just change |
| 26 | # the following to point from the build directory to the src/ folder. |
| 27 |
| --- win/Makefile.mingw.mistachkin | |
| +++ win/Makefile.mingw.mistachkin | |
| @@ -13,14 +13,14 @@ | |
| 13 | # |
| 14 | |
| 15 | #### Select one of MinGW, MinGW-w64 (32-bit) or MinGW-w64 (64-bit) compilers. |
| 16 | # By default, this is an empty string (i.e. use the native compiler). |
| 17 | # |
| 18 | # PREFIX = |
| 19 | # PREFIX = mingw32- |
| 20 | # PREFIX = i686-pc-mingw32- |
| 21 | PREFIX = i686-w64-mingw32- |
| 22 | # PREFIX = x86_64-w64-mingw32- |
| 23 | |
| 24 | #### The toplevel directory of the source tree. Fossil can be built |
| 25 | # in a directory that is separate from the source tree. Just change |
| 26 | # the following to point from the build directory to the src/ folder. |
| 27 |
+11
-1
| --- www/changes.wiki | ||
| +++ www/changes.wiki | ||
| @@ -1,8 +1,18 @@ | ||
| 1 | 1 | <title>Change Log</title> |
| 2 | 2 | |
| 3 | -<h2>Changes For Version 1.28 (as yet unreleased)</h2> | |
| 3 | +<h2>Changes For Version 1.29 (as yet unreleased)</h2> | |
| 4 | + * Add the ability to display content and diffs for UTF16 text files | |
| 5 | + in the web interface. | |
| 6 | + * Honor timezones in imports from git. | |
| 7 | + * The [/reports] page now requires Read ("o") permissions. The "byweek" | |
| 8 | + report now properly propagates the selected year through the event type | |
| 9 | + filter links. | |
| 10 | + * The [/help/info | info command] now shows leaf status of the checkout. | |
| 11 | + * Add support for tunneling https through a http proxy (Ticket [e854101c4f]). | |
| 12 | + | |
| 13 | +<h2>Changes For Version 1.28 (2014-01-27)</h2> | |
| 4 | 14 | * Enhance [/help?cmd=/reports | /reports] to support event type filtering. |
| 5 | 15 | * When cloning a repository, the user name passed via the URL (if any) |
| 6 | 16 | is now used as the default local admin user's name. |
| 7 | 17 | * Enhance the SSH transport mechanism so that it runs a single instance of |
| 8 | 18 | the "fossil" executable on the remote side, obviating the need for a shell |
| 9 | 19 |
| --- www/changes.wiki | |
| +++ www/changes.wiki | |
| @@ -1,8 +1,18 @@ | |
| 1 | <title>Change Log</title> |
| 2 | |
| 3 | <h2>Changes For Version 1.28 (as yet unreleased)</h2> |
| 4 | * Enhance [/help?cmd=/reports | /reports] to support event type filtering. |
| 5 | * When cloning a repository, the user name passed via the URL (if any) |
| 6 | is now used as the default local admin user's name. |
| 7 | * Enhance the SSH transport mechanism so that it runs a single instance of |
| 8 | the "fossil" executable on the remote side, obviating the need for a shell |
| 9 |
| --- www/changes.wiki | |
| +++ www/changes.wiki | |
| @@ -1,8 +1,18 @@ | |
| 1 | <title>Change Log</title> |
| 2 | |
| 3 | <h2>Changes For Version 1.29 (as yet unreleased)</h2> |
| 4 | * Add the ability to display content and diffs for UTF16 text files |
| 5 | in the web interface. |
| 6 | * Honor timezones in imports from git. |
| 7 | * The [/reports] page now requires Read ("o") permissions. The "byweek" |
| 8 | report now properly propagates the selected year through the event type |
| 9 | filter links. |
| 10 | * The [/help/info | info command] now shows leaf status of the checkout. |
| 11 | * Add support for tunneling https through a http proxy (Ticket [e854101c4f]). |
| 12 | |
| 13 | <h2>Changes For Version 1.28 (2014-01-27)</h2> |
| 14 | * Enhance [/help?cmd=/reports | /reports] to support event type filtering. |
| 15 | * When cloning a repository, the user name passed via the URL (if any) |
| 16 | is now used as the default local admin user's name. |
| 17 | * Enhance the SSH transport mechanism so that it runs a single instance of |
| 18 | the "fossil" executable on the remote side, obviating the need for a shell |
| 19 |
+3
-1
| --- www/sync.wiki | ||
| +++ www/sync.wiki | ||
| @@ -356,18 +356,20 @@ | ||
| 356 | 356 | <li> manifest |
| 357 | 357 | <li> index-page |
| 358 | 358 | <ul></td><td valign="top"><ul> |
| 359 | 359 | <li> timeline-block-markup |
| 360 | 360 | <li> timeline-max-comment |
| 361 | +<li> timeline-plaintext | |
| 361 | 362 | <li> ticket-table |
| 362 | 363 | <li> ticket-common |
| 364 | +<li> ticket-change | |
| 363 | 365 | <li> ticket-newpage |
| 364 | 366 | <li> ticket-viewpage |
| 365 | 367 | <li> ticket-editpage |
| 368 | +<ul></td><td valign="top"><ul> | |
| 366 | 369 | <li> ticket-reportlist |
| 367 | 370 | <li> ticket-report-template |
| 368 | -<ul></td><td valign="top"><ul> | |
| 369 | 371 | <li> ticket-key-template |
| 370 | 372 | <li> ticket-title-expr |
| 371 | 373 | <li> ticket-closed-expr |
| 372 | 374 | <li> @reportfmt |
| 373 | 375 | <li> @user |
| 374 | 376 |
| --- www/sync.wiki | |
| +++ www/sync.wiki | |
| @@ -356,18 +356,20 @@ | |
| 356 | <li> manifest |
| 357 | <li> index-page |
| 358 | <ul></td><td valign="top"><ul> |
| 359 | <li> timeline-block-markup |
| 360 | <li> timeline-max-comment |
| 361 | <li> ticket-table |
| 362 | <li> ticket-common |
| 363 | <li> ticket-newpage |
| 364 | <li> ticket-viewpage |
| 365 | <li> ticket-editpage |
| 366 | <li> ticket-reportlist |
| 367 | <li> ticket-report-template |
| 368 | <ul></td><td valign="top"><ul> |
| 369 | <li> ticket-key-template |
| 370 | <li> ticket-title-expr |
| 371 | <li> ticket-closed-expr |
| 372 | <li> @reportfmt |
| 373 | <li> @user |
| 374 |
| --- www/sync.wiki | |
| +++ www/sync.wiki | |
| @@ -356,18 +356,20 @@ | |
| 356 | <li> manifest |
| 357 | <li> index-page |
| 358 | <ul></td><td valign="top"><ul> |
| 359 | <li> timeline-block-markup |
| 360 | <li> timeline-max-comment |
| 361 | <li> timeline-plaintext |
| 362 | <li> ticket-table |
| 363 | <li> ticket-common |
| 364 | <li> ticket-change |
| 365 | <li> ticket-newpage |
| 366 | <li> ticket-viewpage |
| 367 | <li> ticket-editpage |
| 368 | <ul></td><td valign="top"><ul> |
| 369 | <li> ticket-reportlist |
| 370 | <li> ticket-report-template |
| 371 | <li> ticket-key-template |
| 372 | <li> ticket-title-expr |
| 373 | <li> ticket-closed-expr |
| 374 | <li> @reportfmt |
| 375 | <li> @user |
| 376 |