Exemplo n.º 1
0
NODE *lopen(NODE *arg, char *mode)
{
    FILE *tmp;

    arg = car(arg);
    if (find_file(arg, FALSE) != NULL)
	err_logo(FILE_ERROR, make_static_strnode("File already open"));
    else if ((tmp = open_file(arg, mode)) != NULL) {
	push(arg, file_list);
	file_list->n_obj = (NODE *) tmp;
    }
    else
	err_logo(FILE_ERROR, make_static_strnode("I can't open that file"));
    return(UNBOUND);
}
Exemplo n.º 2
0
void filesave(char *temp)
   {
   FILE *tmp;
   NODE *arg;
   int save_yield_flag;

   if (::FindWindow(NULL, "Editor"))
      {
      MainWindowx->CommandWindow->MessageBox("Did you know you have an edit session running?\n\nAny changes in this edit session are not being saved.", "Information", MB_OK | MB_ICONQUESTION);
      }

   arg = cons(make_strnode(temp, NULL, strlen(temp), STRING, strnzcpy), NIL);

   tmp = writestream;
   writestream = open_file(car(arg), "w+");
   if (writestream != NULL)
      {

      save_yield_flag = yield_flag;
      yield_flag = 0;
      lsetcursorwait();

      setcar(arg, cons(lcontents(), NIL));
      lpo(car(arg));
      fclose(writestream);
      IsDirty = 0;

      lsetcursorarrow();
      yield_flag = save_yield_flag;

      }
   else
      err_logo(FILE_ERROR, make_static_strnode("Could not open file"));
   writestream = tmp;
   }
Exemplo n.º 3
0
NODE *lload(NODE *arg)
{
    FILE *tmp;
    NODE *tmp_line, *exec_list;
    NODE *st = valnode__caseobj(Startup);
    int sv_val_status = val_status;

    tmp = loadstream;
    tmp_line = vref(current_line);
    loadstream = open_file(car(arg), "r");
    if (loadstream != NULL) {
	while (!feof(loadstream) && NOT_THROWING) {
	    current_line = reref(current_line, reader(loadstream, ""));
	    exec_list = parser(current_line, TRUE);
	    val_status = 0;
	    if (exec_list != NIL) eval_driver(exec_list);
	}
	fclose(loadstream);
	runstartup(st);
	val_status = sv_val_status;
    } else
	err_logo(FILE_ERROR, make_static_strnode("Could not open file"));
    loadstream = tmp;
    deref(current_line);
    current_line = tmp_line;
    return(UNBOUND);
}
Exemplo n.º 4
0
NODE *lclose(NODE *arg)
{
    FILE *tmp;

    if ((tmp = find_file(car(arg), TRUE)) == NULL)
	err_logo(FILE_ERROR, make_static_strnode("File not open"));
    else
	fclose(tmp);
    return(UNBOUND);
}
Exemplo n.º 5
0
/* Initializes Object Logo */
void obj_init(void) {
    logo_object = newobj();
    current_object = logo_object;
    setvars(logo_object, cons(theName(Name_name), getvars(logo_object)));
    setobject(getvars(logo_object), make_static_strnode("Logo"));

    /* [[initlist] [exist output self]] */
    askexist = cons(cons(theName(Name_initlist), NIL),
		    cons(cons(theName(Name_exist),
			      cons(theName(Name_output),
				   cons(theName(Name_self), NIL))),
			 NIL));
}
Exemplo n.º 6
0
NODE *lerasefile(NODE *arg) {
    char *fnstr;

    arg = cnv_node_to_strnode(car(arg));
    if (arg == UNBOUND) return(UNBOUND);
    fnstr = malloc((size_t)getstrlen(arg) + 1);
    if (fnstr == NULL) {
	err_logo(FILE_ERROR, make_static_strnode(message_texts[MEM_LOW]));
	return UNBOUND;
    }
    strnzcpy(fnstr, getstrptr(arg), getstrlen(arg));
    unlink(fnstr);
    free(fnstr);
    return(UNBOUND);
}
Exemplo n.º 7
0
FILE *open_file(NODE *arg, char *access) {
    char *fnstr;
    FILE *tstrm;
    char *old_stringptr = print_stringptr;
    int old_stringlen = print_stringlen;

    if (is_list(arg)) { /* print to string */
	if (*access != 'w') {
	    err_logo(BAD_DATA_UNREC, arg);
	    return NULL;
	} else {
	    FIXNUM i = int_arg(cdr(arg));
	    if (NOT_THROWING && i > 0 && cddr(arg) == NIL) {
		char *tmp = (char *)malloc(i);
		*tmp = '\0';
		return (FILE *)tmp;
	    }
	    err_logo(BAD_DATA_UNREC, car(arg));
	    return NULL;
	}
    }

    arg = cnv_node_to_strnode(arg);
    if (arg == UNBOUND) return(NULL);
    if (file_prefix != NIL) {
	print_stringlen = getstrlen(file_prefix) +
			    getstrlen(arg) + 2;
	fnstr = (char *)malloc((size_t)print_stringlen + 1);
    } else
	fnstr = (char *) malloc((size_t)getstrlen(arg) + 1);
    if (fnstr == NULL) {
	err_logo(FILE_ERROR, make_static_strnode(message_texts[MEM_LOW]));
	print_stringptr = old_stringptr;
	print_stringlen = old_stringlen;
	return NULL;
    }
    if (file_prefix != NIL) {
	print_stringptr = fnstr;
	ndprintf((FILE *)NULL, "%p%t%p", file_prefix, separator, arg);
	*print_stringptr = '\0';
	print_stringptr = old_stringptr;
	print_stringlen = old_stringlen;
    } else
	noparity_strnzcpy(fnstr, getstrptr(arg), getstrlen(arg));
    tstrm = fopen(fnstr, access);
    free(fnstr);
    return(tstrm);
}
Exemplo n.º 8
0
NODE *lsave(NODE *arg)
{
    FILE *tmp;

    tmp = writestream;
    writestream = open_file(car(arg), "w+");
    if (writestream != NULL) {
	setcar(arg, cons(lcontents(), NIL));
	lpo(car(arg));
	fclose(writestream);
    }
    else
	err_logo(FILE_ERROR, make_static_strnode("Could not open file"));
    writestream = tmp;
    return(UNBOUND);
}
Exemplo n.º 9
0
NODE *lsetread(NODE *arg)
{
    FILE *tmp;

    if (car(arg) == NIL) {
	readstream = stdin;
	deref(reader_name);
	reader_name = NIL;
    }
    else if ((tmp = find_file(car(arg), FALSE)) != NULL) {
	readstream = tmp;
	reader_name = reref(reader_name, car(arg));
    }
    else
	err_logo(FILE_ERROR, make_static_strnode("File not open"));
    return(UNBOUND);
}
Exemplo n.º 10
0
void fileload(char *temp)
   {
   FILE *tmp;
   NODE *tmp_line, *exec_list, *arg;
   NODE *st = valnode__caseobj(Startup);
   int sv_val_status = val_status;
   int IsDirtySave;
   int save_yield_flag;

   arg = make_strnode(temp, NULL, strlen(temp), STRING, strnzcpy);

   IsDirtySave = IsDirty;
   tmp = loadstream;
   tmp_line = vref(current_line);
   loadstream = open_file(arg, "r");
   if (loadstream != NULL)
      {

      save_yield_flag = yield_flag;
      yield_flag = 0;
      lsetcursorwait();

      while (!feof(loadstream) && NOT_THROWING)
         {
         current_line = reref(current_line, reader(loadstream, ""));
         exec_list = parser(current_line, TRUE);
         val_status = 0;
         if (exec_list != NIL) eval_driver(exec_list);
         }
      fclose(loadstream);

      lsetcursorarrow();
      yield_flag = save_yield_flag;

      runstartup(st);
      val_status = sv_val_status;
      }
   else
      err_logo(FILE_ERROR, make_static_strnode("Could not open file"));
   loadstream = tmp;
   deref(current_line);
   current_line = tmp_line;
   IsDirty = IsDirtySave;
   }
Exemplo n.º 11
0
void init()
   {
   //    extern long time();
   int i /* = 0 */;
   NODE *proc = NIL, *pname = NIL, *cnd = NIL;

   fill_reserve_tank();
   Unbound = newnode(PUNBOUND);

#ifdef bsd
   srandom((int) time((long *) NULL));
#else
   //    srand((int)time((long *)NULL));
   //    srand((int)12345);
#endif
#ifdef ecma
   for (i = 0; i < 128; i++)
      ecma_array[i] = i;
   for (i = 0; i < ecma_size; i++)
      ecma_array[special_chars[i]] = ecma_begin+i;
#endif

   //    logolib = getenv("LOGOLIB");
   //    if (logolib == NULL) logolib = libloc;
   //    editor = getenv("EDITOR");
   //    if (editor == NULL) editor = "jove";

   editor = "jove";
   editorname = strrchr(editor, (int) '/');
   editorname = (editorname ? editorname + 1 : editor);

   i = 0;
   while (prims[i].name) 
      {
      if (prims[i].priority == MACRO_PRIORITY)
         proc = reref(proc, newnode(MACRO));
      else if (prims[i].priority == TAIL_PRIORITY)
         proc = reref(proc, newnode(TAILFORM));
      else if ((prims[i].priority & ~4) == PREFIX_PRIORITY)
         proc = reref(proc, newnode(PRIM));/* incl. --                        */
      else
         proc = reref(proc, newnode(INFIX));
      if (prims[i].priority < PREFIX_PRIORITY)
         setprimpri(proc, PREFIX_PRIORITY);
      else
         setprimpri(proc, prims[i].priority);
      setprimfun(proc, (lexzer) prims[i].prim);
      setprimdflt(proc, prims[i].defargs);
      setprimmax(proc, prims[i].maxargs);
      setprimmin(proc, prims[i].minargs);
      pname = reref(pname, make_static_strnode(prims[i].name));
      cnd = reref(cnd, make_instance(pname, pname));
      setprocnode__caseobj(cnd, proc);
      if (nodetype(proc) == MACRO)
         setflag__caseobj(cnd, PROC_MACRO);
      i++; 
      }
   deref(proc);
   deref(cnd);
   deref(pname);
   Truex = intern(make_static_strnode("true"));
   Falsex = intern(make_static_strnode("false"));
   Left_Paren = intern(make_static_strnode("("));
   Right_Paren = intern(make_static_strnode(")"));
   Minus_Sign = intern(make_static_strnode("-"));
   Minus_Tight = intern(make_static_strnode("--"));
   Query = intern(make_static_strnode("?"));
   Null_Word = intern(make_static_strnode("\0"));
   To = intern(make_static_strnode("to"));
   Macro = intern(make_static_strnode(".macro"));
   Toplevel = intern(make_static_strnode("toplevel"));
   System = intern(make_static_strnode("system"));
   Error = intern(make_static_strnode("error"));
   End = intern(make_static_strnode("end"));
   If = intern(make_static_strnode("if"));
   Ifelse = intern(make_static_strnode("ifelse"));
   Redefp = intern(make_static_strnode("redefp"));
   Caseignoredp = intern(make_static_strnode("caseignoredp"));
   setvalnode__caseobj(Caseignoredp, Truex);
   setflag__caseobj(Caseignoredp, VAL_BURIED);
   Erract = intern(make_static_strnode("erract"));
   Printdepthlimit = intern(make_static_strnode("printdepthlimit"));
   Printwidthlimit = intern(make_static_strnode("printwidthlimit"));
   Pause = intern(make_static_strnode("pause"));
   Startup = intern(make_static_strnode("startup"));
   Output = intern(make_static_strnode("output"));
   Op = intern(make_static_strnode("op"));
   Stop = intern(make_static_strnode("stop"));
   Goto = intern(make_static_strnode("goto"));
   Tag = intern(make_static_strnode("Tag"));
   the_generation = valref(cons(NIL, NIL));
   Not_Enough_Node = valref(cons(NIL, NIL));

   }
int main(int argc, char *argv[]) {
	NODE *exec_list = NIL;
	NODE *cl_tail = NIL;
	int argc2;
	char **argv2;

	bottom_stack = &exec_list; /*GC*/


	(void) addseg();
	term_init();
	init();

	math_init();
	my_init();

	signal(SIGINT, logo_stop);

	if (argc < 2) {
		if (1 || isatty(1)) // fix this.  for interactive from menu bar.
		{
			char version[20];
			lcleartext(NIL);
			strcpy(version, "5.6");
			ndprintf(stdout, message_texts[WELCOME_TO], version);
			new_line(stdout);
		}
	}

	setvalnode__caseobj(LogoVersion, make_floatnode(5.6));
	setflag__caseobj(LogoVersion, VAL_BURIED);

	argv2 = argv;
	argc2 = argc;

	if (!strcmp(*argv + strlen(*argv) - 4, "logo")) {
		argv++;
		while (--argc > 0 && strcmp(*argv, "-") && NOT_THROWING) {
			argv++;
		}
	}

	argv++;
	while (--argc > 0) {
		if (command_line == NIL)
			cl_tail = command_line = cons(make_static_strnode(*argv++), NIL);
		else {
			setcdr(cl_tail, cons(make_static_strnode(*argv++), NIL));
			cl_tail = cdr(cl_tail);
		}
	}

	setvalnode__caseobj(CommandLine, command_line);

	silent_load(Startuplg, logolib);
	silent_load(Startup, NULL); /* load startup.lg */
	if (!strcmp(*argv2 + strlen(*argv2) - 4, "logo")) {
		argv2++;
		while (--argc2 > 0 && strcmp(*argv2, "-") && NOT_THROWING) {
			silent_load(NIL, *argv2++);
		}
	}

	for (;;) {
		if (NOT_THROWING) {
			check_reserve_tank();
			current_line = reader(stdin, "? ");

			if (feof(stdin) && !isatty(0))
				lbye(NIL);

			if (NOT_THROWING) {
				exec_list = parser(current_line, TRUE);
				if (exec_list != NIL)
					eval_driver(exec_list);
			}
		}
		if (stopping_flag == THROWING) {
			if (isName(throw_node, Name_error)) {
				err_print(NULL);
			} else if (isName(throw_node, Name_system))
				break;
			else if (!isName(throw_node, Name_toplevel)) {
				err_logo(NO_CATCH_TAG, throw_node);
				err_print(NULL);
			}
			stopping_flag = RUN;
		}
		if (stopping_flag == STOP || stopping_flag == OUTPUT) {
			/*    ndprintf(stdout, "%t\n", message_texts[CANT_STOP]);   */
			stopping_flag = RUN;
		}
	}
	//prepare_to_exit(TRUE);
	my_finish();
	exit(0);
	return 0;
}
Exemplo n.º 13
0
void init(void) {
    int i = 0;
    NODE *iproc = NIL, *pname = NIL, *cnd = NIL;
    FILE *fp;
    char linebuf[100];
    char *sugar;
    static char sugarlib[100], sugarhelp[100], sugarcsls[100];
#ifdef WIN32
    HKEY regKey1, regKey2, regKey3;
    int got_hklm = 0;
    char buf[200];
    unsigned long int bufsiz;
    char *envp;
#endif

    readstream = stdin;
    writestream = stdout;
    loadstream = stdin;

    fill_reserve_tank();
    oldyoungs = Unbound = newnode(PUNBOUND);

#ifdef HAVE_SRANDOM
    srandom((int)time((time_t *)NULL));
#else
    srand((int)time((time_t *)NULL));
#endif
#ifdef ecma
    for (i=0; i<128; i++)
	ecma_array[i] = i;
    for (i=0; i<ecma_size; i++)
	ecma_array[(int)special_chars[i]] = ecma_begin+i;
    i = 0;
#endif

    sugar = getenv("SUGAR_BUNDLE_PATH");
    if (sugar != NULL) {
	strcpy(sugarlib,sugar);
	strcat(sugarlib,"/logolib");
	logolib = sugarlib;
	fp = fopen(logolib,"r");
	if (fp == NULL) goto nosugar;
	fclose(fp);
	chdir(getenv("SUGAR_ACTIVITY_ROOT"));
	chdir("data");
	strcpy(sugarhelp,sugar);
	strcat(sugarhelp,"/helpfiles");
	helpfiles = sugarhelp;
	strcpy(sugarcsls,sugar);
	strcat(sugarcsls,"/csls");
	csls = sugarcsls;
    } else {
nosugar:
	logolib = getenv("LOGOLIB");
	helpfiles = getenv("LOGOHELP");
	csls = getenv("CSLS");
    }
    editor = getenv("EDITOR");
#ifdef WIN32
    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software", 0,
		     KEY_READ, &regKey1) == ERROR_SUCCESS) {
	if (RegOpenKeyEx(regKey1, "UCB", 0, 
			 KEY_READ, &regKey2) == ERROR_SUCCESS) {
	    if (RegOpenKeyEx(regKey2, "UCBLogo", 0,
			     KEY_READ, &regKey3) == ERROR_SUCCESS) {
		got_hklm = 1;
	/*	logolib = getenv("LOGOLIB"); */
		if (logolib == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "LOGOLIB", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
					    logolib = malloc(bufsiz);
					    strcpy(logolib, buf);
		    }
		}
	/*	helpfiles = getenv("LOGOHELP"); */
		if (helpfiles == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "HELPFILE", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			helpfiles = malloc(bufsiz);
			strcpy(helpfiles, buf);
		    }
		}
	/*	csls = getenv("CSLS"); */
		if (csls == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "CSLS", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			csls = malloc(bufsiz);
			strcpy(csls, buf);
		    }
		}
	/*	editor = getenv("EDITOR"); */
		if (editor == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "EDITOR", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			editor = malloc(bufsiz);
			strcpy(editor, buf);
		    }
		}
		RegCloseKey(regKey3);
	    }
	    RegCloseKey(regKey2);
	}
	RegCloseKey(regKey1);
    }
    if (!got_hklm && RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0,
				  KEY_READ, &regKey1) == ERROR_SUCCESS) {
	if (RegOpenKeyEx(regKey1, "UCB", 0, 
			 KEY_READ, &regKey2) == ERROR_SUCCESS) {
	    if (RegOpenKeyEx(regKey2, "UCBLogo", 0,
			     KEY_READ, &regKey3) == ERROR_SUCCESS) {
		got_hklm = 1;
	/*	logolib = getenv("LOGOLIB"); */
		if (logolib == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "LOGOLIB", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
					    logolib = malloc(bufsiz);
					    strcpy(logolib, buf);
		    }
		}
	/*	helpfiles = getenv("LOGOHELP"); */
		if (helpfiles == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "HELPFILE", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			helpfiles = malloc(bufsiz);
			strcpy(helpfiles, buf);
		    }
		}
	/*	csls = getenv("CSLS"); */
		if (csls == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "CSLS", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			csls = malloc(bufsiz);
			strcpy(csls, buf);
		    }
		}
	/*	editor = getenv("EDITOR"); */
		if (editor == NULL) {
		    bufsiz=200;
		    if (RegQueryValueEx(regKey3, "EDITOR", NULL,
					NULL, buf, &bufsiz) == ERROR_SUCCESS) {
			editor = malloc(bufsiz);
			strcpy(editor, buf);
		    }
		}
		RegCloseKey(regKey3);
	    }
	    RegCloseKey(regKey2);
	}
	RegCloseKey(regKey1);
    }
#endif
	
    if (logolib == NULL) logolib = libloc;
    if (helpfiles == NULL) helpfiles = helploc;
    if (csls == NULL) csls = cslsloc;
	
#ifdef HAVE_WX
#ifndef __WXMSW__
	// have to do this because we don't have __WXMAC__ in C
	const char* wxMacGetCslsloc();
	const char* wxMacGetHelploc();
	const char* wxMacGetLibloc();
	char* newlib;
	char* newcsls;
	char* newhelp;
	// check if we are running wxMac
	newlib = wxMacGetLibloc();
	if(newlib)
		logolib=newlib; 
    //if (helpfiles == NULL) helpfiles = wxMacGetHelploc();
    newcsls = wxMacGetCslsloc();
	if(newcsls)
		csls = newcsls;
	newhelp = wxMacGetHelploc();
    if(newhelp)
		helpfiles = newhelp;
#endif
#endif
	
#ifdef unix
    if (editor == NULL) editor = "emacs";
#else
    if (editor == NULL) editor = "jove";
#endif
    editorname = strrchr(editor, (int)'/');
    if (editorname == NULL) editorname = strrchr(editor, (int)'\\');
#ifdef WIN32
    if (editorname == NULL) {
	putenv("DESCRIBE=CMDS.DOC");
	putenv("JOVERC=JOVE.RC");
    } else {
	bufsiz = sprintf(buf, "DESCRIBE=%.*s\\CMDS.DOC", editorname-editor, editor);
	envp = malloc(bufsiz+1);
	strcpy(envp, buf);
	putenv(envp);
	bufsiz = sprintf(buf, "JOVERC=%.*s\\JOVE.RC", editorname-editor, editor);
	envp = malloc(bufsiz+1);
	strcpy(envp, buf);
	putenv(envp);
    }
#endif
    if (editorname == NULL) editorname = strrchr(editor, (int)':');
    editorname = (editorname ? editorname+1 : editor);
    tempdir = getenv("TEMP");
    if (tempdir == NULL) tempdir = temploc;
    while (prims[i].name) {
	if (prims[i].priority == MACRO_PRIORITY)
	    iproc = newnode(MACRO);
	else if (prims[i].priority <= TAIL_PRIORITY)
	    iproc = newnode(TAILFORM);
	else if ((prims[i].priority & ~4) == (PREFIX_PRIORITY & ~4))
	    iproc = newnode(PRIM); /* incl. -- */
	else
	    iproc = newnode(INFIX);
	setprimpri(iproc, prims[i].priority);
	setprimfun(iproc, prims[i].prim);
	setprimdflt(iproc, prims[i].defargs);
	setprimmax(iproc, prims[i].maxargs);
	setprimmin(iproc, prims[i].minargs);
	pname = make_static_strnode(prims[i].name);
	cnd = make_instance(pname, pname);
	setprocnode__caseobj(cnd, iproc);
	if (nodetype(iproc) == MACRO)
	    setflag__caseobj(cnd, PROC_MACRO);
	if (prims[i].minargs < 0)
	    setflag__caseobj(cnd, PROC_SPECFORM);
	setflag__caseobj(cnd, PERMANENT);
	i++;
    }
    Left_Paren = intern_p(make_static_strnode("("));
    Right_Paren = intern_p(make_static_strnode(")"));
    Minus_Sign = intern_p(make_static_strnode("-"));
    Minus_Tight = intern_p(make_static_strnode("--"));
    Query = intern_p(make_static_strnode("?"));
    Null_Word = intern_p(make_static_strnode("\0"));
    Redefp = intern_p(make_static_strnode("redefp"));
    Caseignoredp = intern_p(make_static_strnode("caseignoredp"));
    Erract = intern_p(make_static_strnode("erract"));
    Buttonact = intern_p(make_static_strnode("buttonact"));
    Keyact = intern_p(make_static_strnode("Keyact"));
    Printdepthlimit = intern_p(make_static_strnode("printdepthlimit"));
    Printwidthlimit = intern_p(make_static_strnode("printwidthlimit"));
    LoadNoisily = intern_p(make_static_strnode("loadnoisily"));
    AllowGetSet = intern_p(make_static_strnode("allowgetset"));
    Fullprintp = intern_p(make_static_strnode("fullprintp"));
    UnburyOnEdit = intern_p(make_static_strnode("unburyonedit"));
    UseAlternateNames = intern_p(make_static_strnode("usealternatenames"));
    Make = intern_p(make_static_strnode("make"));
    Listvalue = cons(intern_p(make_static_strnode("value")),NIL);
    Dotsvalue = make_colon(car(Listvalue));
    Pause = intern_p(make_static_strnode("pause"));
    Startup = intern_p(make_static_strnode("startup"));
    Startuplg = intern_p(make_static_strnode("startup.lg"));
    LogoVersion = intern_p(make_static_strnode("logoversion"));
    LogoPlatform = intern_p(make_static_strnode("logoplatform"));
    LogoLogo = intern_p(make_static_strnode("logo-logo"));
    CommandLine = intern_p(make_static_strnode("command.line"));
    setflag__caseobj(CommandLine, VAL_BURIED);
    the_generation = cons(NIL, NIL);
    Not_Enough_Node = cons(NIL, NIL);

    sprintf(linebuf,"%s%sMessages", logolib, separator);
    fp = fopen("Messages", "r");
    if (fp == NULL)
	fp = fopen(linebuf, "r");
    if (fp == NULL)
	fp = fopen("C:\\cygwin\\usr\\local\\lib\\logo\\logolib\\Messages", "r");
    if (fp == NULL) {
	printf("Error -- Can't read Messages file.\n");
	exit(1);
    }

    for (i=0; i<(MAX_MESSAGE+NUM_WORDS); i++) {
	while (fgets(linebuf, 99, fp) != NULL && linebuf[0] == ';') ;
	linebuf[strlen(linebuf)-1] = '\0';
	message_texts[i] = (char *) malloc(1+strlen(linebuf));
	strcpy(message_texts[i], linebuf);
    }

    fclose(fp);

#define wd_copy(x) \
    translations[Name_ ## x].English = intern_p(make_static_strnode(#x)); \
    translations[Name_ ## x].Alt = \
	intern_p(make_static_strnode(message_texts[MAX_MESSAGE + Name_ ## x]));

    do_trans(wd_copy);

    translations[Name_macro].English = intern_p(make_static_strnode(".macro"));

#define True translations[Name_true].English
#define False translations[Name_false].English

    setvalnode__caseobj(Caseignoredp, True);
    setflag__caseobj(Caseignoredp, VAL_BURIED);
    setvalnode__caseobj(AllowGetSet, True);
    setflag__caseobj(AllowGetSet, VAL_BURIED);
    setvalnode__caseobj(Fullprintp, False);
    setflag__caseobj(Fullprintp, VAL_BURIED);
    setvalnode__caseobj(UnburyOnEdit, True);
    setflag__caseobj(UnburyOnEdit, VAL_BURIED);
    setvalnode__caseobj(UseAlternateNames, False);
    setflag__caseobj(UseAlternateNames, VAL_BURIED);

    setvalnode__caseobj(LogoPlatform, make_static_strnode(LogoPlatformName));
    setflag__caseobj(LogoPlatform, VAL_BURIED);

    user_repcount = -1;
    ift_iff_flag = -1;

    num_saved_nodes = (NODE **)(&(val_status)) - (NODE **)(&(proc));
    Regs_Node = newnode(STACK);
    Regs_Node->n_car = (NODE *)&regs;

//hist_inptr = hist_outptr = cmdHistory;

#ifdef OBJECTS
    obj_init();
#endif

/*  Uncomment these to print debugging messages right away! */
/*
    setvalnode__caseobj(Redefp, True);
    setflag__caseobj(Redefp, VAL_BURIED);
 */
}
Exemplo n.º 14
0
main(int argc, char *argv[])
{
    NODE *exec_list = NIL;
#ifdef MEM_DEBUG
    extern long int mem_allocated, mem_freed;
#endif

#ifdef x_window
    x_window_init(argc, argv);
#endif
#ifdef mac
    init_mac_memory();
#endif
    term_init();
    if (argc < 2) {
	if (isatty(1)) lcleartext();
	printf("Welcome to Berkeley Logo version 3.0.1");
	new_line(stdout);
    }
    init();
#ifdef ibm
    signal(SIGINT, SIG_IGN);
#ifdef __ZTC__
    _controlc_handler = do_ctrl_c;
    controlc_open();
#endif
#else
    signal(SIGINT, logo_stop);
#endif
    signal(SIGQUIT, logo_pause);
    /* SIGQUITs never happen on the IBM */
    argv++;
    while (--argc > 0 && NOT_THROWING) {
	silent_load(NIL,*argv++);
    }
    for (;;) {
	if (NOT_THROWING) {
#ifdef MEM_DEBUG
	    printf("alloc=%d, freed=%d, used=%d\n",
		   mem_allocated, mem_freed, mem_allocated-mem_freed);
#endif
	    current_line = reref(current_line, reader(stdin,"? "));
	    if (feof(stdin) && !isatty(0)) lbye();
	    exec_list = parser(current_line, TRUE);
	    val_status = 0;
	    if (exec_list != NIL) eval_driver(exec_list);
	}
	if (stopping_flag == THROWING) {
	    if (compare_node(throw_node, Error, TRUE) == 0) {
		err_print();
	    } else if (compare_node(throw_node, System, TRUE) == 0)
		break;
	    else if (compare_node(throw_node, Toplevel, TRUE) != 0) {
		err_logo(NO_CATCH_TAG, throw_node);
		err_print();
	    }
	    stopping_flag = RUN;
	}
	if (stopping_flag == STOP || stopping_flag == OUTPUT) {
	    print_node(stdout, make_static_strnode(
		"You must be in a procedure to use OUTPUT or STOP.\n"));
	    stopping_flag = RUN;
	}
    }
    prepare_to_exit(TRUE);
}
Exemplo n.º 15
0
int  start (int argc,char ** argv) {
#else
int main(int argc, char *argv[]) {
#endif
    NODE *exec_list = NIL;
    NODE *cl_tail = NIL;
    int argc2;
    char **argv2;

#ifdef SYMANTEC_C
    extern void (*openproc)(void);
    extern void __open_std(void);
    openproc = &__open_std;
#endif

#ifdef mac
    init_mac_memory();
#endif

    bottom_stack = &exec_list; /*GC*/

#ifndef HAVE_WX
#ifdef x_window
    x_window_init(argc, argv);
#endif
#endif
    (void)addseg();
    term_init();
    init();

    math_init();

#ifdef ibm
    signal(SIGINT, SIG_IGN);
#if defined(__RZTC__) && !defined(WIN32) /* sowings */
    _controlc_handler = do_ctrl_c;
    controlc_open();
#endif
#else /* !ibm */
    signal(SIGINT, logo_stop);
#endif /* ibm */
#ifdef mac
    signal(SIGQUIT, SIG_IGN);
#else /* !mac */
	//signal(SIGQUIT, logo_pause);
#endif
    /* SIGQUITs never happen on the IBM */

    if (argc < 2) {
#ifndef WIN32
      if (1 || isatty(1))   // fix this.  for interactive from menu bar.
#endif
      {
#ifdef HAVE_WX
	extern char *SVN;
#endif
	char version[20];
	lcleartext(NIL);
#ifdef HAVE_WX
	strcpy(version,"6.0");
	strcat(version,SVN);
#else
	strcpy(version,"5.6");
#endif
	ndprintf(stdout, message_texts[WELCOME_TO], version);
	new_line(stdout);
      }
    }

#ifdef HAVE_WX
    setvalnode__caseobj(LogoVersion, make_floatnode(6.0));
#else
    setvalnode__caseobj(LogoVersion, make_floatnode(5.6));
#endif
    setflag__caseobj(LogoVersion, VAL_BURIED);

    argv2 = argv; argc2 = argc;

    if (!strcmp(*argv+strlen(*argv)-4, "logo")) {
	argv++;
	while (--argc > 0 && strcmp(*argv, "-") && NOT_THROWING) {
	    argv++;
	}
    }

    argv++;
    while (--argc > 0) {
	if (command_line == NIL) 
	    cl_tail = command_line = cons(make_static_strnode(*argv++), NIL);
	else {
	    setcdr(cl_tail, cons(make_static_strnode(*argv++), NIL));
	    cl_tail = cdr(cl_tail);
	}
    }

    setvalnode__caseobj(CommandLine, command_line);

    silent_load(Startuplg, logolib);
    silent_load(Startup, NULL); /* load startup.lg */
    if (!strcmp(*argv2+strlen(*argv2)-4, "logo")) {
	argv2++;
	while (--argc2 > 0 && strcmp(*argv2, "-") && NOT_THROWING) {
	    silent_load(NIL,*argv2++);
	    }
    }

    for (;;) {
	if (NOT_THROWING) {
	    check_reserve_tank();
	    current_line = reader(stdin,"? ");
#ifdef __RZTC__
		(void)feof(stdin);
		if (!in_graphics_mode)
		    printf(" \b");
		fflush(stdout);
#endif

#ifndef WIN32
	    if (feof(stdin) && !isatty(0)) lbye(NIL);
#endif

#ifdef __RZTC__
	    if (feof(stdin)) clearerr(stdin);
#endif
	    if (NOT_THROWING) {
		exec_list = parser(current_line, TRUE);
		if (exec_list != NIL) eval_driver(exec_list);
	    }
	}
#ifdef HAVE_WX
	if (wx_leave_mainloop) {
	  break;
	}
#endif	
	if (stopping_flag == THROWING) {
	    if (isName(throw_node, Name_error)) {
		err_print(NULL);
	    } else if (isName(throw_node, Name_system))
		break;
	    else if (!isName(throw_node, Name_toplevel)) {
		err_logo(NO_CATCH_TAG, throw_node);
		err_print(NULL);
	    }
	    stopping_flag = RUN;
	}
	if (stopping_flag == STOP || stopping_flag == OUTPUT) {
	/*    ndprintf(stdout, "%t\n", message_texts[CANT_STOP]);   */
	    stopping_flag = RUN;
	}
    }
    //prepare_to_exit(TRUE);
    exit(0);
    return 0;
}