Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on strings.h #481

Merged
merged 3 commits into from Mar 2, 2017
Merged

Remove dependency on strings.h #481

merged 3 commits into from Mar 2, 2017

Conversation

@nurupo
Copy link
Member

@nurupo nurupo commented Feb 20, 2017

strings.h is not available on MSVC.


This change is Reviewable

@nurupo nurupo added this to the v0.1.7 milestone Feb 20, 2017
@nurupo nurupo force-pushed the nurupo:remove-strings-h branch from 213d5f2 to e301081 Feb 20, 2017
@nurupo
Copy link
Member Author

@nurupo nurupo commented Feb 20, 2017

Looks like the -Werror makes the clang build on Travis fail because clang's ctype.h header triggers -Wdisabled-macro-expansion. gcc and mingw don't have such an issue.

/home/travis/build/TokTok/c-toxcore/testing/misc_tools.c:56:18: error: disabled expansion of recursive macro [-Werror,-Wdisabled-macro-expansion]
        int c1 = tolower(*(s1++));
                 ^
/usr/include/ctype.h:230:35: note: expanded from macro 'tolower'
#  define tolower(c)    __tobody (c, tolower, *__ctype_tolower_loc (), (c))
                                     ^
/usr/include/ctype.h:176:14: note: expanded from macro '__tobody'
            __res = f args;                                                   \
                    ^

@iphydf How should we deal with it, is disabling -Wdisabled-macro-expansion just for clang acceptable?

@Diadlo
Copy link

@Diadlo Diadlo commented Feb 20, 2017

Or we can write own tolower

@nurupo nurupo force-pushed the nurupo:remove-strings-h branch from e301081 to 62704f0 Feb 22, 2017
@nurupo nurupo mentioned this pull request Feb 22, 2017
@cebe
Copy link
Member

@cebe cebe commented Feb 22, 2017

Review status: 0 of 2 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


testing/misc_tools.c, line 53 at r1 (raw file):

}

int tox_strncasecmp(const char* s1, const char* s2, size_t n)

add a comment that this is implemented because strings.h is not available on MSVC.


Comments from Reviewable

@nurupo nurupo force-pushed the nurupo:remove-strings-h branch from 62704f0 to 16a6ce5 Feb 22, 2017
@nurupo
Copy link
Member Author

@nurupo nurupo commented Feb 22, 2017

testing/misc_tools.c, line 53 at r1 (raw file):

Previously, cebe (Carsten Brandt) wrote…

add a comment that this is implemented because strings.h is not available on MSVC.

Added.


Comments from Reviewable

@Diadlo
Copy link

@Diadlo Diadlo commented Feb 22, 2017

Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@cebe
Copy link
Member

@cebe cebe commented Feb 22, 2017

:lgtm:


Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@Diadlo
Copy link

@Diadlo Diadlo commented Feb 22, 2017

@cebe Why do you lgtm, if current build is failed?

@cebe
Copy link
Member

@cebe cebe commented Feb 23, 2017

@Diadlo sorry I did not notice that, was looking at the code only.

@cebe
Copy link
Member

@cebe cebe commented Feb 23, 2017

:lgtm_cancel:


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@nurupo nurupo force-pushed the nurupo:remove-strings-h branch from f364a36 to 27bb4b7 Feb 24, 2017
@Diadlo
Copy link

@Diadlo Diadlo commented Feb 24, 2017

Reviewed 1 of 1 files at r3, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


CMakeLists.txt, line 99 at r4 (raw file):

    add_flag("-Wno-covered-switch-default")
    # Due to clang's tolower() macro being recursive https://github.com/TokTok/c-toxcore/pull/481
    add_flag("-Wno-disabled-macro-expansion")

Maybe put inside if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")?


Comments from Reviewable

@nurupo
Copy link
Member Author

@nurupo nurupo commented Feb 24, 2017

CMakeLists.txt, line 99 at r4 (raw file):

Previously, Diadlo (Polshakov Dmitry) wrote…

Maybe put inside if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")?

Do we really want this warning to be enabled in the first place?


Comments from Reviewable

@iphydf
Copy link
Member

@iphydf iphydf commented Feb 26, 2017

:lgtm_strong: could you write a test for this function?


Reviewed 1 of 2 files at r1, 1 of 1 files at r3, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@nurupo
Copy link
Member Author

@nurupo nurupo commented Feb 26, 2017

Uh, sure, if you really want. I thought the function was trivial enough to verify that it does the right thing.

Hm, it's probably easier to just replace this function with an ifdef using strncasecmp() on POSIX systems and _strnicmp() on Windows rather than writing tests for it.

@nurupo nurupo force-pushed the nurupo:remove-strings-h branch 3 times, most recently from e2720f1 to b88a302 Feb 26, 2017
@nurupo
Copy link
Member Author

@nurupo nurupo commented Feb 26, 2017

Added the test. Hopefully the 20 minutes I have spent on it were worth it. Also, I ran out of wafers while writing it, thus the wafer test cases.

verify("The Wafers Are Salty.", "The wafers are sweet.", 17, NEGATIVE);
verify("The Wafers Are Salty.", "The wafers are sweet.", -1, NEGATIVE);

// the comparison should stop at first mistmatch

This comment has been minimized.

@iphydf

iphydf Feb 27, 2017
Member

s/mist/mis/

@iphydf
Copy link
Member

@iphydf iphydf commented Feb 27, 2017

Thanks, looks good. Can you fix the typo and then rebase? I'll merge it after.

@nurupo nurupo force-pushed the nurupo:remove-strings-h branch from b88a302 to f4711bc Feb 27, 2017
@nurupo
Copy link
Member Author

@nurupo nurupo commented Feb 27, 2017

auto_tests/tox_strncasecmp_test.c, line 164 at r5 (raw file):

Previously, iphydf wrote…

s/mist/mis/

Done.


Comments from Reviewable

@iphydf
Copy link
Member

@iphydf iphydf commented Mar 1, 2017

Did I merge something after your rebase? I can't merge this, yet. Can you rebase (again)?

nurupo added 3 commits Feb 20, 2017
Due to clang's tolower() macro being recursive.
@nurupo nurupo force-pushed the nurupo:remove-strings-h branch from f4711bc to def92ab Mar 2, 2017
@nurupo
Copy link
Member Author

@nurupo nurupo commented Mar 2, 2017

Rebased.

@iphydf iphydf merged commit def92ab into TokTok:master Mar 2, 2017
3 of 4 checks passed
3 of 4 checks passed
ci/circleci Your tests are queued behind your running builds
Details
code-review/reviewable 1/1 LGTMs
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.