dp = rdata->dollar; while (dp) {
for (dp = rdata->dollar, ep = rdata->dollarEnd; dp; dp = js_strchr_limit(dp, '$', ep)) {
do_replace(JSContext *cx, ReplaceData *rdata, jschar *chars){    JSString *repstr;    jschar *bp, *cp, *dp;    size_t len, skip;    JSSubString *sub;    repstr = rdata->repstr;    bp = cp = JSSTRING_CHARS(repstr);    dp = rdata->dollar;    while (dp) {        len = dp - cp;        js_strncpy(chars, cp, len);        chars += len;        cp = dp;        sub = interpret_dollar(cx, dp, rdata, &skip);        if (sub) {            len = sub->length;            js_strncpy(chars, sub->chars, len);            chars += len;            cp += skip;            dp += skip;        }        else            dp++;        dp = js_strchr(dp, '$');    }    js_strncpy(chars, cp, JSSTRING_LENGTH(repstr) - (cp - bp));}