/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
trp->max = 3 * trp->max / 2 + 1;
trp->bp = (Token *) realloc(trp->bp, trp->max * sizeof(Token));
assert(trp->bp); // realloc failure is OOM -> no point to handle
trp->lp = &trp->bp[nlast];
trp->tp = &trp->bp[ncur]; return trp->lp;
}
/* * Compare a row of tokens, ignoring the content of WS; return !=0 if different
*/ int
comparetokens(Tokenrow * tr1, Tokenrow * tr2)
{
Token *tp1, *tp2;
/* * replace ntok tokens starting at dtr->tp with the contents of str. * tp ends up pointing just beyond the replacement. * Canonical whitespace is assured on each side.
*/ void
insertrow(Tokenrow * dtr, int ntok, Tokenrow const * str)
{ int nrtok = (int)rowlen(str);
/* * make sure there is WS before trp->tp, if tokens might merge in the output
*/ void
makespace(Tokenrow * trp, Token const * ntp)
{
uchar *tt;
Token *tp = trp->tp;
/* * Copy an entire tokenrow into another, at tp. * It is assumed that there is enough space. * Not strictly conforming.
*/ void
movetokenrow(Tokenrow * dtr, Tokenrow const * str)
{
size_t nby;
/* * Move the tokens in a row, starting at tr->tp, rightward by nt tokens; * nt may be negative (left move). * The row may need to be grown. * Non-strictly conforming because of the (char *), but easily fixed
*/ void
adjustrow(Tokenrow * trp, int nt)
{
size_t nby, size;
if (nt == 0) return;
size = (trp->lp - trp->bp) + nt; while (size > trp->max)
growtokenrow(trp);
nby = (char *) trp->lp - (char *) trp->tp; if (nby)
memmove(trp->tp + nt, trp->tp, nby);
trp->lp += nt;
}
/* * Copy a row of tokens into the destination holder, allocating * the space for the contents. Return the destination.
*/
Tokenrow *
copytokenrow(Tokenrow * dtr, Tokenrow const * str)
{ int len = (int)rowlen(str);
/* * Produce a copy of a row of tokens. Start at trp->tp. * The value strings are copied as well. The first token * has WS available.
*/
Tokenrow *
normtokenrow(Tokenrow * trp)
{
Token *tp;
Tokenrow *ntrp = new(Tokenrow); int len;
len = (int)(trp->lp - trp->tp); if (len <= 0)
len = 1;
maketokenrow(len, ntrp); for (tp = trp->tp; tp < trp->lp; tp++)
{
*ntrp->lp = *tp; if (tp->len)
{
ntrp->lp->t = newstring(tp->t, tp->len, 1);
*ntrp->lp->t++ = ' '; if (tp->wslen)
ntrp->lp->wslen = 1;
}
ntrp->lp++;
} if (ntrp->lp > ntrp->bp)
ntrp->bp->wslen = 0; return ntrp;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.