Skip to content

Opengrok treats C++ STL header file as plain text #3507

@TooYoungTooSimp

Description

@TooYoungTooSimp

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.

Activity

vladak

vladak commented on Mar 30, 2021

@vladak
Member

Depends on the suffix of these files:

private static final String[] SUFFIXES = {
"CPP",
"HPP",
"CC",
"C++",
"HH",
"CXX",
"HXX",
"TXX",
"TCC"
};

changed the title [-]Opengrok treats stl header file as plain text[/-] [+]Opengrok treats C++ STL header file as plain text[/+] on Mar 30, 2021
vladak

vladak commented on Mar 30, 2021

@vladak
Member

If the file in question has one of these suffixes, attach reproducible test case please.

TooYoungTooSimp

TooYoungTooSimp commented on Mar 31, 2021

@TooYoungTooSimp
Author

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

vladak commented on Mar 31, 2021

@vladak
Member

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

TooYoungTooSimp commented on Apr 2, 2021

@TooYoungTooSimp
Author

I found the 'file' utility can successfully identify stl header as c source
IMG_20210402_092348.jpg
Is it possible to integrate this to opengrok? Or directly use libmagic instead?

vladak

vladak commented on Apr 6, 2021

@vladak
Member

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.

TooYoungTooSimp

TooYoungTooSimp commented on Apr 6, 2021

@TooYoungTooSimp
Author

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

TooYoungTooSimp commented on Apr 6, 2021

@TooYoungTooSimp
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @vladak@TooYoungTooSimp

        Issue actions

          Opengrok treats C++ STL header file as plain text · Issue #3507 · oracle/opengrok