diff options
author | Russ Cox <russcox@gmail.com> | 2009-09-25 01:43:54 -0400 |
---|---|---|
committer | Russ Cox <russcox@gmail.com> | 2009-09-25 01:43:54 -0400 |
commit | daea2c7d501c3e825bede80992ade6b241efdce1 (patch) | |
tree | 7b222116d5eb48265654660917dbd0b5be630fcc | |
parent | 1961ee822320bdc107e55f10b2db1bfe8f70d382 (diff) | |
download | plan9port-daea2c7d501c3e825bede80992ade6b241efdce1.tar.gz plan9port-daea2c7d501c3e825bede80992ade6b241efdce1.tar.bz2 plan9port-daea2c7d501c3e825bede80992ade6b241efdce1.zip |
acme: correct modified message after initial load; more detail in
message
http://codereview.appspot.com/123051
-rw-r--r-- | src/cmd/acme/acme.c | 16 | ||||
-rw-r--r-- | src/cmd/acme/dat.h | 4 | ||||
-rw-r--r-- | src/cmd/acme/exec.c | 10 | ||||
-rw-r--r-- | src/cmd/acme/look.c | 3 | ||||
-rw-r--r-- | src/cmd/acme/text.c | 10 |
5 files changed, 29 insertions, 14 deletions
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index ed8307e1..740f3617 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -19,7 +19,8 @@ void keyboardthread(void*); void waitthread(void*); void xfidallocthread(void*); void newwindowthread(void*); -void plumbproc(void*); +void plumbproc(void*); +int timefmt(Fmt*); Reffont **fontcache; int nfontcache; @@ -127,6 +128,8 @@ threadmain(int argc, char *argv[]) fontnames[1] = estrdup(fontnames[1]); quotefmtinstall(); + fmtinstall('t', timefmt); + cputype = getenv("cputype"); objtype = getenv("objtype"); home = getenv("HOME"); @@ -1067,3 +1070,14 @@ ismtpt(char *file) n = strlen(mtpt); return strncmp(file, mtpt, n) == 0 && ((n > 0 && mtpt[n-1] == '/') || file[n] == '/' || file[n] == 0); } + +int +timefmt(Fmt *f) +{ + Tm *tm; + + tm = localtime(va_arg(f->args, ulong)); + return fmtprint(f, "%04d/%02d/%02d %02d:%02d:%02d", + tm->year+1900, tm->mon+1, tm->mday, tm->hour, tm->min, tm->sec); +} + diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h index 8242da69..b15395fd 100644 --- a/src/cmd/acme/dat.h +++ b/src/cmd/acme/dat.h @@ -134,7 +134,7 @@ struct File Rune *name; /* name of associated file */ int nname; /* size of name */ uvlong qidpath; /* of file when read */ - uint mtime; /* of file when read */ + ulong mtime; /* of file when read */ int dev; /* of file when read */ int unread; /* file has not been read from disk */ int editclean; /* mark clean after edit command */ @@ -210,7 +210,7 @@ void textfill(Text*); void textframescroll(Text*, int); void textinit(Text*, File*, Rectangle, Reffont*, Image**); void textinsert(Text*, uint, Rune*, uint, int); -uint textload(Text*, uint, char*, int); +int textload(Text*, uint, char*, int); Rune textreadc(Text*, uint); void textredraw(Text*, Rectangle, Font*, Image*, int); void textreset(Text*); diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index 86c21d64..d24775df 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -644,14 +644,14 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) d = dirstat(name); if(d!=nil && runeeq(namer, nname, f->name, f->nname)){ /* f->mtime+1 because when talking over NFS it's often off by a second */ - if(f->dev!=d->dev || f->qidpath!=d->qid.path || f->mtime+1<d->mtime){ - f->dev = d->dev; - f->qidpath = d->qid.path; - f->mtime = d->mtime; + if(f->dev!=d->dev || f->qidpath!=d->qid.path || abs(f->mtime-d->mtime) > 1){ if(f->unread) warning(nil, "%s not written; file already exists\n", name); else - warning(nil, "%s modified%s%s since last read\n", name, d->muid[0]?" by ":"", d->muid); + warning(nil, "%s modified%s%s since last read\n\twas %t; now %t\n", name, d->muid[0]?" by ":"", d->muid, f->mtime, d->mtime); + f->dev = d->dev; + f->qidpath = d->qid.path; + f->mtime = d->mtime; goto Rescue1; } } diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index 3a92e000..aec850b8 100644 --- a/src/cmd/acme/look.c +++ b/src/cmd/acme/look.c @@ -754,7 +754,8 @@ openfile(Text *t, Expand *e) w = makenewwindow(t); t = &w->body; winsetname(w, e->name, e->nname); - textload(t, 0, e->bname, 1); + if(textload(t, 0, e->bname, 1) >= 0) + t->file->unread = FALSE; t->file->mod = FALSE; t->w->dirty = FALSE; winsettag(t->w); diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c index 1b56076c..7ea4131c 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -188,7 +188,7 @@ textcolumnate(Text *t, Dirlist **dlp, int ndl) } } -uint +int textload(Text *t, uint q0, char *file, int setqid) { Rune *rp; @@ -203,16 +203,16 @@ textload(Text *t, uint q0, char *file, int setqid) error("text.load"); if(t->w->isdir && t->file->nname==0){ warning(nil, "empty directory name"); - return 0; + return -1; } if(ismtpt(file)){ warning(nil, "will not open self mount point %s\n", file); - return 0; + return -1; } fd = open(file, OREAD); if(fd < 0){ warning(nil, "can't open %s: %r\n", file); - return 0; + return -1; } d = dirfstat(fd); if(d == nil){ @@ -303,7 +303,7 @@ textload(Text *t, uint q0, char *file, int setqid) Rescue: close(fd); - return 0; + return -1; } uint |