FreeBSD/sys/contrib/dev/acpica/compiler/dtio.c
/******************************************************************************
 *
 * FUNCTION:    DtTrim
 *
 * PARAMETERS:  String              - Current source code line to trim
 *
 * RETURN:      Trimmed line. Must be freed by caller.
 *
 * DESCRIPTION: Trim left and right spaces
 *
 *****************************************************************************/
DtTrim
PARAMETERS:  String              - Current source code line to trim

Trimmed line. Must be freed by caller.

Trim left and right spaces
DtTrim PARAMETERS : String - Current source code line to trim Trimmed line . Must be freed by caller . Trim left and right spaces
static char *
DtTrim (
    char                    *String)
{
    char                    *Start;
    char                    *End;
    char                    *ReturnString;
    ACPI_SIZE               Length;
    if (!strcmp (String, " "))
    {
        ReturnString = UtStringCacheCalloc (1);
        return (ReturnString);
    }
    Start = String;
    End = String + strlen (String) - 1;
    while ((Start <= End) && ((*Start == ' ') || (*Start == '\t')))
    {
        Start++;
    }
    while (End >= Start)
    {
        if (*End == '\r' || *End == '\n')
        {
            End--;
            continue;
        }
        if (*End != ' ')
        {
            break;
        }
        End--;
    }
    if (*Start == '\"')
    {
        Start++;
    }
    if (*End == '\"')
    {
        End--;
    }
    Length = ACPI_PTR_DIFF (End, Start) + 1;
    ReturnString = UtStringCacheCalloc (Length + 1);
    if (strlen (Start))
    {
        strncpy (ReturnString, Start, Length);
    }
    ReturnString[Length] = 0;
    return (ReturnString);
}
static char * DtTrim ( char * String ) { char * Start ; char * End ; char * ReturnString ; ACPI_SIZE Length ; if ( ! strcmp ( String , " " ) ) { ReturnString = UtStringCacheCalloc ( 1 ) ; return ( ReturnString ) ; } Start = String ; End = String + strlen ( String ) - 1 ; while ( ( Start <= End ) && ( ( * Start == ' ' ) || ( * Start == ' \t ' ) ) ) { Start ++ ; } while ( End >= Start ) { if ( * End == ' \r ' || * End == ' \n ' ) { End -- ; continue ; } if ( * End != ' ' ) { break ; } End -- ; } if ( * Start == ' \" ' ) { Start ++ ; } if ( * End == ' \" ' ) { End -- ; } Length = ACPI_PTR_DIFF ( End , Start ) + 1 ; ReturnString = UtStringCacheCalloc ( Length + 1 ) ; if ( strlen ( Start ) ) { strncpy ( ReturnString , Start , Length ) ; } ReturnString [ Length ] = 0 ; return ( ReturnString ) ; }
FUNCTION:    DtTrim
 PARAMETERS:  String              - Current source code line to trim
FUNCTION : DtTrim PARAMETERS : String - Current source code line to trim
/* Skip lines that start with a space */ /* Setup pointers to start and end of input string */ /* Find first non-whitespace character */ /* Find last non-space character */ /* Remove any quotes around the string */ /* Create the trimmed return string */