toolbox

Check-in [8dbe9c62f5]
Login

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

Overview
Comment:lib: cosmetic changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8dbe9c62f56f76836294a40d4291780c3686b3ea2d3f80b36867ea5c4bd28c58
User & Date: jef 2020-07-19 09:16:48
Context
2020-07-19
17:15
lib: cosmetic changes check-in: e9fdbcbff2 user: jef tags: trunk
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/include/jt.h.

110
111
112
113
114
115
116
117
118
119
char *str_trim(char *str);

char *str_replace(const char *str, const char *pattern, const char *repl);
char *str_cpy(char *dst, const char *src, const char *end);
char *str_repeat(char *pattern, size_t n);

char *str_join(const char *items[], size_t size, const char *sep);
void str_split(const char *src, const char *sep, struct jtlst *head);

#endif







|


110
111
112
113
114
115
116
117
118
119
char *str_trim(char *str);

char *str_replace(const char *str, const char *pattern, const char *repl);
char *str_cpy(char *dst, const char *src, const char *end);
char *str_repeat(char *pattern, size_t n);

char *str_join(const char *items[], size_t size, const char *sep);
void str_split(const char *src, const char *sep, struct jtlst *list);

#endif

Changes to src/lib/jtlst.c.

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
}

void *
jtlst_pop(struct jtlst *list)
{
	struct jtlst_node *next;

	if (&list->head == list->head.next)
		return NULL;

	next = list->head.next;
	list->head.next = list->head.next->next;
	list->size--;

	return (void *) ((char *)next - list->offset);
}

size_t
jtlst_size(struct jtlst *list)







|



|







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
}

void *
jtlst_pop(struct jtlst *list)
{
	struct jtlst_node *next;

	if (list->size == 0)
		return NULL;

	next = list->head.next;
	list->head.next = next->next;
	list->size--;

	return (void *) ((char *)next - list->offset);
}

size_t
jtlst_size(struct jtlst *list)

Changes to src/lib/jtstr.c.

138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
		p += len;
	}

	return res;
}

void
str_split(const char *str, const char *sep, struct jtlst *head)
{
	struct jtlst_str *field;
	const char *p = str;

	while ((p = strstr(str, sep)) != NULL) {
		field = xcalloc(1, sizeof(struct jtlst_str));
		field->str = xstrndup(str, p - str);
		jtlst_append(head, &field->node);
		str = p + strlen(sep);
	}
	field = xcalloc(1, sizeof(struct jtlst_str));
	field->str = xstrdup(str);
	jtlst_append(head, &field->node);
}








|







|




|


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
		p += len;
	}

	return res;
}

void
str_split(const char *str, const char *sep, struct jtlst *list)
{
	struct jtlst_str *field;
	const char *p = str;

	while ((p = strstr(str, sep)) != NULL) {
		field = xcalloc(1, sizeof(struct jtlst_str));
		field->str = xstrndup(str, p - str);
		jtlst_append(list, &field->node);
		str = p + strlen(sep);
	}
	field = xcalloc(1, sizeof(struct jtlst_str));
	field->str = xstrdup(str);
	jtlst_append(list, &field->node);
}

Changes to src/retab/retab.c.

165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
		jtbuf_free(buf);
	}
}

void
max_widths(struct jtlst *maxwidths, struct jtlst *cols)
{
	struct jtlst_iter i1;
	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);







|
<







165
166
167
168
169
170
171
172

173
174
175
176
177
178
179
		jtbuf_free(buf);
	}
}

void
max_widths(struct jtlst *maxwidths, struct jtlst *cols)
{
	struct jtlst_iter i1, 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);