Changeset 4d24650
- Timestamp:
- Feb 4, 2011, 3:49:44 PM (13 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- e062f97
- Parents:
- e3c8332
- git-author:
- David Benjamin <davidben@mit.edu> (01/25/11 00:18:14)
- git-committer:
- David Benjamin <davidben@mit.edu> (02/04/11 15:49:44)
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cmd.c
re3c8332 r4d24650 276 276 if (cmd->usage && *cmd->usage) { 277 277 s = cmd->usage; 278 indent = owl_malloc(strlen(s)+(owl_text_num_lines(s)+3)*OWL_TAB+1); 279 owl_text_indent(indent, s, OWL_TAB); 278 indent = owl_text_indent(s, OWL_TAB); 280 279 owl_fmtext_append_bold(fm, "\nSYNOPSIS\n"); 281 280 owl_fmtext_append_normal(fm, indent); … … 291 290 if (cmd->description && *cmd->description) { 292 291 s = cmd->description; 293 indent = owl_malloc(strlen(s)+(owl_text_num_lines(s)+3)*OWL_TAB+1); 294 owl_text_indent(indent, s, OWL_TAB); 292 indent = owl_text_indent(s, OWL_TAB); 295 293 owl_fmtext_append_bold(fm, "\nDESCRIPTION\n"); 296 294 owl_fmtext_append_normal(fm, indent); -
style.c
r30da473 r4d24650 65 65 66 66 /* indent and ensure ends with a newline */ 67 indent=owl_malloc(strlen(body)+(owl_text_num_lines(body))*OWL_TAB+10); 68 owl_text_indent(indent, body, OWL_TAB); 67 indent = owl_text_indent(body, OWL_TAB); 69 68 curlen = strlen(indent); 70 69 if (curlen==0 || indent[curlen-1] != '\n') { -
text.c
rd222c44 r4d24650 5 5 #include "owl.h" 6 6 7 void owl_text_indent(char *out, const char *in, int n) 7 /* Returns a copy of 'in' with each line indented 'n' 8 * characters. Result must be freed with owl_free. */ 9 char *owl_text_indent(const char *in, int n) 8 10 { 9 11 const char *ptr1, *ptr2, *last; 12 GString *out = g_string_new(""); 10 13 int i; 11 12 strcpy(out, "");13 14 14 15 last=in+strlen(in)-1; … … 16 17 while (ptr1<=last) { 17 18 for (i=0; i<n; i++) { 18 strcat(out, " ");19 g_string_append_c(out, ' '); 19 20 } 20 21 ptr2=strchr(ptr1, '\n'); 21 22 if (!ptr2) { 22 strcat(out, ptr1);23 g_string_append(out, ptr1); 23 24 break; 24 25 } else { 25 strncat(out, ptr1, ptr2-ptr1+1);26 g_string_append_len(out, ptr1, ptr2-ptr1+1); 26 27 } 27 28 ptr1=ptr2+1; 28 29 } 30 return g_string_free(out, false); 29 31 } 30 32
Note: See TracChangeset
for help on using the changeset viewer.