AmendHub

Download (as of this amendment):

jcs

/

amend

/

amendments

/

197

util: Put resource fork size in a different field in 'struct stat'

Anything that cares about the size of the resource fork is going to
need to be modified to do something with it, so adding them together
as st_size was not helpful.
 
This was the root cause of the optimization in repo that tried to
skip unchanged files not working, since the resource forks of .c
files in THINK C are modified frequently even when the content
doesn't change.
 
Also fix a bug in TEGetWidth using the wrong fields, and a memory
leak in UpdateScrollbarForTE.

jcs made amendment 197 18 days ago
--- util.c Sun Oct 4 00:01:32 2026 +++ util.c Sun Oct 4 12:03:40 2026 @@ -1236,9 +1236,8 @@ FStat(Str255 path, struct stat *sb) if (ret != noErr) return -1; - /* data fork logical length + resource fork logical length */ - sb->st_size = catblock.hFileInfo.ioFlLgLen + - catblock.hFileInfo.ioFlRLgLen; + sb->st_size = catblock.hFileInfo.ioFlLgLen; + sb->st_rsize = catblock.hFileInfo.ioFlRLgLen; sb->st_ctime = catblock.hFileInfo.ioFlCrDat; sb->st_mtime = catblock.hFileInfo.ioFlMdDat; sb->st_flags = catblock.hFileInfo.ioFlAttrib; @@ -1607,12 +1606,12 @@ TEGetWidth(short off, TEHandle te) TEGetStyle(off, &style, &fheight, &ascent, te); - old_font = thePort->txFace; + old_font = thePort->txFont; old_size = thePort->txSize; - thePort->txFace = style.tsFont; + thePort->txFont = style.tsFont; thePort->txSize = style.tsSize; fwidth = CharWidth('m'); - thePort->txFace = old_font; + thePort->txFont = old_font; thePort->txSize = old_size; return fwidth; @@ -1701,7 +1700,7 @@ UpdateScrollbarForTE(GrafPtr win, ControlHandle contro rgn = NewRgn(); RectRgn(rgn, &(*control)->contrlRect); UpdtControl(win, rgn); - CloseRgn(rgn); + DisposeRgn(rgn); HUnlock(te); HUnlock(control); @@ -1761,8 +1760,10 @@ TrackMouseDownInControl(ControlHandle control, short p adj = -(val - GetCtlMin(control)); if (val + adj > GetCtlMax(control)) adj = (GetCtlMax(control) - val); - if (adj == 0) + if (adj == 0) { + HUnlock(track_control_te); return; + } if (horiz) TEScroll(-adj * fwidth, 0, track_control_te); --- util.h Fri Oct 2 17:48:30 2026 +++ util.h Sun Oct 4 12:05:16 2026 @@ -72,6 +72,7 @@ struct stat { time_t st_ctime; time_t st_mtime; unsigned char st_flags; + ssize_t st_rsize; }; void util_init(void);