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