diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-10-22 13:12:48 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-10-22 13:12:48 +0000 |
commit | 7dd03145f7521e677db128080742a33214229568 (patch) | |
tree | 73370c902a6d57458b9052da2af8aa6898c585a7 /ext/Encode | |
parent | 6472dca1ce130971bdb208d64ccb9758afc367d0 (diff) | |
download | perl-7dd03145f7521e677db128080742a33214229568.tar.gz |
use more 'const' in the Encode data structures.
p4raw-id: //depot/perl@25823
Diffstat (limited to 'ext/Encode')
-rw-r--r-- | ext/Encode/Encode/encode.h | 34 | ||||
-rw-r--r-- | ext/Encode/bin/enc2xs | 7 |
2 files changed, 23 insertions, 18 deletions
diff --git a/ext/Encode/Encode/encode.h b/ext/Encode/Encode/encode.h index 7a2fa268de..a6880cfd9b 100644 --- a/ext/Encode/Encode/encode.h +++ b/ext/Encode/Encode/encode.h @@ -16,14 +16,14 @@ typedef struct encpage_s encpage_t; struct encpage_s { /* fields ordered to pack nicely on 32-bit machines */ - const U8 *seq; /* Packed output sequences we generate + const U8 *const seq; /* Packed output sequences we generate if we match */ - const encpage_t *next; /* Page to go to if we match */ - U8 min; /* Min value of octet to match this entry */ - U8 max; /* Max value of octet to match this entry */ - U8 dlen; /* destination length - + const encpage_t *const next; /* Page to go to if we match */ + const U8 min; /* Min value of octet to match this entry */ + const U8 max; /* Max value of octet to match this entry */ + const U8 dlen; /* destination length - size of entries in seq */ - U8 slen; /* source length - + const U8 slen; /* source length - number of source octets needed */ }; @@ -60,16 +60,18 @@ struct encpage_s typedef struct encode_s encode_t; struct encode_s { - const encpage_t *t_utf8; /* Starting table for translation from - the encoding to UTF-8 form */ - const encpage_t *f_utf8; /* Starting table for translation - from UTF-8 to the encoding */ - const U8 *rep; /* Replacement character in this encoding - e.g. "?" */ - int replen; /* Number of octets in rep */ - U8 min_el; /* Minimum octets to represent a character */ - U8 max_el; /* Maximum octets to represent a character */ - const char *name[2]; /* name(s) of this encoding */ + const encpage_t *const t_utf8; /* Starting table for translation from + the encoding to UTF-8 form */ + const encpage_t *const f_utf8; /* Starting table for translation + from UTF-8 to the encoding */ + const U8 *const rep; /* Replacement character in this + encoding e.g. "?" */ + int replen; /* Number of octets in rep */ + U8 min_el; /* Minimum octets to represent a + character */ + U8 max_el; /* Maximum octets to represent a + character */ + const char *const name[2]; /* name(s) of this encoding */ }; #ifdef U8 diff --git a/ext/Encode/bin/enc2xs b/ext/Encode/bin/enc2xs index ae2a166c34..82ff01c0ce 100644 --- a/ext/Encode/bin/enc2xs +++ b/ext/Encode/bin/enc2xs @@ -276,16 +276,19 @@ if ($doC) #my @info = ($e2u->{Cname},$u2e->{Cname},$rsym,length($rep),$min_el,$max_el); my $replen = 0; $replen++ while($rep =~ /\G\\x[0-9A-Fa-f]/g); - my @info = ($e2u->{Cname},$u2e->{Cname},qq((U8 *)"$rep"),$replen,$min_el,$max_el); my $sym = "${enc}_encoding"; $sym =~ s/\W+/_/g; + my @info = ($e2u->{Cname},$u2e->{Cname},"${sym}_rep_character",$replen, + $min_el,$max_el); + print C "static const U8 ${sym}_rep_character[] = \"$rep\";\n"; + print C "static const char ${sym}_enc_name[] = \"$enc\";\n\n"; print C "const encode_t $sym = \n"; # This is to make null encoding work -- dankogai for (my $i = (scalar @info) - 1; $i >= 0; --$i){ $info[$i] ||= 1; } # end of null tweak -- dankogai - print C " {",join(',',@info,"{\"$enc\",(const char *)0}"),"};\n\n"; + print C " {",join(',',@info,"{${sym}_enc_name,(const char *)0}"),"};\n\n"; } foreach my $enc (sort cmp_name keys %encoding) |