Skip to content

Commit 2e6f8ff

Browse files
committed
MSys debug
1 parent 30f94ef commit 2e6f8ff

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
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: 21 additions & 18 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)
@@ -311,6 +308,8 @@ namespace lsp
311308
// Read lines
312309
while ((res = read_line()) == STATUS_OK)
313310
{
311+
fprintf(stderr, "READ LINE: %s\n", sLine.get_utf8());
312+
314313
// Check that line is not empty
315314
const char *l = skip_spaces(sLine.get_utf8());
316315
if ((l == NULL) || (*l == '\0'))
@@ -351,27 +350,13 @@ namespace lsp
351350
nBufOff = 0;
352351
}
353352

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-
365353
// Scan for line ending character
366354
size_t tail = nBufOff;
367355
while (tail < nBufLen)
368356
{
369357
lsp_wchar_t ch = pBuffer[tail++];
370358
if (ch == '\n') // Found!
371-
{
372-
bSkipLF = true;
373359
break;
374-
}
375360
}
376361

377362
// Append data to string and update buffer state
@@ -383,6 +368,8 @@ namespace lsp
383368
if (sLine.last() != '\n') // Not end of line?
384369
continue;
385370
sLine.set_length(--len);
371+
if (sLine.last() == '\r') // Remove carriage-return symbol if it is present
372+
sLine.set_length(--len);
386373

387374
// Compute number of terminating '\\' characters
388375
ssize_t slashes = 0, xoff = len-1;
@@ -530,10 +517,13 @@ namespace lsp
530517
return true;
531518
}
532519

533-
status_t PullParser::parse_line(const char *s)
520+
status_t PullParser::parse_line(const char *line)
534521
{
535522
status_t result = ((nLines++) > 0) ? STATUS_CORRUPTED_FILE : STATUS_BAD_FORMAT;
536523

524+
fprintf(stderr, "PARSE LINE: %s\n", line);
525+
526+
const char *s = line;
537527
switch (*(s++))
538528
{
539529
case 'b': // bmat, bevel
@@ -775,10 +765,16 @@ namespace lsp
775765
{
776766
s = skip_spaces(s+1);
777767
if (!parse_float(&sEvent.vertex.x, &s))
768+
{
769+
fprintf(stderr, "Failed parse_float: %s\n", s);
778770
return result;
771+
}
779772
s = skip_spaces(s);
780773
if (!parse_float(&sEvent.vertex.y, &s))
774+
{
775+
fprintf(stderr, "Failed parse_float: %s\n", s);
781776
return result;
777+
}
782778
s = skip_spaces(s);
783779
if (!parse_float(&sEvent.vertex.z, &s))
784780
sEvent.vertex.z = 0.0f; // Extension, strictly required in obj format, for our case facilitated
@@ -787,7 +783,11 @@ namespace lsp
787783
sEvent.vertex.w = 1.0f;
788784

789785
if (!end_of_line(s))
786+
{
787+
fprintf(stderr, "Failed end_of_line: \"%s\"\n", s);
788+
lsp::debug::dumpb("String dump", s, strlen(s));
790789
return result;
790+
}
791791

792792
++nVx;
793793
sEvent.type = EV_VERTEX;
@@ -858,6 +858,9 @@ namespace lsp
858858
break;
859859
}
860860

861+
if (result != STATUS_OK)
862+
lsp::debug::dumpb("Could not parse line", line, strlen(line));
863+
861864
return result;
862865
}
863866

0 commit comments

Comments
 (0)