diff options
Diffstat (limited to 'testing/mmh/musl-fixes.patch')
-rw-r--r-- | testing/mmh/musl-fixes.patch | 155 |
1 files changed, 43 insertions, 112 deletions
diff --git a/testing/mmh/musl-fixes.patch b/testing/mmh/musl-fixes.patch index 4fc272695c..a1c0c8fe1c 100644 --- a/testing/mmh/musl-fixes.patch +++ b/testing/mmh/musl-fixes.patch @@ -1,34 +1,7 @@ ---- mmh-0.1.orig/sbr/discard.c -+++ mmh-0.1/sbr/discard.c -@@ -18,14 +18,6 @@ - - tcflush(fileno(io), TCOFLUSH); - --#if defined(_FSTDIO) || defined(__DragonFly__) -- fpurge(io); --#else --# ifdef LINUX_STDIO -- io->_IO_write_ptr = io->_IO_write_base; --# else -- if ((io->_ptr = io->_base)) -- io->_cnt = 0; --# endif --#endif -+ /* There used to be an fpurge() here on some platforms, stdio -+ hackery on others. But it didn't seem necessary. */ - } ---- mmh-0.1.orig/sbr/m_getfld.c -+++ mmh-0.1/sbr/m_getfld.c -@@ -137,7 +137,7 @@ - ** is used in m_Eom because the first character of the string - ** has been read and matched before m_Eom is called. - */ --char *msg_delim = ""; -+static char *msg_delim = ""; - - static unsigned char *fdelim; - static unsigned char *delimend; -@@ -147,26 +147,85 @@ +diff -upr mmh-0.2.orig/sbr/m_getfld.c mmh-0.2/sbr/m_getfld.c +--- mmh-0.2.orig/sbr/m_getfld.c 2015-12-21 03:36:00.060760463 +0100 ++++ mmh-0.2/sbr/m_getfld.c 2015-12-21 03:38:04.080205306 +0100 +@@ -149,26 +149,81 @@ static int edelimlen; static int (*eom_action)(int) = NULL; @@ -38,6 +11,10 @@ -# define _filbuf __srget /* Puke */ -# define DEFINED__FILBUF_TO_SOMETHING_SPECIFIC -#endif +- +-#ifndef DEFINED__FILBUF_TO_SOMETHING_SPECIFIC +-extern int _filbuf(FILE*); +-#endif +/* +** This replaces the old approach, which included direct access to +** stdio internals. It uses one fread() to load a buffer that we @@ -49,10 +26,7 @@ + unsigned char *readpos; + unsigned char *end; /* One past the last character read in. */ +} m; - --#ifndef DEFINED__FILBUF_TO_SOMETHING_SPECIFIC --extern int _filbuf(FILE*); --#endif ++ +static void +setup_buffer(FILE *iob, struct m_getfld_buffer *m) +{ @@ -69,12 +43,12 @@ + m->readpos = m->end = m->msg_buf; + } +} - ++ +static size_t +read_more(struct m_getfld_buffer *m, FILE *iob) +{ + size_t num_read; - ++ + /* Move any leftover at the end of buf to the beginning. */ + if (m->end > m->readpos) { + memmove(m->msg_buf, m->readpos, m->end - m->readpos); @@ -82,7 +56,7 @@ + m->readpos = m->msg_buf + (m->end - m->readpos); + num_read = fread(m->readpos, 1, MSG_INPUT_SIZE, iob); + m->end = m->readpos + num_read; -+ + + return num_read; +} + @@ -107,26 +81,21 @@ +{ + return (m.readpos == m.msg_buf) ? EOF : (*--m.readpos = c); +} -+ -+ -+ + int m_getfld(int state, unsigned char *name, unsigned char *buf, int bufsz, FILE *iob) { -- register unsigned char *bp, *cp, *ep, *sp; -- register int cnt, c, i, j; -+ unsigned char *bp, *cp, *ep, *sp; + unsigned char *bp, *cp, *ep, *sp; +- int cnt, c, i, j; + int cnt, c, i, j, k; - if ((c = getc(iob)) < 0) { -+ setup_buffer(iob, &m); -+ + if ((c = Getc(iob)) < 0) { msg_count = 0; *buf = 0; return FILEEOF; -@@ -174,10 +233,10 @@ +@@ -176,10 +231,10 @@ m_getfld(int state, unsigned char *name, if (eom(c, iob)) { if (! eom_action) { /* flush null messages */ @@ -139,7 +108,7 @@ } msg_count = 0; *buf = 0; -@@ -190,16 +249,16 @@ +@@ -192,16 +247,16 @@ m_getfld(int state, unsigned char *name, case FLD: if (c == '\n' || c == '-') { /* we hit the header/body separator */ @@ -160,7 +129,7 @@ } msg_count = 0; *buf = 0; -@@ -216,47 +275,28 @@ +@@ -218,47 +273,28 @@ m_getfld(int state, unsigned char *name, cp = name; i = NAMESZ - 1; for (;;) { @@ -220,7 +189,7 @@ } if (c == ':') break; -@@ -310,7 +350,13 @@ +@@ -312,7 +348,14 @@ m_getfld(int state, unsigned char *name, ** that should be harmless enough, right? ** This is a corrupt message anyway. */ @@ -232,10 +201,11 @@ + ** e.g., get_content, can use ftell(), etc. + */ + fseek(iob, -cnt - 1, SEEK_CUR); ++ return BODY; } if ((i -= j) <= 0) { -@@ -334,16 +380,9 @@ +@@ -336,16 +379,9 @@ m_getfld(int state, unsigned char *name, */ cp = buf; i = bufsz-1; for (;;) { @@ -255,7 +225,7 @@ c = cnt < i ? cnt : i; while ((ep = locc( c, bp, '\n' ))) { /* -@@ -351,21 +390,13 @@ +@@ -353,21 +389,14 @@ m_getfld(int state, unsigned char *name, ** return. */ if ((j = *++ep) != ' ' && j != '\t') { @@ -281,10 +251,11 @@ + j = ep - m.readpos; + memcpy (cp, m.readpos, j); + m.readpos = ep; ++ cp += j; state = FLD; goto finish; -@@ -377,64 +408,34 @@ +@@ -379,64 +408,33 @@ m_getfld(int state, unsigned char *name, ** end of input or dest buffer - copy what ** we've found. */ @@ -315,7 +286,7 @@ - iob->_cnt -= c; - iob->_ptr += c; -#endif - state = FLDPLUS; +- state = FLDPLUS; break; } /* @@ -345,8 +316,8 @@ -#endif + *cp++ = j = Getc(iob); + c = Getc(iob); - if (c == EOF || - ((j == '\0' || j == '\n') && c != ' ' && c != '\t')) { + if (c == EOF || ((j == '\0' || j == '\n') + && c != ' ' && c != '\t')) { if (c != EOF) { -#ifdef LINUX_STDIO - --iob->_IO_read_ptr; @@ -365,7 +336,7 @@ } state = FLD; break; -@@ -452,17 +453,10 @@ +@@ -454,17 +452,10 @@ m_getfld(int state, unsigned char *name, ** don't add an eos. */ i = (bufsz < 0) ? -bufsz : bufsz-1; @@ -387,7 +358,7 @@ if (ismbox && c > 1) { /* ** packed maildrop - only take up to the (possible) -@@ -545,15 +539,8 @@ +@@ -547,15 +538,8 @@ m_getfld(int state, unsigned char *name, } } memcpy( buf, bp, c ); @@ -405,17 +376,9 @@ if (bufsz < 0) { msg_count = c; return (state); -@@ -574,16 +561,18 @@ - void - thisisanmbox(FILE *iob) - { -- register int c; -+ int c; - char text[10]; -- register char *cp; -- register char *delimstr; -+ char *cp; -+ char *delimstr; +@@ -581,11 +565,13 @@ thisisanmbox(FILE *iob) + char *cp; + char *delimstr; - c = getc(iob); + setup_buffer(iob, &m); @@ -429,7 +392,7 @@ /* ** Figure out what the message delimitter string is for this -@@ -597,7 +586,12 @@ +@@ -599,7 +585,12 @@ thisisanmbox(FILE *iob) ** abort. */ @@ -440,10 +403,10 @@ + } + } + if (c != 5) { - adios(NULL, "Read error"); + adios(EX_IOERR, NULL, "Read error"); } if (strncmp(text, "From ", 5)!=0) { -@@ -605,7 +599,7 @@ +@@ -607,7 +598,7 @@ thisisanmbox(FILE *iob) } ismbox = TRUE; delimstr = "\nFrom "; @@ -452,9 +415,9 @@ continue; } c = strlen(delimstr); -@@ -628,8 +622,9 @@ +@@ -630,8 +621,9 @@ thisisanmbox(FILE *iob) */ - pat_map = (unsigned char **) calloc(256, sizeof(unsigned char *)); + pat_map = (unsigned char **) mh_xcalloc(256, sizeof(unsigned char *)); - for (cp = (char *) fdelim + 1; cp < (char *) delimend; cp++ ) + for (cp = (char *) fdelim + 1; cp < (char *) delimend; cp++) { @@ -463,19 +426,16 @@ } -@@ -640,27 +635,34 @@ - static int - m_Eom(int c, FILE *iob) - { -- register long pos = 0L; -- register int i; -+ unsigned char *pos; -+ int i; +@@ -645,24 +637,31 @@ m_Eom(int c, FILE *iob) + long pos = 0L; + int i; char text[10]; + char *cp; - pos = ftell(iob); - if ((i = fread(text, sizeof *text, edelimlen, iob)) != edelimlen || +- (strncmp(text, (char *)edelim, edelimlen)!=0)) { +- if (i == 0 && ismbox) + pos = m.readpos; /* ftell */ + for (i=0, cp=text; i<edelimlen; ++i, ++cp) { + if ((*cp = Getc(iob)) == EOF) { @@ -484,8 +444,7 @@ + } + + if (i != edelimlen || - (strncmp(text, (char *)edelim, edelimlen)!=0)) { -- if (i == 0 && ismbox) ++ (strncmp(text, (char *)edelim, edelimlen)!=0)) { + if (i == 0 && ismbox) { /* ** the final newline in the (brain damaged) unix-format @@ -507,31 +466,3 @@ continue; } } -@@ -672,11 +674,11 @@ - static unsigned char * - matchc(int patln, char *pat, int strln, char *str) - { -- register char *es = str + strln - patln; -- register char *sp; -- register char *pp; -- register char *ep = pat + patln; -- register char pc = *pat++; -+ char *es = str + strln - patln; -+ char *sp; -+ char *pp; -+ char *ep = pat + patln; -+ char pc = *pat++; - - for(;;) { - while (pc != *str++) ---- mmh-0.1.orig/uip/Makefile.in -+++ mmh-0.1/uip/Makefile.in -@@ -32,7 +32,7 @@ - - COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS) - LINK = $(CC) $(LDFLAGS) -o $@ --LN = ln -+LN = ln -s - - INSTALL = @INSTALL@ - INSTALL_PROGRAM = @INSTALL_PROGRAM@ |