summarylogtreecommitdiffstats
path: root/hexcurse_gccerrors.patch
blob: 7e76ee71453ade4b64c4dacd04ee23826e18b3e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
diff --git a/src/acceptch.c b/src/acceptch.c
index d57207b..2e61dc3 100644
--- a/src/acceptch.c
+++ b/src/acceptch.c
@@ -32,9 +32,9 @@ int SIZE_CH;                                            /* global winch flag  */
 int wacceptch(WINS *win, off_t len)
 {
     intmax_t tmp_max;
-    
+
     off_t count;
-    int  col = 0, val, tmpval, 	    			/* counters, etc.     */   
+    int  col = 0, val, tmpval, 	    			/* counters, etc.     */
          ch[17],					/* holds search string*/
 	 eol = (BASE * 3) - 1,				/* end of line pos    */
 	 lastRow = 0, lastCol = 0,			/* last row/col coords*/
@@ -61,7 +61,7 @@ int wacceptch(WINS *win, off_t len)
     SIZE_CH	= FALSE;				/* set winch to false */
     Winds       = win->hex;				/* curr edit window   */
     maxlines    = maxLines(len);			/* lines in file      */
-    
+
     bool shouldExit = false;
 
     /*createStack(stack);*/				/* init the stack     */
@@ -81,7 +81,7 @@ int wacceptch(WINS *win, off_t len)
     	wnoutrefresh(win->ascii);
 	doupdate();
     }
-        
+
 							/* get keys til exit  */
     while(!shouldExit)
     //while (!(save=quitProgram(isEmptyStack(stack),(key = wgetch(Winds)))))
@@ -110,10 +110,10 @@ int wacceptch(WINS *win, off_t len)
 	if (!fpIN && (key != CTRL_AND('o')) && (key != KEY_F(3)) &&
 	   (key != CTRL_AND('h')) && (key != KEY_F(1)))
 	    continue;
-	
+
 
 	switch (key) {					/* check keypress     */
-    
+
 							/* if exit key...     */
 	case CTRL_AND('q'):
 	case CTRL_AND('x'):
@@ -144,7 +144,7 @@ int wacceptch(WINS *win, off_t len)
 
 	case KEY_UP:					/* if UP...           */
 		if (currentLine > 0) 			/* move up...         */
-		{   
+		{
 		    currentLine--;
 		    wmove(Winds, --row, col);
 		}
@@ -154,8 +154,8 @@ int wacceptch(WINS *win, off_t len)
 		break;
 
 	case KEY_DOWN:					/* if DOWN...         */
-		if (cursorLoc(currentLine + 1, col, editHex,BASE) < len) 
-		{   
+		if (cursorLoc(currentLine + 1, col, editHex,BASE) < len)
+		{
 		    if (currentLine < maxlines)		/* move down...       */
 		    {
 		        wmove(Winds, ++row, col);
@@ -170,7 +170,7 @@ int wacceptch(WINS *win, off_t len)
 	case KEY_BACKSPACE:
 	case KEY_LEFT:					/* if LEFT or BACK... */
 		if ((col == 0) && (currentLine != 0))   /* move up...         */
-		{   
+		{
 	  	    currentLine--;
 		    if (row == 0)			/* scroll up...       */
 		    {
@@ -192,9 +192,9 @@ int wacceptch(WINS *win, off_t len)
 							/* if key we want...  */
 		if (isprint(key) && ((editHex && isxdigit(key)) || !editHex))
 		{
-		    if ((cl=cursorLoc(currentLine, col, editHex,BASE))< len) 
-		    {   
-		
+		    if ((cl=cursorLoc(currentLine, col, editHex,BASE))< len)
+		    {
+
 							/* if not in ll...    */
 			if ((val = searchList(head, cl)) == -1)
 		  	{
@@ -216,7 +216,7 @@ int wacceptch(WINS *win, off_t len)
 			    else if (key >= 97 && key <= 102)
 			    	key -= 39;
 			    key -= 48;
-			
+
 			    if ((col % 3) == 0)		/* compute byte val   */
                             val = (key * 16) + (val % 16);
 			    else if ((col % 3) == 1)
@@ -227,7 +227,7 @@ int wacceptch(WINS *win, off_t len)
 
 			if (editHex)			/* update ascii win   */
 			{
-			    wmove(win->ascii, row, (col/3));	
+			    wmove(win->ascii, row, (col/3));
 			    wprintw(win->ascii, "%c", (USE_EBCDIC) ?EBCDIC[val]:
 			           (isprint(val) ? val : 46));
 			    wmove(win->hex, row, col);
@@ -235,7 +235,7 @@ int wacceptch(WINS *win, off_t len)
 			}
 			else				/* update hex win     */
 			{
-			    wmove(win->hex, row, (col*3));	
+			    wmove(win->hex, row, (col*3));
 			    wprintw(win->hex, "%02X", val);
 			    wmove(win->ascii, row, col);
 			    wrefresh(win->hex);
@@ -243,7 +243,7 @@ int wacceptch(WINS *win, off_t len)
 
 			wattrset(win->hex, A_NORMAL);
 			wattrset(win->ascii, A_NORMAL);
-			
+
 							/* edit list          */
 			head = insertItem(head, cl, val);
 		/* calloc() is used because it NULLS out all returned memory  */
@@ -257,8 +257,8 @@ int wacceptch(WINS *win, off_t len)
 							    case              */
 
 	case KEY_RIGHT:					/* if RIGHT...        */
-		    if (cursorLoc(currentLine, col, editHex, BASE) < len) 
-		    {   
+		    if (cursorLoc(currentLine, col, editHex, BASE) < len)
+		    {
 			wmove(Winds, row, ++col);	/* move right         */
 		        if (cursorLoc(currentLine, col, editHex,BASE) == len)
 			    wmove(Winds, row, --col);
@@ -338,7 +338,7 @@ int wacceptch(WINS *win, off_t len)
 
  		    break;
 		}
-		
+
 		currentLine += MAXY;
 
 		if (currentLine > maxlines)		/* adjust currentLine */
@@ -347,10 +347,10 @@ int wacceptch(WINS *win, off_t len)
 		    currentLine = 0;
 
 		val = currentLine - row;		/* get val            */
-		if (val < 0) 
+		if (val < 0)
 		{
 		    row = val = 0;
-                    if (cursorLoc(currentLine, col, editHex,BASE) != 
+                    if (cursorLoc(currentLine, col, editHex,BASE) !=
 			cursorLoc(row, col, editHex,BASE))
                         row = currentLine;
                 }
@@ -372,7 +372,7 @@ int wacceptch(WINS *win, off_t len)
                         wmove(win->ascii, count, 0);
                         wclrtoeol(win->ascii);
                     }
-		
+
 		wmove(Winds, row, col);			/* restore cursor     */
     		wnoutrefresh(win->ascii);
     		wnoutrefresh(win->address);
@@ -386,31 +386,31 @@ int wacceptch(WINS *win, off_t len)
 		wmove(win->ascii, 0, 0);
 		wmove(win->address, 0, 0);
 
-		for (count = 0; count <= MAXY && count <= 
+		for (count = 0; count <= MAXY && count <=
 		     maxLines(maxLoc(fpIN)); count++)
 		    outline(fpIN, count);
 
-		mvwprintw(windows->cur_address, 0, 0, "%0*d", MIN_ADDR_LENGTH, 0); 
+		mvwprintw(windows->cur_address, 0, 0, "%0*d", MIN_ADDR_LENGTH, 0);
 		wmove((editHex) ? win->hex : win->ascii, 0, 0);
     		wnoutrefresh(win->ascii);
     		wnoutrefresh(win->address);
     		wnoutrefresh(win->hex);
 		break;
-		
+
 	case CTRL_AND('b'):
 	case KEY_END:					/* goto end of file   */
 		if (cursorLoc(currentLine, col, editHex, BASE)==maxLoc(fpIN)-1)
 		    break;				/* alread at oef      */
-		
+
 		/* if there's more than 1 screen, move to the last screenfull */
 		if ((maxlines - currentLine) >= MAXY)	/*if more than 1 scrn */
-		    currentLine = gotoLine(fpIN, 
+		    currentLine = gotoLine(fpIN,
 			  	  cursorLoc(currentLine, col, editHex, BASE),
                                   maxLoc(fpIN)-(BASE*((len%BASE)?MAXY:MAXY+1)),
 				  maxlines, Winds);
 
 		getyx(Winds, row, col);			/* move to EOF        */
-		currentLine = gotoLine(fpIN, 
+		currentLine = gotoLine(fpIN,
 				cursorLoc(currentLine, col, editHex, BASE),
 				maxLoc(fpIN)-1, maxlines, Winds);
 
@@ -429,7 +429,7 @@ int wacceptch(WINS *win, off_t len)
                     {
 			MIN_ADDR_LENGTH = getMinimumAddressLength(maxLoc(fpIN));
 			curVal = getLocVal(0);
-                    }                
+                    }
 	 	    return TRUE;			/* TRUE if worked     */
 		}
 		break;
@@ -443,7 +443,7 @@ int wacceptch(WINS *win, off_t len)
 	case KEY_F(5):
  		/* SeachStr stores the last searched string into the format *\
 	 	\* "(XXXXXXX...)" with 10 being the max chars shown         */
-                if (!fpINfilename || !strcmp(fpINfilename, "")) 
+                if (!fpINfilename || !strcmp(fpINfilename, ""))
 		{	 				/* output prompt      */
 		    wmove(win->hex_outline, LINES-1, 1);
                     wclrtoeol(win->hex_outline);
@@ -452,14 +452,14 @@ int wacceptch(WINS *win, off_t len)
                     wrefresh(win->hex_outline);
                     break;
                 }
- 
+
 
 		if (temp != NULL)
 		{
 		    bzero(SearchStr, 13);
 		    strcat(SearchStr, "(");
 		    if (strlen(temp) <= 10)
-			strncat(SearchStr, temp, strlen(temp));
+			strncat(SearchStr, temp, 13 - 2);
 		    else
 		    {
 			strncat(SearchStr, temp, 7);
@@ -470,15 +470,15 @@ int wacceptch(WINS *win, off_t len)
 
 		wmove(win->hex_outline, LINES - 1, 19); /* output prompt      */
     		wclrtoeol(win->hex_outline);
-    		mvwprintw(win->hex_outline, LINES - 1, 1, 
-		          "Enter %s value %s: ", 
+    		mvwprintw(win->hex_outline, LINES - 1, 1,
+		          "Enter %s value %s: ",
 		          (editHex) ? "hex" : "ascii", SearchStr);
 
 		echo();					/* echo chars         */
 		/*wscanw(win->hex_outline, "%s", temp);*/
 		/* the third parameter positions the cursor in the correct loc*/
-		tmpstr = inputLine(win->hex_outline, LINES - 1, 
-			 ((editHex) ? 21 : 23) + 
+		tmpstr = inputLine(win->hex_outline, LINES - 1,
+			 ((editHex) ? 21 : 23) +
 			 ((strlen(temp) > 10) ? 10 : strlen(temp)));
 		noecho();
 
@@ -498,8 +498,7 @@ int wacceptch(WINS *win, off_t len)
 		if (tmpstr[0] != '\0' )			/* enter was hit so   */
 		{					/* don't change temp  */
 		    bzero(temp, 81);
-		    strncpy(temp, tmpstr, (strlen(tmpstr) > 80) 
-			    ? 80 : strlen(tmpstr));
+		    strncpy(temp, tmpstr, 80);
 		}
 
 		val = 0;
@@ -509,17 +508,17 @@ int wacceptch(WINS *win, off_t len)
 			ch[count] = temp[count];
 		    else
 							/* if hex digit       */
-	 		if (isxdigit(key = temp[count])) 
+	 		if (isxdigit(key = temp[count]))
 			{
 			    if (key >= 65 && key <= 70)	/* get correct val    */
 			    	key -= 7;
 			    else if (key >= 97 && key <= 102)
 			    	key -= 39;
 			    key -= 48;
-			
+
 			    if ((count % 2) == 0)	/* compute byte val   */
                             	tmp = (key * 16);
-			    else 
+			    else
 			    	ch[(count - 1) / 2] = tmp + key;
 			}
 			else				/* if not hex, bad!   */
@@ -539,7 +538,7 @@ int wacceptch(WINS *win, off_t len)
                     restoreBorder(win);			/* restore border     */
 		    wrefresh(win->hex_outline);
 		}
-		else 
+		else
 		{
                     getyx(Winds, row, col);
 							/* goto found loc     */
@@ -580,11 +579,11 @@ int wacceptch(WINS *win, off_t len)
 	case KEY_F(4):					/* if F4 or ^g...     */
 		wmove(win->hex_outline, LINES-1, 21);   /* output prompt      */
     		wclrtoeol(win->hex_outline);
-    		mvwprintw(win->hex_outline, LINES - 1, 1, 
+    		mvwprintw(win->hex_outline, LINES - 1, 1,
 		"Enter %s location: ", (printHex) ? "HEX":"decimal");
 
 		echo();					/* echo chars         */
-		gotoLocStr = inputLine(win->hex_outline, LINES - 1, 
+		gotoLocStr = inputLine(win->hex_outline, LINES - 1,
 			              (printHex) ? 21 : 25);
 		if (gotoLocStr[0] == 27)		/* escape was hit     */
 		{					/* restore & return   */
@@ -592,22 +591,22 @@ int wacceptch(WINS *win, off_t len)
 		    wrefresh(win->hex_outline);
 		    break;
 		}
-                
+
                 /* convert str to number */
                 if (sscanf(gotoLocStr, printHex ? "%jX" : "%jd", &tmp_max) != 1)
                     tmp_max = 0;
-                    
+
                 gotoLoc = (off_t)tmp_max;
 		/*wscanw(win->hex_outline, (printHex) ? "%X":"%d",&gotoLoc);  */
 		noecho();				/* disable echoing    */
 
 		if ((gotoLoc < 0) || (gotoLoc > len-1))
-		{   
+		{
 		    popupWin("Invalid location!", -1);
                     restoreBorder(win);			/* restore border     */
 		    wrefresh(win->hex_outline);
 		}
-		else 
+		else
 		{
                     getyx(Winds, row, col);
 							/* goto found loc     */
@@ -623,8 +622,8 @@ int wacceptch(WINS *win, off_t len)
 		getyx(Winds, row, col);			/* current location   */
 		wattrset((editHex) ? win->ascii : win->hex, A_NORMAL);
 		mvwprintw((editHex) ? win->ascii : win->hex, row,
-			  (editHex) ? col/3 : col*3, 
-			  (editHex) ? "%c": "%02X", 
+			  (editHex) ? col/3 : col*3,
+			  (editHex) ? "%c": "%02X",
 			  (editHex) ? ((isprint(curVal))?curVal : '.'):curVal);
 		wnoutrefresh((editHex) ? win->ascii : win->hex);
 		if (editHex)				/* already in hex win */
@@ -638,7 +637,7 @@ int wacceptch(WINS *win, off_t len)
 		{
 		    Winds = win->hex;			/* change to hex win  */
 		    eol = (BASE * 3) - 1;
-	 	    wmove(Winds, row, (col*3));	
+	 	    wmove(Winds, row, (col*3));
 		    slk_set(7, "Hex Edit", 1);
 		}
 
@@ -647,14 +646,14 @@ int wacceptch(WINS *win, off_t len)
 
 		getyx(Winds, row, col);			/* current location   */
 		/* re-bold char if the value over the cursor is modified      */
-		if (inHexList(cursorLoc(currentLine, col, editHex, BASE))) 
+		if (inHexList(cursorLoc(currentLine, col, editHex, BASE)))
 		{
 		    wattron((editHex) ? win->hex : win->ascii, A_BOLD);
-		    mvwprintw((editHex) ? win->hex : win->ascii , row, col, 
-			      (editHex) ? "%02X" : "%c", 
+		    mvwprintw((editHex) ? win->hex : win->ascii , row, col,
+			      (editHex) ? "%02X" : "%c",
 			      (editHex) ?curVal:((isprint(curVal))?curVal:'.'));
 		    wattrset((editHex) ? win->hex : win->ascii, A_NORMAL);
-	 	    wmove(Winds, row, col);	
+	 	    wmove(Winds, row, col);
 		    wnoutrefresh((editHex) ? win->ascii : win->hex);
 		}
 		break;
@@ -684,49 +683,49 @@ int wacceptch(WINS *win, off_t len)
 		    head = deleteNode(head,cl);
 
 
-                    currentLine = gotoLine(fpIN, 
+                    currentLine = gotoLine(fpIN,
 			  	    cursorLoc(currentLine, col, editHex,BASE),
                                     cl, maxlines, Winds);
 		/*
                     if (stack != NULL)
-		    { 
+		    {
 		        mvwprintw(win->hex_outline,0,20,"                    ");
 		        mvwprintw(win->hex_outline,0,10,
 			      "value:%02X    location:%d  ",
-		    	      stack->currentLoc, 
+		    	      stack->currentLoc,
 			      currentLine);
 		    }
 		*/
-		
+
 		    getyx(Winds, row, col);
 
    		    if ((searchList(head, cl)) != -1)
-		    {	
+		    {
 			wattron(win->hex, A_BOLD);
 			wattron(win->ascii, A_BOLD);
 		    }
                     if (editHex)
 		    {
-                        wmove(win->ascii, row, (col/3));    
+                        wmove(win->ascii, row, (col/3));
 			wprintw(win->ascii, "%c", (USE_EBCDIC) ? EBCDIC[val] :
 			       (isprint(val) ? val : 46));
                         wmove(win->hex, row, col);
                         wrefresh(win->ascii);
 
                         wprintw(win->hex, "%02X", val);
-                        wmove(win->hex, row, col);      
+                        wmove(win->hex, row, col);
                         wrefresh(win->hex);
 		    }
 		    else
 		    {
-                        wmove(win->hex, row, (col*3));      
+                        wmove(win->hex, row, (col*3));
                         wprintw(win->hex, "%02X", val);
                         wmove(win->ascii, row, col);
                         wrefresh(win->hex);
 
 			wprintw(win->ascii, "%c", (USE_EBCDIC) ? EBCDIC[val] :
 			       (isprint(val) ? val : 46));
-                        wmove(win->ascii, row, col);    
+                        wmove(win->ascii, row, col);
                         wrefresh(win->ascii);
 		    }
 		    wattrset(win->hex, A_NORMAL);
@@ -758,7 +757,7 @@ int wacceptch(WINS *win, off_t len)
 	    else if ((lastRow == 0) && (lastCol == 0) && (key == KEY_LEFT) &&
 		    (currentLine != 0))
 		lastRow++;
-	    
+
 
 	    if (key != KEY_TAB)				/* if tab, don't do it*/
 	    {   /* unhighlight the previous character if tab was not pressed  */
@@ -767,9 +766,9 @@ int wacceptch(WINS *win, off_t len)
 		wattron((editHex) ? win->ascii : win->hex,
 		  (inHexList(cursorLoc(lastLine, lastCol, editHex, BASE))) ?
 		  A_BOLD : A_NORMAL);
-		mvwprintw((editHex) ? win->ascii : win->hex, lastRow, 
-			  (editHex) ? lastCol/3 : lastCol*3, 
-			  (editHex) ? "%c" : "%02X", 
+		mvwprintw((editHex) ? win->ascii : win->hex, lastRow,
+			  (editHex) ? lastCol/3 : lastCol*3,
+			  (editHex) ? "%c" : "%02X",
 			  (editHex) ? (isprint(curVal)) ? curVal : '.': curVal);
 		wmove(Winds, row, col);
 		wattrset((editHex) ? win->ascii : win->hex, A_NORMAL);
@@ -782,10 +781,10 @@ int wacceptch(WINS *win, off_t len)
 
 	    curVal = getLocVal(cursorLoc(currentLine, col, editHex, BASE));
 
-	    mvwprintw((editHex) ? win->ascii : win->hex, row, 
-		      (editHex) ? col/3 : col*3,  
-		      (editHex) ? "%c" : "%02X", 
-		      (editHex) ? (isprint(curVal)) ? curVal : '.' : curVal); 
+	    mvwprintw((editHex) ? win->ascii : win->hex, row,
+		      (editHex) ? col/3 : col*3,
+		      (editHex) ? "%c" : "%02X",
+		      (editHex) ? (isprint(curVal)) ? curVal : '.' : curVal);
 	    wattrset((editHex) ? win->ascii : win->hex, A_NORMAL);
 	    wnoutrefresh((editHex) ? win->ascii : win->hex);
 	}
@@ -795,11 +794,11 @@ int wacceptch(WINS *win, off_t len)
 							/* print cur location */
 	mvwprintw(win->cur_address, 0, 0, (printHex) ? "%0*jX":"%0*jd",
 	   	  MIN_ADDR_LENGTH, (intmax_t)cursorLoc(currentLine, col, editHex,BASE));
-	
+
 	wnoutrefresh(win->cur_address);			/* refresh outline    */
-	
+
 	scrollbar(win, cursorLoc(currentLine, col, editHex,BASE), maxlines);
-	
+
 	wmove(Winds, row, col);				/* restore cursor     */
 	doupdate();					/* update visual      */
     }
@@ -807,7 +806,7 @@ int wacceptch(WINS *win, off_t len)
     free(temp);
     while (stack != NULL)
 	popStack(&stack);
-    
+
     return 0;						/* return             */
 }
 
@@ -842,14 +841,14 @@ char *inputLine(WINDOW *win, int line, int col)
 
     wmove(win, line, col);
 
-    for (x = 0; (c = wgetch(win)) != 10; x++) 
+    for (x = 0; (c = wgetch(win)) != 10; x++)
     {
 	if (x > 0 && x >= allocated)
 	{
 		ch = (char*)realloc(ch, x + 1);
 		allocated = x + 1;
 	}
-	
+
         wclrtoeol(win);					/* clear line         */
         if (c == '\b' || c == 127) 			/* get backspace      */
 	{
@@ -866,7 +865,7 @@ char *inputLine(WINDOW *win, int line, int col)
 	else if (c == 27)				/* if the escape key  */
 	{   						/* is pressed, return */
 	    ch[0] = 27;					/* setting ch to 0xff */
-	    return ch;					
+	    return ch;
 	}
         else 						/* if anything else   */
 	{
@@ -874,7 +873,7 @@ char *inputLine(WINDOW *win, int line, int col)
             x--;
         }
 
-        if (x < 0) 
+        if (x < 0)
 	{
             wmove(win, line, col);			/* move cursor        */
             x = -1;