Author: wmb Date: 2008-10-28 00:37:02 +0100 (Tue, 28 Oct 2008) New Revision: 988
Modified: clients/lib/lib.c ofw/core/filecmds.fth Log: OLPC trac 8897 - EMACS was leaving cruft at the end of files.
Modified: clients/lib/lib.c =================================================================== --- clients/lib/lib.c 2008-10-25 00:54:23 UTC (rev 987) +++ clients/lib/lib.c 2008-10-27 23:37:02 UTC (rev 988) @@ -105,10 +105,13 @@ if (fp == (FILE *)NULL) return ((FILE *)NULL);
+ if (mode[0] == 'w') { + if ((fp->id = OFCreate(name)) == 0) + return ((FILE *)NULL); + goto good; + } + if ((fp->id = OFOpen(name)) == 0) { - if (mode[0] == 'w' && ((fp->id = OFCreate(name)) != 0)) - goto good; - return ((FILE *)NULL); }
Modified: ofw/core/filecmds.fth =================================================================== --- ofw/core/filecmds.fth 2008-10-25 00:54:23 UTC (rev 987) +++ ofw/core/filecmds.fth 2008-10-27 23:37:02 UTC (rev 988) @@ -527,7 +527,18 @@
dev /client-services : firmworks,create ( cstr -- ihandle ) - cscount ['] $create-file catch if 2drop 0 then + cscount ( path$ ) + + \ If the file already exists, delete it so it can be + \ recreated with 0 initial length. + 2dup ['] $open-file catch if ( path$ x x ) + 2drop ( path$ ) + else ( path$ ih ) + close-dev ( path$ ) + 2dup ['] $delete catch if 2drop then ( path$ ) + then ( path$ ) + + ['] $create-file catch if 2drop 0 then ; device-end
openfirmware@openfirmware.info