Hello,
I'm trying to convert a static C library from lcc-win32 to Pelles C and I get this error when building the project on a subroutine declaration.
Here is the faulting subroutine.
#--------------------------------------------------------------------------------
Accept is a generic input routine to accept input from the user
Parameters: Row, Column, Color, Prompt, Length of return, Validate,
Return string
Set length of return to negative to hide input
Set color to negative to prevent altering default on ESC
color contains foreground and background (bg * 16 + fg)
Set return string to provide default
Return Codes: 0: ESC
1: Enter
2: Up arrow
3: Down arrow
4: Page up
5: Page down
59 - 68: Function Keys 1 - 10
104 - 113: Alt Function Keys 1 - 10
94 - 103: Ctrl Function Keys 1 - 10
Example: z = Accept(5,30,-14,"Prompt -> ",6,"ABCwz#-+{}0123456789",ret)
#--------------------------------------------------------------------------------
extern int Accept(int,int,int,char *,int,char *,char *);
extern int Accept(int row,int col,int clr,char *prompt,int length,char *validate,char *rts) {
static unsigned char orig[82],k;
static int hide,s,cp,ep,ins,rcd,cx,cy;
CONSOLE_CURSOR_INFO cci,cco;
if (length < 0) {length = -length; hide = 1; rts[0] = 0;} else {hide = 0;}
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole,&binfo);
if (col < 1 || row < 1) return 0;
if ((col + strlen(prompt) + length) > 80) return 0;
if (row > binfo.dwSize.Y) return 0;
sprintf((char *) orig,"%s",left(rts,length));
sprintf(rts,"%s",orig);
ScreenGetCursor(&cx,&cy); locate(row,col);
GetConsoleCursorInfo(hConsole,&cci);
cco = cci; cci.dwSize = 90; cci.bVisible = TRUE;
SetConsoleCursorInfo(hConsole,&cci);
printf("%s",prompt); color((int)Abs(clr) & 15,((int)Abs(clr) >> 4) & 15);
printf("%s%s",rts,space(length - strlen(rts)));
s = 1; cp = col + strlen(prompt); ep = cp; rcd = 1; ins = 0;
do {
locate(row,cp);
k = _getch();
if (k == 224 || k == 0) { /* A function type key was pressed */
k = _getch();
if (hide == 0) {
switch(k) {
case 71: /* Home key pressed */
cp = ep; k = 128;
break;
case 79: /* End key pressed */
cp = ep + strlen(rts); k = 128;
break;
case 75: /* Left arrow key pressed */
if (cp == ep) {rcd = 6; k = 13; break;}
if (cp > ep) cp--; k = 128; break;
case 77: /* Right arrow key pressed */
if (cp == ep && s != 0) {rcd = 7; k = 13; break;}
if (cp < (ep + strlen(rts))) {cp++; k = 128;}
else {rcd = 7; k = 13;}
break;
case 72: /* Up arrow key pressed */
rcd = 2; k = 13;
break;
case 80: /* Down arrow key pressed */
rcd = 3; k = 13;
break;
case 73: /* Page Up key pressed */
rcd = 4; k = 13;
break;
case 81: /* Page Down key pressed */
rcd = 5; k = 13;
break;
case 82: /* Insert key pressed */
ins = 1 - ins; k = 128;
if (ins) cci.dwSize = 20;
else cci.dwSize = 90;
SetConsoleCursorInfo(hConsole,&cci);
break;
case 83: /* Delete key pressed */
if (s) {
cp = ep; rts[0] = 0; locate(row,cp);
printf("%s",space(length));
}
else {
if ((cp - ep) < strlen(rts)) {
s = cp - ep;
sprintf(rts,"%s%s",left(rts,s),mid(rts,s + 2));
locate(row,ep);
printf("%s%s",rts,space(length - strlen(rts)));
}
}
k = 128;
break;
default:
rcd = k; k = 13;
break;
}
}
else {
k = 128;
}
s = 0;
}
if (k == 8 && cp > ep) { /* Backspace key pressed */
s = cp - ep; memcpy(rts + s - 1,rts + s,length - s + 1);
cp--; s = 0;
if (hide) {
locate(row,cp); _putch(32);
}
else {
locate(row,ep); printf("%s%s",rts,space(length - strlen(rts)));
}
}
if (k == 27) {rcd = 0; k = 13;} /* Escape key pressed */
if (instr((char *) validate,(char *) &k)) {
if (cp - ep < length) {
if (s) {
rts[0] = 0; rts[1] = 0;
printf(space(length)); locate(row,cp);
}
s = cp - ep;
if (s == strlen(rts)) {
rts[s++] = k; rts = 0;
}
else {
if (ins) {
memcpy(rts + s + 1,rts + s,length - s + 1);
rts = k; rts[length] = 0;
locate(row,ep); printf("%s",rts); locate(row,cp);
}
else {
rts = k;
}
}
s = 0; cp++;
if (hide) {_putch(42);} else {_putch(k);}
}
}
} while (k != 13);
if (rcd == 0 && clr < 0) sprintf(rts,"%s",orig);
locate(cx,cy); SetConsoleCursorInfo(hConsole,&cco);
return rcd;
}