956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
|
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
|
-
+
-
|
** On windows, transform the output into the current terminal encoding
** if the output is going to the screen. If output is redirected into
** a file, no translation occurs. Switch output mode to binary to
** properly process line-endings, make sure to switch the mode back to
** text when done.
** No translation ever occurs on unix.
*/
void fossil_puts(const char *z, int toStdErr){
void fossil_puts(const char *z, int toStdErr, int n){
FILE* out = (toStdErr ? stderr : stdout);
int n = (int)strlen(z);
if( n==0 ) return;
assert( toStdErr==0 || toStdErr==1 );
if( toStdErr==0 ) stdoutAtBOL = (z[n-1]=='\n');
#if defined(_WIN32)
if( fossil_utf8_to_console(z, n, toStdErr) >= 0 ){
return;
}
|
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
|
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
|
-
+
|
/*
** Force the standard output cursor to move to the beginning
** of a line, if it is not there already.
*/
int fossil_force_newline(void){
if( g.cgiOutput==0 && stdoutAtBOL==0 ){
fossil_puts("\n", 0);
fossil_puts("\n", 0, 1);
return 1;
}
return 0;
}
/*
** Indicate that the cursor has moved to the start of a line by means
|
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
|
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
|
-
-
+
-
-
-
-
+
-
-
-
+
|
*/
void fossil_print(const char *zFormat, ...){
va_list ap;
va_start(ap, zFormat);
if( g.cgiOutput ){
cgi_vprintf(zFormat, ap);
}else{
Blob b = empty_blob;
vxprintf(&b, zFormat, ap);
vxprintf(0, zFormat, ap);
fossil_puts(blob_str(&b), 0);
blob_reset(&b);
}
va_end(ap);
}
void fossil_vprint(const char *zFormat, va_list ap){
if( g.cgiOutput ){
cgi_vprintf(zFormat, ap);
}else{
Blob b = empty_blob;
vxprintf(&b, zFormat, ap);
vxprintf(0, zFormat, ap);
fossil_puts(blob_str(&b), 0);
blob_reset(&b);
}
}
/*
** Print a trace message on standard error.
*/
void fossil_trace(const char *zFormat, ...){
va_list ap;
Blob b;
va_start(ap, zFormat);
b = empty_blob;
vxprintf(&b, zFormat, ap);
fossil_puts(blob_str(&b), 1);
fossil_puts(blob_buffer(&b), 1, blob_size(&b));
blob_reset(&b);
va_end(ap);
}
/*
** Write a message to the error log, if the error log filename is
** defined.
|