From 6a9a2376b6631a8ac25edf6a2843826f1dd366be Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 13 Jul 2004 15:59:49 +0000 Subject: [PATCH] better handling of NULL input strings --- doc/gl2ps.tex | 4 ++-- gl2ps.c | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/doc/gl2ps.tex b/doc/gl2ps.tex index 7fa78c4..f65dbcb 100644 --- a/doc/gl2ps.tex +++ b/doc/gl2ps.tex @@ -1,4 +1,4 @@ -% $Id: gl2ps.tex,v 1.173 2004-07-11 22:30:25 geuzaine Exp $ +% $Id: gl2ps.tex,v 1.174 2004-07-13 15:59:49 geuzaine Exp $ % % GL2PS, an OpenGL to PostScript Printing Library % Copyright (C) 1999-2004 Christophe Geuzaine <geuz@geuz.org> @@ -572,7 +572,7 @@ while( state == GL2PS_OVERFLOW ){ GL2PS_SIMPLE_LINE_OFFSET | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT, GL_RGBA, 0, NULL, 0, 0, 0, buffsize, - fp, NULL ); + fp, "MyFileName" ); draw(); state = gl2psEndPage(); } diff --git a/gl2ps.c b/gl2ps.c index 09902b4..969346c 100644 --- a/gl2ps.c +++ b/gl2ps.c @@ -1,4 +1,4 @@ -/* $Id: gl2ps.c,v 1.176 2004-07-12 17:49:56 geuzaine Exp $ */ +/* $Id: gl2ps.c,v 1.177 2004-07-13 15:59:49 geuzaine Exp $ */ /* * GL2PS, an OpenGL to PostScript Printing Library * Copyright (C) 1999-2004 Christophe Geuzaine <geuz@geuz.org> @@ -4372,19 +4372,32 @@ GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, rewind(gl2ps->stream); } - if(!title) - title = ""; - if(!producer) - producer = ""; - if(!filename) - filename = ""; - - gl2ps->title = (char*)gl2psMalloc((strlen(title)+1)*sizeof(char)); - strcpy(gl2ps->title, title); - gl2ps->producer = (char*)gl2psMalloc((strlen(producer)+1)*sizeof(char)); - strcpy(gl2ps->producer, producer); - gl2ps->filename = (char*)gl2psMalloc((strlen(filename)+1)*sizeof(char)); - strcpy(gl2ps->filename, filename); + if(!title){ + gl2ps->title = (char*)gl2psMalloc(sizeof(char)); + gl2ps->title[0] = '\0'; + } + else{ + gl2ps->title = (char*)gl2psMalloc((strlen(title)+1)*sizeof(char)); + strcpy(gl2ps->title, title); + } + + if(!producer){ + gl2ps->producer = (char*)gl2psMalloc(sizeof(char)); + gl2ps->producer[0] = '\0'; + } + else{ + gl2ps->producer = (char*)gl2psMalloc((strlen(producer)+1)*sizeof(char)); + strcpy(gl2ps->producer, producer); + } + + if(!filename){ + gl2ps->filename = (char*)gl2psMalloc(sizeof(char)); + gl2ps->filename[0] = '\0'; + } + else{ + gl2ps->filename = (char*)gl2psMalloc((strlen(filename)+1)*sizeof(char)); + strcpy(gl2ps->filename, filename); + } switch(gl2ps->format){ case GL2PS_TEX : -- GitLab