diff options
author | Karl Berry <karl@freefriends.org> | 2010-11-02 00:00:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-11-02 00:00:01 +0000 |
commit | a9b2a790f635e283433247b2b347c67274c6d2b8 (patch) | |
tree | 61f0b5c9604c8a02b2e512cb804151effe545a80 /Build | |
parent | 5c7ef6068414bffac572f3d5b0926e6c100628d2 (diff) |
accept both LF and CRLF; from Taco
git-svn-id: svn://tug.org/texlive/trunk@20290 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/makeindexk/ChangeLog | 7 | ||||
-rw-r--r-- | Build/source/texk/makeindexk/mkind.c | 16 | ||||
-rw-r--r-- | Build/source/texk/makeindexk/mkind.h | 3 |
3 files changed, 25 insertions, 1 deletions
diff --git a/Build/source/texk/makeindexk/ChangeLog b/Build/source/texk/makeindexk/ChangeLog index 29ddffb4d2d..72a94c4a397 100644 --- a/Build/source/texk/makeindexk/ChangeLog +++ b/Build/source/texk/makeindexk/ChangeLog @@ -1,3 +1,10 @@ +2010-11-02 Taco Hoekwater <taco@elvenkind.com> + + * mkind.c (mk_getc): new fn to accept both LF and CRLF. + (main): declare as int just for consistency. + * mkind.h (mk_getc): declare it. + (GET_CHAR): use it. + 2010-07-06 Peter Breitenlohner <peb@mppmu.mpg.de> * configure.ac [TEX_LIVE_VERSION]: From ../../version.ac. diff --git a/Build/source/texk/makeindexk/mkind.c b/Build/source/texk/makeindexk/mkind.c index 60c292fc7d0..754fe771f83 100644 --- a/Build/source/texk/makeindexk/mkind.c +++ b/Build/source/texk/makeindexk/mkind.c @@ -78,6 +78,22 @@ static void process_idx (char * *fn,int use_stdin,int sty_given, long totmem = 0L; /* for debugging memory usage */ #endif /* DEBUG */ +/* |mk_getc|: accept either Unix or Windows line endings */ + +static int lookahead = -2; /* because you can't ungetc(EOF) */ + +int +mk_getc(FILE *stream) +{ + int ch = (lookahead != -2 ? lookahead : getc(stream)); + lookahead = (ch == '\r' ? getc(stream) : -2); + if (lookahead == LFD) { + ch = lookahead; + lookahead = -2; + } + return ch; +} + int main(int argc, char *argv[]) { diff --git a/Build/source/texk/makeindexk/mkind.h b/Build/source/texk/makeindexk/mkind.h index 9c2b6848f8c..3cd9d843787 100644 --- a/Build/source/texk/makeindexk/mkind.h +++ b/Build/source/texk/makeindexk/mkind.h @@ -225,7 +225,8 @@ #define ODD "odd" #define ANY "any" -#define GET_CHAR getc +extern int mk_getc (FILE *str); /* line endings patch */ +#define GET_CHAR mk_getc #define TOASCII(i) (char)((i) + 48) |