As can be seen on https://www.ohloh.net/p/cfunge/analyses/latest ohloh misdetects most of the code as C++. It is all C89 and C99 in that project.
I hope this can be corrected as soon as possible, since one of the key points of the project is that it uses portable C99 + POSIX rather than for example C++. (That is where the "c" in cfunge comes from.)
Hi AnMaster,
Our detector is having a problem with the Emacs mode headers, which look like this:
/* -*- mode: C; coding: utf-8; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
The header is totally reasonable, and any human looking at this would assume that C code (not C++) is about to follow.
However, our parser distinguishes between upper case "C" and lower case "c", and uses the same rules that we use for file extensions.
When upper case "C" is used as a file extension, this usually means that the source file is a C++ file. Lower case "c" means straight C.
This same rule about upper-case-means-C++ and lower-case-means-straight-C gets applied to the Emacs mode header, so our parser concludes that this is a C++ file.
You can see the relevant lines of code in detector.c around line 69.
This is probably wrong. I'm pretty sure -- but someone will need to verify this -- that Emacs mode headers are not case-sensitive, and they will always explicitly say "C++" when they mean C++, and will never use a simple upper case C to mean C++. If that is the case, we can probably insert some code here to correctly interpret Emacs mode "C".
If the Emacs mode headers in these source files are switched to use a lower case "c", or are removed completely, then our parser treats everything as straight C, as expected.
If anyone can clue me in about Emacs mode header case sensitivity, we can probably put together a fix relatively quickly.
Robin
Interesting problem indeed. But as far as I remember the C++ mode string of emacs looks different. I'm pretty sure that the mode string for C++ is indeed "c++" (without the quotes). However since I don't code much in C++ I'm not completely sure. I will try to investigate this today.
Some research indicates that it may be supposed to be case sensitive in theory. However in practise unlikely spellings like "MoDe: lIsP" does the same as the normal "mode: lisp".
It seems emacs either tries lower-cased versions if it can't find anything matching, or that it begins by lower casing the string.
Thus, it isn't clear to me if C should map to c or if C should be considered an unknown value. But one thing is clear: C should not map to c++, since the mode string for C++ is "c++" (without the quotes of course).
Oh, by the way, when you have fixed this, I would be thankful if you would then re-run the analysis of cfunge, so that it no longer says that it is C++.
Hi Anmaster,
I've committed a patch that fixes this problem. It won't be deployed on our website until next week at the earliest, at which point I'll schedule a clean recalc of the project line counts.
Thanks, Robin
Thanks a lot.
Copyright
©
2013
Black Duck Software, Inc.
and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a
Creative Commons Attribution 3.0 Unported License
. Ohloh
®
and the Ohloh logo are trademarks of
Black Duck Software, Inc.
in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.