MCPcopy Create free account
hub / github.com/coreutils/coreutils / adjust_column

Function adjust_column

src/fold.c:114–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 The first column is 0. */
113
114static size_t
115adjust_column (size_t column, mcel_t g)
116{
117 if (counting_mode != COUNT_BYTES)
118 {
119 if (g.ch == '\b')
120 {
121 if (column > 0)
122 column -= last_character_width;
123 }
124 else if (g.ch == '\r')
125 column = 0;
126 else if (g.ch == '\t')
127 column += TAB_WIDTH - column % TAB_WIDTH;
128 else
129 {
130 if (counting_mode == COUNT_CHARACTERS)
131 last_character_width = 1;
132 else
133 {
134 int width = c32width (g.ch);
135 /* Default to a width of 1 if there is an invalid character. */
136 last_character_width = width < 0 ? 1 : width;
137 }
138 column += last_character_width;
139 }
140 }
141 else
142 column += g.len;
143 return column;
144}
145
146static void
147write_out (char const *line, size_t line_len, bool newline)

Callers 1

fold_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected