Added prefix-length optional return from Strcmp. - sam - An updated version of … | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 4f6b0d8ce54e4cfb281246704368631baf66dc6e | |
parent 7f350c19ce7da08c0151abf5228ebe083d6d6826 | |
Author: Rob King <[email protected]> | |
Date: Wed, 25 May 2016 21:56:46 -0500 | |
Added prefix-length optional return from Strcmp. | |
Diffstat: | |
sam/io.c | 2 +- | |
sam/multi.c | 5 +++-- | |
sam/regexp.c | 2 +- | |
sam/sam.c | 4 ++-- | |
sam/sam.h | 2 +- | |
sam/string.c | 7 +++++-- | |
6 files changed, 13 insertions(+), 9 deletions(-) | |
--- | |
diff --git a/sam/io.c b/sam/io.c | |
@@ -31,7 +31,7 @@ writef(File *f) | |
long mtime, appendonly, length; | |
newfile = 0; | |
- samename = Strcmp(&genstr, &f->name) == 0; | |
+ samename = Strcmp(&genstr, &f->name, NULL) == 0; | |
name = Strtoc(&f->name); | |
i = statfile(name, &dev, &qid, &mtime, 0, 0); | |
if(i == -1) | |
diff --git a/sam/multi.c b/sam/multi.c | |
@@ -53,7 +53,7 @@ sortname(File *f) | |
if(f == cmd) | |
i = 0; | |
else for(i=0; i<file.nused; i++){ | |
- cmp = Strcmp(&f->name, &file.filepptr[i]->name); | |
+ cmp = Strcmp(&f->name, &file.filepptr[i]->name, NULL); | |
if(cmp==0 && !dupwarned){ | |
dupwarned = TRUE; | |
warn_S(Wdupname, &f->name); | |
@@ -83,9 +83,10 @@ File * | |
lookfile(String *s) | |
{ | |
int i; | |
+ String *b; | |
for(i=0; i<file.nused; i++) | |
- if(Strcmp(&file.filepptr[i]->name, s) == 0) | |
+ if(Strcmp(&file.filepptr[i]->name, s, NULL) == 0) | |
return file.filepptr[i]; | |
return 0; | |
} | |
diff --git a/sam/regexp.c b/sam/regexp.c | |
@@ -181,7 +181,7 @@ compile(String *s) | |
int i; | |
Inst *oprogp; | |
- if(Strcmp(s, &lastregexp)==0) | |
+ if(Strcmp(s, &lastregexp, NULL)==0) | |
return; | |
for(i=0; i<nclass; i++) | |
free(class[i]); | |
diff --git a/sam/sam.c b/sam/sam.c | |
@@ -324,7 +324,7 @@ edit(File *f, int cmd) | |
if(cmd=='e' || cmd=='I'){ | |
Fdelete(f, (Posn)0, f->nrunes); | |
addr.r.p2 = f->nrunes; | |
- }else if(f->nrunes!=0 || (f->name.s[0] && Strcmp(&genstr, &f->name)!=0… | |
+ }else if(f->nrunes!=0 || (f->name.s[0] && Strcmp(&genstr, &f->name, NU… | |
empty = FALSE; | |
if((io = open(genc, OREAD))<0) { | |
if (curfile && curfile->state == Unread) | |
@@ -375,7 +375,7 @@ getname(File *f, String *s, int save) | |
Straddc(&genstr, '\0'); | |
if(f && (save || f->name.s[0]==0)){ | |
Fsetname(f, &genstr); | |
- if(Strcmp(&f->name, &genstr)){ | |
+ if(Strcmp(&f->name, &genstr, NULL)){ | |
quitok = f->closeok = FALSE; | |
f->qid = 0; | |
f->date = 0; | |
diff --git a/sam/sam.h b/sam/sam.h | |
@@ -305,7 +305,7 @@ int statfd(int, ulong*, ulong*, long*, long*, long*); | |
int statfile(char*, ulong*, ulong*, long*, long*, long*); | |
void Straddc(String*, int); | |
void Strclose(String*); | |
-int Strcmp(String*, String*); | |
+int Strcmp(String*, String*, int *); | |
void Strdelete(String*, Posn, Posn); | |
void Strdupl(String*, Rune*); | |
void Strduplstr(String*, String*); | |
diff --git a/sam/string.c b/sam/string.c | |
@@ -100,13 +100,16 @@ Strdelete(String *p, Posn p1, Posn p2) | |
} | |
int | |
-Strcmp(String *a, String *b) | |
+Strcmp(String *a, String *b, int *l) | |
{ | |
int i, c; | |
- for(i=0; i<a->n && i<b->n; i++) | |
+ for(i=0; i<a->n && i<b->n; i++){ | |
if(c = (a->s[i] - b->s[i])) /* assign = */ | |
return c; | |
+ if (l) | |
+ *l = i; | |
+ } | |
/* damn NULs confuse everything */ | |
i = a->n - b->n; | |
if(i == 1){ |