Finally reworked "cells" command behavior into something
consistent.
This commit is contained in:
parent
fdf2f32654
commit
70bb33cc62
|
|
@ -563,8 +563,11 @@ static int PrintCellHashTableElement(struct hashlist *p)
|
|||
/* only print primitive cells if Debug is enabled */
|
||||
if (Debug == 1) Printf("Cell: %s (instanced %d times); Primitive\n",
|
||||
ptr->name, ptr->number);
|
||||
else if (Debug == 3) { /* list */
|
||||
Tcl_AppendElement(netgeninterp, ptr->name);
|
||||
}
|
||||
}
|
||||
else if (Debug == 2) { /* list only */
|
||||
else if ((Debug == 2) || (Debug == 3)) { /* list only */
|
||||
#ifdef TCL_NETGEN
|
||||
Tcl_AppendElement(netgeninterp, ptr->name);
|
||||
#else
|
||||
|
|
@ -595,7 +598,7 @@ void PrintCellHashTable(int full, int filenum)
|
|||
|
||||
bins = RecurseHashTable(&cell_dict, CountHashTableBinsUsed);
|
||||
total = RecurseHashTable(&cell_dict, CountHashTableEntries);
|
||||
if (full != 2)
|
||||
if (full < 2)
|
||||
Printf("Hash table: %d of %d bins used; %d cells total (%.2f per bin)\n",
|
||||
bins, CELLHASHSIZE, total, (bins == 0) ? 0 :
|
||||
(float)((float)total / (float)bins));
|
||||
|
|
@ -605,7 +608,7 @@ void PrintCellHashTable(int full, int filenum)
|
|||
RecurseHashTable(&cell_dict, PrintCellHashTableElement);
|
||||
Debug = OldDebug;
|
||||
#ifndef TCL_NETGEN
|
||||
if (full == 2) Printf("\n");
|
||||
if (full >= 2) Printf("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1437,9 +1437,9 @@ _netgen_cells(ClientData clientData,
|
|||
char *optstart;
|
||||
int filenum = -1;
|
||||
struct nlist *np = NULL;
|
||||
int result, dolist = 0;
|
||||
int result, printopt, dolist = 0, doall = 0, dotop = 0;
|
||||
|
||||
if (objc > 1) {
|
||||
while (objc > 1) {
|
||||
optstart = Tcl_GetString(objv[1]);
|
||||
if (*optstart == '-') optstart++;
|
||||
if (!strcmp(optstart, "list")) {
|
||||
|
|
@ -1447,27 +1447,41 @@ _netgen_cells(ClientData clientData,
|
|||
objv++;
|
||||
objc--;
|
||||
}
|
||||
else if (!strcmp(optstart, "all")) {
|
||||
doall = 1;
|
||||
objv++;
|
||||
objc--;
|
||||
}
|
||||
else if (!strcmp(optstart, "top")) {
|
||||
dotop = 1;
|
||||
objv++;
|
||||
objc--;
|
||||
}
|
||||
else {
|
||||
result = CommonParseCell(interp, objv[1], &np, &filenum);
|
||||
if (result != TCL_OK) return result;
|
||||
objv++;
|
||||
objc--;
|
||||
}
|
||||
}
|
||||
|
||||
if (objc == 1) {
|
||||
PrintCellHashTable((dolist) ? 2 : 0, -1);
|
||||
}
|
||||
else if (objc != 2 && objc != 3) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "[list] -top|[-all] valid_filename");
|
||||
if (objc != 1) {
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "[list] [-top] [-all] [valid_filename]");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
else {
|
||||
Tcl_Obj *lobj;
|
||||
|
||||
repstr = Tcl_GetString(objv[1]);
|
||||
if (!strncmp(repstr, "-top", 4)) {
|
||||
if (dotop) {
|
||||
if (dolist)
|
||||
lobj = Tcl_NewListObj(0, NULL);
|
||||
else
|
||||
Fprintf(stdout, "Top level cells: ");
|
||||
np = FirstCell();
|
||||
while (np != NULL) {
|
||||
if (np->flags & CELL_TOP) {
|
||||
if ((np->flags & CELL_TOP) && ((filenum == -1) ||
|
||||
(np->file == filenum))) {
|
||||
|
||||
if (dolist)
|
||||
Tcl_ListObjAppendElement(interp, lobj,
|
||||
Tcl_NewStringObj(np->name, -1));
|
||||
|
|
@ -1483,11 +1497,13 @@ _netgen_cells(ClientData clientData,
|
|||
|
||||
return TCL_OK;
|
||||
}
|
||||
else if (strncmp(repstr, "-all", 4)) {
|
||||
result = CommonParseCell(interp, objv[2], &np, &filenum);
|
||||
if (result != TCL_OK) return result;
|
||||
else {
|
||||
if (dolist)
|
||||
printopt = (doall) ? 3 : 2;
|
||||
else
|
||||
printopt = (doall) ? 1 : 0;
|
||||
PrintCellHashTable(printopt, filenum);
|
||||
}
|
||||
PrintCellHashTable((dolist) ? 2 : 1, filenum);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue