1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-02-08 12:31:09 +00:00

Trying to track down file write corruption

This commit is contained in:
David Schmenk 2019-12-30 22:34:35 -08:00
parent de29742841
commit c743ace42b
2 changed files with 23 additions and 24 deletions

Binary file not shown.

View File

@ -247,7 +247,7 @@ def strpoolalloc(size)
end
def striplead(strptr, chr)#0
byte striplen
for striplen = 1 to ^strptr
if ^(strptr + striplen) <> chr
break
@ -391,7 +391,7 @@ end
def strtonum(strptr)
word num, i
byte c
num = 0
for i = 1 to ^strptr
c = ^(strptr + i) & $7F
@ -438,9 +438,8 @@ def readtxt(filename, startline)#0
putln
end
def writetxt(filename)#0
word i, strptr
byte refnum, j, chr
byte txtbuf[MAXLNLEN+2]
word i
byte refnum, txtbuf[MAXLNLEN+2]
fileio:destroy(filename)
fileio:create(filename, $04, $00) // full access, TXT file
@ -558,7 +557,7 @@ end
def drawscrn(toprow, ofst)#0
byte row, numchars, lofst
word strptr, scrnptr
lofst = flags & gutter
if lofst
drawgutter(toprow, ofst)
@ -598,7 +597,7 @@ def drawscrn(toprow, ofst)#0
end
def cursoff#0
word scrnptr
if flags & showcurs
^cursptr = underchr
if flags & gutter
@ -607,13 +606,13 @@ def cursoff#0
^(scrnptr+2) = ^(scrnptr+2) | $80
fin
flags = flags & ~showcurs
fin
end
def curson#0
byte lofst
word scrnptr
if !(flags & showcurs)
lofst = flags & gutter
if lofst
@ -644,7 +643,7 @@ def redraw#0
end
def curshpos(hpos)#1
byte needredraw
needredraw = TRUE
if hpos < 0; hpos = 0; fin
if hpos > MAXLNLEN; hpos = MAXLNLEN; fin
@ -777,7 +776,7 @@ def cursleft#0
end
def pgleft#0
word i, strptr
strptr = txtlinbuf=>[cursrow]
if curscol > ^strptr
i = ^strptr
@ -818,7 +817,7 @@ def cursright#0
end
def pgright#0
word i, strptr
strptr = txtlinbuf=>[cursrow]
if curscol >= ^strptr
i = curscol + 8
@ -849,7 +848,7 @@ end
//
def findline(strptr, start)#1
byte scan, i, upstr[MAXLNLEN+1]
if ^strptr >= findstr
lnupcpy(@upstr, strptr)
for scan = start to upstr - findstr + 1
@ -1098,7 +1097,7 @@ def printtxt(slot)#0
end
def freesel#0
word i
for i = 0 to numcliplines - 1
if cliplinbuf=>[i] <> @nullstr
delstr(cliplinbuf=>[i])
@ -1109,7 +1108,7 @@ def freesel#0
end
def selrange#2
word first, last
if flags & selection
if cursrow > selrow
first, last = selrow, cursrow
@ -1129,7 +1128,7 @@ def beginsel#0
end
def copysel#0
word firstsel, lastsel
freesel
firstsel, lastsel = selrange
for numcliplines = 0 to lastsel - firstsel
@ -1140,7 +1139,7 @@ def copysel#0
end
def cutsel#0
word firstsel, lastsel
freesel
firstsel, lastsel = selrange
if lastsel - firstsel < MAXCLIPLINES
@ -1169,7 +1168,7 @@ def cutsel#0
end
def pastesel#0
word p
if numcliplines and numcliplines + numlines < MAXLINES
memcpy(@txtlinbuf=>[cursrow + numcliplines], @txtlinbuf=>[cursrow], (numlines - cursrow) * 2)
for p = 0 to numcliplines - 1
@ -1185,7 +1184,7 @@ end
def indentsel#0
byte indentstr[MAXLNLEN+1], l
word firstsel, lastsel, i
freesel
firstsel, lastsel = selrange
for i = firstsel to lastsel
@ -1205,7 +1204,7 @@ end
def undentsel#0
byte undentstr[MAXLNLEN+1], l
word firstsel, lastsel, i
freesel
firstsel, lastsel = selrange
for i = firstsel to lastsel
@ -1230,12 +1229,12 @@ def undentsel#0
end
def autoindent(strptr)#0
byte i
for i = 1 to ^strptr
if ^(strptr + i) <> keyspace
break
fin
next
next
curshpos(i - 1)
end
def openline(row)
@ -1289,7 +1288,7 @@ def splitline#0
memcpy(@splitstr + 2, @splitstr + 1, splitstr)
splitstr[1] = keyspace
splitstr++
next
next
txtlinbuf=>[cursrow + 1] = newstr(@splitstr)
splitstr = curscol
memcpy(@splitstr + 1, txtlinbuf=>[cursrow] + 1, splitstr)
@ -1303,7 +1302,7 @@ def splitline#0
break
fin
next
curshpos(curscol - 1)
curshpos(curscol - 1)
fin
fin
else