[tin-bugs] (fwd) Cross-compilation of tin
Thomas Dickey
dickey at his.com
Sun Feb 5 11:58:28 CET 2023
On Sun, Feb 05, 2023 at 06:03:19AM +0100, Urs Janßen wrote:
> Hello Thomas,
>
> would you mind to answer the following mail as it is mainly your code
> and macro. IIRC free(NULL) was an issue > ~25 years ago on several
> operating systems as it caused crashes (but I can't remeber which ones).
I encountered this with SunOS 4 (and probably HP-UX) in getting the sam editor
to work (perhaps 1993).
fwiw, SunOS 4 was in use for development after 2000 :-)
> And at least it should include "bool.h" not <bool.h> and
The <bool.h> should work, assuming that the compiler's -I options are
set up properly (to point to tin's include-directory).
> <stdlib.h> and <string.h> not unconditionally.
agree - those should be ifdef'd. For anything produced over the
past 20 or so years, only unistd.h has been a problem, but
recalling the xpg3 fixups that I did a couple of years ago,
the conditional inclusion still applies.
> Thanks,
> urs
> Date: Thu, 2 Feb 2023 22:36:59 +0300
> From: uis <uis9936 at gmail.com>
> To: tin-bugs at tin.org
> Subject: [tin-bugs] Cross-compilation of tin
>
> While trying to cross-compile tin using crossdev on Gentoo, it failed to do
> because makecfg.c includes tin.h which includes gsasl.h. Usually it is not
> unexpected to do so, given the fact that sasl USE-flag was set, but it was
> compiling tool for CBUILD. So gsasl was required on build system, which is
> very wierd.
...well, a fix for that might be helpful.
> Insted of simply installing tin into build system, I looked at source and
> found that only thing needed from tin.h is FreeIfNeeded macro. And this
> macro is free with condition of pointer being non-null. This macro doesn't
> have different bahaviour compared to simple free(), if you look man 3 free,
sure - tin builds/works with old systems that some people don't care about.
> it says "If ptr is NULL, no operation is performed".
reading the manual page may help (see the section on conformance).
> I changed includes and code and now it should work. Patch attached
the suggested patch isn't relevant to the reported bug.
> --- src/makecfg.c 2021-12-22 16:24:50.000000000 +0300
> +++ src/makecfg.c 2023-02-02 22:34:15.804665881 +0300
> @@ -38,11 +38,11 @@
> */
>
>
> -#define __BUILD__
> -#define PROTO_H 1 /* don't include proto.h */
> -#ifndef TIN_H
> -# include "tin.h"
> -#endif /* !TIN_H */
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <bool.h>
> +#include <ctype.h>
>
> #define L_CURL '{'
> #define R_CURL '}'
> @@ -542,8 +542,8 @@
> m = all_data;
> while (m) {
> n = m->link;
> - FreeIfNeeded(m->name);
> - FreeIfNeeded(m->type);
> + free(m->name);
> + free(m->type);
> free(m);
> m = n;
> }
> _______________________________________________
> tin-bugs mailing list
> tin-bugs at tin.org
> http://lists.tin.org/cgi-bin/mailman/listinfo/tin-bugs
--
Thomas E. Dickey <dickey at invisible-island.net>
https://invisible-island.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <http://lists.tin.org/pipermail/tin-bugs/attachments/20230205/2c63dee0/attachment.sig>
More information about the tin-bugs
mailing list