strversion.cpp revision 469215c767ddc89620e8e5edf36b3cdf7be4dad8
/* $Id$ */
/** @file
* IPRT - Version String Parsing.
*/
/*
* Copyright (C) 2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
#define RTSTRVER_IS_PUNCTUACTION(ch) \
/**
* Parses a out the next block from a version string.
*
* @returns true if numeric, false if not.
* @param pi32Value Where to return the value if numeric.
* @param pcchBlock Where to return the block length.
*/
{
/* Check for end-of-string. */
if (!*psz)
{
*pi32Value = 0;
*pcchBlock = 0;
return false;
}
if (fNumeric)
{
do
psz++;
{
fNumeric = false;
*pi32Value = 0;
}
}
else
{
do
psz++;
/* Translate standard pre release terms to negative values. */
iVal1 = -100000;
iVal1 = -200000;
iVal1 = -300000;
iVal1 = -400000;
iVal1 = -500000;
else
iVal1 = 0;
if (iVal1 != 0)
{
/* Trailing number? Add it assuming BETA == BETA1. */
if (RT_C_IS_DIGIT(*psz))
{
do
psz++;
else
{
}
}
fNumeric = true;
}
}
/* skip punctuation */
if (RTSTRVER_IS_PUNCTUACTION(*psz))
psz++;
return fNumeric;
}
{
/*
* Do a parallel parse of the strings.
*/
{
{
}
&& ( fNumeric1
)
{
/*else: 1.0 == 1.0.0.0.0. */;
}
{
/* Pre-release indicators are smaller than all other strings. */
}
else
{
if (iDiff)
}
}
return 0;
}