From e3d974424088b7375ee34f0c232cf4025a279c29 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Fri, 8 Oct 1999 18:54:22 +0000 Subject: [PATCH] use U_INDEX_OUTOFBOUNDS_ERROR where appropriate X-SVN-Rev: 24 --- icu4c/source/common/ubidiln.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/icu4c/source/common/ubidiln.c b/icu4c/source/common/ubidiln.c index 56fc000ce12..d257a77d1e8 100644 --- a/icu4c/source/common/ubidiln.c +++ b/icu4c/source/common/ubidiln.c @@ -110,12 +110,12 @@ ubidi_setLine(const UBiDi *pParaBiDi, /* check the argument values */ if(pErrorCode==NULL || FAILURE(*pErrorCode)) { return; - } else if(pParaBiDi==NULL || - start<0 || start>limit || limit>pParaBiDi->length || - pLineBiDi==NULL - ) { + } else if(pParaBiDi==NULL || pLineBiDi==NULL) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return; + } else if(start<0 || start>limit || limit>pParaBiDi->length) { + *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR; + return; } /* set the values in pLineBiDi from its pParaBiDi parent */ @@ -826,9 +826,12 @@ CAPI UTextOffset U_EXPORT2 ubidi_getVisualIndex(UBiDi *pBiDi, UTextOffset logicalIndex, UErrorCode *pErrorCode) { if(pErrorCode==NULL || FAILURE(*pErrorCode)) { return 0; - } else if(pBiDi==NULL || logicalIndex<0 || pBiDi->length<=logicalIndex) { + } else if(pBiDi==NULL) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; + } else if(logicalIndex<0 || pBiDi->length<=logicalIndex) { + *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR; + return 0; } else { /* we can do the trivial cases without the runs array */ switch(pBiDi->direction) { @@ -868,9 +871,12 @@ CAPI UTextOffset U_EXPORT2 ubidi_getLogicalIndex(UBiDi *pBiDi, UTextOffset visualIndex, UErrorCode *pErrorCode) { if(pErrorCode==NULL || FAILURE(*pErrorCode)) { return 0; - } else if(pBiDi==NULL || visualIndex<0 || pBiDi->length<=visualIndex) { + } else if(pBiDi==NULL) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; + } else if(visualIndex<0 || pBiDi->length<=visualIndex) { + *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR; + return 0; } else { /* we can do the trivial cases without the runs array */ switch(pBiDi->direction) {