sys/contrib/dev/acpica/source/compiler/dtfield.c
/******************************************************************************
 *
 * FUNCTION:    DtNormalizeBuffer
 *
 * PARAMETERS:  Buffer              - Input buffer
 *              Count               - Output the count of hex numbers in
 *                                    the Buffer
 *
 * RETURN:      The normalized buffer, must be freed by caller
 *
 * DESCRIPTION: [1A,2B,3C,4D] or 1A, 2B, 3C, 4D will be normalized
 *              to 1A 2B 3C 4D
 *
 *****************************************************************************/
DtNormalizeBuffer
PARAMETERS:  Buffer              - Input buffer
Count               - Output the count of hex numbers in
the Buffer

The normalized buffer, must be freed by caller


DtNormalizeBuffer PARAMETERS : Buffer - Input buffer Count - Output the count of hex numbers in the Buffer The normalized buffer must be freed by caller
static char *
DtNormalizeBuffer (
    char                    *Buffer,
    UINT32                  *Count)
{
    char                    *NewBuffer;
    char                    *TmpBuffer;
    UINT32                  BufferCount = 0;
    BOOLEAN                 Separator = TRUE;
    char                    c;
    NewBuffer = UtLocalCalloc (strlen (Buffer) + 1);
    TmpBuffer = NewBuffer;
    while ((c = *Buffer++))
    {
        switch (c)
        {
        case '[':
        case ']':
        case ' ':
        case ',':
            Separator = TRUE;
            break;
        default:
            if (Separator)
            {
                if (NewBuffer[0])
                {
                    *TmpBuffer++ = ' ';
                    BufferCount++;
                }
                Separator = FALSE;
            }
            *TmpBuffer++ = c;
            break;
        }
    }
    *Count = BufferCount + 1;
    return (NewBuffer);
}
static char * DtNormalizeBuffer ( char * Buffer , UINT32 * Count ) { char * NewBuffer ; char * TmpBuffer ; UINT32 BufferCount = 0 ; BOOLEAN Separator = TRUE ; char c ; NewBuffer = UtLocalCalloc ( strlen ( Buffer ) + 1 ) ; TmpBuffer = NewBuffer ; while ( ( c = * Buffer ++ ) ) { switch ( c ) { case ' ' : case ' ' : case ' ' : case ' ' : Separator = TRUE ; break ; default : if ( Separator ) { if ( NewBuffer [ 0 ] ) { * TmpBuffer ++ = ' ' ; BufferCount ++ ; } Separator = FALSE ; } * TmpBuffer ++ = c ; break ; } } * Count = BufferCount + 1 ; return ( NewBuffer ) ; }
FUNCTION:    DtNormalizeBuffer
 PARAMETERS:  Buffer              - Input buffer
              Count               - Output the count of hex numbers in
                                    the Buffer
FUNCTION : DtNormalizeBuffer PARAMETERS : Buffer - Input buffer Count - Output the count of hex numbers in the Buffer
/* Valid separators */ /* Insert blank as the standard separator */