toolbox

Check-in [040954acea]
Login

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

Overview
Comment:retab: cosmetic changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 040954acea6d39e0a3a27ed7b4532b1ed71023e355b739d02ce73982ca2c92f2
User & Date: jef 2020-04-29 13:11:23
Context
2020-05-01
08:42
retab: use struct to rearrange the code check-in: 7fcee8800c user: jef tags: trunk
2020-04-29
13:11
retab: cosmetic changes check-in: 040954acea user: jef tags: trunk
12:33
lib: fix bug in jtlst_pop() check-in: f3fbfada10 user: jef tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/retab/retab.c.

17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
...
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
232
		"Usage:\n"
		"	" PROGNAME " < table.txt\n"
		"Options:\n"
		"	-h : display this help and exit\n");
	exit(1);
}


size_t max(size_t a, size_t b)
{
	return a > b ? a : b;
}

int
is_line(const char *str)
{
................................................................................

void
retab()
{
	char *line = NULL;
	jtlst *lines, *widths;

	// get lines
	lines = jtlst_new();
	while (read_line(&line))
		jtlst_append(lines, line);

	if (jtlst_size(lines) == 0)
		return;

	// compute cols widths
	widths = table_widths(lines);
	if (widths == NULL)
		die("abort, table without rows");

	// render
	JTLST_FOREACH(line, lines)
		line_render(line, widths);

	jtlst_free_all(lines);
	jtlst_free(widths);
}








>
|







 







<







<




<







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
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
		"Usage:\n"
		"	" PROGNAME " < table.txt\n"
		"Options:\n"
		"	-h : display this help and exit\n");
	exit(1);
}

size_t
max(size_t a, size_t b)
{
	return a > b ? a : b;
}

int
is_line(const char *str)
{
................................................................................

void
retab()
{
	char *line = NULL;
	jtlst *lines, *widths;


	lines = jtlst_new();
	while (read_line(&line))
		jtlst_append(lines, line);

	if (jtlst_size(lines) == 0)
		return;


	widths = table_widths(lines);
	if (widths == NULL)
		die("abort, table without rows");


	JTLST_FOREACH(line, lines)
		line_render(line, widths);

	jtlst_free_all(lines);
	jtlst_free(widths);
}