Rev 386 | Rev 388 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 386 | Rev 387 | ||
---|---|---|---|
Line 356... | Line 356... | ||
356 | && (res = readPARM((char*)q, &gdata->parm, reason, 0 /*Strings are already PStrings*/)) ) |
356 | && (res = readPARM((char*)q, &gdata->parm, reason, 0 /*Strings are already PStrings*/)) ) |
357 | { |
357 | { |
358 | // Note: slider[i] = EndianS32_LtoN(slider[i]); will be done in readPARM() |
358 | // Note: slider[i] = EndianS32_LtoN(slider[i]); will be done in readPARM() |
359 | // All the rest are flags which (if we're careful) will work in either ordering |
359 | // All the rest are flags which (if we're careful) will work in either ordering |
360 | 360 | ||
361 | // Convert '\r' in the copyright field to '\r\n'. |
361 | // Convert CR in the copyright field to CRLF. |
362 | int i, j; |
362 | int i, j; |
363 | for (i = 1; i < gdata->parm.copyright[0]; i++) { |
363 | for (i = 1; i < gdata->parm.copyright[0]; i++) { |
364 | if (gdata->parm.copyright[i] == '\r') { |
364 | if (gdata->parm.copyright[i] == CR) { |
365 | for (j = gdata->parm.copyright[0]; j>i; j--) { |
365 | for (j = gdata->parm.copyright[0]; j>i; j--) { |
366 | gdata->parm.copyright[j+1] = gdata->parm.copyright[j]; |
366 | gdata->parm.copyright[j+1] = gdata->parm.copyright[j]; |
367 | } |
367 | } |
368 | gdata->parm.copyright[0]++; |
368 | gdata->parm.copyright[0]++; |
369 | gdata->parm.copyright[i+1] = '\n'; |
369 | gdata->parm.copyright[i+1] = LF; |
370 | } |
370 | } |
371 | } |
371 | } |
372 | } |
372 | } |
373 | #endif |
373 | #endif |
374 | 374 | ||
Line 448... | Line 448... | ||
448 | for (i = 0; i < strlen(line); i++) { |
448 | for (i = 0; i < strlen(line); i++) { |
449 | if (line[i] == ':') { |
449 | if (line[i] == ':') { |
450 | // Note: We are ignoring whitespaces, i.e. " A :" != "A:" (TODO: should we change this?) |
450 | // Note: We are ignoring whitespaces, i.e. " A :" != "A:" (TODO: should we change this?) |
451 | if ((searchkey == NULL) || ((i == strlen(searchkey)) && (memcmp(line, searchkey, i) == 0))) { |
451 | if ((searchkey == NULL) || ((i == strlen(searchkey)) && (memcmp(line, searchkey, i) == 0))) { |
452 | i++; // jump over ':' char |
452 | i++; // jump over ':' char |
453 | //while ((line[i] == ' ') || (line[i] == '\t')) i++; // Trim value left |
453 | //while ((line[i] == ' ') || (line[i] == TAB)) i++; // Trim value left |
454 | *content = line + i; |
454 | *content = line + i; |
455 | return true; |
455 | return true; |
456 | } |
456 | } |
457 | } |
457 | } |
458 | } |
458 | } |
Line 482... | Line 482... | ||
482 | if (inputwork == 0) return false; |
482 | if (inputwork == 0) return false; |
483 | memcpy(inputwork, inputFile, maxInput); |
483 | memcpy(inputwork, inputFile, maxInput); |
484 | // Replace all \r and \n with \0, so that we can parse easier |
484 | // Replace all \r and \n with \0, so that we can parse easier |
485 | for (i = 0; i < maxInput; i++) { |
485 | for (i = 0; i < maxInput; i++) { |
486 | if (inputwork[i] == 0) break; |
486 | if (inputwork[i] == 0) break; |
487 | if (inputwork[i] == '\r') inputwork[i] = 0; |
487 | if (inputwork[i] == CR) inputwork[i] = 0; |
488 | if (inputwork[i] == '\n') inputwork[i] = 0; |
488 | if (inputwork[i] == LF) inputwork[i] = 0; |
489 | } |
489 | } |
490 | // C++ wrong warning: Buffer overflow (C6386) |
490 | // C++ wrong warning: Buffer overflow (C6386) |
491 | // 'The writeable size is "maxInput+1" Byte, but "maxInput" byte can be written'. WTF? |
491 | // 'The writeable size is "maxInput+1" Byte, but "maxInput" byte can be written'. WTF? |
492 | #pragma warning(suppress : 6386) |
492 | #pragma warning(suppress : 6386) |
493 | inputwork[maxInput] = 0; |
493 | inputwork[maxInput] = 0; |
Line 511... | Line 511... | ||
511 | return false; |
511 | return false; |
512 | } |
512 | } |
513 | } while (!_picoLineContainsKey(sline, &svalue, property)); |
513 | } while (!_picoLineContainsKey(sline, &svalue, property)); |
514 | // Read line(s) until we find a line with another key, or the line end |
514 | // Read line(s) until we find a line with another key, or the line end |
515 | do { |
515 | do { |
516 | while ((svalue[0] == ' ') || (svalue[0] == '\t')) svalue++; // Trim left |
516 | while ((svalue[0] == ' ') || (svalue[0] == TAB)) svalue++; // Trim left |
517 | while ((svalue[strlen(svalue) - 1] == ' ') || (svalue[strlen(svalue) - 1] == '\t')) svalue[strlen(svalue) - 1] = 0; // Trim right |
517 | while ((svalue[strlen(svalue) - 1] == ' ') || (svalue[strlen(svalue) - 1] == TAB)) svalue[strlen(svalue) - 1] = 0; // Trim right |
518 | 518 | ||
519 | if (strlen(svalue) > 0) { |
519 | if (strlen(svalue) > 0) { |
520 | if (outputwork + strlen(svalue) + (isFormula ? 3 : 2) > outputFile + maxOutput) { |
520 | if (outputwork + strlen(svalue) + (isFormula ? 3 : 2) > outputFile + maxOutput) { |
521 | int remaining = maxOutput - (outputwork - outputFile) - 1; |
521 | int remaining = maxOutput - (outputwork - outputFile) - 1; |
522 | //printf("BUFFER FULL (remaining = %d)\n", remaining); |
522 | //printf("BUFFER FULL (remaining = %d)\n", remaining); |
Line 530... | Line 530... | ||
530 | else { |
530 | else { |
531 | memcpy(outputwork, svalue, strlen(svalue)); |
531 | memcpy(outputwork, svalue, strlen(svalue)); |
532 | outputwork += strlen(svalue); |
532 | outputwork += strlen(svalue); |
533 | if (isFormula) { |
533 | if (isFormula) { |
534 | // Formulas: TXT line break stays line break (important if you have comments!) |
534 | // Formulas: TXT line break stays line break (important if you have comments!) |
535 | outputwork[0] = '\r'; |
535 | outputwork[1] = CR; |
536 | outputwork++; |
- | |
537 | outputwork[0] = '\n'; |
536 | outputwork[2] = LF; |
538 | outputwork++; |
537 | outputwork += 2; |
539 | } |
538 | } |
540 | else { |
539 | else { |
541 | // Everything else: TXT line breaks becomes single whitespace |
540 | // Everything else: TXT line breaks becomes single whitespace |
542 | outputwork[0] = ' '; |
541 | outputwork[0] = ' '; |
543 | outputwork++; |
542 | outputwork++; |