Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2303 from sparklemotion/2302-c99-fixes
c99 fixes --- **What problem is this PR intended to solve?** #2302 reports a compilation failure on RHEL6, RHEL7, and SLES12. These are older distros (RHEL7 is running gcc 4.8) which seem to compile in a C90-ish mode by default that gives errors on C99-isms. This PR removed the C99isms (which are errors) as well as some C90isms (which generate warnings). Specifically: - don't declare a variable in a `for` statement (C99-ism) - don't mix declarations and code (C90-ism) This PR also cleans up some C casting related to how we're handling `const` qualifiers. Specifically: - `gumbo.c` is now using `(const xmlChar *)` in place of `BAD_CAST` (which is an alias for `(xmlChar *)`) - extracted the const-discard hack `(xmlChar *)(uintptr_t)ptr` into a macro `DISCARD_CONST_QUAL` - introduce use of `DISCARD_CONST_QUAL` in one additional place in `xml_node.c` As a result, even when using `-Wcast-qual` on older Rubies that support it, we now see no compiler warnings. **Have you included adequate test coverage?** I considered setting up CI using a comparable Centos docker image, but I didn't feel like there was much regression value to that test, given the nature of this failure. I could be argued into doing it, if anyone feels strongly.
- Loading branch information
Showing
9 changed files
with
119 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.