Skip to content

Commit dea9945

Browse files
committed
Bugfixes parsing OBJ file under MSys build
1 parent 30f94ef commit dea9945

File tree

4 files changed

+15
-38
lines changed

4 files changed

+15
-38
lines changed

include/lsp-plug.in/fmt/obj/PullParser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ namespace lsp
4949
lsp_wchar_t *pBuffer; // Buffer for character data
5050
size_t nBufOff; // Buffer offset
5151
size_t nBufLen; // Buffer length
52-
bool bSkipLF; // Skip line-feed character
5352
size_t nLines; // Number of lines read
5453

5554
event_t sEvent;

src/main/fmt/obj/PullParser.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ namespace lsp
4141
nBufOff = 0;
4242
nBufLen = 0;
4343
nLines = 0;
44-
bSkipLF = false;
4544
nVx = 0;
4645
nParVx = 0;
4746
nTexVx = 0;
@@ -210,7 +209,6 @@ namespace lsp
210209
pBuffer = b;
211210
nBufOff = 0;
212211
nBufLen = 0;
213-
bSkipLF = false;
214212
nLines = 0;
215213
nVx = 0;
216214
nParVx = 0;
@@ -234,7 +232,6 @@ namespace lsp
234232
nBufOff = 0;
235233
nBufLen = 0;
236234
nLines = 0;
237-
bSkipLF = false;
238235

239236
// Release input sequence
240237
if (pIn != NULL)
@@ -351,27 +348,13 @@ namespace lsp
351348
nBufOff = 0;
352349
}
353350

354-
// Scan for line ending
355-
if (bSkipLF)
356-
{
357-
bSkipLF = false;
358-
if (pBuffer[nBufOff] == '\r')
359-
{
360-
if ((++nBufOff) >= nBufLen)
361-
continue;
362-
}
363-
}
364-
365351
// Scan for line ending character
366352
size_t tail = nBufOff;
367353
while (tail < nBufLen)
368354
{
369355
lsp_wchar_t ch = pBuffer[tail++];
370356
if (ch == '\n') // Found!
371-
{
372-
bSkipLF = true;
373357
break;
374-
}
375358
}
376359

377360
// Append data to string and update buffer state
@@ -383,6 +366,8 @@ namespace lsp
383366
if (sLine.last() != '\n') // Not end of line?
384367
continue;
385368
sLine.set_length(--len);
369+
if (sLine.last() == '\r') // Remove carriage-return symbol if it is present
370+
sLine.set_length(--len);
386371

387372
// Compute number of terminating '\\' characters
388373
ssize_t slashes = 0, xoff = len-1;

src/test/utest/fmt/obj/compressor.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,6 @@ namespace lsp
217217
memcpy(call->indices.t, vt, n * sizeof(obj::index_t));
218218
memcpy(call->indices.n, vn, n * sizeof(obj::index_t));
219219

220-
printf("#%04d: f ", int(vCalls.size() - 1));
221-
for (size_t i=0; i<n; ++i)
222-
{
223-
printf("%d/%d/%d ", int(vv[i]), int(vt[i]), int(vn[i]));
224-
}
225-
printf("\n");
226-
227220
return STATUS_OK;
228221
}
229222

src/test/utest/fmt/obj/pullparser.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@ UTEST_BEGIN("runtime.fmt.obj", pullparser)
9797
"vn 0 0 1\n"
9898
"f 1//1 2//1 3//1\n"
9999
"\n"
100-
"o Triangle 2\n\r"
101-
"v -2.0 -1.0 -2.0\n\r"
102-
"v 2.0 -1.0 -2.0\n\r"
103-
"v 0.0 2.0 -2.0\n\r"
104-
"vt -2.0 -1.0\n\r"
105-
"vt 2.0 -1.0\n\r"
106-
"vt 0.0 2.0\n\r"
107-
"vn 0.0 0.0 1.0\n\r"
108-
"vn 0.1 0.1 1.0\n\r"
109-
"f 4/1/2 5/2/2 6/3/3\n\r"
110-
"f -1/-1/-1 -2/-2/-1 -3/-3/-2\n\r"
111-
"\n\r"
112-
"\n\r";
100+
"o Triangle 2\r\n"
101+
"v -2.0 -1.0 -2.0\r\n"
102+
"v 2.0 -1.0 -2.0\r\n"
103+
"v 0.0 2.0 -2.0\r\n"
104+
"vt -2.0 -1.0\r\n"
105+
"vt 2.0 -1.0\r\n"
106+
"vt 0.0 2.0\r\n"
107+
"vn 0.0 0.0 1.0\r\n"
108+
"vn 0.1 0.1 1.0\r\n"
109+
"f 4/1/2 5/2/2 6/3/3\r\n"
110+
"f -1/-1/-1 -2/-2/-1 -3/-3/-2\r\n"
111+
"\r\n"
112+
"\r\n";
113113

114114
PullParser p;
115115
event_t ev;

0 commit comments

Comments
 (0)