Ignore:
Timestamp:
Feb 15, 2007, 12:27:39 AM (13 years ago)
Author:
Bruno Cornec
Message:

strip_spaces => mr_strip_spaces in mr_str.c and corrected at the same time :-)

File:
1 edited

Legend:

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

    r1148 r1168  
    99#include "my-stuff.h"
    1010#include "mr_mem.h"
     11#include "mr_str.h"
     12
    1113#include "mondostructures.h"
    1214#include "libmondo-string.h"
     
    98100    for (p = in_out; *p == ' '; p++);
    99101    strcpy(scratch, p);
    100     strip_spaces (scratch);
     102    mr_strip_spaces (scratch);
    101103    len = (int) strlen(scratch);
    102104    mid = width / 2;
     
    737739
    738740
    739 
    740 /**
    741  * Remove all characters whose ASCII value is less than or equal to 32
    742  * (spaces and control characters) from both sides of @p in_out.
    743  * @param in_out The string to strip spaces/control characters from (modified).
    744  */
    745 void strip_spaces(char *in_out)
    746 {
    747     /*@ buffers ***************************************************** */
    748     char *tmp = NULL;
    749 
    750     /*@ pointers **************************************************** */
    751     char *p;
    752 
    753     /*@ int ******************************************************** */
    754     int i;
    755     int j;
    756     int original_incoming_length;
    757 
    758     /*@ end vars *************************************************** */
    759 
    760     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
    772     malloc_string(tmp);
    773     strcpy(tmp, in_out + i);
    774     for (i = (int) strlen(tmp); i > 0 && tmp[i - 1] <= 32; i--);
    775     tmp[i] = '\0';
    776     for (i = 0; i < original_incoming_length && MAX_STR_LEN; i++) {
    777         in_out[i] = ' ';
    778     }
    779     in_out[i] = '\0';
    780     i = 0;
    781     p = tmp;
    782     while (*p != '\0') {
    783         in_out[i] = *p;
    784         p++;
    785         in_out[i + 1] = '\0';
    786         if (in_out[i] < 32 && i > 0) {
    787             if (in_out[i] == 8) {
    788                 i--;
    789             } else if (in_out[i] == 9) {
    790                 in_out[i++] = ' ';
    791             } else if (in_out[i] == '\r')   // added 1st October 2003 -- FIXME
    792             {
    793                 strcpy(tmp, in_out + i);
    794                 strcpy(in_out, tmp);
    795                 i = -1;
    796                 continue;
    797             } else if (in_out[i] == '\t') {
    798                 for (i++; i % 5; i++);
    799             } else if (in_out[i] >= 10 && in_out[i] <= 13) {
    800                 break;
    801             } else {
    802                 i--;
    803             }
    804         } else {
    805             i++;
    806         }
    807     }
    808     in_out[i] = '\0';
    809     mr_free(tmp);
    810     */
    811 }
    812 
    813 
    814741/**
    815742 * If there are double quotes "" around @p incoming then remove them.
Note: See TracChangeset for help on using the changeset viewer.