Skip to content

Commit

Permalink
Fix warning about a shadowed variable (with -Wshadow).
Browse files Browse the repository at this point in the history
  • Loading branch information
mity committed Jan 28, 2024
1 parent ccff554 commit 7381b48
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions src/md4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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)
Expand Down

0 comments on commit 7381b48

Please sign in to comment.