1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_jvmfwk.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "sunversion.hxx"
32*cdf0e10cSrcweir #include "osl/thread.h"
33*cdf0e10cSrcweir #include "osl/process.h"
34*cdf0e10cSrcweir #include "osl/security.hxx"
35*cdf0e10cSrcweir #include <string.h>
36*cdf0e10cSrcweir #include <ctype.h>
37*cdf0e10cSrcweir #include "diagnostics.h"
38*cdf0e10cSrcweir using namespace rtl;
39*cdf0e10cSrcweir using namespace osl;
40*cdf0e10cSrcweir namespace jfw_plugin  { //stoc_javadetect
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //extern OUString ::Impl::usPathDelim();
44*cdf0e10cSrcweir #define OUSTR( x )  ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( x ))
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >= 2
47*cdf0e10cSrcweir class SelfTest
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir public:
50*cdf0e10cSrcweir     SelfTest();
51*cdf0e10cSrcweir } test;
52*cdf0e10cSrcweir #endif
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir SunVersion::SunVersion(const rtl::OUString &usVer):
55*cdf0e10cSrcweir     m_nUpdateSpecial(0), m_preRelease(Rel_NONE),
56*cdf0e10cSrcweir     usVersion(usVer)
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir     memset(m_arVersionParts, 0, sizeof(m_arVersionParts));
59*cdf0e10cSrcweir     rtl::OString sVersion= rtl::OUStringToOString(usVer, osl_getThreadTextEncoding());
60*cdf0e10cSrcweir     m_bValid = init(sVersion.getStr());
61*cdf0e10cSrcweir }
62*cdf0e10cSrcweir SunVersion::SunVersion(const char * szVer):
63*cdf0e10cSrcweir     m_nUpdateSpecial(0), m_preRelease(Rel_NONE)
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     memset(m_arVersionParts, 0, sizeof(m_arVersionParts));
66*cdf0e10cSrcweir     m_bValid = init(szVer);
67*cdf0e10cSrcweir     usVersion= rtl::OUString(szVer,strlen(szVer),osl_getThreadTextEncoding());
68*cdf0e10cSrcweir }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir /**Format major.minor.maintainance_update
72*cdf0e10cSrcweir  */
73*cdf0e10cSrcweir bool SunVersion::init(const char *szVersion)
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir     if ( ! szVersion || strlen(szVersion) == 0)
76*cdf0e10cSrcweir         return false;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     //first get the major,minor,maintainance
79*cdf0e10cSrcweir     const char * pLast = szVersion;
80*cdf0e10cSrcweir     const char * pCur = szVersion;
81*cdf0e10cSrcweir 	//pEnd point to the position after the last character
82*cdf0e10cSrcweir     const char * pEnd = szVersion + strlen(szVersion);
83*cdf0e10cSrcweir     // 0 = major, 1 = minor, 2 = maintainance, 3 = update
84*cdf0e10cSrcweir     int nPart = 0;
85*cdf0e10cSrcweir     // position within part beginning with 0
86*cdf0e10cSrcweir     int nPartPos = 0;
87*cdf0e10cSrcweir     char buf[128];
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     //char must me a number 0 - 999 and no leading
90*cdf0e10cSrcweir     while (1)
91*cdf0e10cSrcweir     {
92*cdf0e10cSrcweir         if (pCur < pEnd && isdigit(*pCur))
93*cdf0e10cSrcweir         {
94*cdf0e10cSrcweir             if (pCur < pEnd)
95*cdf0e10cSrcweir                 pCur ++;
96*cdf0e10cSrcweir             nPartPos ++;
97*cdf0e10cSrcweir         }
98*cdf0e10cSrcweir         //if  correct separator then form integer
99*cdf0e10cSrcweir         else if (
100*cdf0e10cSrcweir             ! (nPartPos == 0) // prevents: ".4.1", "..1", part must start with digit
101*cdf0e10cSrcweir             && (
102*cdf0e10cSrcweir                 //seperators after maintainance (1.4.1_01, 1.4.1-beta, or1.4.1
103*cdf0e10cSrcweir                 ((pCur == pEnd || *pCur == '_' || *pCur == '-') && (nPart == 2 ))
104*cdf0e10cSrcweir                 ||
105*cdf0e10cSrcweir                 //separators between major-minor and minor-maintainance
106*cdf0e10cSrcweir                 (nPart < 2 && *pCur == '.') )
107*cdf0e10cSrcweir             && (
108*cdf0e10cSrcweir                 //prevent 1.4.0. 1.4.0-
109*cdf0e10cSrcweir                 pCur + 1 == pEnd ? isdigit(*(pCur)) : 1) )
110*cdf0e10cSrcweir         {
111*cdf0e10cSrcweir             int len = pCur - pLast;
112*cdf0e10cSrcweir             if (len >= 127)
113*cdf0e10cSrcweir                 return false;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir             strncpy(buf, pLast, len);
116*cdf0e10cSrcweir             buf[len] = 0;
117*cdf0e10cSrcweir             pCur ++;
118*cdf0e10cSrcweir             pLast = pCur;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir             m_arVersionParts[nPart] = atoi(buf);
121*cdf0e10cSrcweir             nPart ++;
122*cdf0e10cSrcweir             nPartPos = 0;
123*cdf0e10cSrcweir             if (nPart == 3)
124*cdf0e10cSrcweir                 break;
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir             //check next character
127*cdf0e10cSrcweir             if (! ( (pCur < pEnd)
128*cdf0e10cSrcweir                     && ( (nPart < 3) && isdigit(*pCur)))) //(*pCur >= 48 && *pCur <=57))))
129*cdf0e10cSrcweir                 return false;
130*cdf0e10cSrcweir         }
131*cdf0e10cSrcweir         else
132*cdf0e10cSrcweir         {
133*cdf0e10cSrcweir             return false;
134*cdf0e10cSrcweir         }
135*cdf0e10cSrcweir     }
136*cdf0e10cSrcweir     if (pCur >= pEnd)
137*cdf0e10cSrcweir         return true;
138*cdf0e10cSrcweir     //We have now 1.4.1. This can be followed by _01, -beta, etc.
139*cdf0e10cSrcweir     // _01 (update) According to docu must not be followed by any other
140*cdf0e10cSrcweir     //characters, but on Solaris 9 we have a 1.4.1_01a!!
141*cdf0e10cSrcweir     if (* (pCur - 1) == '_')
142*cdf0e10cSrcweir     {// _01, _02
143*cdf0e10cSrcweir         // update is the last part _01, _01a, part 0 is the digits parts and 1 the trailing alpha
144*cdf0e10cSrcweir         while (1)
145*cdf0e10cSrcweir         {
146*cdf0e10cSrcweir             if (pCur <= pEnd)
147*cdf0e10cSrcweir             {
148*cdf0e10cSrcweir                 if ( ! isdigit(*pCur))
149*cdf0e10cSrcweir                 {
150*cdf0e10cSrcweir                     //1.4.1_01-, 1.4.1_01a, the numerical part may only be 2 chars.
151*cdf0e10cSrcweir                     int len = pCur - pLast;
152*cdf0e10cSrcweir                     if (len > 2)
153*cdf0e10cSrcweir                         return false;
154*cdf0e10cSrcweir                     //we've got the update: 01, 02 etc
155*cdf0e10cSrcweir                     strncpy(buf, pLast, len);
156*cdf0e10cSrcweir                     buf[len] = 0;
157*cdf0e10cSrcweir                     m_arVersionParts[nPart] = atoi(buf);
158*cdf0e10cSrcweir                     if (pCur == pEnd)
159*cdf0e10cSrcweir                     {
160*cdf0e10cSrcweir                         break;
161*cdf0e10cSrcweir                     }
162*cdf0e10cSrcweir                     if (*pCur == 'a' && (pCur + 1) == pEnd)
163*cdf0e10cSrcweir                     {
164*cdf0e10cSrcweir                         //check if it s followed by a simple "a" (not specified)
165*cdf0e10cSrcweir                         m_nUpdateSpecial = *pCur;
166*cdf0e10cSrcweir                         break;
167*cdf0e10cSrcweir                     }
168*cdf0e10cSrcweir                     else if (*pCur == '-' && pCur < pEnd)
169*cdf0e10cSrcweir                     {
170*cdf0e10cSrcweir                         //check 1.5.0_01-ea
171*cdf0e10cSrcweir                         PreRelease pr = getPreRelease(++pCur);
172*cdf0e10cSrcweir                         if (pr == Rel_NONE)
173*cdf0e10cSrcweir                             return false;
174*cdf0e10cSrcweir                         //just ignore -ea because its no official release
175*cdf0e10cSrcweir                         break;
176*cdf0e10cSrcweir                     }
177*cdf0e10cSrcweir                     else
178*cdf0e10cSrcweir                     {
179*cdf0e10cSrcweir                         return false;
180*cdf0e10cSrcweir                     }
181*cdf0e10cSrcweir                 }
182*cdf0e10cSrcweir                 if (pCur < pEnd)
183*cdf0e10cSrcweir                     pCur ++;
184*cdf0e10cSrcweir                 else
185*cdf0e10cSrcweir                     break;
186*cdf0e10cSrcweir             }
187*cdf0e10cSrcweir         }
188*cdf0e10cSrcweir     }
189*cdf0e10cSrcweir     // 1.4.1-ea
190*cdf0e10cSrcweir     else if (*(pCur - 1) == '-')
191*cdf0e10cSrcweir     {
192*cdf0e10cSrcweir         m_preRelease = getPreRelease(pCur);
193*cdf0e10cSrcweir         if (m_preRelease == Rel_NONE)
194*cdf0e10cSrcweir             return false;
195*cdf0e10cSrcweir #if defined(FREEBSD)
196*cdf0e10cSrcweir       if (m_preRelease == Rel_FreeBSD)
197*cdf0e10cSrcweir       {
198*cdf0e10cSrcweir           pCur++; //elemnate `p'
199*cdf0e10cSrcweir           if (pCur < pEnd && isdigit(*pCur))
200*cdf0e10cSrcweir               pCur ++;
201*cdf0e10cSrcweir           int len = pCur - pLast -1; //elemenate `p'
202*cdf0e10cSrcweir           if (len >= 127)
203*cdf0e10cSrcweir               return false;
204*cdf0e10cSrcweir           strncpy(buf, (pLast+1), len); //elemenate `p'
205*cdf0e10cSrcweir           buf[len] = 0;
206*cdf0e10cSrcweir           m_nUpdateSpecial = atoi(buf)+100; //hack for FBSD #i56953#
207*cdf0e10cSrcweir           return true;
208*cdf0e10cSrcweir       }
209*cdf0e10cSrcweir #endif
210*cdf0e10cSrcweir     }
211*cdf0e10cSrcweir     else
212*cdf0e10cSrcweir     {
213*cdf0e10cSrcweir         return false;
214*cdf0e10cSrcweir     }
215*cdf0e10cSrcweir     return true;
216*cdf0e10cSrcweir }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir SunVersion::PreRelease SunVersion::getPreRelease(const char *szRelease)
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir     if (szRelease == NULL)
221*cdf0e10cSrcweir         return Rel_NONE;
222*cdf0e10cSrcweir     if( ! strcmp(szRelease,"ea"))
223*cdf0e10cSrcweir         return  Rel_EA;
224*cdf0e10cSrcweir     else if( ! strcmp(szRelease,"ea1"))
225*cdf0e10cSrcweir         return Rel_EA1;
226*cdf0e10cSrcweir     else if( ! strcmp(szRelease,"ea2"))
227*cdf0e10cSrcweir         return Rel_EA2;
228*cdf0e10cSrcweir     else if( ! strcmp(szRelease,"ea3"))
229*cdf0e10cSrcweir         return Rel_EA3;
230*cdf0e10cSrcweir     else if ( ! strcmp(szRelease,"beta"))
231*cdf0e10cSrcweir         return Rel_BETA;
232*cdf0e10cSrcweir     else if ( ! strcmp(szRelease,"beta1"))
233*cdf0e10cSrcweir         return Rel_BETA1;
234*cdf0e10cSrcweir     else if ( ! strcmp(szRelease,"beta2"))
235*cdf0e10cSrcweir         return Rel_BETA2;
236*cdf0e10cSrcweir     else if ( ! strcmp(szRelease,"beta3"))
237*cdf0e10cSrcweir         return Rel_BETA3;
238*cdf0e10cSrcweir     else if (! strcmp(szRelease, "rc"))
239*cdf0e10cSrcweir         return Rel_RC;
240*cdf0e10cSrcweir     else if (! strcmp(szRelease, "rc1"))
241*cdf0e10cSrcweir         return Rel_RC1;
242*cdf0e10cSrcweir     else if (! strcmp(szRelease, "rc2"))
243*cdf0e10cSrcweir         return Rel_RC2;
244*cdf0e10cSrcweir     else if (! strcmp(szRelease, "rc3"))
245*cdf0e10cSrcweir         return Rel_RC3;
246*cdf0e10cSrcweir #if defined (FREEBSD)
247*cdf0e10cSrcweir     else if (! strncmp(szRelease, "p", 1))
248*cdf0e10cSrcweir         return Rel_FreeBSD;
249*cdf0e10cSrcweir #endif
250*cdf0e10cSrcweir     else
251*cdf0e10cSrcweir         return Rel_NONE;
252*cdf0e10cSrcweir }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir SunVersion::~SunVersion()
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir /* Examples:
260*cdf0e10cSrcweir    a) 1.0 < 1.1
261*cdf0e10cSrcweir    b) 1.0 < 1.0.0
262*cdf0e10cSrcweir    c)  1.0 < 1.0_00
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir    returns false if both values are equal
265*cdf0e10cSrcweir */
266*cdf0e10cSrcweir bool SunVersion::operator > (const SunVersion& ver) const
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir     if( &ver == this)
269*cdf0e10cSrcweir         return false;
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     //compare major.minor.maintainance
272*cdf0e10cSrcweir     for( int i= 0; i < 4; i ++)
273*cdf0e10cSrcweir     {
274*cdf0e10cSrcweir         // 1.4 > 1.3
275*cdf0e10cSrcweir         if(m_arVersionParts[i] > ver.m_arVersionParts[i])
276*cdf0e10cSrcweir         {
277*cdf0e10cSrcweir             return true;
278*cdf0e10cSrcweir         }
279*cdf0e10cSrcweir         else if (m_arVersionParts[i] < ver.m_arVersionParts[i])
280*cdf0e10cSrcweir         {
281*cdf0e10cSrcweir             return false;
282*cdf0e10cSrcweir         }
283*cdf0e10cSrcweir     }
284*cdf0e10cSrcweir     //major.minor.maintainance_update are equal. test for a trailing char
285*cdf0e10cSrcweir     if (m_nUpdateSpecial > ver.m_nUpdateSpecial)
286*cdf0e10cSrcweir     {
287*cdf0e10cSrcweir         return true;
288*cdf0e10cSrcweir     }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 	//Until here the versions are equal
291*cdf0e10cSrcweir     //compare pre -release values
292*cdf0e10cSrcweir 	if ((m_preRelease == Rel_NONE && ver.m_preRelease == Rel_NONE)
293*cdf0e10cSrcweir 		||
294*cdf0e10cSrcweir 		(m_preRelease != Rel_NONE && ver.m_preRelease == Rel_NONE))
295*cdf0e10cSrcweir 		return false;
296*cdf0e10cSrcweir 	else if (m_preRelease == Rel_NONE && ver.m_preRelease != Rel_NONE)
297*cdf0e10cSrcweir 		return true;
298*cdf0e10cSrcweir     else if (m_preRelease > ver.m_preRelease)
299*cdf0e10cSrcweir         return true;
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     return false;
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir bool SunVersion::operator < (const SunVersion& ver) const
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir     return (! operator > (ver)) && (! operator == (ver));
307*cdf0e10cSrcweir }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir bool SunVersion::operator == (const SunVersion& ver) const
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir     bool bRet= true;
312*cdf0e10cSrcweir     for(int i= 0; i < 4; i++)
313*cdf0e10cSrcweir     {
314*cdf0e10cSrcweir         if( m_arVersionParts[i] != ver.m_arVersionParts[i])
315*cdf0e10cSrcweir         {
316*cdf0e10cSrcweir             bRet= false;
317*cdf0e10cSrcweir             break;
318*cdf0e10cSrcweir         }
319*cdf0e10cSrcweir     }
320*cdf0e10cSrcweir     bRet = m_nUpdateSpecial == ver.m_nUpdateSpecial && bRet;
321*cdf0e10cSrcweir     bRet = m_preRelease == ver.m_preRelease && bRet;
322*cdf0e10cSrcweir     return bRet;
323*cdf0e10cSrcweir }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir SunVersion::operator bool()
326*cdf0e10cSrcweir {
327*cdf0e10cSrcweir     return m_bValid;
328*cdf0e10cSrcweir }
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >= 2
331*cdf0e10cSrcweir SelfTest::SelfTest()
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir     bool bRet = true;
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     char const * versions[] = {"1.4.0", "1.4.1", "1.0.0", "10.0.0", "10.10.0",
336*cdf0e10cSrcweir                          "10.2.2", "10.10.0", "10.10.10", "111.0.999",
337*cdf0e10cSrcweir                          "1.4.1_01", "9.90.99_09", "1.4.1_99",
338*cdf0e10cSrcweir                          "1.4.1_00a",
339*cdf0e10cSrcweir                          "1.4.1-ea", "1.4.1-beta", "1.4.1-rc1",
340*cdf0e10cSrcweir                          "1.5.0_01-ea", "1.5.0_01-rc2"};
341*cdf0e10cSrcweir     char const * badVersions[] = {".4.0", "..1", "", "10.0", "10.10.0.", "10.10.0-", "10.10.0.",
342*cdf0e10cSrcweir                             "10.2-2", "10_10.0", "10..10","10.10", "a.0.999",
343*cdf0e10cSrcweir                             "1.4b.1_01", "9.90.-99_09", "1.4.1_99-",
344*cdf0e10cSrcweir                             "1.4.1_00a2", "1.4.0_z01z", "1.4.1__99A",
345*cdf0e10cSrcweir                             "1.4.1-1ea", "1.5.0_010", "1.5.0._01-", "1.5.0_01-eac"};
346*cdf0e10cSrcweir     char const * orderedVer[] = { "1.3.1-ea", "1.3.1-beta", "1.3.1-rc1",
347*cdf0e10cSrcweir                             "1.3.1", "1.3.1_00a", "1.3.1_01", "1.3.1_01a",
348*cdf0e10cSrcweir                             "1.3.2", "1.4.0", "1.5.0_01-ea", "2.0.0"};
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir     int num = sizeof (versions) / sizeof(char*);
351*cdf0e10cSrcweir     int numBad = sizeof (badVersions) / sizeof(char*);
352*cdf0e10cSrcweir     int numOrdered = sizeof (orderedVer) / sizeof(char*);
353*cdf0e10cSrcweir     //parsing test (positive)
354*cdf0e10cSrcweir     for (int i = 0; i < num; i++)
355*cdf0e10cSrcweir 	{
356*cdf0e10cSrcweir         SunVersion ver(versions[i]);
357*cdf0e10cSrcweir         if ( ! ver)
358*cdf0e10cSrcweir         {
359*cdf0e10cSrcweir             bRet = false;
360*cdf0e10cSrcweir             break;
361*cdf0e10cSrcweir         }
362*cdf0e10cSrcweir 	}
363*cdf0e10cSrcweir     OSL_ENSURE(bRet, "SunVersion selftest failed");
364*cdf0e10cSrcweir 	//Parsing test (negative)
365*cdf0e10cSrcweir     for ( int i = 0; i < numBad; i++)
366*cdf0e10cSrcweir     {
367*cdf0e10cSrcweir         SunVersion ver(badVersions[i]);
368*cdf0e10cSrcweir         if (ver)
369*cdf0e10cSrcweir         {
370*cdf0e10cSrcweir             bRet = false;
371*cdf0e10cSrcweir             break;
372*cdf0e10cSrcweir         }
373*cdf0e10cSrcweir     }
374*cdf0e10cSrcweir     OSL_ENSURE(bRet, "SunVersion selftest failed");
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     // Ordering test
377*cdf0e10cSrcweir     bRet = true;
378*cdf0e10cSrcweir     int j = 0;
379*cdf0e10cSrcweir     for (int i = 0; i < numOrdered; i ++)
380*cdf0e10cSrcweir     {
381*cdf0e10cSrcweir         SunVersion curVer(orderedVer[i]);
382*cdf0e10cSrcweir         if ( ! curVer)
383*cdf0e10cSrcweir         {
384*cdf0e10cSrcweir             bRet = false;
385*cdf0e10cSrcweir             break;
386*cdf0e10cSrcweir         }
387*cdf0e10cSrcweir         for (j = 0; j < numOrdered; j++)
388*cdf0e10cSrcweir         {
389*cdf0e10cSrcweir             SunVersion compVer(orderedVer[j]);
390*cdf0e10cSrcweir             if (i < j)
391*cdf0e10cSrcweir             {
392*cdf0e10cSrcweir                 if ( !(curVer < compVer))
393*cdf0e10cSrcweir                 {
394*cdf0e10cSrcweir                     bRet = false;
395*cdf0e10cSrcweir                     break;
396*cdf0e10cSrcweir                 }
397*cdf0e10cSrcweir             }
398*cdf0e10cSrcweir             else if ( i == j)
399*cdf0e10cSrcweir             {
400*cdf0e10cSrcweir                 if (! (curVer == compVer
401*cdf0e10cSrcweir                        && ! (curVer > compVer)
402*cdf0e10cSrcweir                        && ! (curVer < compVer)))
403*cdf0e10cSrcweir                 {
404*cdf0e10cSrcweir                     bRet = false;
405*cdf0e10cSrcweir                     break;
406*cdf0e10cSrcweir                 }
407*cdf0e10cSrcweir             }
408*cdf0e10cSrcweir             else if (i > j)
409*cdf0e10cSrcweir             {
410*cdf0e10cSrcweir                 if ( !(curVer > compVer))
411*cdf0e10cSrcweir                 {
412*cdf0e10cSrcweir                     bRet = false;
413*cdf0e10cSrcweir                     break;
414*cdf0e10cSrcweir                 }
415*cdf0e10cSrcweir             }
416*cdf0e10cSrcweir         }
417*cdf0e10cSrcweir         if ( ! bRet)
418*cdf0e10cSrcweir             break;
419*cdf0e10cSrcweir     }
420*cdf0e10cSrcweir     if (bRet)
421*cdf0e10cSrcweir         JFW_TRACE2("[Java framework] sunjavaplugin: Testing class SunVersion succeeded.\n");
422*cdf0e10cSrcweir     else
423*cdf0e10cSrcweir         OSL_ENSURE(bRet, "[Java framework] sunjavaplugin: SunVersion self test failed.\n");
424*cdf0e10cSrcweir }
425*cdf0e10cSrcweir #endif
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir }
428