1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-06-09 13:30:43 +00:00

Unify macro debugging code in eval and exec.

This commit is contained in:
Renaud 2015-01-15 14:36:19 +08:00
parent 259de639e4
commit e3c8805260
3 changed files with 58 additions and 104 deletions

95
eval.c
View File

@ -50,11 +50,6 @@
static int gettyp( char *token) ; static int gettyp( char *token) ;
#if DEBUGM
/* vars needed for macro debugging output */
char outline[ NSTRING] ; /* global string to hold debug line text */
#endif
/* Emacs global flag bit definitions (for gflags). */ /* Emacs global flag bit definitions (for gflags). */
/* if GFREAD is set, current buffer will be set on first file (read in) */ /* if GFREAD is set, current buffer will be set on first file (read in) */
#define GFREAD 1 #define GFREAD 1
@ -791,58 +786,56 @@ int setvar(int f, int n)
/* if $debug == TRUE, every assignment will echo a statment to /* if $debug == TRUE, every assignment will echo a statment to
that effect here. */ that effect here. */
if (macbug) { if( macbug)
char *sp ; /* temp string pointer */ if( abortc == mdbugout( "(((%s:%s:%s)))", ltos( status), var, value))
status = FALSE ;
strcpy(outline, "(((");
/* assignment status */
strcat(outline, ltos(status));
strcat(outline, ":");
/* variable name */
strcat(outline, var);
strcat(outline, ":");
/* and lastly the value we tried to assign */
strcat(outline, value);
strcat(outline, ")))");
/* expand '%' to "%%" so mlwrite wont bitch */
sp = outline;
while (*sp)
if (*sp++ == '%') {
char *ep ; /* ptr to end of outline */
/* advance to the end */
ep = --sp;
while (*ep++);
/* null terminate the string one out */
*(ep + 1) = 0;
/* copy backwards */
while (ep-- > sp)
*(ep + 1) = *ep;
/* and advance sp past the new % */
sp += 2;
}
/* write out the debug line */
mlforce(outline);
update(TRUE);
/* and get the keystroke to hold the output */
if (get1key() == abortc) {
mlforce("(Macro aborted)");
status = FALSE;
}
}
#endif #endif
/* and return it */ /* and return it */
return status; return status;
} }
#if DEBUGM
int mdbugout( char *fmt, char *s1, char *s2, char *s3) {
char outline[ NSTRING] ; /* global string to hold debug line text */
int c ; /* input from kbd */
char *sp ; /* temp string pointer */
/* assignment status ; variable name ; value we tried to assign */
sprintf( outline, fmt, s1, s2, s3) ;
/* expand '%' to "%%" so mlwrite wont bitch */
sp = outline;
while (*sp)
if (*sp++ == '%') {
char *ep ; /* ptr to end of outline */
/* advance to the end */
ep = --sp;
while (*ep++);
/* null terminate the string one out */
*(ep + 1) = 0;
/* copy backwards */
while (ep-- > sp)
*(ep + 1) = *ep;
/* and advance sp past the new % */
sp += 2;
}
/* write out the debug line */
mlforce(outline);
update(TRUE);
/* and get the keystroke to hold the output */
c = get1key() ;
if( c == abortc)
mlforce("(Macro aborted)");
return c ;
}
#endif
/* /*
* Find a variables type and name. * Find a variables type and name.
* *

5
eval.h
View File

@ -4,12 +4,11 @@
#define DEBUGM 1 /* $debug triggers macro debugging */ #define DEBUGM 1 /* $debug triggers macro debugging */
#if DEBUGM #if DEBUGM
/* Vars needed for macro debugging output. */ int mdbugout( char *fmt, char *s1, char *s2, char *s3) ;
extern char outline[] ; /* Global string to hold debug line text. */
#endif #endif
extern int macbug ; /* macro debuging flag */ extern int macbug ; /* macro debuging flag */
extern int cmdstatus ; /* last command status */ extern int cmdstatus ; /* last command status */
extern int flickcode ; /* do flicker supression? */ extern int flickcode ; /* do flicker supression? */

62
exec.c
View File

@ -632,56 +632,18 @@ static int dobuf(struct buffer *bp)
gets echoed and a key needs to be pressed to continue gets echoed and a key needs to be pressed to continue
^G will abort the command */ ^G will abort the command */
if (macbug) { if( macbug) {
char *sp ; /* temp for building debug string */ int c ;
int c ; /* temp character */
/* debug macro name, if levels and lastly the line */
strcpy(outline, "<<<"); c = mdbugout( "<<<%s:%s:%s>>>", bp->b_bname, i_to_a( execlevel),
eline) ;
/* debug macro name */ if( c == abortc) {
strcat(outline, bp->b_bname); freewhile( whlist) ;
strcat(outline, ":"); return FALSE ;
} else if( c == metac) {
/* debug if levels */ macbug = FALSE ;
strcat(outline, i_to_a(execlevel)); }
strcat(outline, ":");
/* and lastly the line */
strcat(outline, eline);
strcat(outline, ">>>");
/* change all '%' to ':' so mlwrite won't expect arguments */
sp = outline;
while (*sp)
if (*sp++ == '%') {
char *ep ; /* ptr to end of outline */
/* advance to the end */
ep = --sp;
while (*ep++);
/* null terminate the string one out */
*(ep + 1) = 0;
/* copy backwards */
while (ep-- > sp)
*(ep + 1) = *ep;
/* and advance sp past the new % */
sp += 2;
}
/* write out the debug line */
mlforce(outline);
update(TRUE);
/* and get the keystroke */
if ((c = get1key()) == abortc) {
mlforce("(Macro aborted)");
freewhile(whlist);
return FALSE;
}
if (c == metac)
macbug = FALSE;
} }
#endif #endif