added sstrlower / sstrupper variants

Thu, 15 Oct 2015 16:52:53 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 15 Oct 2015 16:52:53 +0200
changeset 210
6bdb04d87236
parent 209
4f02199d8aae
child 211
07a284486fa1

added sstrlower / sstrupper variants

ucx/string.c file | annotate | diff | comparison | revisions
ucx/string.h file | annotate | diff | comparison | revisions
     1.1 --- a/ucx/string.c	Thu Oct 15 14:59:25 2015 +0200
     1.2 +++ b/ucx/string.c	Thu Oct 15 16:52:53 2015 +0200
     1.3 @@ -339,3 +339,35 @@
     1.4              suffix.ptr, suffix.length) == 0;
     1.5      }
     1.6  }
     1.7 +
     1.8 +sstr_t sstrlower(sstr_t string) {
     1.9 +    sstr_t ret = sstrdup(string);
    1.10 +    for (size_t i = 0; i < ret.length ; i++) {
    1.11 +        ret.ptr[i] = tolower(ret.ptr[i]);
    1.12 +    }
    1.13 +    return ret;
    1.14 +}
    1.15 +
    1.16 +sstr_t sstrlower_a(UcxAllocator *allocator, sstr_t string) {
    1.17 +    sstr_t ret = sstrdup_a(allocator, string);
    1.18 +    for (size_t i = 0; i < ret.length ; i++) {
    1.19 +        ret.ptr[i] = tolower(ret.ptr[i]);
    1.20 +    }
    1.21 +    return ret;
    1.22 +}
    1.23 +
    1.24 +sstr_t sstrupper(sstr_t string) {
    1.25 +    sstr_t ret = sstrdup(string);
    1.26 +    for (size_t i = 0; i < ret.length ; i++) {
    1.27 +        ret.ptr[i] = toupper(ret.ptr[i]);
    1.28 +    }
    1.29 +    return ret;
    1.30 +}
    1.31 +
    1.32 +sstr_t sstrupper_a(UcxAllocator *allocator, sstr_t string) {
    1.33 +    sstr_t ret = sstrdup_a(allocator, string);
    1.34 +    for (size_t i = 0; i < ret.length ; i++) {
    1.35 +        ret.ptr[i] = toupper(ret.ptr[i]);
    1.36 +    }
    1.37 +    return ret;
    1.38 +}
     2.1 --- a/ucx/string.h	Thu Oct 15 14:59:25 2015 +0200
     2.2 +++ b/ucx/string.h	Thu Oct 15 16:52:53 2015 +0200
     2.3 @@ -383,6 +383,56 @@
     2.4   */
     2.5  int sstrsuffix(sstr_t string, sstr_t suffix);
     2.6  
     2.7 +/**
     2.8 + * Returns a lower case version of a string.
     2.9 + * 
    2.10 + * This function creates a duplicate of the input string, first. See the
    2.11 + * documentation of sstrdup() for the implications.
    2.12 + * 
    2.13 + * @param string the input string
    2.14 + * @return the resulting lower case string
    2.15 + * @see sstrdup()
    2.16 + */
    2.17 +sstr_t sstrlower(sstr_t string);
    2.18 +
    2.19 +/**
    2.20 + * Returns a lower case version of a string.
    2.21 + * 
    2.22 + * This function creates a duplicate of the input string, first. See the
    2.23 + * documentation of sstrdup_a() for the implications.
    2.24 + * 
    2.25 + * @param allocator the allocator used for duplicating the string
    2.26 + * @param string the input string
    2.27 + * @return the resulting lower case string
    2.28 + * @see sstrdup_a()
    2.29 + */
    2.30 +sstr_t sstrlower_a(UcxAllocator *allocator, sstr_t string);
    2.31 +
    2.32 +/**
    2.33 + * Returns a upper case version of a string.
    2.34 + * 
    2.35 + * This function creates a duplicate of the input string, first. See the
    2.36 + * documentation of sstrdup() for the implications.
    2.37 + * 
    2.38 + * @param string the input string
    2.39 + * @return the resulting upper case string
    2.40 + * @see sstrdup()
    2.41 + */
    2.42 +sstr_t sstrupper(sstr_t string);
    2.43 +
    2.44 +/**
    2.45 + * Returns a upper case version of a string.
    2.46 + * 
    2.47 + * This function creates a duplicate of the input string, first. See the
    2.48 + * documentation of sstrdup_a() for the implications.
    2.49 + * 
    2.50 + * @param allocator the allocator used for duplicating the string
    2.51 + * @param string the input string
    2.52 + * @return the resulting upper case string
    2.53 + * @see sstrdup_a()
    2.54 + */
    2.55 +sstr_t sstrupper_a(UcxAllocator *allocator, sstr_t string);
    2.56 +
    2.57  #ifdef	__cplusplus
    2.58  }
    2.59  #endif

mercurial