#include <string.h>
#include <unistd.h>
#include <glob.h>
+#include <libgen.h>
#include "lkc.h"
static int text_size, text_asize;
struct buffer {
- struct buffer *parent;
- YY_BUFFER_STATE state;
+ struct buffer *parent;
+ YY_BUFFER_STATE state;
};
struct buffer *current_buf;
}
%}
-ws [ \n\t]
n [A-Za-z0-9_]
%%
glob_t gl;
int err;
int i;
+ char path[PATH_MAX], *p;
err = glob(name, GLOB_ERR | GLOB_MARK, NULL, &gl);
+
+ /* ignore wildcard patterns that return no result */
+ if (err == GLOB_NOMATCH && strchr(name, '*')) {
+ err = 0;
+ gl.gl_pathc = 0;
+ }
+
+ if (err == GLOB_NOMATCH) {
+ p = strdup(current_file->name);
+ if (p) {
+ snprintf(path, sizeof(path), "%s/%s", dirname(p), name);
+ err = glob(path, GLOB_ERR | GLOB_MARK, NULL, &gl);
+ free(p);
+ }
+ }
+
if (err) {
const char *reason = "unknown error";