mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16:23 -05:00
Replace strncpy by mystrscpy.
This commit is contained in:
parent
033012f645
commit
f0836bb66a
32
Makefile
32
Makefile
@ -1,8 +1,8 @@
|
|||||||
# Makefile for emacs, updated Fri, Feb 13, 2015 12:02:52 PM
|
# Makefile for emacs, updated Tue, Jul 31, 2018 20:37:16
|
||||||
|
|
||||||
SRC=basic.c bind.c bindable.c buffer.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c input.c isearch.c line.c lock.c main.c mingw32.c mlout.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c window.c word.c wrapper.c wscreen.c
|
SRC=basic.c bind.c bindable.c buffer.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c input.c isearch.c line.c lock.c main.c mingw32.c mlout.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c util.c window.c word.c wrapper.c wscreen.c
|
||||||
OBJ=basic.o bind.o bindable.o buffer.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o input.o isearch.o line.o lock.o main.o mingw32.o mlout.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o window.o word.o wrapper.o wscreen.o
|
OBJ=basic.o bind.o bindable.o buffer.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o input.o isearch.o line.o lock.o main.o mingw32.o mlout.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o util.o window.o word.o wrapper.o wscreen.o
|
||||||
HDR=basic.h bind.h bindable.h buffer.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h mlout.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h wscreen.h
|
HDR=basic.h bind.h bindable.h buffer.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h mlout.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h util.h version.h window.h word.h wrapper.h wscreen.h
|
||||||
|
|
||||||
# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them
|
# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them
|
||||||
|
|
||||||
@ -47,7 +47,8 @@ ifeq ($(uname_S),CYGWIN)
|
|||||||
LIBS=-lcurses
|
LIBS=-lcurses
|
||||||
endif
|
endif
|
||||||
ifeq ($(uname_S),MINGW32)
|
ifeq ($(uname_S),MINGW32)
|
||||||
DEFINES=-DAUTOCONF -DSYSV -DMINGW32 -DPROGRAM=$(PROGRAM)
|
# DEFINES=-DAUTOCONF -DSYSV -DMINGW32 -DPROGRAM=$(PROGRAM)
|
||||||
|
DEFINES=-DAUTOCONF -DPOSIX -DSYSV -DPROGRAM=$(PROGRAM) -IC:/MinGW/include/ncursesw
|
||||||
LIBS=
|
LIBS=
|
||||||
endif
|
endif
|
||||||
#DEFINES=-DAUTOCONF
|
#DEFINES=-DAUTOCONF
|
||||||
@ -132,13 +133,13 @@ depend: ${SRC}
|
|||||||
basic.o: basic.c basic.h retcode.h input.h bind.h mlout.h random.h \
|
basic.o: basic.c basic.h retcode.h input.h bind.h mlout.h random.h \
|
||||||
terminal.h defines.h utf8.h window.h buffer.h line.h
|
terminal.h defines.h utf8.h window.h buffer.h line.h
|
||||||
bind.o: bind.c bind.h estruct.h bindable.h buffer.h line.h retcode.h \
|
bind.o: bind.c bind.h estruct.h bindable.h buffer.h line.h retcode.h \
|
||||||
utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h window.h \
|
utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h util.h \
|
||||||
defines.h
|
window.h defines.h
|
||||||
bindable.o: bindable.c bindable.h defines.h buffer.h line.h retcode.h \
|
bindable.o: bindable.c bindable.h defines.h buffer.h line.h retcode.h \
|
||||||
utf8.h display.h estruct.h file.h input.h bind.h lock.h mlout.h \
|
utf8.h display.h estruct.h file.h input.h bind.h lock.h mlout.h \
|
||||||
terminal.h
|
terminal.h
|
||||||
buffer.o: buffer.c buffer.h line.h retcode.h utf8.h defines.h estruct.h \
|
buffer.o: buffer.c buffer.h line.h retcode.h utf8.h defines.h estruct.h \
|
||||||
file.h input.h bind.h mlout.h window.h
|
file.h input.h bind.h mlout.h util.h window.h
|
||||||
display.o: display.c display.h estruct.h utf8.h buffer.h line.h retcode.h \
|
display.o: display.c display.h estruct.h utf8.h buffer.h line.h retcode.h \
|
||||||
input.h bind.h termio.h terminal.h defines.h version.h wrapper.h \
|
input.h bind.h termio.h terminal.h defines.h version.h wrapper.h \
|
||||||
window.h
|
window.h
|
||||||
@ -147,28 +148,29 @@ ebind.o: ebind.c ebind.h basic.h retcode.h bind.h estruct.h bindable.h \
|
|||||||
search.h spawn.h window.h defines.h word.h
|
search.h spawn.h window.h defines.h word.h
|
||||||
eval.o: eval.c eval.h basic.h retcode.h bind.h buffer.h line.h utf8.h \
|
eval.o: eval.c eval.h basic.h retcode.h bind.h buffer.h line.h utf8.h \
|
||||||
display.h estruct.h exec.h execute.h flook.h input.h random.h search.h \
|
display.h estruct.h exec.h execute.h flook.h input.h random.h search.h \
|
||||||
terminal.h defines.h termio.h version.h window.h
|
terminal.h defines.h termio.h util.h version.h window.h
|
||||||
exec.o: exec.c exec.h retcode.h buffer.h line.h utf8.h bind.h display.h \
|
exec.o: exec.c exec.h retcode.h buffer.h line.h utf8.h bind.h display.h \
|
||||||
estruct.h eval.h file.h flook.h input.h random.h window.h defines.h
|
estruct.h eval.h file.h flook.h input.h random.h util.h window.h \
|
||||||
|
defines.h
|
||||||
execute.o: execute.c execute.h estruct.h bind.h random.h retcode.h \
|
execute.o: execute.c execute.h estruct.h bind.h random.h retcode.h \
|
||||||
display.h utf8.h file.h buffer.h line.h input.h mlout.h search.h \
|
display.h utf8.h file.h buffer.h line.h input.h mlout.h search.h \
|
||||||
terminal.h defines.h window.h
|
terminal.h defines.h window.h
|
||||||
file.o: file.c file.h buffer.h line.h retcode.h utf8.h defines.h \
|
file.o: file.c file.h buffer.h line.h retcode.h utf8.h defines.h \
|
||||||
display.h estruct.h execute.h fileio.h input.h bind.h lock.h mlout.h \
|
display.h estruct.h execute.h fileio.h input.h bind.h lock.h mlout.h \
|
||||||
window.h
|
util.h window.h
|
||||||
fileio.o: fileio.c fileio.h defines.h retcode.h utf8.h
|
fileio.o: fileio.c fileio.h defines.h retcode.h utf8.h
|
||||||
flook.o: flook.c flook.h retcode.h defines.h fileio.h
|
flook.o: flook.c flook.h retcode.h defines.h fileio.h
|
||||||
input.o: input.c input.h bind.h estruct.h bindable.h display.h utf8.h \
|
input.o: input.c input.h bind.h estruct.h bindable.h display.h utf8.h \
|
||||||
exec.h retcode.h names.h terminal.h defines.h wrapper.h
|
exec.h retcode.h names.h terminal.h defines.h wrapper.h
|
||||||
isearch.o: isearch.c isearch.h basic.h retcode.h buffer.h line.h utf8.h \
|
isearch.o: isearch.c isearch.h basic.h retcode.h buffer.h line.h utf8.h \
|
||||||
display.h estruct.h exec.h input.h bind.h search.h terminal.h defines.h \
|
display.h estruct.h exec.h input.h bind.h search.h terminal.h defines.h \
|
||||||
window.h
|
util.h window.h
|
||||||
line.o: line.c line.h retcode.h utf8.h buffer.h estruct.h mlout.h \
|
line.o: line.c line.h retcode.h utf8.h buffer.h estruct.h mlout.h \
|
||||||
window.h defines.h
|
window.h defines.h
|
||||||
lock.o: lock.c estruct.h lock.h
|
lock.o: lock.c estruct.h lock.h
|
||||||
main.o: main.c estruct.h basic.h retcode.h bind.h bindable.h buffer.h \
|
main.o: main.c estruct.h basic.h retcode.h bind.h bindable.h buffer.h \
|
||||||
line.h utf8.h display.h eval.h execute.h file.h lock.h mlout.h random.h \
|
line.h utf8.h display.h eval.h execute.h file.h lock.h mlout.h random.h \
|
||||||
search.h terminal.h defines.h termio.h version.h window.h
|
search.h terminal.h defines.h termio.h util.h version.h window.h
|
||||||
mingw32.o: mingw32.c
|
mingw32.o: mingw32.c
|
||||||
mlout.o: mlout.c mlout.h
|
mlout.o: mlout.c mlout.h
|
||||||
names.o: names.c names.h basic.h retcode.h bind.h bindable.h buffer.h \
|
names.o: names.c names.h basic.h retcode.h bind.h bindable.h buffer.h \
|
||||||
@ -182,7 +184,8 @@ random.o: random.c random.h retcode.h basic.h buffer.h line.h utf8.h \
|
|||||||
region.o: region.c region.h line.h retcode.h utf8.h buffer.h estruct.h \
|
region.o: region.c region.h line.h retcode.h utf8.h buffer.h estruct.h \
|
||||||
mlout.h random.h window.h defines.h
|
mlout.h random.h window.h defines.h
|
||||||
search.o: search.c search.h line.h retcode.h utf8.h basic.h buffer.h \
|
search.o: search.c search.h line.h retcode.h utf8.h basic.h buffer.h \
|
||||||
display.h estruct.h input.h bind.h mlout.h terminal.h defines.h window.h
|
display.h estruct.h input.h bind.h mlout.h terminal.h defines.h util.h \
|
||||||
|
window.h
|
||||||
spawn.o: spawn.c spawn.h defines.h buffer.h line.h retcode.h utf8.h \
|
spawn.o: spawn.c spawn.h defines.h buffer.h line.h retcode.h utf8.h \
|
||||||
display.h estruct.h exec.h file.h flook.h input.h bind.h terminal.h \
|
display.h estruct.h exec.h file.h flook.h input.h bind.h terminal.h \
|
||||||
window.h
|
window.h
|
||||||
@ -190,6 +193,7 @@ tcap.o: tcap.c terminal.h defines.h retcode.h utf8.h display.h estruct.h \
|
|||||||
termio.h
|
termio.h
|
||||||
termio.o: termio.c termio.h utf8.h estruct.h retcode.h
|
termio.o: termio.c termio.h utf8.h estruct.h retcode.h
|
||||||
utf8.o: utf8.c utf8.h
|
utf8.o: utf8.c utf8.h
|
||||||
|
util.o: util.c util.h
|
||||||
window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \
|
window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \
|
||||||
basic.h display.h estruct.h execute.h terminal.h wrapper.h
|
basic.h display.h estruct.h execute.h terminal.h wrapper.h
|
||||||
word.o: word.c word.h basic.h retcode.h buffer.h line.h utf8.h estruct.h \
|
word.o: word.c word.h basic.h retcode.h buffer.h line.h utf8.h estruct.h \
|
||||||
|
4
bind.c
4
bind.c
@ -25,6 +25,7 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "line.h"
|
#include "line.h"
|
||||||
#include "names.h"
|
#include "names.h"
|
||||||
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
|
||||||
@ -348,8 +349,7 @@ static int buildlist( char *mstring) {
|
|||||||
continue ;
|
continue ;
|
||||||
#endif
|
#endif
|
||||||
/* add in the command name */
|
/* add in the command name */
|
||||||
strncpy( outseq, nptr->n_name, sizeof outseq - 1) ;
|
mystrscpy( outseq, nptr->n_name, sizeof outseq) ;
|
||||||
outseq[ sizeof outseq - 1] = '\0' ;
|
|
||||||
cpos = strlen(outseq);
|
cpos = strlen(outseq);
|
||||||
|
|
||||||
/* search down any keys bound to this */
|
/* search down any keys bound to this */
|
||||||
|
7
buffer.c
7
buffer.c
@ -21,6 +21,7 @@
|
|||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "mlout.h"
|
#include "mlout.h"
|
||||||
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
|
||||||
@ -247,8 +248,7 @@ ask:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy buffer name to structure */
|
/* copy buffer name to structure */
|
||||||
strncpy( curbp->b_bname, bufn, sizeof( bname_t) - 1) ;
|
mystrscpy( curbp->b_bname, bufn, sizeof( bname_t)) ;
|
||||||
curbp->b_bname[ sizeof( bname_t) - 1] = '\0' ;
|
|
||||||
free( bufn) ;
|
free( bufn) ;
|
||||||
|
|
||||||
curwp->w_flag |= WFMODE ; /* make mode line replot */
|
curwp->w_flag |= WFMODE ; /* make mode line replot */
|
||||||
@ -525,8 +525,7 @@ struct buffer *bfind( const char *bname, int cflag, int bflag)
|
|||||||
bp->b_nwnd = 0;
|
bp->b_nwnd = 0;
|
||||||
bp->b_linep = lp;
|
bp->b_linep = lp;
|
||||||
bp->b_fname[ 0] = '\0' ;
|
bp->b_fname[ 0] = '\0' ;
|
||||||
strncpy( bp->b_bname, bname, sizeof( bname_t) - 1) ;
|
mystrscpy( bp->b_bname, bname, sizeof( bname_t)) ;
|
||||||
bp->b_bname[ sizeof( bname_t) - 1] = '\0' ;
|
|
||||||
lp->l_fp = lp;
|
lp->l_fp = lp;
|
||||||
lp->l_bp = lp;
|
lp->l_bp = lp;
|
||||||
}
|
}
|
||||||
|
19
eval.c
19
eval.c
@ -29,6 +29,7 @@
|
|||||||
#include "search.h"
|
#include "search.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "termio.h"
|
#include "termio.h"
|
||||||
|
#include "util.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
@ -437,8 +438,7 @@ static char *gtfun( char *fname) {
|
|||||||
ressize = sz + 1 ;
|
ressize = sz + 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy( result, arg1, sz) ;
|
mystrscpy( result, arg1, sz + 1) ;
|
||||||
result[ sz] = 0 ;
|
|
||||||
retstr = result ;
|
retstr = result ;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
@ -482,8 +482,7 @@ static char *gtfun( char *fname) {
|
|||||||
ressize = sz + 1 ;
|
ressize = sz + 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy( result, &arg1[ start], sz) ;
|
mystrscpy( result, &arg1[ start], sz + 1) ;
|
||||||
result[ sz] = 0 ;
|
|
||||||
retstr = result ;
|
retstr = result ;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
@ -838,9 +837,8 @@ int setvar(int f, int n)
|
|||||||
if( value == NULL)
|
if( value == NULL)
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
|
|
||||||
/* a bit overcautious here in using strncpy */
|
/* a bit overcautious here */
|
||||||
strncpy( value, i_to_a( n), NSTRING - 1) ;
|
mystrscpy( value, i_to_a( n), NSTRING) ;
|
||||||
value[ NSTRING - 1] = '\0' ;
|
|
||||||
} else {
|
} else {
|
||||||
status = newmlarg( &value, "Value: ", 0) ;
|
status = newmlarg( &value, "Value: ", 0) ;
|
||||||
if (status != TRUE)
|
if (status != TRUE)
|
||||||
@ -928,8 +926,7 @@ fvar:
|
|||||||
for (vnum = 0; vnum < MAXVARS; vnum++)
|
for (vnum = 0; vnum < MAXVARS; vnum++)
|
||||||
if (uv[vnum].u_name[0] == 0) {
|
if (uv[vnum].u_name[0] == 0) {
|
||||||
vtype = TKVAR;
|
vtype = TKVAR;
|
||||||
strncpy( uv[ vnum].u_name, &var[ 1], NVSIZE) ;
|
mystrscpy( uv[ vnum].u_name, &var[ 1], NVSIZE + 1) ;
|
||||||
uv[ vnum].u_name[ NVSIZE] = '\0' ;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1254,8 +1251,8 @@ char *getval(char *token)
|
|||||||
blen = bp->b_dotp->l_used - bp->b_doto;
|
blen = bp->b_dotp->l_used - bp->b_doto;
|
||||||
if( blen >= sizeof buf)
|
if( blen >= sizeof buf)
|
||||||
blen = sizeof buf - 1 ;
|
blen = sizeof buf - 1 ;
|
||||||
strncpy(buf, bp->b_dotp->l_text + bp->b_doto, blen);
|
|
||||||
buf[blen] = 0;
|
mystrscpy( buf, bp->b_dotp->l_text + bp->b_doto, blen + 1) ;
|
||||||
|
|
||||||
/* and step the buffer's line ptr ahead a line */
|
/* and step the buffer's line ptr ahead a line */
|
||||||
bp->b_dotp = bp->b_dotp->l_fp;
|
bp->b_dotp = bp->b_dotp->l_fp;
|
||||||
|
20
exec.c
20
exec.c
@ -24,6 +24,7 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "line.h"
|
#include "line.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
|
||||||
@ -182,8 +183,7 @@ static int docmd( char *cline) {
|
|||||||
if( !is_it_cmd( tkn)) {
|
if( !is_it_cmd( tkn)) {
|
||||||
f = TRUE;
|
f = TRUE;
|
||||||
/* macarg already includes a getval, skip for now
|
/* macarg already includes a getval, skip for now
|
||||||
strncpy( tkn, getval( tkn), sizeof tkn - 1) ;
|
mystrscpy( tkn, getval( tkn), sizeof tkn) ;
|
||||||
tkn[ sizeof tkn - 1] = '\0' ;
|
|
||||||
*/
|
*/
|
||||||
n = atoi(tkn);
|
n = atoi(tkn);
|
||||||
|
|
||||||
@ -316,8 +316,7 @@ static char *token( char *srcstr, char *tok, int maxtoksize) {
|
|||||||
if( newtok == NULL)
|
if( newtok == NULL)
|
||||||
tok[ 0] = 0 ;
|
tok[ 0] = 0 ;
|
||||||
else {
|
else {
|
||||||
strncpy( tok, newtok, maxtoksize - 1) ;
|
mystrscpy( tok, newtok, maxtoksize) ;
|
||||||
tok[ maxtoksize - 1] = 0 ;
|
|
||||||
free( newtok) ;
|
free( newtok) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,8 +343,7 @@ boolean gettokval( char *tok, int size) {
|
|||||||
return FALSE ;
|
return FALSE ;
|
||||||
|
|
||||||
/* evaluate it */
|
/* evaluate it */
|
||||||
strncpy( tok, getval( tmpbuf), size - 1) ;
|
mystrscpy( tok, getval( tmpbuf), size) ;
|
||||||
tok[ size - 1] = '\0' ;
|
|
||||||
free( tmpbuf) ;
|
free( tmpbuf) ;
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
@ -457,8 +455,7 @@ int storeproc( int f, int n) {
|
|||||||
|
|
||||||
/* construct the macro buffer name */
|
/* construct the macro buffer name */
|
||||||
bname[ 0] = '*';
|
bname[ 0] = '*';
|
||||||
strncpy( &bname[ 1], name, sizeof bname - 3) ;
|
mystrscpy( &bname[ 1], name, sizeof bname - 2) ;
|
||||||
bname[ sizeof bname - 2] = '\0' ;
|
|
||||||
strcat( bname, "*") ;
|
strcat( bname, "*") ;
|
||||||
free( name) ;
|
free( name) ;
|
||||||
|
|
||||||
@ -497,8 +494,7 @@ int execproc( int f, int n) {
|
|||||||
|
|
||||||
/* construct the buffer name */
|
/* construct the buffer name */
|
||||||
bufn[ 0] = '*' ;
|
bufn[ 0] = '*' ;
|
||||||
strncpy( &bufn[ 1], name, sizeof bufn - 3) ;
|
mystrscpy( &bufn[ 1], name, sizeof bufn - 2) ;
|
||||||
bufn[ sizeof bufn - 2] = '\0' ;
|
|
||||||
strcat( bufn, "*") ;
|
strcat( bufn, "*") ;
|
||||||
free( name) ;
|
free( name) ;
|
||||||
|
|
||||||
@ -689,8 +685,8 @@ static int dobuf(struct buffer *bp)
|
|||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
strncpy(eline, lp->l_text, linlen);
|
|
||||||
eline[linlen] = 0; /* make sure it ends */
|
mystrscpy( eline, lp->l_text, linlen + 1) ;
|
||||||
|
|
||||||
/* trim leading whitespace */
|
/* trim leading whitespace */
|
||||||
while (*eline == ' ' || *eline == '\t')
|
while (*eline == ' ' || *eline == '\t')
|
||||||
|
13
file.c
13
file.c
@ -26,6 +26,7 @@
|
|||||||
#include "line.h"
|
#include "line.h"
|
||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
#include "mlout.h"
|
#include "mlout.h"
|
||||||
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -223,8 +224,7 @@ int getfile( const char *fname, boolean lockfl) {
|
|||||||
makename( bname, fname) ;
|
makename( bname, fname) ;
|
||||||
break ;
|
break ;
|
||||||
} else { /* TRUE */
|
} else { /* TRUE */
|
||||||
strncpy( bname, new_bname, sizeof bname - 1) ;
|
mystrscpy( bname, new_bname, sizeof bname) ;
|
||||||
bname[ sizeof bname - 1] = '\0' ;
|
|
||||||
free( new_bname) ;
|
free( new_bname) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,10 +282,8 @@ int readin(const char *fname, boolean lockfl)
|
|||||||
return status ;
|
return status ;
|
||||||
|
|
||||||
bp->b_flag &= ~(BFINVS | BFCHG);
|
bp->b_flag &= ~(BFINVS | BFCHG);
|
||||||
if( fname != bp->b_fname) { /* Copy if source differs from destination */
|
if( fname != bp->b_fname) /* Copy if source differs from destination */
|
||||||
strncpy( bp->b_fname, fname, sizeof( fname_t) - 1) ;
|
mystrscpy( bp->b_fname, fname, sizeof( fname_t)) ;
|
||||||
bp->b_fname[ sizeof( fname_t) - 1] = '\0' ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* let a user macro get hold of things...if he wants */
|
/* let a user macro get hold of things...if he wants */
|
||||||
execute(META | SPEC | 'R', FALSE, 1);
|
execute(META | SPEC | 'R', FALSE, 1);
|
||||||
@ -567,8 +565,7 @@ int filename( int f, int n) {
|
|||||||
else if( status == FALSE)
|
else if( status == FALSE)
|
||||||
curbp->b_fname[ 0] = '\0' ;
|
curbp->b_fname[ 0] = '\0' ;
|
||||||
else { /* TRUE */
|
else { /* TRUE */
|
||||||
strncpy( curbp->b_fname, fname, sizeof( fname_t) - 1) ;
|
mystrscpy( curbp->b_fname, fname, sizeof( fname_t)) ;
|
||||||
curbp->b_fname[ sizeof( fname_t) - 1] = '\0' ;
|
|
||||||
free( fname) ;
|
free( fname) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "line.h"
|
#include "line.h"
|
||||||
#include "search.h"
|
#include "search.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -198,8 +199,7 @@ static int isearch(int f, int n)
|
|||||||
cmd_reexecute = -1; /* We're not re-executing (yet?) */
|
cmd_reexecute = -1; /* We're not re-executing (yet?) */
|
||||||
cmd_offset = 0; /* Start at the beginning of the buff */
|
cmd_offset = 0; /* Start at the beginning of the buff */
|
||||||
cmd_buff[0] = '\0'; /* Init the command buffer */
|
cmd_buff[0] = '\0'; /* Init the command buffer */
|
||||||
strncpy( pat_save, pat, sizeof pat_save - 1) ; /* Save the old pattern string */
|
mystrscpy( pat_save, pat, sizeof pat_save) ; /* Save the old pattern string */
|
||||||
pat_save[ sizeof pat_save - 1] = '\0' ;
|
|
||||||
curline = curwp->w_dotp; /* Save the current line pointer */
|
curline = curwp->w_dotp; /* Save the current line pointer */
|
||||||
curoff = curwp->w_doto; /* Save the current offset */
|
curoff = curwp->w_doto; /* Save the current offset */
|
||||||
init_direction = n; /* Save the initial search direction */
|
init_direction = n; /* Save the initial search direction */
|
||||||
@ -277,7 +277,7 @@ static int isearch(int f, int n)
|
|||||||
curwp->w_dotp = curline; /* Reset the line pointer */
|
curwp->w_dotp = curline; /* Reset the line pointer */
|
||||||
curwp->w_doto = curoff; /* and the offset */
|
curwp->w_doto = curoff; /* and the offset */
|
||||||
n = init_direction; /* Reset the search direction */
|
n = init_direction; /* Reset the search direction */
|
||||||
strncpy( pat, pat_save, sizeof pat) ; /* Restore the old search str */
|
mystrscpy( pat, pat_save, sizeof pat) ; /* Restore the old search str */
|
||||||
cmd_reexecute = 0; /* Start the whole mess over */
|
cmd_reexecute = 0; /* Start the whole mess over */
|
||||||
goto start_over; /* Let it take care of itself */
|
goto start_over; /* Let it take care of itself */
|
||||||
|
|
||||||
|
7
main.c
7
main.c
@ -88,6 +88,7 @@
|
|||||||
#include "search.h"
|
#include "search.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "termio.h"
|
#include "termio.h"
|
||||||
|
#include "util.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
@ -221,8 +222,7 @@ int main(int argc, char **argv)
|
|||||||
case 's': /* -s for initial search string */
|
case 's': /* -s for initial search string */
|
||||||
case 'S':
|
case 'S':
|
||||||
searchflag = TRUE;
|
searchflag = TRUE;
|
||||||
strncpy( pat, &argv[ carg][ 2], sizeof pat - 1) ;
|
mystrscpy( pat, &argv[ carg][ 2], sizeof pat) ;
|
||||||
pat[ sizeof pat -1] = 0 ;
|
|
||||||
break;
|
break;
|
||||||
case 'v': /* -v for View File */
|
case 'v': /* -v for View File */
|
||||||
case 'V':
|
case 'V':
|
||||||
@ -268,8 +268,7 @@ int main(int argc, char **argv)
|
|||||||
exit( EXIT_FAILURE) ;
|
exit( EXIT_FAILURE) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy( bp->b_fname, argv[ carg], sizeof bp->b_fname - 1) ; /* max filename length limited to NFILEN - 1 (79) */
|
mystrscpy( bp->b_fname, argv[ carg], sizeof bp->b_fname) ; /* max filename length limited to NFILEN - 1 */
|
||||||
bp->b_fname[ sizeof bp->b_fname - 1] = 0 ;
|
|
||||||
bp->b_active = FALSE;
|
bp->b_active = FALSE;
|
||||||
if (firstfile) {
|
if (firstfile) {
|
||||||
firstbp = bp;
|
firstbp = bp;
|
||||||
|
8
pklock.c
8
pklock.c
@ -20,6 +20,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
/* Maximum file length name 255 */
|
/* Maximum file length name 255 */
|
||||||
#define MAXLOCK 256
|
#define MAXLOCK 256
|
||||||
#define MAXNAME 128
|
#define MAXNAME 128
|
||||||
@ -51,8 +53,7 @@ char *dolock( const char *fname)
|
|||||||
int mask;
|
int mask;
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
|
|
||||||
strncpy( lname, fname, sizeof lname - 1 - 6) ;
|
mystrscpy( lname, fname, sizeof lname - 6) ;
|
||||||
lname[ sizeof lname - 1 - 6] = 0 ;
|
|
||||||
strcat( lname, ".lock~") ;
|
strcat( lname, ".lock~") ;
|
||||||
|
|
||||||
/* check that we are not being cheated, qname must point to */
|
/* check that we are not being cheated, qname must point to */
|
||||||
@ -126,8 +127,7 @@ char *dolock( const char *fname)
|
|||||||
char *undolock( const char *fname) {
|
char *undolock( const char *fname) {
|
||||||
char lname[ MAXLOCK] ;
|
char lname[ MAXLOCK] ;
|
||||||
|
|
||||||
strncpy( lname, fname, sizeof lname - 1 - 6) ;
|
mystrscpy( lname, fname, sizeof lname - 6) ;
|
||||||
lname[ sizeof lname - 1 - 6] = 0 ;
|
|
||||||
strcat( lname, ".lock~") ;
|
strcat( lname, ".lock~") ;
|
||||||
if (unlink(lname) != 0) {
|
if (unlink(lname) != 0) {
|
||||||
if (errno == EACCES || errno == ENOENT)
|
if (errno == EACCES || errno == ENOENT)
|
||||||
|
7
search.c
7
search.c
@ -72,6 +72,7 @@
|
|||||||
#include "line.h"
|
#include "line.h"
|
||||||
#include "mlout.h"
|
#include "mlout.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
/* The variable matchlen holds the length of the matched
|
/* The variable matchlen holds the length of the matched
|
||||||
@ -683,8 +684,7 @@ int eq(unsigned char bc, unsigned char pc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) {
|
void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) {
|
||||||
strncpy( tpat, prompt, 14) ; /* copy prompt to output string */
|
mystrscpy( tpat, prompt, 15) ; /* copy prompt to output string */
|
||||||
tpat[ 14] = '\0' ; /* longest prompt is "Reverse Search" */
|
|
||||||
strcat( tpat, " (") ; /* build new prompt string */
|
strcat( tpat, " (") ; /* build new prompt string */
|
||||||
expandp( apat, &tpat[ strlen( tpat)], tpat_size) ; /* add old pattern */
|
expandp( apat, &tpat[ strlen( tpat)], tpat_size) ; /* add old pattern */
|
||||||
strcat( tpat, ")<Meta>: ") ;
|
strcat( tpat, ")<Meta>: ") ;
|
||||||
@ -716,8 +716,7 @@ static int readpattern(char *prompt, char *apat, int srch)
|
|||||||
*/
|
*/
|
||||||
status = newmlargt( &dynpat, tpat, NPAT) ;
|
status = newmlargt( &dynpat, tpat, NPAT) ;
|
||||||
if( status == TRUE) {
|
if( status == TRUE) {
|
||||||
strncpy( apat, dynpat, NPAT - 1) ;
|
mystrscpy( apat, dynpat, NPAT) ;
|
||||||
apat[ NPAT - 1] = 0 ;
|
|
||||||
free( dynpat) ;
|
free( dynpat) ;
|
||||||
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
|
||||||
|
17
util.c
Normal file
17
util.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
/* Safe zeroing, no complaining about overlap */
|
||||||
|
void mystrscpy(char *dst, const char *src, int size)
|
||||||
|
{
|
||||||
|
if (!size)
|
||||||
|
return;
|
||||||
|
while (--size) {
|
||||||
|
char c = *src++;
|
||||||
|
if (!c)
|
||||||
|
break;
|
||||||
|
*dst++ = c;
|
||||||
|
}
|
||||||
|
*dst = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user