develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33727 - trunk/src/pmc

From:
pmichaud
Date:
December 9, 2008 13:47
Subject:
[svn:parrot] r33727 - trunk/src/pmc
Message ID:
20081209214707.E1C8DCB9AF@x12.develooper.com
Author: pmichaud
Date: Tue Dec  9 13:47:06 2008
New Revision: 33727

Modified:
   trunk/src/pmc/filehandle.pmc

Log:
[io]: Make readline_interactive more consistent when readline lib isn't present.


Modified: trunk/src/pmc/filehandle.pmc
==============================================================================
--- trunk/src/pmc/filehandle.pmc	(original)
+++ trunk/src/pmc/filehandle.pmc	Tue Dec  9 13:47:06 2008
@@ -299,14 +299,33 @@
             mem_sys_free(r);
             RETURN(STRING *string_result);
         }
-#endif
+
+        RETURN(PMC *PMCNULL);
+#else
+        UINTVAL len;
+
+        if (got_prompt) 
+            fprintf(stderr, "%s", prompt->strstart);
 
         if (!(PARROT_FILEHANDLE(SELF)->flags & PIO_F_LINEBUF))
             Parrot_io_setlinebuf(INTERP, SELF);
 
         string_result = Parrot_io_reads(INTERP, SELF, 0);
+        if (!string_result)
+            RETURN(PMC *PMCNULL);
+        len = string_length(INTERP, string_result);
+        if (len < 1)
+            RETURN(PMC *PMCNULL);
+        while (len > 0 && 
+                (((char*)string_result->strstart)[len - 1] == '\n' ||
+                 ((char*)string_result->strstart)[len - 1] == '\r')) {
+            --len;
+            --string_result->strlen;
+            --string_result->bufused;
+        }
 
         RETURN(STRING *string_result);
+#endif
     }
 
 /*



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About