Ejemplo n.º 1
0
bool xml_istream::collapse_whitespace(const string& s, string& ts)
{
    ts.clear();

    const size_t k = s.length();
    size_t i = 0;

    parse_ws(s, i); /* Ignore leading whitespace. */

    for (; i < k; ++i)
    {
        if (is_ws_char(s[i]) != false)
        {
            ts += ' ';
            ++i;
            for (; i < k && is_ws_char(s[i]) != false; ++i);
            --i;
        }
        else
        {
            ts += s[i];
        }
    }

    size_t last = ts.length() - 1;
    if (is_ws_char(ts[last]) != false) /* Remove tailing whitespace. */
    {
        ts.resize(last);
    }

    return ts.length() < k;
}
Ejemplo n.º 2
0
bool xml_istream::parse_ws(const string& s, size_t& i)
{
    size_t j = i;
    for (; i < s.length() && is_ws_char(s[i]) != false; ++i);

    return i != j;
}
Ejemplo n.º 3
0
static size_t js_skip_ws(jsparser_t *p) {
  size_t start = p->pos;

  while (1) {
    js_ensure_buf(p, 1);
    if (! is_ws_char(js(p)[0])) break;
    p->pos++;
  }

  return p->pos - start;
}
Ejemplo n.º 4
0
char xml_istream::get_next_non_ws()
{
    char ch = get();

    while (good() != false && is_ws_char(ch) != false)
    {
        ch = get();
    }

    return ch;
}