From 6cefbd13f1dac2293aaa1537a6ee2ad23c11a273 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 22 Dec 2022 14:53:24 -0500 Subject: [PATCH] Expanded the method for "flatten in place" to include the more natural flattening from a selection. That is, instead of specifying "flatten -doinplace ", you can select some number of instances and just do "flatten -doinplace". --- commands/CmdFI.c | 160 ++++++++-------------- database/DBcellcopy.c | 293 ++++++++++++++++++++++++++++++++++++++--- database/database.h.in | 3 + 3 files changed, 333 insertions(+), 123 deletions(-) diff --git a/commands/CmdFI.c b/commands/CmdFI.c index 127ff706..fb624e71 100644 --- a/commands/CmdFI.c +++ b/commands/CmdFI.c @@ -1958,7 +1958,7 @@ CmdFlatten(w, cmd) MagWindow *w; TxCommand *cmd; { - int rval, xMask; + int i, xMask, optargs; bool dolabels, dobox, toplabels, invert, doports, doinplace; char *destname; CellDef *newdef; @@ -1966,36 +1966,32 @@ CmdFlatten(w, cmd) SearchContext scx; CellUse *flatDestUse; - destname = cmd->tx_argv[cmd->tx_argc - 1]; + destname = NULL; xMask = CU_DESCEND_ALL; dolabels = TRUE; toplabels = FALSE; dobox = FALSE; doports = TRUE; doinplace = FALSE; + optargs = cmd->tx_argc - 1; - rval = 0; - if (cmd->tx_argc > 2) + if (optargs > 0) { - int i; - for (i = 1; i < (cmd->tx_argc - 1); i++) + for (i = 1; i < (optargs + 1); i++) { - if (!strncmp(cmd->tx_argv[i], "-no", 3)) + if ((cmd->tx_argv[i][0] == '-') && (strlen(cmd->tx_argv[i]) > 3)) { - invert = TRUE; - } - else if (!strncmp(cmd->tx_argv[i], "-do", 3)) - { - invert = FALSE; - } - else - { - rval = -1; - break; - } + if (!strncmp(cmd->tx_argv[i] + 1, "no", 2)) + invert = TRUE; + else if (!strncmp(cmd->tx_argv[i] + 1, "do", 2)) + invert = FALSE; + else + { + TxError("Bad flatten option \"%s\"; must start with \"-no\" or \"-do\"\n", + cmd->tx_argv[i]); + return; + } - if (strlen(cmd->tx_argv[i]) > 3) - { switch(cmd->tx_argv[i][3]) { case 'b': @@ -2029,98 +2025,53 @@ CmdFlatten(w, cmd) break; } } + else + destname = cmd->tx_argv[i]; } } - else if (cmd->tx_argc != 2) - rval = -1; - if (rval != 0) + /* Flatten-in-place */ + if (doinplace) { - TxError("usage: flatten [-