Ignore:
Timestamp:
Sep 25, 2006, 1:07:16 PM (15 years ago)
Author:
andree
Message:

Add new header mr_string.h for mr_string.c. Use mr_strtok() from
mr_string.c and delete from libmondo-string.c. Add mr_string.c and
mr_string.h to Makefile.am. (Follow-up to r828.)

File:
1 edited

Legend:

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

    r668 r831  
    11561156    return (type_of_backup);
    11571157}
    1158 
    1159 
    1160 /* New functions safe from a memory manageemnt point of view */
    1161 /* Developped by Andree Leidenfrost */
    1162 
    1163 char *mr_strtok(char *instr, const char *delims, int *lastpos) {
    1164 
    1165 char *token = NULL;
    1166 char *strptr = NULL;
    1167 size_t pos1 = 0;
    1168 size_t pos2 = 0;
    1169 
    1170 if (strlen(instr) <= *lastpos) {
    1171     *lastpos = 0;
    1172     return token;
    1173 }
    1174 
    1175 strptr = instr + *lastpos;
    1176 pos2 = strspn(strptr, delims);
    1177 strptr += pos2;
    1178 pos1 = strcspn(strptr, delims);
    1179 token = malloc(sizeof(*token)*(pos1+1));
    1180 strncpy(token, strptr, pos1);
    1181 token[pos1] = '\0';
    1182 *lastpos = *lastpos + pos1 + pos2 + 1;
    1183 
    1184 return token;
    1185 }
    1186 /* @} - end of stringGroup */
Note: See TracChangeset for help on using the changeset viewer.