Changeset 171 in MondoRescue for trunk/mondo/mondo/common/libmondo-string.c


Ignore:
Timestamp:
Dec 8, 2005, 5:20:29 PM (18 years ago)
Author:
bcornec
Message:

memory management continues:

  • mondoarchive handled completely
  • bkpinfo, begining of dyn. alloc.
  • lot of changes around memory everywhere

=> even if it compiles, i'm pretty sure it doesn't work yet (even not tried)

File:
1 edited

Legend:

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

    r122 r171  
    106106}
    107107
     108/* sout is allocated here and must be freed by the caller */
    108109
    109110inline void turn_wildcard_chars_into_literal_chars(char *sout, char *sin)
    110111{
    111     char *p, *q;
    112 
    113     for (p = sin, q = sout; *p != '\0'; *(q++) = *(p++)) {
     112    char *p;
     113    char *q = NULL;
     114    char *sav;
     115    char r;
     116    bool end = FALSE;
     117
     118    asprintf(&sav, sin);
     119    p = sav;
     120    while ((*p != '\0') && (! end)) {
    114121        if (strchr("[]*?", *p)) {
    115             *(q++) = '\\';
     122            r = *p;                 // keep the wildcard char
     123            *p = '\0';              // trunc the final string
     124            p++;                    // continue on sav
     125                                    // build the new string by recursion
     126            turn_wildcard_chars_into_literal_chars(q,p);
     127            asprintf(&sout, "%s\\%c%s", sav, r, q);
     128            paranoid_free(q);
     129            paranoid_free(sav);
     130            end = TRUE;
    116131        }
    117     }
    118     *q = *p;                    // for the final '\0'
     132        p++;
     133    }
     134    if (!end) {
     135        sout = sav;
     136    }
    119137}
    120138
     
    345363        break;
    346364    default:
    347         asprintf(&outstr, "%s", "BLK_UNKNOWN (%d)", marker);
     365        asprintf(&outstr, "%s (%d)", "BLK_UNKNOWN", marker);
    348366        break;
    349367    }
     
    530548        asprintf(&suffix, ".%s", s);
    531549    } else {
    532         asprintf(&suffix, "%s", "");
     550        asprintf(&suffix, "%s", " ");
    533551    }
    534552    asprintf(&output, "%s/slice-%07ld.%05ld.dat%s", path, bigfileno,
Note: See TracChangeset for help on using the changeset viewer.