blackducksoftware / ohcount

The Ohloh source code line counter
https://github.com/blackducksoftware/ohcount
GNU General Public License v2.0
261 stars 70 forks source link

Some fixes for building on Fedora #54

Closed bluedreamer closed 5 years ago

bluedreamer commented 7 years ago

Fix error caused from Fedora /etc/issue file containing \S escape sequence

unhandled /etc/issue result: \s
Building Ohcount

Fix compile error with different function signatures

languages.gperf:66:1: error: conflicting types for ‘ohcount_hash_language_from_name’ In file included from languages.gperf:2:0: src/hash/../languages.h:122:21: note: previous declaration of ‘ohcount_hash_language_from_name’ was here struct LanguageMap ohcount_hash_language_from_name(register const char str, register unsigned int len); ^~~~~~~

craigbarnes commented 7 years ago

I assume you changed the unsigned int to size_t to fix compiling with gperf 3.1? That just fixes compiling on Fedora but breaks compiling on any distro that hasn't updated to 3.1 yet.

bluedreamer commented 7 years ago

No, the size_t/unsigned change was for gcc 7.1. I don't see how making the prototype match the actual function definition will break anything anywhere at all - unless it is a broken compiler

craigbarnes commented 7 years ago

The prototype you changed was for a function generated by gperf. gperf >= 3.1 always generates a function that uses size_t whereas before that it used unsigned int. See: https://savannah.gnu.org/forum/forum.php?forum_id=8789.

So anyone compiling with your changes and using gperf < 3.1 will get an error because the prototype in the header won't match the function generated by gperf.

The only way to solve this is to check the version of gperf and set the length type accordingly.

bluedreamer commented 7 years ago

Ah I get it, fixed a symptom not the problem - I just wanted it to compile. I'll look at it more and see if I can provide a better patch then

sylvestre commented 6 years ago

FWIW, I am experiencing the same issue on Debian.

mblo commented 6 years ago

Same problem on osx 10.13.3. size_t solves the issue

sylvestre commented 6 years ago

@notalex Could you please merge that? thanks

sylvestre commented 6 years ago

@msk999 Would be great if you could merge that in the next release! Thanks!

notalex commented 6 years ago

@sylvestre, thanks for keeping check. We had looked at this build before and ran into trouble while compiling it on Ubuntu then. We will be adding onto this work to fix the compilation. I will update further on this soon.

bluedreamer commented 6 years ago

Which version? I am happy to download Ubuntu and make the fix cross platform? Put the work on me! This is open source after all ;-)

notalex commented 6 years ago

Thanks @bluedreamer , that would be very helpful. We need it to be compatible with Ubuntu LTS releases. The current ones are 16.04 & 18.04. This is the error I get:

Building src/parser.c (will take a while)
src/parser.c:10:20: error: conflicting types for ‘ohcount_hash_parser_from_language’
 struct ParserMap * ohcount_hash_parser_from_language (register const char *str, register size_t len);
                    ^
In file included from src/parser.c:8:0:
parsers.gperf:170:1: note: previous definition of ‘ohcount_hash_parser_from_language’ was here
notalex commented 5 years ago

We have cherry-picked this commit for the version 4 release: https://github.com/blackducksoftware/ohcount/pull/68 We have added a few more changes to make the build pass on Fedora 29. We might not release version 4 anytime soon, but the version-4 branch will remain usable for Ubuntu 18.04 and Fedora 29. @bluedreamer, thank you for your contribution.