示例#1
0
CELL * appendString(CELL * cell, CELL * list, char * joint, size_t jointLen, int trailJoint, int evalFlag)
{ 
CELL * result;
STREAM stream = {0, NULL, NULL, 0, 0};
char * sPtr;
size_t len;

openStrStream(&stream, MAX_LINE, 0);
writeStreamStr(&stream, (char *)cell->contents, cell->aux - 1);
while(list != nilCell)
	{
	if(joint == NULL)
		{
		list = getStringSize(list, &sPtr, &len, evalFlag);		
		writeStreamStr(&stream, sPtr, len);
		}
	else
		{
		list = getStringSize(list, &sPtr, &len, FALSE);
		if(jointLen) writeStreamStr(&stream, joint, jointLen);
		writeStreamStr(&stream, sPtr, len);
		}
	}

if(trailJoint)
	writeStreamStr(&stream, joint, jointLen);

result = stuffStringN(stream.buffer, stream.position);

closeStrStream(&stream);

return(result);
}
示例#2
0
文件: nl-debug.c 项目: vxchao/newlisp
int debugPrintFunction(CELL * cell)
{
int preLen, pos = 0;
char * strPos;

STREAM strStream = {NULL, NULL, 0, 0, 0};

if(currentFunc == nilSymbol) return FALSE;

debugPrintCell = cell;
openStrStream(&strStream, MAX_STRING, 0);
printSymbol(currentFunc, (UINT)&strStream);
debugPrintCell = NULL;

strPos = strstr(strStream.buffer, debugPreStr);
if(strPos != NULL)
    {
    preLen = strlen(debugPreStr);
    while(*(strPos + preLen + pos) <= ' ' && *(strPos + preLen + pos) != 0) ++pos;
    if(pos) /* if there is white space */
        {
        /* swap whitespace and debugPreStr */
        strncpy(strPos, strPos + preLen, pos);
        strncpy(strPos + pos, debugPreStr, preLen);
        }
    varPrintf(OUT_CONSOLE, "%s", headerStr);
    varPrintf(OUT_CONSOLE, "%s", strStream.buffer);
    }

closeStrStream(&strStream);
return (strPos != NULL);
}
示例#3
0
static int newLISP_eval_stream(lua_State *L, STREAM *strStream) {
   CELL * cell = evaluateStream(strStream, 0, 1);

   STREAM libStrStream = {0, NULL, NULL, 0, 0};
   openStrStream(&libStrStream, 8192, 1);
   printCell(cell, 0, (UINT)&libStrStream);

   char * result = libStrStream.buffer;
   lua_pushstring(L, result);
   return 1;
}