Browse Source

[c][cpp] Fix multi-page atlas parsing, closes #1935

badlogic 4 years ago
parent
commit
8057c114db
2 changed files with 8 additions and 2 deletions
  1. 4 1
      spine-c/spine-c/src/spine/Atlas.c
  2. 4 1
      spine-cpp/spine-cpp/src/spine/Atlas.cpp

+ 4 - 1
spine-c/spine-c/src/spine/Atlas.c

@@ -139,7 +139,10 @@ typedef struct SimpleString {
 static SimpleString *ss_trim(SimpleString *self) {
 static SimpleString *ss_trim(SimpleString *self) {
 	while (isspace((unsigned char) *self->start) && self->start < self->end)
 	while (isspace((unsigned char) *self->start) && self->start < self->end)
 		self->start++;
 		self->start++;
-	if (self->start == self->end) return self;
+	if (self->start == self->end) {
+		self->length = self->end - self->start;
+		return self;
+	}
 	self->end--;
 	self->end--;
 	while (((unsigned char) *self->end == '\r') && self->end >= self->start)
 	while (((unsigned char) *self->end == '\r') && self->end >= self->start)
 		self->end--;
 		self->end--;

+ 4 - 1
spine-cpp/spine-cpp/src/spine/Atlas.cpp

@@ -111,7 +111,10 @@ struct SimpleString {
 	SimpleString trim() {
 	SimpleString trim() {
 		while (isspace((unsigned char) *start) && start < end)
 		while (isspace((unsigned char) *start) && start < end)
 			start++;
 			start++;
-		if (start == end) return *this;
+		if (start == end) {
+			length = end - start;
+			return *this;
+		}
 		end--;
 		end--;
 		while (((unsigned char) *end == '\r') && end >= start)
 		while (((unsigned char) *end == '\r') && end >= start)
 			end--;
 			end--;