1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

Fix incompatibilites between the Desktop Korn Shell and the musl C library:

- Only check for POSIX's termios.h when deciding to use the POSIX terminal interfaces.
- Check for C99's va_copy in addition to __va_copy.
This commit is contained in:
Lev Kujawski 2021-01-06 12:24:44 -07:00 committed by Jon Trulson
parent 007b6fa023
commit e54ee036ac
5 changed files with 42 additions and 21 deletions

View file

@ -42,7 +42,6 @@ do : This could be done with eval, but eval broken in some shells
KIA) j=$KIA;; KIA) j=$KIA;;
MULTIBYTE) j=$MULTIBYTE;; MULTIBYTE) j=$MULTIBYTE;;
OLDTERMIO) echo "#include <sys/termios.h>" > /tmp/dummy$$.c OLDTERMIO) echo "#include <sys/termios.h>" > /tmp/dummy$$.c
echo "#include <sys/termio.h>" >>/tmp/dummy$$.c
if ${CC-cc} -E /tmp/dummy$$.c > /dev/null 2>&1 if ${CC-cc} -E /tmp/dummy$$.c > /dev/null 2>&1
then j=$OLDTERMIO then j=$OLDTERMIO
fi fi

View file

@ -96,6 +96,12 @@ static const char id_hash[] = "\n@(#)hash (AT&T Bell Laboratories) 05/09/95\0\n"
#include "hashlib.h" #include "hashlib.h"
#if defined(va_copy)
#define __VA_COPY__(d,s) va_copy(d,s)
#else
#define __VA_COPY__(d,s) __va_copy(d,s)
#endif
#if _DLL_INDIRECT_DATA && !_DLL #if _DLL_INDIRECT_DATA && !_DLL
static Hash_info_t hash_info_data; static Hash_info_t hash_info_data;
Hash_info_t hash_info = &hash_info_data; Hash_info_t hash_info = &hash_info_data;
@ -222,10 +228,10 @@ hashalloc __PARAM__((Hash_table_t* ref, ...), (va_alist)) __OTORP__(va_dcl)
#else #else
if (vp < &va[elementsof(va)]) if (vp < &va[elementsof(va)])
{ {
__va_copy( *vp, ap ); __VA_COPY__( *vp, ap );
vp++; vp++;
} }
__va_copy(ap, va_listval(va_arg(ap, va_listarg))); __VA_COPY__(ap, va_listval(va_arg(ap, va_listarg)));
#endif #endif
break; break;
case 0: case 0:
@ -235,7 +241,7 @@ hashalloc __PARAM__((Hash_table_t* ref, ...), (va_alist)) __OTORP__(va_dcl)
ap = *--vp; ap = *--vp;
#else #else
vp--; vp--;
__va_copy( ap, *vp ); __VA_COPY__( ap, *vp );
#endif #endif
break; break;
} }

View file

@ -56,6 +56,12 @@
#define HIGHBIT (~(((ulong)~0L) >> 1)) #define HIGHBIT (~(((ulong)~0L) >> 1))
#endif #endif
#if defined(va_copy)
#define __VA_COPY__(d,s) va_copy(d,s)
#elif defined(__va_copy)
#define __VA_COPY__(d,s) __va_copy(d,s)
#endif
#define F_LEFT 000001 /* left justification (-) */ #define F_LEFT 000001 /* left justification (-) */
#define F_SIGN 000002 /* must set a sign - or + */ #define F_SIGN 000002 /* must set a sign - or + */
#define F_BLANK 000004 /* if not - and +, then prepend a blank */ #define F_BLANK 000004 /* if not - and +, then prepend a blank */
@ -92,10 +98,10 @@
} }
#define GETARGL(elt,arge,argf,args,etype,type,fmt,t_user,n_user) \ #define GETARGL(elt,arge,argf,args,etype,type,fmt,t_user,n_user) \
{ if(!argf) \ { if(!argf) \
__va_copy( elt, va_arg(args,type) ); \ __VA_COPY__( *elt, *va_arg(args,type) ); \
else if((*argf)(fmt,(char*)(&arge),t_user,n_user) < 0) \ else if((*argf)(fmt,(char*)(&arge),t_user,n_user) < 0) \
goto pop_fa; \ goto pop_fa; \
else __va_copy( elt, arge ); \ else __VA_COPY__( *elt, *arge ); \
} }
#if __STD_C #if __STD_C
@ -301,15 +307,14 @@ loop_fa :
GETARG(form,form,argf,args,char*,char*,'1',t_user,n_user); GETARG(form,form,argf,args,char*,char*,'1',t_user,n_user);
if(!form) if(!form)
form = ""; form = "";
#if (defined(CSRG_BASED) && !defined(__LP64__)) || \ #if defined(__VA_COPY__)
(defined(__linux__) && !defined(__LP64__)) || defined(sun) GETARGL(argsp,argsp,argf,args,va_list*,va_list*,'2',t_user,n_user);
__VA_COPY__( fa->args, args );
__VA_COPY__( args, *argsp );
#else
GETARG(argsp,argsp,argf,args,va_list*,va_list*,'2',t_user,n_user); GETARG(argsp,argsp,argf,args,va_list*,va_list*,'2',t_user,n_user);
memcpy((Void_t*)(&(fa->args)), (Void_t*)(&args), sizeof(va_list)); memcpy((Void_t*)(&(fa->args)), (Void_t*)(&args), sizeof(va_list));
memcpy((Void_t*)(&args), (Void_t*)argsp, sizeof(va_list)); memcpy((Void_t*)(&args), (Void_t*)argsp, sizeof(va_list));
#else
GETARGL(argsp,argsp,argf,args,va_list*,va_list*,'2',t_user,n_user);
__va_copy( fa->args, args );
__va_copy( args, argsp );
#endif #endif
fa->argf.p = argf; fa->argf.p = argf;
fa->extf.p = extf; fa->extf.p = extf;
@ -324,7 +329,7 @@ loop_fa :
va_list savarg = args; /* is this portable? */ va_list savarg = args; /* is this portable? */
#else #else
va_list savarg; /* is this portable? Sorry .. NO. */ va_list savarg; /* is this portable? Sorry .. NO. */
__va_copy( savarg, args ); __VA_COPY__( savarg, args );
#endif #endif
GETARG(sp,astr,argf,args,char*,char*,fmt,t_user,n_user); GETARG(sp,astr,argf,args,char*,char*,fmt,t_user,n_user);
@ -336,7 +341,7 @@ loop_fa :
#if defined(CSRG_BASED) && !defined(__LP64__) #if defined(CSRG_BASED) && !defined(__LP64__)
args = savarg; /* extf failed, treat as if unmatched */ args = savarg; /* extf failed, treat as if unmatched */
#else #else
__va_copy( args, savarg ); /* extf failed, treat as if unmatched */ __VA_COPY__( args, savarg ); /* extf failed, treat as if unmatched */
#endif #endif
} }

View file

@ -61,6 +61,12 @@
#endif #endif
#endif #endif
#if defined(va_copy)
#define __VA_COPY__(d,s) va_copy(d,s)
#elif defined(__va_copy)
#define __VA_COPY__(d,s) __va_copy(d,s)
#endif
#define MAXLENGTH (int)(((uint)~0)>>1) #define MAXLENGTH (int)(((uint)~0)>>1)
#define a2f(s) strtod(s,NIL(char**)) #define a2f(s) strtod(s,NIL(char**))
@ -236,10 +242,10 @@ loop_fa :
fa->form = (char*)form; fa->form = (char*)form;
if(!(form = va_arg(args,char*))) if(!(form = va_arg(args,char*)))
form = ""; form = "";
#ifdef __ppc #if defined(__VA_COPY__)
__va_copy( argsp, va_arg(args,va_list*) ); __VA_COPY__( *argsp, *va_arg(args,va_list*) );
__va_copy( fa->args, args ); __VA_COPY__( fa->args, args );
__va_copy( args, argsp ); __VA_COPY__( args, *argsp );
#else #else
argsp = va_arg(args,va_list*); argsp = va_arg(args,va_list*);
memcpy((Void_t*)(&(fa->args)), (Void_t*)(&args), sizeof(va_list)); memcpy((Void_t*)(&(fa->args)), (Void_t*)(&args), sizeof(va_list));

View file

@ -93,6 +93,11 @@
#define va_listarg va_list* #define va_listarg va_list*
#endif #endif
#include <ast.h> #include <ast.h>
#if defined(va_copy)
#define __VA_COPY__(d,s) va_copy(d,s)
#else
#define __VA_COPY__(d,s) __va_copy(d,s)
#endif
static char empty[1]; static char empty[1];
@ -229,7 +234,7 @@ tokscan __PARAM__((char* s, char** nxt, const char* fmt, ...), (va_alist)) __OTO
if (f = prv_f) if (f = prv_f)
{ {
prv_f = 0; prv_f = 0;
__va_copy( ap, prv_ap ); __VA_COPY__( ap, prv_ap );
continue; continue;
} }
goto done; goto done;
@ -258,8 +263,8 @@ tokscan __PARAM__((char* s, char** nxt, const char* fmt, ...), (va_alist)) __OTO
case ':': case ':':
prv_f = f; prv_f = f;
f = va_arg(ap, char*); f = va_arg(ap, char*);
__va_copy( prv_ap, ap ); __VA_COPY__( prv_ap, ap );
__va_copy(ap, va_listval(va_arg(ap, va_listarg))); __VA_COPY__(ap, va_listval(va_arg(ap, va_listarg)));
continue; continue;
case 'c': case 'c':
p_char = va_arg(ap, char*); p_char = va_arg(ap, char*);