URI: 
       tacme: correct modified message after initial load; more detail in message - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit daea2c7d501c3e825bede80992ade6b241efdce1
   DIR parent 1961ee822320bdc107e55f10b2db1bfe8f70d382
  HTML Author: Russ Cox <russcox@gmail.com>
       Date:   Fri, 25 Sep 2009 01:43:54 -0400
       
       acme: correct modified message after initial load; more detail in
       message
       
       http://codereview.appspot.com/123051
       
       Diffstat:
         M src/cmd/acme/acme.c                 |      16 +++++++++++++++-
         M src/cmd/acme/dat.h                  |       4 ++--
         M src/cmd/acme/exec.c                 |      10 +++++-----
         M src/cmd/acme/look.c                 |       3 ++-
         M src/cmd/acme/text.c                 |      10 +++++-----
       
       5 files changed, 29 insertions(+), 14 deletions(-)
       ---
   DIR diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
       t@@ -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;
       t@@ -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");
       t@@ -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);
       +}
       +
   DIR diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
       t@@ -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 */
       t@@ -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*);
   DIR diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c
       t@@ -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;
                        }
                }
   DIR diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c
       t@@ -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);
   DIR diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
       t@@ -188,7 +188,7 @@ textcolumnate(Text *t, Dirlist **dlp, int ndl)
                }
        }
        
       -uint
       +int
        textload(Text *t, uint q0, char *file, int setqid)
        {
                Rune *rp;
       t@@ -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){
       t@@ -303,7 +303,7 @@ textload(Text *t, uint q0, char *file, int setqid)
        
            Rescue:
                close(fd);
       -        return 0;
       +        return -1;
        }
        
        uint