Branch: Tag:

2003-08-04

2003-08-04 16:14:21 by Martin Stjernholm <mast@lysator.liu.se>

Some code cleanup using VSNPRINTF.

Rev: src/cpp.c:1.120
Rev: src/encode.c:1.195
Rev: src/error.c:1.113
Rev: src/interpret.c:1.316
Rev: src/program.c:1.513

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: error.c,v 1.112 2003/07/30 19:05:37 mast Exp $ + || $Id: error.c,v 1.113 2003/08/04 16:14:21 mast Exp $   */      #define NO_PIKE_SHORTHAND
23:   #include "threads.h"   #include "gc.h"    - RCSID("$Id: error.c,v 1.112 2003/07/30 19:05:37 mast Exp $"); + RCSID("$Id: error.c,v 1.113 2003/08/04 16:14:21 mast Exp $");      #undef ATTRIBUTE   #define ATTRIBUTE(X)
211:    }       in_error=buf; +  VSNPRINTF (buf, sizeof (buf), fmt, args);    - #ifdef HAVE_VSNPRINTF -  vsnprintf(buf, 4090, fmt, args); - #else /* !HAVE_VSNPRINTF */ -  VSPRINTF(buf, fmt, args); - #endif /* HAVE_VSNPRINTF */ -  +     if(!Pike_interpreter.recoveries)    {   #ifdef PIKE_DEBUG
231:    exit(99);    }    -  if((size_t)strlen(buf) >= (size_t)sizeof(buf)) -  Pike_fatal("Buffer overflow in error()\n"); -  +     low_error(buf);   }   
666:    char buf[8192];    int i;    - #ifdef HAVE_VSNPRINTF -  vsnprintf(buf, sizeof(buf)-1, fmt, foo); - #else /* !HAVE_VSNPRINTF */ -  /* Sentinel that will be overwritten on buffer overflow. */ -  buf[sizeof(buf)-1] = '\0'; +  VSNPRINTF(buf, sizeof(buf), fmt, foo);    -  VSPRINTF(buf, fmt, foo); -  -  if(buf[sizeof(buf)-1]) -  Pike_fatal("Buffer overflow in error()\n"); - #endif /* HAVE_VSNPRINTF */ -  +     if(in_error)    {    const char *tmp=in_error;