New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cleanup in the highlighting signal. #590

Merged
merged 1 commit into from Jan 31, 2017

Conversation

Projects
None yet
3 participants
@LemonBoy
Member

LemonBoy commented Dec 18, 2016

¯\_(ツ)_/¯

/* start of the line */
pos = strip_real_length(text, hilight_start, NULL, NULL);
g_string_append(tmp, text);
g_string_truncate(tmp, pos);
tmp = g_string_new_len(text, pos);

This comment has been minimized.

@ailin-nemui

ailin-nemui Jan 2, 2017

Contributor

this does not feel save if strlen(text) < pos

This comment has been minimized.

@LemonBoy

LemonBoy Jan 2, 2017

Member

Is that even possible? I expect pos to be <= strlen

This comment has been minimized.

@ailin-nemui

ailin-nemui Jan 2, 2017

Contributor

maybe it isn't... :)

This comment has been minimized.

@dequis

dequis Jan 14, 2017

Member
/* Return how many characters in `str' must be skipped before `len'
   characters of text is skipped. */
int strip_real_length(const char *str, int len,
		      int *last_color_pos, int *last_color_len)
{
	const char *start = str;
	/*...*/
	while (*str != '\0') {
		/*...*/
	}
	return (int) (str-start);
}

strip_real_length would need to read past the end of the string to return something bigger than its length.

@ailin-nemui ailin-nemui merged commit 1ee25d2 into irssi:master Jan 31, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment