Changeset 3294 in MondoRescue for branches/3.2/mondo/src/lib/mr_str.c


Ignore:
Timestamp:
Jun 3, 2014, 8:20:52 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Fix a compilation issue in libmondo-archive.c on mindi call with lack of parameter
  • Fix compilation warnings in mr_mem.c
  • Adds function mr_str_substitute in mr_str (not yet used) and test code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/lib/mr_str.c

    r3194 r3294  
    194194}
    195195
     196char *mr_str_substitute(const char *in, const char *token, const char *subst) {
     197
     198char *output = NULL;
     199char *tmp = NULL;
     200int i = 0;
     201
     202mr_asprintf(output, "%s", in);
     203tmp = strstr(output, token);
     204if (tmp == NULL) {
     205    // token not found returning initial string unmodified
     206    return(output);
     207}
     208// token found end string here for now
     209*tmp = '\0';
     210
     211// Add subst content to the string
     212mr_strcat(output,subst);
     213
     214// now add the rest of in
     215tmp = strstr(in, token);
     216for (; i < strlen(token) ; i++) {
     217    tmp++;
     218}
     219mr_strcat(output,tmp);
     220return(output);
     221}
     222
    196223
    197224/*
Note: See TracChangeset for help on using the changeset viewer.