Hello, Manuel,

Please find attached patches that add support to open-output-file for the 
"pipe:" prefix. I found it odd that both "|" and "pipe:" were supported for 
open-input-file but not for open-output-file.

Best Regards,
Joe
--- bigloo4.0b/runtime/Clib/cports.c	2013-08-01 02:50:44.000000000 -0400
+++ bigloo4.0bmod/runtime/Clib/cports.c	2013-08-25 12:54:09.575404695 -0400
@@ -2019,7 +2019,9 @@
 /*---------------------------------------------------------------------*/
 static bool_t
 pipe_name_p( char *name ) {
-   return( (name[ 0 ] == '|') && (name[ 1 ] == ' ') );
+   int length = strlen(name);
+   return ( length > 2 && (name[ 0 ] == '|') && (name[ 1 ] == ' ') ) 
+          || ( length > 5 && strncmp(name, "pipe:", 5) == 0 );
 }
 
 /*---------------------------------------------------------------------*/
@@ -2030,7 +2032,9 @@
 /*---------------------------------------------------------------------*/
 static char *
 pipe_name( char *pipe_name ) {
-   return (pipe_name + 1);
+  /* if | is used the offset is 1, otherwise, if pipe: is used, it is 5 */ 
+   int offset = (pipe_name[0] == '|') ? 1 : 5;
+   return (pipe_name + offset);
 }
 
 /*---------------------------------------------------------------------*/
--- bigloo4.0b/runtime/Jlib/output_pipe_port.java	2013-08-01 02:50:44.000000000 -0400
+++ bigloo4.0bmod/runtime/Jlib/output_pipe_port.java	2013-08-25 13:02:54.528756217 -0400
@@ -22,7 +22,16 @@
    Thread thread;
    
    static boolean pipe_name_p( final byte[] name ) {
-      return ( (name[ 0 ] == (byte)'|') && (name[ 1 ] == (byte)' ') );
+      
+      return ( name.length > 2 
+               && (name[ 0 ] == (byte)'|') 
+               && (name[ 1 ] == (byte)' ') )
+	  || (name.length > 5 
+	      && name[ 0 ] == (byte)'p'
+	      && name[ 1 ] == (byte)'i'
+	      && name[ 2 ] == (byte)'p'
+	      && name[ 3 ] == (byte)'e'
+	      && name[ 4 ] == (byte)':');
    }
 
    static int skip_whitespace( byte[] s, int i ) {
@@ -34,7 +43,9 @@
    static String[] tokenizer( byte[] s ) {
       int len = s.length;
       Vector v = new Vector();
-      int i = skip_whitespace( s, 1 );
+      // if | then offset = 2, otherwise, if pipe: offset = 5
+      int offset =  (s[0] == (byte)'|') ? 2 : 5;
+      int i = skip_whitespace( s, offset );
 
       while( i < len ) {
 	 int j = i;
@@ -66,7 +77,10 @@
 	 String[] scmd = new String[ 3 ];
 	 scmd[ 0 ] = new String( configure.SHELL );
 	 scmd[ 1 ] = "-c";
-	 scmd[ 2 ] = new String( s, 2, s.length - 2 );
+         
+         // if | then offset = 2, otherwise, if pipe: offset = 5
+         int offset =  (s[0] == (byte)'|') ? 2 : 5;
+	 scmd[ 2 ] = new String( s, offset, s.length - offset );
 
 	 return scmd;
       } else {

Reply via email to