lib/PDL/IO/Pnm/get.c

filter: Statementstmt 85.0% 17 / 20 Branchbran 40.0% 16 / 40 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 55.0% 33 / 60 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/PDL/Core/pdlmagic.c ↑ Summary lib/PDL/FFT/fftn.c »
1 #include "get.h"
2  
3 /* process one input line from an ascii pnm file
4 * and store data into a pdl data component
5 * returns number of elements read
6 * returns -1 if garbage was encountered
7 */
8  
9 /* get the next number from the input string
10 * return values: len : number of characters read
11 * 0 : end of string or skip rest of string because comment
12 * -1 : found garbage
13 */
14 #define TRAILING_WHITESPACE_CHECK(s) \
15 if (s!=' ' && s!='\t' && s!='\r' && s!='\n' && s!=',') return -1
16 90 int getint(PerlIO *fp, PDL_Long *ip)
17 {
18 90 PDL_Long i = 0;
19 90 int nread = 0;
20 90 int s = PerlIO_getc(fp);
21  
22 90 ▶ if (s == EOF) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (s == EOF) return 0; 90 0 90
23 while (1) {
24 198 ▶ if (s == EOF)
Branch: 1 branch
BranchTrueFalseTotal
if (s == EOF) 0 198 198
25 0 return 0; /* signal end of line */
26 198 ▶ if (s == '#')
Branch: 1 branch
BranchTrueFalseTotal
if (s == '#') 0 198 198
27 0 ▶ SWALLOWLINE(fp);
Branch: 2 branches
BranchTrueFalseTotal
SWALLOWLINE(fp); 0 0 0
SWALLOWLINE(fp); 0 0 0
28 198 ▶ if (s >='0' && s <='9') break;
Branch: 2 branches
BranchTrueFalseTotal
if (s >='0' && s <='9') break; 90 108 198
if (s >='0' && s <='9') break; 90 0 90
29 108 ▶ if (s!=' ' && s!='\t' && s!='\r' && s!='\n' && s!=',')
Branch: 5 branches
BranchTrueFalseTotal
if (s!=' ' && s!='\t' && s!='\r' && s!='\n' && s!=',') 20 88 108
if (s!=' ' && s!='\t' && s!='\r' && s!='\n' && s!=',') 20 0 20
if (s!=' ' && s!='\t' && s!='\r' && s!='\n' && s!=',') 20 0 20
if (s!=' ' && s!='\t' && s!='\r' && s!='\n' && s!=',') 0 20 20
if (s!=' ' && s!='\t' && s!='\r' && s!='\n' && s!=',') 0 0 0
30 0 return -1; /* garbage */
31 108 s = PerlIO_getc(fp); /* else skip whitespace */
32 }
33 /* parse number */
34 while (1) {
35 206 i = (i*10) + (s - '0');
36 206 nread++;
37 206 ▶ if ((s = PerlIO_getc(fp)) == EOF) break; /* we could loose that */
Branch: 1 branch
BranchTrueFalseTotal
if ((s = PerlIO_getc(fp)) == EOF) break; /* we could loose that */ 0 206 206
38 206 ▶ if (s<'0' || s>'9') break;
Branch: 2 branches
BranchTrueFalseTotal
if (s<'0' || s>'9') break; 116 90 206
if (s<'0' || s>'9') break; 116 0 116
39 }
40 90 *ip = i;
41 90 ▶ TRAILING_WHITESPACE_CHECK(s);
Branch: 5 branches
BranchTrueFalseTotal
TRAILING_WHITESPACE_CHECK(s); 0 90 90
TRAILING_WHITESPACE_CHECK(s); 0 0 0
TRAILING_WHITESPACE_CHECK(s); 0 0 0
TRAILING_WHITESPACE_CHECK(s); 0 0 0
TRAILING_WHITESPACE_CHECK(s); 0 0 0
42 90 return nread;
43 }
« lib/PDL/Core/pdlmagic.c ↑ Summary lib/PDL/FFT/fftn.c »