Skip to content

Commit

Permalink
add ug.exe --filter support #442
Browse files Browse the repository at this point in the history
  • Loading branch information
genivia-inc committed Nov 19, 2024
1 parent d3e19f9 commit d0ebf7f
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 91 deletions.
Binary file modified bin/win32/ug.exe
Binary file not shown.
Binary file modified bin/win32/ugrep-indexer.exe
Binary file not shown.
Binary file modified bin/win32/ugrep.exe
Binary file not shown.
Binary file modified bin/win64/ug.exe
Binary file not shown.
Binary file modified bin/win64/ugrep-indexer.exe
Binary file not shown.
Binary file modified bin/win64/ugrep.exe
Binary file not shown.
292 changes: 202 additions & 90 deletions src/ugrep.cpp

Large diffs are not rendered by default.

28 changes: 27 additions & 1 deletion src/ugrep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define UGREP_HPP

// DO NOT ALTER THIS LINE: updated by makemake.sh and we need it physically here for MSVC++ build from source
#define UGREP_VERSION "7.0.4"
#define UGREP_VERSION "7.1.0"

// disable mmap because mmap is almost always slower than the file reading speed improvements since 3.0.0
#define WITH_NO_MMAP
Expand Down Expand Up @@ -104,6 +104,30 @@ inline int pipe(int fd[2])
fd[1] = _open_osfhandle(reinterpret_cast<intptr_t>(pipe_w), _O_WRONLY);
return 0;
}
errno = GetLastError();
return -1;
}

// POSIX pipe() emulation with inherited pipe handles for child processes (Windows specific)
inline int pipe_inherit(int fd[2])
{
HANDLE pipe_r = NULL;
HANDLE pipe_w = NULL;
SECURITY_ATTRIBUTES sa;
memset(&sa, 0, sizeof(SECURITY_ATTRIBUTES));
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
if (CreatePipe(&pipe_r, &pipe_w, &sa, 0))
{
fd[0] = _open_osfhandle(reinterpret_cast<intptr_t>(pipe_r), _O_RDONLY);
fd[1] = _open_osfhandle(reinterpret_cast<intptr_t>(pipe_w), _O_WRONLY);
if (SetHandleInformation(reinterpret_cast<HANDLE>(_get_osfhandle(fd[0])), HANDLE_FLAG_INHERIT, 0))
return 0;
close(fd[0]);
close(fd[1]);
}
errno = GetLastError();
return -1;
}

Expand Down Expand Up @@ -166,6 +190,8 @@ inline int chdir(const char *path)
inline char *getcwd0()
{
wchar_t *wcwd = _wgetcwd(NULL, 0);
if (wcwd == NULL)
return NULL;
std::string cwd(utf8_encode(wcwd));
free(wcwd);
return strdup(cwd.c_str());
Expand Down

0 comments on commit d0ebf7f

Please sign in to comment.