aboutsummaryrefslogtreecommitdiff
path: root/src/lib9
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib9')
-rw-r--r--src/lib9/_p9dialparse.c2
-rw-r--r--src/lib9/_p9dir.c9
-rw-r--r--src/lib9/_p9translate.c46
-rw-r--r--src/lib9/announce.c1
-rw-r--r--src/lib9/atoi.c1
-rw-r--r--src/lib9/atol.c1
-rw-r--r--src/lib9/atoll.c1
-rw-r--r--src/lib9/await.c3
-rw-r--r--src/lib9/convD2M.c8
-rw-r--r--src/lib9/convM2D.c4
-rw-r--r--[-rwxr-xr-x]src/lib9/crypt.c0
-rw-r--r--src/lib9/ctime.c3
-rw-r--r--src/lib9/debugmalloc.c4
-rw-r--r--src/lib9/dial.c7
-rw-r--r--src/lib9/dirfstat.c1
-rw-r--r--src/lib9/dirfwstat.c1
-rw-r--r--src/lib9/dirread.c4
-rw-r--r--src/lib9/dirstat.c1
-rw-r--r--src/lib9/errstr.c1
-rw-r--r--src/lib9/execl.c1
-rw-r--r--src/lib9/exitcode.c1
-rw-r--r--src/lib9/fmt/dofmt.c2
-rw-r--r--src/lib9/fmt/fltfmt.c55
-rw-r--r--src/lib9/fmt/fmt.c35
-rw-r--r--src/lib9/fmt/fmtdef.h7
-rw-r--r--src/lib9/fmt/fmtlocale.c3
-rw-r--r--src/lib9/fmt/fmtlock.c14
-rw-r--r--src/lib9/fmt/fmtnull.c1
-rw-r--r--src/lib9/fmt/fmtprint.c1
-rw-r--r--src/lib9/fmt/fmtvprint.c1
-rw-r--r--src/lib9/fmt/nan64.c6
-rw-r--r--src/lib9/fmt/plan9.h1
-rw-r--r--src/lib9/fmt/runesnprint.c1
-rw-r--r--src/lib9/fmt/runevseprint.c1
-rw-r--r--src/lib9/fmt/runevsmprint.c4
-rw-r--r--src/lib9/fmt/snprint.c1
-rw-r--r--src/lib9/fmt/vseprint.c1
-rw-r--r--src/lib9/fmt/vsmprint.c4
-rw-r--r--src/lib9/fmtlock2.c22
-rw-r--r--src/lib9/frexp.c9
-rw-r--r--src/lib9/get9root.c1
-rw-r--r--src/lib9/getcallerpc-386.c7
-rw-r--r--src/lib9/getcallerpc-arm.c8
-rw-r--r--src/lib9/getcallerpc-arm64.c8
-rw-r--r--src/lib9/getcallerpc-mips.c8
-rw-r--r--src/lib9/getcallerpc-power.c11
-rw-r--r--src/lib9/getcallerpc-sun4u.s5
-rw-r--r--src/lib9/getcallerpc-x86_64.c7
-rw-r--r--src/lib9/getcallerpc.c13
-rw-r--r--src/lib9/getnetconn.c3
-rw-r--r--src/lib9/getns.c2
-rw-r--r--src/lib9/jmp.c1
-rw-r--r--src/lib9/lrand.c12
-rw-r--r--src/lib9/malloc.c4
-rw-r--r--src/lib9/mkfile3
-rw-r--r--src/lib9/netmkaddr.c2
-rw-r--r--src/lib9/notify.c11
-rw-r--r--src/lib9/opentemp.c1
-rw-r--r--src/lib9/pin.c1
-rw-r--r--src/lib9/postnote.c2
-rw-r--r--src/lib9/priv.c1
-rw-r--r--src/lib9/quote.c4
-rw-r--r--src/lib9/rfork.c2
-rw-r--r--src/lib9/searchpath.c1
-rw-r--r--src/lib9/sendfd.c2
-rw-r--r--src/lib9/strdup.c1
-rw-r--r--src/lib9/sysfatal.c1
-rw-r--r--src/lib9/testfltfmt.c12
-rw-r--r--src/lib9/testfmt.c6
-rw-r--r--src/lib9/testprint.c2
-rw-r--r--src/lib9/time.c1
-rw-r--r--src/lib9/tm2sec.c2
-rw-r--r--src/lib9/u64.c2
-rw-r--r--src/lib9/udp.c1
-rw-r--r--src/lib9/unsharp.c2
-rw-r--r--src/lib9/utf/lib9.h1
-rw-r--r--src/lib9/utf/plan9.h1
-rw-r--r--src/lib9/utf/rune.c2
-rw-r--r--src/lib9/utf/runestrdup.c4
-rw-r--r--src/lib9/utf/utfdef.h1
-rw-r--r--src/lib9/wait.c1
-rw-r--r--src/lib9/waitpid.c1
-rw-r--r--src/lib9/zoneinfo.c2
-rw-r--r--src/lib9/zoneinfo.h1
84 files changed, 172 insertions, 261 deletions
diff --git a/src/lib9/_p9dialparse.c b/src/lib9/_p9dialparse.c
index 2cc23574..4e56f5ee 100644
--- a/src/lib9/_p9dialparse.c
+++ b/src/lib9/_p9dialparse.c
@@ -72,7 +72,7 @@ p9dialparse(char *addr, char **pnet, char **punix, void *phost, int *pport)
if((port = strchr(host, '!')) == nil){
if(strcmp(net, "unix")==0 || strcmp(net, "net")==0){
Unix:
- if(strlen(host)+1 > sizeof ((struct sockaddr_un*)&ss)->sun_path){
+ if(strlen(host)+1 > sizeof ((struct sockaddr_un*)ss)->sun_path){
werrstr("unix socket name too long");
return -1;
}
diff --git a/src/lib9/_p9dir.c b/src/lib9/_p9dir.c
index b49cd4df..58c63573 100644
--- a/src/lib9/_p9dir.c
+++ b/src/lib9/_p9dir.c
@@ -34,7 +34,7 @@ static vlong
disksize(int fd, struct stat *st)
{
off_t mediasize;
-
+
if(ioctl(fd, DIOCGMEDIASIZE, &mediasize) >= 0)
return mediasize;
return 0;
@@ -155,7 +155,7 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char *
sz += strlen(s)+1;
if(d){
if(*str+strlen(s)+1 > estr)
- d->uid = "oops";
+ d->uid = "oops";
else{
strcpy(*str, s);
d->uid = *str;
@@ -178,7 +178,7 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char *
sz += strlen(s)+1;
if(d){
if(*str + strlen(s)+1 > estr)
- d->gid = "oops";
+ d->gid = "oops";
else{
strcpy(*str, s);
d->gid = *str;
@@ -230,7 +230,7 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char *
d->qid.path = ('c'<<16)|st->st_rdev;
}
/* fetch real size for disks */
- if(S_ISBLK(lst->st_mode) || S_ISCHR(lst->st_mode)){
+ if(S_ISBLK(lst->st_mode)){
if((fd = open(name, O_RDONLY)) >= 0){
d->length = disksize(fd, st);
close(fd);
@@ -240,4 +240,3 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char *
return sz;
}
-
diff --git a/src/lib9/_p9translate.c b/src/lib9/_p9translate.c
deleted file mode 100644
index 84cd65ca..00000000
--- a/src/lib9/_p9translate.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <u.h>
-#include <libc.h>
-
-/*
- * I don't want too many of these,
- * but the ones we have are just too useful.
- */
-static struct {
- char *old;
- char *new;
-} replace[] = {
- "#9", nil, /* must be first */
- "#d", "/dev/fd",
-};
-
-char*
-plan9translate(char *old)
-{
- char *new;
- int i, olen, nlen, len;
-
- if(replace[0].new == nil){
- replace[0].new = getenv("PLAN9");
- if(replace[0].new == nil)
- replace[0].new = "/usr/local/plan9";
- }
-
- for(i=0; i<nelem(replace); i++){
- if(!replace[i].new)
- continue;
- olen = strlen(replace[i].old);
- if(strncmp(old, replace[i].old, olen) != 0
- || (old[olen] != '\0' && old[olen] != '/'))
- continue;
- nlen = strlen(replace[i].new);
- len = strlen(old)+nlen-olen;
- new = malloc(len+1);
- if(new == nil)
- return "<out of memory>";
- strcpy(new, replace[i].new);
- strcpy(new+nlen, old+olen);
- assert(strlen(new) == len);
- return new;
- }
- return old;
-}
diff --git a/src/lib9/announce.c b/src/lib9/announce.c
index cbf5b073..1587988e 100644
--- a/src/lib9/announce.c
+++ b/src/lib9/announce.c
@@ -153,4 +153,3 @@ p9accept(int cfd, char *dir)
/* need to dup because the listen fd will be closed */
return dup(fd);
}
-
diff --git a/src/lib9/atoi.c b/src/lib9/atoi.c
index 66ecb4ef..c0f7251d 100644
--- a/src/lib9/atoi.c
+++ b/src/lib9/atoi.c
@@ -6,4 +6,3 @@ atoi(char *s)
{
return strtol(s, 0, 0);
}
-
diff --git a/src/lib9/atol.c b/src/lib9/atol.c
index d6713834..6ead3004 100644
--- a/src/lib9/atol.c
+++ b/src/lib9/atol.c
@@ -6,4 +6,3 @@ atol(char *s)
{
return strtol(s, 0, 0);
}
-
diff --git a/src/lib9/atoll.c b/src/lib9/atoll.c
index 6c345df6..d4ce0a94 100644
--- a/src/lib9/atoll.c
+++ b/src/lib9/atoll.c
@@ -6,4 +6,3 @@ atoll(char *s)
{
return strtoll(s, 0, 0);
}
-
diff --git a/src/lib9/await.c b/src/lib9/await.c
index e96055f2..8b96865c 100644
--- a/src/lib9/await.c
+++ b/src/lib9/await.c
@@ -55,7 +55,7 @@ static struct {
SIGUSR2, "sys: usr2",
SIGPIPE, "sys: write on closed pipe",
};
-
+
char*
_p9sigstr(int sig, char *tmp)
{
@@ -134,4 +134,3 @@ awaitfor(int pid, char *str, int n)
{
return _await(pid, str, n, 0);
}
-
diff --git a/src/lib9/convD2M.c b/src/lib9/convD2M.c
index 30c0d496..e1ef00c5 100644
--- a/src/lib9/convD2M.c
+++ b/src/lib9/convD2M.c
@@ -12,10 +12,10 @@ sizeD2M(Dir *d)
sv[1] = d->uid;
sv[2] = d->gid;
sv[3] = d->muid;
-
+
fixlen = STATFIXLEN;
nstr = 4;
-
+
ns = 0;
for(i = 0; i < nstr; i++)
if(sv[i])
@@ -44,7 +44,7 @@ convD2M(Dir *d, uchar *buf, uint nbuf)
fixlen = STATFIXLEN;
nstr = 4;
-
+
ns = 0;
for(i = 0; i < nstr; i++){
if(sv[i])
@@ -93,7 +93,7 @@ convD2M(Dir *d, uchar *buf, uint nbuf)
memmove(p, sv[i], ns);
p += ns;
}
-
+
if(ss != p - buf)
return 0;
diff --git a/src/lib9/convM2D.c b/src/lib9/convM2D.c
index 504110b2..410fa603 100644
--- a/src/lib9/convM2D.c
+++ b/src/lib9/convM2D.c
@@ -38,7 +38,7 @@ convM2D(uchar *buf, uint nbuf, Dir *d, char *strs)
int i, ns, nstr;
if(nbuf < STATFIXLEN)
- return 0;
+ return 0;
p = buf;
ebuf = buf + nbuf;
@@ -93,6 +93,6 @@ convM2D(uchar *buf, uint nbuf, Dir *d, char *strs)
d->muid = nullstring;
d->ext = nullstring;
}
-
+
return p - buf;
}
diff --git a/src/lib9/crypt.c b/src/lib9/crypt.c
index 0524c942..0524c942 100755..100644
--- a/src/lib9/crypt.c
+++ b/src/lib9/crypt.c
diff --git a/src/lib9/ctime.c b/src/lib9/ctime.c
index a9ce7b7a..97ebfd2f 100644
--- a/src/lib9/ctime.c
+++ b/src/lib9/ctime.c
@@ -58,7 +58,7 @@ localtime(long tim)
if (zonelookuptinfo(&ti, tim)!=-1) {
ct = gmtime(tim+ti.tzoff);
- strncpy(ct->zone, ti.zone, sizeof ct->zone);
+ strncpy(ct->zone, ti.zone, sizeof ct->zone - 1);
ct->zone[sizeof ct->zone-1] = 0;
ct->tzoff = ti.tzoff;
return ct;
@@ -178,4 +178,3 @@ ct_numb(char *cp, int n)
cp[0] = (n/10)%10 + '0';
cp[1] = n%10 + '0';
}
-
diff --git a/src/lib9/debugmalloc.c b/src/lib9/debugmalloc.c
index 8df27219..51a2c61f 100644
--- a/src/lib9/debugmalloc.c
+++ b/src/lib9/debugmalloc.c
@@ -74,7 +74,7 @@ mark(void *v, ulong pc, ulong n, ulong magic)
p = (char*)(u+4)+n;
memmove(p, END, 4);
return u+4;
- }
+ }
}
void
@@ -104,7 +104,7 @@ setrealloctag(void *v, ulong t)
u = mark(v, 0, 0, 0);
u[3] = t;
}
-
+
void*
p9malloc(ulong n)
{
diff --git a/src/lib9/dial.c b/src/lib9/dial.c
index 1ce3a147..81e3a830 100644
--- a/src/lib9/dial.c
+++ b/src/lib9/dial.c
@@ -92,7 +92,7 @@ p9dial(char *addr, char *local, char *dummy2, int *dummy3)
if((s = socket(ss.ss_family, proto, 0)) < 0)
return -1;
-
+
if(local){
buf = strdup(local);
if(buf == nil){
@@ -141,8 +141,10 @@ Unix:
return -1;
}
/* Allow regular files in addition to Unix sockets. */
- if((s = open(unix, ORDWR)) >= 0)
+ if((s = open(unix, ORDWR)) >= 0){
+ free(buf);
return s;
+ }
free(buf);
if((s = socket(ss.ss_family, SOCK_STREAM, 0)) < 0){
werrstr("socket: %r");
@@ -155,4 +157,3 @@ Unix:
}
return s;
}
-
diff --git a/src/lib9/dirfstat.c b/src/lib9/dirfstat.c
index d1922bf9..37b59a0b 100644
--- a/src/lib9/dirfstat.c
+++ b/src/lib9/dirfstat.c
@@ -26,4 +26,3 @@ dirfstat(int fd)
_p9dir(&st, &st, tmp, d, &str, str+nstr);
return d;
}
-
diff --git a/src/lib9/dirfwstat.c b/src/lib9/dirfwstat.c
index 95e18444..27ed37a8 100644
--- a/src/lib9/dirfwstat.c
+++ b/src/lib9/dirfwstat.c
@@ -54,4 +54,3 @@ dirfwstat(int fd, Dir *dir)
}
return ret;
}
-
diff --git a/src/lib9/dirread.c b/src/lib9/dirread.c
index 40fbe3c7..c232eb8d 100644
--- a/src/lib9/dirread.c
+++ b/src/lib9/dirread.c
@@ -18,7 +18,7 @@ mygetdents(int fd, struct dirent *buf, int n)
nn = getdirentries(fd, (void*)buf, n, &off);
return nn;
}
-#elif defined(__APPLE__)
+#elif defined(__APPLE__)
static int
mygetdents(int fd, struct dirent *buf, int n)
{
@@ -93,7 +93,7 @@ dirpackage(int fd, char *buf, int n, Dir **dp)
return -1;
if(fchdir(fd) < 0)
return -1;
-
+
p = buf;
nstr = 0;
diff --git a/src/lib9/dirstat.c b/src/lib9/dirstat.c
index 187dea7a..a644b6b5 100644
--- a/src/lib9/dirstat.c
+++ b/src/lib9/dirstat.c
@@ -29,4 +29,3 @@ dirstat(char *file)
_p9dir(&lst, &st, file, d, &str, str+nstr);
return d;
}
-
diff --git a/src/lib9/errstr.c b/src/lib9/errstr.c
index caf71532..9493e842 100644
--- a/src/lib9/errstr.c
+++ b/src/lib9/errstr.c
@@ -78,4 +78,3 @@ werrstr(char *fmt, ...)
va_end(arg);
errstr(buf, ERRMAX);
}
-
diff --git a/src/lib9/execl.c b/src/lib9/execl.c
index 988d2072..63b86d6d 100644
--- a/src/lib9/execl.c
+++ b/src/lib9/execl.c
@@ -26,4 +26,3 @@ execl(char *prog, ...)
free(argv);
return -1;
}
-
diff --git a/src/lib9/exitcode.c b/src/lib9/exitcode.c
index f65836e1..797e9d50 100644
--- a/src/lib9/exitcode.c
+++ b/src/lib9/exitcode.c
@@ -6,4 +6,3 @@ exitcode(char *s)
{
return 1;
}
-
diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c
index 353c76e3..f714f8ff 100644
--- a/src/lib9/fmt/dofmt.c
+++ b/src/lib9/fmt/dofmt.c
@@ -478,7 +478,7 @@ __ifmt(Fmt *f)
if(fl & FmtApost)
__needsep(&ndig, &grouping);
}
-
+
/*
* Zero values don't get 0x.
*/
diff --git a/src/lib9/fmt/fltfmt.c b/src/lib9/fmt/fltfmt.c
index bfeb7e50..4045ffd8 100644
--- a/src/lib9/fmt/fltfmt.c
+++ b/src/lib9/fmt/fltfmt.c
@@ -26,22 +26,22 @@ enum
*/
static double pows10[] =
{
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
- 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29,
- 1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39,
- 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47, 1e48, 1e49,
- 1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59,
- 1e60, 1e61, 1e62, 1e63, 1e64, 1e65, 1e66, 1e67, 1e68, 1e69,
- 1e70, 1e71, 1e72, 1e73, 1e74, 1e75, 1e76, 1e77, 1e78, 1e79,
- 1e80, 1e81, 1e82, 1e83, 1e84, 1e85, 1e86, 1e87, 1e88, 1e89,
- 1e90, 1e91, 1e92, 1e93, 1e94, 1e95, 1e96, 1e97, 1e98, 1e99,
- 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109,
- 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119,
- 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129,
- 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139,
- 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149,
- 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159,
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+ 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29,
+ 1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39,
+ 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47, 1e48, 1e49,
+ 1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59,
+ 1e60, 1e61, 1e62, 1e63, 1e64, 1e65, 1e66, 1e67, 1e68, 1e69,
+ 1e70, 1e71, 1e72, 1e73, 1e74, 1e75, 1e76, 1e77, 1e78, 1e79,
+ 1e80, 1e81, 1e82, 1e83, 1e84, 1e85, 1e86, 1e87, 1e88, 1e89,
+ 1e90, 1e91, 1e92, 1e93, 1e94, 1e95, 1e96, 1e97, 1e98, 1e99,
+ 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109,
+ 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119,
+ 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129,
+ 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139,
+ 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149,
+ 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159,
};
#define npows10 ((int)(sizeof(pows10)/sizeof(pows10[0])))
#define pow10(x) fmtpow10(x)
@@ -110,7 +110,7 @@ xadd1(char *a, int n)
/*
* subtract 1 from the decimal integer string a.
* if 10000 underflows into 09999, make it 99999
- * and return 1 to tell caller to move the virtual
+ * and return 1 to tell caller to move the virtual
* decimal point. this way, xsub1 is inverse of xadd1.
*/
static int
@@ -206,7 +206,7 @@ xdtoa(double f, char *s, int *exp, int *neg, int *ns)
*ns = 1;
return;
}
-
+
/*
* find g,e such that f = g*10^e.
* guess 10-exponent using 2-exponent, then fine tune.
@@ -298,7 +298,7 @@ xdtoa(double f, char *s, int *exp, int *neg, int *ns)
e = ee;
}
}
-
+
/*
* bump last few digits down to 0 as we can.
*/
@@ -342,13 +342,13 @@ __efgfmt(Fmt *fmt)
int c, chr, dotwid, e, exp, fl, ndigits, neg, newndigits;
int pad, point, prec, realchr, sign, sufwid, ucase, wid, z1, z2;
Rune r, *rs, *rt;
-
+
if(fmt->flags&FmtLong)
f = va_arg(fmt->args, long double);
else
f = va_arg(fmt->args, double);
-
- /*
+
+ /*
* extract formatting flags
*/
fl = fmt->flags;
@@ -425,7 +425,7 @@ __efgfmt(Fmt *fmt)
exp += ndigits-prec;
ndigits = prec;
}
-
+
/*
* extra rules for %g (implemented below):
* trailing zeros removed after decimal unless FmtSharp.
@@ -435,12 +435,12 @@ __efgfmt(Fmt *fmt)
/* fall through to %e */
default:
case 'e':
- /*
+ /*
* one significant digit before decimal, no leading zeros.
*/
point = 1;
z1 = 0;
-
+
/*
* decimal point is after ndigits digits right now.
* slide to be after first.
@@ -537,11 +537,11 @@ __efgfmt(Fmt *fmt)
}
z2 = 0;
ndigits = newndigits;
- }
+ }
sufwid = 0;
break;
}
-
+
/*
* if %g is given without FmtSharp, remove trailing zeros.
* must do after truncation, so that e.g. print %.3g 1.001
@@ -665,4 +665,3 @@ __efgfmt(Fmt *fmt)
}
return 0;
}
-
diff --git a/src/lib9/fmt/fmt.c b/src/lib9/fmt/fmt.c
index 66093fd0..9c3f45d3 100644
--- a/src/lib9/fmt/fmt.c
+++ b/src/lib9/fmt/fmt.c
@@ -72,7 +72,7 @@ static Convfmt knownfmt[] = {
int (*fmtdoquote)(int);
/*
- * __fmtlock() must be set
+ * __fmtwlock() must be set
*/
static int
__fmtinstall(int c, Fmts f)
@@ -106,34 +106,43 @@ fmtinstall(int c, int (*f)(Fmt*))
{
int ret;
- __fmtlock();
+ __fmtwlock();
ret = __fmtinstall(c, f);
- __fmtunlock();
+ __fmtwunlock();
return ret;
}
static Fmts
fmtfmt(int c)
{
- Convfmt *p, *ep;
+ Convfmt *p, *ep, *kp;
+ /* conflict-free check - common case */
+ __fmtrlock();
ep = &fmtalloc.fmt[fmtalloc.nfmt];
for(p=fmtalloc.fmt; p<ep; p++)
if(p->c == c){
- while(p->fmt == nil) /* loop until value is updated */
- ;
+ __fmtrunlock();
return p->fmt;
}
+ __fmtrunlock();
/* is this a predefined format char? */
- __fmtlock();
- for(p=knownfmt; p->c; p++)
- if(p->c == c){
- __fmtinstall(p->c, p->fmt);
- __fmtunlock();
- return p->fmt;
+ for(kp=knownfmt; kp->c; kp++){
+ if(kp->c == c){
+ __fmtwlock();
+ /* double-check fmtinstall didn't happen */
+ for(p=fmtalloc.fmt; p<ep; p++){
+ if(p->c == c){
+ __fmtwunlock();
+ return p->fmt;
+ }
+ }
+ __fmtinstall(kp->c, kp->fmt);
+ __fmtwunlock();
+ return kp->fmt;
}
- __fmtunlock();
+ }
return __badfmt;
}
diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h
index 1519ea42..d547184d 100644
--- a/src/lib9/fmt/fmtdef.h
+++ b/src/lib9/fmt/fmtdef.h
@@ -33,11 +33,13 @@ int __fmtFdFlush(Fmt *f);
int __fmtcpy(Fmt *f, const void *vm, int n, int sz);
void* __fmtdispatch(Fmt *f, void *fmt, int isrunes);
void * __fmtflush(Fmt *f, void *t, int len);
-void __fmtlock(void);
int __fmtpad(Fmt *f, int n);
double __fmtpow10(int n);
int __fmtrcpy(Fmt *f, const void *vm, int n);
-void __fmtunlock(void);
+void __fmtrlock(void);
+void __fmtrunlock(void);
+void __fmtwlock(void);
+void __fmtwunlock(void);
int __ifmt(Fmt *f);
int __isInf(double d, int sign);
int __isNaN(double d);
@@ -102,4 +104,3 @@ int __strfmt(Fmt *f);
# define VA_COPY(a,b) (a) = (b)
# define VA_END(a)
#endif
-
diff --git a/src/lib9/fmt/fmtlocale.c b/src/lib9/fmt/fmtlocale.c
index 9ebdced3..33ca4011 100644
--- a/src/lib9/fmt/fmtlocale.c
+++ b/src/lib9/fmt/fmtlocale.c
@@ -37,7 +37,7 @@ int
__needsep(int *ndig, char **grouping)
{
int group;
-
+
(*ndig)++;
group = *(unsigned char*)*grouping;
/* CHAR_MAX means no further grouping. \0 means we got the empty string */
@@ -52,4 +52,3 @@ __needsep(int *ndig, char **grouping)
}
return 0;
}
-
diff --git a/src/lib9/fmt/fmtlock.c b/src/lib9/fmt/fmtlock.c
index cabe05f4..eb9cd845 100644
--- a/src/lib9/fmt/fmtlock.c
+++ b/src/lib9/fmt/fmtlock.c
@@ -5,11 +5,21 @@
#include "fmtdef.h"
void
-__fmtlock(void)
+__fmtrlock(void)
{
}
void
-__fmtunlock(void)
+__fmtrunlock(void)
+{
+}
+
+void
+__fmtwlock(void)
+{
+}
+
+void
+__fmtwunlock(void)
{
}
diff --git a/src/lib9/fmt/fmtnull.c b/src/lib9/fmt/fmtnull.c
index aa5124a5..22ac078f 100644
--- a/src/lib9/fmt/fmtnull.c
+++ b/src/lib9/fmt/fmtnull.c
@@ -30,4 +30,3 @@ fmtnullinit(Fmt *f)
fmtlocaleinit(f, nil, nil, nil);
return 0;
}
-
diff --git a/src/lib9/fmt/fmtprint.c b/src/lib9/fmt/fmtprint.c
index 868127e0..41fc8332 100644
--- a/src/lib9/fmt/fmtprint.c
+++ b/src/lib9/fmt/fmtprint.c
@@ -33,4 +33,3 @@ fmtprint(Fmt *f, char *fmt, ...)
return 0;
return n;
}
-
diff --git a/src/lib9/fmt/fmtvprint.c b/src/lib9/fmt/fmtvprint.c
index 66d3929f..694a6cf8 100644
--- a/src/lib9/fmt/fmtvprint.c
+++ b/src/lib9/fmt/fmtvprint.c
@@ -34,4 +34,3 @@ fmtvprint(Fmt *f, char *fmt, va_list args)
return 0;
return n;
}
-
diff --git a/src/lib9/fmt/nan64.c b/src/lib9/fmt/nan64.c
index d408695d..78c3fde3 100644
--- a/src/lib9/fmt/nan64.c
+++ b/src/lib9/fmt/nan64.c
@@ -2,7 +2,7 @@
/*
* 64-bit IEEE not-a-number routines.
- * This is big/little-endian portable assuming that
+ * This is big/little-endian portable assuming that
* the 64-bit doubles and 64-bit integers have the
* same byte ordering.
*/
@@ -51,7 +51,7 @@ int
__isNaN(double d)
{
uvlong x;
-
+
x = d2u(d);
/* IEEE 754: exponent bits 0x7FF and non-zero mantissa */
return (x&uvinf) == uvinf && (x&~uvneginf) != 0;
@@ -67,7 +67,7 @@ int
__isInf(double d, int sign)
{
uvlong x;
-
+
x = d2u(d);
if(sign == 0)
return x==uvinf || x==uvneginf;
diff --git a/src/lib9/fmt/plan9.h b/src/lib9/fmt/plan9.h
index 0872ac71..0de44f14 100644
--- a/src/lib9/fmt/plan9.h
+++ b/src/lib9/fmt/plan9.h
@@ -35,4 +35,3 @@ typedef uintptr_t uintptr;
#undef nelem
#define nelem(x) (sizeof (x)/sizeof (x)[0])
-
diff --git a/src/lib9/fmt/runesnprint.c b/src/lib9/fmt/runesnprint.c
index 50b4813d..afc3f506 100644
--- a/src/lib9/fmt/runesnprint.c
+++ b/src/lib9/fmt/runesnprint.c
@@ -16,4 +16,3 @@ runesnprint(Rune *buf, int len, char *fmt, ...)
va_end(args);
return n;
}
-
diff --git a/src/lib9/fmt/runevseprint.c b/src/lib9/fmt/runevseprint.c
index 24e2f178..213351ab 100644
--- a/src/lib9/fmt/runevseprint.c
+++ b/src/lib9/fmt/runevseprint.c
@@ -26,4 +26,3 @@ runevseprint(Rune *buf, Rune *e, char *fmt, va_list args)
*(Rune*)f.to = '\0';
return (Rune*)f.to;
}
-
diff --git a/src/lib9/fmt/runevsmprint.c b/src/lib9/fmt/runevsmprint.c
index ef273752..de29d2c3 100644
--- a/src/lib9/fmt/runevsmprint.c
+++ b/src/lib9/fmt/runevsmprint.c
@@ -1,8 +1,8 @@
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
/*
- * Plan 9 port version must include libc.h in order to
+ * Plan 9 port version must include libc.h in order to
* get Plan 9 debugging malloc, which sometimes returns
- * different pointers than the standard malloc.
+ * different pointers than the standard malloc.
*/
#ifdef PLAN9PORT
#include <u.h>
diff --git a/src/lib9/fmt/snprint.c b/src/lib9/fmt/snprint.c
index 64d2da43..d019b456 100644
--- a/src/lib9/fmt/snprint.c
+++ b/src/lib9/fmt/snprint.c
@@ -15,4 +15,3 @@ snprint(char *buf, int len, char *fmt, ...)
va_end(args);
return n;
}
-
diff --git a/src/lib9/fmt/vseprint.c b/src/lib9/fmt/vseprint.c
index 1b92d2a9..8266c65d 100644
--- a/src/lib9/fmt/vseprint.c
+++ b/src/lib9/fmt/vseprint.c
@@ -25,4 +25,3 @@ vseprint(char *buf, char *e, char *fmt, va_list args)
*(char*)f.to = '\0';
return (char*)f.to;
}
-
diff --git a/src/lib9/fmt/vsmprint.c b/src/lib9/fmt/vsmprint.c
index 9576f800..0a88e98f 100644
--- a/src/lib9/fmt/vsmprint.c
+++ b/src/lib9/fmt/vsmprint.c
@@ -1,8 +1,8 @@
/* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
/*
- * Plan 9 port version must include libc.h in order to
+ * Plan 9 port version must include libc.h in order to
* get Plan 9 debugging malloc, which sometimes returns
- * different pointers than the standard malloc.
+ * different pointers than the standard malloc.
*/
#ifdef PLAN9PORT
#include <u.h>
diff --git a/src/lib9/fmtlock2.c b/src/lib9/fmtlock2.c
index d711e6d4..b755daa3 100644
--- a/src/lib9/fmtlock2.c
+++ b/src/lib9/fmtlock2.c
@@ -1,16 +1,28 @@
#include <u.h>
#include <libc.h>
-static Lock fmtlock;
+static RWLock fmtlock;
void
-__fmtlock(void)
+__fmtrlock(void)
{
- lock(&fmtlock);
+ rlock(&fmtlock);
}
void
-__fmtunlock(void)
+__fmtrunlock(void)
{
- unlock(&fmtlock);
+ runlock(&fmtlock);
+}
+
+void
+__fmtwlock(void)
+{
+ wlock(&fmtlock);
+}
+
+void
+__fmtwunlock(void)
+{
+ wunlock(&fmtlock);
}
diff --git a/src/lib9/frexp.c b/src/lib9/frexp.c
new file mode 100644
index 00000000..fe3e2f73
--- /dev/null
+++ b/src/lib9/frexp.c
@@ -0,0 +1,9 @@
+#include <u.h>
+#define NOPLAN9DEFINES
+#include <libc.h>
+
+double
+p9frexp(double d, int *i)
+{
+ return frexp(d, i);
+}
diff --git a/src/lib9/get9root.c b/src/lib9/get9root.c
index 3ef704c9..07e2872c 100644
--- a/src/lib9/get9root.c
+++ b/src/lib9/get9root.c
@@ -15,4 +15,3 @@ get9root(void)
s = "/usr/local/plan9";
return s;
}
-
diff --git a/src/lib9/getcallerpc-386.c b/src/lib9/getcallerpc-386.c
deleted file mode 100644
index 1367370e..00000000
--- a/src/lib9/getcallerpc-386.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <lib9.h>
-
-ulong
-getcallerpc(void *x)
-{
- return (((ulong*)(x))[-1]);
-}
diff --git a/src/lib9/getcallerpc-arm.c b/src/lib9/getcallerpc-arm.c
deleted file mode 100644
index 9bb4a955..00000000
--- a/src/lib9/getcallerpc-arm.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <lib9.h>
-
-ulong
-getcallerpc(void *x)
-{
- return ((ulong*)x)[-2];
-}
-
diff --git a/src/lib9/getcallerpc-arm64.c b/src/lib9/getcallerpc-arm64.c
deleted file mode 100644
index 9bb4a955..00000000
--- a/src/lib9/getcallerpc-arm64.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <lib9.h>
-
-ulong
-getcallerpc(void *x)
-{
- return ((ulong*)x)[-2];
-}
-
diff --git a/src/lib9/getcallerpc-mips.c b/src/lib9/getcallerpc-mips.c
deleted file mode 100644
index 9bb4a955..00000000
--- a/src/lib9/getcallerpc-mips.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <lib9.h>
-
-ulong
-getcallerpc(void *x)
-{
- return ((ulong*)x)[-2];
-}
-
diff --git a/src/lib9/getcallerpc-power.c b/src/lib9/getcallerpc-power.c
deleted file mode 100644
index b4bf6980..00000000
--- a/src/lib9/getcallerpc-power.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <lib9.h>
-
-ulong
-getcallerpc(void *x)
-{
- ulong *lp;
-
- lp = x;
-
- return lp[-1];
-}
diff --git a/src/lib9/getcallerpc-sun4u.s b/src/lib9/getcallerpc-sun4u.s
deleted file mode 100644
index f28e57f1..00000000
--- a/src/lib9/getcallerpc-sun4u.s
+++ /dev/null
@@ -1,5 +0,0 @@
-.text
-.globl getcallerpc
-getcallerpc:
- retl
- or %o7, %r0, %o0
diff --git a/src/lib9/getcallerpc-x86_64.c b/src/lib9/getcallerpc-x86_64.c
deleted file mode 100644
index 1367370e..00000000
--- a/src/lib9/getcallerpc-x86_64.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <lib9.h>
-
-ulong
-getcallerpc(void *x)
-{
- return (((ulong*)(x))[-1]);
-}
diff --git a/src/lib9/getcallerpc.c b/src/lib9/getcallerpc.c
new file mode 100644
index 00000000..3067f053
--- /dev/null
+++ b/src/lib9/getcallerpc.c
@@ -0,0 +1,13 @@
+#include <u.h>
+#include <libc.h>
+
+/*
+ * On gcc and clang, getcallerpc is a macro invoking a compiler builtin.
+ * If the macro in libc.h did not trigger, there's no implementation.
+ */
+#undef getcallerpc
+ulong
+getcallerpc(void *v)
+{
+ return 1;
+}
diff --git a/src/lib9/getnetconn.c b/src/lib9/getnetconn.c
index 9fa8a9e0..e88516cf 100644
--- a/src/lib9/getnetconn.c
+++ b/src/lib9/getnetconn.c
@@ -27,7 +27,7 @@ convert(int s, struct sockaddr *sa, char **lsys, char **lserv, char **laddr)
socklen_t sn;
int n;
char *net;
-
+
switch(sa->sa_family){
case AF_INET:
sin = (void*)sa;
@@ -158,4 +158,3 @@ freenetconninfo(NetConnInfo *nci)
xfree(nci->raddr);
free(nci);
}
-
diff --git a/src/lib9/getns.c b/src/lib9/getns.c
index 2421a649..35bbeebd 100644
--- a/src/lib9/getns.c
+++ b/src/lib9/getns.c
@@ -49,7 +49,7 @@ nsfromdisplay(void)
if(strcmp(p, ".0") == 0)
*p = 0;
}
-
+
/* turn /tmp/launch/:0 into _tmp_launch_:0 (OS X 10.5) */
for(p=disp; *p; p++)
if(*p == '/')
diff --git a/src/lib9/jmp.c b/src/lib9/jmp.c
index 6f928bab..5ec21e7f 100644
--- a/src/lib9/jmp.c
+++ b/src/lib9/jmp.c
@@ -14,4 +14,3 @@ p9notejmp(void *x, p9jmp_buf buf, int val)
USED(x);
siglongjmp((void*)buf, val);
}
-
diff --git a/src/lib9/lrand.c b/src/lib9/lrand.c
index 8f536456..3d1b05fe 100644
--- a/src/lib9/lrand.c
+++ b/src/lib9/lrand.c
@@ -63,17 +63,15 @@ p9lrand(void)
lock(&lk);
- rng_tap--;
- if(rng_tap < rng_vec) {
- if(rng_feed == 0) {
+ if(rng_tap <= rng_vec) {
+ if(rng_feed == 0)
isrand(1);
- rng_tap--;
- }
rng_tap += LEN;
}
- rng_feed--;
- if(rng_feed < rng_vec)
+ rng_tap--;
+ if(rng_feed <= rng_vec)
rng_feed += LEN;
+ rng_feed--;
x = (*rng_feed + *rng_tap) & MASK;
*rng_feed = x;
diff --git a/src/lib9/malloc.c b/src/lib9/malloc.c
index 7b6b59dc..33593aa2 100644
--- a/src/lib9/malloc.c
+++ b/src/lib9/malloc.c
@@ -13,7 +13,7 @@ void*
p9malloc(ulong n)
{
void *v;
-
+
if(n == 0)
n++;
lock(&malloclock);
@@ -36,7 +36,7 @@ void*
p9calloc(ulong a, ulong b)
{
void *v;
-
+
if(a*b == 0)
a = b = 1;
diff --git a/src/lib9/mkfile b/src/lib9/mkfile
index 8f7283ef..7c37de42 100644
--- a/src/lib9/mkfile
+++ b/src/lib9/mkfile
@@ -22,6 +22,7 @@ FMTOFILES=\
fmtstr.$O\
fmtvprint.$O\
fprint.$O\
+ frexp.$O\
nan64.$O\
print.$O\
runefmtstr.$O\
@@ -104,7 +105,7 @@ LIB9OFILES=\
fcallfmt.$O\
frand.$O\
get9root.$O\
- getcallerpc-$OBJTYPE.$O\
+ getcallerpc.$O\
getenv.$O\
getfields.$O\
getnetconn.$O\
diff --git a/src/lib9/netmkaddr.c b/src/lib9/netmkaddr.c
index 832f7e28..420c2cf8 100644
--- a/src/lib9/netmkaddr.c
+++ b/src/lib9/netmkaddr.c
@@ -25,7 +25,7 @@ netmkaddr(char *linear, char *defnet, char *defsrv)
}
/* allow host:service in deference to Unix convention */
if((cp = strchr(linear, ':')) != nil){
- snprint(addr, sizeof(addr), "%s!%.*s!%s",
+ snprint(addr, sizeof(addr), "%s!%.*s!%s",
defnet, utfnlen(linear, cp-linear),
linear, cp+1);
return addr;
diff --git a/src/lib9/notify.c b/src/lib9/notify.c
index c3223875..adb3815b 100644
--- a/src/lib9/notify.c
+++ b/src/lib9/notify.c
@@ -1,7 +1,7 @@
/*
- * Signal handling for Plan 9 programs.
- * We stubbornly use the strings from Plan 9 instead
- * of the enumerated Unix constants.
+ * Signal handling for Plan 9 programs.
+ * We stubbornly use the strings from Plan 9 instead
+ * of the enumerated Unix constants.
* There are some weird translations. In particular,
* a "kill" note is the same as SIGTERM in Unix.
* There is no equivalent note to Unix's SIGKILL, since
@@ -110,7 +110,7 @@ Jmp *(*_notejmpbuf)(void) = getonejmp;
static void noteinit(void);
/*
- * Actual signal handler.
+ * Actual signal handler.
*/
static void (*notifyf)(void*, char*); /* Plan 9 handler */
@@ -193,7 +193,7 @@ notesetenable(int sig, int enabled)
sigemptyset(&mask);
sigaddset(&mask, sig);
sigprocmask(enabled ? SIG_UNBLOCK : SIG_BLOCK, &mask, &omask);
- return !sigismember(&omask, sig);
+ return !sigismember(&omask, sig);
}
int
@@ -270,4 +270,3 @@ noteinit(void)
notifyseton(sig->sig, !(sig->flags&NoNotify));
}
}
-
diff --git a/src/lib9/opentemp.c b/src/lib9/opentemp.c
index 9d4e2d07..c999f49c 100644
--- a/src/lib9/opentemp.c
+++ b/src/lib9/opentemp.c
@@ -17,4 +17,3 @@ opentemp(char *template, int mode)
close(fd);
return fd1;
}
-
diff --git a/src/lib9/pin.c b/src/lib9/pin.c
index 3b15d3b8..c50587fc 100644
--- a/src/lib9/pin.c
+++ b/src/lib9/pin.c
@@ -8,4 +8,3 @@ nop(void)
void (*_pin)(void) = nop;
void (*_unpin)(void) = nop;
-
diff --git a/src/lib9/postnote.c b/src/lib9/postnote.c
index b8ef9427..68e6d2f6 100644
--- a/src/lib9/postnote.c
+++ b/src/lib9/postnote.c
@@ -30,5 +30,3 @@ postnote(int who, int pid, char *msg)
return killpg(pid, sig);
}
}
-
-
diff --git a/src/lib9/priv.c b/src/lib9/priv.c
index e64e9194..fb493c72 100644
--- a/src/lib9/priv.c
+++ b/src/lib9/priv.c
@@ -29,4 +29,3 @@ privmem(int i)
up = _p9uproc(0);
return &up->priv[i];
}
-
diff --git a/src/lib9/quote.c b/src/lib9/quote.c
index f850009a..8ab65923 100644
--- a/src/lib9/quote.c
+++ b/src/lib9/quote.c
@@ -92,7 +92,7 @@ quotestrdup(char *s)
if(__needsquotes(s, &quotelen) == 0)
return strdup(s);
-
+
ret = malloc(quotelen+1);
if(ret == nil)
return nil;
@@ -118,7 +118,7 @@ quoterunestrdup(Rune *s)
if(__runeneedsquotes(s, &quotelen) == 0)
return runestrdup(s);
-
+
ret = malloc((quotelen+1)*sizeof(Rune));
if(ret == nil)
return nil;
diff --git a/src/lib9/rfork.c b/src/lib9/rfork.c
index bbd08b0a..c737b49d 100644
--- a/src/lib9/rfork.c
+++ b/src/lib9/rfork.c
@@ -76,7 +76,7 @@ p9rfork(int flags)
pid = strtol(buf, &q, 0);
}else{
/*
- * Child - fork a new child whose wait message can't
+ * Child - fork a new child whose wait message can't
* get back to the parent because we're going to exit!
*/
signal(SIGCHLD, SIG_IGN);
diff --git a/src/lib9/searchpath.c b/src/lib9/searchpath.c
index 3b8e7daa..75e0695f 100644
--- a/src/lib9/searchpath.c
+++ b/src/lib9/searchpath.c
@@ -59,4 +59,3 @@ searchpath(char *name)
free(path);
return nil;
}
-
diff --git a/src/lib9/sendfd.c b/src/lib9/sendfd.c
index e2abb759..e73225e2 100644
--- a/src/lib9/sendfd.c
+++ b/src/lib9/sendfd.c
@@ -31,7 +31,7 @@ sendfd(int s, int fd)
struct cmsghdr *cmsg;
int n;
char cms[CMSG_SPACE(sizeof(int))];
-
+
buf[0] = 0;
iov.iov_base = buf;
iov.iov_len = 1;
diff --git a/src/lib9/strdup.c b/src/lib9/strdup.c
index 5ca31866..5c67f0b6 100644
--- a/src/lib9/strdup.c
+++ b/src/lib9/strdup.c
@@ -14,4 +14,3 @@ strdup(char *s)
memmove(t, s, l+1);
return t;
}
-
diff --git a/src/lib9/sysfatal.c b/src/lib9/sysfatal.c
index 00229db0..11f4234c 100644
--- a/src/lib9/sysfatal.c
+++ b/src/lib9/sysfatal.c
@@ -18,4 +18,3 @@ sysfatal(char *fmt, ...)
fprint(2, "%s: %s\n", argv0 ? argv0 : "<prog>", buf);
exits("fatal");
}
-
diff --git a/src/lib9/testfltfmt.c b/src/lib9/testfltfmt.c
index 06ab5a60..c602ce45 100644
--- a/src/lib9/testfltfmt.c
+++ b/src/lib9/testfltfmt.c
@@ -142,9 +142,9 @@ doit(int just, int plus, int alt, int zero, int width, int prec, int spec)
&& !numclose(ref, buf)) {
d1 = fmtstrtod(ref, 0);
d2 = fmtstrtod(buf, 0);
- fprintf(stderr, "%s: ref='%s'%s fmt='%s'%s\n",
- format,
- ref, d1==fmtvals[i] ? "" : " (ref is inexact!)",
+ fprintf(stderr, "%s: ref='%s'%s fmt='%s'%s\n",
+ format,
+ ref, d1==fmtvals[i] ? "" : " (ref is inexact!)",
buf, d2==fmtvals[i] ? "" : " (fmt is inexact!)");
// exits("oops");
}
@@ -156,9 +156,9 @@ doit(int just, int plus, int alt, int zero, int width, int prec, int spec)
&& !numclose(ref, buf)) {
d1 = fmtstrtod(ref, 0);
d2 = fmtstrtod(buf, 0);
- fprintf(stderr, "%s: ref='%s'%s fmt='%s'%s\n",
- format,
- ref, d1==fmtvals[i] ? "" : " (ref is inexact!)",
+ fprintf(stderr, "%s: ref='%s'%s fmt='%s'%s\n",
+ format,
+ ref, d1==fmtvals[i] ? "" : " (ref is inexact!)",
buf, d2==fmtvals[i] ? "" : " (fmt is inexact!)");
// exits("oops");
}
diff --git a/src/lib9/testfmt.c b/src/lib9/testfmt.c
index fd2b7039..11708ba3 100644
--- a/src/lib9/testfmt.c
+++ b/src/lib9/testfmt.c
@@ -90,14 +90,14 @@ main(int argc, char **argv)
verify(smprint("%d", 23), "23");
verify(smprint("%i", 23), "23");
verify(smprint("%Zi", 1234, 23), "23");
-
+
/* ANSI and their wacky corner cases */
verify(smprint("%.0d", 0), "");
verify(smprint("%.0o", 0), "");
verify(smprint("%.0x", 0), "");
verify(smprint("%#.0o", 0), "0");
verify(smprint("%#.0x", 0), "");
-
+
/* difficult floating point tests that many libraries get wrong */
verify(smprint("%.100f", 1.0), "1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
verify(smprint("%.100g", 1.0), "1");
@@ -112,7 +112,7 @@ main(int argc, char **argv)
verify(smprint("%3$d %4$*5$06d %2$d %1$d", 444, 333, 111, 222, 20), "111 000222 333 444");
verify(smprint("%3$hd %4$*5$06d %2$d %1$d", 444, 333, (short)111, 222, 20), "111 000222 333 444");
verify(smprint("%3$\xe2\x98\xba""d %5$06d %2$d %1$d", 444, 333, 555, 111, 222), "111 000222 333 444");
-
+
/* test %'d formats */
verify(smprint("%'d %'d %'d", 1, 2222, 33333333), "1 2,222 33,333,333");
verify(smprint("%'019d", 0), "000,000,000,000,000");
diff --git a/src/lib9/testprint.c b/src/lib9/testprint.c
index 242befb4..b2c04208 100644
--- a/src/lib9/testprint.c
+++ b/src/lib9/testprint.c
@@ -5,7 +5,7 @@ void
main(int argc, char **argv)
{
char c;
-
+
c = argv[1][strlen(argv[1])-1];
if(c == 'f' || c == 'e' || c == 'g' || c == 'F' || c == 'E' || c == 'G')
print(argv[1], atof(argv[2]));
diff --git a/src/lib9/time.c b/src/lib9/time.c
index 36706367..92ad2ca4 100644
--- a/src/lib9/time.c
+++ b/src/lib9/time.c
@@ -55,4 +55,3 @@ p9time(long *tt)
*tt = t;
return t;
}
-
diff --git a/src/lib9/tm2sec.c b/src/lib9/tm2sec.c
index 5edf439d..58bbe992 100644
--- a/src/lib9/tm2sec.c
+++ b/src/lib9/tm2sec.c
@@ -103,7 +103,7 @@ tm2sec(Tm *tm)
secs -= ti->tzoff;
}
}
-
+
if(secs < 0)
secs = 0;
return secs;
diff --git a/src/lib9/u64.c b/src/lib9/u64.c
index a17bdf1d..84e5fe0e 100644
--- a/src/lib9/u64.c
+++ b/src/lib9/u64.c
@@ -35,7 +35,7 @@ dec64(uchar *out, int lim, char *in, int n)
b24 = 0;
i = 0;
while(n-- > 0){
-
+
c = t64d[*(uchar*)in++];
if(c == INVAL)
continue;
diff --git a/src/lib9/udp.c b/src/lib9/udp.c
index a1164723..a9c4cb68 100644
--- a/src/lib9/udp.c
+++ b/src/lib9/udp.c
@@ -49,4 +49,3 @@ udpwrite(int fd, Udphdr *hdr, void *buf, long n)
*(u16int*)&sin.sin_port = *(u16int*)hdr->rport;
return sendto(fd, buf, n, 0, (struct sockaddr*)&sin, sizeof sin);
}
-
diff --git a/src/lib9/unsharp.c b/src/lib9/unsharp.c
index b7db700c..251cae5d 100644
--- a/src/lib9/unsharp.c
+++ b/src/lib9/unsharp.c
@@ -3,7 +3,7 @@
/*
* I don't want too many of these,
- * but the ones we have are just too useful.
+ * but the ones we have are just too useful.
*/
static struct {
char *old;
diff --git a/src/lib9/utf/lib9.h b/src/lib9/utf/lib9.h
index e6128ae4..450f28f0 100644
--- a/src/lib9/utf/lib9.h
+++ b/src/lib9/utf/lib9.h
@@ -14,4 +14,3 @@ typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
-
diff --git a/src/lib9/utf/plan9.h b/src/lib9/utf/plan9.h
index e40e33eb..1ca8ace7 100644
--- a/src/lib9/utf/plan9.h
+++ b/src/lib9/utf/plan9.h
@@ -26,4 +26,3 @@ typedef unsigned long ulong;
#undef nelem
#define nelem(x) (sizeof (x)/sizeof (x)[0])
-
diff --git a/src/lib9/utf/rune.c b/src/lib9/utf/rune.c
index f5944806..bb2d82cb 100644
--- a/src/lib9/utf/rune.c
+++ b/src/lib9/utf/rune.c
@@ -155,7 +155,7 @@ runetochar(char *str, Rune *rune)
str[2] = Tx | (c & Maskx);
return 3;
}
-
+
/*
* four character sequence
* 010000-1FFFFF => T4 Tx Tx Tx
diff --git a/src/lib9/utf/runestrdup.c b/src/lib9/utf/runestrdup.c
index 8170e7bc..4f9d6f42 100644
--- a/src/lib9/utf/runestrdup.c
+++ b/src/lib9/utf/runestrdup.c
@@ -18,8 +18,8 @@
#include "utf.h"
Rune*
-runestrdup(Rune *s)
-{
+runestrdup(Rune *s)
+{
Rune *ns;
ns = malloc(sizeof(Rune)*(runestrlen(s) + 1));
diff --git a/src/lib9/utf/utfdef.h b/src/lib9/utf/utfdef.h
index 1ff41813..1db7076d 100644
--- a/src/lib9/utf/utfdef.h
+++ b/src/lib9/utf/utfdef.h
@@ -30,4 +30,3 @@ typedef long long vlong;
#undef nelem
#define nelem ((void*)0)
-
diff --git a/src/lib9/wait.c b/src/lib9/wait.c
index 31d8c02a..17d76786 100644
--- a/src/lib9/wait.c
+++ b/src/lib9/wait.c
@@ -51,4 +51,3 @@ waitfor(int pid)
return _wait(awaitfor(pid, buf, sizeof buf-1), buf);
}
-
diff --git a/src/lib9/waitpid.c b/src/lib9/waitpid.c
index 3df8ef89..4c90bb78 100644
--- a/src/lib9/waitpid.c
+++ b/src/lib9/waitpid.c
@@ -17,4 +17,3 @@ waitpid(void)
}
return atoi(fld[0]);
}
-
diff --git a/src/lib9/zoneinfo.c b/src/lib9/zoneinfo.c
index 91f1885a..f8ae442d 100644
--- a/src/lib9/zoneinfo.c
+++ b/src/lib9/zoneinfo.c
@@ -4,7 +4,7 @@
/*
* Access local time entries of zoneinfo files.
* Formats 0 and 2 are supported, and 4-byte timestamps
- *
+ *
* Copyright © 2008 M. Teichgräber
* Contributed under the terms of the Lucent Public License 1.02.
*/
diff --git a/src/lib9/zoneinfo.h b/src/lib9/zoneinfo.h
index 55e60df9..e2ea963d 100644
--- a/src/lib9/zoneinfo.h
+++ b/src/lib9/zoneinfo.h
@@ -16,4 +16,3 @@ struct Tinfo
extern int zonelookuptinfo(Tinfo*, tlong);
extern int zonetinfo(Tinfo*, int);
extern void zonedump(int fd);
-