From owner-freebsd-current Sat Oct 6 12:31:41 2001 Delivered-To: freebsd-current@freebsd.org Received: from hawk.mail.pas.earthlink.net (hawk.mail.pas.earthlink.net [207.217.120.22]) by hub.freebsd.org (Postfix) with ESMTP id 96BD037B405 for ; Sat, 6 Oct 2001 12:31:30 -0700 (PDT) Received: from mindspring.com (dialup-209.245.131.216.Dial1.SanJose1.Level3.net [209.245.131.216]) by hawk.mail.pas.earthlink.net (EL-8_9_3_3/8.9.3) with ESMTP id MAA11703 for ; Sat, 6 Oct 2001 12:31:28 -0700 (PDT) Message-ID: <3BBF5C3E.3F88B4CD@mindspring.com> Date: Sat, 06 Oct 2001 12:32:14 -0700 From: Terry Lambert Reply-To: tlambert2@mindspring.com X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: current@freebsd.org Subject: FORTH PATCH FOR KRIS TO COMMIT Content-Type: multipart/mixed; boundary="------------D1FD7E74232804756F25371E" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------D1FD7E74232804756F25371E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Here is a patch to add the verbs "fwrite" and "flseek" to the FORTH interpreter. This is a necessary part of reimplementing the "nextboot" code, which was murdered when the new boot loader came in. Commit, K PLZ THX. -- Terry --------------D1FD7E74232804756F25371E Content-Type: text/plain; charset=us-ascii; name="forth.pat.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="forth.pat.txt" Index: boot/ficl/words.c =================================================================== RCS file: /home/cvs/clickarray/FreeBSD/sys.releng4/boot/ficl/words.c,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 words.c *** boot/ficl/words.c 2001/03/21 00:50:28 1.1.1.1 --- boot/ficl/words.c 2001/06/08 04:15:33 *************** *** 4256,4262 **** #endif (void)stackPopINT(pVM->pStack); /* don't need count value */ p = stackPopPtr(pVM->pStack); ! fd = open(p, O_RDONLY); stackPushINT(pVM->pStack, fd); return; } --- 4256,4262 ---- #endif (void)stackPopINT(pVM->pStack); /* don't need count value */ p = stackPopPtr(pVM->pStack); ! fd = open(p, O_RDWR); stackPushINT(pVM->pStack, fd); return; } *************** *** 4300,4305 **** --- 4300,4348 ---- return; } + /* fwrite - write file contents + * + * fwrite ( fd buf nbytes -- nwritten ) + */ + static void pfwrite(FICL_VM *pVM) + { + int fd, len; + char *buf; + + #if FICL_ROBUST > 1 + vmCheckStack(pVM, 3, 1); + #endif + len = stackPopINT(pVM->pStack); /* get number of bytes to write */ + buf = stackPopPtr(pVM->pStack); /* get buffer */ + fd = stackPopINT(pVM->pStack); /* get fd */ + if (len > 0 && buf && fd != -1) + stackPushINT(pVM->pStack, write(fd, buf, len)); + else + stackPushINT(pVM->pStack, -1); + return; + } + + /* flseek - seek to file offset + * + * flseek ( fd offset whence -- whence ) + */ + static void pflseek(FICL_VM *pVM) + { + int fd, whence, offset; + + #if FICL_ROBUST > 1 + vmCheckStack(pVM, 3, 1); + #endif + whence = stackPopINT(pVM->pStack); /* get whence */ + offset = stackPopINT(pVM->pStack); /* get offset */ + fd = stackPopINT(pVM->pStack); /* get fd */ + if (whence >= 0 && whence <= 2 && offset >= 0 && fd != -1) + stackPushINT(pVM->pStack, lseek(fd, offset, whence)); + else + stackPushINT(pVM->pStack, -1); + return; + } + /* fload - interpret file contents * * fload ( fd -- ) *************** *** 4808,4813 **** --- 4851,4858 ---- dictAppendWord(dp, "fopen", pfopen, FW_DEFAULT); dictAppendWord(dp, "fclose", pfclose, FW_DEFAULT); dictAppendWord(dp, "fread", pfread, FW_DEFAULT); + dictAppendWord(dp, "fwrite", pfwrite, FW_DEFAULT); + dictAppendWord(dp, "flseek", pflseek, FW_DEFAULT); dictAppendWord(dp, "fload", pfload, FW_DEFAULT); dictAppendWord(dp, "fkey", fkey, FW_DEFAULT); dictAppendWord(dp, "key", key, FW_DEFAULT); --------------D1FD7E74232804756F25371E-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message