Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compilable with Tcl 9.0.0 #57

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions tclreadline.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@
# include <readline/history.h>
#endif

/* Check, if Tcl version supports Tcl_Size,
* which was introduced in Tcl 8.7 and 9.
*/
#ifndef TCL_SIZE_MAX
#include <limits.h>
#define TCL_SIZE_MAX INT_MAX

#ifndef Tcl_Size
typedef int Tcl_Size;
#endif

#define TCL_SIZE_MODIFIER ""
#define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj
#endif

/* TCL 9 does not define CONST anymore */
#ifndef CONST
#define CONST const
#endif

#ifdef EXTEND_LINE_BUFFER
/*
Expand Down Expand Up @@ -595,9 +614,15 @@ int
Tclreadline_Init(Tcl_Interp *interp)
{
int status;
#ifdef USE_TCL_STUBS
Tcl_InitStubs(interp, "8.6", 0);
/* Require 8.6 or later (9.0 also ok) */
#ifdef USE_TCL_STUBS
if ( NULL == Tcl_InitStubs(interp, "8.6-", 0))
#else
if (NULL == Tcl_PkgRequire(interp, "Tcl", "8.6-", 0))
#endif
{
return TCL_ERROR;
}
Tcl_CreateObjCommand(interp, "::tclreadline::readline", TclReadlineCmd,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
tclrl_interp = interp;
Expand Down Expand Up @@ -733,7 +758,7 @@ TclReadlineCompletion(char* text, int start, int end)
char start_s[BUFSIZ], end_s[BUFSIZ];
Tcl_Obj* obj;
Tcl_Obj** objv;
int objc;
Tcl_Size objc;
int state;
char* quoted_text = TclReadlineQuote(text, "$[]{}\"");
char* quoted_rl_line_buffer = TclReadlineQuote(rl_line_buffer, "$[]{}\"");
Expand All @@ -760,7 +785,8 @@ TclReadlineCompletion(char* text, int start, int end)
return matches;

if (objc) {
int i, length;
int i;
Tcl_Size length;
matches = (char**) MALLOC(sizeof(char*) * (objc + 1));
for (i = 0; i < objc; i++) {
matches[i] = strdup(Tcl_GetStringFromObj(objv[i], &length));
Expand Down
Loading