proto: add regex support for skip=
This commit is contained in:
parent
a118f445d5
commit
1665b57e14
2 changed files with 11 additions and 8 deletions
|
@ -86,6 +86,7 @@ sys d775
|
||||||
include
|
include
|
||||||
+
|
+
|
||||||
lib d775
|
lib d775
|
||||||
|
skip=\.(pyo|pyc)$
|
||||||
+
|
+
|
||||||
log
|
log
|
||||||
man
|
man
|
||||||
|
@ -107,6 +108,7 @@ sys d775
|
||||||
8
|
8
|
||||||
*
|
*
|
||||||
src
|
src
|
||||||
|
skip=\.[ao]?[12578vqki]?$
|
||||||
+
|
+
|
||||||
tmp d555
|
tmp d555
|
||||||
usr d775
|
usr d775
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <auth.h>
|
#include <auth.h>
|
||||||
#include <fcall.h>
|
#include <fcall.h>
|
||||||
#include <disk.h>
|
#include <disk.h>
|
||||||
|
#include <regexp.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LEN = 8*1024,
|
LEN = 8*1024,
|
||||||
|
@ -32,7 +33,7 @@ struct Name {
|
||||||
typedef struct Opt Opt;
|
typedef struct Opt Opt;
|
||||||
struct Opt {
|
struct Opt {
|
||||||
int level;
|
int level;
|
||||||
char *skip;
|
Reprog *skip;
|
||||||
char *uid;
|
char *uid;
|
||||||
char *gid;
|
char *gid;
|
||||||
Opt *prev;
|
Opt *prev;
|
||||||
|
@ -187,9 +188,13 @@ mktree(Mkaux *mkaux, File *me, int rec)
|
||||||
child = *me;
|
child = *me;
|
||||||
while((n = dirread(fd, &d)) > 0){
|
while((n = dirread(fd, &d)) > 0){
|
||||||
for(i = 0; i < n; i++){
|
for(i = 0; i < n; i++){
|
||||||
if(mkaux->opt && mkaux->opt->skip)
|
if(mkaux->opt && mkaux->opt->skip){
|
||||||
if(strstr(d[i].name, mkaux->opt->skip))
|
Resub m[8];
|
||||||
|
|
||||||
|
memset(m, 0, sizeof(m));
|
||||||
|
if(regexec(mkaux->opt->skip, d[i].name, m, nelem(m)))
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
child.new = mkpath(mkaux, me->new, d[i].name);
|
child.new = mkpath(mkaux, me->new, d[i].name);
|
||||||
if(me->old)
|
if(me->old)
|
||||||
child.old = mkpath(mkaux, me->old, d[i].name);
|
child.old = mkpath(mkaux, me->old, d[i].name);
|
||||||
|
@ -330,8 +335,6 @@ setopt(Mkaux *mkaux, char *key, char *val)
|
||||||
longjmp(mkaux->jmp, 1);
|
longjmp(mkaux->jmp, 1);
|
||||||
if(mkaux->opt){
|
if(mkaux->opt){
|
||||||
*o = *mkaux->opt;
|
*o = *mkaux->opt;
|
||||||
if(o->skip)
|
|
||||||
o->skip = estrdup(mkaux, o->skip);
|
|
||||||
if(o->uid)
|
if(o->uid)
|
||||||
o->uid = estrdup(mkaux, o->uid);
|
o->uid = estrdup(mkaux, o->uid);
|
||||||
if(o->gid)
|
if(o->gid)
|
||||||
|
@ -344,8 +347,7 @@ setopt(Mkaux *mkaux, char *key, char *val)
|
||||||
} else if(mkaux->indent < o->level)
|
} else if(mkaux->indent < o->level)
|
||||||
return;
|
return;
|
||||||
if(strcmp(key, "skip") == 0){
|
if(strcmp(key, "skip") == 0){
|
||||||
free(o->skip);
|
o->skip = regcomp(val);
|
||||||
o->skip = *val ? estrdup(mkaux, val) : nil;
|
|
||||||
} else if(strcmp(key, "uid") == 0){
|
} else if(strcmp(key, "uid") == 0){
|
||||||
free(o->uid);
|
free(o->uid);
|
||||||
o->uid = *val ? estrdup(mkaux, val) : nil;
|
o->uid = *val ? estrdup(mkaux, val) : nil;
|
||||||
|
@ -364,7 +366,6 @@ popopt(Mkaux *mkaux)
|
||||||
if(o->level <= mkaux->indent)
|
if(o->level <= mkaux->indent)
|
||||||
break;
|
break;
|
||||||
mkaux->opt = o->prev;
|
mkaux->opt = o->prev;
|
||||||
free(o->skip);
|
|
||||||
free(o->uid);
|
free(o->uid);
|
||||||
free(o->gid);
|
free(o->gid);
|
||||||
free(o);
|
free(o);
|
||||||
|
|
Loading…
Reference in a new issue