lib/PDL/IO/Pnm-pp-pnminascii.c

filter: Statementstmt 41.2% 71 / 172 Branchbran 24.6% 66 / 268 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 31.1% 137 / 440 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/PDL/Primitive-pp-pchip_chsp.c ↑ Summary lib/PDL/Primitive-pp-pchip_chfe.c »
1  
2 #line 453 "lib/PDL/PP.pm"
3 /*
4 * THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/IO/Pnm.pd! Do not modify!
5 */
6  
7 #define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \
8 if (destroy) { \
9 comp_free_code \
10 } \
11 if ((trans)->dims_redone) { \
12 ntpriv_free_code \
13 }
14  
15 #include "EXTERN.h"
16 #include "perl.h"
17 #include "XSUB.h"
18 #include "pdl.h"
19 #include "pdlcore.h"
20 #define PDL PDL_IO_Pnm
21 extern Core* PDL; /* Structure hold core C functions */
22 #line 23 "lib/PDL/IO/Pnm-pp-pnminascii.c"
23 #include "get.h"
24  
25  
26  
27 #line 1877 "lib/PDL/PP.pm"
28 typedef struct pdl_params_pnminascii {
29 #line 30 "lib/PDL/IO/Pnm-pp-pnminascii.c"
30 IV ms;
31 IV ns;
32 int format;
33 PerlIO *fp;
34 } pdl_params_pnminascii;
35  
36  
37 #line 1888 "lib/PDL/PP.pm"
38 pdl_error pdl_pnminascii_redodims(pdl_trans *__privtrans) {
39 pdl_error PDL_err = {0, NULL, 0};
40 #line 41 "lib/PDL/IO/Pnm-pp-pnminascii.c"
41 16 pdl_params_pnminascii *__params = __privtrans->params; (void)__params;
42 16 __privtrans->ind_sizes[0] = __params->ms;
43 16 __privtrans->ind_sizes[1] = __params->ns;
44 16 ▶ PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); 0 16 16
45 16 return PDL_err;
46 }
47  
48  
49 #line 1888 "lib/PDL/PP.pm"
50 pdl_error pdl_pnminascii_readdata(pdl_trans *__privtrans) {
51 pdl_error PDL_err = {0, NULL, 0};
52 #line 53 "lib/PDL/IO/Pnm-pp-pnminascii.c"
53 16 pdl_params_pnminascii *__params = __privtrans->params; (void)__params;
54 16 register PDL_Indx __m_size = __privtrans->ind_sizes[0];
55 16 ▶ if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "broadcast.incs NULL");
Branch: 1 branch
BranchTrueFalseTotal
if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "broadcast.incs NULL"); 0 16 16
56 /* broadcastloop declarations */
57 int __brcloopval;
58 register PDL_Indx __tind0,__tind1; /* counters along dim */
59 16 register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
60 /* dims here are how many steps along those dims */
61 16 register PDL_Indx __tinc0_type = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
62 16 register PDL_Indx __tinc0_im = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
63 16 register PDL_Indx __tinc1_type = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
64 16 register PDL_Indx __tinc1_im = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
65 #define PDL_BROADCASTLOOP_START_pnminascii_readdata PDL_BROADCASTLOOP_START( \
66 readdata, \
67 __privtrans->broadcast, \
68 __privtrans->vtable, \
69 type_datap += __offsp[0]; \
70 im_datap += __offsp[1]; \
71 , \
72 ( ,type_datap += __tinc1_type - __tinc0_type * __tdims0 \
73 ,im_datap += __tinc1_im - __tinc0_im * __tdims0 \
74 ), \
75 ( ,type_datap += __tinc0_type \
76 ,im_datap += __tinc0_im \
77 ) \
78 )
79 #define PDL_BROADCASTLOOP_END_pnminascii_readdata PDL_BROADCASTLOOP_END( \
80 __privtrans->broadcast, \
81 type_datap -= __tinc1_type * __tdims1 + __offsp[0]; \
82 im_datap -= __tinc1_im * __tdims1 + __offsp[1]; \
83 )
84 16 register PDL_Indx __inc_im_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_im_m;register PDL_Indx __inc_im_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,1)]; (void)__inc_im_n;
85 #ifndef PDL_DECLARE_PARAMS_pnminascii_1
86 #define PDL_DECLARE_PARAMS_pnminascii_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_im,PDL_PPSYM_PARAM_im) \
87 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, type, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
88 PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_im, im, (__privtrans->pdls[1]), 1, PDL_PPSYM_PARAM_im)
89 #endif
90 #define PDL_IF_BAD(t,f) f
91 16 switch (__privtrans->__datatype) { /* Start generic switch */
92 12 case PDL_B: {
93 12 ▶ PDL_DECLARE_PARAMS_pnminascii_1(PDL_Byte,B,PDL_Byte,B)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Byte,B,PDL_Byte,B) 0 12 12
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Byte,B,PDL_Byte,B) 12 0 12
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Byte,B,PDL_Byte,B) 0 12 12
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Byte,B,PDL_Byte,B) 0 12 12
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Byte,B,PDL_Byte,B) 12 0 12
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Byte,B,PDL_Byte,B) 0 12 12
94 {
95 12 int ns = __privtrans->ind_sizes[1], s, i;
96 12 switch (__params->format) {
97 6 case PBM:
98 24 ▶ PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 6 6 12
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 6 6 12
99 42 ▶ for (i=ns-1; i>= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=ns-1; i>= 0; i--) { 36 6 42
100 252 ▶ {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
Branch: 1 branch
BranchTrueFalseTotal
{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { 216 36 252
101 900 ▶ while ((s = PerlIO_getc(__params->fp)) != EOF) {
Branch: 1 branch
BranchTrueFalseTotal
while ((s = PerlIO_getc(__params->fp)) != EOF) { 900 0 900
102 900 switch (s) {
103 0 case '#': /* comment, skip rest of line */
104 0 ▶ SWALLOWLINE(__params->fp);
Branch: 2 branches
BranchTrueFalseTotal
SWALLOWLINE(__params->fp); 0 0 0
SWALLOWLINE(__params->fp); 0 0 0
105 0 break;
106 216 case '0':
107 case '1':
108 /* invert on the fly */
109 216 (im_datap)[0+(__inc_im_m*(m))+(__inc_im_n*(i))] = 1 - (s - '0');
110 216 goto Bnext;
111 break;
112 684 case ' ':
113 case '\t':
114 case '\r':
115 case '\n':
116 case ',':
117 /* skip whitespace */
118 684 break;
119 0 default: /* garbage */
120 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "found garbage, aborting"); /* for now */
121 break;
122 }
123 }
124 216 Bnext: ;
125 }} /* Close m */
126 }
127 6 ▶ PDL_BROADCASTLOOP_END_pnminascii_readdata
Branch: 2 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 6 6
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 6 6
128 6 break;
129 6 case PGM:
130 case PPM:
131 24 ▶ PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 6 6
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 6 6 12
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 6 6 12
132 PDL_Long j;
133 24 ▶ for (i=ns-1; i>= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=ns-1; i>= 0; i--) { 18 6 24
134 72 ▶ {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
Branch: 1 branch
BranchTrueFalseTotal
{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { 54 18 72
135 54 ▶ if (getint(__params->fp,&j) <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (getint(__params->fp,&j) <= 0) 0 54 54
136 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "found garbage, aborting"); /* for now */
137 54 (im_datap)[0+(__inc_im_m*(m))+(__inc_im_n*(i))] = j;
138 }} /* Close m */
139 }
140 6 ▶ PDL_BROADCASTLOOP_END_pnminascii_readdata
Branch: 2 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 6 6
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 6 6
141 6 break;
142 0 default:
143 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "unknown PNM format");
144 break;
145 } /* end switch */
146 }
147 12 } break;
148 0 case PDL_S: {
149 0 ▶ PDL_DECLARE_PARAMS_pnminascii_1(PDL_Short,S,PDL_Short,S)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Short,S,PDL_Short,S) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Short,S,PDL_Short,S) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Short,S,PDL_Short,S) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Short,S,PDL_Short,S) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Short,S,PDL_Short,S) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Short,S,PDL_Short,S) 0 0 0
150 {
151 0 int ns = __privtrans->ind_sizes[1], s, i;
152 0 switch (__params->format) {
153 0 case PBM:
154 0 ▶ PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
155 0 ▶ for (i=ns-1; i>= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=ns-1; i>= 0; i--) { 0 0 0
156 0 ▶ {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
Branch: 1 branch
BranchTrueFalseTotal
{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { 0 0 0
157 0 ▶ while ((s = PerlIO_getc(__params->fp)) != EOF) {
Branch: 1 branch
BranchTrueFalseTotal
while ((s = PerlIO_getc(__params->fp)) != EOF) { 0 0 0
158 0 switch (s) {
159 0 case '#': /* comment, skip rest of line */
160 0 ▶ SWALLOWLINE(__params->fp);
Branch: 2 branches
BranchTrueFalseTotal
SWALLOWLINE(__params->fp); 0 0 0
SWALLOWLINE(__params->fp); 0 0 0
161 0 break;
162 0 case '0':
163 case '1':
164 /* invert on the fly */
165 0 (im_datap)[0+(__inc_im_m*(m))+(__inc_im_n*(i))] = 1 - (s - '0');
166 0 goto Snext;
167 break;
168 0 case ' ':
169 case '\t':
170 case '\r':
171 case '\n':
172 case ',':
173 /* skip whitespace */
174 0 break;
175 0 default: /* garbage */
176 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "found garbage, aborting"); /* for now */
177 break;
178 }
179 }
180 0 Snext: ;
181 }} /* Close m */
182 }
183 0 ▶ PDL_BROADCASTLOOP_END_pnminascii_readdata
Branch: 2 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
184 0 break;
185 0 case PGM:
186 case PPM:
187 0 ▶ PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
188 PDL_Long j;
189 0 ▶ for (i=ns-1; i>= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=ns-1; i>= 0; i--) { 0 0 0
190 0 ▶ {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
Branch: 1 branch
BranchTrueFalseTotal
{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { 0 0 0
191 0 ▶ if (getint(__params->fp,&j) <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (getint(__params->fp,&j) <= 0) 0 0 0
192 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "found garbage, aborting"); /* for now */
193 0 (im_datap)[0+(__inc_im_m*(m))+(__inc_im_n*(i))] = j;
194 }} /* Close m */
195 }
196 0 ▶ PDL_BROADCASTLOOP_END_pnminascii_readdata
Branch: 2 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
197 0 break;
198 0 default:
199 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "unknown PNM format");
200 break;
201 } /* end switch */
202 }
203 0 } break;
204 4 case PDL_US: {
205 4 ▶ PDL_DECLARE_PARAMS_pnminascii_1(PDL_Ushort,U,PDL_Ushort,U)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Ushort,U,PDL_Ushort,U) 0 4 4
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Ushort,U,PDL_Ushort,U) 4 0 4
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Ushort,U,PDL_Ushort,U) 0 4 4
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Ushort,U,PDL_Ushort,U) 0 4 4
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Ushort,U,PDL_Ushort,U) 4 0 4
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Ushort,U,PDL_Ushort,U) 0 4 4
206 {
207 4 int ns = __privtrans->ind_sizes[1], s, i;
208 4 switch (__params->format) {
209 0 case PBM:
210 0 ▶ PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
211 0 ▶ for (i=ns-1; i>= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=ns-1; i>= 0; i--) { 0 0 0
212 0 ▶ {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
Branch: 1 branch
BranchTrueFalseTotal
{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { 0 0 0
213 0 ▶ while ((s = PerlIO_getc(__params->fp)) != EOF) {
Branch: 1 branch
BranchTrueFalseTotal
while ((s = PerlIO_getc(__params->fp)) != EOF) { 0 0 0
214 0 switch (s) {
215 0 case '#': /* comment, skip rest of line */
216 0 ▶ SWALLOWLINE(__params->fp);
Branch: 2 branches
BranchTrueFalseTotal
SWALLOWLINE(__params->fp); 0 0 0
SWALLOWLINE(__params->fp); 0 0 0
217 0 break;
218 0 case '0':
219 case '1':
220 /* invert on the fly */
221 0 (im_datap)[0+(__inc_im_m*(m))+(__inc_im_n*(i))] = 1 - (s - '0');
222 0 goto Unext;
223 break;
224 0 case ' ':
225 case '\t':
226 case '\r':
227 case '\n':
228 case ',':
229 /* skip whitespace */
230 0 break;
231 0 default: /* garbage */
232 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "found garbage, aborting"); /* for now */
233 break;
234 }
235 }
236 0 Unext: ;
237 }} /* Close m */
238 }
239 0 ▶ PDL_BROADCASTLOOP_END_pnminascii_readdata
Branch: 2 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
240 0 break;
241 4 case PGM:
242 case PPM:
243 16 ▶ PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 4 4
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 4 4
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 4 4
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 4 4
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 4 4
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 4 4 8
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 4 4 8
244 PDL_Long j;
245 16 ▶ for (i=ns-1; i>= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=ns-1; i>= 0; i--) { 12 4 16
246 48 ▶ {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
Branch: 1 branch
BranchTrueFalseTotal
{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { 36 12 48
247 36 ▶ if (getint(__params->fp,&j) <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (getint(__params->fp,&j) <= 0) 0 36 36
248 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "found garbage, aborting"); /* for now */
249 36 (im_datap)[0+(__inc_im_m*(m))+(__inc_im_n*(i))] = j;
250 }} /* Close m */
251 }
252 4 ▶ PDL_BROADCASTLOOP_END_pnminascii_readdata
Branch: 2 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 4 4
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 4 4
253 4 break;
254 0 default:
255 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "unknown PNM format");
256 break;
257 } /* end switch */
258 }
259 4 } break;
260 0 case PDL_L: {
261 0 ▶ PDL_DECLARE_PARAMS_pnminascii_1(PDL_Long,L,PDL_Long,L)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Long,L,PDL_Long,L) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Long,L,PDL_Long,L) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Long,L,PDL_Long,L) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Long,L,PDL_Long,L) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Long,L,PDL_Long,L) 0 0 0
PDL_DECLARE_PARAMS_pnminascii_1(PDL_Long,L,PDL_Long,L) 0 0 0
262 {
263 0 int ns = __privtrans->ind_sizes[1], s, i;
264 0 switch (__params->format) {
265 0 case PBM:
266 0 ▶ PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
267 0 ▶ for (i=ns-1; i>= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=ns-1; i>= 0; i--) { 0 0 0
268 0 ▶ {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
Branch: 1 branch
BranchTrueFalseTotal
{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { 0 0 0
269 0 ▶ while ((s = PerlIO_getc(__params->fp)) != EOF) {
Branch: 1 branch
BranchTrueFalseTotal
while ((s = PerlIO_getc(__params->fp)) != EOF) { 0 0 0
270 0 switch (s) {
271 0 case '#': /* comment, skip rest of line */
272 0 ▶ SWALLOWLINE(__params->fp);
Branch: 2 branches
BranchTrueFalseTotal
SWALLOWLINE(__params->fp); 0 0 0
SWALLOWLINE(__params->fp); 0 0 0
273 0 break;
274 0 case '0':
275 case '1':
276 /* invert on the fly */
277 0 (im_datap)[0+(__inc_im_m*(m))+(__inc_im_n*(i))] = 1 - (s - '0');
278 0 goto Lnext;
279 break;
280 0 case ' ':
281 case '\t':
282 case '\r':
283 case '\n':
284 case ',':
285 /* skip whitespace */
286 0 break;
287 0 default: /* garbage */
288 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "found garbage, aborting"); /* for now */
289 break;
290 }
291 }
292 0 Lnext: ;
293 }} /* Close m */
294 }
295 0 ▶ PDL_BROADCASTLOOP_END_pnminascii_readdata
Branch: 2 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
296 0 break;
297 0 case PGM:
298 case PPM:
299 0 ▶ PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
PDL_BROADCASTLOOP_START_pnminascii_readdata /* with top to bottom inversion */ 0 0 0
300 PDL_Long j;
301 0 ▶ for (i=ns-1; i>= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i=ns-1; i>= 0; i--) { 0 0 0
302 0 ▶ {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
Branch: 1 branch
BranchTrueFalseTotal
{/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { 0 0 0
303 0 ▶ if (getint(__params->fp,&j) <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (getint(__params->fp,&j) <= 0) 0 0 0
304 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "found garbage, aborting"); /* for now */
305 0 (im_datap)[0+(__inc_im_m*(m))+(__inc_im_n*(i))] = j;
306 }} /* Close m */
307 }
308 0 ▶ PDL_BROADCASTLOOP_END_pnminascii_readdata
Branch: 2 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
PDL_BROADCASTLOOP_END_pnminascii_readdata 0 0 0
309 0 break;
310 0 default:
311 0 return PDL->make_error(PDL_EUSERERROR, "Error in pnminascii:" "unknown PNM format");
312 break;
313 } /* end switch */
314 }
315 0 } break;
316 0 default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in pnminascii: unhandled datatype(%d), only handles (BSUL)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
317 }
318 #undef PDL_IF_BAD
319 16 return PDL_err;
320 }
321  
322 static pdl_datatypes pdl_pnminascii_vtable_gentypes[] = { PDL_B, PDL_US, PDL_S, PDL_L, -1 };
323 static PDL_Indx pdl_pnminascii_vtable_realdims[] = { 0, 2 };
324 static char *pdl_pnminascii_vtable_parnames[] = { "type","im" };
325 static short pdl_pnminascii_vtable_parflags[] = {
326 0,
327 PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISTPLUS|PDL_PARAM_ISTYPED|PDL_PARAM_ISWRITE
328 };
329 static pdl_datatypes pdl_pnminascii_vtable_partypes[] = { -1, PDL_B };
330 static PDL_Indx pdl_pnminascii_vtable_realdims_starts[] = { 0, 0 };
331 static PDL_Indx pdl_pnminascii_vtable_realdims_ind_ids[] = { 0, 1 };
332 static char *pdl_pnminascii_vtable_indnames[] = { "m","n" };
333 pdl_transvtable pdl_pnminascii_vtable = {
334 PDL_TRANS_DO_BROADCAST, 0, pdl_pnminascii_vtable_gentypes, 1, 2, NULL /*CORE21*/,
335 pdl_pnminascii_vtable_realdims, pdl_pnminascii_vtable_parnames,
336 pdl_pnminascii_vtable_parflags, pdl_pnminascii_vtable_partypes,
337 pdl_pnminascii_vtable_realdims_starts, pdl_pnminascii_vtable_realdims_ind_ids, 2,
338 2, pdl_pnminascii_vtable_indnames,
339 pdl_pnminascii_redodims, pdl_pnminascii_readdata, NULL,
340 NULL,
341 sizeof(pdl_params_pnminascii),"PDL::IO::Pnm::pnminascii"
342 };
343  
344  
345 16 pdl_error pdl_run_pnminascii(pdl *type,pdl *im,IV ms,IV ns,int format,PerlIO *fp) {
346 16 pdl_error PDL_err = {0, NULL, 0};
347 16 ▶ if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
Branch: 1 branch
BranchTrueFalseTotal
if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; 0 16 16
348 16 pdl_trans *__privtrans = PDL->create_trans(&pdl_pnminascii_vtable);
349 16 ▶ if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
Branch: 1 branch
BranchTrueFalseTotal
if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); 0 16 16
350 16 pdl_params_pnminascii *__params = __privtrans->params;
351 16 __privtrans->pdls[0] = type;
352 16 __privtrans->pdls[1] = im;
353 16 ▶ PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); 0 16 16
354 16 (__params->ms) = (ms); /* CType.get_copy */
355 16 (__params->ns) = (ns); /* CType.get_copy */
356 16 (__params->format) = (format); /* CType.get_copy */
357 16 (__params->fp) = (fp); /* CType.get_copy */
358 16 ▶ PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); 0 16 16
359 16 return PDL_err;
360 }
« lib/PDL/Primitive-pp-pchip_chsp.c ↑ Summary lib/PDL/Primitive-pp-pchip_chfe.c »