Changeset 2980


Ignore:
Timestamp:
Mar 30, 2012, 2:42:07 AM (7 years ago)
Author:
bruno
Message:

r4603@localhost: bruno | 2012-03-29 15:40:58 +0200

  • Rewrite strip_space in a much simpler version without valgrind warnings
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/common/libmondo-string.c

    r2399 r2980  
    695695 */
    696696void strip_spaces(char *in_out)
     697{
     698    /*@ buffers ***************************************************** */
     699    char *tmp = NULL;
     700
     701    /*@ int ******************************************************** */
     702    int i;
     703
     704    /*@ end vars *************************************************** */
     705
     706    assert(in_out != NULL);
     707    malloc_string(tmp);
     708    for (i = 0; in_out[i] <= ' ' && i < (int) strlen(in_out) -1; i++);
     709    strcpy(tmp, in_out + i);
     710    for (i = (int) strlen(tmp) -1; i >= 0 && tmp[i] <= ' '; i--);
     711    i++;
     712    tmp[i] = '\0';
     713
     714    // Now tmp contains the stripped string
     715    strcpy(in_out,tmp);
     716    paranoid_free(tmp);
     717}
     718
     719/**
     720 * Remove all characters whose ASCII value is less than or equal to 32
     721 * (spaces and control characters) from both sides of @p in_out.
     722 * @param in_out The string to strip spaces/control characters from (modified).
     723 */
     724void strip_spaces2(char *in_out)
    697725{
    698726    /*@ buffers ***************************************************** */
Note: See TracChangeset for help on using the changeset viewer.