Commit Graph

455 Commits

Author SHA1 Message Date
Jerry DeLisle dcfddbd49c re PR fortran/40008 (F2008: Add NEWUNIT= for OPEN statement)
2009-06-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/40008
	* libgfortran.h: Define IOPARM_OPEN_HAS_NEWUNIT.
	* io/open.c (st_open): Don't error on negative unit number if NEWUNIT
	was specified. If NEWUNIT is specified, call new function to get the
	unique unit number and assign it.
	* io/io.h (st_parameter_open): Add pointer to newunit.  Add prototype for
	next_available_newunit. Add prototype for new function,
	get_unique_unit_number.
	* io/unit.c: Declare next_available_newunit. Define the first newunit
	number. (init_units): Initialize next_available_unit.
	(get_unique_unit_number): New function. Fix whitespace and comments.
	* io/transfer.c (data_transfer_init): Update error message to not be
	specific to OPEN statements.

From-SVN: r148253
2009-06-07 19:00:47 +00:00
Jerry DeLisle 690aefeba4 re PR libfortran/40334 (changed BACKSPACE behaviour at end of file.)
2009-06-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/40334
	* io/list_read.c (list_formatted_read_scalar): Set the end file
	conditions after a return from EOF error.

From-SVN: r148251
2009-06-07 17:40:24 +00:00
Janne Blomqvist 0c40d2340a re PR libfortran/40330 (incorrect IO)
PR libfortran/40330

Use heap memory for cached format strings.

From-SVN: r148149
2009-06-04 00:07:19 +03:00
Jerry DeLisle 3a546d4d9b re PR libfortran/37754 (READ I/O Performance regression from 4.3 to 4.4/4.5)
2009-05-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/37754
	* io/write_float.def: Simplify format calculation.

From-SVN: r147725
2009-05-20 00:16:38 +00:00
François-Xavier Coudert 743460ea82 re PR libfortran/22423 (Warnings when building libgfortran)
PR fortran/22423

	* io/transfer.c (read_block_direct): Avoid warning.
	* runtime/string.c (compare0): Avoid warning.

From-SVN: r147254
2009-05-07 21:42:22 +00:00
Janne Blomqvist ee56ac9def Fix PR libfortran/39667
From-SVN: r147004
2009-04-30 18:12:37 +03:00
Janne Blomqvist 0a629857bc re PR fortran/39782 (IO depends on uninitialised value)
2009-04-18  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/39782
	* io/transfer.c (data_transfer_init): Don't flush before seek.
	(finalize_transfer): Remove extra flush.

From-SVN: r146308
2009-04-18 13:05:34 +03:00
Janne Blomqvist 4e23895d6a io.h (is_preconnected): Remove prototype.
2009-04-17  Janne Blomqvist  <jb@gcc.gnu.org>

	* io/io.h (is_preconnected): Remove prototype.
	* io/unix.c (is_preconnected): Remove function.

From-SVN: r146287
2009-04-17 22:52:02 +03:00
Janne Blomqvist 6f454a9f7c re PR libfortran/38668 (advance="no": no buffering, truncate and seek)
2009-04-15  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/38688
	* io/transfer.c (finalize_transfer): Don't flush for advance='no'.

From-SVN: r146134
2009-04-15 22:38:32 +03:00
Danny Smith 4ff626092e write.c (itoa): Rename back to gfc_itoa.
* io/write.c (itoa) : Rename back to gfc_itoa.
       (write_i): Adjust call to write_decimal.
       (write_integer):  Use gfc_itoa.

From-SVN: r146079
2009-04-15 04:05:02 +00:00
Janne Blomqvist 4dadda8fb0 io.h (move_pos_offset): Remove prototype.
2009-04-10  Janne Blomqvist  <jb@gcc.gnu.org>

        * io/io.h (move_pos_offset): Remove prototype.
        * io/transfer.c (formatted_transfer_scalar_read): Use sseek
        instead of move_pos_offset.
        * io/unix.c (move_pos_offset): Remove.

From-SVN: r145876
2009-04-10 11:26:56 +03:00
Janne Blomqvist 6b6802109e PR libfortran/39665 libfortran/39702 libfortran/39709
2009-04-10  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/39665 libfortran/39702 libfortran/39709
	* io/io.h (st_parameter_dt): Revert aligned attribute from u.p.value.
        * io/list_read.c (read_complex): Read directly into user pointer.
        (read_real): Likewise.
        (list_formatted_read_scalar): Update read_complex and read_real calls.
        (nml_read_obj): Read directly into user pointer.

From-SVN: r145875
2009-04-10 10:23:25 +03:00
Janne Blomqvist 60c063faab re PR libfortran/39665 (Fortran IO using unaligned accesses to read/write doubles.)
2009-04-09  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/39665
	* io/io.h (st_parameter_dt): Add aligned attribute to u.p.value.
	* io/read.c (convert_real): Add note about alignment requirements.

From-SVN: r145852
2009-04-09 20:44:23 +03:00
Jakub Jelinek 748086b7b2 Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
From-SVN: r145841
2009-04-09 17:00:19 +02:00
Janne Blomqvist 2ac7316d99 open.c (already_open): Test for POSIX close return value.
2009-04-08  Janne Blomqvist  <jb@gcc.gnu.org>

        * io/open.c (already_open): Test for POSIX close return value.
        * io/unit.c (close_unit_1): Likewise.
        * io/unix.c (raw_close): Return 0 for success for preconnected units.

From-SVN: r145761
2009-04-08 20:06:34 +03:00
Janne Blomqvist f9bfed2243 string.c (compare0): Use gfc_charlen_type.
2009-04-08  Janne Blomqvist  <jb@gcc.gnu.org>

        * runtime/string.c (compare0): Use gfc_charlen_type.
        * runtime/error.c (gfc_itoa): Move to io/write.c
        (xtoa): Rename to gfc_xtoa.
        * runtime/backtrace.c (show_backtrace): Call gfc_xtoa.
        * intrinsics/cshift0.c (cshift0): Use index_type for shift arg.
        * intrinsics/date_and_time.c (date_and_time): Use index_type.
        (itime_i4): Likewise.
        (itime_i8): Likewise.
        (idate_i4): Likewise.
        (idate_i8): Likewise.
        (gmtime_i4): Likewise.
        (gmtime_i8): Likewise.
        (ltime_i4): Likewise.
        (ltime_i8): Likewise.
        * libgfortran.h (gfc_itoa): Remove prototype.
        (xtoa): Rename prototype to gfc_xtoa.
        * io/list_read.c (nml_read_obj): Use size_t for string length.
        * io/transfer.c (read_block_direct): Change nbytes arg from
        pointer to value.
        (unformatted_read): Minor cleanup, call read_block_directly properly.
        (skip_record): Use ssize_t.
        (next_record_w_unf): Avoid stell() call by calling sseek with SEEK_CUR.
        (iolength_transfer): Make sure to multiply before cast.
        * io/intrinsics.c (fgetc): Remove unnecessary variable.
        * io/format.c (format_hash): Use gfc_charlen_type.
        * io/write.c (itoa): Move from runtime/error.c:gfc_itoa, rename,
        make static.
        (write_i): Call with pointer to itoa.
        (write_z): Call with pointer to gfc_xtoa.
        (write_integer): Pointer to itoa.
        (nml_write_obj): Type cleanup, don't call strlen in loop.

From-SVN: r145758
2009-04-08 19:48:07 +03:00
H.J. Lu 4197c13d08 re PR libfortran/39664 (Revision 145571 breaks stdio)
2009-04-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR libgfortran/39664
	* io/unix.c (raw_close): Don't close STDOUT_FILENO,
	STDERR_FILENO nor STDIN_FILENO.

From-SVN: r145636
2009-04-06 16:07:51 -07:00
David Edelsohn d26014d24e io.h (struct stream): Rename truncate to trunc.
* io/io.h (struct stream): Rename truncate to trunc.
        (struncate): Same.
        * io/unix.c (raw_init): Rename truncate to trunc.
        (buf_init): Same.
        (open_internal): Same.

From-SVN: r145608
2009-04-06 11:32:03 -04:00
Jerry DeLisle 7812c78c34 [multiple changes]
2009-04-05  Daniel Kraft  <d@domob.eu>

	PR fortran/38654
	* io/read.c (read_f): Reworked to speed up floating point parsing.
	(convert_real): Use pointer-casting instead of memcpy and temporaries.

2009-04-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/37754
	* io/io.h (format_hash_entry): New structure for hash table.
	(format_hash_table): The hash table itself.
	(free_format_data): Revise function prototype.
	(free_format_hash_table, init_format_hash,
	free_format_hash): New function prototypes.
	* io/unit.c (close_unit_1): Use free_format_hash_table.
	* io/transfer.c (st_read_done, st_write_done): Free format data if
	internal unit.
	* io/format.c (free_format_hash_table): New function that frees any
	memory allocated previously for cached format data.
	(reset_node): New static helper function to reset the format counters
	for a format node.
	(reset_fnode_counters): New static function recursively calls reset_node
	to traverse the	fnode tree.
	(format_hash): New simple hash function based on XOR, probabalistic,
	tosses collisions.
	(save_parsed_format): New static function to save the parsed format
	data to use again.
	(find_parsed_format): New static function searches the hash table
	looking for a match.
	(free_format_data): Revised to accept pointer to format data rather than
	the dtp pointer so that the function can be used in more places.
	(format_lex): Editorial.
	(parse_format_list): Set flag used to determine of format data hashing
	is to be used.  Internal units are not persistent enough for this.
	(revert): Move to ne location in file.
	(parse_format): Use new functions to look for previously parsed
	format strings and use them rather than re-parse.  If not found, saves
	the parsed format data for later use.
	
2009-04-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/37754
	* io/transfer.c (formatted_transfer_scalar): Remove this function by
	factoring it into two new functions, one for read and one for write,
	eliminating all the conditionals for read or write mode.
	(formatted transfer_scalar_read): New function.
	(formatted transfer_scalar_write): New function.
	(formatted_transfer): Use new functions.

2009-04-05  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/25561 libfortran/37754
	* io/io.h (struct stream): Define new stream interface function
	pointers, and inline functions for accessing it.
	(struct fbuf): Use int instead of size_t, remove flushed element.
	(mem_alloc_w): New prototype.
	(mem_alloc_r): New prototype.
	(stream_at_bof): Remove prototype.
	(stream_at_eof): Remove prototype.
	(file_position): Remove prototype.
	(flush): Remove prototype.
	(stream_offset): Remove prototype.
	(unit_truncate): New prototype.
	(read_block_form): Change to return pointer, int* argument.
	(hit_eof): New prototype.
	(fbuf_init): Change prototype.
	(fbuf_reset): Change prototype.
	(fbuf_alloc): Change prototype.
	(fbuf_flush): Change prototype.
	(fbuf_seek): Change prototype.
	(fbuf_read): New prototype.
	(fbuf_getc_refill): New prototype.
	(fbuf_getc): New inline function.
        * io/fbuf.c (fbuf_init): Use int, get rid of flushed.
	(fbuf_debug): New function.
	(fbuf_reset): Flush, and return position offset.
	(fbuf_alloc): Simplify, don't flush, just realloc.
	(fbuf_flush): Make usable for read mode, salvage remaining bytes.
	(fbuf_seek): New whence argument.
	(fbuf_read): New function.
	(fbuf_getc_refill): New function.
	* io/file_pos.c (formatted_backspace): Use new stream interface.
	(unformatted_backspace): Likewise.
	(st_backspace): Make sure format buffer is reset, use new stream
	interface, use unit_truncate.
	(st_endfile): Likewise.
	(st_rewind): Likewise.
	* io/intrinsics.c: Use new stream interface.
	* io/list_read.c (push_char): Don't use u.p.scratch, use realloc
	to resize.
	(free_saved): Don't check u.p.scratch.
	(next_char): Use new stream interface, use fbuf_getc() for external files.
	(finish_list_read): flush format buffer.
	(nml_query): Update to use modified interface:s
	* io/open.c (test_endfile): Use new stream interface.
	(edit_modes): Likewise.
	(new_unit): Likewise, set bytes_left to 1 for stream files.
	* io/read.c (read_l): Use new read_block_form interface.
	(read_utf8): Likewise.
	(read_utf8_char1): Likewise.
	(read_default_char1): Likewise.
	(read_utf8_char4): Likewise.
	(read_default_char4): Likewise.
	(read_a): Likewise.
	(read_a_char4): Likewise.
	(read_decimal): Likewise.
	(read_radix): Likewise.
	(read_f): Likewise.
	* io/transfer.c (read_sf): Use fbuf_read and mem_alloc_r, remove
	usage of u.p.line_buffer.
	(read_block_form): Update interface to return pointer, use
	fbuf_read for direct access.
	(read_block_direct): Update to new stream interface.
	(write_block): Use mem_alloc_w for internal I/O.
	(write_buf): Update to new stream interface.
	(formatted_transfer_scalar): Don't use u.p.line_buffer, use
	fbuf_seek for external files.
	(us_read): Update to new stream interface.
	(us_write): Likewise.
	(data_transfer_init): Always check if we switch modes and flush.
	(skip_record): Use new stream interface, fix comparison.
	(next_record_r): Check for and reset u.p.at_eof, use new stream
	interface, use fbuf_getc for spacing.
	(write_us_marker): Update to new stream interface, don't inline.
	(next_record_w_unf): Likewise.
	(sset): New function.
	(next_record_w): Use new stream interface, use fbuf for printing
	newline.
	(next_record): Use new stream interface.
	(finalize_transfer): Remove sfree call, use new stream interface.
	(st_iolength_done): Don't use u.p.scratch.
	(st_read): Don't check for end of file.
	(st_read_done): Don't use u.p.scratch, use unit_truncate.
	(hit_eof): New function.
	* io/unit.c (init_units): Always init fbuf for formatted units.
	(update_position): Use new stream interface.
	(unit_truncate): New function.
	(finish_last_advance_record): Use fbuf to print newline.
	* io/unix.c: Remove unused SSIZE_MAX macro.
	(BUFFER_SIZE): Make static const variable rather than macro.
	(struct unix_stream): Remove dirty_offset, len, method,
	small_buffer. Order elements by decreasing size.
	(struct int_stream): Remove.
	(move_pos_offset): Remove usage of dirty_offset.
	(reset_stream): Remove.
	(do_read): Rename to raw_read, update to match new stream
	interface.
	(do_write): Rename to raw_write, update to new stream interface.
	(raw_seek): New function.
	(raw_tell): New function.
	(raw_truncate): New function.
	(raw_close): New function.
	(raw_flush): New function.
	(raw_init): New function.
	(fd_alloc): Remove.
	(fd_alloc_r_at): Remove.
	(fd_alloc_w_at): Remove.
	(fd_sfree): Remove.
	(fd_seek): Remove.
	(fd_truncate): Remove.
	(fd_sset): Remove.
	(fd_read): Remove.
	(fd_write): Remove.
	(fd_close): Remove.
	(fd_open): Remove.
	(fd_flush): Rename to buf_flush, update to new stream interface
	and unix_stream.
	(buf_read): New function.
	(buf_write): New function.
	(buf_seek): New function.
	(buf_tell): New function.
	(buf_truncate): New function.
	(buf_close): New function.
	(buf_init): New function.
	(mem_alloc_r_at): Rename to mem_alloc_r, change prototype.
	(mem_alloc_w_at): Rename to mem_alloc_w, change prototype.
	(mem_read): Change to match new stream interface.
	(mem_write): Likewise.
	(mem_seek): Likewise.
	(mem_tell): Likewise.
	(mem_truncate): Likewise.
	(mem_close): Likewise.
	(mem_flush): New function.
	(mem_sfree): Remove.
	(empty_internal_buffer): Cast to correct type.
	(open_internal): Use correct type, init function pointers.
	(fd_to_stream): Test whether to open file as buffered or raw.
	(output_stream): Remove mode set.
	(error_stream): Likewise.
	(flush_all_units_1): Use new stream interface.
	(flush_all_units): Likewise.
	(stream_at_bof): Remove.
	(stream_at_eof): Remove.
	(file_position): Remove.
	(file_length): Update logic to use stream interface.
	(flush): Remove.
	(stream_offset): Remove.
	* io/write.c (write_utf8_char4): Use int instead of size_t.
	(write_x): Extra safety check.
	(namelist_write_newline): Use new stream interface.

From-SVN: r145571
2009-04-05 20:13:56 +00:00
Jerry DeLisle b710b6bc87 re PR fortran/39528 (repeated entries are not read when using list-directed input)
2009-03-24  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/39528
	* io/list_read.c (list_formatted_read_scalar): Move check for read
	completion to just after the check for a repeated value.

From-SVN: r145030
2009-03-24 12:24:29 +00:00
Janne Blomqvist f3ed1d0222 Revert part of patch accidentally committed to trunk rather than fortran-dev (I hate svn)
From-SVN: r144994
2009-03-22 13:32:29 +02:00
Janne Blomqvist 9e544d738a PR libfortran/25561 libfortran/37754
2009-03-22  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/25561 libfortran/37754
	* io/io.h (struct stream): Define new stream interface function
	pointers, and inline functions for accessing it.
	(struct fbuf): Use int instead of size_t, remove flushed element.
	(mem_alloc_w): New prototype.
	(mem_alloc_r): New prototype.
	(stream_at_bof): Remove prototype.
	(stream_at_eof): Remove prototype.
	(file_position): Remove prototype.
	(flush): Remove prototype.
	(stream_offset): Remove prototype.
	(unit_truncate): New prototype.
	(read_block_form): Change to return pointer, int* argument.
	(hit_eof): New prototype.
	(fbuf_init): Change prototype.
	(fbuf_reset): Change prototype.
	(fbuf_alloc): Change prototype.
	(fbuf_flush): Change prototype.
	(fbuf_seek): Change prototype.
	(fbuf_read): New prototype.
	(fbuf_getc_refill): New prototype.
	(fbuf_getc): New inline function.
        * io/fbuf.c (fbuf_init): Use int, get rid of flushed.
	(fbuf_debug): New function.
	(fbuf_reset): Flush, and return position offset.
	(fbuf_alloc): Simplify, don't flush, just realloc.
	(fbuf_flush): Make usable for read mode, salvage remaining bytes.
	(fbuf_seek): New whence argument.
	(fbuf_read): New function.
	(fbuf_getc_refill): New function.
	* io/file_pos.c (formatted_backspace): Use new stream interface.
	(unformatted_backspace): Likewise.
	(st_backspace): Make sure format buffer is reset, use new stream
	interface, use unit_truncate.
	(st_endfile): Likewise.
	(st_rewind): Likewise.
	* io/intrinsics.c: Use new stream interface.
	* io/list_read.c (push_char): Don't use u.p.scratch, use realloc
	to resize.
	(free_saved): Don't check u.p.scratch.
	(next_char): Use new stream interface, use fbuf_getc() for external files.
	(finish_list_read): flush format buffer.
	(nml_query): Update to use modified interface:s
	* io/open.c (test_endfile): Use new stream interface.
	(edit_modes): Likewise.
	(new_unit): Likewise, set bytes_left to 1 for stream files.
	* io/read.c (read_l): Use new read_block_form interface.
	(read_utf8): Likewise.
	(read_utf8_char1): Likewise.
	(read_default_char1): Likewise.
	(read_utf8_char4): Likewise.
	(read_default_char4): Likewise.
	(read_a): Likewise.
	(read_a_char4): Likewise.
	(read_decimal): Likewise.
	(read_radix): Likewise.
	(read_f): Likewise.
	* io/transfer.c (read_sf): Use fbuf_read and mem_alloc_r, remove
	usage of u.p.line_buffer.
	(read_block_form): Update interface to return pointer, use
	fbuf_read for direct access.
	(read_block_direct): Update to new stream interface.
	(write_block): Use mem_alloc_w for internal I/O.
	(write_buf): Update to new stream interface.
	(formatted_transfer_scalar): Don't use u.p.line_buffer, use
	fbuf_seek for external files.
	(us_read): Update to new stream interface.
	(us_write): Likewise.
	(data_transfer_init): Always check if we switch modes and flush.
	(skip_record): Use new stream interface, fix comparison.
	(next_record_r): Check for and reset u.p.at_eof, use new stream
	interface, use fbuf_getc for spacing.
	(write_us_marker): Update to new stream interface, don't inline.
	(next_record_w_unf): Likewise.
	(sset): New function.
	(next_record_w): Use new stream interface, use fbuf for printing
	newline.
	(next_record): Use new stream interface.
	(finalize_transfer): Remove sfree call, use new stream interface.
	(st_iolength_done): Don't use u.p.scratch.
	(st_read): Don't check for end of file.
	(st_read_done): Don't use u.p.scratch, use unit_truncate.
	(hit_eof): New function.
	* io/unit.c (init_units): Always init fbuf for formatted units.
	(update_position): Use new stream interface.
	(unit_truncate): New function.
	(finish_last_advance_record): Use fbuf to print newline.
	* io/unix.c: Remove unused SSIZE_MAX macro.
	(BUFFER_SIZE): Make static const variable rather than macro.
	(struct unix_stream): Remove dirty_offset, len, method,
	small_buffer. Order elements by decreasing size.
	(struct int_stream): Remove.
	(move_pos_offset): Remove usage of dirty_offset.
	(reset_stream): Remove.
	(do_read): Rename to raw_read, update to match new stream
	interface.
	(do_write): Rename to raw_write, update to new stream interface.
	(raw_seek): New function.
	(raw_tell): New function.
	(raw_truncate): New function.
	(raw_close): New function.
	(raw_flush): New function.
	(raw_init): New function.
	(fd_alloc): Remove.
	(fd_alloc_r_at): Remove.
	(fd_alloc_w_at): Remove.
	(fd_sfree): Remove.
	(fd_seek): Remove.
	(fd_truncate): Remove.
	(fd_sset): Remove.
	(fd_read): Remove.
	(fd_write): Remove.
	(fd_close): Remove.
	(fd_open): Remove.
	(fd_flush): Rename to buf_flush, update to new stream interface
	and unix_stream.
	(buf_read): New function.
	(buf_write): New function.
	(buf_seek): New function.
	(buf_tell): New function.
	(buf_truncate): New function.
	(buf_close): New function.
	(buf_init): New function.
	(mem_alloc_r_at): Rename to mem_alloc_r, change prototype.
	(mem_alloc_w_at): Rename to mem_alloc_w, change prototype.
	(mem_read): Change to match new stream interface.
	(mem_write): Likewise.
	(mem_seek): Likewise.
	(mem_tell): Likewise.
	(mem_truncate): Likewise.
	(mem_close): Likewise.
	(mem_flush): New function.
	(mem_sfree): Remove.
	(empty_internal_buffer): Cast to correct type.
	(open_internal): Use correct type, init function pointers.
	(fd_to_stream): Test whether to open file as buffered or raw.
	(output_stream): Remove mode set.
	(error_stream): Likewise.
	(flush_all_units_1): Use new stream interface.
	(flush_all_units): Likewise.
	(stream_at_bof): Remove.
	(stream_at_eof): Remove.
	(file_position): Remove.
	(file_length): Update logic to use stream interface.
	(flush): Remove.
	(stream_offset): Remove.
	* io/write.c (write_utf8_char4): Use int instead of size_t.
	(write_x): Extra safety check.
	(namelist_write_newline): Use new stream interface.

[[Split portion of a mixed commit.]]

From-SVN: r144993.2
2009-03-22 12:51:05 +02:00
Jerry DeLisle d53cb9ea60 re PR libfortran/39402 (gfortran 20090306: internal write of 0.0 with F0.3 gives **)
2009-03-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/39409
	* io/write_float.def (output_float): Handle F0.d formatting correctly
	for any d when value is 0.0.

From-SVN: r144718
2009-03-09 04:47:51 +00:00
Jerry DeLisle 1a15c900e8 re PR libfortran/38772 (r143102 reveals missed error checking on floating point reads)
2009-01-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38772
	* io/read.c (read_f): Clean up loop conditions for BZ/BN,
	allowing proper digit testing. White space fix.

From-SVN: r143327
2009-01-13 05:40:36 +00:00
Jerry DeLisle 8217a6359f re PR libfortran/38735 ([4.4 Regresssion] Default BLANK= mode for internal units is wrong)
2009-01-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38735
	* io/unit.c (get_internal_unit): Set default BLANK= status to NULL for
	internal units.

From-SVN: r143102
2009-01-05 22:55:15 +00:00
Jerry DeLisle 82192170e3 re PR fortran/37472 (bad output on default-format write of double in common block with -m64)
2008-12-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/37472
	* io/write_float.def (output_float_FMT_G_): Modify calculation of temp
	to avoid sensitivity to round-off.

From-SVN: r142884
2008-12-22 14:53:37 +00:00
Jerry DeLisle 50220190d2 re PR fortran/38398 (g0.w edit descriptor: Update for F2008 Tokyo meeting changes)
2008-12-21  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38398
	* io/io.h (st_parameter_dt): Add new bit to keep track of when to
	suppress blanks for g0 formatting.
	* io/transfer.c (formatted_transfer_scalar): Always call write_real_g0
	for g0 formatting.
	* io.c (write.c): Do not use ES formatting and use new bit to suppress
	blanks.
	* io/write_float.def (output_float): Adjust the location of setting the
	width so that it can be adjusted when suppressing blanks.  Set number of
	blanks to zero when dtp->u.p.g0_no_blanks is set. Do some minor code
	clean-up and add some white space for readability.

From-SVN: r142871
2008-12-21 21:23:52 +00:00
Jerry DeLisle 07e9d8beb7 re PR fortran/38504 (double minus sign when printing integer?)
2008-12-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38504
	io/write.c (write_decimal): Skip extra sign '-' at beginning of string
	returned by gfc_itoa.

From-SVN: r142747
2008-12-14 06:50:53 +00:00
Jerry DeLisle 9f309df283 re PR fortran/38430 (gfortran.dg/streamio_1.f90, 10, 14, 2, 6 now fails)
2008-12-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38430
	* io/transfer.c (data_transfer_init): Move constraint check for REC=
	and STREAM access into condition for other REC= constraints to simplify.
	Comment out this constraint to avoid breaking compatibility with 4.3
	until later.  Added a TODO for above comment and this one.
	Fix test for max pos.

From-SVN: r142575
2008-12-09 03:19:09 +00:00
Jerry DeLisle 97b14ba880 re PR fortran/38291 (Rejects I/O with POS= if FMT=*)
2008-12-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38291
	* io/transfer.c (data_transfer_init): Add fbuf_flush inadvertently
	ommitted.  Add check for invalid use of REC= with ACCESS="stream".  Fix
	comment.

From-SVN: r142528
2008-12-06 21:53:11 +00:00
Jerry DeLisle 4c934d41d2 re PR fortran/38291 (Rejects I/O with POS= if FMT=*)
2008-12-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/38291
	* io.c (match_dt_element): Use dt->pos in matcher.
	(gfc_free_dt): Free dt->pos after use.
	(gfc_resolve_dt): Use dt->pos in resolution of stream position tag.

2008-12-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38291
	* io/transfer.c (data_transfer_init): Add checks for POS= valid range.
	Add check for unit opened with ACCESS="stream". Flush and seek if
	current stream position does not match. Check ENDFILE on read.

From-SVN: r142515
2008-12-06 04:13:34 +00:00
Jerry DeLisle e318b7602b re PR fortran/38285 (Wrong I/O output: Interaction between F and P for output)
2008-12-04  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/38285
	* write_float.def (WRITE_FLOAT): Zero the float value for special case
	only if	scale_factor = 0.

From-SVN: r142455
2008-12-05 04:07:45 +00:00
Jakub Jelinek e14568432a re PR libfortran/37839 (st_parameter_dt has unwanted padding, is out of sync with compiler)
PR libfortran/37839
	* trans-io.c (gfc_build_io_library_fndecls): Decrease pad size back
	to 16 pointers plus 32 integers.  Don't use max integer kind
	alignment, only gfc_intio_kind's alignment.
	(gfc_trans_inquire): Only set flags2 if mask2 is non-zero.
	* ioparm.def: Fix order, bitmasks and types of inquire round, sign
	and pending fields.  Move u in dt before id.
	* io.c (gfc_free_inquire): Free decimal and size exprs.
	(match_inquire_element): Match size instead of matching blank twice.
	(gfc_resolve_inquire): Resolve size.

	* gfortran.dg/f2003_inquire_1.f03: New test.
	* gfortran.dg/f2003_io_1.f03: Remove xfail.
	* gfortran.dg/f2003_io_4.f03: Likewise.
	* gfortran.dg/f2003_io_5.f03: Likewise.
	* gfortran.dg/f2003_io_6.f03: Likewise.
	* gfortran.dg/f2003_io_7.f03: Likewise.

	* io/io.h (IOPARM_INQUIRE_HAS_ROUND, IOPARM_INQUIRE_HAS_SIGN,
	IOPARM_INQUIRE_HAS_PENDING): Adjust values.
	(st_parameter_inquire): Reorder and fix types of round, sign and
	pending fields.
	(st_parameter_43, st_parameter_44): Removed.
	(st_parameter_dt): Put back struct definition directly to u.p
	declaration.  Change type of u.p.size_used from gfc_offset to
	GFC_IO_INT.  Decrease back size of u.pad to 16 pointers and
	32 ints.  Put id, pos, asynchronous, blank, decimal, delim,
	pad, round and sign fields after the union.
	* io/inquire.c (inquire_via_unit, inquire_via_filename): Only read
	flags2 if it is defined.
	* io/transfer.c (read_sf, read_block_form, write_block): Cast
	additions to size_used to GFC_IO_INT instead of gfc_offset.
	(data_transfer_init): Clear whole u.p struct.  Adjust
	for moving id, pos, asynchronous, blank, decimal, delim, pad,
	round and sign fields from u.p directly into st_parameter_dt.
	(finalize_transfer): Don't cast size_used to GFC_IO_INT.
	* io/file_pos.c (st_endfile): Clear whole u.p struct.

From-SVN: r142111
2008-11-22 09:10:41 +01:00
Jerry DeLisle 0f4122ff3d re PR fortran/37472 (bad output on default-format write of double in common block with -m64)
2008-11-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/37472
	* io/write_float.def (output_float_FMT_G_): Adjust conversion of
	G format specification to F format.

From-SVN: r142079
2008-11-21 04:29:54 +00:00
Jerry DeLisle 264a5255d8 re PR libfortran/38097 (I/O with blanks in exponent fails; blank="NULL", BN edit descriptor)
2008-11-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/38097
	* io/read.c (read_f): Initialize exponent. Fix comment. Set loop
	conditions for BZ/BN.
	* io/unit.c (get_internal_unit): Initialize flags.blank.
	* io/transfer.c (data_transfer_init): Fix whitespace.

From-SVN: r141919
2008-11-16 16:12:16 +00:00
Jerry DeLisle 94bc6c1e77 re PR libfortran/37294 (Namelist I/O to array character internal units)
2008-11-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/37294
	* io/write.c (namelist_write_newline): Use array loop specification to
	advance to next internal array unit record. (namelist_write): Adjust to
	accomodate the internal array unit behavior.

From-SVN: r141892
2008-11-15 19:25:35 +00:00
Jerry DeLisle a7f5d0542a re PR libfortran/37707 (Namelist read of array of derived type incorrect)
2008-10-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37707
	* io/list_read.c (read_character): Remove code to look ahead in namelist
	reads to descriminate non-delimited strings from namelist objects.
	* io/write.c (namelist_write): Delimit character strings with quote or
	apostrophe, defaulting to quote.

From-SVN: r141317
2008-10-23 02:31:00 +00:00
Jerry DeLisle f13c001e1a re PR fortran/37834 (write(*,'(f0.0)') 0.0 prints "." instead of "0.")
2008-10-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37834
	* io/write_float.def (output_float): Emit '0.' for special case of
	format specifier 'f0.0' and value of zero. Likewise emit '0' for 'f1.0'.

From-SVN: r141231
2008-10-19 18:36:21 +00:00
Jerry DeLisle 80ad19715e re PR fortran/37863 (Display of a value close but less to 1 shows 2 with '(F3.0)')
2008-10-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37707
	* io/write_float.def (WRITE_FLOAT): Round to 1.0 correctly.
	* io/io.h (st_parameter_44): Fix id type declaration.

From-SVN: r141207
2008-10-18 05:23:47 +00:00
Thomas Koenig afab92d840 file_pos.c (unformatted_backspace): Normal case is GFC_CONVERT_NATIVE.
2008-10-16  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* io/file_pos.c (unformatted_backspace): Normal case is
	GFC_CONVERT_NATIVE.
	* io/transfer.c (read_sf):  Mark paths leading to generate_error()
	as unlikely.
	(readl_block_form):  Likewise.
	(read_block_direct):  Likewise.
	(write_block):  Likewise.
	(write_buf):  Likewise.
	(us_read):  Likewise.  Normal case is GFC_CONVERT_NATIVE.
	(next_record_w_unf):  Mark paths leading to generate_error()
	as unlikely.

From-SVN: r141179
2008-10-16 18:23:25 +00:00
Jerry DeLisle 724cdffe5c re PR fortran/37083 (Formatted read of line without trailing new-line fails)
2008-10-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37083
	* io/list_read.c (next_char): Simplify EOF tests and set endfile flag.
	(finish_list_read): Add EOF check.

From-SVN: r141101
2008-10-14 01:49:51 +00:00
Thomas Koenig e81897731e re PR libfortran/37753 (Convert="BIG_ENDIAN" reverses character)
2008-10-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/37753
	* io/transfer.c (unformatted_read):  CONVERT_NATIVE
	is the usual case.  Check for kind==1 for non-byte-reversing
	operation.
	(unformatted_write):  Likewise.

2008-10-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/37753
	* gfortran.dg/convert_2.f90:  New test case.

From-SVN: r141008
2008-10-09 19:28:58 +00:00
Jerry DeLisle 22a6009350 re PR libfortran/37707 (Namelist read of array of derived type incorrect)
2008-10-08  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37707
	* io/list_read.c (nml_get_obj_data): If the first namelist object rank
	is greater than zero, call nml_object_read with the first object rather
	than the sub-object.

From-SVN: r140995
2008-10-09 04:02:35 +00:00
Jerry DeLisle 105b713696 re PR fortran/37498 (Incorrect array value returned - 4.3 ABI Broken)
2008-09-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37498
	* list_read.c (eat_separator): Revert previous patch and move
	delim_status, decimal_status, and pad_status to gfc_unit.
	(parse_real): Ditto. (read_real): Ditto.
	* read.c (read_a): Likewise. (read_a_char4): Likewise.
	(read_f): Likewise.
	* inquire.c (inquire_via_unit): Add missing check for
	IOPARM_INQUIRE_HAS_FLAGS2. (inquire_via_filename): Likewise.
	* io.h (unit_sign_s): Move delim_status, decimal_status, and pad_status
	to gfc_unit.
	* transfer.c (read_sf): Ditto. (read_block_form): Ditto.
	(formatted_transfer_scalar): Ditto. (data_transfer_init): Ditto.
	* write.c (write_default_char4): Ditto. (write_utf8_char4): Ditto.
	(write_character): Ditto. (write_real_g0): Ditto.
	(list_formatted_write_scalar): Ditto. (nml_write_obj): Ditto.
	(namelist_write): Ditto.
	* write_float.def (calculate_sign): Ditto. (output_float): Ditto.

From-SVN: r140684
2008-09-26 06:19:42 +00:00
Jerry DeLisle d7445152be re PR fortran/37498 (Incorrect array value returned - 4.3 ABI Broken)
2008-09-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR fortran/37498
	* trans-io.c (gfc_build_io_library_fndecls): Bump pad size.
	(build_dt): Set mask bit for IOPARM_dt_f2003.
	* ioparm.def: Add IOPARM_dt_f2003.

2008-09-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37498
	* file_pos (st_endfile): Clear memory only for libfortran 4.3 private
	area.
	* list_read.c (eat_separator): Only access F2003 I/O parameters if
	IOPARM_DT_HAS_F2003 bit is set. (parse_real): Ditto.
	(read_real): Ditto.
	* read.c (read_a): Likewise. (read_a_char4): Likewise though not
	strictly necessary. (read_f): Likewise.
	* io.h (unit_sign_s): New enumerator to allow duplication of
	st_parameter structures. (IOPARM_DT_HAS_F2003): New mask bit.
	(st_parameter_43): New structure copied from 4.3 version of 
	st_paramater_dt private section. (st_parameter_44): New structure with
	F2003 items added. (st_parameter_dt): Modified to create union of new
	and old structures to allow correct memory setting for 4.3 ABI
	compatibility. Bumped the pad size.
	* transfer.c (read_sf): Do not use F2003 I/O memory areas unless
	IOPARM_DT_HAS_F2003 bit has been set. (read_block_form): Ditto.
	(formatted_transfer_scalar): Ditto. (data_transfer_init): Ditto and
	add comment, fix formatting.
	* write.c (write_default_char4): Likewise though not strictly necessary.
	(write_utf8_char4): Ditto. (write_character): Ditto.
	(write_real_g0): Ditto. (list_formatted_write_scalar): Ditto.
	(nml_write_obj): Ditto. (namelist_write): Ditto.
	* write_float.def (calculate_sign): Eliminate warning by including all
	cases in switch. (output_float): Output only decimal point of F2003 flag
	is not set.

From-SVN: r140576
2008-09-23 03:52:19 +00:00
Jerry DeLisle 900e887f6d re PR fortran/37228 (F2008: Support g0.<d> edit descriptor)
2008-09-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/37228
	* io.c (check_format): Allow specifying precision with g0 format.

2008-09-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/37301
	PR libfortran/37228
	* io/io.h (write_real_g0): Declare new function to handle g0.d format.
	* io/transfer.c (formatted_transfer_scalar): Use new function.
	* io/format.c (parse_format_list): Enable g0.d.
	* io/write.c (write_a_char4): Delete unused var.
	(set_fnode_default): New function to set the default fnode w, d, and e
	factored from write_real. (write_real): Use new factored function.
	(write_real_g0): New function that sets d to that passed by g0.d format
	specifier and set format to ES.  Default values for w and e are used
	from the new function, set_fnode_default.

2008-09-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/37228
	* gfortran.dg/fmt_g0_4.f08: Revised test.

From-SVN: r139886
2008-09-02 10:50:13 +02:00
Jerry DeLisle 8c8627c472 re PR fortran/36895 (Namelist writting to internal files: Control characters wrong?)
2008-08-30  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/36895
	* io/write.c (namelist_write_newline): New function to correctly mark
	next records in both external and internal units.
	(nml_write_obj): Use new function.
	(namelist_write: Use new function.

From-SVN: r139813
2008-08-31 00:04:33 +00:00
Tobias Burnus cfd648ca23 re PR libfortran/35863 ([F2003] Implement ENCODING="UTF-8")
2008-08-19  Tobias Burnus  <burnus@net-b.de>

       PR libfortran/35863
       * io/write.c (write_a_char4): Add missing variable declaration
       in HAVE_CRLF block.

From-SVN: r139223
2008-08-19 08:00:51 +02:00
Jerry DeLisle 3ae86bf4f4 re PR libfortran/35863 ([F2003] Implement ENCODING="UTF-8")
2008-08-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/35863
	* intrinsics/selected_char_kind.c: Enable iso_10646.
	* io/read.c (typedef uchar): New type.
	(read_utf8): New function to read a single UTF-8 encoded character.
	(read_utf8_char1): New function to read UTF-8 into a KIND=1 string.
	(read_default_char1): New functio to read default into KIND=1 string.
	(read_utf8_char4): New function to read UTF-8 into a KIND=4 string.
	(read_default_char4): New function to read UTF-8 into a KIND=4 string.
	(read_a): Modify to use the new functions.
	(read_a_char4): Modify to use the new functions.
	* io/write.c (error.h): Add include. (typedef uchar): New type.
	(write_default_char4): New function to default write KIND=4 string.
	(write_utf8_char4): New function to UTF-8 write KIND=4 string.
	(write_a_char4): Modify to use new functions.
	(write_character): Modify to use new functions.

From-SVN: r139147
2008-08-16 03:38:31 +00:00
Jerry DeLisle ac834957b9 re PR fortran/36582 (Namelist I/O error: Bogus "Cannot match namelist object")
2008-07-22  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36852
	* io/list_read.c: If variable rank is zero, do not adjust the found
	namelist object pointer.

From-SVN: r138072
2008-07-23 04:29:15 +00:00