X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fscansbr.c;h=df18258431101c3032e2ae23f9844a89208e3278;hp=6fd4bb32fb1cc6c9f3c72f8a193a1adf92cf73f3;hb=d8916ff5d389de5ab225cd6f40aeda1b285d0f28;hpb=7879ea4084333b448c5a3a49c1cb52023e3808d1 diff --git a/uip/scansbr.c b/uip/scansbr.c index 6fd4bb3..df18258 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -3,6 +3,10 @@ * scansbr.c -- routines to help scan along... * * $Id$ + * + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include @@ -10,6 +14,7 @@ #include #include #include +#include #ifdef _FSTDIO # define _ptr _p /* Gag */ @@ -63,13 +68,19 @@ char *scanl = 0; /* text of most recent scanline */ int sc_width (void); /* from termsbr.c */ static int mh_fputs(char *, FILE *); +#ifdef MULTIBYTE_SUPPORT +#define SCAN_CHARWIDTH MB_CUR_MAX +#else +#define SCAN_CHARWIDTH 1 +#endif int scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, int unseen, char *folder, long size, int noisy) { int i, compnum, encrypted, state; - char *cp, *tmpbuf, **nxtbuf; + unsigned char *cp, *tmpbuf; + char **nxtbuf; char *saved_c_text; struct comp *cptr; struct comp **savecomp; @@ -92,8 +103,7 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, width = MAXSCANL; } dat[3] = slwidth = width; - if ((scanl = (char *) malloc((size_t) (slwidth + 2) )) == NULL) - adios (NULL, "unable to malloc scan line (%d bytes)", slwidth+2); + scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH * (slwidth + 2) ); if (outnum) umask(~m_gmprot()); @@ -129,8 +139,7 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, used_buf += ncomps+1; *--used_buf = 0; rlwidth = bodycomp && (width > SBUFSIZ) ? width : SBUFSIZ; for (i = ncomps; i--; ) - if ((*nxtbuf++ = malloc(rlwidth)) == NULL) - adios (NULL, "unable to allocate component buffer"); + *nxtbuf++ = mh_xmalloc(rlwidth); } /* @@ -200,7 +209,7 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg, */ if ((cptr = wantcomp[CHASH(name)])) { do { - if (!strcasecmp(name, cptr->c_name)) { + if (!mh_strcasecmp(name, cptr->c_name)) { if (! cptr->c_text) { cptr->c_text = tmpbuf; for (cp = tmpbuf + strlen (tmpbuf) - 1; @@ -247,6 +256,8 @@ body:; while (state == BODY) { #ifdef LINUX_STDIO if (scnout->_IO_write_ptr == scnout->_IO_write_end) { +#elif defined(__DragonFly__) + if (((struct __FILE_public *)scnout)->_w <= 0) { #else if (scnout->_cnt <= 0) { #endif @@ -257,6 +268,10 @@ body:; state = m_getfld(state, name, scnout->_IO_write_ptr, (long)scnout->_IO_write_ptr-(long)scnout->_IO_write_end , inb); scnout->_IO_write_ptr += msg_count; +#elif defined(__DragonFly__) + state = m_getfld( state, name, ((struct __FILE_public *)scnout)->_p, -(((struct __FILE_public *)scnout)->_w), inb ); + ((struct __FILE_public *)scnout)->_w -= msg_count; + ((struct __FILE_public *)scnout)->_p += msg_count; #else state = m_getfld( state, name, scnout->_ptr, -(scnout->_cnt), inb ); scnout->_cnt -= msg_count; @@ -327,9 +342,9 @@ finished: if (datecomp->c_tws == NULL) adios (NULL, "unable to allocate tws buffer"); *datecomp->c_tws = *dlocaltime ((time_t *) &st.st_mtime); - datecomp->c_flags = -1; + datecomp->c_flags |= CF_DATEFAB|CF_TRUE; } else { - datecomp->c_flags = 0; + datecomp->c_flags &= ~CF_DATEFAB; } } }