430bc99013
it build again. Changes: This is a major feature enhancement and bugfix release * Added keyword and optional function arguments. The syntax of a keyword parameter/argument is "identifier = expr". Function Application ------------------------------------------- f(a) f(1) f(~a, b) f(~a = 10, 11) Required keyword argument f(?a, b) f(~a = 10, 12) Optional keyword argument f(12) -- defaults to empty f(?a = 1, b) f(~a = 10, 11) Optional keyword argument with default value f(~a = 1, b) f(11) -- ~a is same as ?a if there is a default value f(?a = 10, 11) -- Arguments can use ?, but it means the same thing Keyword arguments and normal arguments are processed independently. Normal arguments have to appear in the same order as in the parameter list, but keyword arguments can go anywhere. This also adds the function notation. fun(x, y) => add($x, $y) foreach(x => ..., a b c) println($x) where the "..." essentially means "parse as if the indented block below was actually an expression in here" Old-style foreach generate a warning. * Added "program" syntax. This provides a more standard programming language, where strings must be explicit, and variables represent applications. The outer syntax is normal; the program syntax is an ast to ast translation. The translation is turned on with the command ".LANGUAGE: program", which is scoped like "export". Here is an example: #!/usr/bin/env osh .LANGUAGE: program f(x) = return x + 1 println(f(f(1))) The normal $-style expressions are always allowed, but in program-syntax mode, identifiers stand for variables, function application is the f(e1, ..., e2) form, and there are the standard infix operators. To switch back to the default syntax, use .LANGUAGE: make Note, shell commands and rules never use program syntax, except within function arguments. This is not heavily tested. * Added support for partial and curried function applications. Normal funcation application still require using the correct number of arguments (as relaxed by the introduction of optional arguments), but apply function can be used to create curried and partial applications. f(x,y) = return $(add $x, $y) g = $(apply $f, 2) # Partial applications must use apply println($(g 3)) # 5 ff(x) = gg(y) = return $(add $x, $y) println($(apply $(ff), 3, 5)) # Prints 8, also need to use apply here apply can also take keyword arguments. * A high-quality C parser was added to OMake — see lib/parse/C/Parse.om * Added a LaTeX parser and spellchecker - see lib/parse/LaTeX/README.txt * New functions added: localtime, gmtime, mktime, normalize-tm, utimes, digest-string, url-escaped, find-all, addprefixes * New object added: Tm * About 10 Bugs fixed * [Experimental] Object methods can now export their fields back into the parent object. For example, Z. = x = 1 f() = x = 2 export Z.f() echo $(Z.x) # Prints "2" This works with arbitrary levels of nesting.
177 lines
6.8 KiB
Text
177 lines
6.8 KiB
Text
$NetBSD: patch-ae,v 1.1 2010/12/17 09:40:14 wiz Exp $
|
|
|
|
From upstream SVN.
|
|
|
|
--- src/clib/omake_shell_sys.c.orig 2007-12-01 21:32:13.000000000 +0000
|
|
+++ src/clib/omake_shell_sys.c
|
|
@@ -551,7 +551,7 @@ value omake_shell_sys_suspend(value v_pg
|
|
fflush(stderr);
|
|
#endif
|
|
if(process_group_map(suspend_process, Int_val(v_pgrp)) < 0)
|
|
- failwith("omake_shell_sys_suspend");
|
|
+ caml_failwith("omake_shell_sys_suspend");
|
|
CAMLreturn(Val_unit);
|
|
}
|
|
|
|
@@ -563,7 +563,7 @@ value omake_shell_sys_resume(value v_pgr
|
|
fflush(stderr);
|
|
#endif
|
|
if(process_group_map(resume_process, Int_val(v_pgrp)) < 0)
|
|
- failwith("omake_shell_sys_resume");
|
|
+ caml_failwith("omake_shell_sys_resume");
|
|
CAMLreturn(Val_unit);
|
|
}
|
|
|
|
@@ -575,7 +575,7 @@ value omake_shell_sys_kill(value v_pgrp)
|
|
fflush(stderr);
|
|
#endif
|
|
if(process_group_map(kill_process, Int_val(v_pgrp)) < 0)
|
|
- failwith("omake_shell_sys_kill");
|
|
+ caml_failwith("omake_shell_sys_kill");
|
|
CAMLreturn(Val_unit);
|
|
}
|
|
|
|
@@ -600,14 +600,14 @@ value omake_shell_sys_create_thread_pid(
|
|
/* Allocate the process data */
|
|
processp = (Process *) malloc(sizeof(Process));
|
|
if(processp == 0)
|
|
- failwith("omake_shell_sys_create_thread_pid: out of memory");
|
|
+ caml_failwith("omake_shell_sys_create_thread_pid: out of memory");
|
|
memset(processp, 0, sizeof(Process));
|
|
|
|
/* Create an event for waiting on the thread */
|
|
event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
if(event == NULL) {
|
|
free(processp);
|
|
- failwith("omake_shell_sys_create_thread_pid: can't create event");
|
|
+ caml_failwith("omake_shell_sys_create_thread_pid: can't create event");
|
|
}
|
|
|
|
pgrp = Int_val(v_pgrp);
|
|
@@ -645,7 +645,7 @@ value omake_shell_sys_init_thread_pid(va
|
|
break;
|
|
}
|
|
if(processp == 0)
|
|
- raise_not_found();
|
|
+ caml_raise_not_found();
|
|
|
|
/* Process has terminated */
|
|
processp->thread = GetCurrentThreadId();
|
|
@@ -679,7 +679,7 @@ value omake_shell_sys_release_thread_pid
|
|
break;
|
|
}
|
|
if(processp == 0)
|
|
- raise_not_found();
|
|
+ caml_raise_not_found();
|
|
|
|
/* Process has terminated */
|
|
processp->changed = 1;
|
|
@@ -771,7 +771,7 @@ value omake_shell_sys_wait(value v_pgrp,
|
|
goto done;
|
|
else {
|
|
if(ncount == MAXIMUM_WAIT_OBJECTS)
|
|
- invalid_argument("omake_shell_sys_wait: too many processes");
|
|
+ caml_invalid_argument("omake_shell_sys_wait: too many processes");
|
|
processes[ncount] = processp->pid;
|
|
handles[ncount] = processp->handle;
|
|
ncount++;
|
|
@@ -787,11 +787,11 @@ value omake_shell_sys_wait(value v_pgrp,
|
|
/* Wait for an event */
|
|
while(1) {
|
|
/* Perform the wait */
|
|
- enter_blocking_section();
|
|
+ caml_enter_blocking_section();
|
|
index = WaitForMultipleObjects(ncount, handles, FALSE, timeout);
|
|
if(index == WAIT_FAILED)
|
|
code = GetLastError();
|
|
- leave_blocking_section();
|
|
+ caml_leave_blocking_section();
|
|
|
|
/* See if something has changed */
|
|
if(index == WAIT_OBJECT_0) {
|
|
@@ -810,7 +810,7 @@ value omake_shell_sys_wait(value v_pgrp,
|
|
else if(index >= WAIT_ABANDONED_0 + 1 && index < WAIT_ABANDONED_0 + ncount)
|
|
index -= WAIT_ABANDONED_0;
|
|
else
|
|
- raise_not_found();
|
|
+ caml_raise_not_found();
|
|
|
|
/* Adjust process */
|
|
pid = processes[index];
|
|
@@ -863,7 +863,7 @@ value omake_shell_sys_wait(value v_pgrp,
|
|
break;
|
|
case STATUS_RUNNING:
|
|
default:
|
|
- invalid_argument("wait_process: process is running");
|
|
+ caml_invalid_argument("wait_process: process is running");
|
|
break;
|
|
}
|
|
|
|
@@ -908,7 +908,7 @@ value omake_shell_sys_create_process(val
|
|
strp = String_val(Field(v_envp, i));
|
|
length = strlen(strp);
|
|
if(index + length + 2 > SIZEOF_ENVIRONMENT)
|
|
- failwith("omake_shell_sys_create_process: environment is too big");
|
|
+ caml_failwith("omake_shell_sys_create_process: environment is too big");
|
|
strcpy(env + index, strp);
|
|
index += length + 1;
|
|
}
|
|
@@ -919,7 +919,7 @@ value omake_shell_sys_create_process(val
|
|
v_argvp = Field(v_info, CREATE_PROCESS_ARGV);
|
|
count = Wosize_val(v_argvp);
|
|
if(count == 0)
|
|
- invalid_argument("omake_shell_sys_create_process: command line is empty");
|
|
+ caml_invalid_argument("omake_shell_sys_create_process: command line is empty");
|
|
index = 0;
|
|
for(i = 0; i != count; i++) {
|
|
/* Win32 doesn't deal well when the command name differs from the executable */
|
|
@@ -930,7 +930,7 @@ value omake_shell_sys_create_process(val
|
|
length = strlen(argp);
|
|
white = string_escape_length(argp);
|
|
if(index + length + white + 4 >= SIZEOF_COMMAND)
|
|
- failwith("omake_shell_sys_create_process: command line is too long");
|
|
+ caml_failwith("omake_shell_sys_create_process: command line is too long");
|
|
if(index)
|
|
argv[index++] = ' ';
|
|
if(white)
|
|
@@ -1019,13 +1019,13 @@ value omake_shell_sys_create_process(val
|
|
if ((bufLen < 1) || (bufLen > 1024)) {
|
|
if (lpMsgBuf != NULL)
|
|
LocalFree( lpMsgBuf );
|
|
- failwith("omake_shell_sys_create_process: process creation failed");
|
|
+ caml_failwith("omake_shell_sys_create_process: process creation failed");
|
|
} else {
|
|
char err[2048];
|
|
sprintf(err, "omake_shell_sys_create_process: process creation failed: %s", (char *)lpMsgBuf);
|
|
if (lpMsgBuf != NULL)
|
|
LocalFree( lpMsgBuf );
|
|
- failwith(err);
|
|
+ caml_failwith(err);
|
|
}
|
|
}
|
|
CloseHandle(process.hThread);
|
|
@@ -1034,7 +1034,7 @@ value omake_shell_sys_create_process(val
|
|
processp = (Process *) malloc(sizeof(Process));
|
|
if(processp == 0) {
|
|
CloseHandle(process.hProcess);
|
|
- failwith("omake_shell_sys_create_process: out of memory");
|
|
+ caml_failwith("omake_shell_sys_create_process: out of memory");
|
|
}
|
|
memset(processp, 0, sizeof(Process));
|
|
processp->pid = pid;
|
|
@@ -1129,13 +1129,13 @@ value omake_shell_sys_init(value v_unit)
|
|
/* Allocate a struct for the current process */
|
|
processp = (Process *) malloc(sizeof(Process));
|
|
if(processp == 0)
|
|
- failwith("Omake_shell_csys.create_state: out of memory");
|
|
+ caml_failwith("Omake_shell_csys.create_state: out of memory");
|
|
memset(processp, 0, sizeof(Process));
|
|
|
|
/* Allocate the state */
|
|
state = (ShellState *) malloc(sizeof(ShellState));
|
|
if(state == 0)
|
|
- failwith("Omake_shell_csys.create_state: out of memory");
|
|
+ caml_failwith("Omake_shell_csys.create_state: out of memory");
|
|
memset(state, 0, sizeof(ShellState));
|
|
state->pid_counter = INIT_PID;
|
|
state->changed = CreateEvent(NULL, FALSE, FALSE, NULL);
|