[poppler] Branch 'xpdf304merge' - goo/GooString.cc goo/GooString.h
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Fri Jun 6 10:33:49 PDT 2014
goo/GooString.cc | 34 ++++++++++++++++++++++------------
goo/GooString.h | 12 ++++++------
2 files changed, 28 insertions(+), 18 deletions(-)
New commits:
commit e94ff24d1393487547ea835ff5fbd8a68bf574c3
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Fri Jun 6 19:32:40 2014 +0200
xpdf304: Handle NULL strings passed as arguments of GooString::appendfv
diff --git a/goo/GooString.cc b/goo/GooString.cc
index 58d980a..dc9ace8 100644
--- a/goo/GooString.cc
+++ b/goo/GooString.cc
@@ -253,7 +253,7 @@ GooString::GooString(GooString *str1, GooString *str2) {
GooString *GooString::fromInt(int x) {
char buf[24]; // enough space for 64-bit ints plus a little extra
- char *p;
+ const char *p;
int len;
formatInt(x, buf, sizeof(buf), gFalse, 0, 10, &p, &len);
return new GooString(p, len);
@@ -330,7 +330,7 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) {
char buf[65];
int len, i;
const char *p0, *p1;
- char *str;
+ const char *str;
argsLen = 0;
argsSize = 8;
@@ -599,13 +599,23 @@ GooString *GooString::appendfv(const char *fmt, va_list argList) {
reverseAlign = !reverseAlign;
break;
case fmtString:
- str = arg.s;
- len = strlen(str);
+ if (arg.s) {
+ str = arg.s;
+ len = strlen(str);
+ } else {
+ str = "(null)";
+ len = 6;
+ }
reverseAlign = !reverseAlign;
break;
case fmtGooString:
- str = arg.gs->getCString();
- len = arg.gs->getLength();
+ if (arg.gs) {
+ str = arg.gs->getCString();
+ len = arg.gs->getLength();
+ } else {
+ str = "(null)";
+ len = 6;
+ }
reverseAlign = !reverseAlign;
break;
case fmtSpace:
@@ -653,11 +663,11 @@ static const char upperCaseDigits[17] = "0123456789ABCDEF";
#ifdef LLONG_MAX
void GooString::formatInt(long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
- char **p, int *len, GBool upperCase) {
+ const char **p, int *len, GBool upperCase) {
#else
void GooString::formatInt(long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
- char **p, int *len, GBool upperCase) {
+ const char **p, int *len, GBool upperCase) {
#endif
const char *vals = upperCase ? upperCaseDigits : lowerCaseDigits;
GBool neg;
@@ -698,11 +708,11 @@ void GooString::formatInt(long x, char *buf, int bufSize,
#ifdef ULLONG_MAX
void GooString::formatUInt(unsigned long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
- char **p, int *len, GBool upperCase) {
+ const char **p, int *len, GBool upperCase) {
#else
void GooString::formatUInt(Gulong x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
- char **p, int *len, GBool upperCase) {
+ const char **p, int *len, GBool upperCase) {
#endif
const char *vals = upperCase ? upperCaseDigits : lowerCaseDigits;
int i, j;
@@ -726,7 +736,7 @@ void GooString::formatUInt(Gulong x, char *buf, int bufSize,
}
void GooString::formatDouble(double x, char *buf, int bufSize, int prec,
- GBool trim, char **p, int *len) {
+ GBool trim, const char **p, int *len) {
GBool neg, started;
double x2;
int d, i, j;
@@ -765,7 +775,7 @@ void GooString::formatDouble(double x, char *buf, int bufSize, int prec,
}
void GooString::formatDoubleSmallAware(double x, char *buf, int bufSize, int prec,
- GBool trim, char **p, int *len)
+ GBool trim, const char **p, int *len)
{
double absX = fabs(x);
if (absX >= 0.1) {
diff --git a/goo/GooString.h b/goo/GooString.h
index 5932be9..72df4a8 100644
--- a/goo/GooString.h
+++ b/goo/GooString.h
@@ -185,25 +185,25 @@ private:
#ifdef LLONG_MAX
static void formatInt(long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
- char **p, int *len, GBool upperCase = gFalse);
+ const char **p, int *len, GBool upperCase = gFalse);
#else
static void formatInt(long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
- char **p, int *len, GBool upperCase = gFalse);
+ const char **p, int *len, GBool upperCase = gFalse);
#endif
#ifdef ULLONG_MAX
static void formatUInt(unsigned long long x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
- char **p, int *len, GBool upperCase = gFalse);
+ const char **p, int *len, GBool upperCase = gFalse);
#else
static void formatUInt(Gulong x, char *buf, int bufSize,
GBool zeroFill, int width, int base,
- char **p, int *len, GBool upperCase = gFalse);
+ const char **p, int *len, GBool upperCase = gFalse);
#endif
static void formatDouble(double x, char *buf, int bufSize, int prec,
- GBool trim, char **p, int *len);
+ GBool trim, const char **p, int *len);
static void formatDoubleSmallAware(double x, char *buf, int bufSize, int prec,
- GBool trim, char **p, int *len);
+ GBool trim, const char **p, int *len);
};
#endif
More information about the poppler
mailing list