From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Faiz Newsgroups: gmane.lisp.guile.devel Subject: rdelim: Add new procedure `for-line-in-file`. Date: Mon, 16 Dec 2024 00:00:01 +0800 Message-ID: <68eef85f-611e-3245-fa5a-675dc3484def@disroot.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12575"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Dec 15 17:36:40 2024 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tMrbk-00037W-Gy for guile-devel@m.gmane-mx.org; Sun, 15 Dec 2024 17:36:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMrbB-0005pF-2g; Sun, 15 Dec 2024 11:36:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMr6y-0000wZ-3o for guile-devel@gnu.org; Sun, 15 Dec 2024 11:04:52 -0500 Original-Received: from layka.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tMr6v-0003Vm-RP for guile-devel@gnu.org; Sun, 15 Dec 2024 11:04:51 -0500 Original-Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 1841A252DE for ; Sun, 15 Dec 2024 17:04:45 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Original-Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id dFSc_SSyp1iB for ; Sun, 15 Dec 2024 17:04:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1734278404; bh=bKS8OsyElmW44A/Ik3YeUBERpnZTdw7/zzoYnyu2WWg=; h=Date:To:From:Subject; b=RnfPby7qWj7aeC0QZ1rdtcOWYMYcYynwy/1CkqvT8u1ivgocrATKHu3vX5/2ZCVHz u58Ip7jwePfhchaYlER6KuEzyt7iFIPAY5e0ZyFPowYICifv04GUZ5C7Fd1YBINzJD LreNDTJR1eGjce7LAPFB078SVOVUY6o473R19y9WY/HlVx2zIWukbxDbPIWGMBobSl /D4eUAMP287bj52rT6fU6xH5i6OWzADkDFNd6rxb7WKsqY5QyKHyGol0s55JKYbmSO f4Gmqrpu0c/inBpTQrNUm6nzNKsVp6KLaOYFXe+I224LonABxyPHjtzuLmiEG4JVdi ybflKUJaqxDBQ== Content-Language: en-US Received-SPF: pass client-ip=178.21.23.139; envelope-from=adam.faiz@disroot.org; helo=layka.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 15 Dec 2024 11:36:02 -0500 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22812 Archived-At: >From 18485a2b94595ae2239f5dcdeb06d3a80bb04bf1 Mon Sep 17 00:00:00 2001 From: AwesomeAdam54321 Date: Sun, 15 Dec 2024 23:48:30 +0800 Subject: [PATCH] rdelim: Add new procedure `for-line-in-file`. * module/ice-9/rdelim.scm (for-line-in-file): Add it. --- module/ice-9/rdelim.scm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/module/ice-9/rdelim.scm b/module/ice-9/rdelim.scm index d2cd081d7..ffa38efad 100644 --- a/module/ice-9/rdelim.scm +++ b/module/ice-9/rdelim.scm @@ -206,3 +206,15 @@ characters to read. By default, there is no limit." line) (else (error "unexpected handle-delim value: " handle-delim))))) + +;;; for-line-in-file [PORT BODY] calls BODY (a procedure with the +;;; line from PORT as it's argument) for every line until the +;;; eof-object is reached. The line provided to BODY is guaranteed +;;; to be a string. + +(define (for-line-in-file file body) + (while #t + (let ((line (read-line file))) + (if (string? line) + (body line) + (break))))) -- 2.41.0