comparison liboctave/oct-time.cc @ 13982:6cdfbe90e2ab

remove kluge for apparent libc bug that is really a valgrind bug * oct-time.cc (octave_strptime::init): Simply pass str.c_str () to strptime.
author John W. Eaton <jwe@octave.org>
date Sat, 03 Dec 2011 03:30:37 -0500
parents 16158606112d
children 1126c2907878
comparison
equal deleted inserted replaced
13981:5f8bc2f145f5 13982:6cdfbe90e2ab
265 #if defined (HAVE_STRUCT_TM_TM_ZONE) 265 #if defined (HAVE_STRUCT_TM_TM_ZONE)
266 char *ps = strsave (""); 266 char *ps = strsave ("");
267 t.tm_zone = ps; 267 t.tm_zone = ps;
268 #endif 268 #endif
269 269
270 // FIXME -- the following kluge avoids a memory access problem with 270 const char *p = str.c_str ();
271 // strptime in some versions of GNU libc.
272 // http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=650714
273
274 const char *pstr = str.c_str ();
275 size_t len = str.length ();
276 const int extra = 128;
277 OCTAVE_LOCAL_BUFFER (char, p, len + extra);
278 char *pp = p;
279 for (size_t i = 0; i < len; i++)
280 *pp++ = *pstr++;
281 for (size_t i = len; i < extra; i++)
282 *pp++ = 0;
283 271
284 char *q = gnulib::strptime (p, fmt.c_str (), &t); 272 char *q = gnulib::strptime (p, fmt.c_str (), &t);
285 273
286 // Fill in wday and yday, but only if mday is valid and the mon and year 274 // Fill in wday and yday, but only if mday is valid and the mon and year
287 // are filled in, avoiding issues with mktime and invalid dates. 275 // are filled in, avoiding issues with mktime and invalid dates.