Codebase list xd / upstream/3.23.00
Imported Upstream version 3.23.00 tony mancill 9 years ago
11 changed file(s) with 72 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
99 #define CXX "g++"
1010 // the compiler to use.
1111
12 #define CXXFLAGS "--std=c++0x -Wall -O2 -g"
12 #define CXXFLAGS "--std=c++14 -Wall -O2 -g"
1313 // the compiler options to use.
1414
1515 #define LDFLAGS ""
0 #define VERSION "3.22.09"
1 #define YEARS "1994-2013"
0 #define VERSION "3.23.00"
1 #define YEARS "1994-2014"
6969 void order();
7070 void update(size_t idx);
7171
72 // size_t beginHistory() const;
73 // size_t endHistory() const;
7472 size_t separateAt() const;
7573
7674 private:
7775 static std::string getHome();
7876
7977 FBB::ArgConfig &configFile();
80
81
8278
8379 size_t set(char const *longKey, char const *const * const begin,
8480 char const *const *const end,
8884
8985 std::string determineInitialDirectory();
9086 void globFrom(std::string initial);
87
88 void checkCase(std::string &head, size_t *idx) const;
9189
9290 void add(char const *path); // also determines d_nPatterns
9391
102100 void generalizedGlob(std::string initial, GlobContext &context);
103101 void globHead(std::string const &initial,
104102 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,
107105 GlobContext &context);
108106
109107 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 }
44 try
55 {
66 for (size_t idx = 0; idx != searchCmd.length(); )
7 globPattern(initial, searchCmd, ++idx, context);
7 globPattern(initial, searchCmd, &idx, context);
88 }
99 catch (bool headHasSlash)
1010 {}
2121 // If the tail starts with /, that char is ignored.
2222
2323 void Alternatives::globPattern(string pattern,
24 string const &searchCmd, size_t idx,
24 string &searchCmd, size_t *idx,
2525 GlobContext &context)
2626 try
2727 {
28 checkCase(searchCmd, idx);
29
2830 // create a pattern from pattern + initial substring
29 string head = searchCmd.substr(0, idx);
31 string head = searchCmd.substr(0, *idx);
3032
3133 if (head.find('/') != string::npos) // ignore if head has a /
3234 throw false; // caught by globHead
3335
36
3437 pattern += head;
3538 pattern += "*/"; // this pattern must exist
3639
3841 imsg << "Pattern `" << pattern << "', " << glob.size() <<
3942 " matches" << endl;
4043
41 if (idx != searchCmd.length())
44 if (*idx != searchCmd.length())
4245 {
43 string tail = searchCmd.substr(idx);
46 string tail = searchCmd.substr(*idx);
4447 globHead(pattern, tail[0] == '/' ? tail.substr(1) : tail, context);
4548 }
4649 else
1212 s_triState[d_addRoot] << endl;
1313
1414 globFrom(determineInitialDirectory());
15
15
1616 sort(begin(), begin() + d_nInHistory);
1717 sort(begin() + d_nInHistory, end());
1818 }
1818 {"all", 'a'},
1919 {"config-file", 'c'},
2020 {"help", 'h'},
21 {"icase", 'i'},
2122 {"generalized-search", 'g'},
2223 {"version", 'v'},
2324 {"verbose", 'V'},
3536 if (last[idx] == '/')
3637 last[idx] = 0;
3738
38 ArgConfig &arg = ArgConfig::initialize("ac:ghvV",
39 ArgConfig &arg = ArgConfig::initialize("ac:gihvV",
3940 longOptions, longEnd, argc, argv);
4041 arg.setCommentHandling(ArgConfig::RemoveComment);
4142
0 #!/usr/bin/icmake -qt/tmp/bisonc++
0 #!/usr/bin/icmake -qt/tmp/xdbuild
11
22 #include "icmconf"
33
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
08 xd (3.22.09)
19
210 * Added missing (since g++ 2.8.2) #include <sstream> to alternatives.ih
256256 and new alternatives (not previously selected). This option is only
257257 interpreted when the previous option is also specified.
258258
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
259272 it() loption(start-at) tt(origin)nl()
260273 Defines the default start location of directory searches. Origin
261274 tt(home) results in all default searches to start at the user's home
365378 and new alternatives (not previously selected). This directive is only
366379 interpreted when the previous directive is also specified.
367380
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
368392 it() bf(ignore) tt(path) nl()
369393 The configuration file may contain multiple tt(ignore) directives
370394 which are --different from the way other directives are handled-- all
397421 bf(xd) for various shell programs. This allows the shell to change directories
398422 under control of bf(xd).
399423
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)):
402426 verb(
403427 xd() # function to do `cd` using `xd`
404428 {