26 #if defined (HAVE_CONFIG_H)
84 char *tmp =
new char [
len+1];
85 tmp = strcpy (tmp, s);
103 int grow_size = 1024;
104 int max_size = grow_size;
106 char *buf =
static_cast<char *
> (
std::malloc (max_size));
108 (*current_liboctave_error_handler) (
"octave_fgets: unable to malloc %d bytes", max_size);
119 if (
len == grow_size - 1)
121 int tmp = bufptr - buf + grow_size - 1;
123 max_size += grow_size;
124 auto tmpbuf =
static_cast<char *
> (std::realloc (buf, max_size));
128 (*current_liboctave_error_handler) (
"octave_fgets: unable to realloc %d bytes", max_size);
133 if (*(bufptr-1) ==
'\n')
139 else if (bufptr[
len-1] !=
'\n')
141 bufptr[
len++] =
'\n';
162 while (retval.empty ());
181 std::string retval =
fgets (
f, eof);
183 if (! retval.empty () && retval.back () ==
'\n')
189 template <
typename T>
211 template <
typename T>
222 if (c1 ==
'n' || c1 ==
'N')
225 if (c2 ==
'f' || c2 ==
'F')
227 val = std::numeric_limits<T>::infinity ();
231 is.setstate (std::ios::failbit);
234 is.setstate (std::ios::failbit);
241 if (c1 ==
'a' || c1 ==
'A')
244 if (c2 ==
'n' || c2 ==
'N')
246 val = std::numeric_limits<T>::quiet_NaN ();
251 val = numeric_limits<T>::NA ();
252 if (c2 != std::istream::traits_type::eof ())
255 is.clear (is.rdstate () & ~std::ios::failbit);
259 is.setstate (std::ios::failbit);
264 (*current_liboctave_error_handler)
265 (
"read_inf_nan_na: invalid character '%c'", c0);
273 template <
typename T>
281 std::streampos pos = is.tellg ();
297 if (c2 ==
'i' || c2 ==
'I' || c2 ==
'n' || c2 ==
'N')
298 val = read_inf_nan_na<T> (is, c2);
299 else if (isspace (c2))
300 is.setstate (std::ios::failbit);
314 val = read_inf_nan_na<T> (is, c1);
323 std::ios::iostate status = is.rdstate ();
324 if (status & std::ios::failbit)
330 val = -std::numeric_limits<T>::infinity ();
332 val = std::numeric_limits<T>::infinity ();
333 is.clear (status & ~std::ios::failbit);
341 is.setstate (status & ~std::ios_base::eofbit);
348 template <
typename T>
355 std::complex<T> cx = 0.0;
364 re = read_value<T> (is);
369 im = read_value<T> (is);
373 cx = std::complex<T> (re, im);
375 is.setstate (std::ios::failbit);
380 is.setstate (std::ios::failbit);
385 cx = read_value<T> (is);
396 return read_fp_value<double> (is);
401 return read_cx_fp_value<double> (is);
406 return read_fp_value<float> (is);
411 return read_cx_fp_value<float> (is);
414 template <
typename T>
452 os << (value < 0 ?
"-Inf" :
"Inf");
462 write_value<double> (os,
real (value));
464 write_value<double> (os,
imag (value));
480 os << (value < 0 ?
"-Inf" :
"Inf");
490 write_value<float> (os,
real (value));
492 write_value<float> (os,
imag (value));
510 #if defined (OCTAVE_HAVE_LONG_LONG_INT)
526 unsigned long int *
r)
531 #if defined (OCTAVE_HAVE_UNSIGNED_LONG_LONG_INT)
534 unsigned long long int *
r)
540 OCTAVE_END_NAMESPACE(math)
541 OCTAVE_END_NAMESPACE(
octave)
charNDArray max(char d, const charNDArray &m)
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
int octave_i_multiply_overflow_wrapper(int a, int b, int *r)
int octave_ulli_multiply_overflow_wrapper(unsigned long long int a, unsigned long long int b, unsigned long long int *r)
int octave_li_multiply_overflow_wrapper(long int a, long int b, long int *r)
int octave_uli_multiply_overflow_wrapper(unsigned long int a, unsigned long int b, unsigned long int *r)
int octave_ui_multiply_overflow_wrapper(unsigned int a, unsigned int b, unsigned int *r)
int octave_lli_multiply_overflow_wrapper(long long int a, long long int b, long long int *r)
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f
template void write_value< octave_uint64 >(std::ostream &os, const octave_uint64 &value)
void write_value(std::ostream &os, const T &value)
template void write_value< octave_uint8 >(std::ostream &os, const octave_uint8 &value)
bool is_int_or_inf_or_nan(double x)
bool int_multiply_overflow(int a, int b, int *r)
template void write_value< octave_int16 >(std::ostream &os, const octave_int16 &value)
template void write_value< octave_int32 >(std::ostream &os, const octave_int32 &value)
template void write_value< octave_uint32 >(std::ostream &os, const octave_uint32 &value)
std::string fgetl(FILE *f)
template octave_uint8 read_value< octave_uint8 >(std::istream &is)
std::complex< T > read_cx_fp_value(std::istream &is)
template octave_int64 read_value< octave_int64 >(std::istream &is)
double read_fp_value(std::istream &is)
template void write_value< octave_int64 >(std::ostream &os, const octave_int64 &value)
bool too_large_for_float(double x)
template void write_value< octave_uint16 >(std::ostream &os, const octave_uint16 &value)
template octave_uint64 read_value< octave_uint64 >(std::istream &is)
template octave_int32 read_value< octave_int32 >(std::istream &is)
std::string fgets(FILE *f)
template octave_int8 read_value< octave_int8 >(std::istream &is)
template octave_uint32 read_value< octave_uint32 >(std::istream &is)
template void write_value< octave_int8 >(std::ostream &os, const octave_int8 &value)
template void write_value< bool >(std::ostream &os, const bool &value)
char * strsave(const char *s)
template bool read_value< bool >(std::istream &is)
template octave_uint16 read_value< octave_uint16 >(std::istream &is)
template octave_int16 read_value< octave_int16 >(std::istream &is)
T read_inf_nan_na(std::istream &is, char c0)
T read_value(std::istream &is)
std::complex< double > Complex
std::complex< float > FloatComplex
T::size_type strlen(const typename T::value_type *str)