toolbox

Check-in [83160f9bc8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:retab: adapt to new jtlst_iter design
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 83160f9bc8c1c02132dff0323e6ac1258fc47f9c18c8d159c54e5b371efb6c2d
User & Date: jef 2020-07-18 08:46:40
Context
2020-07-19
09:16
lib: cosmetic changes check-in: 8dbe9c62f5 user: jef tags: trunk
2020-07-18
08:46
retab: adapt to new jtlst_iter design check-in: 83160f9bc8 user: jef tags: trunk
08:46
lib: rework jtlst_iter check-in: 8b222eb2dc user: jef tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/retab/retab.c.

142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
	if (row->is_line) {
		nchars = wsum + (jtlst_size(maxwidths) -1) * 3 + 4;
		line = str_repeat("-", nchars);
		puts(line);
		xfree(line);
	} else {
		buf = jtbuf_new();
		jtlst_iter(maxwidths, &i1);
		jtlst_iter(&row->cols, &i2);
		while ((colwidth = jtlst_iter_next(&i1)) && (col = jtlst_iter_next(&i2))) {
			if (first) {
				buf = jtbuf_append_str(buf, "| ");
				first = 0;
			} else {
				buf = jtbuf_append_str(buf, " | ");
			}
................................................................................
	struct jtlst_iter i2;
	struct colwidth *colwidth;
	struct jtlst_str *col;

	if (jtlst_size(maxwidths) != jtlst_size(cols))
		die("rows with different number of fields");

	jtlst_iter(maxwidths, &i1);
	jtlst_iter(cols, &i2);

	while ((colwidth = jtlst_iter_next(&i1)) && (col = jtlst_iter_next(&i2)))
		colwidth->width = max(colwidth->width, utf8len(col->str));
}

struct jtlst *
table_widths(struct jtlst *rows)







|
|







 







|
|







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
	if (row->is_line) {
		nchars = wsum + (jtlst_size(maxwidths) -1) * 3 + 4;
		line = str_repeat("-", nchars);
		puts(line);
		xfree(line);
	} else {
		buf = jtbuf_new();
		i1 = jtlst_iter_start(maxwidths);
		i2 = jtlst_iter_start(&row->cols);
		while ((colwidth = jtlst_iter_next(&i1)) && (col = jtlst_iter_next(&i2))) {
			if (first) {
				buf = jtbuf_append_str(buf, "| ");
				first = 0;
			} else {
				buf = jtbuf_append_str(buf, " | ");
			}
................................................................................
	struct jtlst_iter i2;
	struct colwidth *colwidth;
	struct jtlst_str *col;

	if (jtlst_size(maxwidths) != jtlst_size(cols))
		die("rows with different number of fields");

	i1 = jtlst_iter_start(maxwidths);
	i2 = jtlst_iter_start(cols);

	while ((colwidth = jtlst_iter_next(&i1)) && (col = jtlst_iter_next(&i2)))
		colwidth->width = max(colwidth->width, utf8len(col->str));
}

struct jtlst *
table_widths(struct jtlst *rows)