| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflstr.h" char * wordwrapstr ( char *strbuff, int iwid)
Function that does word wraping of a string at or less than iwid. Breaks up a string on word boundaries by placing '\n' in the string. Returns a pointer to head of the return buffer. Submitted by Scott Beasley jscottb@infoave.com
{ char *strtmp = strbuff; int icnt = 0; ASSERT (strbuff); replacechrswith (strbuff, "\n", ' '); while (*strtmp) { if ((int)strlen (strtmp) > (int)iwid) { icnt = iwid; while (*(strtmp + icnt)) { if (strchr (" .?;!,", *(strtmp + icnt))) { ltrim ((strtmp + icnt)); insertchar (strtmp, '\n', icnt); strtmp += icnt + 1; break; } icnt--; if (!icnt) { if (strchr (" .?;!,", *(strtmp + icnt))) { ltrim ((strtmp + iwid)); insertchar (strtmp, '\n', iwid); strtmp += iwid + 1; break; } } } } else break; } return strbuff; }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |