Changeset 1433ecda in mainline for uspace/lib/fmtutil/fmtutil.c
- Timestamp:
- 2018-04-04T15:42:37Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2c4e1cc
- Parents:
- 47b2d7e3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/fmtutil/fmtutil.c
r47b2d7e3 r1433ecda 101 101 putchar(' '); 102 102 } 103 } 104 else if (mode == ALIGN_RIGHT) { 103 } else if (mode == ALIGN_RIGHT) { 105 104 for (i = 0; i < width; i++) { 106 105 if (i < width - len) 107 106 putchar(' '); 108 107 else 109 putchar(wstr[i- (width - len)]); 110 } 111 } 112 else if (mode == ALIGN_CENTER) { 108 putchar(wstr[i - (width - len)]); 109 } 110 } else if (mode == ALIGN_CENTER) { 113 111 size_t padding = (width - len) / 2; 114 112 for (i = 0; i < width; i++) { … … 116 114 putchar(' '); 117 115 else 118 putchar(wstr[i-padding]); 119 } 120 } 121 else if (mode == ALIGN_JUSTIFY) { 116 putchar(wstr[i - padding]); 117 } 118 } else if (mode == ALIGN_JUSTIFY) { 122 119 size_t words = 0; 123 120 size_t word_chars = 0; … … 128 125 } 129 126 space = wstr[i] == ' '; 130 if (!space) word_chars++; 127 if (!space) 128 word_chars++; 131 129 } 132 130 size_t done_words = 0; … … 134 132 if (words == 0) 135 133 goto skip_words; 136 size_t excess_spaces = width - word_chars - (words -1);134 size_t excess_spaces = width - word_chars - (words - 1); 137 135 space = true; 138 136 i = 0; … … 140 138 while (i < len) { 141 139 /* Find a word */ 142 while (i < len && wstr[i] == ' ') i++; 143 if (i == len) break; 140 while (i < len && wstr[i] == ' ') 141 i++; 142 if (i == len) 143 break; 144 144 if (done_words) { 145 145 size_t spaces = 1 + (((done_words * … … 158 158 done_words++; 159 159 } 160 skip_words:160 skip_words: 161 161 while (done_chars < width) { 162 162 putchar(' '); 163 163 done_chars++; 164 164 } 165 } 166 else { 165 } else { 167 166 return EINVAL; 168 167 }
Note:
See TracChangeset
for help on using the changeset viewer.