Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8eb7a88 authored by Lajos Molnar's avatar Lajos Molnar Committed by Android (Google) Code Review
Browse files

Merge "AString: add startsWithIgnoreCase and endsWithIgnoreCase"

parents 0832b2d7 3c1da722
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ struct AString {

    bool startsWith(const char *prefix) const;
    bool endsWith(const char *suffix) const;
    bool startsWithIgnoreCase(const char *prefix) const;
    bool endsWithIgnoreCase(const char *suffix) const;

    void tolower();

+14 −0
Original line number Diff line number Diff line
@@ -328,6 +328,20 @@ bool AString::endsWith(const char *suffix) const {
    return !strcmp(mData + mSize - suffixLen, suffix);
}

bool AString::startsWithIgnoreCase(const char *prefix) const {
    return !strncasecmp(mData, prefix, strlen(prefix));
}

bool AString::endsWithIgnoreCase(const char *suffix) const {
    size_t suffixLen = strlen(suffix);

    if (mSize < suffixLen) {
        return false;
    }

    return !strcasecmp(mData + mSize - suffixLen, suffix);
}

AString StringPrintf(const char *format, ...) {
    va_list ap;
    va_start(ap, format);