Merged arguments of VM and scsh.
Non-backward comptaible changes: -o for specifying the object file is gone -i does not terminate argument scanning -s for specifying the size of the stack is now -stacksize
This commit is contained in:
parent
0951ec5b42
commit
26fcfcd8b2
|
@ -378,7 +378,7 @@ inst-script:
|
||||||
echo '#!/bin/sh' >$$script && \
|
echo '#!/bin/sh' >$$script && \
|
||||||
echo >>$$script && \
|
echo >>$$script && \
|
||||||
echo 'lib=$(LIB)' >>$$script && \
|
echo 'lib=$(LIB)' >>$$script && \
|
||||||
echo 'exec $$lib/$(VM) -o $$lib/$(VM) -i $$lib/$(IMAGE) "$$@"' \
|
echo 'exec $$lib/$(VM) -i $$lib/$(IMAGE) "$$@"' \
|
||||||
>>$$script && \
|
>>$$script && \
|
||||||
chmod +x $$script
|
chmod +x $$script
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ go:
|
||||||
echo '#!/bin/sh' >$@ && \
|
echo '#!/bin/sh' >$@ && \
|
||||||
echo >>$@ && \
|
echo >>$@ && \
|
||||||
echo "lib=`pwd`" >>$@ && \
|
echo "lib=`pwd`" >>$@ && \
|
||||||
echo 'exec $$lib/$(VM) -o $$lib/$(VM) -i $$lib/scsh/scsh.image "$$@"' \
|
echo 'exec $$lib/$(VM) -i $$lib/scsh/scsh.image "$$@"' \
|
||||||
>>$@ && \
|
>>$@ && \
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
@ -832,7 +832,7 @@ scsh/scsh.image: $(VM) $(SCHEME) $(IMAGE)
|
||||||
echo ",open $(opens)"; \
|
echo ",open $(opens)"; \
|
||||||
echo "(dump-scsh \"$@\")"; \
|
echo "(dump-scsh \"$@\")"; \
|
||||||
) \
|
) \
|
||||||
| ./$(VM) -o ./$(VM) -i $(IMAGE) -h 10000000
|
| ./$(VM) -i $(IMAGE) -h 10000000
|
||||||
|
|
||||||
# ,flush files => 0k
|
# ,flush files => 0k
|
||||||
# ,flush names => -= 17k
|
# ,flush names => -= 17k
|
||||||
|
@ -847,7 +847,7 @@ scsh/stripped-scsh.image: $(VM) $(SCHEME) $(IMAGE)
|
||||||
echo ",open $(opens)"; \
|
echo ",open $(opens)"; \
|
||||||
echo ",flush"; \
|
echo ",flush"; \
|
||||||
echo "(dump-scsh \"$@\")";) \
|
echo "(dump-scsh \"$@\")";) \
|
||||||
| ./$(VM) -o ./$(VM) -i $(IMAGE) -h 10000000
|
| ./$(VM) -i $(IMAGE) -h 10000000
|
||||||
|
|
||||||
install-scsh: scsh install-scsh-image install-stripped-scsh-image
|
install-scsh: scsh install-scsh-image install-stripped-scsh-image
|
||||||
$(RM) $(bindir)/$(RUNNABLE)
|
$(RM) $(bindir)/$(RUNNABLE)
|
||||||
|
|
|
@ -9,7 +9,7 @@ vm=$4
|
||||||
initial=$5
|
initial=$5
|
||||||
USER=${USER-`logname 2>/dev/null || echo '*GOK*'`}
|
USER=${USER-`logname 2>/dev/null || echo '*GOK*'`}
|
||||||
|
|
||||||
./$vm -o ./$vm -i $initial batch <<EOF
|
./$vm -o ./$vm -i $initial -- batch <<EOF
|
||||||
,load $srcdir/scheme/env/init-defpackage.scm
|
,load $srcdir/scheme/env/init-defpackage.scm
|
||||||
((*structure-ref filenames 'set-translation!)
|
((*structure-ref filenames 'set-translation!)
|
||||||
"=scheme48/" "$srcdir/scheme/")
|
"=scheme48/" "$srcdir/scheme/")
|
||||||
|
|
16
c/main.c
16
c/main.c
|
@ -31,11 +31,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char ** process_args(char **argv,
|
void process_args(char **argv,
|
||||||
long *heap_size,
|
long *heap_size,
|
||||||
long *stack_size,
|
long *stack_size,
|
||||||
char **object_file,
|
char **object_file,
|
||||||
char **image_name);
|
char **image_name);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
internal_s48_main(long heap_size, long stack_size,
|
internal_s48_main(long heap_size, long stack_size,
|
||||||
|
@ -65,9 +65,9 @@ main(argc, argv)
|
||||||
char *me = *argv; /* Save program name. */
|
char *me = *argv; /* Save program name. */
|
||||||
prog_name = *argv++;
|
prog_name = *argv++;
|
||||||
|
|
||||||
argv=process_args(argv,
|
process_args(argv,
|
||||||
&heap_size, &stack_size,
|
&heap_size, &stack_size,
|
||||||
&object_file, &image_name);
|
&object_file, &image_name);
|
||||||
for(argc=0, argp=argv; *argp; argc++, argp++); /* Recompute argc. */
|
for(argc=0, argp=argv; *argp; argc++, argp++); /* Recompute argc. */
|
||||||
return internal_s48_main(heap_size, stack_size, prog_name, object_file, image_name, argc, argv);
|
return internal_s48_main(heap_size, stack_size, prog_name, object_file, image_name, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,61 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
extern char *prog_name;
|
|
||||||
|
|
||||||
#define streq(a,b) (strcmp((a),(b))==0)
|
#define streq(a,b) (strcmp((a),(b))==0)
|
||||||
|
|
||||||
static void usage(void) {
|
static void usage(void) {
|
||||||
fprintf(stderr, "Usage: %s [meta-arg] [vm-option+] [end-option scheme-args]\n"
|
printf("
|
||||||
"meta-arg: \\ <script file name>\n"
|
Usage: scsh [meta-arg] [vm-option+] [end-option scheme-args]
|
||||||
"\n"
|
|
||||||
"vm-option: -h <total heap size in words>\n"
|
|
||||||
" -s <stack size in words>\n"
|
|
||||||
" -o <object file name>\n"
|
|
||||||
"\n"
|
|
||||||
"end-option: -i <image file name>\n"
|
|
||||||
" -- (Terminates vm args.)\n"
|
|
||||||
" -a (Terminates vm args. Obsolete.)\n",
|
|
||||||
prog_name);}
|
|
||||||
|
|
||||||
static void bad_args(int nr) {
|
meta-arg: \\ <script-file-name>
|
||||||
fprintf(stderr, "reason : %d\n", nr);
|
|
||||||
usage();
|
|
||||||
exit(1); }
|
|
||||||
|
|
||||||
char ** process_args(char **argv,
|
switch: -e <entry-point> Specify top-level entry point.
|
||||||
|
-o <structure> Open structure in current package.
|
||||||
|
-m <package> Switch to package.
|
||||||
|
-n <new-package> Switch to new package.
|
||||||
|
|
||||||
|
|
||||||
|
-lm <module-file-name> Load module into config package.
|
||||||
|
-le <exec-file-name> Load file into exec package.
|
||||||
|
-l <file-name> Load file into current package.
|
||||||
|
|
||||||
|
-ll <module-file-name> As in -lm, but search the library path list.
|
||||||
|
+lp <dir> Add <dir> to front of library path list.
|
||||||
|
lp+ <dir> Add <dir> to end of library path list.
|
||||||
|
+lpe <dir> +lp, with env var and ~user expansion.
|
||||||
|
lpe+ <dir> lp+, with env var and ~user expansion.
|
||||||
|
+lpsd Add script-file's dir to front of path list.
|
||||||
|
lpsd+ Add script-file's dir to end of path list.
|
||||||
|
-lp-clear Clear library path list to ().
|
||||||
|
-lp-default Reset library path list to system default.
|
||||||
|
|
||||||
|
-ds Do script.
|
||||||
|
-dm Do script module.
|
||||||
|
-de Do script exec.
|
||||||
|
|
||||||
|
-h <cells> Set heap size.
|
||||||
|
-i <file> Specify image.
|
||||||
|
-stacksize <cells> Set stack size
|
||||||
|
|
||||||
|
end-option: -s <script> Specify script.
|
||||||
|
-sfd <num> Script is on file descriptor <num>.
|
||||||
|
-c <exp> Evaluate expression.
|
||||||
|
-- Interactive session.
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bad_args(char* msg, char* arg) {
|
||||||
|
|
||||||
|
printf ("Error:\n");
|
||||||
|
printf (msg,arg);
|
||||||
|
printf ("\n");
|
||||||
|
usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void process_args(char **argv,
|
||||||
long *pheap_size,
|
long *pheap_size,
|
||||||
long *pstack_size,
|
long *pstack_size,
|
||||||
char **pobject_file,
|
char **pobject_file,
|
||||||
|
@ -33,51 +65,79 @@ char ** process_args(char **argv,
|
||||||
/* Handle an initial \ <fname> meta-arg expansion. */
|
/* Handle an initial \ <fname> meta-arg expansion. */
|
||||||
while ( *argv && streq(*argv, "\\") ) {
|
while ( *argv && streq(*argv, "\\") ) {
|
||||||
argv++;
|
argv++;
|
||||||
if( !*argv ) bad_args(0); /* die */
|
if( !*argv ) bad_args("No arguments after meta-arg %s","\\"); /* die */
|
||||||
argv = process_meta_arg(argv);
|
argv = process_meta_arg(argv);
|
||||||
if( !argv ) {
|
if( !argv ) {
|
||||||
fprintf(stderr, "%s: \\ <fname> expansion failed.\n",
|
fprintf(stderr, "scsh: \\ <fname> expansion failed.\n");
|
||||||
prog_name);
|
|
||||||
exit(1);}}
|
exit(1);}}
|
||||||
|
|
||||||
for (; *argv; argv++)
|
|
||||||
if( argv[0][0] != '-' )
|
|
||||||
bad_args(1); /* die */
|
|
||||||
else
|
|
||||||
switch (argv[0][1]) {
|
|
||||||
default:
|
|
||||||
bad_args(2); /* die */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h': /* heapsize */
|
for (; *argv; argv++){
|
||||||
argv++;
|
|
||||||
if( !*argv ) bad_args(3); /* die */
|
char *arg = argv[0];
|
||||||
*pheap_size = atoi(*argv);
|
#define S48_ARGCMP(s) (streq(arg,s))
|
||||||
if( *pheap_size <= 0 ) bad_args(4);
|
|
||||||
break;
|
if (S48_ARGCMP ("-h")) { /* heapsize */
|
||||||
|
argv++;
|
||||||
|
if( !*argv ) bad_args("Option %s requires an argument", arg); /* die */
|
||||||
|
*pheap_size = atoi(*argv);
|
||||||
|
if( *pheap_size <= 0 ) bad_args("Invalid argument to %s", arg);
|
||||||
|
}
|
||||||
|
else if (S48_ARGCMP ("-stacksize")) { /* stacksize */
|
||||||
|
argv++;
|
||||||
|
if( !*argv ) bad_args("Option %s requires an argument", arg); /* die */
|
||||||
|
*pstack_size = atoi(*argv);
|
||||||
|
if( *pstack_size <= 0 ) bad_args("Invalid argument to %s", arg);
|
||||||
|
}
|
||||||
|
else if (S48_ARGCMP ("-i")) { /* image */
|
||||||
|
argv++;
|
||||||
|
if( !*argv ) bad_args("Option %s requires an argument", arg); /* die */
|
||||||
|
*pimage_name = *argv;
|
||||||
|
}
|
||||||
|
|
||||||
case 's':
|
else if (S48_ARGCMP ("+lpsd") ||
|
||||||
argv++;
|
S48_ARGCMP ("lpsd+") ||
|
||||||
if( !*argv ) bad_args(5); /* die */
|
S48_ARGCMP ("-lp-clear") ||
|
||||||
*pstack_size = atoi(*argv);
|
S48_ARGCMP ("-lp-default") ||
|
||||||
if (*pstack_size <= 0) bad_args(6);
|
S48_ARGCMP ("-ds") ||
|
||||||
break;
|
S48_ARGCMP ("-dm") ||
|
||||||
|
S48_ARGCMP ("-de")){
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else if (S48_ARGCMP ("-e") ||
|
||||||
|
S48_ARGCMP ("-o") ||
|
||||||
|
S48_ARGCMP ("-m") ||
|
||||||
|
S48_ARGCMP ("-lm") ||
|
||||||
|
S48_ARGCMP ("-le") ||
|
||||||
|
S48_ARGCMP ("-l") ||
|
||||||
|
S48_ARGCMP ("-ll") ||
|
||||||
|
S48_ARGCMP ("+lp") ||
|
||||||
|
S48_ARGCMP ("lp+") ||
|
||||||
|
S48_ARGCMP ("+lpe") ||
|
||||||
|
S48_ARGCMP ("lpe+")){
|
||||||
|
argv++;
|
||||||
|
if( !*argv ) bad_args("Option %s requires an argument", arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* These switches terminate arg scanning. */
|
||||||
|
else if (S48_ARGCMP ("-s") ||
|
||||||
|
S48_ARGCMP ("-sdf") ||
|
||||||
|
S48_ARGCMP ("-c")){
|
||||||
|
argv++;
|
||||||
|
if( !*argv ){
|
||||||
|
bad_args("Option %s requires an argument", arg);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (S48_ARGCMP ("--")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
bad_args("Unknown switch %s", arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef S48_ARGCMP
|
||||||
|
|
||||||
case 'o': /* object file */
|
return;
|
||||||
argv++;
|
}
|
||||||
if( !*argv ) bad_args(7); /* die */
|
|
||||||
*pobject_file = *argv;
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* These switches terminate arg scanning. */
|
|
||||||
case 'i':
|
|
||||||
argv++;
|
|
||||||
if( !*argv ) bad_args(8); /* die */
|
|
||||||
*pimage_name = *argv++;
|
|
||||||
return argv;
|
|
||||||
|
|
||||||
case '-':
|
|
||||||
case 'a':
|
|
||||||
argv++;
|
|
||||||
return argv;}
|
|
||||||
return argv;}
|
|
||||||
|
|
|
@ -177,6 +177,11 @@
|
||||||
(lp (cdr args) switches
|
(lp (cdr args) switches
|
||||||
(string->symbol (car args)) need-script?))
|
(string->symbol (car args)) need-script?))
|
||||||
|
|
||||||
|
((or (string=? arg "-i")
|
||||||
|
(string=? arg "-h")
|
||||||
|
(string=? arg "-stacksize"))
|
||||||
|
(lp (cdr args) switches top-entry need-script?))
|
||||||
|
|
||||||
(else (bad-arg "Unknown switch" arg))))
|
(else (bad-arg "Unknown switch" arg))))
|
||||||
|
|
||||||
(values (reverse switches) #f #f top-entry '()))))
|
(values (reverse switches) #f #f top-entry '()))))
|
||||||
|
@ -537,6 +542,10 @@ switch: -e <entry-point> Specify top-level entry point.
|
||||||
-dm Do script module.
|
-dm Do script module.
|
||||||
-de Do script exec.
|
-de Do script exec.
|
||||||
|
|
||||||
|
-h <cells> Set heap size.
|
||||||
|
-i <file> Specify image.
|
||||||
|
-stacksize <cells> Set stack size
|
||||||
|
|
||||||
end-option: -s <script> Specify script.
|
end-option: -s <script> Specify script.
|
||||||
-sfd <num> Script is on file descriptor <num>.
|
-sfd <num> Script is on file descriptor <num>.
|
||||||
-c <exp> Evaluate expression.
|
-c <exp> Evaluate expression.
|
||||||
|
|
Loading…
Reference in New Issue