universal-ctags / ctags

A maintained ctags implementation
https://ctags.io
GNU General Public License v2.0
6.57k stars 628 forks source link

main: ban fpos_t #3727

Open masatake opened 1 year ago

masatake commented 1 year ago

fpos_t has caused making our code complicated.

Will ctags deal with files larger than sizeof(long)? I think it will not.

So I would like to use only ftell/fseek, not together with fsetpos/fgetpos.

Anjuta-ctags took the way I like.

https://gitlab.gnome.org/Archive/anjuta/-/commit/91f5e7fe0a6e4d548f4888711cdaaf7bedab6f85 https://gitlab.gnome.org/Archive/anjuta/-/commit/0adbb5451148027bc6cb283acbfd98c5dc79aad0

What do you think?

k-takata commented 1 year ago

You may need to consider that long is 32 bits on Windows. Windows has the 64-bit version of fseek: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fseek-fseeki64?view=msvc-170 If we don't need to consider the files that are larger than 2 GB, simply using long should be okay. Otherwise, the source code of Vim might be helpful: https://github.com/vim/vim/blob/c0da540466c89e388e7a15a12bab2f9fc42d9671/src/vim.h#L384-L416 (MSWIN is defined inside Vim. Normally we can use _WIN32 instead. PROTO is used for the cproto command, so this can be ignored.)

masatake commented 1 year ago

@k-takata, thank you for the suggestion. Only about input, I think 2GB is large enough. For output, 2GB is too small.

k-takata commented 1 year ago

Oh, I remember that we've already done this in readtag: https://github.com/universal-ctags/ctags/blob/3547021a009d3c4b89f17dfb7e6ffd4cacacfa0c/libreadtags/readtags.c#L111-L135

masatake commented 1 year ago

Nice! We should reuse it.