[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] RE: grn
From: |
Egil Kvaleberg |
Subject: |
Re: [Groff] RE: grn |
Date: |
Thu, 17 Feb 2000 05:40:00 +0100 (MET) |
> I'm not able to compile this on my Linux box -- apparently this
> program (written for X11R4) is not compatible with X11R6.
The main problem is that the program does not check the return value from
XAllocColorCells(), which would fail on modern non-index true colour
displays.
The subsequent XStoreNamedColor() then leaves X in a bad state, which
causes the font calls to fail in a big way.
I've added a fix for this - which at least removes the crash. The
complete patch enclosed also attempts to clean up various other issues re.
use of select(), (re)defining libc stuff in the program, updating changes
in the X interface, etc.
That said, I really can't understand what the purpose of this program is
- since xfig seems to be a much better alternative. Or is there something
I haven't understood?
Egil
--
Email: address@hidden Voice: +47 22523641, 92022780 Fax: +47 22525899
Mail: Egil Kvaleberg, Husebybakken 14A, 0379 Oslo, Norway
Home: http://www.kvaleberg.com/
*** Makefile.orig Sat Jul 13 19:17:39 1991
--- Makefile Thu Feb 17 02:17:46 2000
***************
*** 1,4 ****
INC = -I/usr/local/include -ISX
! CFLAGS = -O ${INC} '-DGREMLIB="/usr/local/libdata/gremlin/"'
SRC = db.c display.c feedback.c graphics.c graphics2.c help.c help1.c \
icondata.c inter.c long1.c long2.c main.c menu.c path.c pix.c \
--- 1,5 ----
INC = -I/usr/local/include -ISX
! # *EK*
! CFLAGS = -g -O ${INC} '-DGREMLIB="/usr/local/libdata/gremlin/"'
SRC = db.c display.c feedback.c graphics.c graphics2.c help.c help1.c \
icondata.c inter.c long1.c long2.c main.c menu.c path.c pix.c \
*** db.c.orig Mon Nov 28 21:17:28 1988
--- db.c Thu Feb 17 01:47:21 2000
***************
*** 13,16 ****
--- 13,18 ----
#include "gremlin.h"
+ #include <stdlib.h>
+ #include <string.h>
#include <ctype.h>
***************
*** 21,29 ****
extern UNRembMod();
- /* imports from C */
-
- extern char *malloc();
- extern char *strcpy();
-
/* imports from point.c */
--- 23,26 ----
*** graphics.c.orig Mon Oct 8 19:08:53 1990
--- graphics.c Thu Feb 17 03:39:09 2000
***************
*** 13,16 ****
--- 13,17 ----
#include <math.h>
#include <sys/types.h>
+ #include <stdlib.h>
#include "icondata.h"
#include "gremlin.h"
***************
*** 38,45 ****
extern minsunx, maxsunx, minsuny, maxsuny;
- /* imports from C */
-
- extern char *malloc();
-
/* forward references */
--- 39,42 ----
***************
*** 802,805 ****
--- 799,803 ----
{
char name[256];
+ name[sizeof(name)-1] = '\0';
if (font_info[--font][--size] != (XFontStruct *)NULL) {
***************
*** 814,822 ****
* normal font.
*/
! sprintf(name, "gremlin-%s-%d",font_types[font], size+1);
font_info[font][size] = XLoadQueryFont(display, name);
if (font_info[font][size] == (XFontStruct *)NULL) {
! sprintf(name, font_names[font], font_sizes[size]);
font_info[font][size] = XLoadQueryFont(display, name);
--- 812,820 ----
* normal font.
*/
! snprintf(name, sizeof(name)-1, "gremlin-%s-%d",font_types[font], size+1);
font_info[font][size] = XLoadQueryFont(display, name);
if (font_info[font][size] == (XFontStruct *)NULL) {
! snprintf(name, sizeof(name)-1, font_names[font], font_sizes[size]);
font_info[font][size] = XLoadQueryFont(display, name);
*** graphics2.c.orig Mon Oct 8 19:08:56 1990
--- graphics2.c Thu Feb 17 03:39:12 2000
***************
*** 13,16 ****
--- 13,17 ----
#include "gremlin.h"
+ #include <stdlib.h>
/* imports from main.c */
***************
*** 42,49 ****
extern char *fill; /* zero origin in filling buffer */
- /* imports from C */
-
- extern char *calloc();
-
/* locals */
--- 43,46 ----
*** inter.c.orig Mon Dec 12 22:43:12 1988
--- inter.c Thu Feb 17 01:48:06 2000
***************
*** 10,13 ****
--- 10,14 ----
#include "icondata.h"
#include "gremlin.h"
+ #include <stdlib.h>
/* imports from database files */
***************
*** 68,75 ****
#define LAST 2 /* option to erase */
- /* imports from C */
-
- extern char *malloc();
-
/* imports from main.c */
--- 69,72 ----
*** long1.c.orig Tue Sep 12 18:03:35 1989
--- long1.c Thu Feb 17 01:48:25 2000
***************
*** 18,21 ****
--- 18,23 ----
#include "gremlin.h"
#include <ctype.h>
+ #include <stdlib.h>
+ #include <string.h>
/* imports from icondata.c */
***************
*** 88,96 ****
extern text_getvalue();
- /* imports from C */
-
- extern char *malloc();
- extern char *strcpy();
-
/* imports from main.c */
--- 90,93 ----
*** long2.c.orig Sat Nov 5 22:46:07 1988
--- long2.c Thu Feb 17 03:39:29 2000
***************
*** 12,15 ****
--- 12,17 ----
#include <sys/file.h>
+ #include <string.h>
+ #include <stdlib.h>
#include "gremlin.h"
#include <ctype.h>
***************
*** 78,89 ****
extern HiMode[];
- /* imports from C */
-
- extern char *strcpy();
- extern char *sprintf();
- extern char *malloc();
- extern FILE *fopen();
- extern char *strcat();
-
/* imports from sun.c */
--- 80,83 ----
*** main.c.orig Sat Dec 2 08:33:22 1989
--- main.c Thu Feb 17 04:31:25 2000
***************
*** 13,16 ****
--- 13,17 ----
* Jim Thompson (address@hidden)
* Mike Nelson (address@hidden)
+ * Egil Kvaleberg (address@hidden) *EK*
*
*/
***************
*** 18,24 ****
--- 19,28 ----
#include <ctype.h>
#include <errno.h>
+ #include <string.h>
+ #include <stdlib.h>
#include <sys/time.h>
#include <sys/file.h>
#include <signal.h>
+ #include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
***************
*** 82,92 ****
extern SHUpdate();
- /* imports from C */
-
- extern char *malloc();
- extern char *sprintf();
- extern char *strcat();
- extern char *strcpy();
-
/* imports from strings.c */
--- 86,89 ----
***************
*** 201,206 ****
unsigned int xorOP;
Colormap colorMap;
- unsigned int planeMask;
- unsigned long pixel;
/* Title subwindow stuff */
--- 198,201 ----
***************
*** 289,292 ****
--- 284,288 ----
int dum;
struct timeval curTime;
+ unsigned long planeMask;
file = "";
***************
*** 329,332 ****
--- 325,329 ----
*/
display = XOpenDisplay((char *) NULL);
+
SetErrorHandler();
if (display == (Display *)NULL) {
***************
*** 377,381 ****
}
! strcpy(namestripe, version);
/*
--- 374,378 ----
}
! strncpy(namestripe, version, sizeof(namestripe)-1);
/*
***************
*** 383,386 ****
--- 380,386 ----
*/
if (root_depth == 1) {
+ /*
+ * Pure black/white display
+ */
foreground = BlackPixel(display, DefaultScreen(display));
background = WhitePixel(display, DefaultScreen(display));
***************
*** 397,405 ****
} else {
XColor color;
/*
! * Allocate contiguous color map entries for black and white.
*/
colorMap = XDefaultColormap(display, DefaultScreen(display));
XAllocColorCells(display, colorMap, 1, &planeMask, 1, &pixel, 1);
foreground = pixel | planeMask;
background = pixel;
--- 397,414 ----
} else {
XColor color;
+ Status status;
+ unsigned long pixel;
/*
! * Assume indexed display:
! * Allocate contiguous color map entries for black and white
*/
colorMap = XDefaultColormap(display, DefaultScreen(display));
+ status =
XAllocColorCells(display, colorMap, 1, &planeMask, 1, &pixel, 1);
+
+ if (status != 0) {
+ /*
+ * Request OK
+ */
foreground = pixel | planeMask;
background = pixel;
***************
*** 411,415 ****
--- 420,446 ----
XStoreNamedColor(display, colorMap, "white", background,
DoRed | DoGreen | DoBlue);
+ } else {
+ /*EK*
+ * Can't allocate color maps, presumably non-indexed display
+ */
+ foreground = BlackPixel(display, DefaultScreen(display));
+ background = WhitePixel(display, DefaultScreen(display));
+ #if 0
+ printf("foreground=%08lx\n", foreground);
+ printf("background=%08lx\n", background);
+ #endif
+ if (foreground != 0) {
+ drawOP = GXor;
+ menuEraseOP = GXandInverted;
+ xorOP = GXxor;
+ } else {
+ drawOP = GXand;
+ menuEraseOP = GXorInverted;
+ xorOP = GXequiv;
+ }
+ planeMask = foreground | background;
}
+ }
+
text_pf = XLoadQueryFont(display, text_font);
if (text_pf == NULL) {
***************
*** 529,533 ****
while (1) {
! int readmask;
int nfds;
int numEvents;
--- 560,564 ----
while (1) {
! fd_set readmask;
int nfds;
int numEvents;
***************
*** 590,595 ****
waitTime.tv_usec = timeoff_usec;
}
! readmask = 1 << display->fd;
! nfds = select(32, &readmask, (int *)0, (int *)0, &waitTime);
if (nfds < 0 && errno != EINTR) {
perror("Select");
--- 621,627 ----
waitTime.tv_usec = timeoff_usec;
}
! FD_ZERO(&readmask);
! FD_SET(ConnectionNumber(display), &readmask);
! nfds = select(32, &readmask, (fd_set *)0, (fd_set *)0,
&waitTime);
if (nfds < 0 && errno != EINTR) {
perror("Select");
***************
*** 737,741 ****
cset_pm.pm = XCreatePixmap(display, root_window, root_width,
root_height, root_depth);
! if (cset_pm.pm == NULL) {
printf("can't create cset_pm\n");
exit(1);
--- 769,773 ----
cset_pm.pm = XCreatePixmap(display, root_window, root_width,
root_height, root_depth);
! if (!cset_pm.pm) {
printf("can't create cset_pm\n");
exit(1);
***************
*** 749,753 ****
scratch_pm.pm = XCreatePixmap(display, root_window,
root_width, root_height, root_depth);
! if (scratch_pm.pm == NULL) {
printf("can't create scratch_pm\n");
exit(1);
--- 781,785 ----
scratch_pm.pm = XCreatePixmap(display, root_window,
root_width, root_height, root_depth);
! if (!scratch_pm.pm) {
printf("can't create scratch_pm\n");
exit(1);
***************
*** 1169,1172 ****
--- 1201,1221 ----
return 0;
}
+
+ /*EK*
+ * tell about the problem
+ */
+ {
+ static char bufret[1024];
+
+ fprintf(stderr,"\nAn X error occurred, request %d:\n",
+ errorPtr->request_code);
+ fflush(stderr);
+
+ XGetErrorText(display, errorPtr->error_code, bufret, sizeof(bufret));
+
+ fprintf(stderr,"\nError: %s\n",bufret);
+ fflush(stderr);
+ }
+
abort();
return (*savedHandler)(display, errorPtr);
*** path.c.orig Fri Nov 4 03:26:42 1988
--- path.c Thu Feb 17 03:19:32 2000
***************
*** 12,15 ****
--- 12,17 ----
#include "gremlin.h"
+ #include <stdlib.h>
+ #include <string.h>
#include <pwd.h>
#include <ctype.h>
***************
*** 20,31 ****
extern char GLibrary[];
- /* imports from C */
-
- extern char *strcpy();
- extern char *strncpy();
- extern char *index();
- extern char *sprintf();
- extern char *malloc();
-
/*
* The following string holds the current path, consisting of a bunch
--- 22,25 ----
*** point.c.orig Sat Oct 29 01:01:10 1988
--- point.c Thu Feb 17 01:48:49 2000
***************
*** 10,13 ****
--- 10,14 ----
#include "gremlin.h"
+ #include <stdlib.h>
/* imports from graphics.c */
***************
*** 15,22 ****
extern GRFontStrlen();
- /* imports from C */
-
- extern char *malloc();
-
/*
--- 16,19 ----
*** short.c.orig Fri Nov 4 03:26:54 1988
--- short.c Thu Feb 17 01:49:07 2000
***************
*** 11,14 ****
--- 11,15 ----
#include "icondata.h"
#include "gremlin.h"
+ #include <stdlib.h>
/* imports from graphics files */
***************
*** 82,89 ****
extern prompt_ok();
- /* imports from C */
-
- extern char *malloc();
-
/* imports from main.c */
--- 83,86 ----
*** spline.c.orig Fri Nov 4 03:26:58 1988
--- spline.c Thu Feb 17 03:19:38 2000
***************
*** 12,16 ****
*/
- #include <stdio.h>
#include "gremlin.h"
--- 12,15 ----
*** startup.c.orig Fri Aug 25 20:56:50 1989
--- startup.c Thu Feb 17 02:18:49 2000
***************
*** 15,24 ****
#include <ctype.h>
#include "icondata.h"
!
! /* imports from C */
!
! extern char *malloc();
! extern char *strncpy();
! extern FILE *fopen();
/* imports from path.c */
--- 15,21 ----
#include <ctype.h>
#include "icondata.h"
! #include <string.h>
! #include <stdlib.h>
! #include <string.h>
/* imports from path.c */
***************
*** 87,91 ****
/* The following are defined to allow creation of the command lookup table. */
! extern ST1(), ST2(), ST3(), ST4(), STB(), STI(), STR(), STS(),
STalign(), STbrush(), STflashoff(), STflashon(), STfont(), STfontdir(),
STgravity(), STgrid(), SThadjust(), STjustify(), STlittlepoint(),
--- 84,88 ----
/* The following are defined to allow creation of the command lookup table. */
! static ST1(), ST2(), ST3(), ST4(), STB(), STI(), STR(), STS(),
STalign(), STbrush(), STflashoff(), STflashon(), STfont(), STfontdir(),
STgravity(), STgrid(), SThadjust(), STjustify(), STlittlepoint(),
*** strings.c.orig Fri Aug 25 20:52:24 1989
--- strings.c Thu Feb 17 04:22:12 2000
***************
*** 19,23 ****
#ifndef FONTFILE
! #define FONTFILE "*-*-*-medium-r-normal--12-*-*-*-m-*-*"
#endif
char text_font[] = FONTFILE;
--- 19,23 ----
#ifndef FONTFILE
! #define FONTFILE "-*-*-medium-r-normal--12-*-*-*-m-*-*-*"
#endif
char text_font[] = FONTFILE;
*** text.c.orig Tue May 30 18:18:27 1989
--- text.c Thu Feb 17 04:29:42 2000
***************
*** 8,14 ****
--- 8,20 ----
*/
+ #if 0 /*EK* BSD-specific */
#include <sgtty.h>
+ /* #include <bsd/sgtty.h> *EK* Linux specific */
+ #endif
+
+ #include <sys/ioctl.h>
#include "gremlin.h"
#include "icondata.h"
+ #include <string.h>
/* imports from main.c */
***************
*** 37,44 ****
extern char text_font[];
- /* imports from C */
-
- extern char *strcpy();
-
/* locals */
--- 43,46 ----
***************
*** 309,312 ****
--- 311,315 ----
TxInit()
{
+ #if 0 /*EK* BSD-specific */
struct sgttyb sgtty_buf;
***************
*** 315,318 ****
--- 318,326 ----
text_kill = sgtty_buf.sg_kill;
text_erase_word = CTRL_W;
+ #else
+ text_erase = CTRL_H;
+ text_kill = CTRL_U;
+ text_erase_word = CTRL_W;
+ #endif
text_length = text_next = mesg_length = 0;
*** undodb.c.orig Sat Oct 29 01:01:26 1988
--- undodb.c Thu Feb 17 01:50:01 2000
***************
*** 10,13 ****
--- 10,15 ----
#include "gremlin.h"
+ #include <stdlib.h>
+ #include <string.h>
/* The following are used to point to the undo database lists */
***************
*** 20,28 ****
POINT *PTMakePoint();
- /* imports from C */
-
- extern char *malloc();
- extern char *strcpy();
-
/* imports from db.c */
--- 22,25 ----
*** xmenu.c.orig Thu Jul 11 05:24:33 1991
--- xmenu.c Thu Feb 17 02:19:23 2000
***************
*** 66,73 ****
*/
! extern void ComputeMenuLayout();
! extern void MenuEntryDisplay();
! extern int MenuEventProc();
! extern void MenuInit();
--- 66,73 ----
*/
! static void ComputeMenuLayout();
! static void MenuEntryDisplay();
! static int MenuEventProc();
! static void MenuInit();
*** SX/Makefile.orig Sat Jul 13 18:58:13 1991
--- SX/Makefile Thu Feb 17 02:12:35 2000
***************
*** 11,15 ****
LIBS = -L /usr/local/lib -lX11
! CFLAGS = -O -I. -I/usr/local/include
sx.a: ${OBJS}
--- 11,16 ----
LIBS = -L /usr/local/lib -lX11
! # *EK*
! CFLAGS = -g -O -I. -I/usr/local/include
sx.a: ${OBJS}
*** SX/sxEntry.c.orig Fri Aug 25 20:37:38 1989
--- SX/sxEntry.c Thu Feb 17 01:58:30 2000
***************
*** 339,343 ****
w = XCreateSimpleWindow(display, parent, x, y, width, height,
borderSize, foreground, background);
! if (w == NULL) {
Sx_Panic(display, "Sx_EntryCreate: couldn't create new window.");
}
--- 339,343 ----
w = XCreateSimpleWindow(display, parent, x, y, width, height,
borderSize, foreground, background);
! if (!w) {
Sx_Panic(display, "Sx_EntryCreate: couldn't create new window.");
}
***************
*** 474,478 ****
! if ((eventPtr->subwindow != NULL)
&& (eventPtr->subwindow != entryPtr->w)) {
return;
--- 474,478 ----
! if ((eventPtr->subwindow)
&& (eventPtr->subwindow != entryPtr->w)) {
return;
*** SX/sxMenu.c.orig Thu May 16 11:18:26 1991
--- SX/sxMenu.c Thu Feb 17 01:59:01 2000
***************
*** 775,779 ****
if (XFindContext(display, parent, groupContext, &data) != 0) {
! return NULL;
}
groupPtr = (MenuGroup *) data;
--- 775,779 ----
if (XFindContext(display, parent, groupContext, &data) != 0) {
! return (Window) NULL;
}
groupPtr = (MenuGroup *) data;
***************
*** 788,792 ****
}
}
! return NULL;
}
--- 788,792 ----
}
}
! return (Window) NULL;
}
*** SX/sxPack.c.orig Fri Aug 25 20:37:41 1989
--- SX/sxPack.c Thu Feb 17 02:00:00 2000
***************
*** 268,272 ****
! if (before != NULL) {
if ((XFindContext(display, before, packingContext,
(caddr_t *) &child2Ptr) != 0)
--- 268,272 ----
! if (before) {
if ((XFindContext(display, before, packingContext,
(caddr_t *) &child2Ptr) != 0)
***************
*** 367,371 ****
caddr_t data;
! if (packingContext == NULL) {
return;
}
--- 367,371 ----
caddr_t data;
! if (!packingContext) {
return;
}
*** SX/sxScrollbar.c.orig Fri Aug 25 20:37:41 1989
--- SX/sxScrollbar.c Thu Feb 17 02:00:24 2000
***************
*** 719,723 ****
int units;
! if ((eventPtr->subwindow != NULL)
&& (eventPtr->subwindow != sbPtr->window)) {
return;
--- 719,723 ----
int units;
! if ((eventPtr->subwindow)
&& (eventPtr->subwindow != sbPtr->window)) {
return;
*** SX/sxSelect.c.orig Fri Aug 25 20:37:42 1989
--- SX/sxSelect.c Thu Feb 17 02:08:48 2000
***************
*** 280,287 ****
{
Window owner;
! char *ownerBuffer;
Request request;
Answer *ansPtr;
! int totalCount, actualFormat, bytesAfter, numItems, result;
Atom actualType;
--- 280,288 ----
{
Window owner;
! unsigned char *ownerBuffer;
Request request;
Answer *ansPtr;
! long bytesAfter, numItems;
! int totalCount, actualFormat, result;
Atom actualType;
***************
*** 341,345 ****
RootWindow(display, DefaultScreen(display)), answerProperty,
0, sizeof(Answer), True, stringAtom, &actualType,
! &actualFormat, &numItems, &bytesAfter, (char **) &ansPtr);
if (result != 0) {
return -1;
--- 342,347 ----
RootWindow(display, DefaultScreen(display)), answerProperty,
0, sizeof(Answer), True, stringAtom, &actualType,
! &actualFormat, &numItems, &bytesAfter,
! (unsigned char **) &ansPtr);
if (result != 0) {
return -1;
***************
*** 443,447 ****
Request *reqPtr;
Answer answer;
! int numItems, bytesAfter, actualFormat, length, result;
Atom actualType;
--- 445,450 ----
Request *reqPtr;
Answer answer;
! long numItems, bytesAfter;
! int actualFormat, length, result;
Atom actualType;
***************
*** 463,467 ****
requestProperty, 0, sizeof(Request), True, stringAtom,
&actualType, &actualFormat, &numItems, &bytesAfter,
! (char **) &reqPtr);
if (result != 0) {
return;
--- 466,470 ----
requestProperty, 0, sizeof(Request), True, stringAtom,
&actualType, &actualFormat, &numItems, &bytesAfter,
! (unsigned char **) &reqPtr);
if (result != 0) {
return;
***************
*** 544,549 ****
Display *display; /* Connection to X server. */
{
! char *ownerBuffer;
! int result, actualFormat, numItems, bytesAfter;
Atom actualType;
Window owner;
--- 547,553 ----
Display *display; /* Connection to X server. */
{
! unsigned char *ownerBuffer;
! int result, actualFormat;
! long numItems, bytesAfter;
Atom actualType;
Window owner;
***************
*** 619,623 ****
{
XEvent event;
! int mask, numFound;
struct timeval timeout;
--- 623,628 ----
{
XEvent event;
! fd_set mask;
! int numFound;
struct timeval timeout;
***************
*** 637,643 ****
timeout.tv_sec = 3;
timeout.tv_usec = 0;
! mask = 1 << ConnectionNumber(display);
numFound = select(ConnectionNumber(display) + 1,
! &mask, (int *) 0, (int *) 0, &timeout);
if (numFound <= 0) {
return 0;
--- 642,649 ----
timeout.tv_sec = 3;
timeout.tv_usec = 0;
! FD_ZERO(&mask);
! FD_SET(ConnectionNumber(display),&mask);
numFound = select(ConnectionNumber(display) + 1,
! &mask, (fd_set *) 0, (fd_set *) 0, &timeout);
if (numFound <= 0) {
return 0;
*** SX/sxUtils.c.orig Fri Aug 25 20:37:42 1989
--- SX/sxUtils.c Thu Feb 17 02:03:24 2000
***************
*** 193,197 ****
XFlush(display);
! (void) select(0, (int *) 0, (int *) 0, (int *) 0, &delay);
}
--- 193,197 ----
XFlush(display);
! (void) select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &delay);
}
- [Groff] RE: grn, Werner LEMBERG, 2000/02/16
- Re: [Groff] RE: grn,
Egil Kvaleberg <=
- [Groff] RE: grn, Daniel Senderowicz, 2000/02/16
- Re: [Groff] RE: grn, Daniel Senderowicz, 2000/02/17
- Re: [Groff] RE: grn, Daniel Senderowicz, 2000/02/17
- Re: [Groff] RE: grn, Daniel Senderowicz, 2000/02/18
- Re: [Groff] RE: grn, Daniel Senderowicz, 2000/02/18