Skip to content

Commit

Permalink
GCC attributes!
Browse files Browse the repository at this point in the history
Message-ID: <20050504215540.GA20413@petdance.com>

p4raw-id: //depot/perl@24414
  • Loading branch information
petdance authored and rgs committed May 7, 2005
1 parent 892b45b commit 4373e32
Show file tree
Hide file tree
Showing 15 changed files with 611 additions and 423 deletions.
1 change: 1 addition & 0 deletions autodoc.pl
Expand Up @@ -53,6 +53,7 @@ (&@)
else {
@args = split /\s*\|\s*/, $_;
}
s/\bNN\b\s+// for @args;
print $F $function->(@args);
}
print $F $trailer if $trailer;
Expand Down
3 changes: 1 addition & 2 deletions av.c
Expand Up @@ -25,7 +25,6 @@ void
Perl_av_reify(pTHX_ AV *av)
{
I32 key;
SV* sv;

if (AvREAL(av))
return;
Expand All @@ -37,7 +36,7 @@ Perl_av_reify(pTHX_ AV *av)
while (key > AvFILLp(av) + 1)
AvARRAY(av)[--key] = &PL_sv_undef;
while (key) {
sv = AvARRAY(av)[--key];
SV * const sv = AvARRAY(av)[--key];
assert(sv);
if (sv != &PL_sv_undef)
(void)SvREFCNT_inc(sv);
Expand Down
30 changes: 16 additions & 14 deletions doio.c
Expand Up @@ -926,7 +926,7 @@ Perl_nextargv(pTHX_ register GV *gv)
}
else {
if (ckWARN_d(WARN_INPLACE)) {
int eno = errno;
const int eno = errno;
if (PerlLIO_stat(PL_oldname, &PL_statbuf) >= 0
&& !S_ISREG(PL_statbuf.st_mode))
{
Expand Down Expand Up @@ -1040,11 +1040,10 @@ bool
Perl_io_close(pTHX_ IO *io, bool not_implicit)
{
bool retval = FALSE;
int status;

if (IoIFP(io)) {
if (IoTYPE(io) == IoTYPE_PIPE) {
status = PerlProc_pclose(IoIFP(io));
const int status = PerlProc_pclose(IoIFP(io));
if (not_implicit) {
STATUS_NATIVE_SET(status);
retval = (STATUS_POSIX == 0);
Expand Down Expand Up @@ -1177,7 +1176,7 @@ Perl_mode_from_discipline(pTHX_ SV *discp)
int mode = O_BINARY;
if (discp) {
STRLEN len;
char *s = SvPV(discp,len);
const char *s = SvPV(discp,len);
while (*s) {
if (*s == ':') {
switch (s[1]) {
Expand Down Expand Up @@ -1210,7 +1209,7 @@ Perl_mode_from_discipline(pTHX_ SV *discp)
--len;
}
else {
char *end;
const char *end;
fail_discipline:
end = strchr(s+1, ':');
if (!end)
Expand Down Expand Up @@ -1393,7 +1392,7 @@ Perl_my_stat(pTHX)
}
else {
SV* sv = POPs;
char *s;
const char *s;
STRLEN len;
PUTBACK;
if (SvTYPE(sv) == SVt_PVGV) {
Expand Down Expand Up @@ -1451,6 +1450,7 @@ Perl_my_lstat(pTHX)
GvENAME((GV*) SvRV(sv)));
return (PL_laststatval = -1);
}
/* XXX Do really need to be calling SvPV() all these times? */
sv_setpv(PL_statname,SvPV(sv, n_a));
PL_laststatval = PerlLIO_lstat(SvPV(sv, n_a),&PL_statcache);
if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(SvPV(sv, n_a), '\n'))
Expand Down Expand Up @@ -1700,7 +1700,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
char *name = SvPVx(*mark, n_a);
const char *name = SvPVx(*mark, n_a);
APPLY_TAINT_PROPER();
if (PerlLIO_chmod(name, val))
tot--;
Expand All @@ -1718,7 +1718,7 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
char *name = SvPVx(*mark, n_a);
const char *name = SvPVx(*mark, n_a);
APPLY_TAINT_PROPER();
if (PerlLIO_chown(name, val, val2))
tot--;
Expand Down Expand Up @@ -1859,12 +1859,13 @@ nothing in the core.
utbuf.modtime = (Time_t)SvIVx(modified); /* time modified */
#endif
}
APPLY_TAINT_PROPER();
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
char *name = SvPVx(*mark, n_a);
STRLEN n_a;
const char *name = SvPVx(*mark, n_a);
APPLY_TAINT_PROPER();
if (PerlLIO_utime(name, utbufp))
if (PerlLIO_utime(name, utbufp))
tot--;
}
}
Expand All @@ -1881,7 +1882,7 @@ nothing in the core.
/* Do the permissions allow some operation? Assumes statcache already set. */
#ifndef VMS /* VMS' cando is in vms.c */
bool
Perl_cando(pTHX_ Mode_t mode, Uid_t effective, register Stat_t *statbufp)
Perl_cando(pTHX_ Mode_t mode, Uid_t effective, register const Stat_t *statbufp)
/* Note: we use `effective' both for uids and gids.
* Here we are betting on Uid_t being equal or wider than Gid_t. */
{
Expand Down Expand Up @@ -2237,7 +2238,7 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
{
#ifdef HAS_SHM
SV *mstr;
char *mbuf, *shm;
char *shm;
I32 mpos, msize;
STRLEN len;
struct shmid_ds shmds;
Expand All @@ -2258,6 +2259,7 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
if (shm == (char *)-1) /* I hate System V IPC, I really do */
return -1;
if (optype == OP_SHMREAD) {
const char *mbuf;
/* suppress warning when reading into undef var (tchrist 3/Mar/00) */
if (! SvOK(mstr))
sv_setpvn(mstr, "", 0);
Expand All @@ -2276,7 +2278,7 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
else {
I32 n;

mbuf = SvPV(mstr, len);
const char *mbuf = SvPV(mstr, len);
if ((n = len) > msize)
n = msize;
Copy(mbuf, shm + mpos, n, char);
Expand Down
32 changes: 16 additions & 16 deletions doop.c
Expand Up @@ -252,7 +252,7 @@ S_do_trans_complex(pTHX_ SV *sv)
else {
while (s < send) {
STRLEN len;
UV comp = utf8_to_uvchr(s, &len);
const UV comp = utf8_to_uvchr(s, &len);
if (comp > 0xff) {
if (!complement) {
Move(s, d, len, U8);
Expand Down Expand Up @@ -354,23 +354,22 @@ S_do_trans_simple_utf8(pTHX_ SV *sv)
d = uvuni_to_utf8(d, uv);
}
else if (uv == none) {
int i = UTF8SKIP(s);
const int i = UTF8SKIP(s);
Move(s, d, i, U8);
d += i;
s += i;
}
else if (uv == extra) {
int i = UTF8SKIP(s);
s += i;
s += UTF8SKIP(s);
matches++;
d = uvuni_to_utf8(d, final);
}
else
s += UTF8SKIP(s);

if (d > dend) {
STRLEN clen = d - dstart;
STRLEN nlen = dend - dstart + len + UTF8_MAXBYTES;
const STRLEN clen = d - dstart;
const STRLEN nlen = dend - dstart + len + UTF8_MAXBYTES;
if (!grows)
Perl_croak(aTHX_ "panic: do_trans_simple_utf8 line %d",__LINE__);
Renew(dstart, nlen + UTF8_MAXBYTES, U8);
Expand Down Expand Up @@ -412,9 +411,10 @@ S_do_trans_count_utf8(pTHX_ SV *sv)

s = (U8*)SvPV(sv, len);
if (!SvUTF8(sv)) {
U8 *t = s, *e = s + len;
const U8 *t = s;
const U8 *e = s + len;
while (t < e) {
U8 ch = *t++;
const U8 ch = *t++;
if ((hibit = !NATIVE_IS_INVARIANT(ch)))
break;
}
Expand All @@ -441,9 +441,9 @@ S_do_trans_complex_utf8(pTHX_ SV *sv)
U8 *start, *send;
U8 *d;
I32 matches = 0;
I32 squash = PL_op->op_private & OPpTRANS_SQUASH;
I32 del = PL_op->op_private & OPpTRANS_DELETE;
I32 grows = PL_op->op_private & OPpTRANS_GROWS;
const I32 squash = PL_op->op_private & OPpTRANS_SQUASH;
const I32 del = PL_op->op_private & OPpTRANS_DELETE;
const I32 grows = PL_op->op_private & OPpTRANS_GROWS;
SV* rv = (SV*)cSVOP->op_sv;
HV* hv = (HV*)SvRV(rv);
SV** svp = hv_fetch(hv, "NONE", 4, FALSE);
Expand Down Expand Up @@ -495,8 +495,8 @@ S_do_trans_complex_utf8(pTHX_ SV *sv)
uv = swash_fetch(rv, s, TRUE);

if (d > dend) {
STRLEN clen = d - dstart;
STRLEN nlen = dend - dstart + len + UTF8_MAXBYTES;
const STRLEN clen = d - dstart;
const STRLEN nlen = dend - dstart + len + UTF8_MAXBYTES;
if (!grows)
Perl_croak(aTHX_ "panic: do_trans_complex_utf8 line %d",__LINE__);
Renew(dstart, nlen + UTF8_MAXBYTES, U8);
Expand All @@ -513,7 +513,7 @@ S_do_trans_complex_utf8(pTHX_ SV *sv)
continue;
}
else if (uv == none) { /* "none" is unmapped character */
int i = UTF8SKIP(s);
const int i = UTF8SKIP(s);
Move(s, d, i, U8);
d += i;
s += i;
Expand Down Expand Up @@ -600,7 +600,7 @@ I32
Perl_do_trans(pTHX_ SV *sv)
{
STRLEN len;
I32 hasutf = (PL_op->op_private &
const I32 hasutf = (PL_op->op_private &
(OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF));

if (SvREADONLY(sv)) {
Expand Down Expand Up @@ -704,7 +704,7 @@ void
Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
{
STRLEN patlen;
char *pat = SvPV(*sarg, patlen);
const char *pat = SvPV(*sarg, patlen);
bool do_taint = FALSE;

SvUTF8_off(sv);
Expand Down

0 comments on commit 4373e32

Please sign in to comment.