tcl: port to 9.x using an unofficial patch (wip: clang, ptest fails)

This also requires using -fpermissive for gcc 14.x compatibility,
and dropping some of the existing patches (or their portions) which
are either parts of the 9.x port, or rendered obsolete by it.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
This commit is contained in:
Alexander Kanavin 2025-01-20 13:44:56 +01:00
parent 9dc19afbaa
commit a79a4f5d84
7 changed files with 2245 additions and 618 deletions

View File

@ -19,14 +19,6 @@ diff --git a/exp_chan.c b/exp_chan.c
index 79f486c..50375d3 100644
--- a/exp_chan.c
+++ b/exp_chan.c
@@ -35,6 +35,7 @@
#include "exp_prog.h"
#include "exp_command.h"
#include "exp_log.h"
+#include "exp_event.h" /* exp_background_channelhandler */
#include "tcldbg.h" /* Dbg_StdinMode */
extern int expSetBlockModeProc _ANSI_ARGS_((int fd, int mode));
@@ -631,7 +632,7 @@ expWaitOnOne() {
}
@ -101,13 +93,3 @@ index c605b23..80ed5e7 100644
#include <stdio.h>
#include <signal.h>
@@ -15,6 +16,9 @@ would appreciate credit if you use this file or parts of it.
#endif
#include "expect_cf.h"
+#include "tclInt.h"
+
+extern char * expErrnoMsg _ANSI_ARGS_((int));
/*
The following functions are linked from the Tcl library. They

View File

@ -1,474 +0,0 @@
From d6118fde9c8a7c49f042bc9dc434f56910c23d9c Mon Sep 17 00:00:00 2001
From: Jiaying Song <jiaying.song.cn@windriver.com>
Date: Wed, 25 Dec 2024 13:35:59 +0800
Subject: [PATCH] Replace tclsh with tclsh8 in the scripts used in the Expect
package
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As can be seen from the following, since Expect uses tcl8, it is necessary to
change tclsh to tclsh8 in the related scripts, otherwise they will not execute.
pkgIndex.tcl :
if {![package vsatisfies [package provide Tcl] 8.6]} {return}
package ifneeded Expect 5.45.4 \
[list load [file join /usr/lib64 libexpect5.45.4.so]]
Upstream-Status: Inactive-Upstream
Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
---
example/archie | 2 +-
example/autoexpect | 2 +-
example/autopasswd | 2 +-
example/chess.exp | 2 +-
example/cryptdir | 2 +-
example/decryptdir | 2 +-
example/dislocate | 2 +-
example/dvorak | 2 +-
example/ftp-inband | 2 +-
example/ftp-rfc | 2 +-
example/gethostbyaddr | 2 +-
example/kibitz | 2 +-
example/lpunlock | 2 +-
example/mkpasswd | 2 +-
example/multixterm | 2 +-
example/passmass | 2 +-
example/read1char | 2 +-
example/rftp | 2 +-
example/rlogin-cwd | 2 +-
example/robohunt | 2 +-
example/rogue.exp | 2 +-
example/telnet-cwd | 2 +-
example/timed-read | 2 +-
example/timed-run | 2 +-
example/tknewsbiff | 2 +-
example/tkpasswd | 2 +-
example/tkterm | 2 +-
example/unbuffer | 2 +-
example/virterm | 2 +-
example/weather | 2 +-
example/xkibitz | 2 +-
example/xpstat | 2 +-
32 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/example/archie b/example/archie
index 0d5f43f..0e8d11e 100755
--- a/example/archie
+++ b/example/archie
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/autoexpect b/example/autoexpect
index 35e57ce..e5ea626 100755
--- a/example/autoexpect
+++ b/example/autoexpect
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/autopasswd b/example/autopasswd
index 1d095e2..b87dcd4 100755
--- a/example/autopasswd
+++ b/example/autopasswd
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/chess.exp b/example/chess.exp
index 7cbd8ff..450dd20 100755
--- a/example/chess.exp
+++ b/example/chess.exp
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/cryptdir b/example/cryptdir
index 84a155b..c7bfc02 100755
--- a/example/cryptdir
+++ b/example/cryptdir
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/decryptdir b/example/decryptdir
index 84a155b..c7bfc02 100755
--- a/example/decryptdir
+++ b/example/decryptdir
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/dislocate b/example/dislocate
index 9d34180..b366933 100755
--- a/example/dislocate
+++ b/example/dislocate
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/dvorak b/example/dvorak
index b5debc3..3789938 100755
--- a/example/dvorak
+++ b/example/dvorak
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/ftp-inband b/example/ftp-inband
index 5a28302..d3392f4 100755
--- a/example/ftp-inband
+++ b/example/ftp-inband
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/ftp-rfc b/example/ftp-rfc
index 4153b24..f02b3dc 100755
--- a/example/ftp-rfc
+++ b/example/ftp-rfc
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/gethostbyaddr b/example/gethostbyaddr
index 513a330..803b667 100755
--- a/example/gethostbyaddr
+++ b/example/gethostbyaddr
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/kibitz b/example/kibitz
index eacb139..7c73bf9 100755
--- a/example/kibitz
+++ b/example/kibitz
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/lpunlock b/example/lpunlock
index 2b7ea24..e42224b 100755
--- a/example/lpunlock
+++ b/example/lpunlock
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/mkpasswd b/example/mkpasswd
index 6016b56..c3e97f4 100755
--- a/example/mkpasswd
+++ b/example/mkpasswd
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/multixterm b/example/multixterm
index d0abfe7..82d6651 100755
--- a/example/multixterm
+++ b/example/multixterm
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/passmass b/example/passmass
index e3c18e6..8f396d3 100755
--- a/example/passmass
+++ b/example/passmass
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/read1char b/example/read1char
index 43a3df8..5f947fd 100644
--- a/example/read1char
+++ b/example/read1char
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/rftp b/example/rftp
index c5db679..ebbf4c5 100755
--- a/example/rftp
+++ b/example/rftp
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/rlogin-cwd b/example/rlogin-cwd
index b217373..80863e7 100755
--- a/example/rlogin-cwd
+++ b/example/rlogin-cwd
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/robohunt b/example/robohunt
index 853ce1e..0d70c87 100755
--- a/example/robohunt
+++ b/example/robohunt
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/rogue.exp b/example/rogue.exp
index 083acdf..fb6f9ca 100755
--- a/example/rogue.exp
+++ b/example/rogue.exp
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/telnet-cwd b/example/telnet-cwd
index bd16048..fa520f1 100755
--- a/example/telnet-cwd
+++ b/example/telnet-cwd
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/timed-read b/example/timed-read
index 8e63f0f..0a4ee7d 100755
--- a/example/timed-read
+++ b/example/timed-read
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/timed-run b/example/timed-run
index 80def48..a0a36ba 100755
--- a/example/timed-run
+++ b/example/timed-run
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/tknewsbiff b/example/tknewsbiff
index 9a2da4b..8d9db19 100755
--- a/example/tknewsbiff
+++ b/example/tknewsbiff
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
package require Tk
diff --git a/example/tkpasswd b/example/tkpasswd
index 376c56a..cc4d816 100755
--- a/example/tkpasswd
+++ b/example/tkpasswd
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
package require Tk
diff --git a/example/tkterm b/example/tkterm
index 16ee972..6c85c63 100755
--- a/example/tkterm
+++ b/example/tkterm
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
package require Tk
diff --git a/example/unbuffer b/example/unbuffer
index ad5db7b..f6e42fd 100755
--- a/example/unbuffer
+++ b/example/unbuffer
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/virterm b/example/virterm
index bab254b..911c5bc 100755
--- a/example/virterm
+++ b/example/virterm
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/weather b/example/weather
index 4bd0e1b..8146359 100755
--- a/example/weather
+++ b/example/weather
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/xkibitz b/example/xkibitz
index b61a22f..5718976 100755
--- a/example/xkibitz
+++ b/example/xkibitz
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
diff --git a/example/xpstat b/example/xpstat
index ebbfbcf..067d57e 100755
--- a/example/xpstat
+++ b/example/xpstat
@@ -1,7 +1,7 @@
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
-exec tclsh "$0" ${1+"$@"}
+exec tclsh8 "$0" ${1+"$@"}
package require Expect
--
2.25.1

View File

@ -1,91 +0,0 @@
From f0049b4b2ea55b3b3c53bf6f0275654801c755d2 Mon Sep 17 00:00:00 2001
From: Li Zhou <li.zhou@windriver.com>
Date: Thu, 28 Sep 2017 15:54:55 +0800
Subject: [PATCH] expect: Fix segfaults if Tcl is built with stubs and Expect
is used directly from C program
Description: This dirty hack fixes segfaults if Tcl is built with stubs
and Expect is used directly from C program.
Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=588817
Example:
#include <stdio.h>
#include <tcl8.5/expect.h>
int main()
{
FILE *pipe;
char *some_command = "uname";
char datum;
pipe = exp_popen(some_command);
if (pipe == NULL) return 1;
while ((datum = getc (pipe)) != EOF)
printf("%c",datum);
}
Example:
#include <stdio.h>
#include "expect.h"
main()
{
int fd = 0;
fd = exp_spawnl("echo", "echo", "Hello User: Whats up?", (char*) 0);
switch (exp_expectl(fd, exp_regexp, "ser:", 1, exp_end)) {
case 1: {
printf("GOT ser:\n");
break;
}
default: {
printf("DEFAULT\n");
return 1;
}
}
printf("Normal Exit\n");
return 0;
}
Author: Sergei Golovan <sgolovan@debian.org>
Upstream-Status: Inactive-Upstream [no activity since 2018; cvs server went read-only]
This patch is backported from fedora changes for expect:
http://pkgs.fedoraproject.org/cgit/rpms/expect.git/commit/
?h=master&id=b6737eed550be93182f2ed194e836a6cbbcf4fa3
Signed-off-by: Li Zhou <li.zhou@windriver.com>
---
exp_clib.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/exp_clib.c b/exp_clib.c
index 172c05e..19341d5 100644
--- a/exp_clib.c
+++ b/exp_clib.c
@@ -114,7 +114,11 @@ extern unsigned long strtoul _ANSI_ARGS_((CONST char *string,
#include <stdlib.h> /* for malloc */
#endif
-#include <tcl.h>
+#define ckalloc(x) Tcl_Alloc(x)
+#define ckfree(x) Tcl_Free(x)
+extern char *Tcl_ErrnoMsg(int err);
+extern char *Tcl_Alloc(unsigned int size);
+extern void Tcl_Free(char *ptr);
#include "expect.h"
#define TclRegError exp_TclRegError
@@ -389,7 +393,7 @@ char *exp;
FAIL("regexp too big");
/* Allocate space. */
- r = (regexp *)ckalloc(sizeof(regexp) + (unsigned)rcstate->regsize);
+ r = (regexp *)malloc(sizeof(regexp) + (unsigned)rcstate->regsize);
if (r == NULL)
FAIL("out of space");
@@ -399,7 +403,7 @@ char *exp;
rcstate->regcode = r->program;
regc(MAGIC, rcstate);
if (reg(0, &flags, rcstate) == NULL) {
- ckfree ((char*) r);
+ free((char*) r);
return(NULL);
}
--
1.9.1

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
#!/bin/sh
out_put=`tclsh8 tests/all.tcl -verbose bpse`
out_put=`tclsh tests/all.tcl -verbose bpse`
echo
echo "${out_put}" | awk '/PASSED|FAILED|SKIPPED/{gsub(/PASSED/,"PASS"); gsub(/FAILED/,"FAIL"); gsub(/SKIPPED/,"SKIP"); if ($NF=="PASS"){print $NF": "$(NF-1)}else{print $NF": "$2}}' | uniq

View File

@ -1,27 +0,0 @@
Adjustments for compatibility with the currrent (Tcl 8.4.0+) channel
implementation.
Upstream-Status: Submitted [https://sourceforge.net/p/expect/patches/24/]
Signed-off-by: Ross Burton <ross.burton@arm.com>
diff --git a/exp_chan.c b/exp_chan.c
index c92e26b6fbd02305..944200a63b102672 100644
--- a/exp_chan.c
+++ b/exp_chan.c
@@ -60,7 +60,7 @@ void exp_background_channelhandler _ANSI_ARGS_((ClientData,
Tcl_ChannelType expChannelType = {
"exp", /* Type name. */
- ExpBlockModeProc, /* Set blocking/nonblocking mode.*/
+ TCL_CHANNEL_VERSION_2,
ExpCloseProc, /* Close proc. */
ExpInputProc, /* Input proc. */
ExpOutputProc, /* Output proc. */
@@ -70,6 +70,7 @@ Tcl_ChannelType expChannelType = {
ExpWatchProc, /* Initialize notifier. */
ExpGetHandleProc, /* Get OS handles out of channel. */
NULL, /* Close2 proc */
+ ExpBlockModeProc, /* Set blocking/nonblocking mode.*/
};
typedef struct ThreadSpecificData {

View File

@ -13,8 +13,8 @@ SECTION = "devel"
LIC_FILES_CHKSUM = "file://license.terms;md5=fbf2de7e9102505b1439db06fc36ce5c"
DEPENDS += "tcl8"
RDEPENDS:${PN} = "tcl8"
DEPENDS += "tcl"
RDEPENDS:${PN} = "tcl"
inherit autotools update-alternatives ptest
@ -23,14 +23,12 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/expect/Expect/${PV}/${BPN}${PV}.tar.gz \
file://0002-tcl.m4.patch \
file://0001-expect-install-scripts-without-using-the-fixline1-tc.patch \
file://0001-Resolve-string-formatting-issues.patch \
file://0001-expect-Fix-segfaults-if-Tcl-is-built-with-stubs-and-.patch \
file://0001-exp_main_sub.c-Use-PATH_MAX-for-path.patch \
file://0001-fixline1-fix-line-1.patch \
file://0001-Add-prototype-to-function-definitions.patch \
file://expect-configure-c99.patch \
file://tcl840.patch \
file://run-ptest \
file://0001-Replace-tclsh-with-tclsh8-in-the-scripts-used-in-the.patch \
file://0001-expect-port-to-tcl-9.x.patch \
"
SRC_URI[sha256sum] = "49a7da83b0bdd9f46d04a04deec19c7767bb9a323e40c4781f89caf760b92c34"
@ -40,6 +38,7 @@ UPSTREAM_CHECK_REGEX = "/Expect/(?P<pver>(\d+[\.\-_]*)+)/"
S = "${WORKDIR}/${BPN}${PV}"
EXTRA_AUTORECONF += "--exclude=aclocal"
CFLAGS += "-fpermissive"
CFLAGS += "-std=gnu17"
@ -54,9 +53,9 @@ do_install_ptest() {
cp -r ${S}/tests ${D}${PTEST_PATH}
}
# Apparently the public Tcl headers are only in /usr/include/tcl8.6
# Apparently the public Tcl headers are only in /usr/include/tcl9.0
# when building for the target and nativesdk.
TCL_INCLUDE_PATH = "--with-tclinclude=${STAGING_INCDIR}/tcl8.6"
TCL_INCLUDE_PATH = "--with-tclinclude=${STAGING_INCDIR}/tcl9.0"
TCL_INCLUDE_PATH:class-native = ""
EXTRA_OECONF += "--with-tcl=${STAGING_LIBDIR} \