You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/06/19 21:31:08 UTC
cvs commit: xml-xerces/c/src/util/Transcoders/Iconv400 Iconv400TransService.cpp iconv_cnv.c
tng 01/06/19 12:31:07
Modified: c/src/util/Platforms/OS400 OS400PlatformUtils.cpp
c/src/util/Transcoders/Iconv400 Iconv400TransService.cpp
iconv_cnv.c
Log:
Latest AS/400 update.
Revision Changes Path
1.6 +50 -50 xml-xerces/c/src/util/Platforms/OS400/OS400PlatformUtils.cpp
Index: OS400PlatformUtils.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/util/Platforms/OS400/OS400PlatformUtils.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- OS400PlatformUtils.cpp 2000/09/28 22:42:45 1.5
+++ OS400PlatformUtils.cpp 2001/06/19 19:30:59 1.6
@@ -1,37 +1,37 @@
/*
* The Apache Software License, Version 1.1
- *
+ *
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
+ * notice, this list of conditions and the following disclaimer.
+ *
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- *
+ *
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
- *
+ *
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache\@apache.org.
- *
+ *
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
- *
+ *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -45,7 +45,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
- *
+ *
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
@@ -55,14 +55,14 @@
*/
/**
- * $Id: OS400PlatformUtils.cpp,v 1.5 2000/09/28 22:42:45 aruna1 Exp $
+ * $Id: OS400PlatformUtils.cpp,v 1.6 2001/06/19 19:30:59 tng Exp $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#define MY_XP_CPLUSPLUS
-#include "OS400PlatformUtils.hpp"
+#include "OS400PlatformUtils.hpp"
#include <pthread.h>
#include <util/PlatformUtils.hpp>
#include <util/RuntimeException.hpp>
@@ -78,20 +78,21 @@
#include <string.h>
#include <qmhsndpm.h>
#include <except.h>
+#include <mih/cmpswp.h>
#if defined (XML_USE_ICONV400_TRANSCODER)
#include <util/Transcoders/Iconv400/Iconv400TransService.hpp>
#elif defined (XML_USE_ICU_TRANSCODER)
#include <util/Transcoders/ICU/ICUTransService.hpp>
#else
- Transcoder not Specified - FOr OS/400 must be either ICU or Iconv400
+ Transcoder not Specified - FOr OS/400 must be either ICU or Iconv400
#endif
#if defined(XML_USE_MSGFILE_MESSAGELOADER)
#include <util/MsgLoaders/MsgFile/MsgLoader.hpp>
#elif defined(XML_USE_INMEM_MESSAGELOADER)
#include <util/MsgLoaders/InMemory/InMemMsgLoader.hpp>
-#else
+#else
#include <util/MsgLoaders/ICU/ICUMsgLoader.hpp>
#endif
@@ -149,8 +150,8 @@
void XMLPlatformUtils::platformInit()
{
//
- // The gAtomicOpMutex mutex needs to be created
- // because compareAndSwap and incrementlocation and decrementlocation
+ // The gAtomicOpMutex mutex needs to be created
+ // because compareAndSwap and incrementlocation and decrementlocation
// does not have the atomic system calls for usage
// Normally, mutexes are created on first use, but there is a
// circular dependency between compareAndExchange() and
@@ -231,7 +232,7 @@
reason_code.reason_char = '0';
reason_code.endofstring = '\0';
reason_code.reason_char = reason_code.reason_char + reason;
- send_message((char*)&reason_code,GENERAL_PANIC_MESSAGE,'e');
+ send_message((char*)&reason_code,GENERAL_PANIC_MESSAGE,'e');
}
}
// ---------------------------------------------------------------------------
@@ -342,9 +343,9 @@
// ---------------------------------------------------------------------------
unsigned long XMLPlatformUtils::getCurrentMillis()
{
- _MI_Time mt;
- struct timeval tv;
- int rc;
+ _MI_Time mt;
+ struct timeval tv;
+ int rc;
mattod(mt);
rc = Qp0zCvtToTimeval(&tv, mt, QP0Z_CVTTIME_TO_TIMESTAMP);
@@ -380,7 +381,7 @@
XMLCh* XMLPlatformUtils::getFullPath(const XMLCh* const srcPath)
{
-
+
//
// NOTE: THe path provided has always already been opened successfully,
// so we know that its not some pathological freaky path. It comes in
@@ -390,7 +391,7 @@
ArrayJanitor<char> janText(newSrc);
// Use a local buffer that is big enough for the largest legal path
char *absPath = new char[256];
- //get the absolute path
+ //get the absolute path
char* retPath = realpath(newSrc, absPath);
ArrayJanitor<char> janText2(retPath);
@@ -574,7 +575,7 @@
in QCPFMSG */
}
-
+
else /* just use what we have for immediate text */
{
id = &message_id[0];
@@ -585,9 +586,9 @@
msg_type = "*COMP ";/* set it as completion */
else /* currently all other messages are
diagnostics */
- msg_type = "*DIAG ";
- if (text != 0) /* was a text field passed */
-
+ msg_type = "*DIAG ";
+ if (text != 0) /* was a text field passed */
+
{
textsize = strlen(text);
msg_size = textsize + sizeof(short);
@@ -615,10 +616,10 @@
void abnormal_termination(int termcode)
{
- send_message(NULL,"CPF9899",'e'); /* send final exception that we have terminated*/
+ send_message(NULL,"CPF9899",'e'); /* send final exception that we have terminated*/
}
// -----------------------------------------------------------------------
-// Mutex methods
+// Mutex methods
// -----------------------------------------------------------------------
#if !defined (APP_NO_THREADS)
@@ -630,7 +631,7 @@
int recursionCount;
pthread_t tid;
- RecursiveMutex() {
+ RecursiveMutex() {
if (pthread_mutex_init(&mutex, NULL))
ThrowXML(XMLPlatformUtilsException, XMLExcepts::Mutex_CouldNotCreate);
recursionCount = 0;
@@ -703,11 +704,11 @@
// -----------------------------------------------------------------------
// Miscellaneous synchronization methods
// -----------------------------------------------------------------------
-//atomic system calls in Solaris is only restricted to kernel libraries
-//So, to make operations thread safe we implement static mutex and lock
+//atomic system calls in Solaris is only restricted to kernel libraries
+//So, to make operations thread safe we implement static mutex and lock
//the atomic operations. It makes the process slow but what's the alternative!
-void* XMLPlatformUtils::compareAndSwap ( void** toFill ,
- const void* const newValue ,
+void* XMLPlatformUtils::compareAndSwap ( void** toFill ,
+ const void* const newValue ,
const void* const toCompare)
{
//return ((void*)cas32( (uint32_t*)toFill, (uint32_t)toCompare, (uint32_t)newValue) );
@@ -729,29 +730,28 @@
int XMLPlatformUtils::atomicIncrement(int &location)
{
- //return (int)atomic_add_32_nv( (uint32_t*)&location, 1);
+ int current = location;
+ int new_loc = current+1;
- if (pthread_mutex_lock( gAtomicOpMutex))
- panic(XMLPlatformUtils::Panic_SynchronizationErr);
+ while (_CMPSWP(¤t,
+ &location,
+ new_loc) == 0)
+ new_loc = current+1;
+ int tmp = new_loc;
- int tmp = ++location;
-
- if (pthread_mutex_unlock( gAtomicOpMutex))
- panic(XMLPlatformUtils::Panic_SynchronizationErr);
-
return tmp;
}
int XMLPlatformUtils::atomicDecrement(int &location)
{
- //return (int)atomic_add_32_nv( (uint32_t*)&location, -1);
- if (pthread_mutex_lock( gAtomicOpMutex))
- panic(XMLPlatformUtils::Panic_SynchronizationErr);
-
- int tmp = --location;
+ int current = location;
+ int new_loc = current-1;
- if (pthread_mutex_unlock( gAtomicOpMutex))
- panic(XMLPlatformUtils::Panic_SynchronizationErr);
+ while (_CMPSWP(¤t,
+ &location,
+ new_loc) == 0)
+ new_loc = current-1;
+ int tmp = new_loc;
return tmp;
}
1.6 +9 -6 xml-xerces/c/src/util/Transcoders/Iconv400/Iconv400TransService.cpp
Index: Iconv400TransService.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/util/Transcoders/Iconv400/Iconv400TransService.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Iconv400TransService.cpp 2001/02/21 15:26:57 1.5
+++ Iconv400TransService.cpp 2001/06/19 19:31:03 1.6
@@ -55,7 +55,7 @@
*/
/**
- * $Id: Iconv400TransService.cpp,v 1.5 2001/02/21 15:26:57 tng Exp $
+ * $Id: Iconv400TransService.cpp,v 1.6 2001/06/19 19:31:03 tng Exp $
*/
// ---------------------------------------------------------------------------
@@ -872,6 +872,8 @@
// the best guess as to the storage needed.
//
const int32_t srcLen = (int32_t)strlen(toTranscode);
+ // Allocate unicode string of equivalent length in unicode bytes
+ retVal = new XMLCh[srcLen+1];
// Now lock while we do these calculations
UErrorCode err = U_ZERO_ERROR;
@@ -887,15 +889,15 @@
targetCap = ucnv_toUChars
(
fConverter
- , 0
- , 0
+ , retVal
+ , srcLen+1
, toTranscode
, srcLen
, &err
);
if (err != U_BUFFER_OVERFLOW_ERROR)
- return 0;
+ {
err = U_ZERO_ERROR;
retVal = new XMLCh[targetCap];
@@ -907,8 +909,9 @@
, toTranscode
, srcLen
, &err
- );
- }
+ );
+ }
+ }
if (U_FAILURE(err))
{
1.3 +8 -17 xml-xerces/c/src/util/Transcoders/Iconv400/iconv_cnv.c
Index: iconv_cnv.c
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/util/Transcoders/Iconv400/iconv_cnv.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- iconv_cnv.c 2000/09/12 17:06:49 1.2
+++ iconv_cnv.c 2001/06/19 19:31:04 1.3
@@ -56,6 +56,9 @@
/**
* $Log: iconv_cnv.c,v $
+ * Revision 1.3 2001/06/19 19:31:04 tng
+ * Latest AS/400 update.
+ *
* Revision 1.2 2000/09/12 17:06:49 aruna1
* Replaced INDEX_OUTOFBOUNDS error to BUFFER_OVERFLOW error for toUnicode and from_Unicode functions for compatibility with icu 1.6
*
@@ -192,7 +195,6 @@
int flush,
UErrorCode * err)
{
- UCNV_TYPE myConvType;
/*
* Check parameters in for all conversions
*/
@@ -203,7 +205,6 @@
return;
}
- myConvType = _this->sharedData->conversionType;
/*calls the specific conversion routines */
Converter_fromUnicode(_this,target,targetLimit,source,sourceLimit,
@@ -224,7 +225,6 @@
/*
* Check parameters in for all conversions
*/
- UCNV_TYPE myConvType;
if (U_FAILURE (*err)) return;
if ((_this == NULL) || ((UChar *) targetLimit < *target) || (sourceLimit < *source))
{
@@ -232,7 +232,6 @@
return;
}
- myConvType = _this->sharedData->conversionType;
/*calls the specific conversion routines */
@@ -383,10 +382,10 @@
/*Not in pure pre-flight mode */
if (targetSize > 0)
{
-
+ /* Changed from (targetSize * 2) to (targetSize) */
ucnv_toUnicode (&myConverter,
&myTarget,
- target + (targetSize * 2) - 1, /*Save a spot for the Null terminator */
+ target + (targetSize-1), /*Save a spot for the Null terminator */
&mySource,
mySource_limit,
NULL,
@@ -657,8 +656,7 @@
int chardone;
const UChar *mySource = *source;
unsigned char *myTarget = (unsigned char *) *target;
- int32_t mySourceIndex = 0;
- int32_t myTargetIndex = 0;
+
int32_t targetLength = targetLimit - (char *) myTarget;
int32_t sourceLength = (sourceLimit - mySource) * 2;
unsigned char targetChar = 0x00;
@@ -683,8 +681,6 @@
*err = U_INVALID_CHAR_FOUND;
return;
}
- *target += myTargetIndex;
- *source += mySourceIndex;
return;
@@ -701,12 +697,9 @@
{
char *mySource = (char *) *source;
UChar *myTarget = *target;
- int32_t mySourceIndex = 0;
- int32_t myTargetIndex = 0;
- int32_t targetLength = targetLimit - myTarget;
+
+ int32_t targetLength = (targetLimit - myTarget)*2; /* multiply by 2 */
int32_t sourceLength = (sourceLimit - (char *) mySource);
- UChar *myToUnicode = NULL;
- UChar targetUniChar = 0x0000;
int chardone;
/* pick up the iconv handle */
errno = 0;
@@ -734,8 +727,6 @@
}
- *target += myTargetIndex;
- *source += mySourceIndex;
return;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org