commands: fix various small issues
Reported by dcb314. Recommendations adopted as is. This closes #137, closes #138, closes #139, and hopefully I got that right this time. Change-Id: I79774f4c398495dba19dec43fbc3f79afd186843
This commit is contained in:
parent
1ccb488d84
commit
ab712d1923
@ -231,8 +231,10 @@ regexp *regcomp(char *exp) {
|
||||
regnpar = 1;
|
||||
regcode = r->program;
|
||||
regc(MAGIC);
|
||||
if (reg(0, &flags) == NULL)
|
||||
if (reg(0, &flags) == NULL) {
|
||||
free(r);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Dig out information for optimizations. */
|
||||
r->regstart = '\0'; /* Worst-case defaults. */
|
||||
|
@ -278,7 +278,7 @@ static int fprintf(int fd, const char *format, ...)
|
||||
while (*fp != 0) {
|
||||
if (*fp == '%' && memchr("sdu", fp[1], 3) != nil) {
|
||||
if (fp > fp0) {
|
||||
if ((r= write(fd, fp0, (fp - fp0))) < 0) return -1;
|
||||
if ((r= write(fd, fp0, (fp - fp0))) < 0) goto error;
|
||||
len+= r;
|
||||
}
|
||||
fp++;
|
||||
@ -287,7 +287,7 @@ static int fprintf(int fd, const char *format, ...)
|
||||
if (*fp == 's') {
|
||||
char *s= va_arg(ap, char *);
|
||||
|
||||
if ((r= write(fd, s, strlen(s))) < 0) return -1;
|
||||
if ((r= write(fd, s, strlen(s))) < 0) goto error;
|
||||
len+= r;
|
||||
} else {
|
||||
int d;
|
||||
@ -308,16 +308,19 @@ static int fprintf(int fd, const char *format, ...)
|
||||
do *--p= '0' + (u % 10); while ((u /= 10) > 0);
|
||||
|
||||
if (d < 0) *--p= '-';
|
||||
if ((r= write(fd, p, (a + sizeof(a)) - p)) < 0) return -1;
|
||||
if ((r= write(fd, p, (a + sizeof(a)) - p)) < 0) goto error;
|
||||
len+= r;
|
||||
}
|
||||
}
|
||||
fp++;
|
||||
}
|
||||
if (fp > fp0) {
|
||||
if ((r= write(fd, fp0, (fp - fp0))) < 0) return -1;
|
||||
if ((r= write(fd, fp0, (fp - fp0))) < 0) goto error;
|
||||
len+= r;
|
||||
}
|
||||
va_end(ap);
|
||||
return len;
|
||||
error:
|
||||
va_end(ap);
|
||||
return -1;
|
||||
}
|
||||
|
@ -726,7 +726,8 @@ int wctx(long flen)
|
||||
fflush(stdout);
|
||||
++attempts;
|
||||
}
|
||||
while ((firstch=(readline(Rxtimeout)) != ACK) && attempts < RETRYMAX);
|
||||
while ((firstch = readline(Rxtimeout)) != ACK &&
|
||||
attempts < RETRYMAX);
|
||||
if (attempts == RETRYMAX) {
|
||||
zperr("No ACK on EOT");
|
||||
return ERROR;
|
||||
|
Loading…
x
Reference in New Issue
Block a user