diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2008-05-06 21:06:20 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2008-05-06 21:06:20 +0000 |
commit | 006601890b953c9177624f9f533b997f344802ad (patch) | |
tree | afe9f21644dc49be8c1557eb5347bf2f587920d2 /gcc/fortran/expr.c | |
parent | 1b38192d61001d9cd1b15baf233a9e8847d06889 (diff) | |
download | gcc-006601890b953c9177624f9f533b997f344802ad.zip gcc-006601890b953c9177624f9f533b997f344802ad.tar.gz gcc-006601890b953c9177624f9f533b997f344802ad.tar.bz2 |
arith.c: (gfc_arith_concat...
* arith.c: (gfc_arith_concat, gfc_compare_string,
gfc_compare_with_Cstring, hollerith2representation,
gfc_hollerith2int, gfc_hollerith2real, gfc_hollerith2complex,
gfc_hollerith2character, gfc_hollerith2logical): Use wide
characters for character constants.
* data.c (create_character_intializer): Likewise.
* decl.c (gfc_set_constant_character_len): Likewise.
* dump-parse-tree.c (show_char_const): Correctly dump wide
character strings.
error.c (print_wide_char): Rename into gfc_print_wide_char.
(show_locus): Adapt to new prototype of gfc_print_wide_char.
expr.c (free_expr0): Representation is now disjunct from
character string value, so we always free it.
(gfc_copy_expr, find_substring_ref, gfc_simplify_expr): Adapt
to wide character strings.
* gfortran.h (gfc_expr): Make value.character.string a wide string.
(gfc_wide_toupper, gfc_wide_strncasecmp, gfc_wide_memset,
gfc_widechar_to_char, gfc_char_to_widechar): New prototypes.
(gfc_get_wide_string): New macro.
(gfc_print_wide_char): New prototype.
* io.c (format_string): Make a wide string.
(next_char, gfc_match_format, compare_to_allowed_values,
gfc_match_open): Deal with wide strings.
* module.c (mio_expr): Convert between wide strings and ASCII ones.
* primary.c (match_hollerith_constant, match_charkind_name):
Handle wide strings.
* resolve.c (build_default_init_expr): Likewise.
* scanner.c (gfc_wide_toupper, gfc_wide_memset,
gfc_char_to_widechar): New functions.
(wide_strchr, gfc_widechar_to_char, gfc_wide_strncasecmp):
Changes in prototypes.
(gfc_define_undef_line, load_line, preprocessor_line,
include_line, load_file, gfc_read_orig_filename): Handle wide
strings.
* simplify.c (gfc_simplify_achar, gfc_simplify_adjustl,
gfc_simplify_adjustr, gfc_simplify_char, gfc_simplify_iachar,
gfc_simplify_ichar, simplify_min_max, gfc_simplify_new_line,
gfc_simplify_repeat): Handle wide strings.
(wide_strspn, wide_strcspn): New helper functions.
(gfc_simplify_scan, gfc_simplify_trim, gfc_simplify_verify):
Handle wide strings.
* symbol.c (generate_isocbinding_symbol): Likewise.
* target-memory.c (size_character, gfc_target_expr_size,
encode_character, gfc_target_encode_expr, gfc_interpret_character,
gfc_target_interpret_expr): Handle wide strings.
* trans-const.c (gfc_conv_string_init): Lower wide strings to
narrow ones.
(gfc_conv_constant_to_tree): Likewise.
* trans-expr.c (gfc_conv_substring_expr): Handle wide strings.
* trans-io.c (gfc_new_nml_name_expr): Likewise.
* trans-stmt.c (gfc_trans_label_assign): Likewise.
From-SVN: r135006
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 70914c1..87ea9e9 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -164,9 +164,8 @@ free_expr0 (gfc_expr *e) break; } - /* Free the representation, except in character constants where it - is the same as value.character.string and thus already freed. */ - if (e->representation.string && e->ts.type != BT_CHARACTER) + /* Free the representation. */ + if (e->representation.string) gfc_free (e->representation.string); break; @@ -393,7 +392,8 @@ gfc_expr * gfc_copy_expr (gfc_expr *p) { gfc_expr *q; - char *s; + gfc_char_t *s; + char *c; if (p == NULL) return NULL; @@ -404,20 +404,19 @@ gfc_copy_expr (gfc_expr *p) switch (q->expr_type) { case EXPR_SUBSTRING: - s = gfc_getmem (p->value.character.length + 1); + s = gfc_get_wide_string (p->value.character.length + 1); q->value.character.string = s; - - memcpy (s, p->value.character.string, p->value.character.length + 1); + memcpy (s, p->value.character.string, + (p->value.character.length + 1) * sizeof (gfc_char_t)); break; case EXPR_CONSTANT: /* Copy target representation, if it exists. */ if (p->representation.string) { - s = gfc_getmem (p->representation.length + 1); - q->representation.string = s; - - memcpy (s, p->representation.string, p->representation.length + 1); + c = gfc_getmem (p->representation.length + 1); + q->representation.string = c; + memcpy (c, p->representation.string, (p->representation.length + 1)); } /* Copy the values of any pointer components of p->value. */ @@ -443,10 +442,11 @@ gfc_copy_expr (gfc_expr *p) case BT_CHARACTER: if (p->representation.string) - q->value.character.string = q->representation.string; + q->value.character.string + = gfc_char_to_widechar (q->representation.string); else { - s = gfc_getmem (p->value.character.length + 1); + s = gfc_get_wide_string (p->value.character.length + 1); q->value.character.string = s; /* This is the case for the C_NULL_CHAR named constant. */ @@ -460,7 +460,7 @@ gfc_copy_expr (gfc_expr *p) } else memcpy (s, p->value.character.string, - p->value.character.length + 1); + (p->value.character.length + 1) * sizeof (gfc_char_t)); } break; @@ -1379,7 +1379,7 @@ find_substring_ref (gfc_expr *p, gfc_expr **newp) int end; int start; int length; - char *chr; + gfc_char_t *chr; if (p->ref->u.ss.start->expr_type != EXPR_CONSTANT || p->ref->u.ss.end->expr_type != EXPR_CONSTANT) @@ -1392,9 +1392,10 @@ find_substring_ref (gfc_expr *p, gfc_expr **newp) start = (int) mpz_get_ui (p->ref->u.ss.start->value.integer); length = end - start + 1; - chr = (*newp)->value.character.string = gfc_getmem (length + 1); + chr = (*newp)->value.character.string = gfc_get_wide_string (length + 1); (*newp)->value.character.length = length; - memcpy (chr, &p->value.character.string[start - 1], length); + memcpy (chr, &p->value.character.string[start - 1], + length * sizeof (gfc_char_t)); chr[length] = '\0'; return SUCCESS; } @@ -1592,7 +1593,7 @@ gfc_simplify_expr (gfc_expr *p, int type) if (gfc_is_constant_expr (p)) { - char *s; + gfc_char_t *s; int start, end; if (p->ref && p->ref->u.ss.start) @@ -1608,8 +1609,9 @@ gfc_simplify_expr (gfc_expr *p, int type) else end = p->value.character.length; - s = gfc_getmem (end - start + 2); - memcpy (s, p->value.character.string + start, end - start); + s = gfc_get_wide_string (end - start + 2); + memcpy (s, p->value.character.string + start, + (end - start) * sizeof (gfc_char_t)); s[end - start + 1] = '\0'; /* TODO: C-style string. */ gfc_free (p->value.character.string); p->value.character.string = s; |