/****************************************************************************
- * Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
*
* Date: 05.Nov.90
*
- * $Id: hanoi.c,v 1.25 2006/04/22 22:41:22 tom Exp $
+ * $Id: hanoi.c,v 1.27 2008/08/04 10:57:59 tom Exp $
*/
#include <test.priv.h>
COLOR_RED, /* Length 19 */
};
static int NMoves = 0;
+static bool AutoFlag = FALSE;
static void InitTiles(int NTiles);
static void DisplayTiles(void);
main(int argc, char **argv)
{
int NTiles, FromCol, ToCol;
- bool AutoFlag = 0;
setlocale(LC_ALL, "");
/* Draw tiles */
for (peg = 0; peg < NPEGS; peg++) {
for (SlotNo = 0; SlotNo < Pegs[peg].Count; SlotNo++) {
- memset(TileBuf, ' ', Pegs[peg].Length[SlotNo]);
- TileBuf[Pegs[peg].Length[SlotNo]] = '\0';
- if (has_colors())
- attrset(COLOR_PAIR(LENTOIND(Pegs[peg].Length[SlotNo])));
- else
- attrset(A_REVERSE);
- mvaddstr(BASELINE - (SlotNo + 1),
- (int) (PegPos[peg] - Pegs[peg].Length[SlotNo] / 2),
- TileBuf);
+ unsigned len = Pegs[peg].Length[SlotNo];
+ if (len < sizeof(TileBuf) - 1 && len < (unsigned) PegPos[peg]) {
+ memset(TileBuf, ' ', len);
+ TileBuf[len] = '\0';
+ if (has_colors())
+ attrset(COLOR_PAIR(LENTOIND(len)));
+ else
+ attrset(A_REVERSE);
+ mvaddstr(BASELINE - (SlotNo + 1),
+ (int) (PegPos[peg] - len / 2),
+ TileBuf);
+ }
}
}
attrset(A_NORMAL);
return TRUE;
*To -= ('0' + 1);
refresh();
- napms(500);
+ if (!AutoFlag)
+ napms(500);
move(STATUSLINE, 0);
clrtoeol();