Ticket #8047: diffs.txt

File diffs.txt, 2.8 KB (added by SF/cccp_99, 22 years ago)

The diffs for 4 modified files

Line 
1--- gui_old.cpp Wed Sep 11 06:28:32 2002
2+++ gui_new.cpp Sun Sep 15 01:21:38 2002
3@@ -287,7 +287,6 @@
4 {0, 0, 0, 0, 0, 0, 0, 0, 0}
5 };
6
7-
8 void Gui::draw(int start, int end)
9 {
10 int i;
11@@ -419,8 +418,15 @@
12 break;
13 case GUI_RESTEXT:
14 s = queryString(w->_string_number, w->_id);
15- if (s)
16- strcpy(text, s);
17+ if (s) {
18+ int t = resStrLen(s);
19+ if (t >= 500) { // probably won't happen, but just in case...
20+ warning("Resource string is too long, truncating");
21+ t = 498;
22+ text[499] = '\0';
23+ }
24+ memcpy(text, s, t+1);
25+ }
26 break;
27 case GUI_VARTEXT:
28 sprintf(text, "%s %d", string_map_table_custom[w->_string_number],
29@@ -907,8 +913,6 @@
30
31 const char *Gui::queryString(int stringno, int id)
32 {
33- if ((stringno == 1) && (_s->_gameId == GID_MONKEY2)) return "How may I serve you?"; // FIXME (MI2 data file is wrong)
34-
35 static char namebuf[64];
36 char *result;
37 int string;
38
39
40
41--- str_old.cpp Mon Sep 09 04:42:24 2002
42+++ str_new.cpp Sun Sep 15 01:03:16 2002
43@@ -20,15 +20,15 @@
44
45 #include "stdafx.h"
46 #include "str.h"
47-
48+#include "util.h"
49
50 namespace ScummVM {
51
52 String::String(const char *str)
53 {
54 _refCount = new int(1);
55- if (str) {
56- _capacity = _len = strlen(str);
57+ if (str) {
58+ _capacity = _len = resStrLen(str);
59 _str = (char *)calloc(1, _capacity+1);
60 memcpy(_str, str, _len+1);
61 } else {
62@@ -41,8 +41,8 @@
63 {
64 printf("String::String(const ConstString &str)\n");
65 _refCount = new int(1);
66- if (str._str) {
67- _capacity = _len = strlen(str._str);
68+ if (str._str) {
69+ _capacity = _len = resStrLen(str._str);
70 _str = (char *)calloc(1, _capacity+1);
71 memcpy(_str, str._str, _len+1);
72 } else {
73@@ -77,8 +77,8 @@
74 }
75
76 String& String::operator =(const char* str)
77-{
78- int len = strlen(str);
79+{
80+ int len = resStrLen(str);
81 if (len > 0) {
82 ensureCapacity(len, false);
83
84@@ -111,7 +111,7 @@
85
86 String& String::operator +=(const char* str)
87 {
88- int len = strlen(str);
89+ int len = resStrLen(str);
90 if (len > 0) {
91 ensureCapacity(_len + len, true);
92
93
94
95--- util_old.cpp Sat Sep 07 18:08:12 2002
96+++ util_new.cpp Sun Sep 15 01:09:42 2002
97@@ -120,3 +120,23 @@
98 printf(" ");
99 printf("|\n");
100 }
101+
102+// Resource string length, supports special chars starting with FF
103+int resStrLen(const char *src)
104+{
105+ int num = 0;
106+ byte chr;
107+ while ((chr = *src++) != 0) {
108+ num++;
109+ if (chr == 255) {
110+ chr = *src++;
111+ num++;
112+
113+ if (chr != 1 && chr != 2 && chr != 3 && chr != 8) {
114+ src += 2;
115+ num += 2;
116+ }
117+ }
118+ }
119+ return num;
120+}
121
122
123
124--- util_old.h Sat Sep 07 18:08:12 2002
125+++ util_new.h Sun Sep 15 00:41:28 2002
126@@ -48,4 +48,7 @@
127 */
128 void hexdump(const byte * data, int len);
129
130+// Resource string length
131+int resStrLen(const char *src);
132+
133 #endif