third_party/inchi/INCHI_BASE/src/ichiread.c
const char* ParseSegmentReadDelimitedNumbers( const char *str,
                                              const char *pEnd,
                                              INT_ARRAY *numlist,
                                              char c_delim,
                                              char c_stop,
                                              int *ret )
{
    const char *p, *pStart;
    int num, curr_atom = 0;

    *ret = 1;

    if (!str)
    {
        *ret = -1;
        return NULL;
    }

    pStart = (char *) ( str + 1 );
    p = pStart;
    while (*pStart)
    {
        for (p = pStart, curr_atom = 0; p < pEnd && *p != c_stop; curr_atom++)
        {
            num = (AT_NUMB) inchi_strtol(  p, &p, 10 );
#if ( CHECK_STRTOL_ATNUMB==1 )
            if (num>MAX_ATOMS || num<0)
            {
                *ret = RI_ERR_SYNTAX;
                return p;
            }
#endif
            {
                if (0 != IntArray_Append( numlist, num ))
                {
                    *ret = RI_ERR_SYNTAX;
                    return p;
                }
            }
            if (*p == c_delim)
            {
                p++;
            }
            else if (*p == c_stop)
            {
                return p;
            }
            else
            {
                *ret = -1; return NULL;
            }
        }
        if (*p == c_stop)
        {
            return p;
        }
    }

    return p;
}
/****************************************************************************
Read sequence of integer numbers from str into growing int array numlist
until NULL, EOL or  'c_stop' symbol occurred, whichever is the first.
Numbers are assumed to be delimited with commas.

NB: on success, returns 1.
****************************************************************************/
Read sequence of integer numbers from str into growing int array numlist
until NULL, EOL or  'c_stop' symbol occurred, whichever is the first.
Numbers are assumed to be delimited with commas.

on success, returns 1.
Read sequence of integer numbers from str into growing int array numlist until NULL EOL or ' c_stop ' symbol occurred whichever is the first . Numbers are assumed to be delimited with commas . on success returns 1 .
const char* ParseSegmentReadDelimitedNumbers( const char *str,
                                              const char *pEnd,
                                              INT_ARRAY *numlist,
                                              char c_delim,
                                              char c_stop,
                                              int *ret )
{
    const char *p, *pStart;
    int num, curr_atom = 0;
    *ret = 1;
    if (!str)
    {
        *ret = -1;
        return NULL;
    }
    pStart = (char *) ( str + 1 );
    p = pStart;
    while (*pStart)
    {
        for (p = pStart, curr_atom = 0; p < pEnd && *p != c_stop; curr_atom++)
        {
            num = (AT_NUMB) inchi_strtol(  p, &p, 10 );
#if ( CHECK_STRTOL_ATNUMB==1 )
            if (num>MAX_ATOMS || num<0)
            {
                *ret = RI_ERR_SYNTAX;
                return p;
            }
#endif
            {
                if (0 != IntArray_Append( numlist, num ))
                {
                    *ret = RI_ERR_SYNTAX;
                    return p;
                }
            }
            if (*p == c_delim)
            {
                p++;
            }
            else if (*p == c_stop)
            {
                return p;
            }
            else
            {
                *ret = -1; return NULL;
            }
        }
        if (*p == c_stop)
        {
            return p;
        }
    }
    return p;
}
const char * ParseSegmentReadDelimitedNumbers ( const char * str , const char * pEnd , INT_ARRAY * numlist , char c_delim , char c_stop , int * ret ) { const char * p , * pStart ; int num , curr_atom = 0 ; * ret = 1 ; if ( ! str ) { * ret = -1 ; return NULL ; } pStart = ( char * ) ( str + 1 ) ; p = pStart ; while ( * pStart ) { for ( p = pStart , curr_atom = 0 ; p < pEnd && * p != c_stop ; curr_atom ++ ) { num = ( AT_NUMB ) inchi_strtol ( p , & p , 10 ) ; #if ( CHECK_STRTOL_ATNUMB == 1 ) if ( num > MAX_ATOMS || num < 0 ) { * ret = RI_ERR_SYNTAX ; return p ; } #endif { if ( 0 != IntArray_Append ( numlist , num ) ) { * ret = RI_ERR_SYNTAX ; return p ; } } if ( * p == c_delim ) { p ++ ; } else if ( * p == c_stop ) { return p ; } else { * ret = -1 ; return NULL ; } } if ( * p == c_stop ) { return p ; } } return p ; }
Read sequence of integer numbers from str into growing int array numlist
until NULL, EOL or  'c_stop' symbol occurred, whichever is the first.
Read sequence of integer numbers from str into growing int array numlist until NULL EOL or ' c_stop ' symbol occurred whichever is the first .