code quality
This commit is contained in:
parent
263f7e5649
commit
1853d44e82
@ -368,7 +368,7 @@ int change_input(const int c) {
|
|||||||
|
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case '*': /* invert page */
|
case '*': /* invert page */
|
||||||
for(int i = 0; i < nextline-1; i++) {
|
for(int i = 0; i < (nextline-1); i++) {
|
||||||
change[topref + i] = !change[topref + i];
|
change[topref + i] = !change[topref + i];
|
||||||
}
|
}
|
||||||
window_change |= CH_RESULT;
|
window_change |= CH_RESULT;
|
||||||
@ -401,6 +401,7 @@ int change_input(const int c) {
|
|||||||
case ctrl('D'):
|
case ctrl('D'):
|
||||||
changestring(input_line, newpat, change, totallines);
|
changestring(input_line, newpat, change, totallines);
|
||||||
free(change);
|
free(change);
|
||||||
|
change = NULL;
|
||||||
input_mode = INPUT_NORMAL;
|
input_mode = INPUT_NORMAL;
|
||||||
horswp_window();
|
horswp_window();
|
||||||
rebuild_reference();
|
rebuild_reference();
|
||||||
@ -420,8 +421,8 @@ int change_input(const int c) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int changestring(const char *from, const char *to, const bool *const change,
|
// XXX: move this
|
||||||
const int change_len) {
|
int changestring(const char *from, const char *to, const bool *const change, const int change_len) {
|
||||||
char newfile[PATHLEN + 1]; /* new file name */
|
char newfile[PATHLEN + 1]; /* new file name */
|
||||||
char oldfile[PATHLEN + 1]; /* old file name */
|
char oldfile[PATHLEN + 1]; /* old file name */
|
||||||
char linenum[NUMLEN + 1]; /* file line number */
|
char linenum[NUMLEN + 1]; /* file line number */
|
||||||
|
@ -102,12 +102,9 @@ static struct keystruct *hashtab[HASHMOD]; /* pointer table */
|
|||||||
/* put the keywords into the symbol table */
|
/* put the keywords into the symbol table */
|
||||||
|
|
||||||
void initsymtab(void) {
|
void initsymtab(void) {
|
||||||
unsigned int i, j;
|
for(unsigned i = 1; i < KEYWORDS; ++i) {
|
||||||
struct keystruct *p;
|
struct keystruct *p = keyword + i;
|
||||||
|
int j = hash(p->text) % HASHMOD;
|
||||||
for(i = 1; i < KEYWORDS; ++i) {
|
|
||||||
p = keyword + i;
|
|
||||||
j = hash(p->text) % HASHMOD;
|
|
||||||
p->next = hashtab[j];
|
p->next = hashtab[j];
|
||||||
hashtab[j] = p;
|
hashtab[j] = p;
|
||||||
}
|
}
|
||||||
|
@ -93,13 +93,14 @@ FILE *myfopen(char *path, char *mode) {
|
|||||||
if(fp && !strchr(mode, 'b')) { SETMODE(fileno(fp), O_TEXT); }
|
if(fp && !strchr(mode, 'b')) { SETMODE(fileno(fp), O_TEXT); }
|
||||||
#endif /* SETMODE */
|
#endif /* SETMODE */
|
||||||
|
|
||||||
if(fp && (fcntl(fileno(fp), F_SETFD, CLOSE_ON_EXEC) != -1))
|
if(fp && (fcntl(fileno(fp), F_SETFD, CLOSE_ON_EXEC) != -1)) {
|
||||||
return (fp);
|
return (fp);
|
||||||
|
|
||||||
else {
|
|
||||||
if(fp) fclose(fp);
|
|
||||||
return (NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(fp) {
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *mypopen(char *cmd, char *mode) {
|
FILE *mypopen(char *cmd, char *mode) {
|
||||||
@ -126,16 +127,17 @@ FILE *mypopen(char *cmd, char *mode) {
|
|||||||
close(yourside);
|
close(yourside);
|
||||||
execlp(shell, basename(shell), "-c", cmd, (void *)0);
|
execlp(shell, basename(shell), "-c", cmd, (void *)0);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
} else if(pid > 0)
|
} else if(pid > 0) {
|
||||||
tstat = signal(SIGTSTP, SIG_DFL);
|
tstat = signal(SIGTSTP, SIG_DFL);
|
||||||
if(pid == -1) return (NULL);
|
}
|
||||||
|
if(pid == -1) {
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
popen_pid[myside] = pid;
|
popen_pid[myside] = pid;
|
||||||
(void)close(yourside);
|
(void)close(yourside);
|
||||||
return (fdopen(myside, mode));
|
return (fdopen(myside, mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* HBB 20010705: renamed from 'pclose', which would collide with
|
|
||||||
* system-supplied function of same name */
|
|
||||||
int mypclose(FILE *ptr) {
|
int mypclose(FILE *ptr) {
|
||||||
int f;
|
int f;
|
||||||
pid_t r;
|
pid_t r;
|
||||||
@ -143,17 +145,17 @@ int mypclose(FILE *ptr) {
|
|||||||
sighandler_t hstat, istat, qstat;
|
sighandler_t hstat, istat, qstat;
|
||||||
|
|
||||||
f = fileno(ptr);
|
f = fileno(ptr);
|
||||||
(void)fclose(ptr);
|
UNUSED(fclose(ptr));
|
||||||
istat = signal(SIGINT, SIG_IGN);
|
istat = signal(SIGINT, SIG_IGN);
|
||||||
qstat = signal(SIGQUIT, SIG_IGN);
|
qstat = signal(SIGQUIT, SIG_IGN);
|
||||||
hstat = signal(SIGHUP, SIG_IGN);
|
hstat = signal(SIGHUP, SIG_IGN);
|
||||||
while((r = wait(&status)) != popen_pid[f] && r != -1)
|
while((r = wait(&status)) != popen_pid[f] && r != -1)
|
||||||
; /* nothing */
|
; /* nothing */
|
||||||
if(r == -1) status = -1;
|
if(r == -1) status = -1;
|
||||||
(void)signal(SIGINT, istat);
|
UNUSED(signal(SIGINT, istat));
|
||||||
(void)signal(SIGQUIT, qstat);
|
UNUSED(signal(SIGQUIT, qstat));
|
||||||
(void)signal(SIGHUP, hstat);
|
UNUSED(signal(SIGHUP, hstat));
|
||||||
(void)signal(SIGTSTP, tstat);
|
UNUSED(signal(SIGTSTP, tstat));
|
||||||
/* mark this pipe closed */
|
/* mark this pipe closed */
|
||||||
popen_pid[f] = 0;
|
popen_pid[f] = 0;
|
||||||
return (status);
|
return (status);
|
||||||
|
Loading…
Reference in New Issue
Block a user