diff --git a/runtime/flang/fmtread.c b/runtime/flang/fmtread.c index ff24d31155d..360440ba304 100644 --- a/runtime/flang/fmtread.c +++ b/runtime/flang/fmtread.c @@ -1624,8 +1624,15 @@ fr_read(char *item, /* where to transfer data to. The value of item may if (g->curr_pos > g->obuff_len) g->curr_pos = g->obuff_len; else { +#ifdef TARGET_LLVM_ARM64 + if (g->rec_len < g->curr_pos) { + memset(g->rec_buff + g->rec_len, ' ', g->curr_pos - g->rec_len); + g->rec_len = g->curr_pos; + } +#else while (g->rec_len < g->curr_pos) g->rec_buff[g->rec_len++] = ' '; +#endif } } } @@ -1713,11 +1720,23 @@ fr_read(char *item, /* where to transfer data to. The value of item may i = fr_move_fwd(w); if (i != 0) return i; +#ifdef TARGET_LLVM_ARM64 + memcpy(item, g->rec_buff + idx, w); + item += w; +#else while (w-- > 0) *item++ = g->rec_buff[idx++]; +#endif if (g->pad == FIO_YES) { +#ifdef TARGET_LLVM_ARM64 + if (pad > 0) { + memset(item, ' ', pad); + item += pad; + } +#else while (pad > 0) *item++ = ' ', pad--; +#endif } } goto exit_loop; @@ -1749,11 +1768,23 @@ fr_read(char *item, /* where to transfer data to. The value of item may i = fr_move_fwd(w); if (i != 0) return i; +#ifdef TARGET_LLVM_ARM64 + memcpy(item, g->rec_buff + idx, w); + item += w; +#else while (w-- > 0) *item++ = g->rec_buff[idx++]; +#endif if (g->pad == FIO_YES) { +#ifdef TARGET_LLVM_ARM64 + if (pad > 0) { + memset(item, ' ', pad); + item += pad; + } +#else while (pad > 0) *item++ = ' ', pad--; +#endif } goto exit_loop; } @@ -3199,8 +3230,15 @@ fr_move_fwd(int len) move_fwd_eor = 1; } +#if TARGET_LLVM_ARM64 + if (g->rec_len < g->curr_pos) { + memset(g->rec_buff + g->rec_len, ' ', g->curr_pos - g->rec_len); + g->rec_len = g->curr_pos; + } +#else while (g->rec_len < g->curr_pos) g->rec_buff[g->rec_len++] = ' '; +#endif } g->max_pos = g->curr_pos; return 0;