From 256901bbbc124cd359611df6405dd6ec718b1448 Mon Sep 17 00:00:00 2001 From: Keith Kanios Date: Sat, 9 Apr 2011 10:30:20 -0500 Subject: [PATCH] Revert "nasmlib.c: fix issues with strrep utility function" This reverts commit f16401f9aabb550a556d3a462f428a3b52f6f9c3. --- nasmlib.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nasmlib.c b/nasmlib.c index c08ef09d..538223f8 100644 --- a/nasmlib.c +++ b/nasmlib.c @@ -295,7 +295,7 @@ char *nasm_strrep(const char *str, const char *sub, char *lin, bool casesense) char *outline = lin; char *temp1 = NULL; char *temp2 = NULL; - char *l, *ll, *lp, *lt, *ls; + char *l, *lp, *lt, *ls; int count = 0; int str_len, sub_len, lin_len; int i, c; @@ -321,7 +321,7 @@ char *nasm_strrep(const char *str, const char *sub, char *lin, bool casesense) ls = (char *)str; } - ll = l; + lt = l; do { l = strstr(l, ls); @@ -336,25 +336,23 @@ char *nasm_strrep(const char *str, const char *sub, char *lin, bool casesense) i += (count * sub_len); outline = nasm_zalloc(i); - l = ll; - lt = lin; + l = lt; - for (i = 0; i < count; i++) { + for (i = 0; i < count; i ++) { lp = l; l = strstr(l, ls); - c = (l - lp); + c = (lp - l); if (c > 0) { strncat(outline, lt, c); - lt += c; } strncat(outline, sub, sub_len); l += str_len; lt += str_len; } - c = (l - ll); + c = (l - lin); if (c < lin_len) { - strncat(outline, lt, (lin_len-c)); + strcat(outline, lt); } if (temp2 != NULL) { -- 2.11.4.GIT