Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pdf/goo/GString.cc
diff options
context:
space:
mode:
authorMartin Kretzschmar <mkretzschmar@src.gnome.org>2002-09-18 20:32:18 (GMT)
committer Martin Kretzschmar <mkretzschmar@src.gnome.org>2002-09-18 20:32:18 (GMT)
commit7aac8dc8533347e21311b15186e0af82f1b22fd6 (patch)
tree02650bb02c8a1d8468c22f50ff151885d233016b /pdf/goo/GString.cc
parentd99fb4f4acd14fcdbda968abd907547dcc7af40c (diff)
Synched with Xpdf 0.92
this adds "decryption" support testing this code after six weeks immediately gives me segfaults (image drawing) :-O must have fixed that later without knowing :-O
Diffstat (limited to 'pdf/goo/GString.cc')
-rw-r--r--pdf/goo/GString.cc35
1 files changed, 31 insertions, 4 deletions
diff --git a/pdf/goo/GString.cc b/pdf/goo/GString.cc
index 6225932..7b8f271 100644
--- a/pdf/goo/GString.cc
+++ b/pdf/goo/GString.cc
@@ -16,6 +16,7 @@
#include <stddef.h>
#include <string.h>
#include <ctype.h>
+#include "gtypes.h"
#include "GString.h"
static inline int size(int len) {
@@ -75,6 +76,32 @@ GString::GString(GString *str1, GString *str2) {
memcpy(s + n1, str2->getCString(), n2 + 1);
}
+GString *GString::fromInt(int x) {
+ char buf[24]; // enough space for 64-bit ints plus a little extra
+ GBool neg;
+ Guint y;
+ int i;
+
+ i = 24;
+ if (x == 0) {
+ buf[--i] = '0';
+ } else {
+ if ((neg = x < 0)) {
+ y = (Guint)-x;
+ } else {
+ y = (Guint)x;
+ }
+ while (i > 0 && y > 0) {
+ buf[--i] = '0' + y % 10;
+ y /= 10;
+ }
+ if (neg && i > 0) {
+ buf[--i] = '-';
+ }
+ }
+ return new GString(buf + i, 24 - i);
+}
+
GString::~GString() {
delete[] s;
}
@@ -101,7 +128,7 @@ GString *GString::append(GString *str) {
return this;
}
-GString *GString::append(char *str) {
+GString *GString::append(const char *str) {
int n = strlen(str);
resize(length + n);
@@ -110,7 +137,7 @@ GString *GString::append(char *str) {
return this;
}
-GString *GString::append(char *str, int length1) {
+GString *GString::append(const char *str, int length1) {
resize(length + length1);
memcpy(s + length, str, length1);
length += length1;
@@ -141,7 +168,7 @@ GString *GString::insert(int i, GString *str) {
return this;
}
-GString *GString::insert(int i, char *str) {
+GString *GString::insert(int i, const char *str) {
int n = strlen(str);
int j;
@@ -153,7 +180,7 @@ GString *GString::insert(int i, char *str) {
return this;
}
-GString *GString::insert(int i, char *str, int length1) {
+GString *GString::insert(int i, const char *str, int length1) {
int j;
resize(length + length1);