Changeset 0ffbed9 in mainline for uspace/lib/posix/strings.c


Ignore:
Timestamp:
2011-06-19T17:49:29Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5974661
Parents:
f48b637 (diff), 32fb6944 (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.

File:
1 edited

Legend:

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

    rf48b637 r0ffbed9  
    11/*
    22 * Copyright (c) 2011 Jiri Zarevucky
     3 * Copyright (c) 2011 Petr Koupy
    34 * All rights reserved.
    45 *
     
    3334 */
    3435
    35 #define POSIX_INTERNAL
     36#define LIBPOSIX_INTERNAL
    3637
    37 #include "common.h"
     38#include "internal/common.h"
    3839#include "strings.h"
    3940#include "string.h"
     41#include "ctype.h"
    4042
     43/**
     44 *
     45 * @param i
     46 * @return
     47 */
    4148int posix_ffs(int i)
    4249{
     
    4552}
    4653
     54/**
     55 *
     56 * @param s1
     57 * @param s2
     58 * @return
     59 */
    4760int posix_strcasecmp(const char *s1, const char *s2)
    4861{
    49         // TODO
    50         not_implemented();
     62        return posix_strncasecmp(s1, s2, STR_NO_LIMIT);
    5163}
    5264
     65/**
     66 *
     67 * @param s1
     68 * @param s2
     69 * @param n
     70 * @return
     71 */
    5372int posix_strncasecmp(const char *s1, const char *s2, size_t n)
    5473{
    55         // TODO
    56         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;
    5786}
    5887
     88/**
     89 *
     90 * @param mem1
     91 * @param mem2
     92 * @param n
     93 * @return
     94 */
    5995int posix_bcmp(const void *mem1, const void *mem2, size_t n)
    6096{
     
    6399}
    64100
     101/**
     102 *
     103 * @param dest
     104 * @param src
     105 * @param n
     106 */
    65107void posix_bcopy(const void *dest, void *src, size_t n)
    66108{
     
    69111}
    70112
     113/**
     114 *
     115 * @param mem
     116 * @param n
     117 */
    71118void posix_bzero(void *mem, size_t n)
    72119{
     
    75122}
    76123
     124/**
     125 *
     126 * @param s
     127 * @param c
     128 * @return
     129 */
    77130char *posix_index(const char *s, int c)
    78131{
     
    80133}
    81134
     135/**
     136 *
     137 * @param s
     138 * @param c
     139 * @return
     140 */
    82141char *posix_rindex(const char *s, int c)
    83142{
     
    87146/** @}
    88147 */
    89 
Note: See TracChangeset for help on using the changeset viewer.