Skip to content

Commit efc601e

Browse files
committed
released 7.3
1 parent 56780ab commit efc601e

31 files changed

+157
-122
lines changed

bin/win32/ug.exe

0 Bytes
Binary file not shown.

bin/win32/ugrep-indexer.exe

0 Bytes
Binary file not shown.

bin/win32/ugrep.exe

0 Bytes
Binary file not shown.

bin/win64/ug.exe

-1 KB
Binary file not shown.

bin/win64/ugrep-indexer.exe

0 Bytes
Binary file not shown.

bin/win64/ugrep.exe

-1 KB
Binary file not shown.

include/reflex/pattern.h

+15
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,21 @@ class Pattern {
12451245
{
12461246
return opcode & 0xffff;
12471247
}
1248+
/// check if lower case
1249+
static inline bool islowercase(Char c)
1250+
{
1251+
return (c >= 'a' && c <= 'z');
1252+
}
1253+
/// check if upper case
1254+
static inline bool isuppercase(Char c)
1255+
{
1256+
return (c >= 'A' && c <= 'Z');
1257+
}
1258+
/// check if lower or upper case
1259+
static inline bool isanycase(Char c)
1260+
{
1261+
return islowercase(c) || isuppercase(c);
1262+
}
12481263
/// convert to lower case if c is a letter a-z, A-Z.
12491264
static inline Char lowercase(Char c)
12501265
{

lib/pattern.cpp

+25-29
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ void Pattern::init(const char *options, const uint8_t *pred)
296296
for (DFA::State::Edges::iterator t = state->edges.begin(); t != state->edges.end(); ++t)
297297
{
298298
Char c = t->first;
299-
if (c >= 'a' && c <= 'z')
299+
if (islowercase(c))
300300
{
301301
state->edges[uppercase(c)] = DFA::State::Edge(uppercase(c), t->second.second);
302302
++eno_;
@@ -828,7 +828,7 @@ void Pattern::parse(
828828
c = static_cast<Char>(s - abtnvfr + '\a');
829829
}
830830
}
831-
else if (c >= 'A' && c <= 'Z' && opt_.i)
831+
else if (isuppercase(c) && opt_.i)
832832
{
833833
c = lowercase(c);
834834
}
@@ -1736,7 +1736,7 @@ void Pattern::compile(
17361736
Char c = t->first;
17371737
DFA::State *target_state = last_state = last_state->next = dfa_.state(t->second.second);
17381738
state->edges[c] = DFA::State::Edge(c, target_state);
1739-
if (c >= 'a' && c <= 'z')
1739+
if (islowercase(c))
17401740
{
17411741
state->edges[uppercase(c)] = DFA::State::Edge(uppercase(c), target_state);
17421742
++eno_;
@@ -1765,7 +1765,7 @@ void Pattern::compile(
17651765
{
17661766
Char c = t->first;
17671767
chars.add(c);
1768-
if (c >= 'a' && c <= 'z')
1768+
if (islowercase(c))
17691769
chars.add(uppercase(c));
17701770
}
17711771
}
@@ -1791,9 +1791,9 @@ void Pattern::compile(
17911791
{
17921792
if (common.contains(c))
17931793
{
1794-
if (std::isalpha(c))
1794+
if (isanycase(c))
17951795
{
1796-
if (c >= 'a' && c <= 'z')
1796+
if (islowercase(c))
17971797
{
17981798
pos = i->second;
17991799
DFA::State *target_state = last_state = last_state->next = dfa_.state(state->tnode->edges[c].second, pos);
@@ -1853,7 +1853,7 @@ void Pattern::compile(
18531853
if (chars.contains(c))
18541854
{
18551855
DFA::State *target_state = last_state = last_state->next = dfa_.state(state->tnode->edges[c].second);
1856-
if (std::isalpha(c))
1856+
if (isanycase(c))
18571857
{
18581858
state->edges[lowercase(c)] = DFA::State::Edge(lowercase(c), target_state);
18591859
state->edges[uppercase(c)] = DFA::State::Edge(uppercase(c), target_state);
@@ -1893,7 +1893,7 @@ void Pattern::compile(
18931893
DFA::State *target_state = last_state = last_state->next = dfa_.state(&t->second);
18941894
state->edges[c] = DFA::State::Edge(c, target_state);
18951895
++eno_;
1896-
if (opt_.i && c >= 'a' && c <= 'z')
1896+
if (opt_.i && islowercase(c))
18971897
{
18981898
state->edges[uppercase(c)] = DFA::State::Edge(uppercase(c), target_state);
18991899
++eno_;
@@ -1911,12 +1911,8 @@ void Pattern::compile(
19111911
for (std::map<Char,Tree::Node>::iterator t = state->tnode->edges.begin(); t != state->tnode->edges.end(); ++t)
19121912
{
19131913
Char c = t->first;
1914-
if (c >= 'a')
1915-
{
1916-
if (c > 'z')
1917-
break;
1914+
if (islowercase(c))
19181915
chars.add(uppercase(c));
1919-
}
19201916
}
19211917
}
19221918
Moves::iterator i = moves.begin();
@@ -1936,9 +1932,9 @@ void Pattern::compile(
19361932
{
19371933
if (common.contains(c))
19381934
{
1939-
if (std::isalpha(c))
1935+
if (isanycase(c))
19401936
{
1941-
if (c >= 'a' && c <= 'z')
1937+
if (islowercase(c))
19421938
{
19431939
pos = i->second;
19441940
DFA::State *target_state = last_state = last_state->next = dfa_.state(&state->tnode->edges[c], pos);
@@ -1996,7 +1992,7 @@ void Pattern::compile(
19961992
if (chars.contains(c))
19971993
{
19981994
DFA::State *target_state = last_state = last_state->next = dfa_.state(&state->tnode->edges[c]);
1999-
if (opt_.i && std::isalpha(c))
1995+
if (opt_.i && isanycase(c))
20001996
{
20011997
state->edges[lowercase(c)] = DFA::State::Edge(lowercase(c), target_state);
20021998
state->edges[uppercase(c)] = DFA::State::Edge(uppercase(c), target_state);
@@ -2027,7 +2023,7 @@ void Pattern::compile(
20272023
{
20282024
Char c = (i << 4) + j;
20292025
DFA::State *target_state = last_state = last_state->next = dfa_.state(p[j]);
2030-
if (opt_.i && std::isalpha(c))
2026+
if (opt_.i && isanycase(c))
20312027
{
20322028
state->edges[lowercase(c)] = DFA::State::Edge(lowercase(c), target_state);
20332029
state->edges[uppercase(c)] = DFA::State::Edge(uppercase(c), target_state);
@@ -2083,9 +2079,9 @@ void Pattern::compile(
20832079
{
20842080
if (common.contains(c))
20852081
{
2086-
if (std::isalpha(c))
2082+
if (isanycase(c))
20872083
{
2088-
if (c >= 'a' && c <= 'z')
2084+
if (islowercase(c))
20892085
{
20902086
pos = i->second;
20912087
DFA::State *target_state = last_state = last_state->next = dfa_.state(state->tnode->edge[c >> 4][c & 0xf], pos);
@@ -2143,7 +2139,7 @@ void Pattern::compile(
21432139
if (chars.contains(c))
21442140
{
21452141
DFA::State *target_state = last_state = last_state->next = dfa_.state(state->tnode->edge[c >> 4][c & 0xf]);
2146-
if (opt_.i && std::isalpha(c))
2142+
if (opt_.i && isanycase(c))
21472143
{
21482144
state->edges[lowercase(c)] = DFA::State::Edge(lowercase(c), target_state);
21492145
state->edges[uppercase(c)] = DFA::State::Edge(uppercase(c), target_state);
@@ -2456,10 +2452,10 @@ void Pattern::compile_transition(
24562452
Chars chars;
24572453
if (literal)
24582454
{
2459-
if (std::isalpha(c) && is_modified(ModConst::i, modifiers, loc))
2455+
if (isanycase(c) && is_modified(ModConst::i, modifiers, loc))
24602456
{
2461-
chars.add(uppercase(c));
24622457
chars.add(lowercase(c));
2458+
chars.add(uppercase(c));
24632459
}
24642460
else
24652461
{
@@ -2499,10 +2495,10 @@ void Pattern::compile_transition(
24992495
switch (escape_at(loc))
25002496
{
25012497
case '\0': // no escape at current loc
2502-
if (std::isalpha(c) && is_modified(ModConst::i, modifiers, loc))
2498+
if (isanycase(c) && is_modified(ModConst::i, modifiers, loc))
25032499
{
2504-
chars.add(uppercase(c));
25052500
chars.add(lowercase(c));
2501+
chars.add(uppercase(c));
25062502
}
25072503
else
25082504
{
@@ -2539,10 +2535,10 @@ void Pattern::compile_transition(
25392535
break;
25402536
default:
25412537
c = parse_esc(loc, &chars);
2542-
if (c <= 'z' && std::isalpha(c) && is_modified(ModConst::i, modifiers, loc))
2538+
if (isanycase(c) && is_modified(ModConst::i, modifiers, loc))
25432539
{
2544-
chars.add(uppercase(c));
25452540
chars.add(lowercase(c));
2541+
chars.add(uppercase(c));
25462542
}
25472543
}
25482544
}
@@ -2667,7 +2663,7 @@ void Pattern::compile_list(Location loc, Chars& chars, const Mods modifiers) con
26672663
{
26682664
if (is_modified(ModConst::i, modifiers, loc))
26692665
{
2670-
if (lo >= 'a' && lo <= 'z' && c >= 'A' && c <= 'Z')
2666+
if (islowercase(lo) && isuppercase(c))
26712667
c = lowercase(c);
26722668
Char a = lo;
26732669
Char b = c;
@@ -2691,10 +2687,10 @@ void Pattern::compile_list(Location loc, Chars& chars, const Mods modifiers) con
26912687
}
26922688
else
26932689
{
2694-
if (std::isalpha(c) && is_modified(ModConst::i, modifiers, loc))
2690+
if (isanycase(c) && is_modified(ModConst::i, modifiers, loc))
26952691
{
2696-
chars.add(uppercase(c));
26972692
chars.add(lowercase(c));
2693+
chars.add(uppercase(c));
26982694
}
26992695
else
27002696
{

man.sh

+15-13
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ regular expression matches one or more newlines. An empty pattern matches
3232
every line. Each input line that matches at least one of the patterns is
3333
written to the standard output.
3434
.PP
35-
The \fBug\fR command is intended for interactive searching, using a .ugrep
36-
configuration file located in the working directory or home directory, see
37-
CONFIGURATION. \fBug\fR is equivalent to \fBugrep --config --pretty --sort\fR
38-
to load a .ugrep file, enhance the terminal output, and sort files by name.
35+
The \fBug\fR command is intended for interactive searching, using a `.ugrep'
36+
configuration file located in the working directory or, if not found, in the
37+
home directory, see CONFIGURATION. \fBug\fR is equivalent to \fBugrep --config
38+
--pretty --sort\fR to load a configuration file, enhance the terminal output,
39+
and to sort files by name.
3940
.PP
4041
The \fBugrep+\fR and \fBug+\fR commands are the same as the \fBugrep\fR and
4142
\fBug\fR commands, but also use filters to search pdfs, documents, e-books,
@@ -179,10 +180,10 @@ An error occurred.
179180
If \fB-q\fR or \fB--quiet\fR or \fB--silent\fR is used and a line is selected,
180181
the exit status is 0 even if an error occurred.
181182
.SH CONFIGURATION
182-
The \fBug\fR command is intended for context-dependent interactive searching
183-
and is equivalent to the \fBugrep --config --pretty --sort\fR command to load
184-
the default configuration file `.ugrep' when present in the working directory
185-
or in the home directory.
183+
The \fBug\fR command is intended for interactive searching and is equivalent to
184+
the \fBugrep --config --pretty --sort\fR command to load the `.ugrep`
185+
configuration file located in the working directory or, when not found, in the
186+
home directory.
186187
.PP
187188
A configuration file contains `NAME=VALUE' pairs per line, where `NAME` is the
188189
name of a long option (without `--') and `=VALUE' is an argument, which is
@@ -191,18 +192,19 @@ starting with a `#' are ignored.
191192
.PP
192193
The \fB--config\fR=\fIFILE\fR option and its abbreviated form
193194
\fB---\fR\fIFILE\fR load the specified configuration file located in the
194-
working directory or, when not found, located in the home directory. An error
195-
is produced when \fIFILE\fR is not found or cannot be read.
195+
working directory or, when not found, in the home directory. An error is
196+
produced when \fIFILE\fR is not found or cannot be read.
196197
.PP
197198
Command line options are parsed in the following order: the configuration file
198199
is loaded first, followed by the remaining options and arguments on the command
199200
line.
200201
.PP
201202
The \fB--save-config\fR option saves a `.ugrep' configuration file to the
202203
working directory with a subset of the options specified on the command line.
203-
The \fB--save-config\fR=\fIFILE\fR option saves the configuration to
204-
\fIFILE\fR. The configuration is written to standard output when \fIFILE\fR is
205-
a `-'.
204+
Only part of the specified options are saved that do not cause searches to fail
205+
when combined with other options. The \fB--save-config\fR=\fIFILE\fR option
206+
saves the configuration to \fIFILE\fR. The configuration is written to
207+
standard output when \fIFILE\fR is a `-'.
206208
.SH GLOBBING
207209
Globbing is used by options \fB-g\fR, \fB--include\fR, \fB--include-dir\fR,
208210
\fB--include-from\fR, \fB--exclude\fR, \fB--exclude-dir\fR,

man/ug.1

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH UGREP "1" "March 01, 2025" "ugrep 7.3.0" "User Commands"
1+
.TH UGREP "1" "March 03, 2025" "ugrep 7.3.0" "User Commands"
22
.SH NAME
33
\fBugrep\fR, \fBug\fR -- file pattern searcher
44
.SH SYNOPSIS
@@ -17,10 +17,11 @@ regular expression matches one or more newlines. An empty pattern matches
1717
every line. Each input line that matches at least one of the patterns is
1818
written to the standard output.
1919
.PP
20-
The \fBug\fR command is intended for interactive searching, using a .ugrep
21-
configuration file located in the working directory or home directory, see
22-
CONFIGURATION. \fBug\fR is equivalent to \fBugrep --config --pretty --sort\fR
23-
to load a .ugrep file, enhance the terminal output, and sort files by name.
20+
The \fBug\fR command is intended for interactive searching, using a `.ugrep'
21+
configuration file located in the working directory or, if not found, in the
22+
home directory, see CONFIGURATION. \fBug\fR is equivalent to \fBugrep --config
23+
--pretty --sort\fR to load a configuration file, enhance the terminal output,
24+
and to sort files by name.
2425
.PP
2526
The \fBugrep+\fR and \fBug+\fR commands are the same as the \fBugrep\fR and
2627
\fBug\fR commands, but also use filters to search pdfs, documents, e-books,
@@ -257,8 +258,8 @@ Use configuration FILE. The default FILE is `.ugrep'. The working
257258
directory is checked first for FILE, then the home directory. The
258259
options specified in the configuration FILE are parsed first,
259260
followed by the remaining options specified on the command line.
260-
The ug command automatically loads a `.ugrep' configuration file,
261-
unless \fB\-\-config\fR=\fIFILE\fR or \fB\-\-no\-config\fR is specified.
261+
The ug command automatically loads a `.ugrep' configuration file
262+
when present, unless \fB\-\-config\fR=\fIFILE\fR or \fB\-\-no\-config\fR is specified.
262263
.TP
263264
\fB\-\-no\-config\fR
264265
Do not automatically load the default .ugrep configuration file.
@@ -775,8 +776,8 @@ which is automatically loaded by the ug command. When FILE is a
775776
OPTIONS are saved that do not cause searches to fail when combined
776777
with other options. Additional options may be specified by editing
777778
the saved configuration file. A configuration file may be modified
778-
manually to specify one or more config[=\fIFILE\fR] to indirectly load
779-
the specified FILE, but recursive config loading is not allowed.
779+
by adding one or more config=\fIFILE\fR to include configuration files,
780+
but recursive configuration file inclusion is not permitted.
780781
.TP
781782
\fB\-\-separator\fR[=\fISEP\fR], \fB\-\-context\-separator\fR=\fISEP\fR
782783
Use SEP as field separator between file name, line number, column
@@ -968,10 +969,10 @@ An error occurred.
968969
If \fB-q\fR or \fB--quiet\fR or \fB--silent\fR is used and a line is selected,
969970
the exit status is 0 even if an error occurred.
970971
.SH CONFIGURATION
971-
The \fBug\fR command is intended for context-dependent interactive searching
972-
and is equivalent to the \fBugrep --config --pretty --sort\fR command to load
973-
the default configuration file `.ugrep' when present in the working directory
974-
or in the home directory.
972+
The \fBug\fR command is intended for interactive searching and is equivalent to
973+
the \fBugrep --config --pretty --sort\fR command to load the `.ugrep`
974+
configuration file located in the working directory or, when not found, in the
975+
home directory.
975976
.PP
976977
A configuration file contains `NAME=VALUE' pairs per line, where `NAME` is the
977978
name of a long option (without `--') and `=VALUE' is an argument, which is
@@ -980,18 +981,19 @@ starting with a `#' are ignored.
980981
.PP
981982
The \fB--config\fR=\fIFILE\fR option and its abbreviated form
982983
\fB---\fR\fIFILE\fR load the specified configuration file located in the
983-
working directory or, when not found, located in the home directory. An error
984-
is produced when \fIFILE\fR is not found or cannot be read.
984+
working directory or, when not found, in the home directory. An error is
985+
produced when \fIFILE\fR is not found or cannot be read.
985986
.PP
986987
Command line options are parsed in the following order: the configuration file
987988
is loaded first, followed by the remaining options and arguments on the command
988989
line.
989990
.PP
990991
The \fB--save-config\fR option saves a `.ugrep' configuration file to the
991992
working directory with a subset of the options specified on the command line.
992-
The \fB--save-config\fR=\fIFILE\fR option saves the configuration to
993-
\fIFILE\fR. The configuration is written to standard output when \fIFILE\fR is
994-
a `-'.
993+
Only part of the specified options are saved that do not cause searches to fail
994+
when combined with other options. The \fB--save-config\fR=\fIFILE\fR option
995+
saves the configuration to \fIFILE\fR. The configuration is written to
996+
standard output when \fIFILE\fR is a `-'.
995997
.SH GLOBBING
996998
Globbing is used by options \fB-g\fR, \fB--include\fR, \fB--include-dir\fR,
997999
\fB--include-from\fR, \fB--exclude\fR, \fB--exclude-dir\fR,

man/ugrep-indexer.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH UGREP-INDEXER "1" "March 01, 2025" "ugrep-indexer 7.3.0" "User Commands"
1+
.TH UGREP-INDEXER "1" "March 03, 2025" "ugrep-indexer 7.3.0" "User Commands"
22
.SH NAME
33
\fBugrep-indexer\fR -- file indexer to accelerate recursive searching
44
.SH SYNOPSIS

0 commit comments

Comments
 (0)