Kill most warnings in lib/DtTerm.

Mostly missing headers, explicit parentheses and new prototypes.

Some Caveats:
* I haven't compile-tested the SVR4 getpty file, it might need another tweak
* There were operator precedence bugs in TermPrimCursor.c and TermPrimRender.c
  (^ vs. !=).  This might change behaviour, but at least I haven't experienced
  any crashes ...
* This adds a little more dependencies for include ordering, but unless we
  want to play the "headers that include headers that include headers..." game,
  this is unavoidable.
This commit is contained in:
Pascal Stumpf
2013-07-22 12:34:15 +02:00
committed by Jon Trulson
parent 8f98ac92cd
commit dc0e8ea74d
43 changed files with 437 additions and 285 deletions

View File

@@ -49,16 +49,20 @@ extern char * _DtTermPrimGetMessage( char *filename, int set, int n, char *s );
#include <Xm/MessageB.h>
#include <Xm/XmP.h>
#include <Xm/DisplayP.h>
#include <Xm/XmPrivate.h>
#include <Xm/VirtKeys.h>
#include <Xm/MwmUtil.h>
#include <Xm/DrawP.h>
#include "TermHeader.h"
#include "TermPrimOSDepI.h" /* for SETENV_LINES_AND_COLS */
#include "TermPrimI.h"
#include "TermPrimP.h"
#include "TermPrimBufferP.h"
#include "TermPrimAction.h"
#include "TermPrimGetPty.h"
#include "TermPrimParser.h"
#include "TermPrimParseTable.h"
#include "TermPrimPendingText.h"
#include "TermPrimPendingTextP.h"
#include "TermPrimRenderFont.h"
#include "TermPrimRenderFontSet.h"
@@ -76,6 +80,7 @@ extern char * _DtTermPrimGetMessage( char *filename, int set, int n, char *s );
#include <signal.h>
#include <ctype.h>
#include <nl_types.h>
#include <wchar.h>
#if defined(linux) || defined(hpV4)
# include <sys/types.h> /* For FD_* macros. */
# include <sys/time.h> /* For select() prototype. */
@@ -679,7 +684,7 @@ _DtTermPrimGetFontSet
* "Assignment in conditional 'while' expression."...
*/
/*SUPPRESS 624*/
while (fontListEntry = XmFontListNextEntry(fontContext)) {
while ((fontListEntry = XmFontListNextEntry(fontContext))) {
pointer = XmFontListEntryGetFont(fontListEntry, &fontType);
if (fontType == XmFONT_IS_FONTSET) {
int i;
@@ -2386,7 +2391,7 @@ Realize(Widget w, XtValueMask *p_valueMask, XSetWindowAttributes *attributes)
* register input method, and set callbacks for on the spot
* support.
*/
(void) XmImRegister(w, (unsigned int) NULL);
(void) XmImRegister(w, 0);
imPoint.x = 0;
imPoint.y = 0;

View File

@@ -38,8 +38,11 @@ static char rcs_id[] = "$XConsortium: TermPrimBuffer.c /main/1 1996/04/21 19:16:
#define USE_MEMCPY /* use memcpy for line movement... */
#include <wchar.h>
#include <Xm/Xm.h>
#include "TermHeader.h" /* for MIN/MAX */
#include "TermPrim.h"
#include "TermPrimBuffer.h"
#include "TermPrimBufferP.h"
#include "TermPrimSelect.h"
#include "TermPrimDebug.h"

View File

@@ -662,6 +662,17 @@ _DtTermPrimBufferSetInSelectionFlag
short row,
TermLineSelection state
);
extern void
_DtTermPrimBufferSetSelectLines
(
TermBuffer tb,
short beginRow,
short beginCol,
short endRow,
short endCol
);
#ifdef __cplusplus
} /* close scope of 'extern "C"'... */
#endif /* __cplusplus */

View File

@@ -174,6 +174,29 @@ typedef struct _TermBufferRec
TermBufferPart term_buffer;
} TermBufferRec;
extern
short
_DtTermPrimBufferInsertWc
(
const TermBuffer tb,
const short row,
const short col,
wchar_t *newChars,
short numChars,
Boolean insertFlag,
termChar **returnChars,
short *returnLength
);
extern
Boolean
_DtTermPrimBufferClearLineWc
(
const TermBuffer tb,
const short row,
short newWidth
);
#ifdef __cplusplus
} /* close scope of 'extern "C"'... */
#endif /* __cplusplus */

View File

@@ -38,8 +38,10 @@ static char rcs_id[] = "$XConsortium: TermPrimBufferWc.c /main/1 1996/04/21 19:1
#define USE_MEMCPY /* use memcpy for line movement... */
#include <wchar.h>
#include <Xm/Xm.h>
#include "TermHeader.h" /* for MIN/MAX */
#include "TermPrim.h"
#include "TermPrimOSDepI.h"
#include "TermPrimBufferP.h"
#include "TermPrimDebug.h"

View File

@@ -36,8 +36,12 @@ static char rcs_id[] = "$XConsortium: TermPrimCursor.c /main/1 1996/04/21 19:17:
* (c) Copyright 1996 Hitachi. *
*/
#include <Xm/ScrollBar.h>
#include <Xm/XmPrivate.h>
#include "TermHeader.h"
#include "TermPrimDebug.h"
#include "TermPrimI.h"
#include "TermPrimP.h"
#include "TermPrimData.h"
#include "TermPrimLineDraw.h"
@@ -322,7 +326,7 @@ _DtTermPrimCursorOn(Widget w)
}
/* set the GC... */
if (tpd->cursorGC.foreground != enhInfo.fg ^ enhInfo.bg) {
if (tpd->cursorGC.foreground != (enhInfo.fg ^ enhInfo.bg)) {
tpd->cursorGC.foreground = enhInfo.fg ^ enhInfo.bg;
values.foreground = enhInfo.fg ^ enhInfo.bg;
valueMask |= GCForeground;

View File

@@ -138,7 +138,7 @@ setDebugFlags(char *c1)
argHead.next = (argArray *) 0;
argPtr = &argHead;
while (c3 = _XStrtok(c2, " \t\n", strtok_buf)) {
while ((c3 = _XStrtok(c2, " \t\n", strtok_buf))) {
/* null out c2 so we won't restart strtok... */
c2 = (char *) 0;
argPtr->next = (argArray *) malloc(sizeof(argArray));
@@ -151,7 +151,7 @@ setDebugFlags(char *c1)
for (argPtr = argHead.next; argPtr; argPtr = argPtr->next) {
charList = argPtr->str;
flagList = (char *) 0;
if (c2 = strchr(argPtr->str, ':')) {
if ((c2 = strchr(argPtr->str, ':'))) {
/* null out the ':'... */
*c2++ = '\0';
flagList = c2;
@@ -197,7 +197,7 @@ setDebugFlags(char *c1)
}
c3 = flagList;
while (flagList = _XStrtok(c3, ",", strtok_buf)) {
while ((flagList = _XStrtok(c3, ",", strtok_buf))) {
/* null out c3 so we won't restart strtok... */
c3 = (char *) 0;
if (!flagList || !*flagList) {

View File

@@ -58,5 +58,8 @@ extern unsigned char *debugLevel[256];
#define _TERM_DEBUG(c, a) \
_TERM_DEBUG_FLAG(c, 0, a)
void _DtTermPrimDebugDumpEvent (FILE *f, Widget w, XEvent *ev);
#endif /* _Dt_TermPrimDebug_h */
/* DON'T ADD ANYTHING AFTER THIS #endif... */

View File

@@ -33,11 +33,10 @@ static char rcs_id[] = "$XConsortium: TermPrimGetPty-bsd.c /main/4 1996/11/21 19
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include "TermPrimDebug.h"
#include "TermHeader.h"
#include <fcntl.h>
#include <termios.h>
#if defined(OPENBSD_ARCHITECTURE)
#include <sys/stat.h>
#include <util.h>
#endif
#include <sys/wait.h>
@@ -49,6 +48,10 @@ static char rcs_id[] = "$XConsortium: TermPrimGetPty-bsd.c /main/4 1996/11/21 19
#define X_INCLUDE_UNISTD_H
#define XOS_USE_XT_LOCKING
#include <X11/Xos_r.h>
#include "TermPrim.h"
#include "TermPrimDebug.h"
#include "TermPrimUtil.h"
#include "TermHeader.h"
typedef struct _ptyInfo {
char *ptyName;

View File

@@ -39,6 +39,7 @@ static char rcs_id[] = "$XConsortium: TermPrimGetPty-svr4.c /main/1 1996/04/21 1
* was basically taken intact as were the comments...
*/
#include "TermPrim.h"
#include "TermPrimOSDepI.h"
#include "TermPrimDebug.h"
#include "TermHeader.h"

View File

@@ -36,6 +36,8 @@ int _DtTermPrimGetPty(char **ptySlave, char **ptyMaster);
int _DtTermPrimSetupPty(char *ptySlave, int ptyFd);
void _DtTermPrimReleasePty(char *ptySlave);
void _DtTermPrimPtyCleanup();
int _DtTermPrimGetPty(char **ptySlave, char **ptyMaster);
void _DtTermPrimReleasePty(char *ptySlave);
#endif /* _Dt_TermPrimGetPty_h */
/* DON'T ADD ANYTHING AFTER THIS #endif... */

View File

@@ -47,12 +47,12 @@ static StateTableRec stateStart;
static StateEntryRec
startTable[] =
{
0x07, 0x07, &stateStart, _DtTermPrimParseBell, /* ring the bell */
0x08, 0x08, &stateStart, _DtTermPrimParseBackspace, /* backspace */
0x09, 0x09, &stateStart, _DtTermPrimParseTab, /* horizontal tab */
0x0A, 0x0A, &stateStart, _DtTermPrimParseLF, /* newline */
0x0D, 0x0D, &stateStart, _DtTermPrimParseCR, /* carriage return */
0x00, 0xFF, &stateStart, _DtTermPrimParseWriteChar, /* write to dpy */
{ 0x07, 0x07, &stateStart, _DtTermPrimParseBell, }, /* ring the bell */
{ 0x08, 0x08, &stateStart, _DtTermPrimParseBackspace, }, /* backspace */
{ 0x09, 0x09, &stateStart, _DtTermPrimParseTab, }, /* horizontal tab */
{ 0x0A, 0x0A, &stateStart, _DtTermPrimParseLF, }, /* newline */
{ 0x0D, 0x0D, &stateStart, _DtTermPrimParseCR, }, /* carriage return */
{ 0x00, 0xFF, &stateStart, _DtTermPrimParseWriteChar, }, /* write to dpy */
};
static StateTableRec stateStart = {True, startTable};

View File

@@ -36,6 +36,7 @@ static char rcs_id[] = "$TOG: TermPrimParser.c /main/2 1999/10/15 12:23:41 mgree
* (c) Copyright 1996 Hitachi. *
*/
#include <Xm/Xm.h>
#include "TermPrimDebug.h"
#include "TermPrimP.h"
#include "TermPrimParserP.h"

View File

@@ -278,7 +278,7 @@ _DtTermPrimPendingTextFlush
walkPendingText(list);
#endif /* DEBUG */
while (chunk = _DtTermPrimPendingTextGetChunk(list)) {
while ((chunk = _DtTermPrimPendingTextGetChunk(list))) {
(void) _DtTermPrimPendingTextRemoveChunk(list, chunk);
}
}

View File

@@ -120,6 +120,15 @@ _DtTermPrimPendingTextDestroy
PendingText ptr
);
extern
Boolean
_DtTermPrimPendingTextAppend
(
PendingText list,
unsigned char *text,
int len
);
#ifdef __cplusplus
} /* close scope of 'extern "C"'... */
#endif /* __cplusplus */

View File

@@ -43,7 +43,9 @@ static char rcs_id[] = "$TOG: TermPrimRender.c /main/3 1999/07/20 17:34:54 mgree
#include "TermPrimData.h"
#include "TermPrimLineDraw.h"
#include "TermPrimBufferP.h"
#include "TermPrimRender.h"
#include "TermPrimRenderP.h"
#include "TermPrimSelect.h"
#include "TermPrimSelectP.h"
#include "TermPrimMessageCatI.h"
#include <limits.h>
@@ -123,7 +125,7 @@ _DtTermPrimBell(Widget w)
* are done...
*/
if (tpd->renderGC.foreground !=
tw->primitive.foreground ^ tw->core.background_pixel) {
(tw->primitive.foreground ^ tw->core.background_pixel)) {
tpd->renderGC.foreground =
tw->primitive.foreground ^ tw->core.background_pixel;
(void) XSetForeground(XtDisplay(w), tpd->renderGC.gc,

View File

@@ -63,6 +63,8 @@ extern void _DtTermPrimExposeText(Widget w, int startX, int startY, int endX,
int endY, Boolean isExposeEvent);
extern int _DtTermPrimInsertText(Widget w, unsigned char *buffer, int length);
extern int _DtTermPrimInsertTextWc(Widget w, wchar_t *buffer, int length);
extern void _DtTermPrimRefreshTextWc(Widget w, short startColumn,
short startRow, short endColumn, short endRow);
extern Boolean
_DtTermPrimParseInput

View File

@@ -33,6 +33,8 @@ static char rcs_id[] = "$XConsortium: TermPrimRenderLineDraw.c /main/1 1996/04/2
* (c) Copyright 1993, 1994 Novell, Inc. *
*/
#include <wchar.h>
#include "TermHeader.h"
#include "TermPrimP.h"
#include "TermPrimDebug.h"

View File

@@ -48,8 +48,10 @@ static char rcs_id[] = "$XConsortium: TermPrimRenderMb.c /main/1 1996/04/21 19:1
#include "TermPrimOSDepI.h"
#include "TermPrimBufferP.h"
#include "TermPrimRenderP.h"
#include "TermPrimSelect.h"
#include "TermPrimSelectP.h"
#include <limits.h>
#include <wchar.h>
void
_DtTermPrimRefreshTextWc(Widget w, short startColumn, short startRow,

View File

@@ -514,11 +514,11 @@ _DtTermPrimScrollText(Widget w, short lines)
if (0 == lines)
return;
if (tw->term.jumpScroll &&
if ((tw->term.jumpScroll &&
((lines + tpd->scroll.jump.scrollLines) >
(tw->term.rows -
tpd->scrollLockTopRow -
(tw->term.rows - 1 - tpd->scrollLockBottomRow))) ||
(tw->term.rows - 1 - tpd->scrollLockBottomRow)))) ||
((lines + tpd->scroll.jump.scrollLines) <
-(tw->term.rows -
tpd->scrollLockTopRow -

View File

@@ -41,7 +41,9 @@ static char rcs_id[] = "$TOG: TermPrimSelect.c /main/6 1999/10/14 16:22:53 mgree
#include <Xm/Xm.h>
#include <Xm/AtomMgr.h>
#include <Xm/CutPaste.h>
#include <Xm/XmPrivate.h>
#include <Xm/ScrollBarP.h>
#include "TermPrimAction.h"
#include "TermPrimDebug.h"
#include "TermPrimP.h"
#include "TermPrimData.h"
@@ -51,7 +53,7 @@ static char rcs_id[] = "$TOG: TermPrimSelect.c /main/6 1999/10/14 16:22:53 mgree
#include <Xm/DropSMgr.h>
#include <Xm/DropTrans.h>
#if defined(USL)
#if defined(USL) || defined(OPENBSD_ARCHITECTURE)
#include <ctype.h>
#include <wctype.h>
#endif
@@ -1200,7 +1202,7 @@ _DtTermPrimSelectStart
selectInfo->anchor = xyToPos(tw, btnEvent->x, btnEvent->y);
if (selectInfo->scanType != XmSELECT_POSITION ||
_DtTermPrimSelectGetSelection(w, &begin, &end) && begin != end
(_DtTermPrimSelectGetSelection(w, &begin, &end) && begin != end)
)
{
_DtTermPrimSelectDoSelection(w, event, params, paramCount);
@@ -2057,7 +2059,7 @@ _DtTermPrimSelectConvert
return(False);
}
}
else if ((*target == CS_OF_LOCALE) && !isDebugFSet('s', 2) ||
else if (((*target == CS_OF_LOCALE) && !isDebugFSet('s', 2)) ||
(*target == TEXT && !isDebugFSet('s', 3)))
{
*type = CS_OF_LOCALE;
@@ -2241,8 +2243,8 @@ _DtTermPrimSelectDeleteLines
/* if there are no lines, etc. return... */
if ((len <= 0) || !selectInfo->ownPrimary ||
((tw->term.tpd->scrollLockTopRow > 0 ||
tw->term.tpd->scrollLockBottomRow < tw->term.rows-1)) &&
row < tw->term.tpd->scrollLockTopRow) {
(tw->term.tpd->scrollLockBottomRow < tw->term.rows-1)) &&
row < tw->term.tpd->scrollLockTopRow)) {
return;
}
@@ -3003,8 +3005,8 @@ XmTestInSelection(
position = xyToPos(tw, event->xbutton.x, event->xbutton.y);
if (!(_DtTermPrimSelectGetSelection(w, &left, &right) &&
left != right && (position > left && position < right)
if ((!(_DtTermPrimSelectGetSelection(w, &left, &right) &&
(left != right && (position > left && position < right)))
|| (position == left &&
event->xbutton.x > GetXFromPos(w, left))
|| (position == right &&

View File

@@ -277,6 +277,41 @@ void
_DtTermPrimSelectInitBtnEvents(
Widget w);
extern
void
_DtTermPrimRenderRefreshTextLinear
(
Widget w,
XmTextPosition start,
XmTextPosition stop
);
extern
XmTextPosition
rowColToPos
(
DtTermPrimitiveWidget tw,
short row,
short col
);
extern
void
_DtTermPrimSelectDisown
(
Widget w
);
extern
Boolean
_DtTermPrimSelectIsInSelection
(
Widget w,
int row,
short startCol,
short width,
short *selWidth
);
#ifdef __cplusplus
} /* close scope of 'extern "C"'... */

View File

@@ -71,7 +71,7 @@ static char rcs_id[] = "$TOG: TermPrimSetPty.c /main/2 1998/04/03 17:11:24 mgree
#include <sys/stat.h>
#endif /* USE_TIOCCONS */
#ifdef LINUX_ARCHITECTURE
#if defined(LINUX_ARCHITECTURE) || defined(OPENBSD_ARCHITECTURE)
#include <sys/ioctl.h>
#endif /* LINUX_ARCHITECTURE */

View File

@@ -36,12 +36,12 @@ static char rcs_id[] = "$TOG: TermPrimSetUtmp.c /main/10 1998/04/03 17:11:42 mgr
* (c) Copyright 1996 Hitachi. *
*/
#include "TermPrimDebug.h"
#include "TermHeader.h"
#include <Xm/Xm.h>
#include <TermPrimP.h>
#include <TermPrimSetUtmp.h>
#include <TermPrimUtil.h>
#include "TermPrimDebug.h"
#include "TermHeader.h"
/* for sigprocmask... */
#include <signal.h>

View File

@@ -65,6 +65,7 @@ static char rcs_id[] = "$TOG: TermPrimSubproc.c /main/11 1998/04/20 12:45:57 mgr
#include "TermPrimSetPty.h"
#include "TermPrimSubproc.h"
#include "TermPrimDebug.h"
#include "TermPrimSetUtmp.h"
#include "TermPrimUtil.h"
typedef struct _subprocInfo {
@@ -94,7 +95,7 @@ FakeFork (void)
#endif /*BBA*/
_DtTermProcessLock();
if (debugInit) {
if (c = getenv("dttermDebugForkFailures")) {
if ((c = getenv("dttermDebugForkFailures"))) {
debugForkFailures = strtol(c, (char **) 0, 0);
debugInit = 0;
}
@@ -382,7 +383,7 @@ _DtTermPrimSubprocExec(Widget w,
if (loginShell) {
/* pre-pend an '-' for loginShell... */
(void) strcat(argv[0], "-");
if (c = strrchr(cmd, '/')) {
if ((c = strrchr(cmd, '/'))) {
strcat(argv[0], ++c);
} else {
strcat(argv[0], cmd);

View File

@@ -467,7 +467,7 @@ _DtTermPrimStartLog(Widget w)
_bA_dump();
#endif /* BBA */
(void) execl(DEFAULT_SHELL, DEFAULT_SHELL_ARGV0,
"-c", &tw->term.logFile[1], 0);
"-c", &tw->term.logFile[1], NULL);
(void) fprintf(stderr, " Can't exec \"%s\"\n",
&tw->term.logFile[1]);
(void) exit(1);
@@ -484,7 +484,7 @@ _DtTermPrimStartLog(Widget w)
if (access(tw->term.logFile, W_OK) < 0) {
return;
}
} else if (cp = strrchr(tw->term.logFile, '/')) {
} else if ((cp = strrchr(tw->term.logFile, '/'))) {
*cp = 0;
i = access(tw->term.logFile, W_OK);
*cp = '/';

View File

@@ -49,6 +49,9 @@ extern void _DtTermPrimLogFileCleanup(void);
extern void _DtTermPrimRemoveSuidRoot();
extern void _DtTermPrimToggleSuidRoot(Boolean root);
extern void _DtTermPrimStartLog(Widget w);
extern void _DtTermPrimCloseLog(Widget w);
extern void _DtTermPrimWriteLog(DtTermPrimitiveWidget tw, char *buffer, int cnt);
#endif /* _Dt_TermPrimUtil_h */