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); }
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); }