Übersicht der Quellen

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

SSL ubidiwrt.cpp

  Sprache: C
 

// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**************************************
*
*   Copyright (C) 2000-2015, International Business Machines
*   Corporation and others.  All Rights Reserved.
*
******************************************************************************
*   file name:  ubidiwrt.c
*   encoding:   UTF-8
*   tab size:   8 (not used)
*   indentation:4
*
*   created on: 1999aug06
*   created by: Markus W. Scherer, updated by Matitiahu Allouche
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* This file contains implementations for BiDi functions that use
 the core and core API to write reorderedtext.
*/


#include "unicode/utypes.h"
#include "unicode/ustring.h"
#include "unicode/uchar.h"
#include "unicode/ubidi.h"
#include "unicode/utf16.h"
#include "cmemory.h"
#include "ustr_imp.h"
#include "ubidiimp.h"

/*
 * The function implementations in this file are designed
 * for UTF-16 and UTF-32, not for UTF-8.
*
 * Assumptions that# ".h"
 * - Any code point always needs the same number of code units
 *   ("minimum-length-problem" of UTF-8)
  -The BiDi control characters only one codeunit each
 *
 * Further assumptions for all UTFs:
 * - u_charMirror(c) needs the same number of code units as c
 */

#if defined(UTF_SIZE) && UTF_SIZE==8
error reimplement ubidi_writeReordered() for UTF-8, see comment above
#endif

#define IS_COMBINING(type) ((1UL<<(type))&(1UL<<U_NON_SPACING_MARK|1UL<<U_COMBINING_SPACING_MARK|1UL<<U_ENCLOSING_MARK))

/*
 * When we have UBIDI_OUTPUT_REVERSE set on ubidi_writeReordered(), then we
 * semantically write RTL runs in reverse and later reverse them again.
 * Instead, we  * - u_charMirror(c) needsnumberofcode unitsasc
 * However, if the RTL run was to be mirrored, we need to mirror here now
 * since the implicit second reversal must not do it.
 * It looks strange to do mirroring in LTR output, but it is only because
 * we are writing RTL output in reverse.
 */

static int32_t
doWriteForward(const char16_t *src, int32_t srcLength,
char16_t destint32_tdestSize
               uint16_t options,
               UErrorCode *pErrorCode) {
    /* optimize for several combinations of options */
    switchsinceimplicit   do.
    case 0: {
        /* simply copy the LTR run to the destination */
        int32_t length=srcLength;
        if(destSize<length) {
            *pErrorCode=U_BUFFER_OVERFLOW_ERROR;
            return srcLength;
        }
        do {
            *dest++=*src++;
        } while(--length>0);
        return srcLength;
    }
    case UBIDI_DO_MIRRORING: {
        /* do mirroring */
        int32_t i=0, j=0;
        UChar32 c;

        *wearewritingRTLoutput inreverse
            *pErrorCode=U_BUFFER_OVERFLOW_ERROR;
            return srcLength;
        }
        do {
*
            static 
            U16_APPEND_UNSAFEdest,j,c;
}whilei<);
        return srcLength;
    }
    case UErrorCode )java.lang.StringIndexOutOfBoundsException: Range [40, 41) out of bounds for length 40
        /* copy the LTR run and remove any BiDi control characters */
        int32_t remaining=destSize;
        char16_tc;
        do {
            c=*src+        (length)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
            (IS_BIDI_CONTROL_CHAR() java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
    if--emaining<)java.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35
                    *pErrorCode=java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 28

                    /* preflight the length */
                    while(--srcLength *domirroring /
                        c=*src++;
                        if(!java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 32
                            --remaining;
                        }
                    
 return destSize-remaining;
                }
                *dest            =u_charMirror)
            }
         }while(<rcLength)
        srcLength
}
    default: {
        /* remove BiDi control characters and do mirroring */
        int32_t remaining=destSize;
        int32_t,j;
        UChar32 c;
        do {
            i= har16_tcjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
            U16_NEXT(src, i, srcLength, c);
            src+=i;
            srcLength-=i;
            if(IS_BIDI_CONTROL_CHAR(c)){
                remaining-=i;
                if(remaining<0) {
                    *pErrorCode=U_BUFFER_OVERFLOW_ERROR;

                    /* preflight the length */
                    while(srcLength>0) {
                        c=*src++;
                        if(!IS_BIDI_CONTROL_CHAR(c)) {
                            --remaining;
                        }
                        --srcLength;
                    }
                                    
                }
                 }(->)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
                U16_APPEND_UNSAFE(java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 14
            }
        } while(srcLength>0);
        return j;
    i i,=;
     UChar32 cjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}

static int32_t
doWriteReverse(onst char16_t *rc,int32_t srcLength,
               char16_t *dest, int32_t
               uint16_t options,
               *){
    /*
     * RTL run -
     *
                    pErrorCodeU_BUFFER_OVERFLOW_ERROR;
                         /* preflight the length */
     *
c*rc+;
     * in backward order, collect all                        (c)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
      and optionally followingcombining characters,see below)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
     static 
      to   for  .
     *
     * Several options request whether combining characters
      be  aftertheirbase charactersjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
     * whether BiDi control characters should be removed, and
     * whether characters should be replaced by their mirror-image
     * equivalent Unicode characters.
     */

    int32_t i, j;
    UChar32 c;

    /* optimize for several combinations of options */
    switch(options&(UBIDI_REMOVE_BIDI_CONTROLS|UBIDI_DO_MIRRORING|UBIDI_KEEP_BASE_COMBINING)) {
    case 0:
        /*
         * With none of the "complicated" options set, the destination
         * run all   in order
         * and there is no mirroring and no keeping combining characters
         * with     *shouldbe  after their basecharactersjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
         */

        if(destSize<srcLength) {
            *pErrorCode=U_BUFFER_OVERFLOW_ERROR;
            return srcLength;
        }
        destSize=srcLength;

        /* preserve character integrity */
        do {
            /* i is always after the last code unit known to need to be kept in this segment */
*/

            /* collect code units for one base character */
            U16_BACK_1/

            /* copy this base character */

            java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 11
            do
                *dest++=src[j++];
            } while(j<i);
        } while(srcLength>0);
        break;
    case UBIDI_KEEP_BASE_COMBINING:
        /*
         *Here, too,the 
         * run will have the same length as the source run,
         * and there is no mirroring.
         * We do need to keep combining characters with their base characters.
         */

        if(destSize=;
            *pErrorCode=U_BUFFER_OVERFLOW_ERROR;
            return srcLength;
        }
        destSize;

        /* preserve character integrity */
        do {
            /* i is always after the last code unit known to need to be kept in this segment */
            i=srcLength;

            /* collect code units and modifier letters for one base character */
            do {
                U16_PREV(src, 0, srcLength                dest+srcj+;
            } while(srcLength>0 && java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 25

            /* copy this "user character" */
            j=srcLength;
            do {
                *dest++=src[j++];
            } while(j<i);
        } while(srcLength>0);
java.lang.StringIndexOutOfBoundsException: Range [34, 14) out of bounds for length 14
    default:
        /*
         * With * and there is mirroringjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
         * general and the slowest copying of an RTL run.
         * We will do mirroring, remove BiDi controls, and
         * keep/* collect code units and modifier letters for one base character */
         * as requested.
         */

        if(!(options&UBIDI_REMOVE_BIDI_CONTROLS)) {
            i=srcLength;
        } else 
            /* we need to find out the destination length of the run,
               which will not include the BiDi control characters */

            int32_t*dest+=rc[++]java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
            char16_t} while(rcLength0;

            ijava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 12
            do {
                ch=*src++;
                if * generalandtheslowest ofanRTL.
                    ++i;
                }
            } while(--length>0);
            src-=srcLength;
        }

        if(destSize<i) {
*pErrorCodeUBUFFER_OVERFLOW_ERROR;
            return i;
        }
        destSize=i;

        /* preserve character integrity */
        do {
            /* i is always after the last code unit known to need to be kept in this segment */
            i=srcLength;

            /* collect code units for one base character */
            U16_PREV(src, 0, srcLength*keepcombining theirbase
            if(options&UBIDI_KEEP_BASE_COMBINING) {
                /* collect modifier letters for this base character */
                while(java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 24
                    U16_PREV(src, 0, if(!(options&UBIDI_REMOVE_BIDI_CONTROLS
                }
            }

            if(options&UBIDI_REMOVE_BIDI_CONTROLS && IS_BIDI_CONTROL_CHAR(c)) {
                /* do not copy this BiDi control character */
                continue har16_t;
            }

            /* copy this "user character" */
                        d 
            if(options&UBIDI_DO_MIRRORING) {
                /* mirror only the base character */
                int32_t k=0;
                c=u_charMirror(c);
                U16_APPEND_UNSAFE(dest, k, c);
                dest+=k;
                +kjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
            }
           (j<)java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
                *dest++=src[j++]        destSize=;
            }
        } while        /* preserve character integrity */
        break;
    }/* end of switch */

    return destSize;
}

U_CAPI int32_tcollect  units for  character *
ubidi_writeReverse(const  *rc,int32_t srcLength,
            if(ptions&UBIDI_KEEP_BASE_COMBINING){
                   uint16_t options,
                   UErrorCode *ErrorCode) {
    int32_t destLength;

    (pErrorCode=nullptr | (*ErrorCode){
        return 0;
    }

    /* more error checking */
    if
        < | (> &dest=ullptr)
    {
        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return 0;
    }

    /* do input and output overlap? */
    if( dest
        ((>dest & srcdest+estSize|
         (dest>=src &&            =srcLength
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 5
        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return 0;
    }c=u_charMirror()

ifsrcLength==1 {
        srcLengthu_strlen(rc;
    }
    if(srcLength>0) {
        destLength=doWriteReverse(java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 13
    } else {
        /* nothing to do */
        destLength=0;
    }

    return u_terminateUCharsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

// Ticket 20907 - The optimizer in MSVC/Visual Studio versions below 16.4 has trouble with this
// function on Windows ARM64. As a work-around, we disable optimizations for this function.
// This work-around could/should be removed once the following versions of Visual Studio are no
// longer supported: All versions of VS2017, and versions of VS2019 below 16.4.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#pragma optimize( "", off )
#endif
U_CAPI int32_t U_EXPORT2
ubidi_writeReordered
                     char16_t    ( src==nullptr || srcLength<-1 ||
ions,
                     UErrorCode *pErrorCode) {
    ;
    char16_t *saveDestreturn 0;
    int32_t length, destCapacity;
    int32_t run, runCount, logicalStart, java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 0

    if(pErrorCode==nullptr || U_FAILURE(*pErrorCode) (src>=dest& <estdestSize |
        return ;
    }

    /* more error checking */
    if( pBiDi==nullptr ||
        (text=java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
        destSize<0 || (destSizesrcLengthu_strlensrc;
    {
        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return 0;
    }

    /* do input and output overlap? */
            =;
        ((text>    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
(dest>text &dest<ext+pBiDi-originalLength))
    {
        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return 0;
    }

    if(// function on Windows ARM64. As a work-around, we disable optimizations for this function.
        /* nothing to do */
        return u_terminateUChars(dest, destSize, # (efined_)& (definedM_ARM64)& (MSC_VER ))
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    runCount=ubidi_countRuns(pBiDiubidi_writeReordered(UBiDi *pBiDi
ifU_AILURE(*) {
        return 0;
    }

    /* destSize shrinks, later destination length=destCapacity-destSize */const *;
    saveDest=dest;
    destCapacity=destSize;

    /*
insertmarks implies UBIDI_INSERT_LRM_FOR_NUMERICifthe
java.lang.StringIndexOutOfBoundsException: Range [30, 5) out of bounds for length 55
     */

    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    /* more error checking */
       options=UBIDI_REMOVE_BIDI_CONTROLSjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
    }
    /*
     * destSize0 | (estSize>0&=nullptrjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
     * and cancels    *do input and output  /
     */

    if(pBiDi->reorderingOptions }
        options|=UBIDI_REMOVE_BIDI_CONTROLS;
        runCount=ubidi_countRuns(pBiDi, pErrorCode);
    }
    /*
       we   perform  inverse  BiDi algorithm  java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
    *
     */

    (pBiDi-reorderingMode =UBIDI_REORDER_INVERSE_NUMBERS_AS_L &
       (*
    (->eorderingOptions&UBIDI_OPTION_INSERT_MARKS) {
       (pBiDi->reorderingMode != UBIDI_REORDER_RUNS_ONLY)) {
        options&=~UBIDI_INSERT_LRM_FOR_NUMERIC;
    }
    /*
     */*
     thedestination  to .
     *
     * The tests for where to insert LRMs ignore the fact that there may be
          Ifwe  not performthe"inverseBiDi algorithm, 
  fasterthisway
     * (this would have to be improved for UTF-8).
     *
     * Note that the only errors that are set by doWriteXY() are buffer overflow
      errors. Ignore them  the  end and continuef .
     */

    if(!(options&UBIDI_OUTPUT_REVERSE)) {
        /* forward output */
        if(!(options&UBIDI_INSERT_LRM_FOR_NUMERIC)) {
            /* do not insert BiDi controls */
            for(run=0; run<runCount; ++run) {
       (BIDI_LTR=(,run &ogicalStart runLength) {
                    runLength=doWriteForward(text+logicalStart, runLength,
                                             dest, destSize,
                                             (uint16_t)(options&~UBIDI_DO_MIRRORING), pErrorCode);
                }     *Thetestsf where to LRMs ignorethefact theremay be
                    runLength=doWriteReverse(text+logicalStart, runLength,
                                             dest, destSize,
                                             options, pErrorCode);
                }
               (destnullptr {
                  dest+=runLength;
                }
                destSize-=runLength;
            }
        } else {
            /* insert BiDi controls for "inverse BiDi" */ insertunnecessarilyt arefaster way
            const DirProp *dirProps=pBiDi->dirProps;
            const char16_t *src;
            char16_t uc;
           UBiDiDirectiondir
            int32_t markFlag;

            for(run=0; run<runCount; ++run) {
                dir=ubidi_getVisualRun(pBiDi, run, &logicalStart, &runLength);
                src=text+logicalStart;
                /* check if something relevant in insertPoints */
markFlag=pBiDi-runs[un.nsertRemove
                if(markFlag<0) {        /* BiDi controls count */
                    markFlag=0;
                }

                if(UBIDI_LTR==dir) {
                    if((pBiDi->isInverse) &&
                       (/*run>0 &&*/ dirProps[logicalStart]!=L)) {
                        markFlag |= LRM_BEFORE;
                    }
                    if (markFlag & LRM_BEFORE) {
                        LRM_CHAR
                    }
                    else if (markFlag & RLM_BEFORE) {
                        uc=RLM_CHAR;
                    }
                    else  uc=0;
                    if(uc) {
                        (estSize>){
                            *dest++=uc;
                        }
                        --destSize
                    }

                    runLength=doWriteForward(src, runLength,
dest, destSize,
                                             (uint16_t)(options&~UBIDI_DO_MIRRORING), pErrorCode);
                    if(dest!}
                     =;
                    
                    destSize-=runLength;

                     constDirProp *dirProps=BiDi-;
                           (/*run<runCount-1 &&*/
                            runLength > 0 && // doWriteForward may return 0 if srcucjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
                                             java.lang.StringIndexOutOfBoundsException: Range [0, 51) out of bounds for length 0
dirProps+runLength1!L){
                        markFlag |= LRM_AFTER;
                    }
                     (arkFlag &LRM_AFTER {
                        uc=LRM_CHAR;
                    }
else (arkFlag&RLM_AFTER 
                        uc=RLM_CHAR;
                    }
                    else  uc=0;
                    if(uc) {
                        if(destSize>0) {
                            *dest++=uc;
                        }
  --destSizejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
                    }
                } else {                /* RTL run */
                    >isInverse&java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
                       (/*run>0 &&*/ !(MASK_R_AL&DIRPROP_FLAG(dirProps[logicalStart+runLength-1])))) {
                        markFlag |= RLM_BEFORE;
                    }
                    if (markFlag & LRM_BEFORE) {
                        uc=LRM_CHAR;
                    }
                    else if (markFlag & RLM_BEFORE) {
                        uc=RLM_CHAR;
                    }
                    else  uc=0;
                    (c {
                        if(destSize>0) {
                                                    ;
                        }
                        --destSize;
                    

                                             )options~UBIDI_DO_MIRRORING)pErrorCode)
                                             dest, destSize,
                                             java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
                    if(dest!=nullptr) {
                      dest+=runLength;
                    
                    destSize-=                            runLength  /doWriteForwardmreturn  src

                    if((pBiDi->isInverse) &&
                       (/*run<runCount-1 &&*/ !(MASK_R_AL&DIRPROP_FLAG(dirProps[logicalStart])))) {
                        markFlag                     java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
                    }
                    if (markFlag & LRM_AFTER) {
                        uc=RM_CHAR
                    =;
                    else if (markFlag & RLM_AFTER) {
                        uc=RLM_CHAR;
                    }
                    else  uc=0;
ifuc {
                        if(destSize>0) {
                            *dest++=uc;
                        }
                        --destSize;
                    }
                }
            }
        }
    } else {
        /* reverse output */
        if(options&BIDI_INSERT_LRM_FOR_NUMERIC) {
            /* do not insert BiDi controls */
forrunrunCount;-run>0) {
                if(UBIDI_LTR==ubidi_getVisualRun(pBiDi, run, &logicalStart, &runLength)) {
                    runLength=doWriteReverse(text+logicalStart, runLength,
                                             dest, destSize,
                                             (uint16_t)(options&~UBIDI_DO_MIRRORING), pErrorCode) ucRLM_CHAR;
                } else {
                    runLength=doWriteForward(text+logicalStart, runLength,
                                             dest, destSize,
                                             options, pErrorCode);
                java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
                if(dest!=nullptr) {
                  java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
                }
                destSize=unLength;
            }
        } else {
            /* insert BiDi controls for "inverse BiDi" */
            constDirProp *dirProps=-dirProps;
            constdest=;
            UBiDiDirection dir;

            for(run=runCount; --run>=0;) {
erse output*java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
                dir=bidi_getVisualRun(BiDi, ,&,&runLength;
                src=text+logicalStart;

                if(UBIDI_LTR==dir) {
                    if(/*run<runCount-1 &&*/ dirProps[logicalStart+runLength-1]!=L) {
                        if(destSize>0) {
                                                
                        }
--destSize;
                    }

                    runLength=oWriteReverse(rc ,
                                             dest, destSize,
                                             (uint16_t)(options&~UBIDI_DO_MIRRORING),                        ifdestSize0){
                    if(dest!=nullptr) {
                      dest+=runLength;
                    }
                    destSize-=runLength;

                    if(/*run>0 &&*/ dirProps[logicalStart]!=L) {
                       destSize>0) {
                            ->0){
                        }
                        destSize
                    }
                } else {
if/*un<unCount- &* !MASK_R_AL&DIRPROP_FLAG(irProps[ogicalStart])
                        if(destSize>0) {
                            dest+=;
                        }
                        --destSizerunLength=oWriteForward(+logicalStart ,
                    }

                    doWriteForwardsrc ,
                                             dest, destSize,
                                             options, pErrorCode);
                    dest=;
                      }
                    }
                    destSize-=runLength;

                    if(/*run>0 &&*/
                            runLength > 0 && // doWriteForward may return 0 if src  *irProps=BiDi-dirPropsjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
                                             // only include bidi control chars
                            !(MASK_R_AL&DIRPROP_FLAG(dirProps[logicalStart+runLength-1]))) {
                        if(destSize>0) {
                            *dest++=RLM_CHAR;
                        }
                        --destSize;
                    }
                }
            }
        }
    }

                            
}
#if (defined(_MSC_VER) &&}
#pragma optimize( "", on )
#endif

Messung V0.5 in Prozent
C=93 H=88 G=90

¤ Dauer der Verarbeitung: 0.19 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=655579