- Timestamp:
- Feb 4, 2011, 3:49:44 PM (14 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.