You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using opengrok to index some stl implements for learning.
But I find opengrok treats all stl headers as plain text (algorithm,set,map and etc).
So I'm wondering if there's a way to let opengrok treats no suffix text file as cpp header file?
Thanks for your help.
I don't think there is a way currently how to make this work. Either the -A specification needs to be extended to paths or the matching needs to be much more flexible.
I found the 'file' utility can successfully identify stl header as c source
Is it possible to integrate this to opengrok? Or directly use libmagic instead?
straceing the file utility reveals that it reads the file whole (it reads 1 MiB of the file in fact, at least on my system). We definitely want to avoid that - the classification of a file should be fast. Maybe the AnalyzerGuru could perform some quick analysis based on some predefined chunk of the file however that sounds like an overhaul.
Maybe we can use the existing file type analyzer first. When a file has no file extension, then use file to distinguish its type. (So use file just as a addition)
Activity
vladak commentedon Mar 30, 2021
Depends on the suffix of these files:
opengrok/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/c/CxxAnalyzerFactory.java
Lines 32 to 42 in 6364b31
[-]Opengrok treats stl header file as plain text[/-][+]Opengrok treats C++ STL header file as plain text[/+]vladak commentedon Mar 30, 2021
If the file in question has one of these suffixes, attach reproducible test case please.
TooYoungTooSimp commentedon Mar 31, 2021
Unfortunately, C++ STL headers have no suffix.
https://github.com/microsoft/STL/tree/main/stl/inc
https://github.com/llvm/llvm-project/tree/main/libcxx/include
As we can see, stl headers (like algorithm, vector, set, map, queue) are all have no suffix.
That's why I'm wondering how to index them.
vladak commentedon Mar 31, 2021
I don't think there is a way currently how to make this work. Either the -A specification needs to be extended to paths or the matching needs to be much more flexible.
TooYoungTooSimp commentedon Apr 2, 2021
I found the 'file' utility can successfully identify stl header as c source

Is it possible to integrate this to opengrok? Or directly use libmagic instead?
vladak commentedon Apr 6, 2021
strace
ing thefile
utility reveals that it reads the file whole (it reads 1 MiB of the file in fact, at least on my system). We definitely want to avoid that - the classification of a file should be fast. Maybe theAnalyzerGuru
could perform some quick analysis based on some predefined chunk of the file however that sounds like an overhaul.TooYoungTooSimp commentedon Apr 6, 2021
Maybe we can use the existing file type analyzer first. When a file has no file extension, then use file to distinguish its type. (So use file just as a addition)
Is that possible?
TooYoungTooSimp commentedon Apr 6, 2021
and when use libmagic directly, there's no need to read full file, providing a buffer is okay.
https://linux.die.net/man/3/libmagic