~strahinja/poe

006680fded4a1fffc5b86983425524e6eb12c77c — Страхиња Радић 5 months ago d6b533b
Reformat using clang-format, remove commented debug output

Signed-off-by: Страхиња Радић <contact@strahinja.org>
4 files changed, 23 insertions(+), 41 deletions(-)

M draw.c
M draw.h
M po.c
M poe.c
M draw.c => draw.c +2 -2
@@ 172,8 172,8 @@ format_msgs(char* result, size_t result_size, const char* format,
	if (!result)
		return;

	snprintf(result, result_size, format, state ?
	real_msgid_to_display_msgid(state) : 0,
	snprintf(result, result_size, format,
		state ? real_msgid_to_display_msgid(state) : 0,
		state ? state->msgid_count : 0,
		state ? state->untranslated_count : 0,
		state ? state->fuzzy_count : 0,

M draw.h => draw.h +2 -2
@@ 79,8 79,8 @@ struct DrawState {
	int show_search;
	int maxx;
	int maxy;
	size_t msgid_number;	/* "real" msgid (inc. obsolete msgids) */
	size_t msgid_count;	/* without obsolete msgids */
	size_t msgid_number; /* "real" msgid (inc. obsolete msgids) */
	size_t msgid_count;  /* without obsolete msgids */
	size_t msgid_size;
	size_t fuzzy_count;
	size_t untranslated_count;

M po.c => po.c +3 -19
@@ 494,40 494,24 @@ load_file(struct DrawState* dstate, long* lineno, long* col)
	update_statistics(dstate->entries, dstate, entry);
	dstate->real_msgid_count = dstate->msgid_count + dstate->obsolete_count;

	//FILE* logfile = fopen("logfile.log", "w");
	current = dstate->entries;
	while (current != dstate->entries + dstate->real_msgid_count)
	{
		char u8buf[4096];
		*u8buf = 0;
		if (current->msgid)
			unicode_string_to_u8(u8buf, current->msgid,
				4096);
		/*fprintf(logfile, "ENTRY #%lu\n",
			current - dstate->entries);
		fprintf(logfile, "ENTRY: msgid={%s}\n",
			*u8buf ? (char*)u8buf : "(NULL)");*/
			unicode_string_to_u8(u8buf, current->msgid, 4096);
		*u8buf = 0;
		if (current->msgstr && current->msgstr[0])
			unicode_string_to_u8(u8buf, current->msgstr[0],
				4096);
		/*fprintf(logfile, "ENTRY: msgstr={%s}\n",
			*u8buf ? (char*)u8buf : "(NULL)");*/
			unicode_string_to_u8(u8buf, current->msgstr[0], 4096);
		*u8buf = 0;
		if (current->comments && current->comments[0])
			unicode_string_to_u8(u8buf, current->comments[0],
				4096);
		/*fprintf(logfile, "ENTRY: comments={%s}\n",
			*u8buf ? (char*)u8buf : "(NULL)");
		fprintf(logfile, "ENTRY: obsolete? %s\n",
			current->obsolete ? "YES" : "NO");*/
			unicode_string_to_u8(u8buf, current->comments[0], 4096);
		if (!current->obsolete && current->msgid && current->msgstr)
			update_warning(current->msgid, *current->msgstr,
				&current->warning);
		//fprintf(logfile, "\n");
		current++;
	}
	//fclose(logfile);

	return LOAD_ERR_NONE;
}

M poe.c => poe.c +16 -18
@@ 59,19 59,18 @@ cancel_callback(struct DrawState* state, struct tb_event* ev)
void
goto_msgid(struct DrawState* state, const size_t msgid_number)
{
	if (msgid_number > state->real_msgid_count+1)
	if (msgid_number > state->real_msgid_count + 1)
		return;
	state->msgid_number = msgid_number;
	if (state->msgid_number < state->first_shown_msgid)
		state->first_shown_msgid = state->msgid_number;
	else if (state->msgid_number
		> state->first_shown_msgid + state->maxy - 2)
		state->first_shown_msgid = state->msgid_number
			- (state->maxy - 2);
	else if (state->real_msgid_count
		< state->msgid_number + state->maxy - 2)
		state->first_shown_msgid
			= (state->real_msgid_count > state->maxy - 2
			= state->msgid_number - (state->maxy - 2);
	else if (state->real_msgid_count < state->msgid_number + state->maxy - 2)
		state->first_shown_msgid = (state->real_msgid_count
					> state->maxy - 2
				? state->real_msgid_count - (state->maxy - 2)
				: 1);
	else


@@ 487,24 486,24 @@ load_info(struct DrawState* state)
size_t
next_msgid(struct DrawState* state, const int delta)
{
	size_t ret = state->msgid_number;
	size_t ret   = state->msgid_number;
	size_t start = ret;

	while (ret < state->real_msgid_count+1)
	while (ret < state->real_msgid_count + 1)
	{
		ret++;
		if (!state->entries[ret-1].obsolete
			&& ret >= start + delta)
		if (!state->entries[ret - 1].obsolete && ret >= start + delta)
			break;
	}

	return ret == state->real_msgid_count+1 ? state->real_msgid_count : ret;
	return ret == state->real_msgid_count + 1 ? state->real_msgid_count
						  : ret;
}

size_t
prev_msgid(struct DrawState* state, const int delta)
{
	size_t ret = state->msgid_number;
	size_t ret   = state->msgid_number;
	size_t start = ret;

	if (start < delta)


@@ 513,8 512,7 @@ prev_msgid(struct DrawState* state, const int delta)
	while (ret > 1)
	{
		ret--;
		if (!state->entries[ret-1].obsolete
			&& ret <= start - delta)
		if (!state->entries[ret - 1].obsolete && ret <= start - delta)
			break;
	}



@@ 525,7 523,7 @@ size_t
msgid_to_real_msgid(struct DrawState* state, const size_t msgid)
{
	size_t ret = 0;
	size_t i = 0;
	size_t i   = 0;

	do
	{


@@ 646,12 644,12 @@ size_t
real_msgid_to_display_msgid(const struct DrawState* state)
{
	struct PoEntry* current = state->entries;
	size_t ret = state->msgid_count ? 1 : 0;
	size_t ret		= state->msgid_count ? 1 : 0;

	while (current != state->entries + state->msgid_number - 1)
	{
		if (!current->obsolete && current != state->entries +
		state->msgid_number - 1)
		if (!current->obsolete
			&& current != state->entries + state->msgid_number - 1)
			ret++;
		current++;
	}