aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/glob.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-12 15:12:59 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-12 15:12:59 +0200
commit7919aca84cdea7746b60fec9795e9617c266dd1d (patch)
tree90db8c7d899b69014d085af0cf3327741691df6a /src/glob.h
parent3551924ccd580a59190ac80e25c59b729ec4f613 (diff)
downloadsciteco-7919aca84cdea7746b60fec9795e9617c266dd1d.tar.gz
support UNIX-shell-like tilde-expansions in file names and directories
* expands to the value of $HOME (the env variable instead of the register which currently makes a slight difference). * supported for tab-completions * supported for all file-name accepting commands. The expansion is done centrally in StateExpectFile::done(). A new virtual method StateExpectFile::got_file() has been introduced to pass the expanded/processed file name to command implementations. * sciteco(7) has been updated: There is now a separate section on file name arguments and file name handling in SciTECO. This information is important but has been scattered across the document previously. * optimized is_glob_pattern() in glob.h
Diffstat (limited to 'src/glob.h')
-rw-r--r--src/glob.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/glob.h b/src/glob.h
index a289228..75361b8 100644
--- a/src/glob.h
+++ b/src/glob.h
@@ -18,8 +18,6 @@
#ifndef __GLOB_H
#define __GLOB_H
-#include <string.h>
-
#include <glib.h>
#include <glib/gstdio.h>
@@ -34,7 +32,16 @@ namespace SciTECO {
static inline bool
is_glob_pattern(const gchar *str)
{
- return strchr(str, '*') || strchr(str, '?');
+ if (!str)
+ return false;
+
+ while (*str) {
+ if (*str == '*' || *str == '?')
+ return true;
+ str++;
+ }
+
+ return false;
}
class Globber {
@@ -60,12 +67,12 @@ public:
StateGlob_pattern() : StateExpectFile(true, false) {}
private:
- State *done(const gchar *str);
+ State *got_file(const gchar *filename);
};
class StateGlob_filename : public StateExpectFile {
private:
- State *done(const gchar *str);
+ State *got_file(const gchar *filename);
};
namespace States {