Commit Graph

593 Commits

Author SHA1 Message Date
Janne Blomqvist eb6a1e56e0 Copyright years and whitespace fix for r180734
From-SVN: r180736
2011-11-01 14:03:38 +02:00
Janne Blomqvist ea5e3c042b Cleanup NEWUNIT allocation.
2011-11-01  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/io.h (next_available_newunit): Remove prototype.
	* io/unit.h (next_available_newunit): Make variable static,
	initialize it.
	(init_units): Don't initialize next_available_newunit.
	(get_unique_unit_number): Use atomic builtin if available.

From-SVN: r180734
2011-11-01 13:44:12 +02:00
Janne Blomqvist 08810e5257 Update file position for inquire lazily.
libgfortran ChangeLog:

2011-10-31  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/inquire.c (inquire_via_unit): Check whether we're at the
	beginning or end if the position is unspecified. If the position
	is not one of the 3 standard ones, return unspecified.
	* io/io.h (update_position): Remove prototype.
	* io/transfer.c (next_record): Set the position to unspecified,
	letting inquire figure it out more exactly when needed.
	* io/unit.c (update_position): Remove function.


testsuite ChangeLog:

2011-10-31  Janne Blomqvist  <jb@gcc.gnu.org>

	* gfortran.dg/inquire_5.f90: Update testcase to match the standard
	and current implementation.

From-SVN: r180703
2011-10-31 16:59:19 +02:00
Janne Blomqvist 3469bd8660 Introduce a size member function to struct stream.
2011-10-31  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/unix.h (struct stream): Add size function pointer.
	(ssize): New inline function.
	(file_length): Remove prototype.
	* io/unix.c (raw_size): New function.
	(raw_init): Initialize st.size pointer.
	(buf_size): New function.
	(buf_init): Initialize st.size pointer.
	(open_internal): Likewise.
	(open_internal4): Likewise.
	(file_length): Remove function.
	* io/file_pos.c (st_rewind): Use ssize instead of file_length.
	* io/open.c (test_endfile): Likewise.
	* io/transfer.c (data_transfer_init): Likewise.
	(next_record_r): Likewise.
	(next_record_w): Likewise.
	* io/unit.c (update_position): Likewise.

From-SVN: r180702
2011-10-31 16:52:26 +02:00
Janne Blomqvist 7d5ee21935 Simplify handling of special files.
2011-10-31  Janne Blomqvist  <jb@gcc.gnu.org>

* io/file_pos.c (st_rewind): Handle regular and special files
identically.
* io/intrinsics.c (fseek_sub): Don't check whether we think the
file is seekable, just do what the caller says.
* io/transfer.c (skip_record): First try to seek, then fallback to
reading and throwing away what we read.
* io/unit.c (update_position): Don't check whether file is
seekable, just try to do what we're told.
(unit_truncate): Likewise.
* io/unix.c (struct unix_stream): Remove special_file flag.
(buf_flush): Remove code for handling unseekable files.
(buf_seek): Likewise.
(fd_to_stream): Use buffered IO only for regular files.
(file_length): Remove is_seekable() call.
(is_seekable): Remove function.
(is_special): Likewise.
* io/unix.h: Remove prototypes for is_seekable and is_special.

From-SVN: r180701
2011-10-31 16:45:50 +02:00
Tobias Burnus a2f3eae24d re PR fortran/50109 (Formatted namelist read with multiple "!" fails with: Cannot match namelist object name !)
2011-08-18  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50109
        * io/list_read.c (eat_separator): Fix skipping over "!" lines.

2011-08-18  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50109
        * gfortran.dg/namelist_73.f90: New.

From-SVN: r177858
2011-08-18 16:23:41 +02:00
Tobias Burnus f5e62ce922 re PR libfortran/49791 (Formatted namelist reads fails with: Cannot match namelist object)
2011-07-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/49791
        * io/list_read.c (nml_parse_qualifier): Remove check to
        enabled extended read for another case.

2011-07-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/49791
        * gfortran.dg/namelist_72.f: New.

From-SVN: r176661
2011-07-23 00:44:20 +02:00
Janne Blomqvist 5f54710465 PR 49296 List read, EOF without preceding separator
2011-07-13  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/49296
	* io/list_read.c (read_logical): Don't error out if a valid value
	is followed by EOF instead of a normal separator.
	(read_integer): Likewise.

testsuite:

2011-07-13  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/49296
	* gfortran.dg/read_list_eof_1.f90: Add tests for integer, real,
	and logical reads.

From-SVN: r176245
2011-07-13 21:46:44 +03:00
Janne Blomqvist d3ff9ee468 PR 49296 List directed read of string ending in EOF.
libgfortran ChangeLog entry:

2011-06-18  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/49296
        * io/list_read.c (read_character): Accept EOF as a separator when
        reading string.


testsuite ChangeLog entry:

2011-06-18  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/48296
	* gfortran.dg/read_list_eof_1.f90: New test.

From-SVN: r175166
2011-06-18 10:53:09 +03:00
Janne Blomqvist 09ad57ec8f Return error when trying to seek a non-seekable buffered file
From-SVN: r174947
2011-06-11 13:52:18 +03:00
Janne Blomqvist 5ea0705af7 Figure out whether a file is seekable with lseek()
From-SVN: r174946
2011-06-11 13:19:49 +03:00
Janne Blomqvist 04a4a57b1b PR 19155 Check for strtod failure via endptr
From-SVN: r174393
2011-05-29 11:59:44 +03:00
Janne Blomqvist 1028b2bded Error printing thread safety, remove GFORTRAN_USE_STDERR
From-SVN: r173749
2011-05-14 10:55:51 +03:00
Jerry DeLisle d6b872ad5e re PR libfortran/48787 (Invalid UP/DOWN rounding with F editing)
2011-05-04  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/48787
	* io/write_float.def (output_float): Adjust up and down rounding for
	cases where 'd' = 0. Gather common code to one location.

From-SVN: r173408
2011-05-05 01:19:30 +00:00
Jerry DeLisle 7c4f44cd60 re PR libfortran/48787 (Invalid UP/DOWN rounding with F editing)
2011-05-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/48787
	* io/write_float.def (output_float): Gather up integer declarations and
	add new 'p' for scale factor. Use 'p' in place of the 'dtp' reference
	everywhere. For ROUND_UP scan the digit string and only perform
	rounding if something other than '0' is found.

From-SVN: r173231
2011-05-01 12:32:18 +00:00
Janne Blomqvist 1e03060224 Fix path handling
From-SVN: r173172
2011-04-29 19:09:45 +03:00
Janne Blomqvist 848eab5c43 PR 48488 Typo
From-SVN: r173171
2011-04-29 19:06:48 +03:00
Janne Blomqvist ef6d0b6760 PR 48488 Fix comments
From-SVN: r173170
2011-04-29 19:03:54 +03:00
Janne Blomqvist d785f6a394 PR 48488 Fix comments
From-SVN: r173169
2011-04-29 18:58:20 +03:00
Jerry DeLisle a3f02fe44c re PR libfortran/48488 (Wrong default format for real numbers)
2011-04-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
	    Janne Blomqvist  <jb@gcc.gnu.org>

	PR libgfortran/48488
	PR libgfortran/48602
	PR libgfortran/48615
	PR libgfortran/48684
	PR libgfortran/48787
	* io/write.c (write_d, write_e, write_f, write_en,
	write_es): Add precision compemsation parameter to call.
	(set_fnode_default): Adjust default widths to assure
	round trip on write and read. (write_real): Adjust call to write_float.
	(write_real_g0): Calculate compensation for extra precision and adjust
	call to write_float. 
	* io/write_float.def (output_float_FMT_G_): Use volatile rather than
	asm volatile to avoid optimization issue. Correctly calculate the
	number of blanks (nb) to be appended and simplify calculation logic.
	(write_float): Increase MIN_FIELD_WIDTH by one to accomodate the new
	default widths. Eliminate the code that attempted to reduce the
	the precision used in later sprintf functions.  Add call parameter to
	compensate for extra precision.

Co-Authored-By: Janne Blomqvist <jb@gcc.gnu.org>

From-SVN: r173166
2011-04-29 14:56:02 +00:00
Jim Meyering 046957830e remove useless if-before-free tests
Change "if (E) free (E);" to "free (E);" everywhere except in the
libgo/, intl/, zlib/ and classpath/ directories.
Also transform equivalent variants like
"if (E != NULL) free (E);" and allow an extra cast on the
argument to free.  Otherwise, the tested and freed "E"
expressions must be identical, modulo white space.

From-SVN: r172785
2011-04-20 18:19:03 +00:00
Jerry DeLisle b48de48389 re PR libfortran/48602 (Invalid F conversion of G descriptor for values close to powers of 10)
2011-04-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/48602
	* io/write_float.def (output_float_FMT_G): Fix reversal in conditional.
	Use asm volatile to mark temp variable, avoiding optimization errors.

From-SVN: r172753
2011-04-20 04:18:25 +00:00
Jerry DeLisle bc7409a8a9 re PR libfortran/48602 (Invalid F conversion of G descriptor for values close to powers of 10)
2011-04-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/48602
	* io/write_float.def (output_float_FMT_G): Use current rounding mode
	to set the rounding parameters. (output_float): Skip rounding
	if value is zero.

From-SVN: r172634
2011-04-18 03:48:25 +00:00
Janne Blomqvist d30fe1c5cd Replace sprintf with snprintf
From-SVN: r172590
2011-04-16 20:43:03 +03:00
Jerry DeLisle 0b0a0c945f re PR libfortran/48589 (Invalid G0/G0.d editing for NaN/infinity)
2011-04-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/48589
	* io/write_float.def (write_infnan): Set width properly for G0.

From-SVN: r172502
2011-04-15 16:29:44 +00:00
Janne Blomqvist 44720bef9d Cleanup memsize types
From-SVN: r172340
2011-04-12 22:27:49 +03:00
Tobias Burnus 99ebea0382 unix.c: Adapt stat DEFINEs since MinGW64 supports LFS.
2011-04-04  Tobias Burnus  <burnus@net-b.de>

        * unix.c: Adapt stat DEFINEs since MinGW64 supports LFS.
        (fallback_access, open_internal4, compare_file_filename,
        find_file, file_size, inquire_sequential, inquire_direct,
        inquire_formatted): Use "struct stat" instead of gfstat_t.

From-SVN: r171911
2011-04-03 17:44:02 +02:00
Jerry DeLisle 27deda791b re PR libfortran/48030 (Implement read_x using fbuf_getc)
2011-03-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/48030
	* io/read.c (read_x): Re-implement using fbuf_getc.

From-SVN: r171378
2011-03-24 01:48:57 +00:00
John David Anglin 458653cc06 re PR libfortran/35667 (HP-UX 10 has broken strtod)
PR fortran/35667
	* io/io.h (convert_infnan): Declare.
	* io/read.c (convert_infnan): New.
	(read_f): Use convert_infnan to convert INFs and NANs.
	* list_read.c (parse_real, read_real): Likewise.

From-SVN: r171182
2011-03-19 17:25:18 +00:00
Francois-Xavier Coudert 14bef49e53 re PR libfortran/47439 (Fun with scratch files on Windows MKTEMP only allows for 26 files)
PR libfortran/47439

	* io/unix.c (tempfile): Work around poor mktemp() implementations.

	* gfortran.dg/scratch_1.f90: New test.

From-SVN: r171178
2011-03-19 12:09:27 +00:00
Jerry DeLisle 8e71a20690 re PR libfortran/48047 (Incorrect output rounding of double precision numbers)
2011-03-11  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/48047
	* io/write_float.def (write_float): Change MIN_FIELD_WIDTH to 48.

From-SVN: r170895
2011-03-12 00:49:51 +00:00
Jerry DeLisle 0eac6ca562 re PR libfortran/47567 (Wrong output for small absolute values with F editing)
2011-02-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47567
	* io/write_float.def (output_float): Move handling of w = 0 to after
	output rounding. Check for zero and set zero_flag accordingly. Set
	width according to zero_flag. Add better comments.

From-SVN: r170585
2011-03-01 02:24:50 +00:00
Jerry DeLisle 353255cd6f re PR fortran/47778 (reading two arrays of structures from namelist fails)
2011-02-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47778
	* io/list_read.c (namelist_read): Intialize the error string buffere.
	If pprev_nl was used during the previous namelist read and the rank
	was zero, reset the pointer to NULL for the next namelist read.

From-SVN: r170548
2011-02-27 20:06:10 +00:00
Francois-Xavier Coudert fe230fccd4 re PR libfortran/45165 (unix.c:fallback_access() leaks file descriptors)
PR libfortran/45165
	* unix.c (fallback_access): Fix file descriptor leaks.

From-SVN: r170517
2011-02-26 15:21:45 +00:00
Jakub Jelinek ae01ced508 re PR fortran/47878 (187.facerec miscompares)
PR fortran/47878
	* io/transfer.c (read_sf): Call fbuf_getptr only at the end,
	and subtract n, dtp->u.p.sf_seen_eor and seen_comma from it.

	* gfortran.dg/pr47878.f90: New test.

From-SVN: r170476
2011-02-24 21:13:57 +01:00
Jerry DeLisle 5a30f819c7 re PR libfortran/47567 (Wrong output for small absolute values with F editing)
2011-02-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47567
	* io/write_float.def (output_float): Remove special case handling of
	zero with width 1.

From-SVN: r170458
2011-02-24 04:52:00 +00:00
Janne Blomqvist a2c037bdec PR 47694 Read from named pipe fails
Co-Authored-By: Jerry DeLisle <jvdelisle@gcc.gnu.org>

From-SVN: r170432
2011-02-23 08:59:51 +02:00
Jerry DeLisle ffe89a288f re PR libfortran/47567 (Wrong output for small absolute values with F editing)
2011-02-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47567
	* io/write_float.def (output_float): Adjust width for F0.d to
	allow space for negative signs on zero.

From-SVN: r170318
2011-02-19 15:10:55 +00:00
Jerry DeLisle fc2c5998f7 re PR libfortran/47567 (Wrong output for small absolute values with F editing)
2011-02-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47567
	* io/list_read.c (read_logical): Check for end of line before calling
	eat_line. (read_integer): Likewise. (parse_real): Don't unget the
	separator. Check for end of line before calling	eat_line.
	(read_complex): Allow line-end before and after parenthesis and comma.
	Check for end of line before calling eat_line. (read_real): Check for
	end of line before calling eat_line.

From-SVN: r170239
2011-02-17 05:19:50 +00:00
Jakub Jelinek 1d92226be3 re PR fortran/47642 (real(kind=16) - libquadmath - segfault on amd64 FreeBSD)
PR fortran/47642
	* libquadmath.texi (quadmath_snprintf): Document.
	(quadmath_flt128tostr): Remove.
	* Makefile.am (libquadmath_la_SOURCES): Add printf/*.c.
	Remove  quadmath_io.c, gdtoa/gdtoa.c, gdtoa/g__fmt.c,
	gdtoa/g_Qfmt.c, gdtoa/dmisc.c and gdtoa/ulp.c.
	* quadmath.h (quadmath_snprintf): New prototype.
	(quadmath_flt128tostr): Remove.
	* quadmath_weak.h (quadmath_snprintf): Add.
	(quadmath_flt128tostr): Remove.
	* configure.ac: New AC_CHECK_HEADERS headers: langinfo.h, wchar.h,
	wctype.h, limits.h, ctype.h, printf.h, errno.h.
	(AC_USE_SYSTEM_EXTENSIONS): Add.
	(HAVE_HIDDEN_VISIBILITY, HAVE_PRINTF_HOOKS,
	USE_LOCALE_SUPPORT, USE_I18N_NUMBER_H): New checks.
	* quadmath.map (QUADMATH_1.0): Add quadmath_snprintf.  Remove
	quadmath_flt128tostr.
	* printf/printf_fphex.c: New file.
	* printf/_itowa.h: New file.
	* printf/mul_n.c: New file.
	* printf/quadmath-printf.h: New file.
	* printf/submul_1.c: New file.
	* printf/quadmath-printf.c: New file.
	* printf/gmp-impl.h: New file.
	* printf/lshift.c: New file.
	* printf/fpioconst.h: New file.
	* printf/add_n.c: New file.
	* printf/cmp.c: New file.
	* printf/sub_n.c: New file.
	* printf/mul.c: New file.
	* printf/divrem.c: New file.
	* printf/addmul_1.c: New file.
	* printf/printf_fp.c: New file.
	* printf/_itoa.h: New file.
	* printf/fpioconst.c: New file.
	* printf/_i18n_number.h: New file.
	* printf/flt1282mpn.c: New file.
	* printf/rshift.c: New file.
	* printf/mul_1.c: New file.
	* quadmath_io.c: Removed.
	* gdtoa/gdtoa.c: Removed.
	* gdtoa/g__fmt.c: Removed.
	* gdtoa/g_Qfmt.c: Removed.
	* gdtoa/dmisc.c: Removed.
	* gdtoa/ulp.c: Removed.
	* config.h.in: Regenerated.
	* configure: Regenerated.
	* Makefile.in: Regenerated.

	* io/write_float.def (DTOAQ): Use quadmath_snprintf instead of
	quadmath_flt128tostr.
	* io/transfer128.c (tmp2): Initialize to quadmath_snprintf instead
	of quadmath_flt128tostr.

From-SVN: r170135
2011-02-14 16:34:44 +01:00
Jerry DeLisle 9e7628863b re PR libfortran/47567 (Wrong output for small absolute values with F editing)
2011-02-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47567
	* io/write_float.def (output_float): Eliminate some redundant code.
	Adjust width for case of F0.X for values of zero and all other values.
	Expand cases where '*' is set to give cleaner results.

From-SVN: r169853
2011-02-05 17:58:48 +00:00
Jerry DeLisle 6e0576ee50 re PR libfortran/47434 (Wrong field width for NaN with (F0.n) formatting)
2011-01-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47434
	* io/write_float.def (write_infnan): Use calculate_sign to determine
	if the sign should be given and check field widths accordingly.

From-SVN: r169390
2011-01-29 17:31:04 +00:00
Janne Blomqvist 6a0f6e7799 PR 47432 Use ttyname_r() if available
From-SVN: r169337
2011-01-27 22:05:45 +02:00
Jerry DeLisle 434b897293 re PR libfortran/47285 (G format outputs wrong number of characters when decimal supplied in literal)
2011-01-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47285
	* io/write_float.def (output_float): Return SUCCESS or FAILURE and use
	the result to set the padding.

From-SVN: r169320
2011-01-27 02:16:18 +00:00
Janne Blomqvist 723553bdc1 PR 46267 strerror thread safety
From-SVN: r169110
2011-01-22 00:42:17 +02:00
Janne Blomqvist 9cd72574bc PR47296 Segfault when running out of file descriptors
From-SVN: r168888
2011-01-17 07:48:10 +02:00
Jakub Jelinek e313241f91 re PR fortran/46625 (libquadmath: Mangle internal symbols; rename __float128 <-> string functions)
PR fortran/46625
	* quadmath.map (QUADMATH_1.0): Remove quadmath_strtopQ
	and quadmath_dtoaq.  Add strtoflt128 and quadmath_flt128tostr.
	* quadmath_weak.h (quadmath_strtopQ, quadmath_dtoaq): Remove.
	(strtoflt128, quadmath_flt128tostr): Add.
	* gdtoa/strtopQ.c (quadmath_strtopQ): Rename to...
	(strtoflt128): ... this.  Return __float128, instead of writing
	to memory pointed by last argument.
	* quadmath.h: Use C style comments instead of C++ style.
	(quadmath_strtopQ, quadmath_dtoaq): Remove prototypes.
	(strtoflt128, quadmath_flt128tostr): Add prototypes.
	* libquadmath.texi (quadmath_dtoaq): Rename to quadmath_flt128tostr.
	(quadmath_strtopQ): Rename to strtoflt128.  Adjust prototype,
	adjust examples.
	* quadmath_io.c (quadmath_dtoaq): Rename to...
	(quadmath_flt128tostr): ... this.
libgfortran/
	* io/write_float.def (DTOAQ): Use quadmath_flt128tostr
	instead of quadmath_dtoa.
	* io/transfer128.c (tmp1, tmp2): New variables, bring in
	strtoflt128 and quadmath_flt128tostr.
	(transfer_real128, transfer_real128_write, transfer_complex128,
	transfer_complex128_write): Remove tmp1/tmp2 variables.
	* io/read.c (convert_real): Use strtoflt128 instead of
	quadmath_strtopQ, adjust for the changed arguments and return
	value.

From-SVN: r168856
2011-01-16 17:55:27 +01:00
Jerry DeLisle 050d1a59d1 re PR fortran/47296 (I/O Segfault when running out of file descriptors)
2011-01-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47296
	* io/unix.c (unpack_filename): Return non-zero if the filename passed
	in is NULL.

From-SVN: r168832
2011-01-15 06:42:30 +00:00
Jerry DeLisle 43e0224a58 re PR libfortran/47154 (END= does not work in namelist read)
2011-01-04  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47154
	* io/list_read.c (namelist_read): Remove calls to hit_eof to avoid the
	duplicate calls via next_record.

From-SVN: r168502
2011-01-05 03:53:15 +00:00
Jakub Jelinek d652f226fc Update Copyright years for files modified in 2010.
From-SVN: r168438
2011-01-03 21:52:22 +01:00