Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 086cab0 in mainline


Ignore:
Timestamp:
2019-12-11T15:27:21Z (12 months ago)
Author:
Martin Decky <martin@…>
Branches:
master
Children:
5723313b
Parents:
fe7bcf1
Message:

function for retrieving string suffix

Location:
uspace/lib/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/str.c

    rfe7bcf1 r086cab0  
    801801
    802802        return false;
     803}
     804
     805/** Get a string suffix.
     806 *
     807 * Return a string suffix defined by the prefix length.
     808 *
     809 * @param s             The string to get the suffix from.
     810 * @param prefix_length Number of prefix characters to ignore.
     811 *
     812 * @return String suffix.
     813 *
     814 */
     815const char *str_suffix(const char *s, size_t prefix_length)
     816{
     817        size_t off = 0;
     818        size_t i = 0;
     819
     820        while (true) {
     821                str_decode(s, &off, STR_NO_LIMIT);
     822                i++;
     823
     824                if (i >= prefix_length)
     825                        break;
     826        }
     827
     828        return s + off;
    803829}
    804830
  • uspace/lib/c/include/str.h

    rfe7bcf1 r086cab0  
    9898
    9999extern bool str_test_prefix(const char *s, const char *p);
     100extern const char *str_suffix(const char *s, size_t prefix_length);
    100101
    101102extern void str_cpy(char *dest, size_t size, const char *src);
Note: See TracChangeset for help on using the changeset viewer.