Open TooYoungTooSimp opened 3 years ago
If the file in question has one of these suffixes, attach reproducible test case please.
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.
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?
strace
ing 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)
Is that possible?
and when use libmagic directly, there's no need to read full file, providing a buffer is okay.
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.