Clean up some details, to make it clear to gcc that we do not try to do

something stupid.
This commit is contained in:
Poul-Henning Kamp 1995-02-10 05:25:00 +00:00
parent 070b9f121a
commit 833ccb5d7a
3 changed files with 28 additions and 21 deletions

View File

@ -12,6 +12,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@ -46,6 +47,8 @@ int decode_line(char *line, char *out_buf);
* reflected in the exit status. In this case, the delta is left in * reflected in the exit status. In this case, the delta is left in
* 'deltadir'. * 'deltadir'.
*/ */
int
main(int argc, char **argv) main(int argc, char **argv)
{ {
char *log_file = NULL; char *log_file = NULL;
@ -61,7 +64,10 @@ main(int argc, char **argv)
STRING('l', log_file) STRING('l', log_file)
ENDOPTS ENDOPTS
if (delta_dir == NULL || piece_dir == NULL && (base_dir == NULL || argc>1)) if (delta_dir == NULL)
usage();
if (piece_dir == NULL && (base_dir == NULL || argc>1))
usage(); usage();
if (log_file != NULL) if (log_file != NULL)
@ -197,13 +203,13 @@ int
read_piece(char *input_file) read_piece(char *input_file)
{ {
int status = 0; int status = 0;
FILE *ifp, *ofp; FILE *ifp, *ofp = 0;
int decoding = 0; int decoding = 0;
int line_no = 0; int line_no = 0;
int i, n; int i, n;
int pce, npieces; int pce, npieces;
unsigned claimed_cksum; unsigned claimed_cksum;
unsigned short cksum; unsigned short cksum = 0;
char out_buf[200]; char out_buf[200];
char line[200]; char line[200];
char delta[30]; char delta[30];
@ -226,24 +232,25 @@ read_piece(char *input_file)
*/ */
if (!decoding) if (!decoding)
{ {
if (sscanf(line, "CTM_MAIL BEGIN %s %d %d %c", delta, &pce, &npieces, junk) == 3) char *s;
if (sscanf(line, "CTM_MAIL BEGIN %s %d %d %c",
delta, &pce, &npieces, junk) != 3)
continue;
while ((s = strchr(delta, '/')) != NULL)
*s = '_';
mk_piece_name(pname, delta, pce, npieces);
if ((ofp = fopen(pname, "w")) == NULL)
{ {
char *s; err("cannot open '%s' for writing", pname);
status++;
while ((s = strchr(delta, '/')) != NULL) continue;
*s = '_';
mk_piece_name(pname, delta, pce, npieces);
if ((ofp = fopen(pname, "w")) == NULL)
{
err("cannot open '%s' for writing", pname);
status++;
continue;
}
cksum = 0xffff;
decoding++;
} }
cksum = 0xffff;
decoding++;
continue; continue;
} }

View File

@ -134,6 +134,5 @@ pusage()
usage(); \ usage(); \
} \ } \
} \ } \
O_end: \
*--argv = O_name; \ *--argv = O_name; \
} }

View File

@ -13,6 +13,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
@ -35,7 +36,7 @@ void apologise(char *delta, off_t ctm_size, long max_ctm_size,
FILE *open_sendmail(void); FILE *open_sendmail(void);
int close_sendmail(FILE *fp); int close_sendmail(FILE *fp);
int
main(int argc, char **argv) main(int argc, char **argv)
{ {
char *delta_file; char *delta_file;