mirror of
https://github.com/Interlisp/maiko.git
synced 2026-01-26 20:02:37 +00:00
Improvements to package/atom access in the sysout from maiko C code (#372)
* Display atom name in error message if get_package_atom() fails * Various fixes to package/atom handling in testtool.c Remove S_TOPVAL and S_MAKEATOM which only existed to deal with an old issue with dbx where you supposedly couldn't enter a string with "\" in it. Remove countchar(), which is functionally identical to strlen(), and adjust code that used it. Adjust return type of MAKEATOM() to be the LispPTR that it should be, instead of int. Limit find_package_from_name() to examining only the number of entries that are present in the *PACKAGE-FROM-INDEX* array, instead of walking off the end. MakeAtom68k() now drops into uraid() if asked to look up an atom that does not exist (Make... is a misnomer, it will never *make* the atom, only lookup an existing one)
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lispemul.h"
|
||||
#include "lispmap.h"
|
||||
@@ -58,7 +59,9 @@
|
||||
#include "debug.h"
|
||||
#include "dbprint.h"
|
||||
#include "tosfns.h"
|
||||
#include "array.h"
|
||||
|
||||
#include "commondefs.h"
|
||||
#include "testtooldefs.h"
|
||||
#include "dbgtooldefs.h"
|
||||
#include "gcarraydefs.h"
|
||||
@@ -107,16 +110,17 @@ void print_atomname(LispPTR index)
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
#define PACKAGES_LIMIT 255
|
||||
/** GET PACKAGE INDEX from PACKAGE FULL NAME */
|
||||
int find_package_from_name(const char *packname, int len) {
|
||||
int index;
|
||||
PACKAGE *package;
|
||||
NEWSTRINGP *namestring;
|
||||
DLword len2;
|
||||
char *pname;
|
||||
struct arrayheader *pi_array;
|
||||
|
||||
for (index = 1; index <= PACKAGES_LIMIT; index++) {
|
||||
/* assumes the *PACKAGE-FROM-INDEX* array is simple with no offset */
|
||||
pi_array = (struct arrayheader *)Addr68k_from_LADDR(*Package_from_Index_word);
|
||||
for (index = 1; index < pi_array->totalsize; index++) {
|
||||
package = (PACKAGE *)Addr68k_from_LADDR(aref1(*Package_from_Index_word, index));
|
||||
namestring = (NEWSTRINGP *)Addr68k_from_LADDR(package->NAME);
|
||||
pname = (char *)Addr68k_from_LADDR(namestring->base);
|
||||
@@ -848,18 +852,6 @@ void printPC(void) {
|
||||
printf("PC: O%o ", pc);
|
||||
}
|
||||
|
||||
/***************************/
|
||||
int countchar(char *string) {
|
||||
int cnt = 0;
|
||||
|
||||
while (*string != '\0') {
|
||||
string++;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
void dump_bf(Bframe *bf) {
|
||||
DLword *ptr;
|
||||
printf("\n*** Basic Frame");
|
||||
@@ -1025,10 +1017,8 @@ FX *get_nextFX(FX *fx) {
|
||||
|
||||
} /* get_nextFX end */
|
||||
|
||||
int MAKEATOM(char *string) {
|
||||
int length;
|
||||
length = countchar(string);
|
||||
return (make_atom(string, 0, length, 0));
|
||||
LispPTR MAKEATOM(char *string) {
|
||||
return (make_atom(string, 0, strlen(string), 0));
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
@@ -1041,8 +1031,11 @@ int MAKEATOM(char *string) {
|
||||
/************************************************************************/
|
||||
|
||||
LispPTR *MakeAtom68k(char *string) {
|
||||
int index;
|
||||
index = make_atom(string, 0, countchar(string), 0);
|
||||
LispPTR index;
|
||||
index = make_atom(string, 0, strlen(string), 0);
|
||||
if (index == 0xffffffff) {
|
||||
error("MakeAtom68k: no such atom found");
|
||||
}
|
||||
#ifdef BIGVM
|
||||
index = (ATOMS_HI << 16) + (index * 10) + NEWATOM_VALUE_OFFSET;
|
||||
#else
|
||||
@@ -1071,44 +1064,6 @@ void GETTOPVAL(char *string) {
|
||||
printf("'%s': no such symbol.\n", string);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* S _ T O P V A L */
|
||||
/* */
|
||||
/* Given a string that's an atom name minus the initial \, */
|
||||
/* print the atom's top-level value. This is here because */
|
||||
/* DBX won't put \'s in strings you type. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
void S_TOPVAL(char *string) {
|
||||
int index;
|
||||
LispPTR *cell68k;
|
||||
int length;
|
||||
char dummy[256];
|
||||
|
||||
dummy[0] = '\\';
|
||||
for (length = 1; *string != '\0'; length++, string++) { dummy[length] = *string; }
|
||||
|
||||
index = make_atom(dummy, 0, length, 0);
|
||||
cell68k = (LispPTR *)GetVALCELL68k(index);
|
||||
print(*cell68k);
|
||||
}
|
||||
|
||||
/***************/
|
||||
int S_MAKEATOM(char *string) {
|
||||
int index = 0;
|
||||
int length;
|
||||
char dummy[256];
|
||||
|
||||
dummy[0] = '\\';
|
||||
for (length = 1; *string != '\0'; length++, string++) { dummy[length] = *string; }
|
||||
|
||||
index = make_atom(dummy, 0, length, 0);
|
||||
printf("#Atomindex : %d\n", index);
|
||||
return (index);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* all_stack_dump(start,end)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user