hotspot/src/share/vm/utilities/xmlstream.cpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1 489c9b5090e2
child 768 d0bebc7eefc2
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_xmlstream.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
void xmlStream::initialize(outputStream* out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  _out = out;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  _last_flush = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  _markup_state = BODY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  _text_init._outer_xmlStream = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  _text = &_text_init;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  _element_depth = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  int   init_len = 100;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  char* init_buf = NEW_C_HEAP_ARRAY(char, init_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  _element_close_stack_low  = init_buf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  _element_close_stack_high = init_buf + init_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  _element_close_stack_ptr  = init_buf + init_len - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  _element_close_stack_ptr[0] = '\0';
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Make sure each log uses the same base for time stamps.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  if (is_open()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    _out->time_stamp().update_to(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
xmlStream::~xmlStream() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  FREE_C_HEAP_ARRAY(char, _element_close_stack_low);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// Pass the given chars directly to _out.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
void xmlStream::write(const char* s, size_t len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  if (!is_open())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  out()->write(s, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// Pass the given chars directly to _out, except that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// we watch for special "<&>" chars.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// This is suitable for either attribute text or for body text.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// We don't fool with "<![CDATA[" quotes, just single-character entities.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// This makes it easier for dumb tools to parse the output.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
void xmlStream::write_text(const char* s, size_t len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  if (!is_open())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  size_t written = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // All normally printed material goes inside XML quotes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // This leaves the output free to include markup also.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // Scan the string looking for inadvertant "<&>" chars
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  for (size_t i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    char ch = s[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    // Escape special chars.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    const char* esc = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    switch (ch) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
      // These are important only in attrs, but we do them always:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    case '\'': esc = "&apos;"; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    case '"':  esc = "&quot;"; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    case '<':  esc = "&lt;";   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    case '&':  esc = "&amp;";  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      // This is a freebie.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    case '>':  esc = "&gt;";   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    if (esc != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      if (written < i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
        out()->write(&s[written], i - written);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
        written = i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
      out()->print_raw(esc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      written++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // Print the clean remainder.  Usually, it is all of s.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  if (written < len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    out()->write(&s[written], len - written);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
// Outputs XML text, with special characters quoted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
void xmlStream::text(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  va_text(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
#define BUFLEN 2*K   /* max size of output of individual print methods */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
void xmlStream::va_tag(bool push, const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  assert_if_no_error(!inside_attrs(), "cannot print tag inside attrs");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  char buffer[BUFLEN];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  size_t len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  const char* kind = do_vsnprintf(buffer, BUFLEN, format, ap, false, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  see_tag(kind, push);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  print_raw("<");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  write(kind, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  _markup_state = (push ? HEAD : ELEM);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
/// Debugging goo to make sure element tags nest properly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
void xmlStream::see_tag(const char* tag, bool push) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  assert_if_no_error(!inside_attrs(), "cannot start new element inside attrs");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  if (!push)  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // tag goes up until either null or space:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  const char* tag_end = strchr(tag, ' ');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  size_t tag_len = (tag_end == NULL) ? strlen(tag) : tag_end - tag;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  assert(tag_len > 0, "tag must not be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // push the tag onto the stack, pulling down the pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  char* old_ptr  = _element_close_stack_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  char* old_low  = _element_close_stack_low;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  char* push_ptr = old_ptr - (tag_len+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  if (push_ptr < old_low) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    int old_len = _element_close_stack_high - old_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    int new_len = old_len * 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    if (new_len < 100)  new_len = 100;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    char* new_low  = NEW_C_HEAP_ARRAY(char, new_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    char* new_high = new_low + new_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    char* new_ptr  = new_high - old_len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    memcpy(new_ptr, old_ptr, old_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    _element_close_stack_high = new_high;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    _element_close_stack_low  = new_low;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    _element_close_stack_ptr  = new_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    FREE_C_HEAP_ARRAY(char, old_low);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    push_ptr = new_ptr - (tag_len+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  assert(push_ptr >= _element_close_stack_low, "in range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  memcpy(push_ptr, tag, tag_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  push_ptr[tag_len] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  _element_close_stack_ptr = push_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  _element_depth += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
void xmlStream::pop_tag(const char* tag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  assert_if_no_error(!inside_attrs(), "cannot close element inside attrs");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  assert(_element_depth > 0, "must be in an element to close");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  assert(*tag != 0, "tag must not be empty");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  char* cur_tag = _element_close_stack_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  bool  bad_tag = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  while (*cur_tag != 0 && strcmp(cur_tag, tag) != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    this->print_cr("</%s> <!-- missing closing tag -->", cur_tag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    _element_close_stack_ptr = (cur_tag += strlen(cur_tag) + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    _element_depth -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    bad_tag = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  if (*cur_tag == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    bad_tag = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    // Pop the stack, by skipping over the tag and its null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    _element_close_stack_ptr = cur_tag + strlen(cur_tag) + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    _element_depth -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  if (bad_tag && !VMThread::should_terminate() && !is_error_reported())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    assert(false, "bad tag in log");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
// First word in formatted string is element kind, and any subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
// words must be XML attributes.  Outputs "<kind .../>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
void xmlStream::elem(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  va_elem(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
void xmlStream::va_elem(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  va_begin_elem(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  end_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
// First word in formatted string is element kind, and any subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
// words must be XML attributes.  Outputs "<kind ...", not including "/>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
void xmlStream::begin_elem(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  va_tag(false, format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
void xmlStream::va_begin_elem(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  va_tag(false, format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
// Outputs "/>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
void xmlStream::end_elem() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  assert(_markup_state == ELEM, "misplaced end_elem");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  print_raw("/>\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  _markup_state = BODY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
// Outputs formatted text, followed by "/>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
void xmlStream::end_elem(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  out()->vprint(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  end_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
// First word in formatted string is element kind, and any subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
// words must be XML attributes.  Outputs "<kind ...>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
void xmlStream::head(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  va_head(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
void xmlStream::va_head(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  va_begin_head(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  end_head();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
// First word in formatted string is element kind, and any subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
// words must be XML attributes.  Outputs "<kind ...", not including ">".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
void xmlStream::begin_head(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  va_tag(true, format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
void xmlStream::va_begin_head(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  va_tag(true, format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
// Outputs ">".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
void xmlStream::end_head() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  assert(_markup_state == HEAD, "misplaced end_head");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  print_raw(">\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  _markup_state = BODY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
// Outputs formatted text, followed by ">".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
void xmlStream::end_head(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  out()->vprint(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  end_head();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
// Outputs "</kind>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
void xmlStream::tail(const char* kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  pop_tag(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  print_raw("</");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  print_raw(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  print_raw(">\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
// Outputs "<kind_done ... stamp='D.DD'/> </kind>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
void xmlStream::done(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  va_done(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
// Outputs "<kind_done stamp='D.DD'/> </kind>".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
// Because done_raw() doesn't need to format strings, it's simpler than
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
// done(), and can be called safely by fatal error handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
void xmlStream::done_raw(const char* kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  print_raw("<");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  print_raw(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  print_raw("_done stamp='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  out()->stamp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  print_raw_cr("'/>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  print_raw("</");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  print_raw(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  print_raw_cr(">");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
void xmlStream::va_done(const char* format, va_list ap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  char buffer[200];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  guarantee(strlen(format) + 10 < sizeof(buffer), "bigger format buffer")
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  const char* kind = format;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  const char* kind_end = strchr(kind, ' ');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  size_t kind_len = (kind_end != NULL) ? (kind_end - kind) : strlen(kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  strncpy(buffer, kind, kind_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  strcpy(buffer + kind_len, "_done");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  strcat(buffer, format + kind_len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  // Output the trailing event with the timestamp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  va_begin_elem(buffer, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  stamp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  end_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  // Output the tail-tag of the enclosing element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  buffer[kind_len] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  tail(buffer);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
// Output a timestamp attribute.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
void xmlStream::stamp() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  assert_if_no_error(inside_attrs(), "stamp must be an attribute");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  print_raw(" stamp='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  out()->stamp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  print_raw("'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
// Output a method attribute, in the form " method='pkg/cls name sig'".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
// This is used only when there is no ciMethod available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
void xmlStream::method(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  assert_if_no_error(inside_attrs(), "printing attributes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  if (method.is_null())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  print_raw(" method='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  method_text(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  print("' bytes='%d'", method->code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  print(" count='%d'", method->invocation_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  int bec = method->backedge_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  if (bec != 0)  print(" backedge_count='%d'", bec);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  print(" iicount='%d'", method->interpreter_invocation_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  int throwouts = method->interpreter_throwout_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  if (throwouts != 0)  print(" throwouts='%d'", throwouts);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  methodDataOop mdo = method->method_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  if (mdo != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    uint cnt;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    cnt = mdo->decompile_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    if (cnt != 0)  print(" decompiles='%d'", cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    for (uint reason = 0; reason < mdo->trap_reason_limit(); reason++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      cnt = mdo->trap_count(reason);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      if (cnt != 0)  print(" %s_traps='%d'", Deoptimization::trap_reason_name(reason), cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    cnt = mdo->overflow_trap_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    if (cnt != 0)  print(" overflow_traps='%d'", cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    cnt = mdo->overflow_recompile_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    if (cnt != 0)  print(" overflow_recompiles='%d'", cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
void xmlStream::method_text(methodHandle method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  assert_if_no_error(inside_attrs(), "printing attributes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  if (method.is_null())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  //method->print_short_name(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  method->method_holder()->klass_part()->name()->print_symbol_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  print_raw(" ");  // " " is easier for tools to parse than "::"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  method->name()->print_symbol_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  print_raw(" ");  // separator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  method->signature()->print_symbol_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
// Output a klass attribute, in the form " klass='pkg/cls'".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
// This is used only when there is no ciKlass available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
void xmlStream::klass(KlassHandle klass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  assert_if_no_error(inside_attrs(), "printing attributes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  if (klass.is_null())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  print_raw(" klass='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  klass_text(klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  print_raw("'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
void xmlStream::klass_text(KlassHandle klass) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  assert_if_no_error(inside_attrs(), "printing attributes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  if (klass.is_null())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  //klass->print_short_name(log->out());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  klass->name()->print_symbol_on(out());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
void xmlStream::name(symbolHandle name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  assert_if_no_error(inside_attrs(), "printing attributes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  if (name.is_null())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  print_raw(" name='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  name_text(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  print_raw("'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
void xmlStream::name_text(symbolHandle name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  assert_if_no_error(inside_attrs(), "printing attributes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  if (name.is_null())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  //name->print_short_name(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  name->print_symbol_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
void xmlStream::object(const char* attr, Handle x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  assert_if_no_error(inside_attrs(), "printing attributes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  if (x.is_null())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  print_raw(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  print_raw(attr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  print_raw("='");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  object_text(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  print_raw("'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
void xmlStream::object_text(Handle x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  assert_if_no_error(inside_attrs(), "printing attributes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  if (x.is_null())  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  //x->print_value_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  if (x->is_method())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    method_text(methodOop(x()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  else if (x->is_klass())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    klass_text(klassOop(x()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  else if (x->is_symbol())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    name_text(symbolOop(x()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    x->print_value_on(text());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
void xmlStream::flush() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  out()->flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  _last_flush = count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
void xmlTextStream::flush() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  if (_outer_xmlStream == NULL)  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  _outer_xmlStream->flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
void xmlTextStream::write(const char* str, size_t len) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  if (_outer_xmlStream == NULL)  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  _outer_xmlStream->write_text(str, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  update_position(str, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
}