Ignore:
Timestamp:
Feb 12, 2007, 11:41:51 AM (17 years ago)
Author:
Bruno Cornec
Message:

rewrite of strip_spaces (way shorter, maybe less complete, but valgrind clean)

File:
1 edited

Legend:

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

    r1140 r1148  
    746746{
    747747    /*@ buffers ***************************************************** */
    748     char *tmp;
     748    char *tmp = NULL;
    749749
    750750    /*@ pointers **************************************************** */
     
    753753    /*@ int ******************************************************** */
    754754    int i;
     755    int j;
    755756    int original_incoming_length;
    756757
     
    758759
    759760    assert(in_out != NULL);
     761    original_incoming_length = (int)strlen(in_out);
     762
     763    for (i = 0; (in_out[i] <= ' ' || in_out[i] == '\t' || in_out[i] == '\r')
     764                    && i < original_incoming_length ; i++);
     765    for (j = 0; in_out[i] > ' ' && in_out[i] != '\t' && in_out[i] != '\r'
     766                    && i < original_incoming_length ; i++, j++) {
     767        in_out[j] = in_out[i];
     768    }
     769    in_out[j] = '\0';
     770
     771    /* BERLIOS: Old code
    760772    malloc_string(tmp);
    761     original_incoming_length = (int) strlen(in_out);
    762     for (i = 0; in_out[i] <= ' ' && i < (int) strlen(in_out); i++);
    763773    strcpy(tmp, in_out + i);
    764774    for (i = (int) strlen(tmp); i > 0 && tmp[i - 1] <= 32; i--);
     
    798808    in_out[i] = '\0';
    799809    mr_free(tmp);
     810    */
    800811}
    801812
Note: See TracChangeset for help on using the changeset viewer.