2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: UnivCharsetDesc.C /main/1 1996/07/29 17:07:43 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
28 #pragma implementation
31 #include "UnivCharsetDesc.h"
36 namespace SP_NAMESPACE {
39 UnivCharsetDesc::UnivCharsetDesc()
43 UnivCharsetDesc::UnivCharsetDesc(const Range *p, size_t n)
48 void UnivCharsetDesc::set(const Range *p, size_t n)
50 for (size_t i = 0; i < n; i++) {
51 const Range &r = p[i];
53 if (r.count > wideCharMax || r.descMin > wideCharMax - r.count)
56 max = r.descMin + (r.count - 1);
57 if (max - r.descMin > univCharMax
58 || r.univMin > univCharMax - (max - r.descMin))
59 max = r.descMin + (univCharMax - r.univMin);
60 descToUniv_.addRange(r.descMin, max, r.univMin);
64 void UnivCharsetDesc::addBaseRange(const UnivCharsetDesc &baseSet,
68 ISet<WideChar> &baseMissing)
70 UnivCharsetDescIter iter(baseSet);
71 WideChar baseMax = baseMin + (descMax - descMin);
72 WideChar iDescMin, iDescMax;
74 WideChar missingBaseMin = baseMin;
76 while (iter.next(iDescMin, iDescMax, iBaseMin) && iDescMin <= baseMax) {
79 if (iDescMax >= baseMin) {
80 WideChar min = baseMin > iDescMin ? baseMin : iDescMin;
81 if (min > missingBaseMin)
82 baseMissing.addRange(missingBaseMin, min - 1);
83 WideChar max = baseMax < iDescMax ? baseMax : iDescMax;
84 missingBaseMin = max + 1;
85 if (missingBaseMin == 0)
88 descToUniv_.addRange(descMin + (min - baseMin),
89 descMin + (max - baseMin),
90 iBaseMin + (min - iDescMin));
93 if (!usedAll && baseMax >= missingBaseMin)
94 baseMissing.addRange(missingBaseMin, baseMax);