37 #include <sys/types.h>
51 {
return x == 0 || x == 1; }
71 {
return x == 0 || x == 1; }
85 char *tmp =
new char [len+1];
86 tmp = strcpy (tmp, s);
98 int new_len = name.length () + value.length () + 2;
100 char *new_item =
static_cast<char*
> (gnulib::malloc (new_len));
102 sprintf (new_item,
"%s=%s", name.c_str (), value.c_str ());
107 if (gnulib::putenv (new_item) < 0)
125 int grow_size = 1024;
126 int max_size = grow_size;
128 char *buf =
static_cast<char *
> (gnulib::malloc (max_size));
134 if (gnulib::fgets (bufptr, grow_size, f))
136 len = strlen (bufptr);
138 if (len == grow_size - 1)
140 int tmp = bufptr - buf + grow_size - 1;
142 max_size += grow_size;
143 buf =
static_cast<char *
> (gnulib::realloc (buf, max_size));
146 if (*(bufptr-1) ==
'\n')
152 else if (bufptr[len-1] !=
'\n')
154 bufptr[len++] =
'\n';
175 while (retval.empty ());
197 size_t len = retval.length ();
199 if (retval[len-1] ==
'\n')
200 retval.resize (len-1);
207 template <
typename T>
218 if (c1 ==
'n' || c1 ==
'N')
221 if (c2 ==
'f' || c2 ==
'F')
222 val = std::numeric_limits<T>::infinity ();
224 is.setstate (std::ios::failbit);
227 is.setstate (std::ios::failbit);
234 if (c1 ==
'a' || c1 ==
'A')
237 if (c2 ==
'n' || c2 ==
'N')
238 val = std::numeric_limits<T>::quiet_NaN ();
241 val = octave_numeric_limits<T>::NA ();
246 is.setstate (std::ios::failbit);
259 template <
typename T>
267 std::ios::streampos pos = is.tellg ();
286 if (c2 ==
'i' || c2 ==
'I' || c2 ==
'n' || c2 ==
'N')
287 val = read_inf_nan_na<T> (is, c2);
294 if (neg && ! is.fail ())
301 val = read_inf_nan_na<T> (is,
c1);
310 std::ios::iostate status = is.rdstate ();
311 if (status & std::ios::failbit)
315 is.setstate (status);
321 template <
typename T>
325 T re = 0.0, im = 0.0;
327 std::complex<T> cx = 0.0;
336 re = octave_read_value<T> (is);
341 im = octave_read_value<T> (is);
345 cx = std::complex<T> (re, im);
347 is.setstate (std::ios::failbit);
352 is.setstate (std::ios::failbit);
357 cx = octave_read_value<double> (is);
365 return octave_read_fp_value<double> (is);
370 return octave_read_cx_fp_value<double> (is);
375 return octave_read_fp_value<float> (is);
380 return octave_read_cx_fp_value<float> (is);
391 os << (d < 0 ?
"-Inf" :
"Inf");
414 os << (d < 0 ?
"-Inf" :
"Inf");