FUN2CD() on a function pointer still raises -Wpedantic warning due to the
officially undefined behaviour as defined by C standards.
So added FUN2CD() and CD2FUN() to at least mark the call-sites to help
with identification and ignoring -Wpedantic based on the source file
context given in the compiler output.
Use of (void*) with pointer arithmetic warning removal.
But more so as it is in a macro (all be it local to file) which will
take on the form of the type passed as argument when the 'offset' looks
to be always be specified in bytes.
cb_heap_kill_t callback typedef created
Invoked from HeapKill()
No active callback implementation in the codebase.
callback interface (from hash.h):
marked @invoke call-site
This did not work as expected. Maybe that indicate this should have
a slighlt restructure so the tcl.h definition is always given a chance
to provide type.
Or maybe autoconf should detect the type and provide in config.h ?
This seems like it has 2 use cases.
Internal console management around reprinting command prompt, but many
modes of operation delegate the prompt processing to tkcon or readline.
Process termination to restore the termios.
The Tcl_Exit() replacement proc takes charge of calling exit()
So this function can be easily migrated to libc atexit() which will
now run during exit() not just before. Which seems ok for the purpose
of restoring the termios state of the tty.
This solution seems compatible with TCL8 as well so all calls to this
removed API are removed.
Note this patch also removes the invalidation (of the callback so
the deefault use of Tcl_Exit() is restored) before returning from
this function. atexit() usage can not be invalidated after
registration but that can be controlled with application flag
checked inside the callback function if needed.
I have observed scenarios where I need to issue 'reset' manually
after exiting magic, still understanding better the build types
and scenarios that triggers this.
Now a (void *) but previously an integer.
These macros resolve the codebase allowing it to be built against both
tcl8 (8.5, 8.6) and tcl9 (9.0).
tar -zxvf tcl9.0.0-src.tar.gz
cd tcl9.0.0/unix
./configure --enable-symbols --prefix=/opt/tktcl9
make install
tar -zxvf tk9.0.0-src.tar.gz
cd tk9.0.0/unix
./configure --enable-symbols --prefix=/opt/tktcl9 --with-tcl=/opt/tktcl9/lib
make install
cd magic
./configure --with-tk=/opt/tktcl9/lib --with-tcl=/opt/tktcl9/lib
Dereference of 'h' after calling freeMagic(h)
Found while putting in cast.
Initially this is what was thought however....
freeMagic() has this one allocation to free latency, which is a matter
to resolve another day.
When constifying there is this inconsistent quirk in this API returning
'filename' or a malloced storage. When special handling needs to be
made by the caller to detect this to decide if it needs a free.
This appears to done to save a strdup().
Make it always return a malloc block so the API contract is
strightforward to the caller. A non-NULL return requires
free() by the caller.
Example build issue using MacOS 12 (Xcode 14.2 from MacOSX.platform).
In file included from grTk1.c:23:
In file included from ../utils/main.h:26:
In file included from ../windows/windows.h:26:
../utils/magic.h:143:13: warning: 'FREAD' macro redefined [-Wmacro-redefined]
#define FREAD(a,b,c,d) gzread(d,a,b*c)
^
/Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/fcntl.h:110:9: note: previous definition is here
#define FREAD 0x00000001