Fixed input editors

This commit is contained in:
Michiel Broek 2005-08-29 13:42:56 +00:00
parent 2806a27734
commit ce6749c55c
5 changed files with 21 additions and 16 deletions

View File

@ -111,7 +111,7 @@ void GetstrD(char *sStr, int iMaxlen)
if (ch > 31 && ch < 127) { if (ch > 31 && ch < 127) {
if (iPos <= iMaxlen) { if (iPos <= iMaxlen) {
iPos++; iPos++;
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
} else } else
PUTCHAR(7); PUTCHAR(7);

View File

@ -215,7 +215,7 @@ void GetstrLC(char *sStr, int iMaxlen)
if ((ch > 31 && ch < 127) || traduce(&ch)) { if ((ch > 31 && ch < 127) || traduce(&ch)) {
if (iPos <= iMaxlen) { if (iPos <= iMaxlen) {
iPos++; iPos++;
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
} else { } else {
Beep(); Beep();

View File

@ -352,7 +352,7 @@ void GetstrP(char *sStr, int iMaxLen, int Position)
} else if ((ch > 31 && ch < 127) || traduce(&ch)) { } else if ((ch > 31 && ch < 127) || traduce(&ch)) {
if (iPos <= iMaxLen) { if (iPos <= iMaxLen) {
iPos++; iPos++;
snprintf(sStr, iMaxLen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
} else { } else {
PUTCHAR('\007'); PUTCHAR('\007');
@ -393,7 +393,7 @@ void GetstrC(char *sStr, int iMaxlen)
if ((ch > 31) && (ch < 127) && (ch != ',')) { if ((ch > 31) && (ch < 127) && (ch != ',')) {
if (iPos <= iMaxlen) { if (iPos <= iMaxlen) {
iPos++; iPos++;
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
} else } else
PUTCHAR('\007'); PUTCHAR('\007');
@ -433,7 +433,7 @@ void GetstrU(char *sStr, int iMaxlen)
if (isalnum(ch) || (ch == '@') || (ch == '.') || (ch == '-') || (ch == '_')) { if (isalnum(ch) || (ch == '@') || (ch == '.') || (ch == '-') || (ch == '_')) {
if (iPos <= iMaxlen) { if (iPos <= iMaxlen) {
iPos++; iPos++;
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
} else } else
PUTCHAR('\007'); PUTCHAR('\007');
@ -474,7 +474,7 @@ void GetPhone(char *sStr, int iMaxlen)
if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == '+')) { if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == '+')) {
if (iPos <= iMaxlen) { if (iPos <= iMaxlen) {
iPos++; iPos++;
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
} else } else
PUTCHAR('\007'); PUTCHAR('\007');
@ -516,7 +516,7 @@ void Getnum(char *sStr, int iMaxlen)
if (iPos <= iMaxlen) { if (iPos <= iMaxlen) {
iPos++; iPos++;
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
} else } else
PUTCHAR('\007'); PUTCHAR('\007');
@ -563,11 +563,11 @@ void GetDate(char *sStr, int iMaxlen)
if (ch >= '0' && ch <= '9') { if (ch >= '0' && ch <= '9') {
if (iPos < iMaxlen) { if (iPos < iMaxlen) {
iPos++; iPos++;
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
if (iPos == 2 || iPos == 5) { if (iPos == 2 || iPos == 5) {
PUTCHAR('-'); PUTCHAR('-');
snprintf(sStr, iMaxlen, "%s-", sStr); snprintf(sStr + strlen(sStr), 1, "-");
iPos++; iPos++;
} }
} else } else
@ -628,7 +628,7 @@ void Getname(char *sStr, int iMaxlen)
if (iPos == 1 && CFG.iCapUserName) if (iPos == 1 && CFG.iCapUserName)
ch = toupper(ch); ch = toupper(ch);
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
printf("%c", ch); printf("%c", ch);
} else } else
putchar('\007'); putchar('\007');
@ -688,7 +688,7 @@ void GetnameNE(char *sStr, int iMaxlen)
if (iPos == 1) if (iPos == 1)
ch = toupper(ch); ch = toupper(ch);
snprintf(sStr, iMaxlen, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
printf("%c", ch); printf("%c", ch);
} else } else
putchar('\007'); putchar('\007');

View File

@ -310,7 +310,7 @@ void Oneliner_Show()
FILE *pOneline; FILE *pOneline;
int recno = 0; int recno = 0;
long offset; long offset;
char *sFileName, msg[11]; char *sFileName, msg[81];
sFileName = calloc(PATH_MAX, sizeof(char)); sFileName = calloc(PATH_MAX, sizeof(char));
snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT")); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT"));
@ -320,15 +320,20 @@ void Oneliner_Show()
return; return;
} }
fread(&olhdr, sizeof(olhdr), 1, pOneline); fread(&olhdr, sizeof(olhdr), 1, pOneline);
fseek(pOneline, 0, SEEK_END);
recno = (ftell(pOneline) - olhdr.hdrsize) / olhdr.recsize;
Enter(1); Enter(1);
/* Please enter number to list: */ /* Please enter number to list: */
pout(WHITE, BLACK, Language(347)); snprintf(msg, 81, "%s (1..%d) ", Language(347), recno -1);
pout(WHITE, BLACK, msg);
colour(CFG.InputColourF, CFG.InputColourB); colour(CFG.InputColourF, CFG.InputColourB);
scanf("%d", &recno); msg[0] = '\0';
Getnum(msg, 10);
recno = atoi(msg);
offset = olhdr.hdrsize + (recno * olhdr.recsize); offset = olhdr.hdrsize + (recno * olhdr.recsize);
if (fseek(pOneline, offset, 0) != 0) if (fseek(pOneline, offset, SEEK_SET) != 0)
WriteError("Can't move pointer in %s",sFileName); WriteError("Can't move pointer in %s",sFileName);
fread(&ol, olhdr.recsize, 1, pOneline); fread(&ol, olhdr.recsize, 1, pOneline);

View File

@ -247,7 +247,7 @@ void GetPageStr(char *sStr, int iMaxlen)
if (ch > 31 && ch < 127) { if (ch > 31 && ch < 127) {
if (iPos <= iMaxlen) { if (iPos <= iMaxlen) {
iPos++; iPos++;
snprintf(sStr, 4, "%s%c", sStr, ch); snprintf(sStr + strlen(sStr), 5, "%c", ch);
PUTCHAR(ch); PUTCHAR(ch);
fflush(stdout); fflush(stdout);
} else } else