43
43
extern " C" void jio_print (const char * s, size_t len);
44
44
extern " C" int jio_printf (const char *fmt, ...);
45
45
46
- outputStream::outputStream (int width) {
47
- _width = width;
46
+ outputStream::outputStream () {
48
47
_position = 0 ;
49
- _newlines = 0 ;
50
48
_precount = 0 ;
51
49
_indentation = 0 ;
52
50
_scratch = NULL ;
53
51
_scratch_len = 0 ;
54
52
}
55
53
56
- outputStream::outputStream (int width, bool has_time_stamps) {
57
- _width = width;
54
+ outputStream::outputStream (bool has_time_stamps) {
58
55
_position = 0 ;
59
- _newlines = 0 ;
60
56
_precount = 0 ;
61
57
_indentation = 0 ;
62
58
_scratch = NULL ;
63
59
_scratch_len = 0 ;
64
60
if (has_time_stamps) _stamp.update ();
65
61
}
66
62
67
- void outputStream::update_position (const char * s, size_t len) {
63
+ bool outputStream::update_position (const char * s, size_t len) {
64
+ bool saw_newline = false ;
68
65
for (size_t i = 0 ; i < len; i++) {
69
66
char ch = s[i];
70
67
if (ch == ' \n ' ) {
71
- _newlines += 1 ;
68
+ saw_newline = true ;
72
69
_precount += _position + 1 ;
73
70
_position = 0 ;
74
71
} else if (ch == ' \t ' ) {
@@ -79,6 +76,7 @@ void outputStream::update_position(const char* s, size_t len) {
79
76
_position += 1 ;
80
77
}
81
78
}
79
+ return saw_newline;
82
80
}
83
81
84
82
// Execute a vsprintf, using the given buffer if necessary.
@@ -400,7 +398,6 @@ void stringStream::zero_terminate() {
400
398
void stringStream::reset () {
401
399
assert (_is_frozen == false , " Modification forbidden" );
402
400
_written = 0 ; _precount = 0 ; _position = 0 ;
403
- _newlines = 0 ;
404
401
zero_terminate ();
405
402
}
406
403
@@ -893,17 +890,17 @@ void defaultStream::write(const char* s, size_t len) {
893
890
intx holder = hold (thread_id);
894
891
895
892
if (DisplayVMOutput &&
896
- (_outer_xmlStream == NULL || !_outer_xmlStream->inside_attrs ())) {
893
+ (_outer_xmlStream == nullptr || !_outer_xmlStream->inside_attrs ())) {
897
894
// print to output stream. It can be redirected by a vfprintf hook
898
895
jio_print (s, len);
899
896
}
900
897
901
898
// print to log file
902
- if (has_log_file ()) {
903
- int nl0 = _newlines ;
904
- xmlTextStream::write (s, len);
899
+ if (has_log_file () && _outer_xmlStream != nullptr ) {
900
+ _outer_xmlStream-> write_text (s, len) ;
901
+ bool nl = update_position (s, len);
905
902
// flush the log file too, if there were any newlines
906
- if (nl0 != _newlines) {
903
+ if (nl) {
907
904
flush ();
908
905
}
909
906
} else {
0 commit comments