Copyright 2010, SIL International All rights reserved.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should also have received a copy of the GNU Lesser General Public License along with this library in the file named "LICENSE". If not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA or visit their web page on the internet at http://www.fsf.org/licenses/lgpl.html.
Alternatively, the contents of this file may be used under the terms of the Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public License, as published by the Free Software Foundation, either version 2 of the License or (at your option) any later version.
*/ #include <cstdlib> #include"graphite2/Segment.h" #include"inc/debug.h" #include"inc/Endian.h" #include"inc/Silf.h" #include"inc/Segment.h" #include"inc/Rule.h" #include"inc/Error.h"
// Check that numLinear < numClass, // that there is at least enough data for numClasses offsets. if (e.test(m_nLinear > m_nClass, E_TOOMANYLINEAR)
|| e.test((m_nClass + 1) * (version >= 0x00040000 ? sizeof(uint32) : sizeof(uint16)) > (data_len - 4), E_CLASSESTOOBIG)) return ERROROFFSET;
// Check the linear offsets are sane, these must be monotonically increasing.
assert(m_nClass >= m_nLinear); for (const uint32 *o = m_classOffsets, * const o_end = o + m_nLinear; o != o_end; ++o) if (e.test(o[0] > o[1], E_BADCLASSOFFSET)) return ERROROFFSET;
// Fortunately the class data is all uint16s so we can decode these now
m_classData = gralloc<uint16>(max_off); if (e.test(!m_classData, E_OUTOFMEM)) return ERROROFFSET; for (uint16 *d = m_classData, * const d_end = d + max_off; d != d_end; ++d)
*d = be::read<uint16>(p);
// Check the lookup class invariants for each non-linear class for (const uint32 *o = m_classOffsets + m_nLinear, * const o_end = m_classOffsets + m_nClass; o != o_end; ++o)
{ const uint16 * lookup = m_classData + *o; if (e.test(*o + 4 > max_off, E_HIGHCLASSOFFSET) // LookupClass doesn't stretch over max_off
|| e.test(lookup[0] == 0 // A LookupClass with no looks is a suspicious thing ...
|| lookup[0] * 2 + *o + 4 > max_off // numIDs lookup pairs fits within (start of LookupClass' lookups array, max_off]
|| lookup[3] + lookup[1] != lookup[0], E_BADCLASSLOOKUPINFO) // rangeShift: numIDs - searchRange
|| e.test(((o[1] - *o) & 1) != 0, ERROROFFSET)) // glyphs are in pairs so difference must be even. return ERROROFFSET;
}
return max_off;
}
uint16 Silf::findPseudo(uint32 uid) const
{ for (int i = 0; i < m_numPseudo; i++) if (m_pseudos[i].uid == uid) return m_pseudos[i].gid; return 0;
}
uint32 loc = m_classOffsets[cid]; if (cid < m_nLinear)
{ if (index < m_classOffsets[cid + 1] - loc) return m_classData[index + loc];
} else// input class being used for output. Shouldn't happen
{ for (unsignedint i = loc + 4; i < m_classOffsets[cid + 1]; i += 2) if (m_classData[i + 1] == index) return m_classData[i];
} return 0;
}
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.