1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

Harmonize usage of mlreply, mlreplyt and nextarg based on actual needs (input always terminated either on meta or newline characters).

This commit is contained in:
Renaud 2015-08-25 09:17:41 +08:00
parent 1ab601071e
commit 51967939b8
6 changed files with 15 additions and 25 deletions

2
eval.c
View File

@ -1172,7 +1172,7 @@ char *getval(char *token)
strcpy(token, getval(&token[1])); strcpy(token, getval(&token[1]));
distmp = discmd; /* echo it always! */ distmp = discmd; /* echo it always! */
discmd = TRUE; discmd = TRUE;
status = getstring(token, buf, NSTRING, ctoec('\n')); status = getstring( token, buf, NSTRING, nlc) ;
discmd = distmp; discmd = distmp;
if (status == ABORT) if (status == ABORT)
return errorm; return errorm;

2
exec.c
View File

@ -298,7 +298,7 @@ int macarg( char *tok, int toksz)
savcle = clexec; /* save execution mode */ savcle = clexec; /* save execution mode */
clexec = TRUE; /* get the argument */ clexec = TRUE; /* get the argument */
status = nextarg("", tok, toksz, ctoec('\n')); status = mlreply( "", tok, toksz) ;
clexec = savcle; /* restore execution mode */ clexec = savcle; /* restore execution mode */
return status; return status;
} }

24
input.c
View File

@ -52,6 +52,8 @@ int ctlxc = CONTROL | 'X' ; /* current control X prefix char */
int reptc = CONTROL | 'U' ; /* current universal repeat char */ int reptc = CONTROL | 'U' ; /* current universal repeat char */
int abortc = CONTROL | 'G' ; /* current abort command char */ int abortc = CONTROL | 'G' ; /* current abort command char */
const int nlc = CONTROL | 'J' ; /* end of input char */
static const int quotec = 0x11 ; /* quote char during mlreply() */ static const int quotec = 0x11 ; /* quote char during mlreply() */
static void outstring( char *s) ; static void outstring( char *s) ;
@ -91,14 +93,12 @@ int mlyesno( const char *prompt)
* return. Handle erase, kill, and abort keys. * return. Handle erase, kill, and abort keys.
*/ */
int mlreply( const char *prompt, char *buf, int nbuf) int mlreply( const char *prompt, char *buf, int nbuf) {
{ return nextarg( prompt, buf, nbuf, nlc) ;
return nextarg(prompt, buf, nbuf, ctoec('\n'));
} }
int mlreplyt(const char *prompt, char *buf, int nbuf, int eolchar) int mlreplyt( const char *prompt, char *buf, int nbuf) {
{ return nextarg( prompt, buf, nbuf, metac) ;
return nextarg(prompt, buf, nbuf, eolchar);
} }
/* /*
@ -115,18 +115,6 @@ int ectoc(int c)
return c; return c;
} }
/*
* ctoec:
* character to extended character
* pull out the CONTROL and SPEC prefixes (if possible)
*/
int ctoec(int c)
{
if (c >= 0x00 && c <= 0x1F)
c = CONTROL | (c + '@');
return c;
}
/* /*
* get a command name from the command line. Command completion means * get a command name from the command line. Command completion means
* that pressing a <SPACE> will attempt to complete an unfinished command * that pressing a <SPACE> will attempt to complete an unfinished command

View File

@ -14,17 +14,18 @@ extern int kbdm[] ; /* Holds kayboard macro data */
extern int *kbdptr ; /* current position in keyboard buf */ extern int *kbdptr ; /* current position in keyboard buf */
extern int *kbdend ; /* ptr to end of the keyboard */ extern int *kbdend ; /* ptr to end of the keyboard */
extern int disinp ; /* display input characters */ extern int disinp ; /* display input characters */
extern int metac; /* current meta character */ extern int metac; /* current meta character */
extern int ctlxc; /* current control X prefix char */ extern int ctlxc; /* current control X prefix char */
extern int reptc; /* current universal repeat char */ extern int reptc; /* current universal repeat char */
extern int abortc; /* current abort command char */ extern int abortc; /* current abort command char */
extern const int nlc ; /* end of input char */
int mlyesno( const char *prompt) ; int mlyesno( const char *prompt) ;
int mlreply( const char *prompt, char *buf, int nbuf) ; int mlreply( const char *prompt, char *buf, int nbuf) ;
int mlreplyt( const char *prompt, char *buf, int nbuf, int eolchar) ; int mlreplyt( const char *prompt, char *buf, int nbuf) ;
int ectoc( int c) ; int ectoc( int c) ;
int ctoec( int c) ;
fn_t getname( void) ; fn_t getname( void) ;
int tgetc( void) ; int tgetc( void) ;
int get1key( void) ; int get1key( void) ;

View File

@ -1196,7 +1196,7 @@ int istring(int f, int n)
/* ask for string to insert */ /* ask for string to insert */
status = status =
mlreplyt("String to insert<META>: ", tstring, sizeof tstring - 1, metac) ; mlreplyt( "String to insert<META>: ", tstring, sizeof tstring - 1) ;
if (status != TRUE) if (status != TRUE)
return status; return status;
@ -1224,7 +1224,7 @@ int ovstring(int f, int n)
/* ask for string to insert */ /* ask for string to insert */
status = status =
mlreplyt( "String to overwrite<META>: ", tstring, NSTRING, metac) ; mlreplyt( "String to overwrite<META>: ", tstring, NSTRING) ;
if (status != TRUE) if (status != TRUE)
return status; return status;

View File

@ -713,7 +713,8 @@ static int readpattern(char *prompt, char *apat, int srch)
* Then, if it's the search string, make a reversed pattern. * Then, if it's the search string, make a reversed pattern.
* *Then*, make the meta-pattern, if we are defined that way. * *Then*, make the meta-pattern, if we are defined that way.
*/ */
if ((status = mlreplyt(tpat, tpat, NPAT, metac)) == TRUE) { status = mlreplyt( tpat, tpat, NPAT) ;
if( status == TRUE) {
strcpy(apat, tpat); strcpy(apat, tpat);
if (srch) { /* If we are doing the search string. */ if (srch) { /* If we are doing the search string. */
/* Reverse string copy, and remember /* Reverse string copy, and remember