diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 46120cf8..30d99dc6 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -11,10 +11,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Configure - # We enforce -Wdeclaration-after-statement because Qt project needs to - # build MD4C with Integrity compiler which chokes whenever a declaration - # is not at the beginning of a block. - run: CFLAGS='--coverage -g -O0 -Wall -Wdeclaration-after-statement -Werror' cmake -DCMAKE_BUILD_TYPE=Debug -G 'Unix Makefiles' . + run: CFLAGS='--coverage -Werror' cmake -DCMAKE_BUILD_TYPE=Debug -G 'Unix Makefiles' . - name: Build run: make VERBOSE=1 - name: Test diff --git a/CMakeLists.txt b/CMakeLists.txt index 82fdf688..84648996 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,12 @@ endif() if(${CMAKE_C_COMPILER_ID} MATCHES GNU|Clang) - add_compile_options(-Wall -Wextra) + add_compile_options(-Wall -Wextra -Wshadow) + + # We enforce -Wdeclaration-after-statement because Qt project needs to + # build MD4C with Integrity compiler which chokes whenever a declaration + # is not at the beginning of a block. + add_compile_options(-Wdeclaration-after-statement) elseif(MSVC) # Disable warnings about the so-called unsecured functions: add_definitions(/D_CRT_SECURE_NO_WARNINGS) diff --git a/src/md4c.c b/src/md4c.c index 7c397106..d34933f7 100644 --- a/src/md4c.c +++ b/src/md4c.c @@ -4201,6 +4201,7 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines) MD_MARK* mark; OFF off = lines[0].beg; OFF end = lines[n_lines-1].end; + OFF tmp; int enforce_hardbreak = 0; int ret = 0; @@ -4216,7 +4217,7 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines) while(1) { /* Process the text up to the next mark or end-of-line. */ - OFF tmp = (line->end < mark->beg ? line->end : mark->beg); + tmp = (line->end < mark->beg ? line->end : mark->beg); if(tmp > off) { MD_TEXT(text_type, STR(off), tmp - off); off = tmp; @@ -4427,8 +4428,6 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines) break; if(text_type == MD_TEXT_CODE || text_type == MD_TEXT_LATEXMATH) { - OFF tmp; - MD_ASSERT(prev_mark != NULL); MD_ASSERT(ISANYOF2_(prev_mark->ch, '`', '$') && (prev_mark->flags & MD_MARK_OPENER)); MD_ASSERT(ISANYOF2_(mark->ch, '`', '$') && (mark->flags & MD_MARK_CLOSER)); @@ -4447,8 +4446,7 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines) } else if(text_type == MD_TEXT_HTML) { /* Inside raw HTML, we output the new line verbatim, including * any trailing spaces. */ - OFF tmp = off; - + tmp = off; while(tmp < end && ISBLANK(tmp)) tmp++; if(tmp > off)