mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 15:26:23 -05:00
Exec commands based on newmlarg (replacement of mlreply).
This commit is contained in:
parent
b59a47bb3a
commit
bcba236265
160
exec.c
160
exec.c
@ -120,19 +120,20 @@ static int docmd( char *cline) ;
|
|||||||
*
|
*
|
||||||
* int f, n; default Flag and Numeric argument
|
* int f, n; default Flag and Numeric argument
|
||||||
*/
|
*/
|
||||||
int execcmd(int f, int n)
|
int execcmd( int f, int n) {
|
||||||
{
|
int status ; /* status return */
|
||||||
int status; /* status return */
|
char *cmdstr ; /* string holding command to execute */
|
||||||
char cmdstr[NSTRING]; /* string holding command to execute */
|
|
||||||
|
|
||||||
/* get the line wanted */
|
/* get the line wanted */
|
||||||
if ((status = mlreply(": ", cmdstr, NSTRING)) != TRUE)
|
status = newmlarg( &cmdstr, ": ", 0) ;
|
||||||
return status;
|
if( status != TRUE)
|
||||||
|
return status ;
|
||||||
|
|
||||||
execlevel = 0;
|
execlevel = 0 ;
|
||||||
while( status == TRUE && n-- > 0)
|
while( status == TRUE && n-- > 0)
|
||||||
status = docmd( cmdstr) ;
|
status = docmd( cmdstr) ;
|
||||||
|
|
||||||
|
free( cmdstr) ;
|
||||||
return status ;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,38 +440,42 @@ int storemac(int f, int n)
|
|||||||
* int f; default flag
|
* int f; default flag
|
||||||
* int n; macro number to use
|
* int n; macro number to use
|
||||||
*/
|
*/
|
||||||
int storeproc(int f, int n)
|
int storeproc( int f, int n) {
|
||||||
{
|
struct buffer *bp ; /* pointer to macro buffer */
|
||||||
struct buffer *bp; /* pointer to macro buffer */
|
int status ; /* return status */
|
||||||
int status; /* return status */
|
|
||||||
bname_t bname ; /* name of buffer to use */
|
bname_t bname ; /* name of buffer to use */
|
||||||
|
char *name ;
|
||||||
|
|
||||||
/* a numeric argument means its a numbered macro */
|
/* a numeric argument means its a numbered macro */
|
||||||
if (f == TRUE)
|
if( f == TRUE)
|
||||||
return storemac(f, n);
|
return storemac( f, n) ;
|
||||||
|
|
||||||
/* get the name of the procedure */
|
/* get the name of the procedure */
|
||||||
if ((status =
|
status = newmlarg( &name, "Procedure name: ", sizeof bname - 2) ;
|
||||||
mlreply("Procedure name: ", &bname[1], sizeof bname - 2)) != TRUE)
|
if( status != TRUE)
|
||||||
return status;
|
return status ;
|
||||||
|
|
||||||
/* construct the macro buffer name */
|
/* construct the macro buffer name */
|
||||||
bname[0] = '*';
|
bname[ 0] = '*';
|
||||||
strcat(bname, "*");
|
strncpy( &bname[ 1], name, sizeof bname - 3) ;
|
||||||
|
bname[ sizeof bname - 2] = '\0' ;
|
||||||
|
strcat( bname, "*") ;
|
||||||
|
free( name) ;
|
||||||
|
|
||||||
/* set up the new macro buffer */
|
/* set up the new macro buffer */
|
||||||
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
|
bp = bfind( bname, TRUE, BFINVS) ;
|
||||||
mlwrite("Can not create macro");
|
if( bp == NULL) {
|
||||||
return FALSE;
|
mlwrite( "Can not create macro") ;
|
||||||
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and make sure it is empty */
|
/* and make sure it is empty */
|
||||||
bclear(bp);
|
bclear( bp) ;
|
||||||
|
|
||||||
/* and set the macro store pointers to it */
|
/* and set the macro store pointers to it */
|
||||||
mstore = TRUE;
|
mstore = TRUE ;
|
||||||
bstore = bp;
|
bstore = bp ;
|
||||||
return TRUE;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -479,32 +484,36 @@ int storeproc(int f, int n)
|
|||||||
*
|
*
|
||||||
* int f, n; default flag and numeric arg
|
* int f, n; default flag and numeric arg
|
||||||
*/
|
*/
|
||||||
int execproc(int f, int n)
|
int execproc( int f, int n) {
|
||||||
{
|
struct buffer *bp ; /* ptr to buffer to execute */
|
||||||
struct buffer *bp; /* ptr to buffer to execute */
|
int status ; /* status return */
|
||||||
int status; /* status return */
|
bname_t bufn ; /* name of buffer to execute */
|
||||||
char bufn[NBUFN + 2]; /* name of buffer to execute */
|
char *name ;
|
||||||
|
|
||||||
/* find out what buffer the user wants to execute */
|
/* find out what buffer the user wants to execute */
|
||||||
if ((status =
|
status = newmlarg( &name, "Execute procedure: ", sizeof bufn - 2) ;
|
||||||
mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE)
|
if( status != TRUE)
|
||||||
return status;
|
return status ;
|
||||||
|
|
||||||
/* construct the buffer name */
|
/* construct the buffer name */
|
||||||
bufn[0] = '*';
|
bufn[ 0] = '*' ;
|
||||||
strcat(bufn, "*");
|
strncpy( &bufn[ 1], name, sizeof bufn - 3) ;
|
||||||
|
bufn[ sizeof bufn - 2] = '\0' ;
|
||||||
|
strcat( bufn, "*") ;
|
||||||
|
free( name) ;
|
||||||
|
|
||||||
/* find the pointer to that buffer */
|
/* find the pointer to that buffer */
|
||||||
if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
|
bp = bfind( bufn, FALSE, 0) ;
|
||||||
mlwrite("No such procedure");
|
if( bp == NULL) {
|
||||||
return FALSE;
|
mlwrite( "No such procedure") ;
|
||||||
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and now execute it as asked */
|
/* and now execute it as asked */
|
||||||
while (n-- > 0)
|
while( status == TRUE && n-- > 0)
|
||||||
if ((status = dobuf(bp)) != TRUE)
|
status = dobuf( bp) ;
|
||||||
return status;
|
|
||||||
return TRUE;
|
return status ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -514,27 +523,29 @@ int execproc(int f, int n)
|
|||||||
*
|
*
|
||||||
* int f, n; default flag and numeric arg
|
* int f, n; default flag and numeric arg
|
||||||
*/
|
*/
|
||||||
int execbuf(int f, int n)
|
int execbuf( int f, int n) {
|
||||||
{
|
struct buffer *bp ; /* ptr to buffer to execute */
|
||||||
struct buffer *bp; /* ptr to buffer to execute */
|
int status ; /* status return */
|
||||||
int status; /* status return */
|
char *bufn ; /* name of buffer to execute */
|
||||||
bname_t bufn ; /* name of buffer to execute */
|
|
||||||
|
|
||||||
/* find out what buffer the user wants to execute */
|
/* find out what buffer the user wants to execute */
|
||||||
if ((status = mlreply("Execute buffer: ", bufn, sizeof bufn)) != TRUE)
|
status = newmlarg( &bufn, "Execute buffer: ", sizeof( bname_t)) ;
|
||||||
return status;
|
if( status != TRUE)
|
||||||
|
return status ;
|
||||||
|
|
||||||
/* find the pointer to that buffer */
|
/* find the pointer to that buffer */
|
||||||
if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
|
bp = bfind( bufn, FALSE, 0) ;
|
||||||
mlwrite("No such buffer");
|
free( bufn) ;
|
||||||
return FALSE;
|
if( bp == NULL) {
|
||||||
|
mlwrite( "No such buffer") ;
|
||||||
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and now execute it as asked */
|
/* and now execute it as asked */
|
||||||
while (n-- > 0)
|
while( status == TRUE && n-- > 0)
|
||||||
if ((status = dobuf(bp)) != TRUE)
|
status = dobuf( bp) ;
|
||||||
return status;
|
|
||||||
return TRUE;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -949,31 +960,28 @@ static void freewhile(struct while_block *wp)
|
|||||||
*
|
*
|
||||||
* int f, n; default flag and numeric arg to pass on to file
|
* int f, n; default flag and numeric arg to pass on to file
|
||||||
*/
|
*/
|
||||||
int execfile(int f, int n)
|
int execfile( int f, int n) {
|
||||||
{
|
int status ; /* return status of name query */
|
||||||
int status; /* return status of name query */
|
char *fname ; /* name of file to execute */
|
||||||
char fname[NSTRING]; /* name of file to execute */
|
char *fspec ; /* full file spec */
|
||||||
char *fspec; /* full file spec */
|
|
||||||
|
|
||||||
if ((status =
|
status = newmlarg( &fname, "File to execute: ", 0) ;
|
||||||
mlreply("File to execute: ", fname, NSTRING - 1)) != TRUE)
|
if( status != TRUE)
|
||||||
return status;
|
return status ;
|
||||||
|
|
||||||
#if 1
|
/* look up the path for the file */
|
||||||
/* look up the path for the file */
|
fspec = flook( fname, FALSE) ; /* used to be TRUE, P.K. */
|
||||||
fspec = flook(fname, FALSE); /* used to by TRUE, P.K. */
|
free( fname) ;
|
||||||
|
|
||||||
/* if it isn't around */
|
/* if it isn't around */
|
||||||
if (fspec == NULL)
|
if( fspec == NULL)
|
||||||
return FALSE;
|
return FALSE ;
|
||||||
|
|
||||||
#endif
|
/* otherwise, execute it */
|
||||||
/* otherwise, execute it */
|
while( status == TRUE && n-- > 0)
|
||||||
while (n-- > 0)
|
status = dofile( fspec) ;
|
||||||
if ((status = dofile(fspec)) != TRUE)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
return TRUE;
|
return status ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user