This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
If comparison is always true, while (1) should suffice.
authorJames E Keenan <jkeenan@cpan.org>
Fri, 30 Nov 2018 15:33:07 +0000 (10:33 -0500)
committerJames E Keenan <jkeenan@cpan.org>
Tue, 29 Jan 2019 23:51:37 +0000 (18:51 -0500)
Per suggestion by Dave Mitchell in RT 133703, re-implemented in RT
133744.

sv.c

diff --git a/sv.c b/sv.c
index ad238cd..b3c4024 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -8535,18 +8535,19 @@ Perl_sv_gets(pTHX_ SV *const sv, PerlIO *const fp, I32 append)
      * null assign is a placeholder. */
     rslast = rslen ? rsptr[rslen - 1] : '\0';
 
-    if (rspara) {              /* have to do this both before and after */
-       do {                    /* to make sure file boundaries work right */
-           if (PerlIO_eof(fp))
-               return 0;
-           i = PerlIO_getc(fp);
-           if (i != '\n') {
-               if (i == -1)
-                   return 0;
-               PerlIO_ungetc(fp,i);
-               break;
-           }
-       } while (i != EOF);
+    if (rspara) {        /* have to do this both before and after */
+                         /* to make sure file boundaries work right */
+        while (1) {
+            if (PerlIO_eof(fp))
+                return 0;
+            i = PerlIO_getc(fp);
+            if (i != '\n') {
+                if (i == -1)
+                    return 0;
+                PerlIO_ungetc(fp,i);
+                break;
+            }
+        }
     }
 
     /* See if we know enough about I/O mechanism to cheat it ! */