Introduction
Introduction Statistics Contact Development Disclaimer Help
Style fixes - sam - An updated version of the sam text editor.
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit df3e7c46eae5620b6f3ab7fb5e3cdf02edeae541
parent dc40bc617f9c43c86abd68e2ee7b50b0425c1433
Author: Rob King <[email protected]>
Date: Fri, 30 Sep 2016 12:43:25 -0500
Style fixes
Diffstat:
libXg/rune.c | 1 -
sam/io.c | 21 +++++++++++++--------
sam/sam.c | 12 +++++++-----
sam/string.c | 20 ++++++--------------
4 files changed, 26 insertions(+), 28 deletions(-)
---
diff --git a/libXg/rune.c b/libXg/rune.c
@@ -15,4 +15,3 @@ chartorune(wchar_t *rune, char *str)
}
return r;
}
-
diff --git a/sam/io.c b/sam/io.c
@@ -79,17 +79,18 @@ readio(File *f, int *nulls, int setdate)
Posn p = addr.r.p2;
uint64_t dev, qid;
int64_t mtime;
- char buf[BLOCKSIZE+1], *s;
+ char buf[BLOCKSIZE+1] = {0};
+ char *s = NULL;
*nulls = FALSE;
b = 0;
- for(nt = 0; (n = read(io, buf+b, BLOCKSIZE-b))>0; nt+=(r-genbuf)){
+ for (nt = 0; (n = read(io, buf + b, BLOCKSIZE - b)) > 0; nt += (r - genbuf…
n += b;
b = 0;
r = genbuf;
s = buf;
- while(n > 0){
- if(fullrune(s, n)){
+ while (n > 0){
+ if (fullrune(s, n)){
w = chartorune(r, s);
n -= w;
s += w;
@@ -107,18 +108,22 @@ readio(File *f, int *nulls, int setdate)
}
Finsert(f, tmprstr(genbuf, r-genbuf), p);
}
- if(b)
+
+ if (b)
*nulls = TRUE;
- if(*nulls)
+
+ if (*nulls)
warn(Wnulls);
- if(setdate){
- if(statfd(io, &dev, &qid, &mtime, 0, 0) > 0){
+
+ if (setdate){
+ if (statfd(io, &dev, &qid, &mtime, 0, 0) > 0){
f->dev = dev;
f->qid = qid;
f->date = mtime;
checkqid(f);
}
}
+
return nt;
}
diff --git a/sam/sam.c b/sam/sam.c
@@ -391,11 +391,13 @@ getname(File *f, String *s, int save)
Straddc(&genstr, '\0');
goto Return;
}
- if(c!=' ' && c!='\t')
+ if (c != L' ' && c != L'\t')
error(Eblank);
- for(i=0; (c=s->s[i])==' ' || c=='\t'; i++)
+
+ for (i = 0; (c = s->s[i]) == L' ' || c == L'\t'; i++)
;
- while(s->s[i] > ' ')
+
+ while (s->s[i] > L' ')
Straddc(&genstr, s->s[i++]);
if(s->s[i])
error(Enewline);
@@ -594,7 +596,7 @@ tofile(String *s)
{
File *f = NULL;
- if(s->s[0] != ' ')
+ if(s->s[0] != L' ')
error(Eblank);
if (loadflist(s) == 0)
@@ -633,7 +635,7 @@ closefiles(File *f, String *s)
trytoclose(f);
return;
}
- if(s->s[0] != ' ')
+ if(s->s[0] != L' ')
error(Eblank);
if(loadflist(s) == 0)
error(Enewline);
diff --git a/sam/string.c b/sam/string.c
@@ -38,20 +38,10 @@ Strzero(String *p)
p->n = 0;
}
-int
-Strlen(wchar_t *r)
-{
- wchar_t *s;
-
- for(s=r; *s; s++)
- ;
- return s-r;
-}
-
void
Strdupl(String *p, wchar_t *s) /* copies the null */
{
- p->n = Strlen(s)+1;
+ p->n = wcslen(s) + 1;
Strinsure(p, p->n);
memmove(p->s, s, p->n*RUNESIZE);
}
@@ -65,9 +55,9 @@ Strduplstr(String *p, String *q) /* will copy the null if …
}
void
-Straddc(String *p, int c)
+Straddc(String *p, wchar_t c)
{
- Strinsure(p, p->n+1);
+ Strinsure(p, p->n + 1);
p->s[p->n++] = c;
}
@@ -76,9 +66,10 @@ Strinsure(String *p, uint64_t n)
{
if(n > STRSIZE)
error(Etoolong);
+
if(p->size < n){ /* p needs to grow */
n += 100;
- p->s = erealloc(p->s, n*RUNESIZE);
+ p->s = erealloc(p->s, n * RUNESIZE);
p->size = n;
}
}
@@ -112,6 +103,7 @@ Strtoc(String *s)
char *c = emalloc(l + 1);
wchar_t ws[s->n + 1];
+ memset(ws, 0, sizeof(ws));
memset(c, 0, l + 1);
ws[s->n] = 0;
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.