int main6(int argc, char *argv[]) { Intstack cell, co; int rank, upb, nr = 0; assert(argc > 1); rank = atoi(argv[1]); upb = 1 << rank; co = newIntstack(upb, NULL); cell = readCell(); while (cell) { nr = getCnr(); printCell(nr, cell); complement(upb, cell, co); printf("COM "); printCell(0, co); freestack(cell); printf("\n"); cell = readCell(); } freestack(cell); freestack(co); #if 0 reportTime(); reportCnt(); #endif finalizeScanner(); return 0; }
static void* cycleWander(void *maxPtr) { int maxX = *((int *) maxPtr); int index = randUnif(1, 87); int sleepFor = 0; while (1) { index = randNextCell(index); pthread_mutex_lock(&mutex); printFolly(maxX); printCell(index, maxX); sleepFor = randUnif(0, 4); move(0, 0); pthread_mutex_unlock(&mutex); if (sleepFor == 0) { usleep(250000); } else if (sleepFor == 1) { usleep(450000); } else if (sleepFor == 2) { usleep(500000); } else if (sleepFor == 3) { usleep(550000); } else { usleep(1250000); } } return NULL; }
void traceExit(CELL * result, CELL * cell, CELL * pCell, CELL * args) { if(traceFlag & (TRACE_IN_ENTRY | TRACE_IN_EXIT | TRACE_SIGNAL | TRACE_SIGINT | TRACE_TIMER)) return; if(traceFlag == TRACE_PRINT_EVAL) { tracePrint("exit", result); return; } traceFlag |= TRACE_IN_EXIT; #ifdef DEBUGGER if(traceFlag & TRACE_DEBUG_NEXT) { if(currentLevel >= recursionCount) traceFlag &= ~TRACE_DEBUG_NEXT; else { traceFlag &= ~TRACE_IN_EXIT; return; } } if( (pCell->type == CELL_LAMBDA || pCell->type == CELL_FEXPR) && args->type == CELL_SYMBOL) { if((UINT)recursionCount == *(debugStack + debugStackIdx - 2) ) { debugStackIdx -= 2; if(debugStackIdx > 0) currentFunc = (SYMBOL *)*(debugStack + debugStackIdx - 1); if(debugStackIdx == 0) traceFlag &= ~TRACE_DEBUG_NEXT; } } if(debugPrintFunction(cell)) { varPrintf(OUT_CONSOLE, "\nRESULT: "); printCell(result, TRUE, OUT_CONSOLE); varPrintf(OUT_CONSOLE, "\n"); if(debugStackIdx > 0) { getDebuggerInput(DEBUG_EXIT); if(!traceFlag) return; } } if(traceFlag & TRACE_DEBUG_NEXT) currentLevel = recursionCount; #endif /* DEBUGGER */ traceFlag &= ~TRACE_IN_EXIT; }
void tracePrint(char * label, CELL * expr) { UINT printDeviceSave = printDevice; printDevice = tracePrintDevice; varPrintf(OUT_DEVICE, "%d %s: ", recursionCount, label); if(expr) printCell(expr, TRUE, OUT_DEVICE); varPrintf(OUT_DEVICE, "%s", "\n"); printDevice = printDeviceSave; }
void printTbl(htmltbl_t * tbl, int ind) { htmlcell_t **cells = tbl->u.n.cells; indent(ind); fprintf(stderr, "tbl %d %d ", tbl->cc, tbl->rc); printData(&tbl->data); fputs("\n", stderr); while (*cells) printCell(*cells++, ind + 1); }
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; }
void DualPolyhedron_3::makeConsistent() { DEBUG_START; unsigned iIteration = 0; unsigned numResolved = countResolvedItems(); std::set<std::pair<Cell_handle, unsigned>> touched; while (numResolved < items.size()) { std::cout << "===== Iteration #" << iIteration << " =====" << std::endl; std::cout << " Resolved " << numResolved << " items from " << items.size() << std::endl; const auto &outerCells = getOuterCells(); auto steps = iterate(outerCells, items, infinite_vertex()); auto it = steps.begin(); do { while (touched.find(std::make_pair( it->cell, it->iNearest)) != touched.end()) ++it; ASSERT(it != steps.end() && "No possible step has been found."); touched.insert(std::make_pair(it->cell, it->iNearest)); std::cout << "Next cell to be iterated on: "; printCell(it->cell, infinite_vertex()); std::cout << "Nearest plane ID: " << it->iNearest << std::endl; std::cout << "Nearest distance: " << it->distance << std::endl; } while (!lift(it->cell, it->iNearest)); /* FIXME: Optimize this by local graph traversal */ initialize(); unsigned numResolvedPrev = numResolved; numResolved = countResolvedItems(); std::cout << " Change in the number of resolved items: " << numResolved - numResolvedPrev << std::endl; ASSERT(numResolved >= numResolvedPrev && "Degradation happened"); ++iIteration; } DEBUG_END; }
void Printer::printLine(string type, string line, string text, string val) { cout << _cellSeparator; printCell(type, TOKEN_TYPE_LEN); printCell(line, TOKEN_LINE_LEN); printCell(text, TOKEN_TEXT_LEN); size_t lpos = 0, rpos; while ((rpos = val.find('\n', lpos)) != string::npos) { printCell(val.substr(lpos, rpos - 1), TOKEN_VALUE_LEN, 1); cout << endl << '|'; lpos = rpos + 1; printCell("", TOKEN_TYPE_LEN); printCell("", TOKEN_LINE_LEN); printCell("", TOKEN_TEXT_LEN); } rpos = rpos != string::npos ? rpos : val.length(); printCell(val.substr(lpos, rpos), TOKEN_VALUE_LEN, 1); cout << endl; }
/******************************************************************* * Function: void printMap(void) * Input Variables: void * Output Return: void * Overview: Print the map ********************************************************************/ void printMap(void) { unsigned char r; unsigned char c; unsigned char cell; unsigned char curRow = currentCellWorld >> 2; unsigned char curCol = currentCellWorld & 0b0011; BOOL isrobot; for(r = 0; r < WORLD_ROW_SIZE; r++){ for(c = 0; c < WORLD_COLUMN_SIZE; c++){ cell = ROBOT_WORLD[r][c]; isrobot = (r == curRow)&&(c == curCol); printCell(cell, r, c, isrobot, currentOrientation); } } }
void printTreeRec(cellptr cell, int level) { int i, l; nodeptr q; for (i = 0; i < NCHILD; i++) { if ((q = Child(cell)[i]) != NULL) { if (Type(q) == BODY) { for (l = 1; l < level; l++) printf(" "); printf("%d B ", findIndex((bodyptr) q, cell)); printBody((bodyptr) q); printf("\n"); } else { for (l = 1; l < level; l++) printf(" "); printf("%d C ", findIndex((bodyptr) q, cell)); printCell((cellptr) q); printf("\n"); printTreeRec((cellptr) q, level + 1); } } } }
void Maze::writeMazeToFile (void *pFile, bool isShowMouse) { char buf; for (int i = 0; i < (mazeMAX_ROW_SIZE * 2 + 1); i++) { if (i % 2 == 0) { for (int j = 0; j < mazeMAX_COL_SIZE; j++) { switch (rowWall[i / 2][j]) { case empty: buf = '.'; break; case wall: buf = '_'; break; case unknown: buf = '*'; break; case eWallError: default: printf("Error on rowWall!"); break; } fputc(' ', (FILE*) pFile); fputc(buf, (FILE*) pFile); } fputc(' ', (FILE*) pFile); } else { for (int j = 0; j < mazeMAX_COL_SIZE + 1; j++) { switch (colWall[i / 2][j]) { case empty: buf = '.'; break; case wall: buf = '|'; break; case unknown: buf = '*'; break; case eWallError: default: printf("Error on rowWall!"); break; } /* print wall first */ fputc(buf, (FILE*) pFile); if(!(j >= mazeMAX_COL_SIZE)) { printCell(i/2, j, isShowMouse, pFile); } } } /* print newline */ fputc('\r', (FILE*) pFile); fputc('\n', (FILE*) pFile); } }