Trim trailing '\0'

This commit is contained in:
Damiano Galassi committed 2017-10-03 14:11:14 +02:00
1 parent 300e4a0249
commit e4763788a3
2 files changed
+16 -2

No files matched your search

+15 -1
View File
@@ -193,8 +193,22 @@
}
[sc scanString:@"," intoString:nil];
}
// Trim '\0' from string end.
NSUInteger index = string.length;
unichar c;
while (index > 0) {
c = [string characterAtIndex:index - 1];
if (c == '\0') {
index--;
}
else {
break;
}
}
value = [sc.string substringFromIndex:sc.scanLocation];
NSRange range = NSMakeRange(sc.scanLocation, index - sc.scanLocation);
value = [sc.string substringWithRange:range];
if (value) {
[valuesArray addObject:value];
}