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;
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;
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 ();
247 is.setstate (std::ios::failbit);
260 template <
typename T>
268 std::ios::streampos pos = is.tellg ();
287 if (c2 ==
'i' || c2 ==
'I' || c2 ==
'n' || c2 ==
'N')
288 val = read_inf_nan_na<T> (is, c2);
295 if (neg && ! is.fail ())
302 val = read_inf_nan_na<T> (is,
c1);
311 std::ios::iostate status = is.rdstate ();
312 if (status & std::ios::failbit)
316 is.setstate (status);
322 template <
typename T>
329 std::complex<T> cx = 0.0;
338 re = octave_read_value<T> (is);
343 im = octave_read_value<T> (is);
347 cx = std::complex<T> (re, im);
349 is.setstate (std::ios::failbit);
354 is.setstate (std::ios::failbit);
359 cx = octave_read_value<double> (is);
367 return octave_read_fp_value<double> (is);
372 return octave_read_cx_fp_value<double> (is);
377 return octave_read_fp_value<float> (is);
382 return octave_read_cx_fp_value<float> (is);
393 os << (d < 0 ?
"-Inf" :
"Inf");
416 os << (d < 0 ?
"-Inf" :
"Inf");
void octave_write_double(std::ostream &os, double d)
std::complex< T > octave_read_cx_fp_value(std::istream &is)
void octave_putenv(const std::string &name, const std::string &value)
std::string octave_fgets(FILE *f)
void octave_write_complex(std::ostream &os, const Complex &c)
F77_RET_T const double const double double * d
OCTAVE_API double octave_read_value(std::istream &is)
liboctave_error_handler current_liboctave_error_handler
char * strsave(const char *s)
F77_RET_T const double const double * f
T read_inf_nan_na(std::istream &is, char c0)
OCTAVE_API double D_NINT(double x)
double octave_read_fp_value(std::istream &is)
charNDArray max(char d, const charNDArray &m)
void octave_write_float(std::ostream &os, float d)
bool xtoo_large_for_float(double x)
ColumnVector imag(const ComplexColumnVector &a)
std::complex< float > FloatComplex
static MArray< double > const octave_idx_type const octave_idx_type octave_idx_type octave_idx_type octave_idx_type c1
std::complex< double > Complex
void octave_write_float_complex(std::ostream &os, const FloatComplex &c)
ColumnVector real(const ComplexColumnVector &a)
bool xis_one_or_zero(double x)
F77_RET_T const double * x
bool xis_int_or_inf_or_nan(double x)
std::string octave_fgetl(FILE *f)