Changeset 051bc69a in mainline for uspace/app/sbi/src/os/helenos.c


Ignore:
Timestamp:
2010-05-08T08:10:44Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
640ffe6, c5cb943d
Parents:
25a76ab8
Message:

Update SBI to rev. 244.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/os/helenos.c

    r25a76ab8 r051bc69a  
    2929/** @file HelenOS-specific code. */
    3030
     31#include <assert.h>
    3132#include <errno.h>
    3233#include <stdio.h>
     
    7576}
    7677
     78/** Return slice (substring) of a string.
     79 *
     80 * Copies the specified range of characters from @a str and returns it
     81 * as a newly allocated string. @a start + @a length must be less than
     82 * or equal to the length of @a str.
     83 *
     84 * @param str           String
     85 * @param start         Index of first character (starting from zero).
     86 * @param length        Number of characters to copy.
     87 *
     88 * @return              Newly allocated string holding the slice.
     89 */
     90char *os_str_aslice(const char *str, size_t start, size_t length)
     91{
     92        char *slice;
     93        size_t offset;
     94        size_t i;
     95        size_t size;
     96        wchar_t c;
     97
     98        assert(start + length <= str_length(str));
     99
     100        offset = 0;
     101        for (i = 0; i < start; ++i) {
     102                c = str_decode(str, &offset, STR_NO_LIMIT);
     103                assert(c != '\0');
     104                assert(c != U_SPECIAL);
     105                (void) c;
     106        }
     107
     108        size = str_lsize(str, length);
     109        slice = str_ndup(str + offset, size);
     110
     111        return slice;
     112}
     113
    77114/** Compare two strings.
    78115 *
Note: See TracChangeset for help on using the changeset viewer.