toolbox

Check-in [c4678b759f]
Login

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

Overview
Comment:retab: improve table_widths()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c4678b759f6b7c6718e21f5b5fbdc957c009c32ee0e167cb9631fa160a8c3393
User & Date: jef 2020-05-01 14:22:59
Context
2020-05-01
14:28
retab: remove unnecessary check check-in: ab0b7a818c user: jef tags: trunk
14:22
retab: improve table_widths() check-in: c4678b759f user: jef tags: trunk
11:44
retab: fix memory leak check-in: 87d8a0bbf2 user: jef tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/retab/retab.c.

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

205

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231

	return res;
}

jtlst *
table_widths(jtlst *rows)
{
	jtlst *allwidths, *width, *res, *tmp;
	struct row *row;
	int first = 1;

	allwidths = jtlst_new();
	JTLST_FOREACH(row, rows) {
		if (row->is_line)
			continue;

		jtlst_append(allwidths, row->fields_widths);

	}

	if (jtlst_size(allwidths) == 0) {
		jtlst_free(allwidths);
		return NULL;
	}

	jtlst_pop(allwidths, (void **) &res);
	while (jtlst_pop(allwidths, (void **) &width)) {
		tmp = max_widths(res, width);
		if (! first) {
			jtlst_free(res);
		}
		first = 0;
		res = tmp;
	}

	jtlst_free(allwidths);

	return res;
}

void
retab()
{
	char *line = NULL;







|

<

<



>
|
>
|
<
<
|
<
<
<
<
<
|
<

<
<
|
|
|
<








190
191
192
193
194
195
196
197
198

199

200
201
202
203
204
205
206


207





208

209


210
211
212

213
214
215
216
217
218
219
220

	return res;
}

jtlst *
table_widths(jtlst *rows)
{
	jtlst *tmp, *res = NULL;
	struct row *row;



	JTLST_FOREACH(row, rows) {
		if (row->is_line)
			continue;
		else if (res == NULL) {
			res = jtlst_clone(row->fields_widths);
			continue;
		}


		else {





			tmp = max_widths(res, row->fields_widths);

			jtlst_free(res);


			res = tmp;
		}
	}


	return res;
}

void
retab()
{
	char *line = NULL;