@@ -40,23 +40,22 @@ std::stringstream accept_comma_and_complex_default_format(std::stringstream & is
4040 if (parIn->Type () == GDL_STRING) return std::stringstream (is.str ());
4141
4242 bool debug = false ;
43- if (debug) std::cout << " the raw full input :" << is.str () << std::endl;
43+ if (debug) std::cout << " the raw full input (1) :" << is.str () << std::endl;
4444
45- // for Complex, compting cases is complex since (12) eq (12,12) eq 12 ... count 1
45+ // for Complex, counting cases is complex since (12) eq (12,12) eq 12 ... count 1
4646 int flag_cplx = 0 ;
4747 if ((parIn->Type () == GDL_COMPLEX) || (parIn->Type () == GDL_COMPLEXDBL)) flag_cplx = 1 ;
48- // int open_brace=0;
49- // int loop=0;
50-
48+ SizeT NToTransfer=parIn->N_Elements ();
49+ if (parIn->Type () == GDL_STRUCT) NToTransfer=parIn->ToTransfer ();
5150 std::stringstream temp;
5251 char c;
5352 int loop = 0 ;
5453 int open_brace = 0 ;
5554 // repeat as many elements necessary, but no more!
5655 // for (SizeT ielem=0; ielem < (*par)->N_Elements(); ++ielem ) {
57- if (debug) std::cout << " nb elems : " << parIn-> N_Elements () << std::endl;
56+ if (debug) std::cout << " nb elems : " << NToTransfer << std::endl;
5857
59- for (int ielem = 0 ; ielem < parIn-> N_Elements () ; ++ielem) {
58+ for (int ielem = 0 ; ielem < NToTransfer ; ++ielem) {
6059
6160 loop++;
6261 while (is.get (c)) { // remove starting blanks, commas, tabs, newlines
@@ -88,7 +87,7 @@ std::stringstream accept_comma_and_complex_default_format(std::stringstream & is
8887 temp.put (' ' ); // put a spearator between values
8988
9089 // this is a security if the input is really badly formatted
91- if (loop > 5 * parIn-> N_Elements () ) break ;
90+ if (loop > 5 * NToTransfer ) break ;
9291
9392 } // for loop
9493
@@ -102,22 +101,24 @@ std::stringstream accept_comma_and_complex_default_format(std::istream *is, Base
102101 assert (parIn->Type () != GDL_STRING);
103102
104103 bool debug = false ;
104+ if (debug) std::cout << " the raw full input (2):" << is << std::endl;
105105
106- // for Complex, compting cases is complex since (12) eq (12,12) eq 12 ... count 1
106+ // for Complex, counting cases is complex since (12) eq (12,12) eq 12 ... count 1
107107 int flag_cplx = 0 ;
108108 if ((parIn->Type () == GDL_COMPLEX) || (parIn->Type () == GDL_COMPLEXDBL)) flag_cplx = 1 ;
109- // int open_brace=0;
110- // int loop=0;
109+ SizeT NToTransfer=parIn->N_Elements ();
110+ if (parIn->Type () == GDL_STRUCT) NToTransfer=parIn->ToTransfer ();
111+
111112
112113 std::stringstream temp;
113114 char c;
114115 int loop = 0 ;
115116 int open_brace = 0 ;
116117 // repeat as many elements necessary, but no more!
117118 // for (SizeT ielem=0; ielem < (*par)->N_Elements(); ++ielem ) {
118- if (debug) std::cout << " nb elems : " << parIn-> N_Elements () << std::endl;
119+ if (debug) std::cout << " nb elems : " << NToTransfer << std::endl;
119120
120- for (int ielem = 0 ; ielem < parIn-> N_Elements () ; ++ielem) {
121+ for (int ielem = 0 ; ielem < NToTransfer ; ++ielem) {
121122
122123 loop++;
123124 while (is->get (c)) { // remove starting blanks, commas, tabs, newlines
@@ -149,7 +150,7 @@ std::stringstream accept_comma_and_complex_default_format(std::istream *is, Base
149150 temp.put (' ' ); // put a spearator between values
150151
151152 // this is a security if the input is really badly formatted
152- if (loop > 5 * parIn-> N_Elements () ) break ;
153+ if (loop > 5 * NToTransfer ) break ;
153154
154155 } // for loop
155156
0 commit comments