Skip to content

Commit 33b51a7

Browse files
authored
Merge pull request #44 from masatake/fopen-m
Use mmap(2) when opening a tags file if fopen() supports "m" mode flag.
2 parents 95bdb65 + c0f0107 commit 33b51a7

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

.github/workflows/msys2.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,5 @@ jobs:
5050
- run: make check V=1
5151
- run: cat tests/test-suite.log
5252
if: failure()
53+
- run: for x in tests/*.log; do echo '#' $x; cat $x; done
54+
if: failure()

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
- add a new API function (tagsFindPseudoTag) for finding a pseudo tag for
2121
given name.
2222

23+
- Use mmap(2) when opening a tags file if fopen() supports "m" mode flag.
24+
2325
# Version 0.1.0
2426

2527
- propagate internal errors to caller

readtags.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,14 @@ static tagFile *initialize (const char *const filePath, tagFileInfo *const info)
832832
result->fields.max, sizeof (tagExtensionField));
833833
if (result->fields.list == NULL)
834834
goto mem_error;
835-
result->fp = fopen (filePath, "rb");
835+
836+
#define GLIBC_FOPEN_MODE_USE_MMAP "m"
837+
result->fp = fopen (filePath, "rb" GLIBC_FOPEN_MODE_USE_MMAP);
838+
if (result->fp == NULL)
839+
{
840+
errno = 0;
841+
result->fp = fopen (filePath, "rb");
842+
}
836843
if (result->fp == NULL)
837844
{
838845
info->status.error_number = errno;

0 commit comments

Comments
 (0)