MCPcopy Create free account
hub / github.com/Genivia/ugrep / execute

Method execute

src/query.cpp:1929–1980  ·  view source on GitHub ↗

execute the search in a new thread and send results to a pipe

Source from the content-addressed store, hash-verified

1927
1928// execute the search in a new thread and send results to a pipe
1929void Query::execute(int pipe_fd)
1930{
1931 Static::output = fdopen(pipe_fd, "wb");
1932
1933 if (Static::output != NULL)
1934 {
1935 try
1936 {
1937 ugrep();
1938 }
1939
1940 catch (reflex::regex_error& error)
1941 {
1942 what_.assign(error.what());
1943
1944 // error position in the pattern
1945 error_ = static_cast<int>(error.pos());
1946
1947 // subtract 4 for (?m) or (?misx)
1948 if (error_ >= 4 + flag_ignore_case + flag_dotall + flag_free_space)
1949 error_ -= 4 + flag_ignore_case + flag_dotall + flag_free_space;
1950
1951 // subtract 2 for -F
1952 if (flag_fixed_strings && error_ >= 2)
1953 error_ -= 2;
1954
1955 // subtract 2 or 3 for -x or -w
1956 if (flags_[27].flag && error_ >= 2)
1957 error_ -= 2;
1958 else if (flags_[25].flag && error_ >= 3)
1959 error_ -= 3;
1960 }
1961
1962 catch (std::exception& error)
1963 {
1964 what_.assign(error.what());
1965
1966 // error at the end of the line, not within
1967 error_ = line_wsize();
1968 }
1969
1970 fclose(Static::output);
1971 Static::output = NULL;
1972 }
1973 else
1974 {
1975 what_.assign("cannot fdopen pipe");
1976
1977 // error at the end of the line, not within
1978 error_ = line_wsize();
1979 }
1980}
1981
1982// cursor up
1983void Query::up()

Callers

nothing calls this directly

Calls 3

ugrepFunction · 0.85
assignMethod · 0.80
posMethod · 0.45

Tested by

no test coverage detected