Commit Graph

432 Commits

Author SHA1 Message Date
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
Daniel Kraft 9cad01cefb re PR fortran/29835 (Error message of unknown edit descriptor needs improvement)
2008-07-22  Daniel Kraft  <d@domob.eu>

	PR fortran/29835
	* io.c (error_element), (format_locus):  New static globals.
	(unexpected_element):  Spelled out this message fully.
	(next_char):  Keep track of locus when not MODE_STRING.
	(next_char_not_space):  Remember last parsed element in error_element.
	(format_lex):  Fix two indentation errors.
	(check_format):  Use format_locus and possibly error_element for a
	slightly better error message on invalid format.
	(check_format_string):  Set format_locus to start of the string
	expression used as format.

2008-07-22  Daniel Kraft  <d@domob.eu>

	PR fortran/29835
	* io/format.c (struct format_data):  New member error_element.
	(unexpected_element):  Added '%c' to message.
	(next_char):  Keep track of last parsed character in fmt->error_element.
	(format_error):  If the message is unexpected_element, output the
	offending character, too.

2008-07-22  Daniel Kraft  <d@domob.eu>

	PR fortran/29835
	* gfortran.dg/fmt_error_3.f90:  New test.
	* gfortran.dg/fmt_error_4.f90:  New test.
	* gfortran.dg/fmt_error_5.f90:  New test.

From-SVN: r138063
2008-07-22 19:05:55 +02:00
Thomas Koenig 4a799ae7a6 re PR fortran/36890 (libgfortran/io/file_pos.c:55: warning: comparison between signed and unsigned)
2008-07-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/36890
	* io/file_pos.c:  Declare READ_CHUNK as signed to avoid
	signed/unsigned comparison warning in formatted_backspace.

From-SVN: r138050
2008-07-22 10:27:10 +00:00
Jerry DeLisle 302b150e73 re PR libfortran/36857 (Non-English locale breaks gfortran float formatting ("printf is broken"))
2008-07-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36857
	* io/write_float.def: Comment out locale dependent code and fix general
	comments.

From-SVN: r138021
2008-07-21 04:44:10 +00:00
Jerry DeLisle bdd3085e66 re PR fortran/36676 (Namelist Comments Problems)
2008-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36676
	* io/list_read.c (find_nml_name): Use eat_separator instead of eat_line.

From-SVN: r137334
2008-07-02 03:58:57 +00:00
Jerry DeLisle 7b063fdc13 re PR libfortran/36657 (Namelist reading bug with string constant immediately followed by comment)
2008-06-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36657
	* io/list_read.c (read_character): Check for '!' along with separators.
	(find_nml_name): Likewise and eat the comment if found.

From-SVN: r137236
2008-06-28 21:46:53 +00:00
Jerry DeLisle fb669c2b42 re PR libfortran/36546 (Namelist error with tab following a comma and newline)
2008-06-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36546
	* io/list_read.c (eat_separator): Add tab character to condition
	for looping past whitespace.

From-SVN: r136859
2008-06-17 04:14:07 +00:00
Jerry DeLisle a9608b5743 re PR fortran/36515 (Integer read from stdin yields a value overflow for a valid integer.)
2008-06-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36515
	* libgfortran.h (compile_options_t): Add int range_check to structure.
	* runtime/compile_options.c (set_options): Add range_check option.
	(init_compile_options): Likewise.
	*io/read.c (read_decimal): Change overflow checks to include
	range_check.

From-SVN: r136822
2008-06-15 20:02:58 +00:00
Jerry DeLisle a82094b70d re PR libfortran/36538 (namelist failure with tabs preceding object name)
2008-06-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36538
	* io/list_read.c (namelist_read): Add eat_separator to eliminate leading
	tabs.

From-SVN: r136776
2008-06-14 04:30:48 +00:00
Jerry DeLisle cea93abbe2 re PR libfortran/35863 ([F2003] Implement ENCODING="UTF-8")
2008-06-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/35863
	* libgfortran.h: Change l8_to_l4_offset to big_endian and add endian_off.
	* runtime/main.c: Fix error in comment. Change l8_to_l4_offset to
	big_endian. (determine_endianness): Add endian_off and set its value
	according to big_endian.
	* gfortran.map: Add symbol for new _gfortran_transfer_character_wide.
	* io/io.h: Add prototype declarations for new functions.
	* io/list_read.c (list_formatted_read_scalar): Modify to handle kind=4.
	(list_formatted_read): Calculate stride based on kind for character type
	and use it when calling list_formatted_read_scalar.
	* io/inquire.c (inquire_via_unit): Change l8_to_l4_offset to big_endian.
	* io/open.c (st_open): Change l8_to_l4_offset to big_endian.
	* io/read.c (read_a_char4): New function to handle formatted read.
	* io/write.c: Define GFC_CHAR4(x) to improve readability of code.
	(write_a_char4): New function to handle formatted write.
	(write_character): Modify to accept the kind parameter and adjust for
	endianess of the machine. (list_formatted_write): Calculate the stride
	resulting from the kind and adjust the list_formatted_write_scalar call
	accordingly. (nml_write_obj): Adjust calls to write_character.
	(namelist_write): Likewise.
	* io/transfer.c (formatted_transfer_scaler): Rename 'len' argument to
	'kind' argument to better describe what it is. Add calls to new
	functions for kind == 4. (formatted_transfer): Modify to handle the case
	of type character and kind equals 4 to pass in the kind to the transfer
	routines. (transfer_character_wide): Add this new function.
	(transfer_array): Don't set kind to the character string length. Adjust
	strides bases on character kind.
	(unformatted_read): Adjust size based on kind for character types.
	(unformatted_write): Likewise. (data_transfer_init): Change
	l8_to_l4_offset to big_endian.

From-SVN: r136763
2008-06-13 20:28:08 +00:00
Jerry DeLisle 9355110f96 re PR fortran/36420 (Fortran 2008: g0 edit descriptor)
2008-06-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/36420
	PR libfortran/36421
	PR libfortran/36422
	* io/io.h: Add prototype for write_real.
	* io/transfer.c (formatted_transfer_scalar): For FMT_G and width zero,
	use write_real.
	* io/format.c: Add zero width error message. (parse_format_list): Use
	error message for FMT_A if followed by FMT_ZERO. Use zero width error
	message	for FMT_G if mode is READ or if -std=f95 or f2003. (fmormat0):
	Fix typo in comment.
	* io/write.c (write_a): Set wlen to len if FMT_G and length is zero.
	(write_l): Add wlen variable and use it if FMT_G and width is zero.
	(write_decimal): If FMT_G, set m to -1 to flag processor dependent
	formatting. (write_real): Remove static declaration.

From-SVN: r136545
2008-06-07 23:59:53 +00:00
Thomas Koenig 51407486c4 list_read.c (list_formatted_read_scalar): Declare type as volatile to shut up compiler warning.
2008-05-17  Thomas Koenig  <tkoenig@gcc.gnu.org>

	* io/list_read.c (list_formatted_read_scalar):  Declare
	type as volatile to shut up compiler warning.

From-SVN: r135480
2008-05-17 22:24:06 +00:00
Janne Blomqvist 8947fd62fa Part 1.1 of PR25561.
2008-05-15  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/25561
	* io/io.h (struct fbuf): Change pointer to position offset.
	* io/fbuf.c (fbuf_init): Reduce default size of buffer, ptr=>pos
	changes.
	(fbuf_reset): ptr=>pos changes.
	(fbuf_alloc): If the request doesn't fit, don't waste memory by
	keeping flushed bytes. ptr=>pos changes.
	(fbuf_flush): ptr=>pos changes.
	(fbuf_seek): Don't seek past the left tab limit, don't update active
	byte count.
	* io/open.c (new_unit): If RECL has been specified, used that as
	initial buffer size.

From-SVN: r135433
2008-05-16 20:42:44 +03:00
Janne Blomqvist 65686652e4 Fix fallout from part 1 of PR25561 patch.
2008-05-16  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/35632
        * io/open.c (new_unit): Set stream position to correct value.

From-SVN: r135432
2008-05-16 20:37:30 +03:00
Janne Blomqvist 3044d36951 Part 1 of PR25561, fix compile warnings forgotten in actual commit.
From-SVN: r135379
2008-05-15 19:32:00 +03:00
Janne Blomqvist 7c1b4aba72 Add fbuf.c
From-SVN: r135376
2008-05-15 18:58:20 +03:00
Janne Blomqvist 15877a88eb Part 1 of PR 25561.
2008-05-15  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/25561
	* Makefile.am: Add fbuf.c to gfor_io_src.
	* Makefile.in: Regenerate.
	* io/io.h (read_block): Remove.
	(struct stream): Remove alloc_r_at function pointer.
	(salloc_r): Remove.
	(salloc_r_at): Remove.
	(salloc_w_at): Remove.
	(salloc_w): Remove offset argument.
	(struct fbuf): New struct for format buffer.
	(struct gfc_unit): Add fbuf.
	(read_block_form): New prototype.
	(fbuf_init): Likewise.
	(fbuf_destroy): Likewise.
	(fbuf_reset): Likewise.
	(fbuf_alloc): Likewise.
	(fbuf_flush): Likewise.
	(fbuf_seek): Likewise.
	* io/file_pos.c (formatted_backspace): Change to use sread.
	(unformatted_backspace): Likewise.
	(st_backspace): Flush format buffer.
	(st_rewind): Likewise.
	* io/list_read.c (next_char): Likewise.
	(nml_query): Tidying, flush format buffer.
	* io/open.c (new_unit): Init format buffer.
	* io/read.c (read_l): Change to use read_block_form.
	(read_a): Likewise.
	(read_decimal): Likewise.
	(read_radix): Likewise.
	(read_f): Likewise.
	(read_x): Empty reads also for stream I/O.
	* io/transfer.c (read_sf): Change to use sread.
	(read_block): Rename to read_block_form, change prototype, use sread.
	(read_block_direct): Don't seek stream files.
	(write_block): Change to use fbuf if external file, don't seek stream
	files.
	(write_buf): Don't seek stream files.
	(formatted_transfer_scalar): Use fbuf for external files.
	(us_read): Change to use sread.
	(pre_position): Do nothing for stream I/O.
	(data_transfer_init): Flush fbuf when switching from write to read, if
	POS is specified, seek stream file to correct offset.
	(skip_record): Change to use sread.
	(min_off): New function.
	(next_record_r): Change to use sread.
	(next_record_w): Change to use sset/sseek, flush fbuf.
	(finalize_transfer): Flush fbuf.
	* io/unit.c (init_units): Init fbuf for stdout, stderr.
	(close_unit_1): Destroy fbuf.
	(finish_last_advance_record): Flush fbuf, no need to seek.
	* io/unix.c (fd_alloc_r_at): Remove unused where argument.
	(fd_alloc_w_at): Likewise.
	(fd_read): Remove third argument to fd_alloc_r_at.
	(fd_write): Remove third argument to fd_alloc_w_at.
	(fd_sset): Likewise.
	(fd_open): Don't set alloc_r_at.
	(mem_alloc_r_at): Remove unused where argument.
	(mem_alloc_w_at): Likewise.
	(mem_read): Don't incorrectly return previous errno, remove unused
	third argument to alloc function.
	(mem_write): Likewise.
	(mem_set): Likewise.
	(open_internal): Don't set alloc_r_at pointer.
	* io/fbuf.c: New file.

From-SVN: r135373
2008-05-15 18:53:34 +03:00
Jerry DeLisle 36afed5a79 re PR libfortran/36202 ([mingw] Namelist read fails with CRLF)
2008-05-11  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/36202
	* io/list_read (eat_separator): Handle the CR-LF case correctly.

From-SVN: r135177
2008-05-11 15:02:41 +00:00
Jerry DeLisle d0d51277e2 re PR libfortran/36131 (wrong IO)
2008-05-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/36131
	* io/transfer.c (formatted_transfer_scalar): Revert patch for PR34974.
	(next_record_w): Likewise.

From-SVN: r134973
2008-05-06 04:00:38 +00:00
Jerry DeLisle c26cc9a6a6 re PR libfortran/36094 (Runtime error show_locus not working correctly)
2008-05-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/36094
	* runtime/error.c (show_locus): Provide modified error message when
	filename has not yet been associated with a unit number.
	* io/open.c (encoding_opt[]): Comment out "utf-8" option and add TODO.

From-SVN: r134876
2008-05-02 01:33:16 +00:00
Jakub Jelinek 24722ea98e list_read.c (snprintf): Define if HAVE_SNPRINTF isn't defined.
* io/list_read.c (snprintf): Define if HAVE_SNPRINTF isn't defined.
	(nml_read_obj): Add nml_err_msg_size argument.  Pass it down to
	recursive call.  Use snprintf instead of sprintf when %s nl->var_name
	is used.
	(nml_get_obj_data): Add nml_err_msg_size argument.  Pass it down to
	nml_read_obj call.  Use snprintf instead of sprintf when %s
	nl->var_name is used.  Pass nml_err_msg to nml_parse_qualifier instead
	of parse_err_msg array.  Append " for namelist variable " and
	nl->var_name to it.
	(namelist_read): Increase size of nml_err_msg array to 200.  Pass
	sizeof nml_err_msg as extra argument to nml_get_obj_data.

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

From-SVN: r134132
2008-04-09 11:00:31 +02:00
Jerry DeLisle 931149a6b7 PR fortran/25829 28655
2008-04-07  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/25829 28655
	* io/open.c (edit_modes): Set flags.async. (new_unit) Set flags.async
	and flags.status. (st_open): Initialize flags.async.
	* io/list_read.c (read_charactor): Use delim_status instead of
	flags.delim.
	* io/read.c (read_x): Use pad_status instead of flags.pad.
	* io/inquire.c (inquire_via_unit): Add new checks.
	(inquire_via_filename): Likewise.
	* io/io.h (st_parameter_inquire): Add new flags.
	(st_parameter_dt): Likewise.
	* io/unit.c (get_internal_unit): Set flags.async. (init_units): Set
	flags.async.
	* io/transfer.c: Add delim and pad option arrays. (read_sf): Use
	pad_status instead of flags.pad. (read_block): Likewise.
	(data_transfer_init): Set flags.async and add checks.
	* io/write.c (write_character): Use delim_status.
	(list_formatted_write_scalar): Likewise. (nml_write_obj): Likewise.
	(namelist_write): Likewise.

From-SVN: r133988
2008-04-07 22:05:52 +00:00
Jerry DeLisle 10256cbe95 PR fortran/25829 28655
2008-04-05  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/25829 28655
	* gfortran.map: Add new symbol, _gfortran_st_wait.
	* libgfortran.h (st_paramter_common): Add new I/O parameters.
	* open.c (st_option decimal_opt[], st_option encoding_opt[],
	st_option round_opt[], st_option sign_opt[], st_option async_opt[]): New
	parameter option arrays. (edit_modes): Add checks for new parameters.
	(new_unit): Likewise. (st_open): Likewise.
	* list_read.c (CASE_SEPERATORS): Add ';' as a valid separator.
	(eat_separator): Handle deimal comma. (read_logical): Fix whitespace.
	(parse_real): Handle decimal comma. (read_real): Handle decimal comma.
	* read.c (read_a): Use decimal status flag to allow comma in place of a
	decimal point. (read_f): Allow comma as acceptable character in float.
	According to decimal flag, substitute a period for a comma.
	(read_x): If decimal status flag is comma, disable the read_comma flag,
	not allowing comma as a delimiter, an extension otherwise.
	* io.h: (unit_decimal, unit_encoding, unit_round, unit_sign,
	unit_async): New enumerators. Add all new I/O parameters.
	* unix.c (unix_stream, int_stream): Add io_mode	asychronous I/O	control.
	(move_pos_offset, fd_alloc_w_at): Fix some whitespace.
	(fd_sfree): Use new enumerator. (fd_read): Likewise.
	(fd_write): Likewise. (fd_close): Fix whitespace.
	(fd_open): Use new enumertors. (tempfile, regular_file,
	open_external): Fix whitespace. (output_stream, error_stream): Set
	method. (stream_offset): Fix whitespace.
	* transfer.c: (st_option decimal_opt[], sign_opt[], blank_opt[]): New
	option arrays. 	(formatted_transfer_scalar): Set sf_read_comma flag
	based on new decimal_status flag. (data_transfer_init): Initialize new
	parameters. Add checks for decimal, sign, and blank. (st_wait): New stub.
	* format.c: (format_lex): Add format specifiers DP, DC, and D.
	(parse_format_list): Parse the new specifiers.
	* write.c (write_decimal): Use new sign enumerators to set the sign.
	(write_complex): Handle decimal comma and semi-colon separator.
	(nml_write_obj): Likewise.
	* write_float.def: Revise sign enumerators. (calculate_sign): Use new
	sign enumerators. (output_float): Likewise. Use new decimal_status flag
	to set the decimal character to a point or a comma.

From-SVN: r133943
2008-04-05 22:18:03 +00:00
Jerry DeLisle fc8bc1753d re PR fortran/35699 (run-time abort writing zero sized section to direct access file)
2008-03-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/35699
	* io/transfer.c (write_buf):  Don't pad the record, just return if the
	data is NULL.  (next_record_w): If there are bytes left in the record
	for unformatted direct I/O, pad out the record with zero bytes.

From-SVN: r133699
2008-03-28 22:13:17 +00:00