diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-01-30 10:06:52 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-30 10:06:52 +0000 |
commit | f8f0e563ce3115f738a4521806036fb84107e32f (patch) | |
tree | 14af1103f5bc64f1a9e74a689403ec93178a1491 /x2p | |
parent | ee16861aca3d3b92698682862dcc7700d61db89b (diff) | |
download | perl-f8f0e563ce3115f738a4521806036fb84107e32f.tar.gz |
Integrate:
[ 32689]
Subject: [PATCH] const'ing in cygwin.c
From: "Jerry D. Hedden" <jdhedden@cpan.org>
Date: Fri, 21 Dec 2007 09:13:41 -0500
Message-ID: <1ff86f510712210613s71712346i6e9f2b5e7275aa34@mail.gmail.com>
[ 32690]
Subject: [PATCH] C<make translators> -Wwrite-strings clean
From: "Robin Barker" <Robin.Barker@npl.co.uk>
Date: Fri, 21 Dec 2007 14:30:20 -0000
Message-ID: <46A0F33545E63740BC7563DE59CA9C6D09399C@exchsvr2.npl.ad.local>
[ 32711]
Remove warning about casting integer to different sized pointer.
[ 32720]
Subject: PATCH re 32711
From: "Robin Barker" <Robin.Barker@npl.co.uk>
Message-ID: <46A0F33545E63740BC7563DE59CA9C6D0939A4@exchsvr2.npl.ad.local>
Date: Mon, 24 Dec 2007 20:56:13 -0000
"IMO patch 32711 is better implemented using (the existing) NUM2PTR macro, as below/attached."
[ 32893]
Save an upgrade each by first setting the NV on PL_sv_yes and PL_sv_no
at interpreter construction time.
[ 32912]
newSV() + sv_upgrade() => newSV_type()
[ 32947]
Subject: [PATCH ext/POSIX/POSIX.xs]
From: "Robin Barker" <Robin.Barker@npl.co.uk>
Date: Thu, 10 Jan 2008 18:50:12 -0000
Message-ID: <46A0F33545E63740BC7563DE59CA9C6D0939C3@exchsvr2.npl.ad.local>
More consting.
[ 32960]
__DATE__ and __TIME__ are both string literals, so we can concatentate
them, rather than formating them via %s.
[ 32994]
Remove commented out code from S_validate_suid()
[ 32996]
Remove commented out declaration from S_validate_suid()
[ 33036]
Remove code obsoleted by change 18.
p4raw-link: @33036 on //depot/perl: 5c8c4cb2e56f3a0b4e2b54cb9ba6767a30ae85a4
p4raw-link: @32996 on //depot/perl: 69867b4e28ea835a3b328f99facbba4462e28c83
p4raw-link: @32994 on //depot/perl: eb36cb72ef10b6174e7dbe1080bd1872ad79cd34
p4raw-link: @32960 on //depot/perl: 895aa832c42328fe103a78a829d7dcfa39731ca7
p4raw-link: @32947 on //depot/perl: 4b48cf39454aea22003054f8b0a85963f328fe30
p4raw-link: @32912 on //depot/perl: d0328fd7d629f8429b08eacaee4fd3cb902fdf5e
p4raw-link: @32893 on //depot/perl: c1939273d48daaa779bfff86aacdcd7106ed3497
p4raw-link: @32720 on //depot/perl: 1f36f092f89152cd3ffb1cb9d8754c1edcc4ab53
p4raw-link: @32711 on //depot/perl: 51310be14a8055c326c9ad74c096ae990fb988c8
p4raw-link: @32690 on //depot/perl: aab391487e4ce7ac2d97b35a504de2697fadd1b6
p4raw-link: @32689 on //depot/perl: 3f5211dd25d06319ac363a33485c17282b4021a7
p4raw-id: //depot/maint-5.10/perl@33119
p4raw-integrated: from //depot/perl@33118 'copy in' x2p/util.h
(@26033..) x2p/a2p.c (@31350..) x2p/Makefile.SH (@31878..)
'merge in' ext/POSIX/POSIX.xs (@32703..)
p4raw-integrated: from //depot/perl@33036 'edit in' pp_ctl.c (@33034..)
p4raw-integrated: from //depot/perl@32960 'edit in' perl.c (@32959..)
p4raw-integrated: from //depot/perl@32711 'ignore' pp_hot.c (@32157..)
p4raw-integrated: from //depot/perl@32690 'copy in' x2p/a2py.c
x2p/str.c x2p/str.h x2p/util.c x2p/walk.c (@26033..) x2p/a2p.h
(@27204..)
p4raw-integrated: from //depot/perl@32689 'copy in' cygwin/cygwin.c
(@32006..)
Diffstat (limited to 'x2p')
-rwxr-xr-x | x2p/Makefile.SH | 3 | ||||
-rw-r--r-- | x2p/a2p.c | 6 | ||||
-rw-r--r-- | x2p/a2p.h | 12 | ||||
-rw-r--r-- | x2p/a2py.c | 23 | ||||
-rw-r--r-- | x2p/str.c | 12 | ||||
-rw-r--r-- | x2p/str.h | 10 | ||||
-rw-r--r-- | x2p/util.c | 7 | ||||
-rw-r--r-- | x2p/util.h | 4 | ||||
-rw-r--r-- | x2p/walk.c | 45 |
9 files changed, 65 insertions, 57 deletions
diff --git a/x2p/Makefile.SH b/x2p/Makefile.SH index b4c305894c..ba56c49e7b 100755 --- a/x2p/Makefile.SH +++ b/x2p/Makefile.SH @@ -124,6 +124,9 @@ run_byacc: FORCE -e 's/^yynewerror://' \ -e 's/^ goto yynewerror;//' \ -e 's|^static char yysccsid\(.*\)|/* static char yysccsid\1 */|' \ + -e 's/^\(char \*yyname\[\]\)/const \1/' \ + -e 's/^\(char \*yyrule\[\]\)/const \1/' \ + -e 's/^\( register\) \(char \*yys;\)/\1 const \2/' \ < y.tab.c > a2p.c FORCE: @@ -1984,7 +1984,7 @@ short yycheck[] = { 41, #endif #define YYMAXTOKEN 306 #if YYDEBUG -char *yyname[] = { +const char *yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,"'%'",0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, "':'","';'","'<'",0,"'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -1999,7 +1999,7 @@ char *yyname[] = { "DELETE","ASGNOP","OROR","ANDAND","NUMBER","VAR","SUBSTR","INDEX","MATCHOP", "RELOP","OR","STRING","UMINUS","NOT","INCR","DECR","FIELD","VFIELD","SVFIELD", }; -char *yyrule[] = { +const char *yyrule[] = { "$accept : program", "program : junk hunks", "begin : BEGIN '{' maybe states '}' junk", @@ -2193,7 +2193,7 @@ yyparse(void) { register int yym, yyn, yystate; #if YYDEBUG - register char *yys; + register const char *yys; if ((yys = getenv("YYDEBUG"))) { @@ -252,7 +252,7 @@ char *strcpy(), *strcat(); #define OSTAR 88 #ifdef DOINIT -char *opname[] = { +const char *opname[] = { "0", "PROG", "JUNK", @@ -345,7 +345,7 @@ char *opname[] = { "89" }; #else -extern char *opname[]; +extern const char *opname[]; #endif EXT int mop INIT(1); @@ -370,8 +370,8 @@ typedef struct htbl HASH; /* A string is TRUE if not "" or "0". */ #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1]))) -EXT char *Yes INIT("1"); -EXT char *No INIT(""); +EXT const char *Yes INIT("1"); +EXT const char *No INIT(""); #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) EXT STR *Str; @@ -397,8 +397,8 @@ void putone ( void ); int rememberargs ( int arg ); char * scannum ( char *s ); char * scanpat ( char *s ); -int string ( char *ptr, int len ); -void yyerror ( char *s ); +int string ( const char *ptr, int len ); +void yyerror ( const char *s ); int yylex ( void ); EXT int line INIT(0); diff --git a/x2p/a2py.c b/x2p/a2py.c index df0a55cb21..b6497afdb1 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -18,8 +18,8 @@ #endif #include "util.h" -char *filename; -char *myname; +const char *filename; +const char *myname; int checkers = 0; @@ -59,7 +59,7 @@ usage() #endif int -main(register int argc, register char **argv, register char **env) +main(register int argc, register const char **argv, register const char **env) { register STR *str; int i; @@ -126,7 +126,6 @@ main(register int argc, register char **argv, register char **env) } filename = savestr(argv[0]); - filename = savestr(argv[0]); if (strEQ(filename,"-")) argv[0] = ""; if (!*argv[0]) @@ -562,7 +561,7 @@ yylex(void) else if (strEQ(d,"function")) XTERM(FUNCTION); if (strEQ(d,"FILENAME")) - d = "ARGV"; + ID("ARGV"); if (strEQ(d,"foreach")) *d = toUPPER(*d); else if (strEQ(d,"format")) @@ -666,14 +665,14 @@ yylex(void) SNARFWORD; if (strEQ(d,"ORS")) { saw_ORS = TRUE; - d = "\\"; + ID("\\"); } if (strEQ(d,"OFS")) { saw_OFS = TRUE; - d = ","; + ID(","); } if (strEQ(d,"OFMT")) { - d = "#"; + ID("#"); } if (strEQ(d,"open")) *d = toUPPER(*d); @@ -701,8 +700,8 @@ yylex(void) case 'r': case 'R': SNARFWORD; if (strEQ(d,"RS")) { - d = "/"; saw_RS = TRUE; + ID("/"); } if (strEQ(d,"rand")) { yylval = ORAND; @@ -743,7 +742,7 @@ yylex(void) XTERM(FUN1); } if (strEQ(d,"SUBSEP")) { - d = ";"; + ID(";"); } if (strEQ(d,"sin")) { yylval = OSIN; @@ -878,7 +877,7 @@ scanpat(register char *s) } void -yyerror(char *s) +yyerror(const char *s) { fprintf(stderr,"%s in file %s at line %d\n", s,filename,line); @@ -921,7 +920,7 @@ scannum(register char *s) } int -string(char *ptr, int len) +string(const char *ptr, int len) { int retval = mop; @@ -25,7 +25,7 @@ str_2ptr(register STR *str) register char *s; if (!str) - return ""; + return (char *)""; /* probably safe - won't be written to */ GROWSTR(&(str->str_ptr), &(str->str_len), 24); s = str->str_ptr; if (str->str_nok) { @@ -56,7 +56,7 @@ str_sset(STR *dstr, register STR *sstr) } void -str_nset(register STR *str, register char *ptr, register int len) +str_nset(register STR *str, register const char *ptr, register int len) { GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); memcpy(str->str_ptr,ptr,len); @@ -67,7 +67,7 @@ str_nset(register STR *str, register char *ptr, register int len) } void -str_set(register STR *str, register char *ptr) +str_set(register STR *str, register const char *ptr) { register int len; @@ -82,7 +82,7 @@ str_set(register STR *str, register char *ptr) } void -str_ncat(register STR *str, register char *ptr, register int len) +str_ncat(register STR *str, register const char *ptr, register int len) { if (!(str->str_pok)) str_2ptr(str); @@ -104,7 +104,7 @@ str_scat(STR *dstr, register STR *sstr) } void -str_cat(register STR *str, register char *ptr) +str_cat(register STR *str, register const char *ptr) { register int len; @@ -250,7 +250,7 @@ thats_all_folks: } STR * -str_make(char *s) +str_make(const char *s) { register STR *str = str_new(0); @@ -29,15 +29,15 @@ EXT STR **tmps_list; EXT long tmps_max INIT(-1); char * str_2ptr ( STR *str ); -void str_cat ( STR *str, char *ptr ); +void str_cat ( STR *str, const char *ptr ); void str_free ( STR *str ); char * str_gets ( STR *str, FILE *fp ); int str_len ( STR *str ); -STR * str_make ( char *s ); -void str_ncat ( STR *str, char *ptr, int len ); +STR * str_make ( const char *s ); +void str_ncat ( STR *str, const char *ptr, int len ); STR * str_new ( int len ); -void str_nset ( STR *str, char *ptr, int len ); +void str_nset ( STR *str, const char *ptr, int len ); void str_numset ( STR *str, double num ); void str_scat ( STR *dstr, STR *sstr ); -void str_set ( STR *str, char *ptr ); +void str_set ( STR *str, const char *ptr ); void str_sset ( STR *dstr, STR *sstr ); diff --git a/x2p/util.c b/x2p/util.c index 6994e873f7..aff3f00873 100644 --- a/x2p/util.c +++ b/x2p/util.c @@ -119,9 +119,10 @@ cpy2(register char *to, register char *from, register int delim) /* return ptr to little string in big string, NULL if not found */ char * -instr(char *big, char *little) +instr(char *big, const char *little) { - register char *t, *s, *x; + register char *t, *x; + register const char *s; for (t = big; *t; t++) { for (x=t,s=little; *s; x++,s++) { @@ -139,7 +140,7 @@ instr(char *big, char *little) /* copy a string to a safe spot */ char * -savestr(char *str) +savestr(const char *str) { register char * const newaddr = (char *) safemalloc((MEM_SIZE)(strlen(str)+1)); diff --git a/x2p/util.h b/x2p/util.h index 74341c2959..3330a60957 100644 --- a/x2p/util.h +++ b/x2p/util.h @@ -21,8 +21,8 @@ char * cpy2 ( char *to, char *from, int delim ); char * cpytill ( char *to, char *from, int delim ); void growstr ( char **strptr, int *curlen, int newlen ); -char * instr ( char *big, char *little ); -char * savestr ( char *str ); +char * instr ( char *big, const char *little ); +char * savestr ( const char *str ); void fatal ( const char *pat, ... ); void warn ( const char *pat, ... ); int prewalk ( int numit, int level, int node, int *numericptr ); diff --git a/x2p/walk.c b/x2p/walk.c index de1263fc16..cc9f8ac74c 100644 --- a/x2p/walk.c +++ b/x2p/walk.c @@ -19,9 +19,9 @@ bool saw_FNR = FALSE; bool saw_argv0 = FALSE; bool saw_fh = FALSE; int maxtmp = 0; -char *lparen; -char *rparen; -char *limit; +const char *lparen; +const char *rparen; +const char *limit; STR *subs; STR *curargs = Nullstr; @@ -36,7 +36,7 @@ STR * walk ( int useval, int level, int node, int *numericptr, int minprec ); #ifdef NETWARE char *savestr(char *str); char *cpytill(register char *to, register char *from, register int delim); -char *instr(char *big, char *little); +char *instr(char *big, const char *little); #endif STR * @@ -838,7 +838,9 @@ sub Pick {\n\ len = type >> 8; type &= 255; tmp3str = str_new(0); - if (type == OSTR) { + { + const char *s; + if (type == OSTR) { tmp2str=walk(1,level,ops[ops[node+2].ival+1].ival,&numarg,P_MIN); for (t = tmp2str->str_ptr, d=tokenbuf; *t; d++,t++) { if (*t == '&') @@ -849,18 +851,19 @@ sub Pick {\n\ } *d = '\0'; str_set(tmp2str,tokenbuf); - s = (char *) (gsub ? "/g" : "/"); - } - else { + s = (gsub ? "/g" : "/"); + } + else { tmp2str=walk(1,level,ops[node+2].ival,&numarg,P_MIN); str_set(tmp3str,"($s_ = '\"'.("); str_scat(tmp3str,tmp2str); str_cat(tmp3str,").'\"') =~ s/&/\\$&/g, "); str_set(tmp2str,"eval $s_"); - s = (char *) (gsub ? "/ge" : "/e"); + s = (gsub ? "/ge" : "/e"); i++; + } + str_cat(tmp2str,s); } - str_cat(tmp2str,s); type = ops[ops[node+1].ival].ival; len = type >> 8; type &= 255; @@ -909,8 +912,9 @@ sub Pick {\n\ break; case OSTR: tmpstr = walk(1,level,ops[node+1].ival,&numarg,P_MIN); - s = "'"; - for (t = tmpstr->str_ptr, d=tokenbuf; *t; d++,t++) { + { + const char *s = "'"; + for (t = tmpstr->str_ptr, d=tokenbuf; *t; d++,t++) { if (*t == '\'') s = "\""; else if (*t == '\\') { @@ -924,13 +928,14 @@ sub Pick {\n\ } } *d = *t + 128; + } + *d = '\0'; + str = str_new(0); + str_set(str,s); + str_cat(str,tokenbuf); + str_free(tmpstr); + str_cat(str,s); } - *d = '\0'; - str = str_new(0); - str_set(str,s); - str_cat(str,tokenbuf); - str_free(tmpstr); - str_cat(str,s); break; case ODEFINED: prec = P_UNI; @@ -1208,7 +1213,7 @@ sub Pick {\n\ } tmpstr = walk(1+(type==OPRINT),level,ops[node+1].ival,&numarg,P_MIN); if (!*tmpstr->str_ptr && lval_field) { - t = (char*)(saw_OFS ? "$," : "' '"); + const char *t = (saw_OFS ? "$," : "' '"); if (split_to_array) { sprintf(tokenbuf,"join(%s,@Fld)",t); str_cat(tmpstr,tokenbuf); @@ -1284,7 +1289,7 @@ sub Pick {\n\ tmpstr = str_new(0); if (!tmpstr->str_ptr || !*tmpstr->str_ptr) { if (lval_field) { - t = (char*)(saw_OFS ? "$," : "' '"); + const char *t = (saw_OFS ? "$," : "' '"); if (split_to_array) { sprintf(tokenbuf,"join(%s,@Fld)",t); str_cat(tmpstr,tokenbuf); |