- supplying <init-files> for --r6rs-script or --script now raises an

error (as suggested by Derick Eddington).
- The -h or [-b <bootfile>] options must now come first, so,
  the rest of the command-line arguments are not scanned: only the
  first one or two.   The docs (in ikarus -h) already suggested the
  correct invocation arguments, so, this conforms to the previously
  documented behavior.
This commit is contained in:
Abdulaziz Ghuloum 2008-10-18 17:49:20 -04:00
parent c464e8ebce
commit 8cd9d6ef16
4 changed files with 18 additions and 61 deletions

View File

@ -115,12 +115,19 @@
[else
(let-values ([(f* script script-type a*) (f (cdr args))])
(values (cons (car args) f*) script script-type a*))]))])
(define (assert-null files who)
(unless (null? files)
(apply die 'ikarus
(format "load files not allowed for ~a" who)
files)))
(cond
[(eq? script-type 'r6rs-script)
(assert-null files "--r6rs-script")
(command-line-arguments (cons script args))
(load-r6rs-top-level script 'run)
(exit 0)]
[(eq? script-type 'compile)
(assert-null files "--compile-dependencies")
(command-line-arguments (cons script args))
(load-r6rs-top-level script 'compile)
(exit 0)]

View File

@ -1 +1 @@
1635
1636

View File

@ -53,70 +53,21 @@ Options for running ikarus scheme:\n\
fprintf(stderr, helpstring, BOOTFILE);
}
/* get_option
takes pointers to argc and argv and looks for the first
option matching opt. If one exists, it removes it from the argv
list, updates argc, and returns a pointer to the option value.
returns null if option is not found.
*/
char*
get_option(char* opt, int argc, char** argv){
int i;
for(i=1; i<argc; i++){
if(strcmp(opt, argv[i]) == 0){
if((i+1) < argc){
char* rv = argv[i+1];
int j;
for(j=i+2; j<argc; j++, i++){
argv[i] = argv[j];
}
return rv;
}
else {
fprintf(stderr,
"ikarus error: option %s requires a value, none provided\n",
opt);
ikarus_usage_short();
exit(-1);
}
}
else if(strcmp("--", argv[i]) == 0){
return 0;
}
}
return 0;
}
int
get_option0(char* opt, int argc, char** argv){
int i;
for(i=1; i<argc; i++){
if(strcmp(opt, argv[i]) == 0){
int j;
for(j=i+1; j<argc; j++, i++){
argv[i] = argv[j];
}
return 1;
}
else if(strcmp("--", argv[i]) == 0){
return 0;
}
}
return 0;
}
int main(int argc, char** argv){
if(get_option0("-h", argc, argv)){
char* boot_file = BOOTFILE;
if (((argc >= 2) && (strcmp(argv[1], "-h") == 0)) ||
((argc == 2) && (strcmp(argv[1], "-b") == 0))) {
ikarus_usage();
exit(0);
}
char* boot_file = get_option("-b", argc, argv);
if(boot_file){
if ((argc >= 3) && (strcmp(argv[1], "-b") == 0)){
boot_file = argv[2];
int i;
for(i=3; i<=argc; i++){
argv[i-2] = argv[i];
}
argc -= 2;
} else {
boot_file = BOOTFILE;
}
return ikarus_main(argc, argv, boot_file);
}

View File

@ -49,7 +49,6 @@ int main(int argc, char** argv){
char** args = calloc(sizeof(char*), argc+1);
args[0] = argv[0];
args[1] = "--r6rs-script";
args[2] = argv[1];
int i;
for(i=1; i<argc; i++){
args[i+1] = argv[i];