static char * edit(const char *str, int len, const char *rep, int nmat, const int *ovec, char *res) { int i, slen, rlen; const int *mvec = ovec; int replen[MAXCAPTURE]; const char *repstr[MAXCAPTURE]; nmat--; ovec += 2; for (i = 0; i < nmat; i++) { replen[i] = ovec[i * 2 + 1] - ovec[i * 2]; repstr[i] = &str[ovec[i * 2]]; #ifdef REGEX_DEBUG printf(">>>%d %d %.*s\n", i, replen[i], replen[i], repstr[i]); #endif /* REGEX_DEBUG */ } slen = len; len -= mvec[1] - mvec[0]; len += rlen = findreplen(rep, nmat, replen); #ifdef REGEX_DEBUG printf("resulting length %d (srclen=%d)\n", len, slen); #endif /* REGEX_DEBUG */ if (mvec[0] > 0) { strncpy(cp, str, (mvec[0] > ep - cp - 1)? ep - cp - 1 :mvec[0]); cp += mvec[0]; } if(ep - cp < rlen) return NULL; doreplace(cp, rep, nmat, replen, repstr); cp += rlen; return res; }
static char * edit(const char *str, int len, const char *rep, int nmat, const int *ovec) { int i, slen, rlen; const int *mvec = ovec; char *res, *cp; int replen[MAXCAPTURE]; const char *repstr[MAXCAPTURE]; nmat--; ovec += 2; for (i = 0; i < nmat; i++) { replen[i] = ovec[i * 2 + 1] - ovec[i * 2]; repstr[i] = &str[ovec[i * 2]]; #ifdef DEBUG_PCRE_SUBST printf(">>>%d %d %.*s\n", i, replen[i], replen[i], repstr[i]); #endif } slen = len; len -= mvec[1] - mvec[0]; len += rlen = findreplen(rep, nmat, replen); #ifdef DEBUG_PCRE_SUBST printf("resulting length %d (srclen=%d)\n", len, slen); #endif cp = res = pcre_malloc(len + 1); if (mvec[0] > 0) { strncpy(cp, str, mvec[0]); cp += mvec[0]; } doreplace(cp, rep, nmat, replen, repstr); cp += rlen; if (mvec[1] < slen) strcpy(cp, &str[mvec[1]]); res[len] = 0; return res; }
static short *llreplace(short *buf, int *max, int *len, TYP *to, TYP *tn) { char type[512]; short formattedtype[512]; short searchfor[256]; int slen; int flen; int i; // if (to->type != bt_class) // return buf ; slen = strlen(to->sp->name); for (i = 0; i < slen; i++) searchfor[i] = to->sp->name[i]; if (prm_cmangle && searchfor[0] == '_') { memcpy(searchfor, searchfor + 1, slen *sizeof(short)); slen--; } if (to->type != bt_class) { if (scalarnonfloat(to)) { if (to->type == bt_char || to->type == bt_unsignedchar) { #ifdef CC68K sprintf(type, "'%c'", tn->sp->value.i + 3); #else sprintf(type, "'%c'", tn->sp->value.i); #endif } else sprintf(type, "%d", tn->sp->value.i); } else sprintf(type, "%f", tn->sp->value.i); flen = strlen(type); for (i = 0; i < flen; i++) formattedtype[i] = type[i]; } else if (tn->type == bt_string) { flen = tn->size; for (i = 0; i < flen; i++) formattedtype[i] = ((char*)tn->lst.head)[i]; } else { typenum(type, tn); flen = strlen(type); for (i = 1; i < flen - 1; i++) formattedtype[i - 1] = type[i]; flen -= 2; } return doreplace(buf, max, len, searchfor, formattedtype, slen, flen, FALSE) ; }
flagType qreplace ( CMDDATA argData, ARG * pArg, flagType fMeta ) { return doreplace (TRUE, pArg, fMeta, FALSE); argData; }
static short *llreplace2(short *buf, int *max, int *len, char *find, char *replace) { short formattedtype[512]; short searchfor[256]; char *p = replace; int flen = 0, slen = 0; while (*p) if (*p == '@' || *p == '$' || *p == '#') formattedtype[flen++] = '_', p++; else formattedtype[flen++] = *p++; p = find; while (*p) searchfor[slen++] = *p++; if (prm_cmangle && searchfor[0] == '_') { memcpy(searchfor, searchfor + 1, slen *sizeof(short)); slen--; } return doreplace(buf, max, len, searchfor, formattedtype, slen, flen, TRUE); }