From bc6d3e81e83de83871b03856d55eb71c6a5a0a4c Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 19 Oct 2005 12:23:42 +0000 Subject: made "!progname" fully BSD-compliant; added property "programname" --- stringbuf.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'stringbuf.c') diff --git a/stringbuf.c b/stringbuf.c index ea008e77..5aa94fc4 100755 --- a/stringbuf.c +++ b/stringbuf.c @@ -236,10 +236,29 @@ rsRetVal rsCStrSetSzStr(rsCStrObj *pThis, char *pszNew) return RS_RET_OK; } +/* Converts the CStr object to a classical sz string and returns that. + * Same restrictions as in rsCStrGetSzStr() applies (see there!). This + * function here guarantees that a valid string is returned, even if + * the CStr object currently holds a NULL pointer string buffer. If so, + * "" is returned. + * rgerhards 2005-10-19 + */ +char* rsCStrGetSzStrNoNULL(rsCStrObj *pThis) +{ + rsCHECKVALIDOBJECT(pThis, OIDrsCStr); + if(pThis->pBuf == NULL) + return ""; + else + return rsCStrGetSzStr(pThis); +} + /* Converts the CStr object to a classical zero-terminated C string * and returns that string. The caller must not free it and must not * destroy the CStr object as long as the ascii string is used. + * This function may return NULL, if the string is currently NULL. This + * is a feature, not a bug. If you need non-NULL in any case, use + * rsCStrGetSzStrNoNULL() instead. * rgerhards, 2005-09-15 */ char* rsCStrGetSzStr(rsCStrObj *pThis) -- cgit