[#7708] Bug in libsnmp-ruby1.8 — Hadmut Danisch <hadmut@...>

Hi,

8 messages 2006/04/11
[#7709] Re: Bug in libsnmp-ruby1.8 — Eric Hodel <drbrain@...7.net> 2006/04/11

On Apr 11, 2006, at 6:23 AM, Hadmut Danisch wrote:

[#7770] Re: possible defect in array.c — "Brown, Warren" <warrenbrown@...>

> rb_range_beg_len (in range.c) does set beg and len.

13 messages 2006/04/26
[#7771] Re: possible defect in array.c — "Pat Eyler" <rubypate@...> 2006/04/26

On 4/26/06, Brown, Warren <warrenbrown@aquire.com> wrote:

Patch: code-cleanup (const...)

From: Stefan Huehner <stefan@...>
Date: 2006-04-25 11:20:18 UTC
List: ruby-core #7764
Hi,

attached patch adds alot of const to 'char*' variables and parameters.
This is necessary when string-literals are included in the source, as
these memory location are not writable. Additinally i added cons't to
function parameters where the parameters isn't modified in the
functions' body.

Please consider applying the patch..

Regards,
Stefan

Attachments (1)

ruby_cleanup1.diff (25.1 KB, text/x-diff)
Index: bignum.c
===================================================================
RCS file: /src/ruby/bignum.c,v
retrieving revision 1.128
diff -u -r1.128 bignum.c
--- bignum.c	1 Mar 2006 10:06:02 -0000	1.128
+++ bignum.c	25 Apr 2006 11:07:41 -0000
@@ -406,7 +406,7 @@
     len *= strlen(str)*sizeof(char);
 
     if (len <= (sizeof(VALUE)*CHAR_BIT)) {
-	unsigned long val = strtoul((char*)str, &end, base);
+	unsigned long val = strtoul(str, &end, base);
 
 	if (*end == '_') goto bigparse;
 	if (badcheck) {
@@ -516,7 +516,7 @@
 
 #if HAVE_LONG_LONG
 
-VALUE
+static VALUE
 rb_ull2big(unsigned LONG_LONG n)
 {
     BDIGIT_DBL num = n;
@@ -537,7 +537,7 @@
     return big;
 }
 
-VALUE
+static VALUE
 rb_ll2big(LONG_LONG n)
 {
     long neg = 0;
Index: error.c
===================================================================
RCS file: /src/ruby/error.c,v
retrieving revision 1.121
diff -u -r1.121 error.c
--- error.c	13 Feb 2006 04:53:21 -0000	1.121
+++ error.c	25 Apr 2006 11:07:41 -0000
@@ -209,7 +209,7 @@
     if (TYPE(x) != t) {
 	while (type->type >= 0) {
 	    if (type->type == t) {
-		char *etype;
+		const char *etype;
 
 		if (NIL_P(x)) {
 		    etype = "nil";
@@ -434,7 +434,7 @@
 check_backtrace(VALUE bt)
 {
     long i;
-    static char *err = "backtrace must be Array of String";
+    static const char *err = "backtrace must be Array of String";
 
     if (!NIL_P(bt)) {
 	int t = TYPE(bt);
@@ -683,7 +683,7 @@
     mesg = ptr[0];
     if (NIL_P(mesg)) return Qnil;
     else {
-	char *desc = 0;
+	const char *desc = 0;
 	VALUE d = 0, args[3];
 
 	obj = ptr[1];
@@ -828,7 +828,7 @@
 #if !defined(_WIN32) && !defined(__VMS)
     char *strerror();
 #endif
-    char *err;
+    const char *err;
     VALUE mesg, error;
     VALUE klass = rb_obj_class(self);
 
Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.890
diff -u -r1.890 eval.c
--- eval.c	23 Feb 2006 04:24:39 -0000	1.890
+++ eval.c	25 Apr 2006 11:07:42 -0000
@@ -1869,7 +1869,7 @@
 void
 rb_frozen_class_p(VALUE klass)
 {
-    char *desc = "something(?!)";
+    const char *desc = "something(?!)";
 
     if (OBJ_FROZEN(klass)) {
 	if (FL_TEST(klass, FL_SINGLETON))
@@ -1905,7 +1905,7 @@
     }
     body = search_method(klass, id, &origin);
     if (!body || !body->nd_body) {
-	char *s0 = " class";
+	const char *s0 = " class";
 	VALUE c = klass;
 
 	if (FL_TEST(c, FL_SINGLETON)) {
@@ -6326,7 +6326,7 @@
 rb_f_eval(int argc, VALUE *argv, VALUE self)
 {
     VALUE src, scope, vfile, vline;
-    char *file = "(eval)";
+    const char *file = "(eval)";
     int line = 1;
 
     rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
@@ -6458,7 +6458,7 @@
 	return yield_under(klass, self, Qundef);
     }
     else {
-	char *file = "(eval)";
+	const char *file = "(eval)";
 	int   line = 1;
 
 	if (argc == 0) {
@@ -9193,7 +9193,7 @@
     struct METHOD *data;
     VALUE str;
     const char *s;
-    char *sharp = "#";
+    const char *sharp = "#";
 
     Data_Get_Struct(method, struct METHOD, data);
     str = rb_str_buf_new2("#<");
Index: io.c
===================================================================
RCS file: /src/ruby/io.c,v
retrieving revision 1.401
diff -u -r1.401 io.c
--- io.c	28 Mar 2006 01:50:11 -0000	1.401
+++ io.c	25 Apr 2006 11:07:42 -0000
@@ -1095,7 +1095,8 @@
 rb_io_inspect(VALUE obj)
 {
     OpenFile *fptr;
-    char *cname, *st = "";
+    char *cname;
+    const char *st = "";
 
     fptr = RFILE(rb_io_taint_check(obj))->fptr;
     if (!fptr || !fptr->path) return rb_any_to_s(obj);
Index: marshal.c
===================================================================
RCS file: /src/ruby/marshal.c,v
retrieving revision 1.125
diff -u -r1.125 marshal.c
--- marshal.c	5 Feb 2006 14:40:01 -0000	1.125
+++ marshal.c	25 Apr 2006 11:07:42 -0000
@@ -304,7 +304,7 @@
 static void
 w_symbol(ID id, struct dump_arg *arg)
 {
-    char *sym = rb_id2name(id);
+    const char *sym = rb_id2name(id);
     st_data_t num;
 
     if (st_lookup(arg->symbols, id, &num)) {
@@ -872,7 +872,7 @@
     return r_symreal(arg);
 }
 
-static char*
+static const char*
 r_unique(struct load_arg *arg)
 {
     return rb_id2name(r_symbol(arg));
Index: numeric.c
===================================================================
RCS file: /src/ruby/numeric.c,v
retrieving revision 1.136
diff -u -r1.136 numeric.c
--- numeric.c	5 Feb 2006 12:08:38 -0000	1.136
+++ numeric.c	25 Apr 2006 11:07:42 -0000
@@ -2603,7 +2603,7 @@
 static VALUE
 fix_id2name(VALUE fix)
 {
-    char *name = rb_id2name(FIX2UINT(fix));
+    const char *name = rb_id2name(FIX2UINT(fix));
     if (name) return rb_str_new2(name);
     return Qnil;
 }
Index: object.c
===================================================================
RCS file: /src/ruby/object.c,v
retrieving revision 1.184
diff -u -r1.184 object.c
--- object.c	2 Mar 2006 05:22:30 -0000	1.184
+++ object.c	25 Apr 2006 11:07:42 -0000
@@ -266,7 +266,7 @@
 inspect_i(ID id, VALUE value, VALUE str)
 {
     VALUE str2;
-    char *ivname;
+    const char *ivname;
 
     /* need not to show internal data */
     if (CLASS_OF(value) == 0) return ST_CONTINUE;
@@ -1007,7 +1007,7 @@
 sym_inspect(VALUE sym)
 {
     VALUE str;
-    char *name;
+    const char *name;
     ID id = SYM2ID(sym);
 
     name = rb_id2name(id);
@@ -2258,7 +2258,7 @@
 }
 
 static VALUE
-boot_defclass(char *name, VALUE super)
+boot_defclass(const char *name, VALUE super)
 {
     extern st_table *rb_class_tbl;
     VALUE obj = rb_class_boot(super);
Index: pack.c
===================================================================
RCS file: /src/ruby/pack.c,v
retrieving revision 1.83
diff -u -r1.83 pack.c
--- pack.c	1 Mar 2006 10:06:03 -0000	1.83
+++ pack.c	25 Apr 2006 11:07:42 -0000
@@ -1286,7 +1286,7 @@
 static VALUE
 pack_unpack(VALUE str, VALUE fmt)
 {
-    static char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
+    static const char *hexdigits = "0123456789abcdef0123456789ABCDEFx";
     char *s, *send;
     char *p, *pend;
     VALUE ary;
@@ -1320,7 +1320,7 @@
 	}
 	star = 0;
 	if (*p == '_' || *p == '!') {
-	    char *natstr = "sSiIlL";
+	    const char *natstr = "sSiIlL";
 
 	    if (strchr(natstr, type)) {
 #ifdef NATINT_PACK
Index: parse.y
===================================================================
RCS file: /src/ruby/parse.y,v
retrieving revision 1.434
diff -u -r1.434 parse.y
--- parse.y	26 Mar 2006 13:04:13 -0000	1.434
+++ parse.y	25 Apr 2006 11:07:44 -0000
@@ -7427,7 +7427,7 @@
 static void
 void_expr_gen(struct parser_params *parser, NODE *node)
 {
-    char *useless = 0;
+    const char *useless = 0;
 
     if (!RTEST(ruby_verbose)) return;
 
@@ -8236,7 +8236,7 @@
 
 static const struct {
     ID token;
-    char *name;
+    const char *name;
 } op_tbl[] = {
     {tDOT2,	".."},
     {tDOT3,	"..."},
@@ -8471,10 +8471,10 @@
     return id;
 }
 
-char *
+const char *
 rb_id2name(ID id)
 {
-    char *name;
+    const char *name;
     st_data_t data;
 
     if (id < tLAST_TOKEN) {
Index: re.c
===================================================================
RCS file: /src/ruby/re.c,v
retrieving revision 1.149
diff -u -r1.149 re.c
--- re.c	26 Mar 2006 13:04:13 -0000	1.149
+++ re.c	25 Apr 2006 11:07:44 -0000
@@ -1243,12 +1243,12 @@
 }
 
 static int
-name_to_backref_number(struct re_registers *regs, VALUE regexp, char* name, char* name_end)
+name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end)
 {
   int num;
 
   num = onig_name_to_backref_number(RREGEXP(regexp)->ptr,
-            (unsigned char* )name, (unsigned char* )name_end, regs);
+            (const unsigned char* )name, (const unsigned char* )name_end, regs);
   if (num >= 1) {
     return num;
   }
@@ -1297,7 +1297,7 @@
         }
       }
       else {
-        char *p;
+        const char *p;
         int num;
 
         switch (TYPE(idx)) {
Index: regerror.c
===================================================================
RCS file: /src/ruby/regerror.c,v
retrieving revision 1.4
diff -u -r1.4 regerror.c
--- regerror.c	23 Mar 2006 12:08:08 -0000	1.4
+++ regerror.c	25 Apr 2006 11:07:44 -0000
@@ -276,8 +276,8 @@
   UChar bs[6];
   va_list args;
 
-  va_init_list(args, (char* )fmt);
-  n = vsnprintf((char* )buf, bufsize, (char* )fmt, args);
+  va_init_list(args, (const char* )fmt);
+  n = vsnprintf((char* )buf, bufsize, (const char* )fmt, args);
   va_end(args);
 
   need = (pat_end - pat) * 4 + 4;
Index: regparse.c
===================================================================
RCS file: /src/ruby/regparse.c,v
retrieving revision 1.25
diff -u -r1.25 regparse.c
--- regparse.c	23 Mar 2006 12:08:08 -0000	1.25
+++ regparse.c	25 Apr 2006 11:07:44 -0000
@@ -4487,11 +4487,11 @@
   return 0;
 }
 
-static char* PopularQStr[] = {
+static const char* PopularQStr[] = {
   "?", "*", "+", "??", "*?", "+?"
 };
 
-static char* ReduceQStr[] = {
+static const char* ReduceQStr[] = {
   "", "", "*", "*?", "??", "+ and ??", "+? and ?"
 };
 
Index: ruby.c
===================================================================
RCS file: /src/ruby/ruby.c,v
retrieving revision 1.113
diff -u -r1.113 ruby.c
--- ruby.c	1 Feb 2006 13:27:10 -0000	1.113
+++ ruby.c	25 Apr 2006 11:07:45 -0000
@@ -73,7 +73,7 @@
     /* This message really ought to be max 23 lines.
      * Removed -h because the user already knows that option. Others? */
 
-    static char *usage_msg[] = {
+    static const char *usage_msg[] = {
 "-0[octal]       specify record separator (\\0, if no argument)",
 "-a              autosplit mode with -n or -p (splits $_ into $F)",
 "-c              check syntax only",
@@ -99,7 +99,7 @@
 "--version       print the version",
 NULL
 };
-    char **p = usage_msg;
+    const char **p = usage_msg;
 
     printf("Usage: %s [switches] [--] [programfile] [arguments]\n", name);
     while (*p)
Index: ruby.h
===================================================================
RCS file: /src/ruby/ruby.h,v
retrieving revision 1.134
diff -u -r1.134 ruby.h
--- ruby.h	2 Mar 2006 05:22:30 -0000	1.134
+++ ruby.h	25 Apr 2006 11:07:45 -0000
@@ -544,7 +544,7 @@
 void rb_gc_unregister_address(VALUE*);
 
 ID rb_intern(const char*);
-char *rb_id2name(ID);
+const char *rb_id2name(ID);
 ID rb_to_id(VALUE);
 
 char *rb_class2name(VALUE);
Index: signal.c
===================================================================
RCS file: /src/ruby/signal.c,v
retrieving revision 1.72
diff -u -r1.72 signal.c
--- signal.c	9 Jan 2006 22:32:55 -0000	1.72
+++ signal.c	25 Apr 2006 11:07:45 -0000
@@ -226,7 +226,7 @@
     int negative = 0;
     int sig;
     int i;
-    char *s;
+    const char *s;
 
     rb_secure(2);
     if (argc < 2)
@@ -564,7 +564,7 @@
     sighandler_t func, oldfunc;
     VALUE command, oldcmd;
     int sig = -1;
-    char *s;
+    const char *s;
 
     func = sighandler;
     if (NIL_P(arg->cmd)) {
Index: struct.c
===================================================================
RCS file: /src/ruby/struct.c,v
retrieving revision 1.74
diff -u -r1.74 struct.c
--- struct.c	5 Feb 2006 14:40:01 -0000	1.74
+++ struct.c	25 Apr 2006 11:07:45 -0000
@@ -451,7 +451,7 @@
     for (i=0; i<RSTRUCT_LEN(s); i++) {
 	VALUE slot;
 	ID id;
-	char *p;
+	const char *p;
 
 	if (i > 0) {
 	    rb_str_cat2(str, ", ");
Index: time.c
===================================================================
RCS file: /src/ruby/time.c,v
retrieving revision 1.112
diff -u -r1.112 time.c
--- time.c	1 Mar 2006 10:06:03 -0000	1.112
+++ time.c	25 Apr 2006 11:07:45 -0000
@@ -157,7 +157,7 @@
 time_timeval(VALUE time, int interval)
 {
     struct timeval t;
-    char *tstr = interval ? "time interval" : "time";
+    const char *tstr = interval ? "time interval" : "time";
 
 #ifndef NEGATIVE_TIME_T
     interval = 1;
Index: variable.c
===================================================================
RCS file: /src/ruby/variable.c,v
retrieving revision 1.135
diff -u -r1.135 variable.c
--- variable.c	20 Feb 2006 01:07:40 -0000	1.135
+++ variable.c	25 Apr 2006 11:07:45 -0000
@@ -186,7 +186,7 @@
 	return path;
     }
     else {
-	char *s = "Class";
+	const char *s = "Class";
 
 	if (TYPE(klass) == T_MODULE) {
 	    if (rb_obj_class(klass) == rb_cModule) {
@@ -711,7 +711,7 @@
 {
     VALUE ary = rb_ary_new();
     char buf[4];
-    char *s = "&`'+123456789";
+    const char *s = "&`'+123456789";
 
     st_foreach_safe(rb_global_tbl, gvar_i, ary);
     if (!NIL_P(rb_backref_get())) {
@@ -1510,7 +1510,7 @@
 static void
 mod_av_set(VALUE klass, ID id, VALUE val, int isconst)
 {
-    char *dest = isconst ? "constant" : "class variable";
+    const char *dest = isconst ? "constant" : "class variable";
 
     if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4)
 	rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest);
Index: ext/bigdecimal/bigdecimal.c
===================================================================
RCS file: /src/ruby/ext/bigdecimal/bigdecimal.c,v
retrieving revision 1.45
diff -u -r1.45 bigdecimal.c
--- ext/bigdecimal/bigdecimal.c	16 Sep 2005 07:22:49 -0000	1.45
+++ ext/bigdecimal/bigdecimal.c	25 Apr 2006 11:07:45 -0000
@@ -302,7 +302,7 @@
 }
 
 VP_EXPORT Real *
-VpCreateRbObject(U_LONG mx, char *str)
+VpCreateRbObject(U_LONG mx, const char *str)
 {
     Real *pv = VpAlloc(mx,str);
     pv->obj = (VALUE)Data_Wrap_Struct(rb_cBigDecimal, 0, BigDecimal_delete, pv);
@@ -1578,7 +1578,7 @@
 }
 
 VP_EXPORT int
-VpException(unsigned short f,char *str,int always)
+VpException(unsigned short f, const char *str,int always)
 {
     VALUE exc;
     int   fatal=0;
@@ -1720,7 +1720,7 @@
  *    returns number of chars needed to represent vp in specified format.
  */
 VP_EXPORT U_LONG
-VpNumOfChars(Real *vp,char *pszFmt)
+VpNumOfChars(Real *vp,const char *pszFmt)
 {
     S_INT  ex;
     U_LONG nc;
@@ -1873,7 +1873,7 @@
  *   NULL be returned if memory allocation is failed,or any error.
  */
 VP_EXPORT Real *
-VpAlloc(U_LONG mx, char *szVal)
+VpAlloc(U_LONG mx, const char *szVal)
 {
     U_LONG i, ni, ipn, ipf, nf, ipe, ne, nalloc;
     char v,*psz;
@@ -3277,7 +3277,7 @@
  *   ne   ... number of characters in exp_chr[],not including '+/-'.
  */
 VP_EXPORT int
-VpCtoV(Real *a, char *int_chr, U_LONG ni, char *frac, U_LONG nf, char *exp_chr, U_LONG ne)
+VpCtoV(Real *a, const char *int_chr, U_LONG ni, const char *frac, U_LONG nf, const char *exp_chr, U_LONG ne)
 {
     U_LONG i, j, ind_a, ma, mi, me;
     U_LONG loc;
Index: ext/bigdecimal/bigdecimal.h
===================================================================
RCS file: /src/ruby/ext/bigdecimal/bigdecimal.h,v
retrieving revision 1.14
diff -u -r1.14 bigdecimal.h
--- ext/bigdecimal/bigdecimal.h	24 Sep 2003 22:55:33 -0000	1.14
+++ ext/bigdecimal/bigdecimal.h	25 Apr 2006 11:07:45 -0000
@@ -105,7 +105,7 @@
 VP_EXPORT  Real *
 VpNewRbClass(U_LONG mx,char *str,VALUE klass);
 
-VP_EXPORT  Real *VpCreateRbObject(U_LONG mx,char *str);
+VP_EXPORT  Real *VpCreateRbObject(U_LONG mx,const char *str);
 
 VP_EXPORT U_LONG VpBaseFig(void);
 VP_EXPORT U_LONG VpDblFig(void);
@@ -126,13 +126,13 @@
 VP_EXPORT unsigned long VpGetRoundMode(void);
 VP_EXPORT unsigned long VpSetRoundMode(unsigned long n);
 
-VP_EXPORT int VpException(unsigned short f,char *str,int always);
+VP_EXPORT int VpException(unsigned short f,const char *str,int always);
 VP_EXPORT int VpIsNegDoubleZero(double v);
-VP_EXPORT U_LONG VpNumOfChars(Real *vp,char *pszFmt);
+VP_EXPORT U_LONG VpNumOfChars(Real *vp,const char *pszFmt);
 VP_EXPORT U_LONG VpInit(U_LONG BaseVal);
 VP_EXPORT void *VpMemAlloc(U_LONG mb);
 VP_EXPORT void VpFree(Real *pv);
-VP_EXPORT Real *VpAlloc(U_LONG mx, char *szVal);
+VP_EXPORT Real *VpAlloc(U_LONG mx, const char *szVal);
 VP_EXPORT int VpAsgn(Real *c,Real *a,int isw);
 VP_EXPORT int VpAddSub(Real *c,Real *a,Real *b,int operation);
 VP_EXPORT int VpMult(Real *c,Real *a,Real *b);
@@ -143,7 +143,7 @@
 VP_EXPORT int VpToSpecialString(Real *a,char *psz,int fPlus);
 VP_EXPORT void VpToString(Real *a,char *psz,int fFmt,int fPlus);
 VP_EXPORT void VpToFString(Real *a,char *psz,int fFmt,int fPlus);
-VP_EXPORT int VpCtoV(Real *a,char *int_chr,U_LONG ni,char *frac,U_LONG nf,char *exp_chr,U_LONG ne);
+VP_EXPORT int VpCtoV(Real *a,const char *int_chr,U_LONG ni,const char *frac,U_LONG nf,const char *exp_chr,U_LONG ne);
 VP_EXPORT int VpVtoD(double *d,S_LONG *e,Real *m);
 VP_EXPORT void VpDtoV(Real *m,double d);
 VP_EXPORT void VpItoV(Real *m,S_INT ival);
Index: ext/iconv/iconv.c
===================================================================
RCS file: /src/ruby/ext/iconv/iconv.c,v
retrieving revision 1.29
diff -u -r1.29 iconv.c
--- ext/iconv/iconv.c	3 Feb 2006 09:15:39 -0000	1.29
+++ ext/iconv/iconv.c	25 Apr 2006 11:07:45 -0000
@@ -166,7 +166,7 @@
 	}
 	if (cd == (iconv_t)-1) {
 	    int inval = errno == EINVAL;
-	    char *s = inval ? "invalid encoding " : "iconv";
+	    const char *s = inval ? "invalid encoding " : "iconv";
 	    volatile VALUE msg = rb_str_new(0, strlen(s) + RSTRING(to)->len +
 					    RSTRING(from)->len + 8);
 
Index: ext/openssl/ossl_asn1.c
===================================================================
RCS file: /src/ruby/ext/openssl/ossl_asn1.c,v
retrieving revision 1.13
diff -u -r1.13 ossl_asn1.c
--- ext/openssl/ossl_asn1.c	3 Feb 2006 09:15:38 -0000	1.13
+++ ext/openssl/ossl_asn1.c	25 Apr 2006 11:07:45 -0000
@@ -445,7 +445,7 @@
 /********/
 
 typedef struct {
-    char *name;
+    const char *name;
     VALUE *klass;
 } ossl_asn1_info_t;
 
Index: ext/openssl/ossl_pkcs7.c
===================================================================
RCS file: /src/ruby/ext/openssl/ossl_pkcs7.c,v
retrieving revision 1.9
diff -u -r1.9 ossl_pkcs7.c
--- ext/openssl/ossl_pkcs7.c	3 Feb 2006 09:15:38 -0000	1.9
+++ ext/openssl/ossl_pkcs7.c	25 Apr 2006 11:07:45 -0000
@@ -335,7 +335,7 @@
 ossl_pkcs7_sym2typeid(VALUE sym)
 {
     int i, ret = Qnil;
-    char *s;
+    const char *s;
 
     static struct {
         const char *name;
Index: ext/openssl/ossl_ssl.c
===================================================================
RCS file: /src/ruby/ext/openssl/ossl_ssl.c,v
retrieving revision 1.30
diff -u -r1.30 ossl_ssl.c
--- ext/openssl/ossl_ssl.c	15 Mar 2006 07:41:33 -0000	1.30
+++ ext/openssl/ossl_ssl.c	25 Apr 2006 11:07:45 -0000
@@ -62,7 +62,7 @@
 #define ossl_sslctx_get_tmp_dh_cb(o)     rb_iv_get((o),"@tmp_dh_callback")
 #define ossl_sslctx_get_sess_id_ctx(o)   rb_iv_get((o),"@session_id_context")
 
-static char *ossl_sslctx_attrs[] = {
+static const char *ossl_sslctx_attrs[] = {
     "cert", "key", "client_ca", "ca_file", "ca_path",
     "timeout", "verify_mode", "verify_depth",
     "verify_callback", "options", "cert_store", "extra_chain_cert",
@@ -83,8 +83,8 @@
 #define ossl_ssl_set_key(o,v)        rb_iv_set((o),"@key",(v))
 #define ossl_ssl_set_tmp_dh(o,v)     rb_iv_set((o),"@tmp_dh",(v))
 
-static char *ossl_ssl_attr_readers[] = { "io", "context", };
-static char *ossl_ssl_attrs[] = { "sync_close", };
+static const char *ossl_ssl_attr_readers[] = { "io", "context", };
+static const char *ossl_ssl_attrs[] = { "sync_close", };
 
 /*
  * SSLContext class
@@ -144,7 +144,7 @@
     SSL_METHOD *method = NULL;
     SSL_CTX *ctx;
     int i;
-    char *s;
+    const char *s;
 
     for(i = 0; i < numberof(ossl_sslctx_attrs); i++){
 	char buf[32];
Index: ext/syck/emitter.c
===================================================================
RCS file: /src/ruby/ext/syck/emitter.c,v
retrieving revision 1.16
diff -u -r1.16 emitter.c
--- ext/syck/emitter.c	2 Feb 2006 15:02:49 -0000	1.16
+++ ext/syck/emitter.c	25 Apr 2006 11:07:45 -0000
@@ -282,7 +282,7 @@
  * Raw write to the emitter buffer.
  */
 void
-syck_emitter_write( SyckEmitter *e, char *str, long len )
+syck_emitter_write( SyckEmitter *e, const char *str, long len )
 {
     long at;
     ASSERT( str != NULL )
@@ -438,7 +438,7 @@
  * and the implicit tag which would be assigned to this node.  If a tag is
  * required, write the tag.
  */
-void syck_emit_tag( SyckEmitter *e, char *tag, char *ignore )
+void syck_emit_tag( SyckEmitter *e, const char *tag, const char *ignore )
 {
     SyckLevel *lvl;
     if ( tag == NULL ) return;
@@ -457,7 +457,7 @@
             int skip = 4 + strlen( YAML_DOMAIN ) + 1;
             syck_emitter_write( e, tag + skip, taglen - skip );
         } else {
-            char *subd = tag + 4;
+            const char *subd = tag + 4;
             while ( *subd != ':' && *subd != '\0' ) subd++;
             if ( *subd == ':' ) {
                 if ( subd - tag > ( strlen( YAML_DOMAIN ) + 5 ) &&
@@ -1221,7 +1221,7 @@
         if ( ! st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) )
         {
             int idx = 0;
-            char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
+            const char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
 
             /*
              * Second time hitting this object, let's give it an anchor
Index: ext/syck/handler.c
===================================================================
RCS file: /src/ruby/ext/syck/handler.c,v
retrieving revision 1.14
diff -u -r1.14 handler.c
--- ext/syck/handler.c	20 Sep 2005 06:50:19 -0000	1.14
+++ ext/syck/handler.c	25 Apr 2006 11:07:45 -0000
@@ -155,7 +155,7 @@
 }
 
 char *
-syck_taguri( char *domain, char *type_id, int type_len )
+syck_taguri( const char *domain, const char *type_id, int type_len )
 {
     char *uri = S_ALLOC_N( char, strlen( domain ) + type_len + 14 );
     uri[0] = '\0';
Index: ext/syck/implicit.c
===================================================================
RCS file: /src/ruby/ext/syck/implicit.c,v
retrieving revision 1.20
diff -u -r1.20 implicit.c
--- ext/syck/implicit.c	26 Oct 2005 00:27:35 -0000	1.20
+++ ext/syck/implicit.c	25 Apr 2006 11:07:45 -0000
@@ -1585,7 +1585,7 @@
 
 /* Remove ending fragment and compare types */
 int
-syck_tagcmp( char *tag1, char *tag2 )
+syck_tagcmp( const char *tag1, const char *tag2 )
 {
     if ( tag1 == tag2 ) return 1;
     if ( tag1 == NULL || tag2 == NULL ) return 0;
Index: ext/syck/node.c
===================================================================
RCS file: /src/ruby/ext/syck/node.c,v
retrieving revision 1.11
diff -u -r1.11 node.c
--- ext/syck/node.c	16 Sep 2005 09:37:44 -0000	1.11
+++ ext/syck/node.c	25 Apr 2006 11:07:45 -0000
@@ -100,13 +100,13 @@
 }
 
 SyckNode *
-syck_new_str( char *str, enum scalar_style style )
+syck_new_str( const char *str, enum scalar_style style )
 {
     return syck_new_str2( str, strlen( str ), style );
 }
 
 SyckNode *
-syck_new_str2( char *str, long len, enum scalar_style style )
+syck_new_str2( const char *str, long len, enum scalar_style style )
 {
     SyckNode *n;
 
Index: ext/syck/syck.c
===================================================================
RCS file: /src/ruby/ext/syck/syck.c,v
retrieving revision 1.26
diff -u -r1.26 syck.c
--- ext/syck/syck.c	3 Feb 2006 06:10:21 -0000	1.26
+++ ext/syck/syck.c	25 Apr 2006 11:07:45 -0000
@@ -32,7 +32,7 @@
  * Allocates and copies a string
  */
 char *
-syck_strndup( char *buf, long len )
+syck_strndup( const char *buf, long len )
 {
     char *new = S_ALLOC_N( char, len + 1 );
     S_MEMZERO( new, char, len + 1 );
Index: ext/syck/syck.h
===================================================================
RCS file: /src/ruby/ext/syck/syck.h,v
retrieving revision 1.30
diff -u -r1.30 syck.h
--- ext/syck/syck.h	19 Dec 2005 14:13:27 -0000	1.30
+++ ext/syck/syck.h	25 Apr 2006 11:07:45 -0000
@@ -346,8 +346,8 @@
 SyckNode *syck_hdlr_get_anchor( SyckParser *, char * );
 void syck_add_transfer( char *, SyckNode *, int );
 char *syck_xprivate( char *, int );
-char *syck_taguri( char *, char *, int );
-int syck_tagcmp( char *, char * );
+char *syck_taguri( const char *, const char *, int );
+int syck_tagcmp( const char *, const char * );
 int syck_add_sym( SyckParser *, char * );
 int syck_lookup_sym( SyckParser *, SYMID, char ** );
 int syck_try_implicit( SyckNode * );
@@ -358,7 +358,7 @@
 /*
  * API prototypes
  */
-char *syck_strndup( char *, long );
+char *syck_strndup( const char *, long );
 long syck_io_file_read( char *, SyckIoFile *, long, long );
 long syck_io_str_read( char *, SyckIoStr *, long, long );
 char *syck_base64enc( char *, long );
@@ -370,7 +370,7 @@
 void syck_emitter_handler( SyckEmitter *, SyckEmitterHandler );
 void syck_free_emitter( SyckEmitter * );
 void syck_emitter_clear( SyckEmitter * );
-void syck_emitter_write( SyckEmitter *, char *, long );
+void syck_emitter_write( SyckEmitter *, const char *, long );
 void syck_emitter_escape( SyckEmitter *, char *, long );
 void syck_emitter_flush( SyckEmitter *, long );
 void syck_emit( SyckEmitter *, st_data_t );
@@ -383,7 +383,7 @@
 void syck_emit_item( SyckEmitter *, st_data_t );
 void syck_emit_map( SyckEmitter *, char *, enum map_style );
 void syck_emit_end( SyckEmitter * );
-void syck_emit_tag( SyckEmitter *, char *, char * );
+void syck_emit_tag( SyckEmitter *, const char *, const char * );
 void syck_emit_indent( SyckEmitter * );
 SyckLevel *syck_emitter_current_level( SyckEmitter * );
 SyckLevel *syck_emitter_parent_level( SyckEmitter * );
@@ -421,8 +421,8 @@
 SyckNode *syck_alloc_str();
 void syck_free_node( SyckNode * );
 void syck_free_members( SyckNode * );
-SyckNode *syck_new_str( char *, enum scalar_style );
-SyckNode *syck_new_str2( char *, long, enum scalar_style );
+SyckNode *syck_new_str( const char *, enum scalar_style );
+SyckNode *syck_new_str2( const char *, long, enum scalar_style );
 void syck_replace_str( SyckNode *, char *, enum scalar_style );
 void syck_replace_str2( SyckNode *, char *, long, enum scalar_style );
 void syck_str_blow_away_commas( SyckNode * );

In This Thread

Prev Next