Fossil SCM
Take care that xfer error messages and user prompts always begin at the start of a new line.
Commit
f1ef22136f6e8427e09e8e09add679fccf1fa319
Parent
b963446708df0d0…
5 files changed
+1
+4
+21
-2
+1
+3
-2
+1
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -193,10 +193,11 @@ | ||
| 193 | 193 | blob_appendf(&zCmd, " -P %d", g.urlPort); |
| 194 | 194 | #else |
| 195 | 195 | blob_appendf(&zCmd, " -p %d", g.urlPort); |
| 196 | 196 | #endif |
| 197 | 197 | } |
| 198 | + fossil_force_newline(); | |
| 198 | 199 | fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */ |
| 199 | 200 | if( g.urlUser && g.urlUser[0] ){ |
| 200 | 201 | zHost = mprintf("%s@%s", g.urlUser, g.urlName); |
| 201 | 202 | #ifdef __MINGW32__ |
| 202 | 203 | /* Only win32 (and specifically PLINK.EXE) support the -pw option */ |
| 203 | 204 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -193,10 +193,11 @@ | |
| 193 | blob_appendf(&zCmd, " -P %d", g.urlPort); |
| 194 | #else |
| 195 | blob_appendf(&zCmd, " -p %d", g.urlPort); |
| 196 | #endif |
| 197 | } |
| 198 | fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */ |
| 199 | if( g.urlUser && g.urlUser[0] ){ |
| 200 | zHost = mprintf("%s@%s", g.urlUser, g.urlName); |
| 201 | #ifdef __MINGW32__ |
| 202 | /* Only win32 (and specifically PLINK.EXE) support the -pw option */ |
| 203 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -193,10 +193,11 @@ | |
| 193 | blob_appendf(&zCmd, " -P %d", g.urlPort); |
| 194 | #else |
| 195 | blob_appendf(&zCmd, " -p %d", g.urlPort); |
| 196 | #endif |
| 197 | } |
| 198 | fossil_force_newline(); |
| 199 | fossil_print("%s", blob_str(&zCmd)); /* Show the base of the SSH command */ |
| 200 | if( g.urlUser && g.urlUser[0] ){ |
| 201 | zHost = mprintf("%s@%s", g.urlUser, g.urlName); |
| 202 | #ifdef __MINGW32__ |
| 203 | /* Only win32 (and specifically PLINK.EXE) support the -pw option */ |
| 204 |
+4
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -712,10 +712,11 @@ | ||
| 712 | 712 | once = 0; |
| 713 | 713 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 714 | 714 | cgi_reply(); |
| 715 | 715 | }else if( !g.fQuiet ){ |
| 716 | 716 | char *zOut = mprintf("%s: %s\n", g.argv[0], z); |
| 717 | + fossil_force_newline(); | |
| 717 | 718 | fossil_puts(zOut, 1); |
| 718 | 719 | fossil_free(zOut); |
| 719 | 720 | } |
| 720 | 721 | } |
| 721 | 722 | free(z); |
| @@ -745,10 +746,11 @@ | ||
| 745 | 746 | g.cgiOutput = 0; |
| 746 | 747 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 747 | 748 | cgi_reply(); |
| 748 | 749 | }else if( !g.fQuiet ){ |
| 749 | 750 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 751 | + fossil_force_newline(); | |
| 750 | 752 | fossil_puts(zOut, 1); |
| 751 | 753 | fossil_free(zOut); |
| 752 | 754 | } |
| 753 | 755 | } |
| 754 | 756 | free(z); |
| @@ -787,10 +789,11 @@ | ||
| 787 | 789 | g.cgiOutput = 0; |
| 788 | 790 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 789 | 791 | cgi_reply(); |
| 790 | 792 | }else{ |
| 791 | 793 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 794 | + fossil_force_newline(); | |
| 792 | 795 | fossil_puts(zOut, 1); |
| 793 | 796 | fossil_free(zOut); |
| 794 | 797 | } |
| 795 | 798 | } |
| 796 | 799 | db_force_rollback(); |
| @@ -813,10 +816,11 @@ | ||
| 813 | 816 | { |
| 814 | 817 | if( g.cgiOutput ){ |
| 815 | 818 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 816 | 819 | }else{ |
| 817 | 820 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 821 | + fossil_force_newline(); | |
| 818 | 822 | fossil_puts(zOut, 1); |
| 819 | 823 | fossil_free(zOut); |
| 820 | 824 | } |
| 821 | 825 | } |
| 822 | 826 | free(z); |
| 823 | 827 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -712,10 +712,11 @@ | |
| 712 | once = 0; |
| 713 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 714 | cgi_reply(); |
| 715 | }else if( !g.fQuiet ){ |
| 716 | char *zOut = mprintf("%s: %s\n", g.argv[0], z); |
| 717 | fossil_puts(zOut, 1); |
| 718 | fossil_free(zOut); |
| 719 | } |
| 720 | } |
| 721 | free(z); |
| @@ -745,10 +746,11 @@ | |
| 745 | g.cgiOutput = 0; |
| 746 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 747 | cgi_reply(); |
| 748 | }else if( !g.fQuiet ){ |
| 749 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 750 | fossil_puts(zOut, 1); |
| 751 | fossil_free(zOut); |
| 752 | } |
| 753 | } |
| 754 | free(z); |
| @@ -787,10 +789,11 @@ | |
| 787 | g.cgiOutput = 0; |
| 788 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 789 | cgi_reply(); |
| 790 | }else{ |
| 791 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 792 | fossil_puts(zOut, 1); |
| 793 | fossil_free(zOut); |
| 794 | } |
| 795 | } |
| 796 | db_force_rollback(); |
| @@ -813,10 +816,11 @@ | |
| 813 | { |
| 814 | if( g.cgiOutput ){ |
| 815 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 816 | }else{ |
| 817 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 818 | fossil_puts(zOut, 1); |
| 819 | fossil_free(zOut); |
| 820 | } |
| 821 | } |
| 822 | free(z); |
| 823 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -712,10 +712,11 @@ | |
| 712 | once = 0; |
| 713 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 714 | cgi_reply(); |
| 715 | }else if( !g.fQuiet ){ |
| 716 | char *zOut = mprintf("%s: %s\n", g.argv[0], z); |
| 717 | fossil_force_newline(); |
| 718 | fossil_puts(zOut, 1); |
| 719 | fossil_free(zOut); |
| 720 | } |
| 721 | } |
| 722 | free(z); |
| @@ -745,10 +746,11 @@ | |
| 746 | g.cgiOutput = 0; |
| 747 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 748 | cgi_reply(); |
| 749 | }else if( !g.fQuiet ){ |
| 750 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 751 | fossil_force_newline(); |
| 752 | fossil_puts(zOut, 1); |
| 753 | fossil_free(zOut); |
| 754 | } |
| 755 | } |
| 756 | free(z); |
| @@ -787,10 +789,11 @@ | |
| 789 | g.cgiOutput = 0; |
| 790 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 791 | cgi_reply(); |
| 792 | }else{ |
| 793 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 794 | fossil_force_newline(); |
| 795 | fossil_puts(zOut, 1); |
| 796 | fossil_free(zOut); |
| 797 | } |
| 798 | } |
| 799 | db_force_rollback(); |
| @@ -813,10 +816,11 @@ | |
| 816 | { |
| 817 | if( g.cgiOutput ){ |
| 818 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 819 | }else{ |
| 820 | char *zOut = mprintf("\r%s: %s\n", g.argv[0], z); |
| 821 | fossil_force_newline(); |
| 822 | fossil_puts(zOut, 1); |
| 823 | fossil_free(zOut); |
| 824 | } |
| 825 | } |
| 826 | free(z); |
| 827 |
+21
-2
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -818,27 +818,46 @@ | ||
| 818 | 818 | free(g.zErrMsg); |
| 819 | 819 | g.zErrMsg = 0; |
| 820 | 820 | g.iErrPriority = 0; |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | +/* True if the last character standard output cursor is setting at | |
| 824 | +** the beginning of a blank link. False if a \r has been to move the | |
| 825 | +** cursor to the beginning of the line or if not at the beginning of | |
| 826 | +** a line. | |
| 827 | +** was a \n | |
| 828 | +*/ | |
| 829 | +static int stdoutAtBOL = 1; | |
| 830 | + | |
| 823 | 831 | /* |
| 824 | 832 | ** Write to standard output or standard error. |
| 825 | 833 | ** |
| 826 | 834 | ** On windows, transform the output into the current terminal encoding |
| 827 | 835 | ** if the output is going to the screen. If output is redirected into |
| 828 | 836 | ** a file, no translation occurs. No translation ever occurs on unix. |
| 829 | 837 | */ |
| 830 | 838 | void fossil_puts(const char *z, int toStdErr){ |
| 839 | + int n = (int)strlen(z); | |
| 840 | + if( n==0 ) return; | |
| 841 | + if( toStdErr==0 ) stdoutAtBOL = (z[n-1]=='\n'); | |
| 831 | 842 | #if defined(_WIN32) |
| 832 | - if( fossil_utf8_to_console(z, strlen(z), toStdErr) >= 0 ){ | |
| 843 | + if( fossil_utf8_to_console(z, n, toStdErr) >= 0 ){ | |
| 833 | 844 | return; |
| 834 | 845 | } |
| 835 | 846 | #endif |
| 836 | 847 | assert( toStdErr==0 || toStdErr==1 ); |
| 837 | - fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); | |
| 848 | + fwrite(z, 1, n, toStdErr ? stderr : stdout); | |
| 838 | 849 | fflush(toStdErr ? stderr : stdout); |
| 839 | 850 | } |
| 851 | + | |
| 852 | +/* | |
| 853 | +** Force the the standard output cursor to move to the beginning | |
| 854 | +** of a line, if it is not there already. | |
| 855 | +*/ | |
| 856 | +void fossil_force_newline(void){ | |
| 857 | + if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); | |
| 858 | +} | |
| 840 | 859 | |
| 841 | 860 | /* |
| 842 | 861 | ** Write output for user consumption. If g.cgiOutput is enabled, then |
| 843 | 862 | ** send the output as part of the CGI reply. If g.cgiOutput is false, |
| 844 | 863 | ** then write on standard output. |
| 845 | 864 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -818,27 +818,46 @@ | |
| 818 | free(g.zErrMsg); |
| 819 | g.zErrMsg = 0; |
| 820 | g.iErrPriority = 0; |
| 821 | } |
| 822 | |
| 823 | /* |
| 824 | ** Write to standard output or standard error. |
| 825 | ** |
| 826 | ** On windows, transform the output into the current terminal encoding |
| 827 | ** if the output is going to the screen. If output is redirected into |
| 828 | ** a file, no translation occurs. No translation ever occurs on unix. |
| 829 | */ |
| 830 | void fossil_puts(const char *z, int toStdErr){ |
| 831 | #if defined(_WIN32) |
| 832 | if( fossil_utf8_to_console(z, strlen(z), toStdErr) >= 0 ){ |
| 833 | return; |
| 834 | } |
| 835 | #endif |
| 836 | assert( toStdErr==0 || toStdErr==1 ); |
| 837 | fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout); |
| 838 | fflush(toStdErr ? stderr : stdout); |
| 839 | } |
| 840 | |
| 841 | /* |
| 842 | ** Write output for user consumption. If g.cgiOutput is enabled, then |
| 843 | ** send the output as part of the CGI reply. If g.cgiOutput is false, |
| 844 | ** then write on standard output. |
| 845 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -818,27 +818,46 @@ | |
| 818 | free(g.zErrMsg); |
| 819 | g.zErrMsg = 0; |
| 820 | g.iErrPriority = 0; |
| 821 | } |
| 822 | |
| 823 | /* True if the last character standard output cursor is setting at |
| 824 | ** the beginning of a blank link. False if a \r has been to move the |
| 825 | ** cursor to the beginning of the line or if not at the beginning of |
| 826 | ** a line. |
| 827 | ** was a \n |
| 828 | */ |
| 829 | static int stdoutAtBOL = 1; |
| 830 | |
| 831 | /* |
| 832 | ** Write to standard output or standard error. |
| 833 | ** |
| 834 | ** On windows, transform the output into the current terminal encoding |
| 835 | ** if the output is going to the screen. If output is redirected into |
| 836 | ** a file, no translation occurs. No translation ever occurs on unix. |
| 837 | */ |
| 838 | void fossil_puts(const char *z, int toStdErr){ |
| 839 | int n = (int)strlen(z); |
| 840 | if( n==0 ) return; |
| 841 | if( toStdErr==0 ) stdoutAtBOL = (z[n-1]=='\n'); |
| 842 | #if defined(_WIN32) |
| 843 | if( fossil_utf8_to_console(z, n, toStdErr) >= 0 ){ |
| 844 | return; |
| 845 | } |
| 846 | #endif |
| 847 | assert( toStdErr==0 || toStdErr==1 ); |
| 848 | fwrite(z, 1, n, toStdErr ? stderr : stdout); |
| 849 | fflush(toStdErr ? stderr : stdout); |
| 850 | } |
| 851 | |
| 852 | /* |
| 853 | ** Force the the standard output cursor to move to the beginning |
| 854 | ** of a line, if it is not there already. |
| 855 | */ |
| 856 | void fossil_force_newline(void){ |
| 857 | if( g.cgiOutput==0 && stdoutAtBOL==0 ) fossil_puts("\n", 0); |
| 858 | } |
| 859 | |
| 860 | /* |
| 861 | ** Write output for user consumption. If g.cgiOutput is enabled, then |
| 862 | ** send the output as part of the CGI reply. If g.cgiOutput is false, |
| 863 | ** then write on standard output. |
| 864 |
+1
| --- src/user.c | ||
| +++ src/user.c | ||
| @@ -132,10 +132,11 @@ | ||
| 132 | 132 | */ |
| 133 | 133 | void prompt_user(const char *zPrompt, Blob *pIn){ |
| 134 | 134 | char *z; |
| 135 | 135 | char zLine[1000]; |
| 136 | 136 | blob_zero(pIn); |
| 137 | + fossil_force_newline(); | |
| 137 | 138 | fossil_print("%s", zPrompt); |
| 138 | 139 | fflush(stdout); |
| 139 | 140 | z = fgets(zLine, sizeof(zLine), stdin); |
| 140 | 141 | if( z ){ |
| 141 | 142 | strip_string(pIn, z); |
| 142 | 143 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -132,10 +132,11 @@ | |
| 132 | */ |
| 133 | void prompt_user(const char *zPrompt, Blob *pIn){ |
| 134 | char *z; |
| 135 | char zLine[1000]; |
| 136 | blob_zero(pIn); |
| 137 | fossil_print("%s", zPrompt); |
| 138 | fflush(stdout); |
| 139 | z = fgets(zLine, sizeof(zLine), stdin); |
| 140 | if( z ){ |
| 141 | strip_string(pIn, z); |
| 142 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -132,10 +132,11 @@ | |
| 132 | */ |
| 133 | void prompt_user(const char *zPrompt, Blob *pIn){ |
| 134 | char *z; |
| 135 | char zLine[1000]; |
| 136 | blob_zero(pIn); |
| 137 | fossil_force_newline(); |
| 138 | fossil_print("%s", zPrompt); |
| 139 | fflush(stdout); |
| 140 | z = fgets(zLine, sizeof(zLine), stdin); |
| 141 | if( z ){ |
| 142 | strip_string(pIn, z); |
| 143 |
+3
-2
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1692,11 +1692,12 @@ | ||
| 1692 | 1692 | defossilize(zMsg); |
| 1693 | 1693 | if( (syncFlags & SYNC_PUSH) && zMsg && strglob("pull only *", zMsg) ){ |
| 1694 | 1694 | syncFlags &= ~SYNC_PUSH; |
| 1695 | 1695 | zMsg = 0; |
| 1696 | 1696 | } |
| 1697 | - fossil_print("\rServer says: %s\n", zMsg); | |
| 1697 | + fossil_force_newline(); | |
| 1698 | + fossil_print("Server says: %s\n", zMsg); | |
| 1698 | 1699 | }else |
| 1699 | 1700 | |
| 1700 | 1701 | /* pragma NAME VALUE... |
| 1701 | 1702 | ** |
| 1702 | 1703 | ** The server can send pragmas to try to convey meta-information to |
| @@ -1804,11 +1805,11 @@ | ||
| 1804 | 1805 | ** information which is only sent on the second round. |
| 1805 | 1806 | */ |
| 1806 | 1807 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 1807 | 1808 | }; |
| 1808 | 1809 | transport_stats(&nSent, &nRcvd, 1); |
| 1809 | - if( (syncFlags & SYNC_VERBOSE)==0 ) fossil_print("\n"); | |
| 1810 | + fossil_force_newline(); | |
| 1810 | 1811 | fossil_print( |
| 1811 | 1812 | "%s finished with %lld bytes sent, %lld bytes received\n", |
| 1812 | 1813 | zOpType, nSent, nRcvd); |
| 1813 | 1814 | transport_close(); |
| 1814 | 1815 | transport_global_shutdown(); |
| 1815 | 1816 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1692,11 +1692,12 @@ | |
| 1692 | defossilize(zMsg); |
| 1693 | if( (syncFlags & SYNC_PUSH) && zMsg && strglob("pull only *", zMsg) ){ |
| 1694 | syncFlags &= ~SYNC_PUSH; |
| 1695 | zMsg = 0; |
| 1696 | } |
| 1697 | fossil_print("\rServer says: %s\n", zMsg); |
| 1698 | }else |
| 1699 | |
| 1700 | /* pragma NAME VALUE... |
| 1701 | ** |
| 1702 | ** The server can send pragmas to try to convey meta-information to |
| @@ -1804,11 +1805,11 @@ | |
| 1804 | ** information which is only sent on the second round. |
| 1805 | */ |
| 1806 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 1807 | }; |
| 1808 | transport_stats(&nSent, &nRcvd, 1); |
| 1809 | if( (syncFlags & SYNC_VERBOSE)==0 ) fossil_print("\n"); |
| 1810 | fossil_print( |
| 1811 | "%s finished with %lld bytes sent, %lld bytes received\n", |
| 1812 | zOpType, nSent, nRcvd); |
| 1813 | transport_close(); |
| 1814 | transport_global_shutdown(); |
| 1815 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1692,11 +1692,12 @@ | |
| 1692 | defossilize(zMsg); |
| 1693 | if( (syncFlags & SYNC_PUSH) && zMsg && strglob("pull only *", zMsg) ){ |
| 1694 | syncFlags &= ~SYNC_PUSH; |
| 1695 | zMsg = 0; |
| 1696 | } |
| 1697 | fossil_force_newline(); |
| 1698 | fossil_print("Server says: %s\n", zMsg); |
| 1699 | }else |
| 1700 | |
| 1701 | /* pragma NAME VALUE... |
| 1702 | ** |
| 1703 | ** The server can send pragmas to try to convey meta-information to |
| @@ -1804,11 +1805,11 @@ | |
| 1805 | ** information which is only sent on the second round. |
| 1806 | */ |
| 1807 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 1808 | }; |
| 1809 | transport_stats(&nSent, &nRcvd, 1); |
| 1810 | fossil_force_newline(); |
| 1811 | fossil_print( |
| 1812 | "%s finished with %lld bytes sent, %lld bytes received\n", |
| 1813 | zOpType, nSent, nRcvd); |
| 1814 | transport_close(); |
| 1815 | transport_global_shutdown(); |
| 1816 |