From 9480d504d3c91e3d014c9e52fd7383d434fe58d4 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 4 Sep 2016 15:31:52 +0200 Subject: [PATCH] Rename look counters. --- src/mrsimplify.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mrsimplify.cpp b/src/mrsimplify.cpp index bfa792ef..e037fd99 100644 --- a/src/mrsimplify.cpp +++ b/src/mrsimplify.cpp @@ -167,27 +167,28 @@ void MrSimplify::SimplifyPlainText(char* buf_terminated) carray* lines = SplitIntoLines(buf_terminated); // search for the line `-- ` and ignore this and all following lines - unsigned int l_indx, l_cnt = carray_count(lines); - for( l_indx = 0; l_indx < l_cnt; l_indx++ ) + unsigned int l, l_first = 0, l_last = carray_count(lines)-1; // if l_last is -1, there are no lines + for( l = l_first; l <= l_last; l++ ) { - char* line = (char*)carray_get(lines, l_indx); + char* line = (char*)carray_get(lines, l); if( strcmp(line, "-- ")==0 ) { - l_cnt = l_indx; + l_last = l - 1; // if l_last is -1, there are no lines break; // done } } // re-create buffer from lines char* p1 = buf_terminated; - for( l_indx = 0; l_indx < l_cnt; l_indx++ ) + *p1 = 0; // make sure, the string is terminated if there are no lines (l_last==-1) + for( l = l_first; l < l_last; l++ ) { - char* line = (char*)carray_get(lines, l_indx); + char* line = (char*)carray_get(lines, l); size_t line_len = strlen(line); strcpy(p1, line); - if( l_indx!=l_cnt-1 ) { + if( l!=l_last ) { p1[line_len] = '\n'; line_len++; }