Changeset 5c5117c in mainline for uspace/lib/posix/strings.c


Ignore:
Timestamp:
2011-06-20T02:42:01Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
79506d6
Parents:
f3a605be (diff), b4d6252 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/strings.c

    rf3a605be r5c5117c  
    3636#define LIBPOSIX_INTERNAL
    3737
    38 #include "common.h"
     38#include "internal/common.h"
    3939#include "strings.h"
    4040#include "string.h"
     41#include "ctype.h"
    4142
    4243/**
     
    5960int posix_strcasecmp(const char *s1, const char *s2)
    6061{
    61         // TODO
    62         not_implemented();
     62        return posix_strncasecmp(s1, s2, STR_NO_LIMIT);
    6363}
    6464
     
    7272int posix_strncasecmp(const char *s1, const char *s2, size_t n)
    7373{
    74         // TODO
    75         not_implemented();
     74        for (size_t i = 0; i < n; ++i) {
     75                int cmp = tolower(s1[i]) - tolower(s2[i]);
     76                if (cmp != 0) {
     77                        return cmp;
     78                }
     79               
     80                if (s1[i] == 0) {
     81                        return 0;
     82                }
     83        }
     84       
     85        return 0;
    7686}
    7787
Note: See TracChangeset for help on using the changeset viewer.