1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-10-01 17:55:55 -04:00

Introduce bname_t type and reduce need of NBUFN buffer name length constant.

This commit is contained in:
Renaud 2014-05-30 18:08:58 +08:00
parent 494210424c
commit fc79c8e013
5 changed files with 19 additions and 18 deletions

View File

@ -59,9 +59,9 @@ int usebuffer(int f, int n)
{ {
struct buffer *bp; struct buffer *bp;
int s; int s;
char bufn[NBUFN]; bname_t bufn ;
if ((s = mlreply("Use buffer: ", bufn, NBUFN)) != TRUE) if ((s = mlreply("Use buffer: ", bufn, sizeof bufn)) != TRUE)
return s; return s;
if ((bp = bfind(bufn, TRUE, 0)) == NULL) if ((bp = bfind(bufn, TRUE, 0)) == NULL)
return FALSE; return FALSE;
@ -168,9 +168,9 @@ int killbuffer(int f, int n)
{ {
struct buffer *bp; struct buffer *bp;
int s; int s;
char bufn[NBUFN]; bname_t bufn ;
if ((s = mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE) if ((s = mlreply("Kill buffer: ", bufn, sizeof bufn)) != TRUE)
return s; return s;
if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */ if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */
return TRUE; return TRUE;
@ -218,10 +218,10 @@ int zotbuf(struct buffer *bp)
int namebuffer(int f, int n) int namebuffer(int f, int n)
{ {
struct buffer *bp; /* pointer to scan through all buffers */ struct buffer *bp; /* pointer to scan through all buffers */
char bufn[NBUFN]; /* buffer to hold buffer name */ bname_t bufn ; /* buffer to hold buffer name */
/* prompt for and get the new buffer name */ /* prompt for and get the new buffer name */
ask:if (mlreply("Change buffer name to: ", bufn, NBUFN) != ask:if (mlreply("Change buffer name to: ", bufn, sizeof bufn) !=
TRUE) TRUE)
return FALSE; return FALSE;

View File

@ -4,10 +4,11 @@
#include "crypt.h" #include "crypt.h"
#include "line.h" #include "line.h"
#define NBUFN 16 /* # of bytes, buffer name */
#define NPAT 128 /* # of bytes, pattern */ #define NPAT 128 /* # of bytes, pattern */
typedef char fname_t[ 80] ; typedef char fname_t[ 80] ; /* file name */
typedef char bname_t[ 16] ; /* buffer name */
#define NBUFN sizeof( bname_t)
/* /*
* Text is kept in buffers. A buffer header, described below, exists for every * Text is kept in buffers. A buffer header, described below, exists for every
@ -32,7 +33,7 @@ struct buffer {
char b_nwnd; /* Count of windows on buffer */ char b_nwnd; /* Count of windows on buffer */
char b_flag; /* Flags */ char b_flag; /* Flags */
fname_t b_fname ; /* File name */ fname_t b_fname ; /* File name */
char b_bname[NBUFN]; /* Buffer name */ bname_t b_bname ; /* Buffer name */
#if CRYPT #if CRYPT
char b_key[NPAT]; /* current encrypted key */ char b_key[NPAT]; /* current encrypted key */
#endif #endif

12
exec.c
View File

@ -319,7 +319,7 @@ int nextarg(const char *prompt, char *buffer, int size, int terminator)
int storemac(int f, int n) int storemac(int f, int n)
{ {
struct buffer *bp; /* pointer to macro buffer */ struct buffer *bp; /* pointer to macro buffer */
char bname[NBUFN]; /* name of buffer to use */ bname_t bname ; /* name of buffer to use */
/* must have a numeric argument to this function */ /* must have a numeric argument to this function */
if (f == FALSE) { if (f == FALSE) {
@ -366,7 +366,7 @@ 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 */
char bname[NBUFN]; /* name of buffer to use */ bname_t bname ; /* name of buffer to use */
/* a numeric argument means its a numbered macro */ /* a numeric argument means its a numbered macro */
if (f == TRUE) if (f == TRUE)
@ -374,7 +374,7 @@ int storeproc(int f, int n)
/* get the name of the procedure */ /* get the name of the procedure */
if ((status = if ((status =
mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE) mlreply("Procedure name: ", &bname[1], sizeof bname - 2)) != TRUE)
return status; return status;
/* construct the macro buffer name */ /* construct the macro buffer name */
@ -441,10 +441,10 @@ 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[NSTRING]; /* 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, NBUFN)) != TRUE) if ((status = mlreply("Execute buffer: ", bufn, sizeof bufn)) != TRUE)
return status; return status;
/* find the pointer to that buffer */ /* find the pointer to that buffer */
@ -952,7 +952,7 @@ int dofile(char *fname)
struct buffer *bp; /* buffer to place file to exeute */ struct buffer *bp; /* buffer to place file to exeute */
struct buffer *cb; /* temp to hold current buf while we read */ struct buffer *cb; /* temp to hold current buf while we read */
int status; /* results of various calls */ int status; /* results of various calls */
char bname[NBUFN]; /* name of buffer */ bname_t bname ; /* name of buffer */
makename(bname, fname); /* derive the name of the buffer */ makename(bname, fname); /* derive the name of the buffer */
unqname(bname); /* make sure we don't stomp things */ unqname(bname); /* make sure we don't stomp things */

4
file.c
View File

@ -215,7 +215,7 @@ int getfile( const char *fname, boolean lockfl)
struct line *lp; struct line *lp;
int i; int i;
int s; int s;
char bname[NBUFN]; /* buffer name to put file */ bname_t bname ; /* buffer name to put file */
#if MSDOS #if MSDOS
mklower(fname); /* msdos isn't case sensitive */ mklower(fname); /* msdos isn't case sensitive */
@ -238,7 +238,7 @@ int getfile( const char *fname, boolean lockfl)
makename(bname, fname); /* New buffer name. */ makename(bname, fname); /* New buffer name. */
while ((bp = bfind(bname, FALSE, 0)) != NULL) { while ((bp = bfind(bname, FALSE, 0)) != NULL) {
/* old buffer name conflict code */ /* old buffer name conflict code */
s = mlreply("Buffer name: ", bname, NBUFN); s = mlreply("Buffer name: ", bname, sizeof bname);
if (s == ABORT) /* ^G to just quit */ if (s == ABORT) /* ^G to just quit */
return s; return s;
if (s == FALSE) { /* CR to clobber it */ if (s == FALSE) { /* CR to clobber it */

2
main.c
View File

@ -156,7 +156,7 @@ int main(int argc, char **argv)
int searchflag; /* Do we need to search at start? */ int searchflag; /* Do we need to search at start? */
int saveflag; /* temp store for lastflag */ int saveflag; /* temp store for lastflag */
int errflag; /* C error processing? */ int errflag; /* C error processing? */
char bname[NBUFN]; /* buffer name of file to read */ bname_t bname ; /* buffer name of file to read */
#if CRYPT #if CRYPT
int cryptflag; /* encrypting on the way in? */ int cryptflag; /* encrypting on the way in? */
char ekey[NPAT]; /* startup encryption key */ char ekey[NPAT]; /* startup encryption key */