Codebase list xd / f4233af
New upstream version 3.27.00 Frank B. Brokken 5 years ago
12 changed file(s) with 114 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
00 #define PROJECT "xd"
11 #define CXX "g++"
2 #define CXXFLAGS "--std=c++14 -fdiagnostics-color=never -Wall -O2 -g"
2 #define CXXFLAGS "--std=c++2a -fdiagnostics-color=never -Wall -O2 -g"
33 #define LDFLAGS ""
44 #define CPOPTS
55
0 #define VERSION "3.26.01"
1 #define YEARS "1994-2018"
0 #define VERSION "3.27.00"
1 #define YEARS "1994-2019"
2525 GlobContext &context)
2626 try
2727 {
28 checkCase(searchCmd, idx);
28 checkCase(searchCmd, idx);
2929
3030 // create a pattern from pattern + initial substring
3131 string head = searchCmd.substr(0, *idx);
33 {
44 ArgConfig::LongOption longOptions[] =
55 {
6 {"add-root", ArgConfig::Required},
7 {"directories", ArgConfig::Required},
8 {"start-at", ArgConfig::Required},
6 {"add-root", ArgConfig::Required},
7 {"directories", ArgConfig::Required},
8 {"homedir-char", ArgConfig::Required},
9 {"start-at", ArgConfig::Required},
910
1011 {"history", ArgConfig::Optional},
1112 {"history-lifetime", ArgConfig::Required},
0 xd (3.27.00)
1
2 * Added option --homedir-char and configuration file directive homedir-char
3 to specify a non-default homedir specification character.
4
5 * Updated the man-page (also its section `ABOUT xd').
6
7 * Compilation using the `build' script uses g++-2a.
8
9 -- Frank B. Brokken <f.b.brokken@rug.nl> Wed, 23 Jan 2019 11:44:19 +0100
10
011 xd (3.26.01)
112
213 * Migrated from Github to Gitlab.
99 class Command: public std::vector<std::string>
1010 // stores the elements of the pattern
1111 {
12 int d_homedirChar = '.'; // default homedir char
1213 std::string d_arguments;
1314 static char const *s_action[];
1415 static char const s_separators[]; // separating parts of nested dir
66 #include <bobcat/argconfig>
77 #include <bobcat/string>
88 #include <bobcat/mstream>
9 #include <bobcat/exception>
910
1011 using namespace std;
1112 using namespace FBB;
44 d_action(FROM_HOME),
55 d_parent(0)
66 {
7 ArgConfig &argConfig = ArgConfig::instance();
8
9 if (string value; argConfig.option(&value, "homedir-char"))
10 {
11 d_homedirChar = value[0];
12 if ("0123456789/"s.find(d_homedirChar) != string::npos)
13 throw Exception{ 1 } << "Character `" << value[0] <<
14 "' cannot be used as homedir-character";
15 }
16
717 concatArgs();
818
919 determineAction();
00 #include "command.ih"
11
22 void Command::determineAction()
3 {
4 switch (int ch = d_arguments[0]) // Interpret the first character
3 {
4 switch (int ch = d_arguments[0]) // Interpret the first character
55 {
66 case '0': // from parent 0 or cwd
77 d_action = FROM_CWD;
8 break;
9
10 case '.': // from HOME
11 d_action = FROM_HOME;
128 break;
139
1410 case '/': // explicitly from the root
2117 d_action = FROM_PARENT;
2218 break;
2319
24 // other characters: 1st char. of directory
20 // other characters: 1st char. of directory or homedir char.
2521 default:
26 // {
27 // bool firstIsSeparator = (ch == '_');
28 // if (firstIsSeparator)
29 // d_arguments.erase(0, 1); // remove the 1st char
30 d_action = FROM_CONFIG;
22 if (ch == d_homedirChar)
23 {
24 d_action = FROM_HOME;
25 break;
26 }
27
28 d_action = FROM_CONFIG;
3129 return;
32 // return firstIsSeparator;
33 // }
3430 }
3531
3632 do
7676 tt(/) then all expansions are performed from the system's root
7777 directory. E.g., tt(xd /t) results in tt(/tmp) but not in tt(/home/user/tmp).
7878 it() Initial character bf(.): If the first character of the command is
79 tt(.) then all expansions are performed from the user's home directory. E.g.,
80 tt(xd .t) results in tt(/home/user/tmp) but not in tt(/tmp)
79 tt(.) then by default all expansions are performed from the user's home
80 directory. E.g., tt(xd .t) results in tt(/home/user/tmp) but not in
81 tt(/tmp). The home directory recognition character can be altered using the
82 tt(--homedir-char) option, see below (section bf(OPTIONS)).
8183 it() Initial character bf(0): If the first character of the command is
8284 tt(0), then all expansions start at the current working directory. In fact,
8385 this is a specialization of the following, more general form:
8890 tt(xd 2lb) will offer the alternative tt(/usr/local/bin): two steps up, then
8991 look for directories starting with tt(l) and therein directories starting with
9092 tt(b).
91 it() Separators (space, and the forward slash (tt( ), and /)):
92 sometimes it is clear that there are many alternatives and the intention is to
93 reduce that number. By using separators subsequently nested directories must
94 start with the characters between the separators. E.g., tt(xd u l bi) never
95 produces the alternative tt(/usr/lib/base-config) anymore, since
96 tt(base-config) does not start with tt(bi). In this case only
97 tt(/usr/local/bin) is produced. When used as initial character in a pattern
98 the forward slash always indicates the root-directory.
93 it() Separators (space, and the forward slash (`tt(/)'): sometimes it is
94 clear that there are many alternatives and the intention is to reduce that
95 number. By using separators subsequently nested directories must start with
96 the characters between the separators. E.g., tt(xd u l bi) never produces the
97 alternative tt(/usr/lib/base-config) anymore, since tt(base-config) does not
98 start with tt(bi). In this case only tt(/usr/local/bin) is produced. When used
99 as initial character in a pattern the forward slash always indicates the
100 root-directory.
99101 COMMENT(
100102 Separators may be mixed (tt(xd u/l bi) is identical to tt(xd u l
101103 bi)). Since the tt(/) can also be used as a root-directory specification,
215217 the list of alternatives. There is also a configuration file directive
216218 tt(directories) (see below).
217219
220 it() loption(homedir-char) tt(ch)nl()
221 By default an initial dot character (`tt(.)') initiates a search from
222 the user's home directory. There is a slight disadvantage to using the dot, as
223 it is also be the initial character of `hidden' directories. Assuming that you
224 have a directory tt(~/.ssh) then the command to xd to that directory would be
225 tt(xd ..s), the first dot being the home directory indicator, after which
226 tt(.s) is used to find tt(.ssh). The option tt(--homedir-char) can be used to
227 specify another character. Homedir characters cannot be digits or a slash
228 (`tt(/)') as these are used to specify, respectively, parent directories and
229 the computer's root directory. Characters like ``tt(, @ % ^)'' or maybe
230 `tt(H)' (assuming that it doesn't interfere with an existing directory
231 beginning with tt(H)) could be used as homedir-characters, other than the
232 default dot character.
233
234 Caveat: command shells by default interpret characters like ``tt(~ $ \ ' " ` <
235 > |)'' etc., which therefore should probably not be specified as
236 home directory specifiers.
237
238 There is also a configuration file directive tt(homedir-char) (see below).
239
218240 it() loption(generalized-search) soption(g)nl()
219241 When this option is specified bf(xd) uses GDS unless the
220242 directive tt(traditional) is specified in the configuration file.
332354 performed if the initial search (starting at the user's home directory) did
333355 not yield any directory.nl()
334356 If it is specified as tt(never) no additional search is
335 performed.nl()
357 performed.
358
336359 This directive is overruled by the tt(---add-root) command line option.
337360
338361 it() bf(directories) tt(which) (all)nl()
339362 Directories may be also be reached via symbolic links. The
340363 specification tt(all) will add these symbolic links to the list of
341364 alternatives. The specification tt(unique) will prevent the symbolic links
342 from being added to the list of alternatives.nl()
365 from being added to the list of alternatives.
366
343367 This directive is overruled by the tt(---directories) command line option.
368
369 it() bf(homedir-char) tt(ch)nl()
370 By default an initial dot character (`tt(.)') initiates a search from
371 the user's home directory. There is a slight disadvantage to using the dot, as
372 it is also be the initial character of `hidden' directories. Assuming that you
373 have a directory tt(~/.ssh) then the command to xd to that directory would be
374 tt(xd ..s), the first dot being the home directory indicator, after which
375 tt(.s) is used to find tt(.ssh). The specification tt(homedir-char ch) can be
376 used to specify another home directory indicating character tt(ch), as in:
377 verb(
378 homedir-char ,
379 )
380 Homedir characters cannot be digits or a
381 slash (`tt(/)') as these are used to specify, respectively, parent directories
382 and the computer's root directory. Characters like ``tt(, @ % ^)'' or maybe
383 `tt(H)' (assuming that it doesn't interfere with an existing directory
384 beginning with tt(H)) could be used as homedir-characters, other than the
385 default dot character.
386
387 Caveat: command shells by default interpret characters like ``tt(~ $ \ ' " ` <
388 > |)'' etc., which therefore should probably not be specified as
389 home directory specifiers.
390
391 This directive is overruled by the tt(---homedir-char) command line option.
344392
345393 it() bf(generalized-search) nl()
346394 When this directive is specified bf(xd) will use GDS by default.
406454 matching any of the tt(ignore) directives (with the tt(*) interpreted as `any
407455 further directory name' specification) it will not display that path in its
408456 list of alternatives.
457
409458 This directive is overruled by the tt(---all) command line option.
410459
411460 it() bf(start-at) tt(value) (home) nl()
413462 are tt(home) and tt(root). When tt(home) is specified all searches start at
414463 the user's home directory. When tt(root) is specified searches start at the
415464 disk's root (tt(/)) directory. If the directory is omitted or if another value
416 is specified then the default is used, which is tt(home). This directive is
417 overruled by the tt(---start-at) command line option.
465 is specified then the default is used, which is tt(home).
466
467 This directive is overruled by the tt(---start-at) command line option.
418468
419469 it() bf(traditional) nl()
420470 This directive may be used to request the use of bf(xd)'s traditional
509559 manpagesection(ABOUT xd)
510560
511561 The program bf(xd) was initially (before 1994) written for the MS-DOS
512 platform. In 1994 it was designed to work under Unix (Linux, AIX) and it was
513 converted to bf(C++). The original bf(C++) code is still available
514 (tt(https://oosix.icce.rug.nl/svnroot/xd/tags/start/xd/)) and is funny to look
515 at as it is a remarkable illustration of bf(C++) code written by bf(C)
516 programmers who had just learned about bf(C++). Versions tt(2.x) have been
517 used until 2008, and in late August 2008 I rewrote bf(xd) completely,
518 reflecting my current views about bf(C++), resulting in versions tt(3.x.y) and
519 beyond. The tt(3.x.y) and later versions extensively use the facilities
520 offered by the bf(bobcat)(7) library.
562 platform. In 1994 it was redesigned to work under Unix (Linux, AIX) and it was
563 converted to bf(C++). The original bf(C++) code is still available from tag
564 tt(start) (tt(https://gitlab.com/fbb-git/xd/tags), find the tt(start) tag and
565 download) and is funny to look at as it is a remarkable illustration of
566 bf(C++) code written by bf(C) programmers who had just learned about
567 bf(C++). Versions tt(2.x) were used until 2008, and in late August 2008 I
568 rewrote bf(xd) completely, reflecting my then views about bf(C++), eventually
569 resulting in versions tt(3.x.y) and beyond. The tt(3.x.y) and later versions
570 extensively use the facilities offered by the bf(bobcat)(7) library.
521571
522572 manpagesection(ACKNOWLEDGEMENTS)
523573
0 /* xd.cc
1
2 A C++ main()-frame generated by cpp.im for xd.cc
3 */
4
50 #include "main.ih" // program header file
61
72 int main(int argc, char **argv)
+0
-2
release.yo less more
0 SUBST(_CurVers_)(3.26.00)
1 SUBST(_CurYrs_)(1994-2017)