Skip to content

Commit

Permalink
Merge branch 'master' into kermit-95
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrg committed Aug 19, 2024
2 parents 7251f2d + b6bf336 commit 7c1289a
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ jobs:
set CKF_SSH_DLL_VARIANT=g
call mksshdll.bat
ren k95ssh.dll k95sshg.dll
ren k95ssh.pdb k95sshg.pdb
del k95ssh.res
if "%CKB_XP_COMPATIBLE%" NEQ "yes" goto :noxp
Expand All @@ -530,13 +531,15 @@ jobs:
set CKF_SSH_DLL_VARIANT=x
call mksshdll.bat
ren k95ssh.dll k95sshx.dll
ren k95ssh.pdb k95sshx.pdb
del k95ssh.res
REM XP, GSSAPI-enabled
set SSH_LIB=sshgx.lib
set CKF_SSH_DLL_VARIANT=gx
call mksshdll.bat
ren k95ssh.dll k95sshgx.dll
ren k95ssh.pdb k95sshgx.pdb
del k95ssh.res
:noxp
Expand Down
4 changes: 3 additions & 1 deletion doc/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Nothing yet
None yet

### Fixed bugs
None yet
* Fix `fopen` causing a crash. This issue seems to have come in some recent
version of the Microsoft C Runtime.
* Fix hitting backspace in an empty search-in-buffer crashing

### Other Source Changes
None yet
Expand Down
12 changes: 9 additions & 3 deletions kermit/k95/ckoco3.c
Original file line number Diff line number Diff line change
Expand Up @@ -7742,6 +7742,8 @@ gotojump( int vmode )
return;
}

#define SEARCHSTRING_LEN 63

BOOL
search( BYTE vmode, BOOL forward, BOOL prompt )
{
Expand All @@ -7750,7 +7752,7 @@ search( BYTE vmode, BOOL forward, BOOL prompt )
#else
extern int inpcas[] ;
#endif /* DCMDBUF */
static char searchstring[63] = "" ;
static char searchstring[SEARCHSTRING_LEN] = "" ;
CHAR x1;
con_event evt ;
int line = 1 ;
Expand Down Expand Up @@ -7807,7 +7809,7 @@ search( BYTE vmode, BOOL forward, BOOL prompt )
}
else if ( x1 >= ' ' && x1 <= 126 || x1 >= 128 /*always true: && x1 <= 255*/ )
{
if ( len >= 62 ) {
if ( len >= SEARCHSTRING_LEN - 1 ) {
bleep(BP_WARN);
}
else {
Expand All @@ -7817,7 +7819,11 @@ search( BYTE vmode, BOOL forward, BOOL prompt )
}
else if ( x1 == 8 || x1 == 127 )
{
searchstring[len-1] = '\0' ;
if (len - 1 < 0) {
bleep(BP_WARN);
} else {
searchstring[len-1] = '\0' ;
}
}
else if ( x1 == 13 )
{
Expand Down
76 changes: 55 additions & 21 deletions kermit/k95/ckoker.mak
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ COMMON_CFLAGS = /MD
!if "$(CKF_DEV_CHECKS)" == "yes"
# Enable extra runtime checks. These only work with a debug build and
# Visual C++ 2002 and newer
COMMON_CFLAGS = /RTCsu
COMMON_CFLAGS = $(COMMON_CFLAGS) /RTCsu
!else
COMMON_OPTS = /Ox
!endif
Expand Down Expand Up @@ -187,11 +187,11 @@ CKB_STATIC_CRT = yes
# Standard windows headers from MinGW that don't come with OpenWatcom:
INCLUDE = $(INCLUDE);ow\;

!endif
!endif # EndIf CMP == OWCL

!if ($(MSC_VER) < 80)
!error Unsupported compiler version. Visual C++ 1.0 32-bit edition or newer required.
!endif
!endif # EndIf MSC_VER < 80

# TODO: Much of this compiler flag work should be applied to the KUI Makefile
# too
Expand All @@ -200,18 +200,18 @@ INCLUDE = $(INCLUDE);ow\;
# then tell the linker we're targeting x86-64
!if "$(TARGET_CPU)" == "x86-64"
LDFLAGS = $(LDFLAGS) /MACHINE:X64
!endif
!endif # EndIf TARGET_CPU == x86-64

!if "$(TARGET_CPU)" == "AXP64"
# This compiler is capable of targeting AXP64, so add the build flag to do that.
COMMON_CFLAGS = $(COMMON_CFLAGS) /Ap64
LINKFLAGS = $(LINKFLAGS) /MACHINE:ALPHA64
!endif
!endif # EndIf TARGET_CPU == AXP64

!if ("$(DEBUG)" != "-DNDEBUG") && ($(MSC_VER) <= 130)
# This debug flag is only valid on Visual C++ 6.0 and older.
LINKFLAGS = $(LINKFLAGS) /debugtype:both
!endif
!endif # EndIf DEBUG != -DNDEBUG and MSC_VER <= 130

!if ($(MSC_VER) >= 170) && ($(MSC_VER) <= 192)
# Starting with Visual C++ 2012, the default subsystem version is set to 6.0
Expand All @@ -221,23 +221,57 @@ LINKFLAGS = $(LINKFLAGS) /debugtype:both
# version to 5.1 so the generated binaries are compatible.
SUBSYSTEM_CONSOLE=console,5.1
SUBSYSTEM_WIN32=windows,5.1
!endif
!endif # EndIf MSC_VER >= 170 and MSC_VER <= 192

!if ($(MSC_VER) == 80) && ("$(MSC_VER)" == "AXP")
!if ($(MSC_VER) == 80) && ("$(TARGET_CPU)" == "AXP")
# The linker included with the NT 3.50 SDK for Alpha can't handle
# K95 (complains "LINK : error LNK1155: Special symbol 'end' already defined.")
# So to support using a newer linker that has less problems, we'll set
# the subsystem version so the result still works on NT 3.1/3.50
SUBSYSTEM_CONSOLE=console,3.1
SUBSYSTEM_WIN32=windows,3.1
!endif
!endif # EndIf MSC_VER == 80 and TARGET_CPU == AXP

!if ($(MSC_VER) > 90)
!if "$(TARGET_CPU)" != "MIPS"
# This flag isn't valid on Visual C++ 4.0 MIPS (or, I assume, any other version)
COMMON_OPTS = $(COMMON_OPTS) /GA
!endif
!endif
!endif # EndIf TARGET_CPU != MIPS
!endif # EndIf MSC_VER > 90

# PDB Generation Stuff

!if ($(MSC_VER) < 180) && ("$(ISJOM)" == "yes") && ("$(CKB_MAKE_PDB)" != "yes")
!message Make is JOM and compiler is older than Visual C++ 2013. Can't reliably
!message synchronise writes to a PDB file with this compiler. Disabling PDB
!message generation. override with: set CKB_MAKE_PDB=yes but you may get build
!message errors.
CKB_MAKE_PDB=no
!endif # EndIf MSC_VER < 180 and ISJOM == yes and CKB_MAKE_PDB != yes

!if "$(CKB_MAKE_PDB)" != "no"
# Lets see if we can make a PDB file! This requires Visual C++ 4.0 or newer.
!if ($(MSC_VER) > 90)
!message Enabling PDB generation

COMMON_CFLAGS = $(COMMON_CFLAGS) /Zi
LDDEBUG = $(LDDEBUG) /DEBUG /INCREMENTAL:NO /OPT:REF

# /OPT:ICF is new in Visual C++ 5.0
!if ($(MSC_VER) >= 110)
LDDEBUG = $(LDDEBUG) /OPT:ICF
!endif # EndIf MSC_VER >= 110

# /FS is required to synchronise writes to a PDB when doing parallel builds with
# something like JOM. It was introduced in Visual C++ 2013.
!if ($(MSC_VER) >= 180)
COMMON_CFLAGS = $(COMMON_CFLAGS) /FS
!endif # EndIf MSC_VER >= 180

!endif # EndIf MSC_VER > 90
!endif # EndIf CKB_MAKE_PDB != no

# End PDB Generation Stuff

!if ($(MSC_VER) < 140)
# These flags and options are deprecated or unsupported
Expand All @@ -246,13 +280,13 @@ COMMON_OPTS = $(COMMON_OPTS) /GA
# /GX- is new in Visual C++ 2.0
!if ($(MSC_VER) > 80)
COMMON_CFLAGS = $(COMMON_CFLAGS) /GX-
!endif
!endif # EndIf MSC_VER > 80

!if ($(MSC_VER) < 100)
# Visual C++ 2.0 and 1.0 32-bit edition don't support these flags, so don't
# use them.
CFLAG_GF=
!endif
!endif # EndIf MSC_VER < 100

COMMON_CFLAGS = $(COMMON_CFLAGS) /Ze
# These are: /Ze Enable extensions (default)
Expand All @@ -263,19 +297,19 @@ COMMON_CFLAGS = $(COMMON_CFLAGS) /Ze
# So only generate PCH files when nmake instead of jom.
!if "$(ISJOM)" == "no"
COMMON_CFLAGS = $(COMMON_CFLAGS) /YX
!endif
!endif # EndIf ISJOM == no

!if "$(TARGET_CPU)" == "x86"
# Optimise for Pentium
COMMON_OPTS = $(COMMON_OPTS) /G5
!endif
!endif # EndIf TARGET_CPU == x86

!else
!else # Else MSC_VER < 140
COMMON_CFLAGS = $(COMMON_CFLAGS) /EHs-c-
# These are: /EHs-c- Enable C++ Exception handling (replaces /GX-)
!endif
!endif # EndIf MSC_VER < 140

!endif
!endif # EndIf PLATFORM == NT

RCDEFINES=$(RC_FEATURE_DEFS) /dCOMPILER_$(CMP)
!if "$(SSH_LIB)" == ""
Expand Down Expand Up @@ -386,7 +420,7 @@ msvc:
LDFLAGS="" \
PLATFORM="NT" \
NOLINK="/c" \
LINKFLAGS="/nologo /SUBSYSTEM:$(SUBSYSTEM_CONSOLE) /MAP /OPT:REF" DEF="cknker.def"
LINKFLAGS="/nologo /SUBSYSTEM:$(SUBSYSTEM_CONSOLE) /MAP /OPT:REF $(LDDEBUG)" DEF="cknker.def"

!if "$(CKF_DYNAMIC_SSH)" == "yes"
msvc-sshdll:
Expand Down Expand Up @@ -540,7 +574,7 @@ k95gd:
LDFLAGS="" \
PLATFORM="NT" \
NOLINK="-c" \
LINKFLAGS="/nologo /MAP /DEBUG:full /SUBSYSTEM:$(SUBSYSTEM_WIN32)" \
LINKFLAGS="/nologo /MAP /DEBUG /SUBSYSTEM:$(SUBSYSTEM_WIN32)" \
DEF="cknker.def"

k95g:
Expand All @@ -555,7 +589,7 @@ k95g:
LDFLAGS="" \
PLATFORM="NT" \
NOLINK="-c" \
LINKFLAGS="/nologo /SUBSYSTEM:$(SUBSYSTEM_WIN32)" \
LINKFLAGS="/nologo /SUBSYSTEM:$(SUBSYSTEM_WIN32) $(LDDEBUG)" \
DEF="cknker.def"

################### OS/2 TARGETS ###################
Expand Down
16 changes: 9 additions & 7 deletions kermit/k95/ckuus4.c
Original file line number Diff line number Diff line change
Expand Up @@ -14205,23 +14205,25 @@ char * /* Evaluate builtin variable */
p++;
}
p = vvbuf;

#ifndef VMS
if (p > vvbuf) { /* Directory termination character */
c =
c =
#ifdef MAC
':'
':'
#else
#ifdef datageneral
':'
':'
#else
#ifdef STRATUS
'>'
'>'
#else
'/'
'/'
#endif /* STRATUS */
#endif /* datageneral */
#endif /* MAC */
;
;

if (p > vvbuf) { /* Directory termination character */
if (*(p-1) != c) { /* Add it to the end of the */
*p++ = c; /* string if it was not already */
*p = NUL; /* there */
Expand Down
16 changes: 16 additions & 0 deletions kermit/k95/ckuus7.c
Original file line number Diff line number Diff line change
Expand Up @@ -11890,6 +11890,12 @@ z_open(name, flags) char * name; int flags;
if (!mode[0]) /* Check for illegal combinations */
return(z_error = FX_BOM);
}

#ifdef NT
ckstrncat(mode,"S",8); /* S is also known as _O_SEQUENTIAL */
debug(F110, "z_open fopen", mode, 0);
#endif /* NT */

if (!z_inited) { /* If file structs not inited */
debug(F101,"z_open z_maxchan 1","",z_maxchan);
#ifdef UNIX
Expand Down Expand Up @@ -12010,12 +12016,22 @@ z_open(name, flags) char * name; int flags;
z_file[n] = NULL;
return(z_error = (errno ? FX_SYS : FX_UNK)); /* Return error code */
}
#ifdef COMMENT
/*
* 2024-08-19 DavidG: This started crashing on Windows 11 in CKW Beta 6. The
* call to setmode seems ok, it just doesn't like O_SEQUENTIAL anymore. Not
* sure if this is something unsupported now, or if its a bug in the CRT.
* For some reason I've not looked into too closely I'm not even getting
* O_SEQUENTIAL defined on my local PC, while its clearly there on the
* Gitub build agents.
*/
#ifdef NT
#ifdef O_SEQUENTIAL
if (t) /* Caching hint for NT */
_setmode(_fileno(t),O_SEQUENTIAL);
#endif /* O_SEQUENTIAL */
#endif /* NT */
#endif /* COMMENT */

z_nopen++; /* Open, count it. */
z_file[n]->z_fp = t; /* Stash the file pointer */
Expand Down
28 changes: 28 additions & 0 deletions kermit/k95/kui/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,34 @@ COMMON_CFLAGS = /D_MT /QmipsOb5000
CKB_STATIC_CRT = yes
!endif

# PDB Generation Stuff

!if ($(MSC_VER) < 180) && ("$(ISJOM)" == "yes") && ("$(CKB_MAKE_PDB)" != "yes")
!message Make is JOM and compiler is older than Visual C++ 2013. Can't reliably
!message synchronise writes to a PDB file with this compiler. Disabling PDB
!message generation. override with: set CKB_MAKE_PDB=yes but you may get build
!message errors.
CKB_MAKE_PDB=no
!endif # EndIf MSC_VER < 180 and ISJOM == yes and CKB_MAKE_PDB != yes

!if "$(CKB_MAKE_PDB)" != "no"
# Lets see if we can make a PDB file! This requires Visual C++ 4.0 or newer.
!if ($(MSC_VER) > 90)
!message Enabling PDB generation

COMMON_CFLAGS = $(COMMON_CFLAGS) /Zi

# /FS is required to synchronise writes to a PDB when doing parallel builds with
# something like JOM. It was introduced in Visual C++ 2013.
!if ($(MSC_VER) >= 180)
COMMON_CFLAGS = $(COMMON_CFLAGS) /FS
!endif # EndIf MSC_VER >= 180

!endif # EndIf MSC_VER > 90
!endif # EndIf CKB_MAKE_PDB != no

# End PDB Generation Stuff

all: $(OUTDIR)\$(PROJ).exe

KUIOBJS = \
Expand Down
3 changes: 3 additions & 0 deletions kermit/k95/mkdist.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ if not exist dist\users\NUL mkdir dist\users

@echo Move build outputs...
move *.exe dist
move *.pdb dist
if exist dist\nullssh.pdb delete dist\nullssh.pdb
move k95ssh*.dll dist
if exist k95crypt.dll move k95crypt.dll dist
copy *.manifest dist
copy iksd.ksc dist\iksd.ksc.sample
ren dist\cknker.exe k95.exe
ren dist\cknker.pdb k95.pdb
ren dist\cknker.exe.manifest k95.exe.manifest
del dist\cknker.exe.manifest
REM del dist\ctl3dins.exe -- this can trip up virus scanners but its required by the dialer
Expand Down

0 comments on commit 7c1289a

Please sign in to comment.