From b033302d2a4f654fdc346f9cac35bd6c7cdadd0b Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 12:00:08 -0700 Subject: [PATCH 01/27] Remove duplicate #defines for items that are in display.h --- src/keyevent.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/keyevent.c b/src/keyevent.c index cfcbba7..5e348f3 100644 --- a/src/keyevent.c +++ b/src/keyevent.c @@ -573,13 +573,6 @@ typedef struct { LispPTR CUDATA; } CURSOR; -#define DLWORD_PERLINE (displaywidth / 16) -#define HARD_CURSORWIDTH 16 -#define HARD_CURSORHEIGHT 16 -#define COLOR_BITSPER_PIXEL 8 -/* For MonoOrColor */ -#define MONO_SCREEN 0 -#define COLOR_SCREEN 1 #define CursorClippingX(posx, width) \ { \ if (displaywidth < (posx + HARD_CURSORWIDTH)) { \ From b647f694970557abb5423b25b2d299fa15687a86 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 12:03:28 -0700 Subject: [PATCH 02/27] Add missing include stdio.h, only required if DEBUG or TRACE is defined, but doesn't hurt. --- src/return.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/return.c b/src/return.c index cdc904f..b07b1f6 100644 --- a/src/return.c +++ b/src/return.c @@ -32,6 +32,7 @@ static char *id = "$Id: return.c,v 1.4 2001/12/24 01:09:05 sybalsky Exp $ Copyri */ /***********************************************************/ +#include #include "lispemul.h" #include "address.h" From 24d210f8d393ac6d36c4a1d6c98838688354652d Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 12:07:23 -0700 Subject: [PATCH 03/27] Initialize various X structures to 0 as not all fields are explicitly set. Remove PPosition from size hints as we don't set position. --- src/xlspwin.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/xlspwin.c b/src/xlspwin.c index 59c1d9e..caecafe 100644 --- a/src/xlspwin.c +++ b/src/xlspwin.c @@ -73,15 +73,15 @@ extern int LispWindowRequestedX, LispWindowRequestedY, LispWindowRequestedWidht, void Create_LispWindow(dsp) DspInterface dsp; { - XSizeHints szhint; - XWMHints Lisp_WMhints; - XClassHint xclasshint; - XTextProperty IconText, WindowNameText; - XSetWindowAttributes Lisp_SetWinAttributes; + XSizeHints szhint = {0}; + XWMHints Lisp_WMhints = {0}; + XClassHint xclasshint = {0}; + XTextProperty IconText = {0}, WindowNameText = {0}; + XSetWindowAttributes Lisp_SetWinAttributes = {0}; Screen *screen; - Window lspwinRoot; + Window lspwinRoot = {0}; int lspwinX, lspwinY, Col2, Row2, Col3, Row3, GravSize; unsigned int lspwinHeight, lspwinWidth, lspwinBorder, lspwinDepth; char *WT, *IT; @@ -130,7 +130,7 @@ void Create_LispWindow(dsp) DspInterface dsp; szhint.min_width = OUTER_SB_WIDTH(dsp); szhint.min_height = OUTER_SB_WIDTH(dsp); szhint.win_gravity = dsp->BitGravity; - szhint.flags = PMaxSize | PWinGravity | PSize | PPosition; + szhint.flags = PMaxSize | PWinGravity | PSize; Lisp_WMhints.icon_pixmap = make_Xicon(dsp); Lisp_WMhints.input = True; From cea2223dae59411a03a106dc3d602d1b66bd31d1 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 12:08:23 -0700 Subject: [PATCH 04/27] Convert to modern parameter declaration style. --- src/xbbt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/xbbt.c b/src/xbbt.c index 1f816d6..309f5b9 100644 --- a/src/xbbt.c +++ b/src/xbbt.c @@ -37,8 +37,7 @@ extern DspInterface currentdsp; /* dummy is the placeholder for the bitmap to be blitted */ /* */ /************************************************************************/ -unsigned long clipping_Xbitblt(dsp, dummy, x, y, w, h) DspInterface dsp; -int dummy, x, y, w, h; +unsigned long clipping_Xbitblt(DspInterface dsp, int dummy, int x, int y, int w, int h) { int temp_x, temp_y, LowerRightX, LowerRightY; From 4eaf562a8aa8560cc5088c9feeed81bfdd857f97 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 14:21:10 -0700 Subject: [PATCH 05/27] Add parentheses to correct interpretation of word-alignment check due to operator precedence confusion. --- src/gcmain3.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gcmain3.c b/src/gcmain3.c index ec6b932..7855d3f 100644 --- a/src/gcmain3.c +++ b/src/gcmain3.c @@ -401,7 +401,7 @@ LispPTR gcscanstack(void) { scanend68K = (UNSIGNED)Addr68k_from_LADDR(scanend); bascframe = (Bframe *)Addr68k_from_LADDR(scanptr); - if (0 != 3 & (UNSIGNED)bascframe) { + if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, "Frame ptr (0x%x) not to word bound " @@ -481,7 +481,7 @@ LispPTR gcscanstack(void) { bascframe = (Bframe *)ADD_OFFSET(bascframe, FRAMESIZE + PADDING + (((fnheader->pv) + 1) << 2)); - if (0 != 3 & (UNSIGNED)bascframe) { + if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, "Frame ptr (0x%x) not to word bound " @@ -502,7 +502,7 @@ LispPTR gcscanstack(void) { if (ntend != 0) { obascframe = bascframe; bascframe = (Bframe *)Addr68k_from_StkOffset(ntend); - if (0 != 3 & (UNSIGNED)bascframe) { + if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, "Frame ptr (0x%x) not to word bound " @@ -519,7 +519,7 @@ LispPTR gcscanstack(void) { obascframe = bascframe; bascframe = (Bframe *)next; - if (0 != 3 & (UNSIGNED)bascframe) { + if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, "Frame ptr (0x%x) not to word bound " @@ -539,7 +539,7 @@ LispPTR gcscanstack(void) { obascframe = bascframe; bascframe = (Bframe *)((DLword *)bascframe + bascframe->ivar); - if (0 != 3 & (UNSIGNED)bascframe) { + if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, "Frame ptr (0x%x) not to word bound " @@ -554,7 +554,7 @@ LispPTR gcscanstack(void) { obascframe = bascframe; bascframe = (Bframe *)((DLword *)bascframe + bascframe->ivar); - if (0 != 3 & (UNSIGNED)bascframe) { + if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, "Frame ptr (0x%x) not to word bound " From ac563a69f3ce21f6c12920332d0b2fddf9c9a88f Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 14:33:31 -0700 Subject: [PATCH 06/27] Replace 0x%x with %p for pointer output in error messages. %p arrived in C89. --- src/gcmain3.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gcmain3.c b/src/gcmain3.c index 7855d3f..27b2429 100644 --- a/src/gcmain3.c +++ b/src/gcmain3.c @@ -404,8 +404,7 @@ LispPTR gcscanstack(void) { if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, - "Frame ptr (0x%x) not to word bound " - "at start of gcscanstack.", + "Frame ptr (%p) not to word bound at start of gcscanstack.", bascframe); error(debugStr); } @@ -484,8 +483,8 @@ LispPTR gcscanstack(void) { if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, - "Frame ptr (0x%x) not to word bound " - "in gcscanstack() STK_FX case; old frame = 0x%x.", + "Frame ptr (%p) not to word bound " + "in gcscanstack() STK_FX case; old frame = %p.", bascframe, obascframe); error(debugStr); } @@ -505,8 +504,8 @@ LispPTR gcscanstack(void) { if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, - "Frame ptr (0x%x) not to word bound " - "in gcscanstack() scantemps; old frame = 0x%x.", + "Frame ptr (%p) not to word bound " + "in gcscanstack() scantemps; old frame = %p.", bascframe, obascframe); error(debugStr); } @@ -522,8 +521,8 @@ LispPTR gcscanstack(void) { if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, - "Frame ptr (0x%x) not to word bound " - "in gcscanstack(), end scantemps; old frame = 0x%x.", + "Frame ptr (%p) not to word bound " + "in gcscanstack(), end scantemps; old frame = %p.", bascframe, obascframe); error(debugStr); } @@ -542,8 +541,8 @@ LispPTR gcscanstack(void) { if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, - "Frame ptr (0x%x) not to word bound " - "in gcscanstack() STK_GUARD; old frame = 0x%x.", + "Frame ptr (%p) not to word bound " + "in gcscanstack() STK_GUARD; old frame = %p.", bascframe, obascframe); error(debugStr); } @@ -557,8 +556,8 @@ LispPTR gcscanstack(void) { if (0 != (3 & (UNSIGNED)bascframe)) { char debugStr[100]; sprintf(debugStr, - "Frame ptr (0x%x) not to word bound " - "in gcscanstack() STK_FSB; old frame = 0x%x.", + "Frame ptr (%p) not to word bound " + "in gcscanstack() STK_FSB; old frame = %p.", bascframe, obascframe); error(debugStr); } From 1dadac18881ae2b44c0f60e5ca0c6bf9bc18207d Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 16:58:45 -0700 Subject: [PATCH 07/27] Clean up types (long unsigned int => unsigned long). Add "l" qualifiers to printf format strings for long types. Rewrite input string handling in keymaker.c to get rid of unsafe gets(). --- src/keylib.c | 8 ++--- src/keymaker.c | 98 ++++++++++++++++++++------------------------------ src/keytst.c | 4 +-- 3 files changed, 44 insertions(+), 66 deletions(-) diff --git a/src/keylib.c b/src/keylib.c index d30175f..7831ba7 100644 --- a/src/keylib.c +++ b/src/keylib.c @@ -35,10 +35,10 @@ static char *id = "$Id: keylib.c,v 1.4 2001/12/24 01:09:03 sybalsky Exp $ Copyri #define FAILURE2 -2 -unsigned long make_verification(long unsigned int x, long unsigned int y); +unsigned long make_verification(unsigned long x, unsigned long y); unsigned long date_integer16(const char *date); unsigned long idate(const char *str); -unsigned long modify(long unsigned int hostid); +unsigned long modify(unsigned long hostid); /* =========================================================================== MAKE_VERIFICATION forms a new 32-bit integer by messaging the two input @@ -59,7 +59,7 @@ unsigned long make_verification(long unsigned int x, long unsigned int y) { (((ULONG_MAX % y) + 1 ) % y) is equivalent to (expt 2 32) % y =============================================================================*/ -int imod64bit(long unsigned int x1, long unsigned int x0, long unsigned int y) { +int imod64bit(unsigned long x1, unsigned long x0, unsigned long y) { /* JDS 990601 ansi return (((x0 % y) + ((x1 % y) * (((ULONG_MAX % y) + 1 ) % y) )) % y); */ return (((x0 % y) + ((x1 % y) * ((y + 1) % y))) % y); } @@ -169,7 +169,7 @@ unsigned long idate(const char *str) { in 32-bit hostid, depending on the value of (hostid % 16). =============================================================*/ -unsigned long modify(long unsigned int hostid) { +unsigned long modify(unsigned long hostid) { unsigned long dividor; #ifdef xBIGVM diff --git a/src/keymaker.c b/src/keymaker.c index 11e6c72..4c3bc1e 100644 --- a/src/keymaker.c +++ b/src/keymaker.c @@ -1,6 +1,6 @@ /* $Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ -static char *id = "$Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copyright (C) Venue"; +static const char *id = "$Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ /* */ @@ -35,7 +35,6 @@ static char *id = "$Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copy #define floadbyte(number, pos) ((number >> pos) & 0xFFFF) #define hash_unhash(number, hashkey) \ (number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey, 16) + floadbyte(hashkey, 0)))) -#define KEYNUMBERS 3 /* meaning of symbolic constants used: @@ -47,10 +46,10 @@ static char *id = "$Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copy #define FAILURE2 -2 #define FAILURE3 -3 -unsigned long make_verification(long unsigned int x, long unsigned int y); +unsigned long make_verification(unsigned long x, unsigned long y); unsigned long date_integer16(char *date); unsigned long idate(char *str); -unsigned long modify(long unsigned int hostid); +unsigned long modify(unsigned long hostid); /************************************************************************/ /* */ @@ -60,9 +59,11 @@ unsigned long modify(long unsigned int hostid); /* */ /************************************************************************/ -void writeresults(FILE *fp, char *host, char *expdate, int key1, int key2, int key3, char *info) { +void writeresults(FILE *fp, char *host, char *expdate, + unsigned long key1, unsigned long key2, unsigned long key3, + char *info) { fprintf(fp, "Host ID: %-14s Expiration: %-9s", host, expdate); - fprintf(fp, " Key: %8x %8x %8x", key1, key2, key3); + fprintf(fp, " Key: %8lx %8lx %8lx", key1, key2, key3); fprintf(fp, " Doc: %s\n", info); } @@ -78,15 +79,12 @@ int main(int argc, char **argv) { int logfile = 0; /* set to 1 if logfile on command line */ FILE *fp; /* file pointer for the logfile */ unsigned long hostid; - long keyarray[KEYNUMBERS]; - char *hexdigits = {"-0123456789abcdefABCDEF"}; - char s[50], hstr[50], expdate[30], saveexpdate[30], cc; + unsigned long keys[3]; + char s[50], expdate[30], saveexpdate[30]; char infostring[500]; - char *sptr, *ptr, *digitstring; - char *hptr = {" "}; - char **hhptr = &hptr; - int base = 10; - int i, j, c; + char *sptr; + char *eptr; + int i, c; int commandlineargs; commandlineargs = (argc > 2); @@ -107,66 +105,47 @@ int main(int argc, char **argv) { if (commandlineargs) { /* assume that the second argument is hex-hostid */ sptr = *++argv; - hostid = strtol(sptr, hhptr, 16); - + hostid = strtoul(sptr, &eptr, 16); } else { - printf("\n\nEnter Host ID (starts with 0x if the number is hexidecimal): "); - gets(s); - sptr = strtok(s, " "); - - /* decide the base */ - if (((ptr = strchr(sptr, '0')) != NULL) && (*(ptr + 1) == 'x' || *(ptr + 1) == 'X')) base = 16; - -#ifdef INDIGO - hostid = strtoul(sptr, hhptr, base); -#elif defined(OS5) - hostid = strtoul(sptr, hhptr, base); -#else - hostid = strtol(sptr, hhptr, base); -#endif + printf("Enter Host ID (starts with 0x if the number is hexadecimal): "); + sptr = fgets(s, sizeof(s), stdin); + hostid = strtoul(s, &eptr, 0); /* look for syntax error */ - if (**hhptr != '\0') { - printf("\nInvalid Host ID \n"); + if (*eptr != '\n') { + printf("\nInvalid Host ID\n"); exit(FAILURE1); - }; - - /* make sure Host ID is less than 32 bits */ - if (base == 16) { - sprintf(hstr, "%x", hostid); - for (i = 0; (cc = *(sptr + i)) != '\0'; ++i) - if (isupper(cc)) *(sptr + i) = tolower(cc); - for (i = 0; (cc = *(hstr + i)) != '\0'; ++i) - if (isupper(cc)) *(hstr + i) = tolower(cc); - digitstring = "123456789abcdef"; } else { - sprintf(hstr, "%u", hostid); - digitstring = "123456789"; - }; + /* trim off the trailing newline */ + *eptr = '\0'; + } - ptr = strpbrk(sptr, digitstring); - if ((ptr == NULL && *sptr != '0' && *hstr != '0') || (ptr != NULL && strcmp(ptr, hstr) != 0)) { - printf("\nInvalid Host ID \n"); + /* make sure Host ID is less than 32 bits */ + /* XXX: why?, is 32-bits not OK -- compare to original code */ + if ((hostid & 0x7FFFFFFF) != hostid) { + printf("\nInvalid Host ID\n"); exit(FAILURE1); } - }; + } + hostid = modify(hostid); /* == prompt for the expiration date and validate it == */ if (!commandlineargs) { /* assume that info is not needed when we use argc,argv */ - printf("\n\nEnter information string (one line only, below)\n:"); - gets(infostring); + printf("Enter information string (one line only, below)\n:"); + fgets(infostring, sizeof(infostring), stdin); + infostring[strlen(infostring) - 1] = '\0'; } /* == prompt for the expiration date and validate it == */ if (commandlineargs) { strcpy(expdate, *++argv); - } else { printf("Enter Software Expiration Date (dd-mmm-yy or never): "); - gets(expdate); + fgets(expdate, sizeof(expdate), stdin); + expdate[strlen(expdate) - 1] = '\0'; } strcpy(saveexpdate, expdate); /* check for 'never' entry */ @@ -189,14 +168,14 @@ int main(int argc, char **argv) { }; /* == generate 3 keys == */ - keyarray[0] = hash_unhash(hostid, hostid); - keyarray[1] = hash_unhash(((date_integer16(expdate) << 16) | 0), hostid); - keyarray[2] = make_verification(keyarray[0], keyarray[1]); + keys[0] = hash_unhash(hostid, hostid); + keys[1] = hash_unhash(((date_integer16(expdate) << 16) | 0), hostid); + keys[2] = make_verification(keys[0], keys[1]); /* == report the results == */ if (commandlineargs) { - printf("%8x %8x %8x\n", *keyarray, *(keyarray + 1), *(keyarray + 2)); + printf("%8lx %8lx %8lx\n", keys[0], keys[1], keys[2]); exit(1); } else { /* if logfile is open, append the results to the end of the file */ @@ -205,12 +184,11 @@ int main(int argc, char **argv) { fprintf(fp, "\n%s", *++argv); printf("\n%s", *argv); } - writeresults(fp, sptr, saveexpdate, *keyarray, *(keyarray + 1), *(keyarray + 2), infostring); + writeresults(fp, sptr, saveexpdate, keys[0], keys[1], keys[2], infostring); fclose(fp); }; - writeresults(stdout, sptr, saveexpdate, *keyarray, *(keyarray + 1), *(keyarray + 2), - infostring); /* display the results on the terminal */ + writeresults(stdout, sptr, saveexpdate, keys[0], keys[1], keys[2], infostring); }; exit(0); } diff --git a/src/keytst.c b/src/keytst.c index 76ce34f..aba8b2c 100644 --- a/src/keytst.c +++ b/src/keytst.c @@ -56,10 +56,10 @@ static char *id = "$Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ Copyri #define FAILURE4 -4 #define FAILURE99 -99 -unsigned long make_verification(long unsigned int x, long unsigned int y); +unsigned long make_verification(unsigned long x, unsigned long y); unsigned long date_integer16(char *date); unsigned long idate(char *str); -unsigned long modify(long unsigned int hostid); +unsigned long modify(unsigned long hostid); /* ===================================================================== KEYTESTER checks the input key string. From 118a3e77500b416c0c885e90ece4045e3a6decb2 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 17:19:02 -0700 Subject: [PATCH 08/27] Correct signedness of window parameters used in XParseGeometry. Signed x, y, Unsigned width, height. modified: xinit.c modified: xlspwin.c modified: xrdopt.c --- src/xinit.c | 8 ++++---- src/xlspwin.c | 4 ++-- src/xrdopt.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/xinit.c b/src/xinit.c index dec558f..cdef2ca 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -72,11 +72,11 @@ int Byte_Order, Bitmap_Bit_Order, Bitmap_Pad, Default_Depth, Display_Height, Dis int LispWindowRequestedX = 0; int LispWindowRequestedY = 0; -int LispWindowRequestedWidth = DEF_WIN_WIDTH; -int LispWindowRequestedHeight = DEF_WIN_HEIGHT; +unsigned LispWindowRequestedWidth = DEF_WIN_WIDTH; +unsigned LispWindowRequestedHeight = DEF_WIN_HEIGHT; -int LispDisplayRequestedX, LispDisplayRequestedY, LispDisplayRequestedWidth, - LispDisplayRequestedHeight; +int LispDisplayRequestedX, LispDisplayRequestedY; +unsigned LispDisplayRequestedWidth, LispDisplayRequestedHeight; Colormap Colors; diff --git a/src/xlspwin.c b/src/xlspwin.c index caecafe..d55321e 100644 --- a/src/xlspwin.c +++ b/src/xlspwin.c @@ -60,8 +60,8 @@ XEvent report; Cursor WaitCursor, DefaultCursor, VertScrollCursor, VertThumbCursor, ScrollUpCursor, ScrollDownCursor, HorizScrollCursor, HorizThumbCursor, ScrollLeftCursor, ScrollRightCursor; -extern int LispWindowRequestedX, LispWindowRequestedY, LispWindowRequestedWidht, - LispWindowRequestedHeight; +extern int LispWindowRequestedX, LispWindowRequestedY; +extern unsigned LispWindowRequestedWidth, LispWindowRequestedHeight; /************************************************************************/ /* */ diff --git a/src/xrdopt.c b/src/xrdopt.c index f44daef..9a76e3d 100644 --- a/src/xrdopt.c +++ b/src/xrdopt.c @@ -42,11 +42,11 @@ static char *id = "$Id: xrdopt.c,v 1.6 2001/12/26 22:17:07 sybalsky Exp $ Copyri XrmDatabase commandlineDB, applicationDB, serverDB, homeDB, rDB; int opTableEntries = 33; -extern int LispWindowRequestedX, LispWindowRequestedY, LispWindowRequestedWidth, - LispWindowRequestedHeight; +extern int LispWindowRequestedX, LispWindowRequestedY; +extern unsigned LispWindowRequestedWidth, LispWindowRequestedHeight; -extern int LispDisplayRequestedX, LispDisplayRequestedY, LispDisplayRequestedWidth, - LispDisplayRequestedHeight; +extern int LispDisplayRequestedX, LispDisplayRequestedY; +extern unsigned LispDisplayRequestedWidth, LispDisplayRequestedHeight; extern int xsync; From de2ae84bfcf35e5c4592c02e2d36ad2d6a31b0f7 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 17:42:50 -0700 Subject: [PATCH 09/27] Explicitly cast cursor bitmap to char * to match XCreatePixmapFromBitmapData modified: xcursor.c --- src/xcursor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xcursor.c b/src/xcursor.c index 1c1282c..db543ab 100644 --- a/src/xcursor.c +++ b/src/xcursor.c @@ -248,10 +248,10 @@ Cursor *return_cursor; XLOCK; screen = ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)); - Cursor_src = XCreatePixmapFromBitmapData(dsp->display_id, dsp->DisplayWindow, image, 16, 16, 1, 0, - 1); /* Has to have a depth of 1! */ - Cursor_msk = XCreatePixmapFromBitmapData(dsp->display_id, dsp->DisplayWindow, image, 16, 16, 1, 0, - 1); /* Has to have a depth of 1! */ + Cursor_src = XCreatePixmapFromBitmapData(dsp->display_id, dsp->DisplayWindow, (char *)image, + 16, 16, 1, 0, 1); /* Has to have a depth of 1! */ + Cursor_msk = XCreatePixmapFromBitmapData(dsp->display_id, dsp->DisplayWindow, (char *)image, + 16, 16, 1, 0, 1); /* Has to have a depth of 1! */ *return_cursor = XCreatePixmapCursor(dsp->display_id, Cursor_src, Cursor_msk, &cursor_fore_xcsd, &cursor_back_xcsd, hotspot_x, hotspot_y); From 0dc8820060daef44abc13a305415895486d89abd Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 17:51:48 -0700 Subject: [PATCH 10/27] Add "l" qualifiers to printf format strings for long types. modified: dspif.c --- src/dspif.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dspif.c b/src/dspif.c index 1d7380e..77fb4c9 100644 --- a/src/dspif.c +++ b/src/dspif.c @@ -123,15 +123,15 @@ void describedsp(DspInterface dsp) { printf("width= %d\n", dsp->Display.width); printf("height= %d\n", dsp->Display.height); printf("bitsperpixel= %d\n", dsp->bitsperpixel); - printf("colors= %d\n", dsp->colors); - printf("graphicsmode= %d\n", dsp->graphicsmode); - printf("numberofbanks= %d\n", dsp->numberofbanks); + printf("colors= %lu\n", dsp->colors); + printf("graphicsmode= %lu\n", dsp->graphicsmode); + printf("numberofbanks= %lu\n", dsp->numberofbanks); #ifdef DOS printf("BytesPerLine= %d\n", dsp->BytesPerLine); printf("DisplayStartAddr= %d\n", dsp->DisplayStartAddr); #endif /* DOS */ - printf("bitblt_to_screen= %d\n", dsp->bitblt_to_screen); - printf("cleardisplay= %d\n", dsp->cleardisplay); + printf("bitblt_to_screen= %p\n", dsp->bitblt_to_screen); + printf("cleardisplay= %p\n", dsp->cleardisplay); #ifdef DOS printf("mouse_vissible= %d\n", dsp->mouse_vissible); printf("mouse_invissible= %d\n", dsp->mouse_invissible); From e2264ff1f96691d12cf34f15648434043ca0d693 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 18:33:53 -0700 Subject: [PATCH 11/27] Add braces to suppress warning for dangling else clause. modified: gcoflow.c --- src/gcoflow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gcoflow.c b/src/gcoflow.c index ced726a..c8e72f8 100644 --- a/src/gcoflow.c +++ b/src/gcoflow.c @@ -49,13 +49,14 @@ static char *id = "$Id: gcoflow.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyr #define Oddp(num) (((num % 2) != 0) ? 1 : 0) #define Evenp(num, prim) (((num % prim) == 0) ? 1 : 0) #define Increment_Allocation_Count(n) \ - if (*Reclaim_cnt_word != NIL) \ + if (*Reclaim_cnt_word != NIL) { \ if (*Reclaim_cnt_word > n) \ (*Reclaim_cnt_word) -= n; \ else { \ *Reclaim_cnt_word = NIL; \ doreclaim(); \ - }; + } \ + } DLword gc_handleoverflow(DLword arg) { struct htoverflow *cell; From 409f1f598745500c490b5eb7c4fc3f0a2b55071e Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 18:37:15 -0700 Subject: [PATCH 12/27] Add missing comment closing delimiter to suppress warning for nested comments. modified: gcr.c --- src/gcr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gcr.c b/src/gcr.c index 3afdd36..55cf832 100644 --- a/src/gcr.c +++ b/src/gcr.c @@ -45,7 +45,7 @@ static char *id = "$Id: gcr.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright /* But currently this function is not used(may be used in Future.) */ /* This function may have a problem. It is to manipulate "clock" */ /* for keeping the GC's time period. */ -/* disablegc1(noerror) +/* disablegc1(noerror) */ /* This function is the rescue function,when the HTcoll table is */ /* overflow and so on.After this function's process is over, the */ /* keyhandler will sense the interrupt table state and call the */ From 9510746af4d1966a09ab3bc815735994d22e952f Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 19:57:40 -0700 Subject: [PATCH 13/27] Add comment regarding return from NewEntry macro. modified: gchtfind.c --- src/gchtfind.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gchtfind.c b/src/gchtfind.c index f8c2232..ba6c780 100644 --- a/src/gchtfind.c +++ b/src/gchtfind.c @@ -417,6 +417,7 @@ nolink: /* no match */ GETGC((GCENTRY *)link + 1) = GETGC((GCENTRY *)entry) - 1; GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; NewEntry(link, hiptr, casep, ptr); + /* NewEntry will return */ } /************************************************************************/ From 4fe917e2d832bab5477cea2a9b02beb7b1601c11 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 19:59:00 -0700 Subject: [PATCH 14/27] Fix unsequenced modification and access to 'addr' Fix incorrect format string for type, replacing 0x%x with %p. modified: gcfinal.c --- src/gcfinal.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gcfinal.c b/src/gcfinal.c index cd3075c..3ea1565 100644 --- a/src/gcfinal.c +++ b/src/gcfinal.c @@ -536,13 +536,15 @@ void printarrayblock(LispPTR base) { printf(" Length: %d cells.\n\n", bbase->arlen); addr = ((LispPTR *)bbase) - 20; - for (; addr < (LispPTR *)bbase; addr++) printf("0x%x %8x\n", addr, *addr); - printf("0x%x %8x <- array header\n", addr, *addr++); - for (; addr < (LispPTR *)bbase + 20; addr++) printf("0x%x %8x\n", addr, *addr); + for (; addr < (LispPTR *)bbase; addr++) printf("%p %8x\n", addr, *addr); + printf("%p %8x <- array header\n", addr, *addr); + addr++; + for (; addr < (LispPTR *)bbase + 20; addr++) printf("%p %8x\n", addr, *addr); printf(". . .\n"); addr = ((LispPTR *)btrailer) - 20; - for (; addr < (LispPTR *)btrailer; addr++) printf("0x%x %8x\n", addr, *addr); - printf("0x%x %8x <- array trailer\n", addr, *addr++); - for (; addr < (LispPTR *)btrailer + 20; addr++) printf("0x%x %8x\n", addr, *addr); + for (; addr < (LispPTR *)btrailer; addr++) printf("%p %8x\n", addr, *addr); + printf("%p %8x <- array trailer\n", addr, *addr); + addr++; + for (; addr < (LispPTR *)btrailer + 20; addr++) printf("%p %8x\n", addr, *addr); } From f4f9118a7cdfd3d3e991e81ed32d401171d0d79a Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 20:03:31 -0700 Subject: [PATCH 15/27] Add casts to match calculations to format specifier. modified: gccode.c --- src/gccode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gccode.c b/src/gccode.c index 9dd3a51..2499816 100644 --- a/src/gccode.c +++ b/src/gccode.c @@ -276,7 +276,7 @@ int code_block_size(long unsigned int codeblock68k) { sprintf(errtext, "Unrecognized bytecode (0%o) at offset 0%o in code block x%x,x%x; continue to use " "UFN length", - opnum, codeptr - (InstPtr)fnbase, (codeblock68k >> 16) & 0xFF, codeblock68k & 0xFFFF); + opnum, codeptr - (InstPtr)fnbase, (int)((codeblock68k >> 16) & 0xFF), (int)(codeblock68k & 0xFFFF)); error(errtext); oplength[opnum] = len = (((UFN *)UFNTable) + (opnum))->byte_num; } From 1b7a7fc6fc1d79d9d54f3f257b1b245fd272a402 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 20:09:11 -0700 Subject: [PATCH 16/27] Correct format strings and arguments. modified: gcarray.c --- src/gcarray.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gcarray.c b/src/gcarray.c index f211d4b..5275fd7 100644 --- a/src/gcarray.c +++ b/src/gcarray.c @@ -101,7 +101,7 @@ struct hashtable { /************************************************************************/ LispPTR aref1(LispPTR array, int index) { - register LispPTR retval; + register LispPTR retval = 0; register LispPTR base; register short typenumber; register struct arrayheader *actarray; @@ -110,8 +110,8 @@ LispPTR aref1(LispPTR array, int index) { if (index >= actarray->totalsize) { printf("Invalid index in GC's AREF1: 0x%x\n", index); printf(" Array size limit: 0x%x\n", actarray->totalsize); - printf(" Array ptr: 0x%x\n", (UNSIGNED)array); - printf(" Array 68K ptr: 0x%x\n", (UNSIGNED)actarray); + printf(" Array ptr: 0x%lx\n", (UNSIGNED)array); + printf(" Array 68K ptr: %p\n", actarray); printf("base: 0x%x\n", actarray->base); printf("offset: 0x%x\n", actarray->offset); printf("type #: 0x%x\n", actarray->typenumber); From 154d07edce76617eb4a0878dd1484d2eaf5b2270 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 20:11:57 -0700 Subject: [PATCH 17/27] Remove unused argument from printf(). modified: initkbd.c --- src/initkbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/initkbd.c b/src/initkbd.c index 0482814..cc3b777 100644 --- a/src/initkbd.c +++ b/src/initkbd.c @@ -798,7 +798,7 @@ void keyboardtype(fd) int fd; char errmsg[200]; sprintf(errmsg, "Unsupported keyboard type: %d", type); printf("%s\n", errmsg); - printf("Configuring keyboard for type-3\n", errmsg); + printf("Configuring keyboard for type-3\n"); SUNLispKeyMap = SUNLispKeyMap_for3; InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; break; From 25b0a24e3f1d758c8d32caa58264d3e1ffd15c12 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 20:18:47 -0700 Subject: [PATCH 18/27] Convert from K&R style parameter declaration to modern. modified: keyevent.c --- src/keyevent.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/keyevent.c b/src/keyevent.c index 5e348f3..83bc18b 100644 --- a/src/keyevent.c +++ b/src/keyevent.c @@ -300,8 +300,7 @@ DLword ColorCursor_savebitmap[CURSORWIDTH / COLORPIXELS_IN_DLWORD * CURSORHEIGHT /* */ /************************************************************************/ -void getsignaldata(sig, code, scp) int sig, code; -struct sigcontext *scp; +void getsignaldata(int sig, int code, struct sigcontext *scp) { #ifndef DOS #ifndef XWINDOW @@ -418,7 +417,7 @@ void kb_trans(u_short keycode, u_short upflg); #if (!defined(XWINDOW) && !defined(DOS)) extern int for_makeinit; -int kb_event(event) register struct inputevent *event; +int kb_event(struct inputevent *event); { register u_int upflg; int kn; @@ -542,8 +541,7 @@ int kb_event(event) register struct inputevent *event; /* */ /************************************************************************/ -void kb_trans(keycode, upflg) u_short keycode; -u_short upflg; +void kb_trans(u_short keycode, u_short upflg) { extern IFPAGE *InterfacePage; if (keycode < 64) /* DLKBDAD0 ~ 3 */ @@ -673,7 +671,7 @@ void taking_mouse_down() { To avoid duplicate caluculation */ #ifndef COLOR /* FOR MONO ONLY */ -void copy_cursor(newx, newy) int newx, newy; +void copy_cursor(int newx, int newy) { register DLword *srcbase, *dstbase; register int offsetx, offsety; @@ -698,7 +696,7 @@ void copy_cursor(newx, newy) int newx, newy; } /* store bitmap image inside rect. which specified by x,y */ -void cursor_hidden_bitmap(x, y) int x, y; +void cursor_hidden_bitmap(int x, int y) { register DLword *srcbase, *dstbase; static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; @@ -719,7 +717,7 @@ void cursor_hidden_bitmap(x, y) int x, y; #else /* For COLOR & MONO */ #define IMIN(x, y) (((x) > (y)) ? (y) : (x)) -void copy_cursor(newx, newy) int newx, newy; +void copy_cursor(int newx, int newy) { register DLword *srcbase, *dstbase; register int offsetx, offsety; @@ -760,7 +758,7 @@ void copy_cursor(newx, newy) int newx, newy; } /* I'll make it MACRO */ -void taking_mouse_up(newx, newy) int newx, newy; +void taking_mouse_up(int newx, int newy) { #ifdef DOS (currentdsp->mouse_vissible)(newx, newy); @@ -778,7 +776,7 @@ void taking_mouse_up(newx, newy) int newx, newy; } /* store bitmap image inside rect. which specified by x,y */ -void cursor_hidden_bitmap(x, y) int x, y; +void cursor_hidden_bitmap(int x, int y) { register DLword *srcbase, *dstbase; static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; From 6595e9f7b118543e6a26a305cbc682b7e6d85d65 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 20:39:27 -0700 Subject: [PATCH 19/27] Add braces to suppress dangling else warning. modified: inc/tosfns.h --- inc/tosfns.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/tosfns.h b/inc/tosfns.h index a1029c6..9d8a9e1 100755 --- a/inc/tosfns.h +++ b/inc/tosfns.h @@ -535,7 +535,7 @@ op_fn_common: \ LispPTR closure_env = (LispPTR) 0xffffffff; \ {register int NEXTBLOCK = NIL; \ defcell = fn_defcell; \ - if( (defcell->ccodep == 0) ) \ + if(defcell->ccodep == 0) { \ if(GetTypeNumber(defcell->defpointer)==TYPE_COMPILED_CLOSURE) \ { /* setup closure */ \ closure=(CClosure *)Addr68k_from_LADDR(defcell->defpointer);\ @@ -550,6 +550,7 @@ op_fn_common: \ defcell = (DefCell *)GetDEFCELL68k(ATOM_INTERPRETER); \ needpush = 1; \ } /*else end */ \ + } \ LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR(defcell->defpointer); \ BCE_CURRENTFX->pc = ((UNSIGNED)PCMAC \ - (UNSIGNED)FuncObj) + fn_opcode_size; \ From ce13dce2796dad121ec83f006067fc7733d2ec3e Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 20:40:43 -0700 Subject: [PATCH 20/27] Convert 0x%x to %p where appropriate. modified: llstk.c --- src/llstk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/llstk.c b/src/llstk.c index 54846ae..9a59859 100644 --- a/src/llstk.c +++ b/src/llstk.c @@ -630,7 +630,7 @@ void stack_check(StackWord *start68k) { if (scanptr68k != start68k) { if (scanptr68k > endstack68k) { WARN("scanptr exceeded end stack", - printf("scanptr68k=0x%x endstack68k=0x%x", scanptr68k, endstack68k)); + printf("scanptr68k=%p endstack68k=%p", scanptr68k, endstack68k)); } } } /* while end */ @@ -707,7 +707,7 @@ void walk_stack(StackWord *start68k) { printf(" End of stack = 0x%x.\n\n", (DLword *)endstack68k - Stackspace); if (STKWORD(endstack68k)->flags != STK_GUARD) - printf("?? endstack is not GUARD BLK\nendstack = 0x%x, flags = %d\n\n", endstack68k, + printf("?? endstack is not GUARD BLK\nendstack = %p, flags = %d\n\n", endstack68k, STKWORD(endstack68k)->flags); while (scanptr68k < endstack68k) { @@ -800,7 +800,7 @@ void walk_stack(StackWord *start68k) { if (scanptr68k != start68k) { if (scanptr68k > endstack68k) { WARN("scanptr exceeded end stack", - printf("scanptr68k=0x%x endstack68k=0x%x", scanptr68k, endstack68k)); + printf("scanptr68k=%p endstack68k=%p", scanptr68k, endstack68k)); } } } /* while end */ @@ -927,7 +927,7 @@ void quick_stack_check(void) { if (scanptr68k != start68k) { if (scanptr68k > endstack68k) { WARN("scanptr exceeded end stack", - printf("scanptr68k=0x%x endstack68k=0x%x", scanptr68k, endstack68k)); + printf("scanptr68k=%p endstack68k=%p", scanptr68k, endstack68k)); } } } /* while end */ From 3d47027d3172db7233c694de99d690960b943ae4 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 20:50:30 -0700 Subject: [PATCH 21/27] Clean up error message for case where sysout is not integral number of pages. Correct format string (%lx) for size of argument (long). modified: ldsout.c --- src/ldsout.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ldsout.c b/src/ldsout.c index 60fd1b1..a891d8b 100644 --- a/src/ldsout.c +++ b/src/ldsout.c @@ -247,8 +247,9 @@ int sys_size; /* sysout size in megabytes */ machinetype = ifpage.machinetype; - if ((stat_buf.st_size & 0x1ff) != 0) - printf("CAUTION::sysout & 0x1ff = 0x%x\n", stat_buf.st_size & BYTESPER_PAGE); + if ((stat_buf.st_size & (BYTESPER_PAGE - 1)) != 0) + printf("CAUTION::not an integral number of pages. sysout & 0x1ff = 0x%x\n", + (int)(stat_buf.st_size & (BYTESPER_PAGE - 1))); if (ifpage.nactivepages != (sysout_size / 2)) { printf("sysout_loader:IFPAGE says sysout size is %d\n", ifpage.nactivepages); @@ -335,7 +336,7 @@ int sys_size; /* sysout size in megabytes */ lispworld_offset = GETFPTOVP(fptovp, i) * BYTESPER_PAGE; if (read(sysout, lispworld_scratch + lispworld_offset, BYTESPER_PAGE) == -1) { printf("sysout_loader: can't read sysout file at %d\n", i); - printf(" offset was 0x%x (0x%x pages).\n", lispworld_offset, + printf(" offset was 0x%lx (0x%x pages).\n", lispworld_offset, GETFPTOVP(fptovp, i)); perror("read() error was"); { From 2c3fb229d199af57d0e6628f6b735f5005136f43 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 20:54:52 -0700 Subject: [PATCH 22/27] Add braces to suppress dangling else warning. modified: vars3.c --- src/vars3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vars3.c b/src/vars3.c index f0b8502..ba878c1 100644 --- a/src/vars3.c +++ b/src/vars3.c @@ -45,7 +45,7 @@ struct cadr_cell cadr(LispPTR cell_adr) struct cadr_cell cadr1; /* return value */ short offset; - if (Listp(cell_adr) == NIL) + if (Listp(cell_adr) == NIL) { if (cell_adr == NIL) { cadr1.car_cell = 0; cadr1.cdr_cell = 0; @@ -55,7 +55,7 @@ struct cadr_cell cadr(LispPTR cell_adr) cadr1.cdr_cell = cdr(cell_adr); return (cadr1); } - + } pcons = (ConsCell *)Addr68k_from_LADDR(cell_adr); while (pcons->cdr_code == CDR_INDIRECT) { /* CDR indirect */ From 9ea244b9271693134991d51e2452f87567b4dab9 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 21:21:15 -0700 Subject: [PATCH 23/27] Use correct type (unsigned) for message length. modified: rpc.c --- src/rpc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpc.c b/src/rpc.c index f9bf32a..66f9e67 100644 --- a/src/rpc.c +++ b/src/rpc.c @@ -73,7 +73,8 @@ LispPTR rpc(args) LispPTR *args; register int s, msec_until_timeout, msec_between_tries, out_length; register int received, mask; register int port; - int dontblock, dest, fromlen, read_descriptors; + int dontblock, dest, read_descriptors; + unsigned fromlen; struct timeval pertry_timeout, total_timeout, time_waited; From 04b0b3ee0b773959fc6523f8b09b1783dee3c0de Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Wed, 7 Jun 2017 23:53:03 -0700 Subject: [PATCH 24/27] Add new include file xscroll.h defining the Scroll functions implemented in xscroll.c and used in xwinman.c Update function declarations from K&R style to new style. Fix incorrect argument counts for some procedure calls. new file: ../inc/xscroll.h modified: xscroll.c modified: xwinman.c --- inc/xscroll.h | 15 +++++++++++++++ src/xscroll.c | 17 ++++++++--------- src/xwinman.c | 21 +++++++++------------ 3 files changed, 32 insertions(+), 21 deletions(-) create mode 100644 inc/xscroll.h diff --git a/inc/xscroll.h b/inc/xscroll.h new file mode 100644 index 0000000..b5d0bb5 --- /dev/null +++ b/inc/xscroll.h @@ -0,0 +1,15 @@ +/************************************************************************/ +/* */ +/* xscroll.h */ +/* */ +/* Scrolling functions implemented in xscroll.c */ +/* */ +/************************************************************************/ + +void Scroll(DspInterface dsp, int newX, int newY); +void JumpScrollVer(DspInterface dsp, int y); +void JumpScrollHor(DspInterface dsp, int x); +void ScrollLeft(DspInterface dsp); +void ScrollRight(DspInterface dsp); +void ScrollUp(DspInterface dsp); +void ScrollDown(DspInterface dsp); diff --git a/src/xscroll.c b/src/xscroll.c index 7452dda..0a11987 100644 --- a/src/xscroll.c +++ b/src/xscroll.c @@ -29,10 +29,9 @@ static char *id = "$Id: xscroll.c,v 1.2 1999/01/03 02:07:48 sybalsky Exp $ Copyr int ScrollPitch = SCROLL_PITCH; /* Move the DisplayWindow and the ScrollButtons to a new */ -/* position. newX, newY refers to the uppre left corner */ +/* position. newX, newY refers to the upper left corner */ /* of the LispDisplay */ -void Scroll(dsp, newX, newY) DspInterface dsp; -int newX, newY; +void Scroll(DspInterface dsp, int newX, int newY) { /* Limit the newX and newY values. */ dsp->Vissible.x = bound(0, newX, dsp->Display.width - dsp->Vissible.width); @@ -48,20 +47,20 @@ int newX, newY; dsp->Vissible.height); } /* end Scroll */ -void JumpScrollVer(dsp, y) DspInterface dsp; +void JumpScrollVer(DspInterface dsp, int y) { Scroll(dsp, dsp->Vissible.x, (int)((dsp->Display.width * y) / dsp->Vissible.height)); } -void JumpScrollHor(dsp, x) DspInterface dsp; +void JumpScrollHor(DspInterface dsp, int x) { Scroll(dsp, (int)((dsp->Display.width * x) / dsp->Vissible.width), dsp->Vissible.y); } -void ScrollLeft(dsp) DspInterface dsp; +void ScrollLeft(DspInterface dsp) { Scroll(dsp, dsp->Vissible.x - ScrollPitch, dsp->Vissible.y); } -void ScrollRight(dsp) DspInterface dsp; +void ScrollRight(DspInterface dsp) { Scroll(dsp, dsp->Vissible.x + ScrollPitch, dsp->Vissible.y); } -void ScrollUp(dsp) DspInterface dsp; +void ScrollUp(DspInterface dsp) { Scroll(dsp, dsp->Vissible.x, dsp->Vissible.y - ScrollPitch); } -void ScrollDown(dsp) DspInterface dsp; +void ScrollDown(DspInterface dsp) { Scroll(dsp, dsp->Vissible.x, dsp->Vissible.y + ScrollPitch); } diff --git a/src/xwinman.c b/src/xwinman.c index b268b9e..6a0b900 100644 --- a/src/xwinman.c +++ b/src/xwinman.c @@ -29,6 +29,7 @@ static char *id = "$Id: xwinman.c,v 1.3 2001/12/26 22:17:07 sybalsky Exp $ Copyr #include "lispemul.h" #include "devif.h" #include "xdefs.h" +#include "xscroll.h" int Mouse_Included = FALSE; @@ -60,10 +61,7 @@ int bound(a, b, c) int a, b, c; return (b); } -void Set_BitGravity(event, dsp, window, grav) XButtonEvent *event; -DspInterface dsp; -Window window; -int grav; +void Set_BitGravity(XButtonEvent *event, DspInterface dsp, Window window, int grav) { XSetWindowAttributes Lisp_SetWinAttributes; Window OldWindow; @@ -87,8 +85,7 @@ int grav; XUNLOCK; } /* end Set_BitGravity */ -void lisp_Xconfigure(dsp, x, y, lspWinWidth, lspWinHeight) DspInterface dsp; -int x, y, lspWinWidth, lspWinHeight; +void lisp_Xconfigure(DspInterface dsp, int x, int y, int lspWinWidth, int lspWinHeight) { int GravSize, Col2, Row2, Col3, Row3; @@ -142,7 +139,7 @@ int x, y, lspWinWidth, lspWinHeight; XUNLOCK; } /* end lisp_Xconfigure */ -void enable_Xkeyboard(dsp) DspInterface dsp; +void enable_Xkeyboard(DspInterface dsp) { XLOCK; XSelectInput(dsp->display_id, dsp->DisplayWindow, dsp->EnableEventMask); @@ -150,7 +147,7 @@ void enable_Xkeyboard(dsp) DspInterface dsp; XUNLOCK; } -void disable_Xkeyboard(dsp) DspInterface dsp; +void disable_Xkeyboard(DspInterface dsp) { XLOCK; XSelectInput(dsp->display_id, dsp->DisplayWindow, dsp->DisableEventMask); @@ -158,7 +155,7 @@ void disable_Xkeyboard(dsp) DspInterface dsp; XUNLOCK; } -void beep_Xkeyboard(dsp) DspInterface dsp; +void beep_Xkeyboard(DspInterface dsp) { #ifdef TRACE printf("TRACE: beep_Xkeyboard()\n"); @@ -181,7 +178,7 @@ void beep_Xkeyboard(dsp) DspInterface dsp; extern int Current_Hot_X, Current_Hot_Y; /* Cursor hotspot */ -void getXsignaldata(dsp) DspInterface dsp; +void getXsignaldata(DspInterface dsp) { XEvent report; @@ -261,14 +258,14 @@ void getXsignaldata(dsp) DspInterface dsp; switch (report.xbutton.button) { case Button1: DefineCursor(dsp->display_id, dsp->HorScrollBar, &ScrollLeftCursor); - ScrollLeft(dsp, report); + ScrollLeft(dsp); break; case Button2: DefineCursor(dsp->display_id, dsp->HorScrollBar, &HorizThumbCursor); break; case Button3: DefineCursor(dsp->display_id, dsp->HorScrollBar, &ScrollRightCursor); - ScrollRight(dsp, report); + ScrollRight(dsp); break; default: break; } /* end switch */ From 224e6478bd4ad69fe772dd6a705e1f567e5bcced Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 8 Jun 2017 08:24:41 -0700 Subject: [PATCH 25/27] Fix warning for comment within comment. modified: vmemsave.c --- src/vmemsave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vmemsave.c b/src/vmemsave.c index b3139e1..7b2f5d8 100644 --- a/src/vmemsave.c +++ b/src/vmemsave.c @@ -586,7 +586,7 @@ void lisp_finish() { /* following 5 lines don't work well. */ d[0] = 'E'; d[3] = 1; - /* These only happen if the fork really succeeded: + /* These only happen if the fork really succeeded: */ /* if (UnixPipeOut >= 0) write(UnixPipeOut, d, 4); */ /* if (UnixPipeIn >= 0 read(UnixPipeIn, d, 4);*/ /* Make sure it's finished */ /* if (UnixPID >= 0) kill(UnixPID, SIGKILL);*/ /* Then kill fork_Unix itself */ From eae092e02b89d2c31d052c8ebde7b89973649936 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 8 Jun 2017 08:46:54 -0700 Subject: [PATCH 26/27] Initialize keystring as empty string. Declare help string as const. Print the helpstring through a %s format rather than using it directly. Don't bother to check the address of allocated keystring for NULL. modified: main.c --- src/main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index abec01a..94c05c3 100644 --- a/src/main.c +++ b/src/main.c @@ -263,7 +263,7 @@ extern int maxpages; extern int *Lisp_errno; extern int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */ -char keystring[128]; +char keystring[128] = {""}; #define FALSE 0 #define TRUE !FALSE @@ -287,7 +287,7 @@ extern void dispatch(); int dosdisplaymode = 0; int twobuttonflag = FALSE; int eurokbd = TRUE; /* Assume eurokbd by default. */ -char *helpstring = +const char *helpstring = "\n\ medley [sysout-name] [] ...\n\ Where are:\n\ @@ -305,7 +305,7 @@ Where are:\n\ -info Print general info about the system\n\ -help Print this message\n"; #elif XWINDOW -char *helpstring = +const char *helpstring = "\n\ either setenv LDESRCESYSOUT or do:\n\ medley [] []\n\ @@ -317,7 +317,7 @@ char *helpstring = -g[eometry] ] The Medley screen geometry\n\ -sc[reen] x] The Medley screen geometry\n"; #else /* not DOS, not XWINDOW */ -char *helpstring = +const char *helpstring = "\n\ either setenv LDESRCESYSOUT or do:\n\ lde[ether] [sysout-name] [-k access-key] []\n\ @@ -382,7 +382,7 @@ char **argv; } if (argv[i] && ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "-HELP") == 0))) { - fprintf(stderr, helpstring); + fprintf(stderr, "%s", helpstring); exit(0); } @@ -400,7 +400,7 @@ char **argv; #endif /* DOS */ || access(sysout_name, R_OK)) { fprintf(stderr, "Couldn't find a sysout to run;\n"); - fprintf(stderr, helpstring); + fprintf(stderr, "%s", helpstring); exit(1); } /* OK, sysout name is now in sysout_name, and i is moved past a supplied name */ @@ -514,8 +514,7 @@ char **argv; } #endif /* DOS */ - if (keystring) /* key given, so safe to copy */ - strcpy(keytyped, keystring); + strcpy(keytyped, keystring); if (keytester(keystring)) { /* keytester destroys keystring */ fprintf(stderr, "Sorry, invalid or expired access key.\n"); From 208bce9b4070e7963a7f8adb71f2710e6af6aad4 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 8 Jun 2017 11:21:23 -0700 Subject: [PATCH 27/27] Use unsigned instead of int where, on modern systems, socklen_t would be appropriate. --- src/inet.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/inet.c b/src/inet.c index 4da6f6d..ef21afc 100644 --- a/src/inet.c +++ b/src/inet.c @@ -95,6 +95,7 @@ LispPTR nameConn, proto, length, bufaddr, maxlen; { #ifndef DOS int sock, len, buflen, res; + unsigned ures; char namestring[100]; char servstring[50]; struct sockaddr_in addr; @@ -149,8 +150,7 @@ LispPTR nameConn, proto, length, bufaddr, maxlen; return (GetSmallp(result)); break; - - case TCPconnect: /* args: hostname, socket# */ + case TCPconnect: /* args: hostname or (fixp)address, socket# */ memset(&farend, 0, sizeof farend); N_GETNUMBER(nameConn, res, string_host); farend.sin_addr.s_addr = htons(res); @@ -326,9 +326,9 @@ LispPTR nameConn, proto, length, bufaddr, maxlen; case INETpeername: /* socket#, buffer for name string */ sock = LispNumToCInt(nameConn); buffer = (char *)Addr68k_from_LADDR(proto); - res = sizeof(addr); - getpeername(sock, (struct sockaddr *)&addr, &res); - host = gethostbyaddr((const char *)&addr, res, AF_INET); + ures = sizeof(addr); + getpeername(sock, (struct sockaddr *)&addr, &ures); + host = gethostbyaddr((const char *)&addr, ures, AF_INET); strcpy(buffer, host->h_name); return (GetSmallp(strlen(host->h_name))); break; @@ -336,9 +336,9 @@ LispPTR nameConn, proto, length, bufaddr, maxlen; case INETgetname: /* host addr, buffer for name string */ sock = LispNumToCInt(nameConn); buffer = (char *)Addr68k_from_LADDR(proto); - res = sizeof(addr); + ures = sizeof(addr); addr.sin_addr.s_addr = sock; - host = gethostbyaddr((const char *)&addr, res, 0); + host = gethostbyaddr((const char *)&addr, ures, 0); if (!host) return (GetSmallp(0)); strcpy(buffer, host->h_name); return (GetSmallp(strlen(host->h_name))); @@ -407,8 +407,8 @@ LispPTR nameConn, proto, length, bufaddr, maxlen; sock = LispNumToCInt(nameConn); buffer = (char *)Addr68k_from_LADDR(proto); buflen = LispNumToCInt(length); - res = sizeof farend; - if ((result = recvfrom(sock, buffer, buflen, 0, (struct sockaddr *)&farend, &res)) < 0) { + ures = sizeof farend; + if ((result = recvfrom(sock, buffer, buflen, 0, (struct sockaddr *)&farend, &ures)) < 0) { perror("UDP Recv"); return (NIL); }