From 2a62981df381ab1be178f4c8ab4597990fc04538 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Thu, 17 Jul 2003 22:16:33 +0000 Subject: [PATCH] Accept CRLF line endings in .txt and .ts files. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1058 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/sc2code/libs/sound/trackplayer.c | 11 ++++++----- sc2/src/sc2code/libs/strings/getstr.c | 11 +++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 35c2941c4..36b69069d 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.3: +- Accept CRLF line endings in .txt and .ts files - SvdB - Fixed overflow problem with 32bpp bilinear,biadapt,biadv scalers -Mika - MixSDL now handles resampling correctly (less cracklings); added cubic interpolation for high quality mode -Mika diff --git a/sc2/src/sc2code/libs/sound/trackplayer.c b/sc2/src/sc2code/libs/sound/trackplayer.c index 99d92335c..fa3792da5 100644 --- a/sc2/src/sc2code/libs/sound/trackplayer.c +++ b/sc2/src/sc2code/libs/sound/trackplayer.c @@ -196,7 +196,7 @@ GetTimeStamps(UNICODE *TimeStamps, sint32 *time_stamps) { int pos; int num = 0; - while (*TimeStamps && (pos = wstrcspn (TimeStamps, ",\n"))) + while (*TimeStamps && (pos = wstrcspn (TimeStamps, ",\r\n"))) { UNICODE valStr[10]; uint32 val; @@ -210,8 +210,7 @@ GetTimeStamps(UNICODE *TimeStamps, sint32 *time_stamps) time_stamps++; } TimeStamps += pos; - if (*TimeStamps) - TimeStamps++; + TimeStamps += strspn(TimeStamps, ",\r\n"); } return (num); } @@ -241,7 +240,7 @@ SplitSubPages (UNICODE *text, sint32 *timestamp, int *num_pages) wstrcpy (split_text[page] + ellips + pos, "..."); timestamp[page] = - pos * TEXT_SPEED; ellips = 2; - text = text + pos + 1; + text = text + pos; pos = 0; page ++; } @@ -254,10 +253,12 @@ SplitSubPages (UNICODE *text, sint32 *timestamp, int *num_pages) *(split_text[page] + ellips + pos) = 0; timestamp[page] = - pos * TEXT_SPEED; ellips = 0; - text = text + pos + 1; + text = text + pos; pos = 0; page ++; } + while (text[pos] == '\n' || text[pos] == '\r') + text++; } else pos++; diff --git a/sc2/src/sc2code/libs/strings/getstr.c b/sc2/src/sc2code/libs/strings/getstr.c index c9fac3849..ef131e327 100644 --- a/sc2/src/sc2code/libs/strings/getstr.c +++ b/sc2/src/sc2code/libs/strings/getstr.c @@ -121,7 +121,9 @@ _GetStringData (uio_Stream *fp, DWORD length) { if (n >= 0) { - while (slen[n] > 1 && strdata[StringOffs - 2] == '\n') + while (slen[n] > 1 && + (strdata[StringOffs - 2] == '\n' || + strdata[StringOffs - 2] == '\r')) { --slen[n]; --StringOffs; @@ -144,7 +146,7 @@ _GetStringData (uio_Stream *fp, DWORD length) && (++tsptr)) { ts_ok = TRUE; - while (! strcspn(tsptr," \t\n") && *tsptr) + while (! strcspn(tsptr," \t\r\n") && *tsptr) tsptr++; if (*tsptr) { @@ -173,7 +175,7 @@ _GetStringData (uio_Stream *fp, DWORD length) } } clen[n] = 0; - s = strtok (NULL, " \t\n)"); + s = strtok (NULL, " \t\r\n)"); if (s) { l = path_len + strlen (s) + 1; @@ -220,7 +222,8 @@ _GetStringData (uio_Stream *fp, DWORD length) } if (n >= 0) { - while (slen[n] > 1 && strdata[StringOffs - 2] == '\n') + while (slen[n] > 1 && (strdata[StringOffs - 2] == '\n' + || strdata[StringOffs - 2] == '\r')) { --slen[n]; --StringOffs;