[sword-cvs] sword/src/utilfuns swbuf.cpp,1.15,1.16
sword@www.crosswire.org
sword@www.crosswire.org
Fri, 2 Apr 2004 16:54:47 -0700
Update of /cvs/core/sword/src/utilfuns
In directory www:/tmp/cvs-serv28564/src/utilfuns
Modified Files:
swbuf.cpp
Log Message:
Added SWBuf method setFormatted(). Altered all remaining uses of char[127] for file names to use SWBufs.
Index: swbuf.cpp
===================================================================
RCS file: /cvs/core/sword/src/utilfuns/swbuf.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- swbuf.cpp 29 Feb 2004 23:26:17 -0000 1.15
+++ swbuf.cpp 2 Apr 2004 23:54:44 -0000 1.16
@@ -119,6 +119,22 @@
end = buf + (len-1);
}
+/******************************************************************************
+* SWBuf::setFormatted - sets this buf to a formatted string
+* WARNING: This function can only write at most
+* JUNKBUFSIZE to the string per call.
+*/
+void SWBuf::setFormatted(const char *format, ...) {
+ va_list argptr;
+
+ va_start(argptr, format);
+ int len = vsprintf(junkBuf, format, argptr)+1;
+ va_end(argptr);
+ assureSize(len);
+ va_start(argptr, format);
+ end = vsprintf(buf, format, argptr) + buf;
+ va_end(argptr);
+}
/******************************************************************************
* SWBuf::append - appends a value to the current value of this SWBuf
@@ -130,7 +146,6 @@
end += (len-1);
*end = 0;
}
-
/******************************************************************************
* SWBuf::setSize - Size this buffer to a specific length