Update of /cvsroot/cscope/cscope/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14234/src
Modified Files:
global.h input.c command.c
Log Message:
Removed getline(); replaced its calls by calls to mygetline().
Index: global.h
===================================================================
RCS file: /cvsroot/cscope/cscope/src/global.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -r1.32 -r1.33
*** global.h 27 Oct 2004 11:32:46 -0000 1.32
--- global.h 14 Mar 2005 17:24:46 -0000 1.33
***************
*** 407,411 ****
int egrep(char *file, FILE *output, char *format);
- int getline(char s[], unsigned size, int firstchar, BOOL iscaseless);
int mygetline(char p[], char s[], unsigned size, int firstchar, BOOL iscaseless);
int mygetch(void);
--- 407,410 ----
Index: input.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/input.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** input.c 4 Feb 2005 12:19:08 -0000 1.12
--- input.c 14 Mar 2005 17:24:46 -0000 1.13
***************
*** 238,377 ****
return(i);
}
- /* get a line from the terminal in non-canonical mode */
-
- int
- getline(char s[], unsigned size, int firstchar, BOOL iscaseless)
- {
- int c, i = 0;
- int j;
- char *sright; /* substring to the right of the cursor */
- int ri = 0; /* position in right-string */
-
- /* Inserts and deletes are always performed on the left-string,
- * but we'll also have a right-string 'sright' to hold characters
- * which are on the right of the cursor [insertion point].
- *
- * Think of 'sright' as a stack -- we push chars into it when the cursor
- * moves left, and we pop chars off it when the cursor moves right again.
- * At the end of the function, we'll pop off any remaining characters
- * onto the end of 's'
- */
- sright = calloc(sizeof(char), size);
-
- /* if a character already has been typed */
- if (firstchar != '\0') {
- if(iscaseless == YES) {
- firstchar = tolower(firstchar);
- }
- addch(firstchar); /* display it */
- s[i++] = firstchar; /* save it */
- }
- /* until the end of the line is reached */
- while ((c = mygetch()) != '\r' && c != '\n' && c != KEY_ENTER) {
-
- if (c == KEY_LEFT || c == ctrl('B')) { /* left */
- if (i > 0) {
- addch('\b');
- /* move this char into the second (rhs) string */
- sright[ri++] = s[--i];
- }
- }
- else if (c == KEY_RIGHT || c == ctrl('F')) { /* right */
- if (i < size && ri > 0) {
- /* move this char to the left of the cursor */
- s[i++] = sright[--ri];
- addch(s[i-1]);
- }
- }
- else if (
- #ifdef KEY_HOME
- c == KEY_HOME ||
- #endif
- c == ctrl('A') ) {
- while ( i > 0 ) {
- sright[ri++] = s[--i];
- addch('\b');
- addch(s[i]);
- addch('\b');
- }
- }
- else if (
- #ifdef KEY_END
- c == KEY_END ||
- #endif
- c == ctrl('E') ) {
- while ( ri > 0 ) {
- s[i++] = sright[--ri];
- addch(s[i-1]);
- }
- }
- else if (c == erasechar() || c == KEY_BACKSPACE || c == DEL || c == ctrl('H') ) {
- /* erase */
- if (i > 0) {
- if (ri == 0) {
- addstr("\b \b");
- } else {
- addch('\b');
- delch();
- }
- s[i] = '\0';
- --i;
- }
- }
- else if (c == killchar() || c == KEY_BREAK) { /* kill */
- for (j = 0; j < i; ++j) {
- addch('\b');
- }
- for (j = 0; j < i; ++j) {
- addch(' ');
- }
- for (j = 0; j < i; ++j) {
- addch('\b');
- }
- i = 0;
- }
- else if (isprint(c) || c == '\t') { /* printable */
- if(iscaseless == YES) {
- c = tolower(c);
- }
- /* if it will fit on the line */
- if (i < size) {
- s[i++] = c; /* save it */
- if (ri == 0) {
- addch(c); /* display it */
- } else {
- insch(c); /* display it */
- addch(c); /* advance cursor */
- }
- }
- }
- #if UNIXPC
- else if (unixpcmouse == YES && c == ESC) { /* mouse */
- (void) getmouseaction(ESC); /* ignore it */
- }
- #endif
- else if (mouse == YES && c == ctrl('X')) {
- (void) getmouseaction(ctrl('X')); /* ignore it */
- }
- else if (c == EOF) { /* end-of-file */
- break;
- }
- /* return on an empty line to allow a command to be entered */
- if (firstchar != '\0' && (i+ri) == 0) {
- break;
- }
- }
-
- /* move any remaining chars on the rhs of the cursor
- * onto the end of our string
- */
- for (; ri > 0; ) {
- s[i++] = sright[--ri];
- }
- free(sright);
-
- s[i] = '\0';
- return(i);
- }
/* ask user to enter a character after reading the message */
--- 238,241 ----
Index: command.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/command.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** command.c 16 Feb 2005 20:49:24 -0000 1.26
--- command.c 14 Mar 2005 17:24:47 -0000 1.27
***************
*** 82,86 ****
struct cmd *curritem, *item; /* command history */
char *s;
! int lines, cols;
switch (commandc) {
--- 82,86 ----
struct cmd *curritem, *item; /* command history */
char *s;
! /* int lines, cols; --- HBB UNUSED 20050314 */
switch (commandc) {
***************
*** 332,338 ****
s = "a";
}
! if (c != '\r' &&
! getline(newpat, COLS - sizeof(appendprompt), c,
! NO) > 0) {
shellpath(filename, sizeof(filename), newpat);
if ((file = myfopen(filename, s)) == NULL) {
--- 332,339 ----
s = "a";
}
! if (c != '\r' &&
! mygetline("", newpat,
! COLS - sizeof(appendprompt), c, NO) > 0
! ) {
shellpath(filename, sizeof(filename), newpat);
if ((file = myfopen(filename, s)) == NULL) {
***************
*** 355,360 ****
(void) move(PRLINE, 0);
(void) addstr(readprompt);
! if (getline(newpat, COLS - sizeof(readprompt), '\0',
! NO) > 0) {
clearprompt();
shellpath(filename, sizeof(filename), newpat);
--- 356,361 ----
(void) move(PRLINE, 0);
(void) addstr(readprompt);
! if (mygetline("", newpat, COLS - sizeof(readprompt),
! '\0', NO) > 0) {
clearprompt();
shellpath(filename, sizeof(filename), newpat);
***************
*** 377,381 ****
(void) move(PRLINE, 0);
(void) addstr(pipeprompt);
! if (getline(newpat, COLS - sizeof(pipeprompt), '\0', NO) == 0) {
clearprompt();
return(NO);
--- 378,383 ----
(void) move(PRLINE, 0);
(void) addstr(pipeprompt);
! if (mygetline("", newpat, COLS - sizeof(pipeprompt), '\0', NO)
! == 0) {
clearprompt();
return(NO);
***************
*** 518,544 ****
/* FALLTHROUGH */
default:
!
! if (selecting && !mouse)
! {
char *c;
if ((c = strchr(dispchars, commandc)))
editref(c - dispchars);
- }
/* if this is the start of a pattern */
! else if (isprint(commandc)) {
! ispat: if (getline(newpat, COLS - fldcolumn - 1, commandc,
! caseless) > 0) {
! (void) strcpy(Pattern, newpat);
! resetcmd(); /* reset command history */
! repeat:
addcmd(field, Pattern); /* add to command history */
if (field == CHANGE) {
-
/* prompt for the new text */
! (void) move(PRLINE, 0);
! (void) addstr(toprompt);
! (void) getline(newpat, COLS - sizeof(toprompt), '\0', NO);
}
/* search for the pattern */
--- 520,545 ----
/* FALLTHROUGH */
default:
! if (selecting && !mouse) {
char *c;
if ((c = strchr(dispchars, commandc)))
editref(c - dispchars);
/* if this is the start of a pattern */
! } else if (isprint(commandc)) {
! ispat:
! if (mygetline("", newpat, COLS - fldcolumn - 1,
! commandc, caseless) > 0) {
! strcpy(Pattern, newpat);
! resetcmd(); /* reset command history */
! repeat:
addcmd(field, Pattern); /* add to command history */
if (field == CHANGE) {
/* prompt for the new text */
! move(PRLINE, 0);
! addstr(toprompt);
! mygetline("", newpat,
! COLS - sizeof(toprompt),
! '\0', NO);
}
/* search for the pattern */
***************
*** 559,577 ****
return(changestring());
}
! }
! /* try to edit the file anyway */
! else if (field == FILENAME &&
! access(newpat, READ) == 0) {
edit(newpat, "1");
}
! }
! else { /* no pattern--the input was erased */
return(NO);
}
! }
! else { /* control character */
return(NO);
}
! }
return(YES);
}
--- 560,576 ----
return(changestring());
}
!
! } else if (field == FILENAME &&
! access(newpat, READ) == 0) {
! /* try to edit the file anyway */
edit(newpat, "1");
}
! } else { /* no pattern--the input was erased */
return(NO);
}
! } else { /* control character */
return(NO);
}
! } /* switch(commandc) */
return(YES);
}
|