2 /*$Name: ezmlm-idx-040 $*/
11 void concatHDR(indata
,n
,outdata
,fatal
)
16 /* takes a concatenated string of line and continuation line, trims leading */
17 /* and trailing LWSP and collapses line breaks and surrounding LWSP to ' '. */
18 /* indata has to end in \n or \0 or this routine will write beyond indata! */
19 /* if indata ends with \0, this will be changed to \n. */
22 register char *cp
,*cpout
;
24 if (!stralloc_copys(outdata
,"")) die_nomem(fatal
);
25 if (!stralloc_ready(outdata
,n
)) die_nomem(fatal
);
28 cplast
= indata
+ n
- 1;
30 while (*cplast
== '\0' || *cplast
== '\n') --cplast
;
31 if (cp
== cplast
) die_nomem(fatal
); /* just in case */
32 *(++cplast
) = '\n'; /* have terminal '\n' */
34 while (cp
<= cplast
) {
35 while (*cp
== ' ' || *cp
== '\t') ++cp
; /* LWSP before */
36 while (*cp
!= '\n') *(cpout
++) = *(cp
++); /* text */
38 --cpout
; /* last char */
39 while (*cpout
== ' ' || *cpout
== '\t') --cpout
; /* LWSP after */
40 *(++cpout
) = ' '; /* replace with single ' ' */
41 ++cpout
; /* point to free byte */
43 outdata
->len
= cpout
- outdata
->s
;