79 const char *start_line;
81 const char *next_word;
82 const char *next_space;
88 curr_indent = -indent;
89 curr_len = len + indent;
99 for (start_line = word = str; word != 0; word = next_word) {
100 next_space = word + strcspn(word,
" \t");
101 if (word > start_line) {
102 if (next_space - start_line > curr_len) {
103 line_len = word - start_line;
104 while (line_len > 0 &&
ISSPACE(start_line[line_len - 1]))
106 output_fn(start_line, line_len, curr_indent, context);
107 while (*word &&
ISSPACE(*word))
109 if (start_line == str) {
110 curr_indent += indent;
116 next_word = *next_space ? next_space + 1 : 0;
118 line_len = strlen(start_line);
119 while (line_len > 0 &&
ISSPACE(start_line[line_len - 1]))
121 output_fn(start_line, line_len, curr_indent, context);
void line_wrap(const char *str, int len, int indent, LINE_WRAP_FN output_fn, void *context)
void(* LINE_WRAP_FN)(const char *, int, int, void *)