Fossil SCM
Improvements to error handling and code formatting.
Commit
9270ae240d1730e38f609a5cbc6f3cd6c357824a
Parent
3c9cca2bd8d012c…
2 files changed
+10
-6
+1
-1
+10
-6
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -42,20 +42,24 @@ | ||
| 42 | 42 | int doIndent = 0; |
| 43 | 43 | char *zBuf; |
| 44 | 44 | char zBuffer[400]; |
| 45 | 45 | int lineCnt = 0; |
| 46 | 46 | #if defined(_WIN32) |
| 47 | - if ( lineLength<0 ){ | |
| 47 | + if( lineLength<0 ){ | |
| 48 | 48 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 49 | - GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); | |
| 50 | - tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent + 1; | |
| 49 | + memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); | |
| 50 | + if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){ | |
| 51 | + tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent + 1; | |
| 52 | + } | |
| 51 | 53 | } |
| 52 | 54 | #elif defined(TIOCGWINSZ) |
| 53 | - if ( lineLength<0 ){ | |
| 55 | + if( lineLength<0 ){ | |
| 54 | 56 | struct winsize w; |
| 55 | - ioctl(0, TIOCGWINSZ, &w); | |
| 56 | - tlen = w.ws_col - indent; | |
| 57 | + memset(&w, 0, sizeof(struct winsize)); | |
| 58 | + if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ | |
| 59 | + tlen = w.ws_col - indent; | |
| 60 | + } | |
| 57 | 61 | } |
| 58 | 62 | #endif |
| 59 | 63 | if( zText==0 ) zText = "(NULL)"; |
| 60 | 64 | if( tlen<=0 ){ |
| 61 | 65 | tlen = strlen(zText); |
| 62 | 66 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -42,20 +42,24 @@ | |
| 42 | int doIndent = 0; |
| 43 | char *zBuf; |
| 44 | char zBuffer[400]; |
| 45 | int lineCnt = 0; |
| 46 | #if defined(_WIN32) |
| 47 | if ( lineLength<0 ){ |
| 48 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 49 | GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); |
| 50 | tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent + 1; |
| 51 | } |
| 52 | #elif defined(TIOCGWINSZ) |
| 53 | if ( lineLength<0 ){ |
| 54 | struct winsize w; |
| 55 | ioctl(0, TIOCGWINSZ, &w); |
| 56 | tlen = w.ws_col - indent; |
| 57 | } |
| 58 | #endif |
| 59 | if( zText==0 ) zText = "(NULL)"; |
| 60 | if( tlen<=0 ){ |
| 61 | tlen = strlen(zText); |
| 62 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -42,20 +42,24 @@ | |
| 42 | int doIndent = 0; |
| 43 | char *zBuf; |
| 44 | char zBuffer[400]; |
| 45 | int lineCnt = 0; |
| 46 | #if defined(_WIN32) |
| 47 | if( lineLength<0 ){ |
| 48 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 49 | memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO)); |
| 50 | if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){ |
| 51 | tlen = csbi.srWindow.Right - csbi.srWindow.Left - indent + 1; |
| 52 | } |
| 53 | } |
| 54 | #elif defined(TIOCGWINSZ) |
| 55 | if( lineLength<0 ){ |
| 56 | struct winsize w; |
| 57 | memset(&w, 0, sizeof(struct winsize)); |
| 58 | if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ |
| 59 | tlen = w.ws_col - indent; |
| 60 | } |
| 61 | } |
| 62 | #endif |
| 63 | if( zText==0 ) zText = "(NULL)"; |
| 64 | if( tlen<=0 ){ |
| 65 | tlen = strlen(zText); |
| 66 |
+1
-1
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -525,11 +525,11 @@ | ||
| 525 | 525 | width = atoi(zWidth); |
| 526 | 526 | if( (width!=0) && (width<=46) ){ |
| 527 | 527 | fossil_fatal("-W|--width value must be >46 or 0"); |
| 528 | 528 | } |
| 529 | 529 | }else{ |
| 530 | - width = -1; | |
| 530 | + width = -1; | |
| 531 | 531 | } |
| 532 | 532 | if( !verboseFlag ){ |
| 533 | 533 | verboseFlag = find_option("detail","l",0)!=0; /* deprecated */ |
| 534 | 534 | } |
| 535 | 535 | verify_all_options(); |
| 536 | 536 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -525,11 +525,11 @@ | |
| 525 | width = atoi(zWidth); |
| 526 | if( (width!=0) && (width<=46) ){ |
| 527 | fossil_fatal("-W|--width value must be >46 or 0"); |
| 528 | } |
| 529 | }else{ |
| 530 | width = -1; |
| 531 | } |
| 532 | if( !verboseFlag ){ |
| 533 | verboseFlag = find_option("detail","l",0)!=0; /* deprecated */ |
| 534 | } |
| 535 | verify_all_options(); |
| 536 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -525,11 +525,11 @@ | |
| 525 | width = atoi(zWidth); |
| 526 | if( (width!=0) && (width<=46) ){ |
| 527 | fossil_fatal("-W|--width value must be >46 or 0"); |
| 528 | } |
| 529 | }else{ |
| 530 | width = -1; |
| 531 | } |
| 532 | if( !verboseFlag ){ |
| 533 | verboseFlag = find_option("detail","l",0)!=0; /* deprecated */ |
| 534 | } |
| 535 | verify_all_options(); |
| 536 |