aboutsummaryrefslogtreecommitdiff
path: root/src/scintilla_backports/6442_3e3bfe29a819.patch
blob: acc6dbae9e9ea9bd5c66790eda4107d193127c72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# HG changeset patch
# User Neil <nyamatongwe@gmail.com>
# Date 1516950278 -39600
# Node ID 3e3bfe29a819c1f7a1761096ec54e9b6ee446a68
# Parent  92c8f0f1b3e64900cbb868a56936898693b9cfcc
Extend SplitVector to allow more than 2 billion elements on 64-bit systems.

diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/CellBuffer.cxx
--- a/src/CellBuffer.cxx	Fri Jan 26 11:12:10 2018 +1100
+++ b/src/CellBuffer.cxx	Fri Jan 26 18:04:38 2018 +1100
@@ -394,7 +394,7 @@
 }

 Sci::Position CellBuffer::GapPosition() const {
-	return substance.GapPosition();
+	return static_cast<Sci::Position>(substance.GapPosition());
 }

 // The char* returned is to an allocation owned by the undo history
@@ -457,7 +457,7 @@
 }

 Sci::Position CellBuffer::Length() const {
-	return substance.Length();
+	return static_cast<Sci::Position>(substance.Length());
 }

 void CellBuffer::Allocate(Sci::Position newSize) {
diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/Partitioning.h
--- a/src/Partitioning.h	Fri Jan 26 11:12:10 2018 +1100
+++ b/src/Partitioning.h	Fri Jan 26 18:04:38 2018 +1100
@@ -16,7 +16,7 @@

 class SplitVectorWithRangeAdd : public SplitVector<int> {
 public:
-	explicit SplitVectorWithRangeAdd(int growSize_) {
+	explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) {
 		SetGrowSize(growSize_);
 		ReAllocate(growSize_);
 	}
@@ -25,12 +25,12 @@
 	void operator=(const SplitVectorWithRangeAdd &) = delete;
 	~SplitVectorWithRangeAdd() {
 	}
-	void RangeAddDelta(int start, int end, int delta) {
+	void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, int delta) {
 		// end is 1 past end, so end-start is number of elements to change
-		int i = 0;
-		const int rangeLength = end - start;
-		int range1Length = rangeLength;
-		const int part1Left = part1Length - start;
+		ptrdiff_t i = 0;
+		const ptrdiff_t rangeLength = end - start;
+		ptrdiff_t range1Length = rangeLength;
+		const ptrdiff_t part1Left = part1Length - start;
 		if (range1Length > part1Left)
 			range1Length = part1Left;
 		while (i < range1Length) {
@@ -67,7 +67,7 @@
 		}
 		stepPartition = partitionUpTo;
 		if (stepPartition >= body->Length()-1) {
-			stepPartition = body->Length()-1;
+			stepPartition = Partitions();
 			stepLength = 0;
 		}
 	}
@@ -80,7 +80,7 @@
 		stepPartition = partitionDownTo;
 	}

-	void Allocate(int growSize) {
+	void Allocate(ptrdiff_t growSize) {
 		body = new SplitVectorWithRangeAdd(growSize);
 		stepPartition = 0;
 		stepLength = 0;
@@ -101,7 +101,7 @@
 	}

 	int Partitions() const {
-		return body->Length()-1;
+		return static_cast<int>(body->Length()-1);
 	}

 	void InsertPartition(int partition, int pos) {
@@ -132,7 +132,7 @@
 				BackStep(partitionInsert);
 				stepLength += delta;
 			} else {
-				ApplyStep(body->Length()-1);
+				ApplyStep(Partitions());
 				stepPartition = partitionInsert;
 				stepLength = delta;
 			}
@@ -168,10 +168,10 @@
 	int PartitionFromPosition(int pos) const {
 		if (body->Length() <= 1)
 			return 0;
-		if (pos >= (PositionFromPartition(body->Length()-1)))
-			return body->Length() - 1 - 1;
+		if (pos >= (PositionFromPartition(Partitions())))
+			return Partitions() - 1;
 		int lower = 0;
-		int upper = body->Length()-1;
+		int upper = Partitions();
 		do {
 			const int middle = (upper + lower + 1) / 2; 	// Round high
 			int posMiddle = body->ValueAt(middle);
diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/PerLine.cxx
--- a/src/PerLine.cxx	Fri Jan 26 11:12:10 2018 +1100
+++ b/src/PerLine.cxx	Fri Jan 26 18:04:38 2018 +1100
@@ -135,7 +135,7 @@
 Sci::Line LineMarkers::MarkerNext(Sci::Line lineStart, int mask) const {
 	if (lineStart < 0)
 		lineStart = 0;
-	const Sci::Line length = markers.Length();
+	const Sci::Line length = static_cast<Sci::Line>(markers.Length());
 	for (Sci::Line iLine = lineStart; iLine < length; iLine++) {
 		const MarkerHandleSet *onLine = markers[iLine].get();
 		if (onLine && ((onLine->MarkValue() & mask) != 0))
@@ -281,7 +281,7 @@
 }

 Sci::Line LineState::GetMaxLineState() const {
-	return lineStates.Length();
+	return static_cast<Sci::Line>(lineStates.Length());
 }

 static int NumberLines(const char *text) {
diff -r 92c8f0f1b3e6 -r 3e3bfe29a819 src/SplitVector.h
--- a/src/SplitVector.h	Fri Jan 26 11:12:10 2018 +1100
+++ b/src/SplitVector.h	Fri Jan 26 18:04:38 2018 +1100
@@ -16,15 +16,15 @@
 protected:
 	T *body;
-	int size;
-	int lengthBody;
-	int part1Length;
-	int gapLength;	/// invariant: gapLength == size - lengthBody
-	int growSize;
+	ptrdiff_t size;
+	ptrdiff_t lengthBody;
+	ptrdiff_t part1Length;
+	ptrdiff_t gapLength;	/// invariant: gapLength == size - lengthBody
+	ptrdiff_t growSize;

 	/// Move the gap to a particular position so that insertion and
 	/// deletion at that point will not require much copying and
 	/// hence be fast.
-	void GapTo(int position) {
+	void GapTo(ptrdiff_t position) {
 		if (position != part1Length) {
 			if (position < part1Length) {
 				// Moving the gap towards start so moving elements towards end
@@ -45,11 +45,11 @@

 	/// Check that there is room in the buffer for an insertion,
 	/// reallocating if more space needed.
-	void RoomFor(int insertionLength) {
+	void RoomFor(ptrdiff_t insertionLength) {
 		if (gapLength <= insertionLength) {
 			while (growSize < size / 6)
 				growSize *= 2;
 			ReAllocate(size + insertionLength + growSize);
 		}
 	}

@@ -75,18 +75,18 @@
 	~SplitVector() {
 	}

-	int GetGrowSize() const {
+	ptrdiff_t GetGrowSize() const {
 		return growSize;
 	}
-
-	void SetGrowSize(int growSize_) {
+
+	void SetGrowSize(ptrdiff_t growSize_) {
 		growSize = growSize_;
 	}

 	/// Reallocate the storage for the buffer to be newSize and
 	/// copy exisiting contents to the new buffer.
 	/// Must not be used to decrease the size of the buffer.
-	void ReAllocate(int newSize) {
+	void ReAllocate(ptrdiff_t newSize) {
 		if (newSize < 0)
 			throw std::runtime_error("SplitVector::ReAllocate: negative size.");

@@ -104,9 +104,9 @@

 	/// Retrieve the character at a particular position.
 	/// Retrieving positions outside the range of the buffer returns 0.
 	/// The assertions here are disabled since calling code can be
 	/// simpler if out of range access works and returns 0.
-	T ValueAt(int position) const {
+	T ValueAt(ptrdiff_t position) const {
 		if (position < part1Length) {
 			//PLATFORM_ASSERT(position >= 0);
 			if (position < 0) {
@@ -124,7 +124,7 @@
 		}
 	}

-	void SetValueAt(int position, T v) {
+	void SetValueAt(ptrdiff_t position, T v) {
 		if (position < part1Length) {
 			PLATFORM_ASSERT(position >= 0);
 			if (position < 0) {
@@ -144,7 +144,7 @@
 		}
 	}

-	T &operator[](int position) const {
+	T &operator[](ptrdiff_t position) const {
 		PLATFORM_ASSERT(position >= 0 && position < lengthBody);
 		if (position < part1Length) {
 			return body[position];
@@ -166,13 +166,13 @@
 	}

 	/// Retrieve the length of the buffer.
-	int Length() const {
+	ptrdiff_t Length() const {
 		return lengthBody;
 	}

 	/// Insert a single value into the buffer.
 	/// Inserting at positions outside the current range fails.
-	void Insert(int position, T v) {
+	void Insert(ptrdiff_t position, T v) {
 		PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
 		if ((position < 0) || (position > lengthBody)) {
 			return;
@@ -187,7 +187,7 @@

 	/// Insert a number of elements into the buffer setting their value.
 	/// Inserting at positions outside the current range fails.
-	void InsertValue(int position, int insertLength, T v) {
+	void InsertValue(ptrdiff_t position, ptrdiff_t insertLength, T v) {
 		PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
 		if (insertLength > 0) {
 			if ((position < 0) || (position > lengthBody)) {
@@ -225,14 +225,14 @@

 	/// Ensure at least length elements allocated,
 	/// appending zero valued elements if needed.
-	void EnsureLength(int wantedLength) {
+	void EnsureLength(ptrdiff_t wantedLength) {
 		if (Length() < wantedLength) {
 			InsertValue(Length(), wantedLength - Length(), 0);
 		}
 	}

 	/// Insert text into the buffer from an array.
-	void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) {
+	void InsertFromArray(ptrdiff_t positionToInsert, const T s[], ptrdiff_t positionFrom, ptrdiff_t insertLength) {
 		PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody));
 		if (insertLength > 0) {
 			if ((positionToInsert < 0) || (positionToInsert > lengthBody)) {
@@ -248,7 +248,7 @@
 	}

 	/// Delete one element from the buffer.
-	void Delete(int position) {
+	void Delete(ptrdiff_t position) {
 		PLATFORM_ASSERT((position >= 0) && (position < lengthBody));
 		if ((position < 0) || (position >= lengthBody)) {
 			return;
@@ -258,7 +258,7 @@

 	/// Delete a range from the buffer.
 	/// Deleting positions outside the current range fails.
-	void DeleteRange(int position, int deleteLength) {
+	void DeleteRange(ptrdiff_t position, ptrdiff_t deleteLength) {
 		PLATFORM_ASSERT((position >= 0) && (position + deleteLength <= lengthBody));
 		if ((position < 0) || ((position + deleteLength) > lengthBody)) {
 			return;
@@ -277,17 +277,17 @@
 	// Retrieve a range of elements into an array
-	void GetRange(T *buffer, int position, int retrieveLength) const {
+	void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const {
 		// Split into up to 2 ranges, before and after the split then use memcpy on each.
-		int range1Length = 0;
+		ptrdiff_t range1Length = 0;
 		if (position < part1Length) {
-			const int part1AfterPosition = part1Length - position;
+			const ptrdiff_t part1AfterPosition = part1Length - position;
 			range1Length = retrieveLength;
 			if (range1Length > part1AfterPosition)
 				range1Length = part1AfterPosition;
 		}
 		std::copy(body + position, body + position + range1Length, buffer);
 		buffer += range1Length;
 		position = position + range1Length + gapLength;
-		int range2Length = retrieveLength - range1Length;
+		ptrdiff_t range2Length = retrieveLength - range1Length;
 		std::copy(body + position, body + position + range2Length, buffer);
 	}

@@ -308,7 +308,7 @@
 		return body;
 	}

-	T *RangePointer(int position, int rangeLength) {
+	T *RangePointer(ptrdiff_t position, ptrdiff_t rangeLength) {
 		if (position < part1Length) {
 			if ((position + rangeLength) > part1Length) {
 				// Range overlaps gap, so move gap to start of range.
@@ -323,7 +323,7 @@
 		}
 	}

-	int GapPosition() const {
+	ptrdiff_t GapPosition() const {
 		return part1Length;
 	}
 };