Imported Upstream version 3.23.00
tony mancill
9 years ago
9 | 9 | #define CXX "g++" |
10 | 10 | // the compiler to use. |
11 | 11 | |
12 | #define CXXFLAGS "--std=c++0x -Wall -O2 -g" | |
12 | #define CXXFLAGS "--std=c++14 -Wall -O2 -g" | |
13 | 13 | // the compiler options to use. |
14 | 14 | |
15 | 15 | #define LDFLAGS "" |
0 | #define VERSION "3.22.09" | |
1 | #define YEARS "1994-2013" | |
0 | #define VERSION "3.23.00" | |
1 | #define YEARS "1994-2014" |
69 | 69 | void order(); |
70 | 70 | void update(size_t idx); |
71 | 71 | |
72 | // size_t beginHistory() const; | |
73 | // size_t endHistory() const; | |
74 | 72 | size_t separateAt() const; |
75 | 73 | |
76 | 74 | private: |
77 | 75 | static std::string getHome(); |
78 | 76 | |
79 | 77 | FBB::ArgConfig &configFile(); |
80 | ||
81 | ||
82 | 78 | |
83 | 79 | size_t set(char const *longKey, char const *const * const begin, |
84 | 80 | char const *const *const end, |
88 | 84 | |
89 | 85 | std::string determineInitialDirectory(); |
90 | 86 | void globFrom(std::string initial); |
87 | ||
88 | void checkCase(std::string &head, size_t *idx) const; | |
91 | 89 | |
92 | 90 | void add(char const *path); // also determines d_nPatterns |
93 | 91 | |
102 | 100 | void generalizedGlob(std::string initial, GlobContext &context); |
103 | 101 | void globHead(std::string const &initial, |
104 | 102 | std::string searchCmd, GlobContext &context); |
105 | void globPattern(std::string pattern, | |
106 | std::string const &searchCmd, size_t idx, | |
103 | void globPattern(std::string pattern, | |
104 | std::string &searchCmd, size_t *idx, | |
107 | 105 | GlobContext &context); |
108 | 106 | |
109 | 107 | static void globFilter(char const *entry, GlobContext &context); |
0 | #include "alternatives.ih" | |
1 | ||
2 | void Alternatives::checkCase(string &head, size_t *idx) const | |
3 | { | |
4 | if ((d_arg.option('i') & 1) != 0) // even number of --icase specs | |
5 | { | |
6 | string mold("[..]"); | |
7 | int ch = head[*idx]; | |
8 | if (isalpha(ch)) | |
9 | { | |
10 | mold[1] = tolower(ch); | |
11 | mold[2] = toupper(ch); | |
12 | head.replace(*idx, 1, mold); | |
13 | *idx += 4; | |
14 | return; | |
15 | } | |
16 | } | |
17 | ++*idx; | |
18 | } |
4 | 4 | try |
5 | 5 | { |
6 | 6 | for (size_t idx = 0; idx != searchCmd.length(); ) |
7 | globPattern(initial, searchCmd, ++idx, context); | |
7 | globPattern(initial, searchCmd, &idx, context); | |
8 | 8 | } |
9 | 9 | catch (bool headHasSlash) |
10 | 10 | {} |
21 | 21 | // If the tail starts with /, that char is ignored. |
22 | 22 | |
23 | 23 | void Alternatives::globPattern(string pattern, |
24 | string const &searchCmd, size_t idx, | |
24 | string &searchCmd, size_t *idx, | |
25 | 25 | GlobContext &context) |
26 | 26 | try |
27 | 27 | { |
28 | checkCase(searchCmd, idx); | |
29 | ||
28 | 30 | // create a pattern from pattern + initial substring |
29 | string head = searchCmd.substr(0, idx); | |
31 | string head = searchCmd.substr(0, *idx); | |
30 | 32 | |
31 | 33 | if (head.find('/') != string::npos) // ignore if head has a / |
32 | 34 | throw false; // caught by globHead |
33 | 35 | |
36 | ||
34 | 37 | pattern += head; |
35 | 38 | pattern += "*/"; // this pattern must exist |
36 | 39 | |
38 | 41 | imsg << "Pattern `" << pattern << "', " << glob.size() << |
39 | 42 | " matches" << endl; |
40 | 43 | |
41 | if (idx != searchCmd.length()) | |
44 | if (*idx != searchCmd.length()) | |
42 | 45 | { |
43 | string tail = searchCmd.substr(idx); | |
46 | string tail = searchCmd.substr(*idx); | |
44 | 47 | globHead(pattern, tail[0] == '/' ? tail.substr(1) : tail, context); |
45 | 48 | } |
46 | 49 | else |
12 | 12 | s_triState[d_addRoot] << endl; |
13 | 13 | |
14 | 14 | globFrom(determineInitialDirectory()); |
15 | ||
15 | ||
16 | 16 | sort(begin(), begin() + d_nInHistory); |
17 | 17 | sort(begin() + d_nInHistory, end()); |
18 | 18 | } |
18 | 18 | {"all", 'a'}, |
19 | 19 | {"config-file", 'c'}, |
20 | 20 | {"help", 'h'}, |
21 | {"icase", 'i'}, | |
21 | 22 | {"generalized-search", 'g'}, |
22 | 23 | {"version", 'v'}, |
23 | 24 | {"verbose", 'V'}, |
35 | 36 | if (last[idx] == '/') |
36 | 37 | last[idx] = 0; |
37 | 38 | |
38 | ArgConfig &arg = ArgConfig::initialize("ac:ghvV", | |
39 | ArgConfig &arg = ArgConfig::initialize("ac:gihvV", | |
39 | 40 | longOptions, longEnd, argc, argv); |
40 | 41 | arg.setCommentHandling(ArgConfig::RemoveComment); |
41 | 42 |
0 | #!/usr/bin/icmake -qt/tmp/bisonc++ | |
0 | #!/usr/bin/icmake -qt/tmp/xdbuild | |
1 | 1 | |
2 | 2 | #include "icmconf" |
3 | 3 |
0 | xd (3.23.00) | |
1 | ||
2 | * Added --icase (-i) allowing case insensitive directory matching | |
3 | ||
4 | * Changed compilation option --std=c++0x to --std=c++14 | |
5 | ||
6 | -- Frank B. Brokken <f.b.brokken@rug.nl> Thu, 11 Dec 2014 13:14:01 +0100 | |
7 | ||
0 | 8 | xd (3.22.09) |
1 | 9 | |
2 | 10 | * Added missing (since g++ 2.8.2) #include <sstream> to alternatives.ih |
256 | 256 | and new alternatives (not previously selected). This option is only |
257 | 257 | interpreted when the previous option is also specified. |
258 | 258 | |
259 | it() loption(icase) soption(i)nl() | |
260 | This option is used to specify case-insensitive pattern matching. E.g., | |
261 | specifying tt(xd /ub) returns the directory tt(/usr/bin), but not a directory | |
262 | like tt(/UnSpecified/Books), which is returned by tt(xd /UB). However, tt(xd | |
263 | -i /ub) (using any letter casing for the specification) returns both | |
264 | directories. The option tt(icase) could of course be specified in the | |
265 | configuration file, which which case case-insensitive matching is used by | |
266 | default. In the latter case specifying tt(-i) as a command line option reverts | |
267 | the matching procedure to case-sensitive directory matching. In general, when | |
268 | an even number of em(icase) specifications is provided bf(xd) uses | |
269 | case-sensitive directory matching, while an odd number of em(icase) | |
270 | specifications results in case-insensitive directory matching. | |
271 | ||
259 | 272 | it() loption(start-at) tt(origin)nl() |
260 | 273 | Defines the default start location of directory searches. Origin |
261 | 274 | tt(home) results in all default searches to start at the user's home |
365 | 378 | and new alternatives (not previously selected). This directive is only |
366 | 379 | interpreted when the previous directive is also specified. |
367 | 380 | |
381 | it() loption(icase) soption(i)nl() | |
382 | This specification is used to request case-insensitive pattern | |
383 | matching. If this option is entered in the configuration file then specifying | |
384 | tt(xd /ub) returns the directory tt(/usr/bin) as welll as a directory like | |
385 | (assuming it exists) tt(/UnSpecified/Books). When specified in the | |
386 | configuration file, the command-line option tt(-i) reverts the matching | |
387 | procedure back to case-sensitive directory matching. In general, when an even | |
388 | number of em(icase) specifications is provided bf(xd) uses case-sensitive | |
389 | directory matching, while an odd number of em(icase) specifications results in | |
390 | case-insensitive directory matching. | |
391 | ||
368 | 392 | it() bf(ignore) tt(path) nl() |
369 | 393 | The configuration file may contain multiple tt(ignore) directives |
370 | 394 | which are --different from the way other directives are handled-- all |
397 | 421 | bf(xd) for various shell programs. This allows the shell to change directories |
398 | 422 | under control of bf(xd). |
399 | 423 | |
400 | To use bf(xd) with the bf(bash)(1)-shell, the following script | |
401 | can be used (to be added to, e.g., tt(.profile)): | |
424 | To use bf(xd) with the bf(bash)(1)-shell, the following function | |
425 | can be used (which could be added to, e.g., tt(.bash_login)): | |
402 | 426 | verb( |
403 | 427 | xd() # function to do `cd` using `xd` |
404 | 428 | { |