===================================================================
@@ -242,7 +242,7 @@ match_hollerith_constant (gfc_expr **result)
locus old_loc;
gfc_expr *e = NULL;
const char *msg;
- int num;
+ int num, pad;
int i;
old_loc = gfc_current_locus;
@@ -279,8 +279,11 @@ match_hollerith_constant (gfc_expr **result)
e = gfc_get_constant_expr (BT_HOLLERITH, gfc_default_character_kind,
&gfc_current_locus);
- e->representation.string = XCNEWVEC (char, num + 1);
+ /* Calculate padding needed to fit default integer memory. */
+ pad = gfc_default_integer_kind - (num % gfc_default_integer_kind);
+ e->representation.string = XCNEWVEC (char, num + pad + 1);
+
for (i = 0; i < num; i++)
{
gfc_char_t c = gfc_next_char_literal (1);
@@ -294,9 +297,13 @@ match_hollerith_constant (gfc_expr **result)
e->representation.string[i] = (unsigned char) c;
}
- e->representation.string[num] = '\0';
- e->representation.length = num;
+ /* Now pad with blanks and end with a null char. */
+ for (i = 0; i < pad; i++)
+ e->representation.string[num + i] = ' ';
+ e->representation.string[num + i] = '\0 ';
+ e->representation.length = num + pad;
+
*result = e;
return MATCH_YES;
}