mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
Better check of input data?
This commit is contained in:
parent
58b38ccc9d
commit
d61bbb33f7
1 changed files with 13 additions and 3 deletions
|
|
@ -78,9 +78,19 @@ main(argc, argv)
|
|||
exit(1);
|
||||
}
|
||||
while( !feof(stdin) ) {
|
||||
gets(lbuf);
|
||||
if ( feof(stdin) ) break;
|
||||
puts(lbuf);
|
||||
{ int t, s;
|
||||
gets(lbuf);
|
||||
if ( feof(stdin) ) break;
|
||||
if ( sscanf(lbuf, "%d,%d", &t,&s) == 2) {
|
||||
if ( s != h*w*4 ) {
|
||||
fprintf(stderr, "Size changed from %d to %d: %s\n",4*h*w,s, lbuf);
|
||||
exit(1);
|
||||
}
|
||||
printf("%d, %d\n", t, nh*nw*4);
|
||||
} else {
|
||||
puts(lbuf);
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Reading %d\n", h*w*sizeof(long));
|
||||
if ( (i=fread(bm, 1, h*w*sizeof(long), stdin)) != h*w*sizeof(long)) {
|
||||
fprintf(stderr, "%s: short read, %d wanted %d\n", argv[0],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue