fread.c (e95f37bb696f1b62cf4e5093f875be5c5483cb1f) | fread.c (77822acff7bf72c4a8e4020fb9256372f851c65e) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 53 unchanged lines hidden (view full) --- 62__fread(void * __restrict buf, size_t size, size_t count, FILE * __restrict fp) 63{ 64 size_t resid; 65 char *p; 66 int r; 67 size_t total; 68 69 /* | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Chris Torek. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 53 unchanged lines hidden (view full) --- 62__fread(void * __restrict buf, size_t size, size_t count, FILE * __restrict fp) 63{ 64 size_t resid; 65 char *p; 66 int r; 67 size_t total; 68 69 /* |
70 * The ANSI standard requires a return value of 0 for a count 71 * or a size of 0. Peculiarily, it imposes no such requirements 72 * on fwrite; it only requires fread to be broken. | 70 * ANSI and SUSv2 require a return value of 0 if size or count are 0. |
73 */ 74 if ((resid = count * size) == 0) 75 return (0); 76 ORIENT(fp, -1); 77 if (fp->_r < 0) 78 fp->_r = 0; 79 total = resid; 80 p = buf; --- 16 unchanged lines hidden --- | 71 */ 72 if ((resid = count * size) == 0) 73 return (0); 74 ORIENT(fp, -1); 75 if (fp->_r < 0) 76 fp->_r = 0; 77 total = resid; 78 p = buf; --- 16 unchanged lines hidden --- |