2016-09-06 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/77393
* io/write_float.def (build_float_string): Recognize when the
result will not fit in the user provided, star fill, and exit
early.
* gfortran.dg/fmt_f0_2.f90: Update test.
* gfortran.dg/fmt_f0_3.f90: New test.
From-SVN: r240018
2016-06-23 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/48852
* io/write.c: Cleaned up whitespace.
(write_d, write_e, write_f, write_es, write_en): Use new helper function
write_float_0. (write_float_0): New helper function.
(get_precision, select_buffer, select_string, write_float_string): New
helper functions used in remaining float writing functions. Helper function
write_float_string now contains code for writing to kind=4 character
internal units.
(write_real): Modified to establish working buffers at this level and to
use new helper functions.
(write_real_g0): Likewise modified.
(write_complex): Likewise modified. Gets both float strings before
output so that final lengths can be determined which allows right
justifying the complex number with no intervening spaces.
* io/write_float.def (build_float_string): Renamed from previosly
output_float, modified to use buffers passed in from higher functions,
builds a null terminated string of the floating point value. Character
kind=4 code eliminated.
(write_infnan): Likewise modified to use incoming buffers and eliminate
kind=4 related code.
(OUTPUT_FLOAT_FMT_G): Deleted, functionality moved into FORMAT_FLOAT.
(FORMAT_FLOAT): Renamed macro from WRITE_FLOAT. Use build_float_string.
(get_float_string): Renamed from write_float, uses FORMAT_FLOAT macro.
Buffer allocation removed, now at higher level.
PR libgfortran/48852
* gfortran.dg/char4_iunit_1.f03: Update test.
* gfortran.dg/f2003_io_5.f03: Update test.
* gfortran.dg/real_const_3.f90: Update test.
From-SVN: r237735
2016-03-30 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Dominique d'Humieres <dominiq@lps.ens.fr>
PR libgfortran/70235
* io/write_float.def: Fix PF format for negative values of the scale
factor.
2016-03-30 Dominique d'Humieres <dominiq@lps.ens.fr>
Jerry DeLisle <jvdelisle@gcc.gnu.org>
* gfortran.dg/fmt_pf.f90: New test.
From-SVN: r234600
2015-11-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* io/write_float.def (output_float): Move block determining
room for leading zero to before checkng g0 formatting.
From-SVN: r230728
PR libfortran/57496
* io/write_float.def: Use built-in type-generic functions defined
by libgfortran.h for isfinite, isnan, and signbit.
From-SVN: r227136
2015-02-10 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/57822
* io/write_float.def (output_float): Apply fix of previous patch
to correctly calculate the exponent number of digits and take
care of wide character output.
From-SVN: r220606
2015-02-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/57822
* io/write_float.def (output_float): If doing g0 editing and
exponent is zero, do not emit exponent.
From-SVN: r220564
2014-11-13 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/60324
* configure: Regenerated.
* configure.ac (AM_CFLAGS): Add Werror=vla.
* libgfortran.h (gfc_alloca): Remove macro.
(fc_strdup_notrim): New prototype.
* intrinsics/access.c (access_func): Use fc_strdup rather than
stack allocation.
* intrinsics/chdir.c (chdir_i4_sub): Likewise.
(chdir_i8_sub): Likewise.
* intrinsics/chmod.c (chmod_internal): New function, move logic
here.
(chmod_func): Call chmod_internal.
* intrinsics/env.c (getenv): Use fc_strdup rather than stack
allocation.
(get_environment_variable_i4): Likewise.
* intrinsics/execute_command_line.c (execute_command_line):
Likewise.
* intrinsics/hostnm.c (hostnm_0): New function, use static buffer
rather than VLA.
(hostnm_i4_sub): Call hostnm_0.
(hostnm_i8_sub): Likewise.
(hostnm): Likewise.
* intrinsics/link.c (link_internal): New function, use fc_strdup
rather than stack allocation.
(link_i4_sub): Call link_internal.
(link_i8_sub): Likewise.
(link_i4): Likewise.
(link_i8): Likewise.
* intrinsics/perror.c (perror_sub): Use fc_strdup rather than
stack allocation.
* intrinsics/random.c (random_seed_i4): Use static buffer rather
than VLA, use _Static_assert to make sure it's big enough.
* intrinsics/rename.c (rename_internal): New function, use
fc_strdup rather than stack allocation.
(rename_i4_sub): Call rename_internal.
(rename_i8_sub): Likewise.
(rename_i4): Likewise.
(rename_i8): Likewise.
* intrinsics/stat.c (stat_i4_sub_0): Use fc_strdup rather than
stack allocation.
(stat_i8_sub_0): Likewise.
* intrinsics/symlink.c (symlnk_internal): New function, use
fc_strdup rather than stack allocation.
(symlnk_i4_sub): Call symlnk_internal.
(symlnk_i8_sub): Likewise.
(symlnk_i4): Likewise.
(symlnk_i8): Likewise.
* intrinsics/system.c (system_sub): Use fc_strdup rather than
stack allocation.
* intrinsics/unlink.c (unlink_i4_sub): Likewise.
* io/file_pos.c (READ_CHUNK): Make it a macro rather than variable.
* io/list_read.c (nml_get_obj_data): Use fixed stack buffer, fall
back to xmalloc/free for large sizes.
* io/read.c (read_f): Likewise.
* io/transfer.c (MAX_READ): Make it a macro rather than variable.
(WRITE_CHUNK): Likewise.
* io/write_float.def (write_float): Use fixed stack buffer, fall
back to xmalloc/free for large sizes.
* runtime/string.c (fc_strdup_notrim): New function.
From-SVN: r217480
2014-03-08 Dominique d'Humieres <dominiq@lps.ens.fr>
PR libgfortran/60128
* io/write_float.def (output_float): Remove unused variable
nzero_real. Replace a double space with a single one.
(determine_en_precision): Fix wrong handling of the EN format.
PR libfortran/60128
* gfortran.dg/fmt_en.f90: New test.
From-SVN: r208423
2013-03-19 Janne Blomqvist <jb@gcc.gnu.org>
* libgfortran.h: Include stdbool.h.
(enum try): Remove.
(notify_std): Change return type to bool.
* intrinsics/chmod.c: Don't include stdbool.h.
* intrinsics/execute_command_line.c: Likewise.
* io/format.c: Likewise.
* io/list_read.c (nml_parse_qualifier): Change return type to bool.
(nml_read_obj): Likewise.
(nml_get_obj_data): Likewise.
* io/transfer.c (read_block_form): Fix comment.
(write_buf): Change return type to bool.
* io/write.c: Don't include stdbool.h.
* io/write_float.def (output_float): Change return type to bool.
(output_float_FMT_G_ ## x): Change type of result variable.
* runtime/error.c (notify_std): Change return type to bool.
From-SVN: r196791
2012-03-17 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/52608
* io/write_float.def (output_float): Move removal of initial zeros
until after the scale factor has been applied.
From-SVN: r185486
2012-03-15 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/52434
PR libfortran/48878
PR libfortran/38199
* io/unit.c (get_internal_unit): Default to ROUND_UNSPECIFIED.
(init_units): Likewise.
* io/write_float.def (determine_precision): New function.
(output_float): Take into account buffer with %f format, no need
for our own rounding if unspecified or processor specified
rounding.
(DTOA): Simplify format string, add parameters.
(FDTOA): New macros similar to DTOA, but using %f format.
(OUTPUT_FLOAT_FMT_G): Stack allocate newf, determine correct
precision and fill buffer.
(EN_PREC): New macro.
(determine_en_precision): New function.
(WRITE_FLOAT): For G format, move buffer filling into
output_float_FMT_G, use FDTOA for F format.
(write_float): Increase buffer due to F format.
testsuite ChangeLog:
2012-03-15 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/52434
PR libfortran/48878
PR libfortran/38199
* gfortran.dg/edit_real_1.f90: Don't assume roundTiesToAway.
* gfortran.dg/round_1.f03: Likewise.
From-SVN: r185433
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-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-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-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-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-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-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-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-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-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-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
2010-07-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/44953
* io/unix.c (mem_alloc_w4): Return gfc_char4_t instead of char type
pointer. (mem_write4): Remove cast to gfc_char4_t.
* io/transfer.c (write_block): Use a gfc_char4_t pointer.
(memset4): New helper function. (next_record_w): Use new helper
function rather than sset for internal units. Don't attempt to pad
with spaces if it is not needed.
* io/unix.h: Update prototype for mem_alloc_w4.
* io/write.c (memset4): Use gfc_char4_t pointer and chracter type.
Don't use multiply by 4 to compute offset. (memcpy4): Likewise.
(write_default_char4): Use a gfc_char4_t pointer and update memset4
and memcpy calls. (write_a): Likewise. (write_l): Likewise.
(write_boz): Likewise. (write_decimal): Likewise. (write_x): Likewise.
(write_char): Add support for character(kind=4) internal units that
was previously missed. (write_integer): Use a gfc_char4_t pointer and
update memset4 and memcpy calls. (write_character): Likewise.
(write_separator): Add support for character(kind=4) internal units
that was previously missed.
* write_float.def (output_float): Use a gfc_char4_t pointer and
update memset4 and memcpy calls. (write_infnan): Likewise.
(output_float_FMT_G_): Likewise.
From-SVN: r162304
2010-07-12 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/37077
* io/read.c: Fix comment.
* io/io.h (is_char4_unit): New macro.
* io/unit.c (get_internal_unit): Call new function open_internal4.
* io/unix.c (mem_alloc_r4): New function. (mem_alloc_w4): New function.
(mem_read4): New function, temporary stub. (mem_write4): New function.
(open_internal4): New function to set stream pointers to use the new
mem functions.
* io/transfer.c (write_block): Use new mem_alloc_w4 to access internal
units of kind=4.
* io/unix.h: Add prototypes for open_internal4, mem_alloc_w4, and
mem_alloc_r4.
* io/write.c (memset4): New helper function. (memcpy4): New helper
function. (write_default_char4): Use new helper functions.
(write_a): Likewise. (write_l): Likewise. (write_boz): Likewise.
(write_decimal): Likewise. (write_x): Likewise.
(write_integer): Likewise.
* io/write_float.def (output_float): Add code blocks to handle internal
unit kind=4 output utilizing gfc_char4_t pointers. (write_infnan): Use
new helper functions. (OUTPUT_FLOAT_FMT_G): Update this macro likewise.
From-SVN: r162123
2009-10-05 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/35862
* write_float.def (outout_float): Fix handling of special case where no
digits after the decimal point and values less than 1.0. Adjust index
into digits string. (WRITE_FLOAT): Remove special case code from macro.
From-SVN: r152483
2009-09-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/35862
* io.h (gfc_unit): Add round_status.
(format_token): Add enumerators for rounding format specifiers.
* transfer.c (round_opt): New options table.
(formatted_transfer_scalar_read): Add set round_status for each rounding
format token. (formatted_transfer_scalar_write): Likewise.
* format.c (format_lex): Tokenize the rounding format specifiers.
(parse_format_list): Parse the rounding format specifiers.
* write_float.def (outout_float): Modify rounding code to use new
variable rchar to set the appropriate rounding. Fix some whitespace.
* unit.c (get_internal_unit): Initialize rounding mode for internal
units. (init_units): Likewise.
From-SVN: r152263