[PATCH 3/8] Enhance source position implementation.

Scott Wood scottwood at freescale.com
Thu Sep 25 03:23:10 EST 2008


Jon Loeliger wrote:
> +char *
> +srcpos_string(srcpos *pos)
> +{
> +#	define POS_BUF_SIZE	(100)
> +
> +	const char *fname;
> +	char buf[POS_BUF_SIZE];
> +
> +	if (pos->file && pos->file->name)
> +		fname = pos->file->name;
> +	else
> +		fname = "<no-file>";
> +
> +	if (pos->first_line == pos->last_line) {
> +		if (pos->first_column == pos->last_column) {
> +			snprintf(buf, POS_BUF_SIZE, "%s %d:%d",
> +				 fname, pos->first_line, pos->first_column);

Oh, another thing -- if the filename is over 100 characters (due to 
having directory components included, for example), this will cut off 
the most useful information (the line/column info), and the second most 
useful information (the end of the file name, rather than the leading 
path components).

If we wrote directly to a FILE *, this would be a non-issue.

-Scott



More information about the devicetree-discuss mailing list