ICU-210 Three major changes:

u_getVersion: returns ICU release/version information
u_getUnicodeVersion: returns Unicode standard version supported in ICU
Renamed the original u_getVersion to u_getUnicodeVersion.

X-SVN-Rev: 536
This commit is contained in:
Helena Chapman 2000-01-11 23:20:26 +00:00
parent e8fa02126f
commit 218b24bba5
12 changed files with 145 additions and 66 deletions

View File

@ -895,7 +895,7 @@ InputPath=.\unicode\umisc.h
InputName=umisc
"..\..\include\unicode\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy unicode\$(InputName).h ..\..\include\unicode
copy unicode\$(InputName).h ..\..\include\unicode
echo $(InputName)
# End Custom Build
@ -1053,6 +1053,33 @@ InputPath=.\unicode\utypes.h
# Begin Source File
SOURCE=.\uvector.h
# End Source File
# Begin Source File
SOURCE=.\unicode\uversion.h
!IF "$(CFG)" == "common - Win32 Release"
# Begin Custom Build
InputPath=.\unicode\uversion.h
"..\..\include\unicode\uversion.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy unicode\uversion.h ..\..\include\unicode
# End Custom Build
!ELSEIF "$(CFG)" == "common - Win32 Debug"
# Begin Custom Build
InputPath=.\unicode\uversion.h
"..\..\include\unicode\uversion.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy unicode\uversion.h ..\..\include\unicode
# End Custom Build
!ENDIF
# End Source File
# End Group
# Begin Group "Resource Files"

View File

@ -985,7 +985,7 @@ findLibraryPath(char *path, int size) {
}
/* define a path for fallbacks */
#define FALLBACK_PATH U_FILE_SEP_STRING "share" U_FILE_SEP_STRING "icu" U_FILE_SEP_STRING ICU_VERSION U_FILE_SEP_STRING
#define FALLBACK_PATH U_FILE_SEP_STRING "share" U_FILE_SEP_STRING "icu" U_FILE_SEP_STRING U_ICU_VERSION U_FILE_SEP_STRING
/* #include <stdio.h> */
/* #include <unistd.h> */
@ -1465,6 +1465,32 @@ u_UCharsToChars(const UChar *us, char *cs, UTextOffset length) {
}
}
U_CAPI int32_t U_EXPORT2
u_getVersion(uint8_t* versionArray)
{
int32_t len = uprv_strlen(U_ICU_VERSION), i = 0, part = 0;
char verString[U_MAX_VERSION_STRING], *begin;
if (versionArray == 0)
{
return U_MAX_VERSION_LEN;
}
begin = &(verString[0]);
uprv_strcpy(verString, U_ICU_VERSION);
uprv_memset(versionArray, 0, U_MAX_VERSION_LEN);
do {
if (verString[i] == U_VERSION_DELIMITER)
{
verString[i] = 0;
versionArray[part++] = (uint8_t)T_CString_stringToInteger(begin, 16);
begin = &(verString[i+1]);
}
}
while (i++ < len);
versionArray[part++] = (uint8_t)T_CString_stringToInteger(begin, 16);
return U_MAX_VERSION_LEN;
}
/* u_errorName() ------------------------------------------------------------ */
static const char *

View File

@ -914,7 +914,7 @@ ResourceBundle::getVersionNumber() const
// the length of the major part + the length of the separator
// (==1) + the length of the minor part (+ 1 for the zero byte at
// the end).
int32_t len = uprv_strlen(ICU_VERSION);
int32_t len = uprv_strlen(U_ICU_VERSION);
int32_t minor_len = 0;
if(U_SUCCESS(status) && minor_version.length() > 0)
minor_len = minor_version.length();
@ -925,7 +925,7 @@ ResourceBundle::getVersionNumber() const
// + 1 for zero byte
((ResourceBundle*)this)->fVersionID = new char[1 + len];
uprv_strcpy(fVersionID, ICU_VERSION);
uprv_strcpy(fVersionID, U_ICU_VERSION);
uprv_strcat(fVersionID, kVersionSeparator);
if(minor_len > 0) {
minor_version.extract(0, minor_len, fVersionID + len - minor_len);

View File

@ -1,13 +1,7 @@
/*
********************************************************************************
* *
* COPYRIGHT: *
* (C) Copyright Taligent, Inc., 1997 *
* (C) Copyright International Business Machines Corporation, 1997-1998 *
* Licensed Material - Program-Property of IBM - All Rights Reserved. *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
* Copyright (C) 1996-2000, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************************
*
* File UCHAR.CPP
@ -17,10 +11,11 @@
* Date Name Description
* 04/02/97 aliu Creation.
*
* 4/15/99 Madhu Updated all the function definitions for C Implementation
* 4/15/99 Madhu Updated all the function definitions for C Implementation
* 5/20/99 Madhu Added the function u_getVersion()
* 8/19/1999 srl Upgraded scripts to Unicode3.0
* 8/19/1999 srl Upgraded scripts to Unicode3.0
* 11/11/1999 weiv added u_isalnum(), cleaned comments
* 01/11/2000 helena Renamed u_getVersion to u_getUnicodeVersion.
********************************************************************************************
*/
#include "unicode/utypes.h"
@ -29,9 +24,7 @@
#include "umutex.h"
#include "unicode/uchar.h"
#include "cmemory.h"
#include <string.h>
#include <stdio.h>
#include "cstring.h"
struct UCharDigitPair{
uint16_t fUnicode;
@ -5260,13 +5253,27 @@ createDirTables()
#endif
}
const char* u_getVersion()
int32_t u_getUnicodeVersion(uint8_t* versionArray)
{
int32_t len=strlen(UNICODE_VERSION) + strlen("Unicode Version ");
_ucdVersion=(char*)uprv_realloc(_ucdVersion, len + 1 );
strcpy(_ucdVersion, "Unicode Version ");
strcat(_ucdVersion, UNICODE_VERSION);
return _ucdVersion;
int32_t len = uprv_strlen(U_UNICODE_VERSION), i = 0, part = 0;
char verString[U_MAX_VERSION_STRING], *begin;
if (versionArray == 0)
{
return U_MAX_VERSION_LEN;
}
begin = &(verString[0]);
uprv_strcpy(verString, U_UNICODE_VERSION);
uprv_memset(versionArray, 0, U_MAX_VERSION_LEN);
do {
if (verString[i] == U_VERSION_DELIMITER)
{
verString[i] = 0;
versionArray[part++] = (uint8_t)T_CString_stringToInteger(begin, 16);
begin = &(verString[i+1]);
}
}
while (i++ < len);
versionArray[part++] = (uint8_t)T_CString_stringToInteger(begin, 16);
return U_MAX_VERSION_LEN;
}

View File

@ -257,10 +257,10 @@ Unicode::forDigit(int32_t digit, int8_t radix) {
+ digit);
}
const char*
Unicode::getVersion()
int32_t
Unicode::getVersion(uint8_t* versionArray)
{
return (u_getVersion() );
return (u_getVersion(versionArray) );
}

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1997-1999, International Business Machines
* Copyright (C) 1997-2000, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -17,6 +17,7 @@
* 03/02/99 stephen Removed openFile(). Added AS400 support.
* 04/15/99 stephen Converted to C
* 11/15/99 helena Integrated S/390 changes for IEEE support.
* 01/11/00 helena Added u_getVersion.
*******************************************************************************
*/
@ -212,4 +213,14 @@ u_charsToUChars(const char *cs, UChar *us, UTextOffset length);
U_CAPI void U_EXPORT2
u_UCharsToChars(const UChar *us, char *cs, UTextOffset length);
/**
* Gets the ICU release version. The version array stores the version information
* for ICU. For example, release "1.3.31.2" is then represented as 0x01031F02.
* @param versionArray the version #
* @return the size of the version array
*/
U_CAPI int32_t U_EXPORT2
u_getVersion(uint8_t* versionArray);
#endif

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (C) 1997-1999, International Business Machines
* Copyright (C) 1997-2000, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
@ -16,6 +16,7 @@
* 8/19/1999 srl Upgraded scripts to Unicode 3.0
* 8/27/1999 schererm UCharDirection constants: U_...
* 11/11/1999 weiv added u_isalnum(), cleaned comments
* 01/11/2000 helena Renamed u_getVersion to u_getUnicodeVersion().
********************************************************************************
*/
@ -830,12 +831,14 @@ U_CAPI UChar U_EXPORT2
u_totitle(UChar c);
/**
* The function is used to get the Unicode standard Version that is used.
*
* @return the Unicode stabdard Version number
* Gets the Unicode version information. The version array stores the version information
* for the Unicode standard that is currently used by ICU. For example, release "1.3.31.2"
* is then represented as 0x01031F02.
* @param versionArray the version #
* @return the size of the version array
*/
U_CAPI const char* U_EXPORT2
u_getVersion(void);
U_CAPI int32_t U_EXPORT2
u_getUnicodeVersion(uint8_t* versionArray);
#endif /*_UCHAR*/
/*eof*/

View File

@ -752,7 +752,7 @@ public:
* Retrieves the Unicode Standard Version number that is used
* @return the Unicode Standard Version Number.
*/
static const char* getVersion(void);
static int32_t getVersion(uint8_t *versionArray);
protected:
// These constructors, destructor, and assignment operator must

View File

@ -38,6 +38,7 @@
#include <wchar.h>
#include <stdlib.h>
#include "unicode\uversion.h"
/*===========================================================================*/
/* Include platform-dependent definitions */
/* which are contained in the platform-specific file platform.h */
@ -144,30 +145,6 @@ typedef uint16_t UChar;
/* U_SIZEOF_UCHAR==sizeof(UChar) */
#define U_SIZEOF_UCHAR 2
/*===========================================================================*/
/* ICU version number */
/*===========================================================================*/
/*
* This version number is incremented if and only if the code has changed
* in a binary incompatible way. For example, if the algorithm for generating
* sort keys has changed, this code version must be incremented.
*
* This is for internal use only. Clients should use
* ResourceBundle::getVersionNumber().
*
* ResourceBundle::getVersionNumber() returns a full version number
* for a resource, which consists of this code version number concatenated
* with the ResourceBundle data file version number.
*/
/**
* ICU package code version number.
* For internal use only. Please use ResourceBundle::getVersionNumber()
*/
#define ICU_VERSION "3"
/*===========================================================================*/
/* For C wrappers, we use the symbol U_CAPI. */
/* This works properly if the includer is C or C++. */

View File

@ -0,0 +1,24 @@
/*
**********************************************************************
* Copyright (C) 2000, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
* File UVERSION.H
*
* Modification History:
*
* Date Name Description
* 01/11/2000 helena Creation as per jitterbug 210.
********************************************************************************
*/
#ifndef UVERSION_H
#define UVERSION_H
#define U_ICU_VERSION "1.4.0"
#define U_UNICODE_VERSION "3.0.0"
#define U_MAX_VERSION_LEN 4
#define U_VERSION_DELIMITER '.'
#define U_MAX_VERSION_STRING 20
#endif

View File

@ -344,6 +344,8 @@ void TestUnicodeData()
int32_t unicode;
char newPath[256];
const char *expectVersion = "3.0.0"; /* NOTE: this purposely breaks to force the tests to stay in sync with the unicodedata */
uint8_t expectVersionArray[] = {0x03, 0x00, 0x00, 0x00};
uint8_t versionArray[U_MAX_VERSION_LEN];
char expectString[256];
strcpy(newPath, u_getDataDirectory());
@ -353,10 +355,12 @@ void TestUnicodeData()
strcpy(expectString, "Unicode Version ");
strcat(expectString, expectVersion);
u_getUnicodeVersion(versionArray);
if(strcmp(u_getVersion(), expectString) != 0)
if(memcmp(versionArray, expectVersionArray, U_MAX_VERSION_LEN) != 0)
{
log_err("Testing u_getVersion() - expected %s got %s\n", expectString, u_getVersion());
log_err("Testing u_getUnicodeVersion() - expected %s got %d.%d.%d.%d\n", expectString,
versionArray[0], versionArray[1], versionArray[2], versionArray[3]);
}
#if defined(ICU_UNICODE_VERSION)

View File

@ -278,13 +278,13 @@ ResourceBundleTest::TestConstruction()
version1 = test1.getVersionNumber();
version2 = test2.getVersionNumber();
char *versionID1 = new char[1 + strlen(ICU_VERSION) + strlen(version1)]; // + 1 for zero byte
char *versionID2 = new char[1 + strlen(ICU_VERSION) + strlen(version2)]; // + 1 for zero byte
char *versionID1 = new char[1 + strlen(U_ICU_VERSION) + strlen(version1)]; // + 1 for zero byte
char *versionID2 = new char[1 + strlen(U_ICU_VERSION) + strlen(version2)]; // + 1 for zero byte
strcpy(versionID1, ICU_VERSION);
strcpy(versionID1, U_ICU_VERSION);
strcat(versionID1, ".44"); // hardcoded, please change if the default.txt file or ResourceBundle::kVersionSeparater is changed.
strcpy(versionID2, ICU_VERSION);
strcpy(versionID2, U_ICU_VERSION);
strcat(versionID2, ".55"); // hardcoded, please change if the te_IN.txt file or ResourceBundle::kVersionSeparater is changed.
logln(UnicodeString("getVersionNumber on default.txt returned ") + version1);