Skip to content

Commit

Permalink
[FIX] disambiguate pro (IDL/PVWAVE vs QMAKE)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Verprauskus committed Aug 10, 2009
1 parent 71a0335 commit a2fbdef
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
Binary file modified bin/ohcount
Binary file not shown.
11 changes: 11 additions & 0 deletions src/detector.c
Expand Up @@ -607,6 +607,17 @@ const char *disambiguate_m(SourceFile *sourcefile) {
return octave_syntax_detected ? LANG_OCTAVE : LANG_MATLAB;
}

const char *disambiguate_pro(SourceFile *sourcefile) {
char *p = ohcount_sourcefile_get_contents(sourcefile);
char *eof = p + strlen(p);
for (; p < eof; p++) {
if (strncmp(p, "SOURCES", 7) == 0 ||
strncmp(p, "CONFIG", 6) == 0)
return LANG_MAKE; // really QMAKE
}
return LANG_IDL_PVWAVE;
}

const char *disambiguate_st(SourceFile *sourcefile) {
char *p, *pe;
int length;
Expand Down
2 changes: 2 additions & 0 deletions src/hash/disambiguatefuncs.gperf
Expand Up @@ -11,6 +11,7 @@ const char *disambiguate_h(SourceFile *sourcefile);
const char *disambiguate_in(SourceFile *sourcefile);
const char *disambiguate_inc(SourceFile *sourcefile);
const char *disambiguate_m(SourceFile *sourcefile);
const char *disambiguate_pro(SourceFile *sourcefile);
const char *disambiguate_st(SourceFile *sourcefile);
%}
struct DisambiguateFuncsMap { const char *key; const char* (*value)(SourceFile*); };
Expand All @@ -24,4 +25,5 @@ h, disambiguate_h
in, disambiguate_in
inc, disambiguate_inc
m, disambiguate_m
pro, disambiguate_pro
st, disambiguate_st
2 changes: 1 addition & 1 deletion src/hash/extensions.gperf
Expand Up @@ -124,7 +124,7 @@ pnt, BINARY
pod, LANG_PERL
pp, LANG_PASCAL
ppt, BINARY
pro, LANG_IDL_PVWAVE
pro, DISAMBIGUATE("pro")
py, LANG_PYTHON
qt, BINARY
r, LANG_R
Expand Down
16 changes: 16 additions & 0 deletions test/detect_files/qmake.pro
@@ -0,0 +1,16 @@
CONFIG += qt debug
HEADERS += hello.h
SOURCES += hello.cpp
SOURCES += main.cpp
win32 {
SOURCES += hellowin.cpp
}
unix {
SOURCES += hellounix.cpp
}
!exists( main.cpp ) {
error( "No main.cpp file found" )
}
win32:debug {
CONFIG += console
}
6 changes: 6 additions & 0 deletions test/unit/detector_test.h
Expand Up @@ -36,6 +36,11 @@ void test_detector_disambiguate_m() {
ASSERT_DETECT(LANG_OCTAVE, "foo_octave.m");
}

void test_detector_disambiguate_pro() {
ASSERT_DETECT(LANG_IDL_PVWAVE, "foo.pro");
ASSERT_DETECT(LANG_MAKE, "qmake.pro");
}

void test_detector_fortran_fixedfree() {
ASSERT_DETECT(LANG_FORTRANFIXED, "fortranfixed.f");
ASSERT_DETECT(LANG_FORTRANFREE, "fortranfree.f");
Expand Down Expand Up @@ -112,6 +117,7 @@ void test_detector_xml_with_custom_extension() {
void all_detector_tests() {
test_detector_smalltalk();
test_detector_disambiguate_m();
test_detector_disambiguate_pro();
test_detector_fortran_fixedfree();
test_detector_detect_polyglot();
test_detector_upper_case_extensions();
Expand Down

0 comments on commit a2fbdef

Please sign in to comment.