[Commit] nickle/builtin file.c,1.12,1.13

Bart Massey commit at keithp.com
Sun Oct 12 22:33:38 PDT 2003


Committed by: bart

Update of /local/src/CVS/nickle/builtin
In directory home.keithp.com:/tmp/cvs-serv2126/builtin

Modified Files:
	file.c 
Log Message:
Replace pipe() builtin with filter() and mkpipe().  Yes, the
name mkpipe() is a poor choice, but didn't want existing
apps to be confused about what happened.  Will implement
popen() atop these primitives eventually.



Index: file.c
===================================================================
RCS file: /local/src/CVS/nickle/builtin/file.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- file.c	26 Jun 2003 08:59:10 -0000	1.12
+++ file.c	13 Oct 2003 04:33:36 -0000	1.13
@@ -32,6 +32,7 @@
     ENTER ();
     static const struct fbuiltin_0 funcs_0[] = {
         { do_File_string_write, "string_write", "f", "" },
+	{ do_File_mkpipe, "mkpipe", "A*f", "" },
         { 0 }
     };
 
@@ -60,7 +61,7 @@
     };
 
     static const struct fbuiltin_3 funcs_3[] = {
-        { do_File_pipe, "pipe", "f", "sA*ss" },
+        { do_File_filter, "filter", "i", "sA*sA*f" },
 	{ do_File_reopen, "reopen", "f", "ssf" },
         { 0 }
     };
@@ -198,7 +199,7 @@
 }
 
 Value
-do_File_pipe (Value file, Value argv, Value mode)
+do_File_filter (Value path, Value argv, Value filev)
 {
     ENTER ();
     char    **args;
@@ -207,6 +208,7 @@
     Value   ret;
     int	    err;
 
+    /* set up arguments */
     args = AllocateTemp ((ArrayDims(&argv->array)[0] + 1) * sizeof (char *));
     for (argc = 0; argc < ArrayDims(&argv->array)[0]; argc++)
     {
@@ -214,21 +216,41 @@
 	args[argc] = StringChars (&arg->string);
     }
     args[argc] = 0;
+
+    /* run the filter */
     if (aborting)
 	RETURN(Void);
-    ret = FilePopen (StringChars (&file->string), args, 
-		     StringChars (&mode->string), &err);
+    ret = FileFilter (StringChars (&path->string), args, 
+		      filev, &err);
     if (!ret)
     {
 	RaiseStandardException (exception_open_error,
 				FileGetErrorMessage (err),
-				2, FileGetError (err), file);
+				2, FileGetError (err), path);
 	ret = Void;
     }
     complete = True;
     RETURN (ret);
 }
 
+Value do_File_mkpipe (void) {
+    ENTER ();
+    int err;
+    Value ret;
+    
+    if (aborting)
+	RETURN (Void);
+    ret = FileMakePipe (&err);
+    if (!ret)
+    {
+	RaiseStandardException (exception_open_error,
+				FileGetErrorMessage (err),
+				2, FileGetError (err), Void);
+	RETURN (Void);
+    }
+    RETURN (ret);
+}
+
 Value
 do_File_reopen (Value name, Value mode, Value file)
 {




More information about the Commit mailing list