Ikarus now recognizes a -b command-line argument for providing the

name of the boot file. If -b is missing, argv[0]++".boot" is used.
This commit is contained in:
Abdulaziz Ghuloum 2006-12-01 09:23:37 -05:00
parent c3401ef735
commit ee0e6c91e7
5 changed files with 50 additions and 8 deletions

Binary file not shown.

View File

@ -10,11 +10,57 @@
#include <errno.h>
#include <gmp.h>
/* 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, "Error: option %s not provided\n", opt);
exit(-1);
}
}
else if(strcmp("--", argv[i]) == 0){
return 0;
}
}
return 0;
}
int main(int argc, char** argv){
if(argc < 2){
fprintf(stderr, "insufficient arguments\n");
char ikarus_boot[FILENAME_MAX];
char* boot_file = get_option("-b", argc, argv);
if(boot_file){
argc -= 2;
} else {
boot_file = ikarus_boot;
char* x = ikarus_boot;
x = stpcpy(x, argv[0]);
x = stpcpy(x, ".boot");
}
if(argc != 1){
fprintf(stderr,
"Error ~s: unrecognized argument %s\n",
argv[0], argv[1]);
exit(-1);
}
if(sizeof(mp_limb_t) != sizeof(int)){
fprintf(stderr, "ERROR: limb size\n");
}
@ -22,11 +68,7 @@ int main(int argc, char** argv){
fprintf(stderr, "ERROR: bits_per_limb=%d\n", mp_bits_per_limb);
}
ikpcb* pcb = ik_make_pcb();
int i;
for(i=1; i<argc; i++){
char* fasl_file = argv[i];
ik_fasl_load(pcb, fasl_file);
}
ik_fasl_load(pcb, boot_file);
/*
fprintf(stderr, "collect time: %d.%03d utime, %d.%03d stime (%d collections)\n",
pcb->collect_utime.tv_sec,

View File

@ -3,7 +3,7 @@ all: ikarus.boot
ikarus.boot: *.ss
cp ikarus.boot ikarus.boot.back
echo '(load "makefile.ss")' | time ../runtime/ikarus ikarus.boot
echo '(load "makefile.ss")' | time ../runtime/ikarus -b ikarus.boot
clean:
rm -f *.fasl

Binary file not shown.

Binary file not shown.