Commit Graph

256 Commits

Author SHA1 Message Date
R. Timothy Edwards 27c423c2ed Substantially revised the "macro" command callback functions and
the "tool" implementation.  Previously, the "tool" implementation
would overwrite the button bindings for the mouse.  The problem
with that is that if the user customizes one or more of the
bindings, such as using the mouse wheel for zooming instead of
panning, then the custom macro gets obliterated when the tool
changes.  The reimplementation creates multiple macro sets which
are unique to each tool.  The "enable_tools" function sets up
the initial unique default bindings for each tool.  The user
can then customize the bindings for any tool, and the
implementation no longer requires the constant changing of key
bindings.  Note that the new implementation is slightly less
efficient because the macro tables are found by string hash
based on the name of the tool or client type, not the integer
client ID.  The reduction in efficiency is balanced by the
increased flexibility of the macros.
2025-10-09 15:43:54 -04:00
Darryl L. Miles 3c9987f460 CmdFI.c: CmdGoto() correct printf output
non-tktcl build check
2025-10-04 20:50:31 -04:00
Darryl L. Miles dc45242d46 database: DBTypeLongNameTbl() constify data (const char*) 2025-10-04 20:50:31 -04:00
Darryl L. Miles c8fe30398b database: DBTechInitPlane() consumer (DBPlaneLongNameTbl constify) 2025-10-04 20:50:31 -04:00
Darryl L. Miles c7ef7d743a CmdRS.c: SimGetNodeCommand() returns (const char *) now 2025-10-04 20:50:31 -04:00
Darryl L. Miles df7b9079bd CmdFindLabel: fix off-by-one error with: findlabel -glob name
Thanks @d-m-bailey Mitch Bailey for reporting
2025-10-04 20:50:31 -04:00
Darryl L. Miles cfd1d567bd commands: Various fixes for TxPrintf() with !MAGIC_WRAPPER
!MAGIC_WRAPPER build for WASM exposes
2025-10-04 20:50:31 -04:00
R. Timothy Edwards b1c7b52ed2 Modified "gds flatglob" to have the value "*_CDNS_*" by default,
since this is a common artifact of foundry cells and almost
always incompatible with magic.  Modified the "port" command to
allow "port make <index>" on a label where other labels of the
same text already have the same index.  Removed deprecated
documentation and added some missing documentation, such as an
explanation of the "ext2spice subcircuit auto" option.
2025-09-26 09:18:43 -04:00
R. Timothy Edwards 741216d6f3 Added a new command "archive" that works roughly like the "crash"
command, but with some critical differences, since the "crash"
command is designed for crash backups.  "crash" will save in a
temp file and removes the file after a successful recovery.
"archive" can be used at any time to make a complete snapshot of
a layout in a single file, or to read back that snapshot.
There is a "writeall" option that will make a snapshot including
layout of all read-only (PDK) cells.
2025-09-10 12:40:40 -04:00
R. Timothy Edwards 59a1953f3c Modified the GDS read routine to give location information when
a self-intersecting or reversing path is seen in the input.
Added a new feature in which "save <cell>.tcl" will create a
file of magic commands that will re-create the cell when sourced
as a command file.
2025-09-05 17:51:46 -04:00
R. Timothy Edwards b1095b323c Added a command option for "select move" without specifying the
X and Y values, in which case the selection is moved to the
current pointer position.  This allows a different implementation
of the "copy" command as "select move; select keep", which avoids
the problem that "copy" has of modifying the selection with layer
interactions with the existing layout.
2025-08-27 09:57:22 -04:00
R. Timothy Edwards e04307c085 Corrected an issue in computing the extended (includes area of
label text) vs. non-extended bounding box of a cell when doing
"getcell" (and probably a number of other commands/functions, as
well).  A function was always computing the extended bounding box
and then setting both the normal and extended bounding boxes of
the cell to this value, resulting in incorrect cell selections.
2025-08-26 11:00:20 -04:00
R. Timothy Edwards d2acdac901 Corrected an error accidentally introduced a few commits ago in
(commit 4084a6a246) in which a
misplaced close-brace altered the way that "getcell" handles
some orientation cases.  Thanks to Sylvain Munaut for discovering
the error.
2025-08-21 10:44:24 -04:00
R. Timothy Edwards 4084a6a246 Modified the syntax of the "getcell" command to make the
arguments unambiguous, and to allow coordinates to be given in
any units.  To do this, the (seldom if ever used) passing of a
label as a reference point was changed to require the "label"
keyword before the label name, avoiding the code having to
disambiguate arguments from label text.  This now makes it
possible to specify the coordinates in microns, lambda, etc.,
units.
2025-08-15 10:24:31 -04:00
Darryl L. Miles d55a2b74ac header file #ifndef guard namespace consistency (global change)
This add an effective namespace prefix to the guard ifndef
2025-07-29 10:50:32 -04:00
Darryl L. Miles f88c7a86cb utils/magic_zlib.h: limit #include <zlib.h> to files that need it
Remove limited use HAVE_ZLIB wrapper API into separate header as
utils.h is used in many places and most source files don't need
to drag in the header file from this external dependency.

Copyright date(s) taken from original source file / git blame.
2025-07-29 10:50:32 -04:00
Darryl L. Miles acefe4811f readline/Makefile: move up before with no scheme
rename symlink(s) use phony targets, delegate the symlink creation
management command sequence to a single point in the project inside
the readline/Makefile
2025-07-29 10:50:31 -04:00
Darryl L. Miles df0623a435 include <unistd.h> where necessary in files using API calls
When global <sys/mman.h> was removed from tile.h it also removed
<unistd.h> nearby.  This exposes the lack of <unistd.h> being
included where needed using APIs like close()/read()/unlink()/isatty()
the WASM build seems to show this as the header file set is structured
differently.
2025-07-27 12:42:05 -04:00
Darryl L. Miles 35d455fd72 C23: CmdSubrs.c fixup deprecated isascii() 2025-07-26 17:44:45 -04:00
Darryl L. Miles dd84be9172 CmdCD.c: fix missing 'else' from my recent commit e88dcba1c 2025-02-23 10:23:51 -05:00
Darryl L. Miles e88dcba1c5 CodeQL File{MayNot,Never}BeClosed.ql file-handle resource leaks
Guided by CodeQL static code analyser.

FileMayNotBeClosed.ql
FileMayNeverBeClosed.ql

The trick with "if(fp != stdout)" is problematic (to analyser) as
technically 'stdout' can be a global pointer that COULD be modified any
time, so it might have changed between the fopen() and fclose() calls so
the close MAY NEVER occurs (which is problem the analyzer can see).

So local state is maintained as a bool which will also clarify to the
compiler see the intention without concern for external stdout
modification.

Some items appear to be out and out leaks when certain commands are use.
2025-02-22 21:02:49 -05:00
Tim Edwards 144c22f579 Added the ability to translate pointer-based "wire" commands from
interactive wiring into coordinate-based commands.  Added new
command extensions for "wire leg", "wire vertical", "wire type",
and "wire horizontal".  Modified the command logging such that
"wire show" (which does not modify layout) does not get logged,
which avoids unnecessary logging of mouse movement.
2025-02-22 17:06:06 -05:00
Darryl L. Miles b694827bcb feat: flush [-noprompt], option support 2025-01-07 13:58:45 -05:00
Darryl L. Miles cfdd50aa63 Revert "commands/CmdFI.c: added CmdFlush_NoConfirm option to disable flush prompt"
This reverts commit 772bfe2f71.

See #341
2025-01-07 13:58:45 -05:00
Darryl L. Miles 065f31f689 gcc11 -Wall -Wpedantic cleanup (post __attribute__ DLONG_PREFIX) 2025-01-06 16:27:10 +00:00
Darryl L. Miles 07f9bbe1fb gcc11 -Wall -Wpedantic cleanup 2025-01-06 16:12:11 +00:00
Darryl L. Miles 0376430702 command: use 'const' with readonly data
This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
2025-01-04 11:31:17 -05:00
Darryl L. Miles 5c410e9dcb command: use 'const' with 'rcsid' 2025-01-04 11:31:17 -05:00
Darryl L. Miles c339e9b845 TCL9: CmdLQ.c Tcl_AppendResult(... (char*)NULL) cast sentinal
In the TCL8 to TCL9 porting information it was indicated the
sentinal NULL termination should be cast (char *) with API
call Tcl_AppendResult().

This was already in place for most of the codebase this
resolves the last few places.
2025-01-04 11:08:01 -05:00
Darryl L. Miles 0ce8265570 TCL9: ClientData macro assignment and access usage 2025-01-04 11:08:01 -05:00
Darryl L. Miles b8dae95515 Lookup() constify call-site
extflat/EFantenna.c: Lookup() constify call-site
drc/DRCtech.c: Lookup() constify call-site
dbwind/DBWelement.c: Lookup() constify call-site
database/DBtpaint.c: Lookup() constify call-site
commands/CmdTZ.c: Lookup() constify call-site
commands/CmdRS.c: Lookup() constify call-site
commands/CmdLQ.c: Lookup() constify call-site
commands/CmdFI.c: Lookup() constify call-site
commands/CmdE.c: Lookup() constify call-site
commands/CmdCD.c: Lookup() constify call-site
commands/CmdAB.c: Lookup() constify call-site
cmwind/CMWcmmnds.c: Lookup() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles 14b6453707 LookupStruct() constify call-site
irouter/irTestCmd.c: LookupStruct() constify call-site
irouter/irCommand.c: LookupStruct() constify call-site
mzrouter/mzTestCmd.c: LookupStruct() constify call-site
mzrouter/mzTech.c: LookupStruct() constify call-site
router/rtrCmd.c: LookupStruct() constify call-site
plow/PlowTest.c: LookupStruct() constify call-site
plow/PlowTech.c: LookupStruct() constify call-site
plot/plotVers.c: LookupStruct() constify call-site
grouter/grouteTest.c: LookupStruct() constify call-site
garouter/gaTest.c: LookupStruct() constify call-site
extract/ExtTest.c: LookupStruct() constify call-site
extract/ExtTech.c: LookupStruct() constify call-site
extflat/EFread.c: LookupStruct() constify call-site
DRCtech.c: LookupStruct() constify call-site
debugFlags.c: LookupStruct() constify call-site
CmdSubrs.c: LookupStruct() constify call-site
geometry.c: LookupStruct() constify call-site
set.c: LookupStruct() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles aa43cc164e geometry.h: constify global wellknown Geometry data values
This then rippled through into callers

Fixed merge conflicts in cif/CIFrdutils.c and cif/CIFread.h
2024-12-26 15:20:39 -05:00
Darryl L. Miles bd03a550d3 CmdCD.c: DBOrientUse() called with too many arguments.
Comment added to come back to later.

DBOrientUse(cellname, dodef/*, orient*/);
2024-12-26 13:13:13 -05:00
Darryl L. Miles f08793ddd7 CmdTZ.c: use strict prototype for qsort() compar callback function 2024-12-26 13:13:13 -05:00
Darryl L. Miles 2123f7090d CmdCD.c: removed unnecessary fwd decl for function in included header
commands.h contains the prototype for cmdFlushCell() which is already
being included in CmdCD.c
2024-12-26 13:13:13 -05:00
Darryl L. Miles 56139b48eb K&R commands/*.c: bulk forward reference function prototype conversion
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles afd1b0b2df K&R commands: 2 x missing forward declaration removal
Functions do not appear to exist:
 extern void DisplayWindow();
 extern void DisplayWindow();

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles b3d4ab7980 K&R commands/*.c: bulk function implementation conversion
Argument order and type declaration mismatches:

Label *
portFindLabel(editDef, port, unique, nonEdit)
    CellDef *editDef;
    bool unique;
    bool port;         // If TRUE, only look for labels that are ports
    bool *nonEdit;     // TRUE if label is not in the edit cell

This warrants inspection at call site CmdLQ.c:1712 as both types are bool
is it not so straightforward to check.

It looks like when PORT_MAKE is the option 'port make [index] [dir...]'
  port=FALSE is this the correct intention ?  This looks ok in that
 we're searching for labels to make (upgrade) into ports.
Where as all other 'port ....' commands are operating on items that are
 already ports, and ignoring labels.
So the K&R argument name order is also how the call-sites are using it.

void
cmdStatsHier(parent, nuses, child)
    CellDef *parent, *child;
    int nuses;

This was checked and found ok as callback to ../database/DBcount.c
DBTreeCountPaint(... hiercount, ...)

Due to this not-obvious K&R style also being used in the documentation
this was changed as well (in another commit0.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles 8a4464f443 commands.h: add #include "textio/txcommands.h"
The type TxCommand is used in the function signatures.

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles 06b5870035 K&R commands.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Darryl L. Miles 866699f353 K&R commands.h: 3 x missing prototype removal
Functions do not appear to exist:
 extern MagWindow *CmdGetRootBox();
 extern void CmdAddSlop();
 extern void CmdDoMacro();

K&R obsolete syntax removal for C23 compatibility series
2024-12-26 13:13:13 -05:00
Carsten Wulff 772bfe2f71 commands/CmdFI.c: added CmdFlush_NoConfirm option to disable flush prompt 2024-12-26 12:49:33 -05:00
Darryl L. Miles 489de7fdb4 CmdCD.c: 'option' is used uninitialized
CmdCD.c:3693:14: warning: variable 'option' is used uninitialized whenever 'if' condition is false
CmdCD.c:3691:9: warning: variable 'option' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
2024-10-09 21:34:12 -04:00
Darryl L. Miles 9ca8697659 strings.h: add #include required when strict
Due to use of strcasecmp() or similar C API.

Maybe HAVE_STRINGS_H is needed ?  If so which platforms needs this ?

clang18 default warning cleanup (strict)
2024-10-09 21:22:37 -04:00
Darryl L. Miles 6cdb9ad167 36 x warning: suggest parentheses around assignment used as truth value
bpMain.c:265:11: warning: suggest parentheses around assignment used as truth value
CmdSubrs.c:413:12: warning: suggest parentheses around assignment used as truth value
CmdSubrs.c:759:13: warning: suggest parentheses around assignment used as truth value
CmdFI.c:1600:12: warning: suggest parentheses around assignment used as truth value
DBcell.c:109:12: warning: suggest parentheses around assignment used as truth value
DBcellname.c:2512:9: warning: suggest parentheses around assignment used as truth value
DBcellsrch.c:95:12: warning: suggest parentheses around assignment used as truth value
DBio.c:3998:9: warning: suggest parentheses around assignment used as truth value
DBlabel2.c:228:9: warning: suggest parentheses around assignment used as truth value
DBWelement.c:195:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:197:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:295:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:297:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:637:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:639:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:679:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:681:13: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1219:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1368:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1471:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1543:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1676:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1772:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1919:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2099:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2324:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2713:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2830:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2944:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3097:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3144:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3181:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3215:9: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3227:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3261:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3459:17: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 9225fa6cf1 4 x warning: suggest explicit braces to avoid ambiguous 'else'
Give compiler the extra braces it recommends.

DBio.c edited as my original change was caught out by the incorrect
indention of the 'else' keyword and my modification would have caused a
NULL deref.   Exactly the kind of issue this warning is trying to prevent.

CmdTZ.c:417:20: warning: suggest explicit braces to avoid ambiguous 'else'
DBio.c:1422:12: warning: suggest explicit braces to avoid ambiguous 'else'
DBpaint2.c:285:12: warning: suggest explicit braces to avoid ambiguous 'else'
DBpaint2.c:384:12: warning: suggest explicit braces to avoid ambiguous 'else'

GCC14 -Wall cleanup series [-Wdangling-else]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 967b41343b GCC14: warning: missing braces around initializer
GCC14 -Wall cleanup series [-Wmissing-braces]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 4359aa8d4b commands/CmdWizard.c: %x => (intmax_t) %lx
Wrong type of arguments to formatting function

Looks like SPICE comment, change maintains hex without 0x prefix in portable way.

Copilot Autofix rejected: TxPrintf("%p\n", tp);

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/65
2024-10-01 12:36:13 -04:00
Darryl L. Miles f47a173a49 commands/CmdLQ.c: Call to function with fewer arguments than declared parameters
No AI resolution.

The NULL added is cdata which looks to be opaque callback user-defined-pointer,
this is not used in the method printPropertiesFunc() as a possible 3rd argument.

CodeQL: https://github.com/dlmiles/magic/security/code-scanning/157
2024-10-01 12:36:12 -04:00