Commit ca6b9955 by Per Bothner Committed by Per Bothner

jcf-parse.c (set_source_filename): Improvement to Andrew's fix...


	* jcf-parse.c (set_source_filename):  Improvement to Andrew's fix:
	Fix fencepost error in 'i', which got executed one too many times.
	Also, fold memcpy into explicit loop, as originally intended.
	Also, free temporary 'buf' which otherwise leaks.

From-SVN: r91411
parent ad500466
2004-11-27 Per Bothner <per@bothner.com>
* jcf-parse.c (set_source_filename): Improvement to Andrew's fix:
Fix fencepost error in 'i', which got executed one too many times.
Also, fold memcpy into explicit loop, as originally intended.
Also, free temporary 'buf' which otherwise leaks.
2004-11-27 Per Bothner <per@bothner.com>
* expr.c (build_expr_wfl): Only declare last_file and last_filenode
local static variables if not USE_MAPPED_LOCATION.
......
......@@ -151,18 +151,22 @@ set_source_filename (JCF *jcf, int index)
char *dot = strrchr (class_name, '.');
if (dot != NULL)
{
int i = dot - class_name + 1;
/* Length of prefix, not counting final dot. */
int i = dot - class_name;
/* Concatenate current package prefix with new sfname. */
char *buf = xmalloc (i+new_len+3);
memcpy (buf, class_name, i);
strcpy (buf + i, sfname);
/* Replace '.' by DIR_SEPARATOR. */
char *buf = xmalloc (i + new_len + 2); /* Space for '.' and '\0'. */
strcpy (buf + i + 1, sfname);
/* Copy package from class_name, replacing '.' by DIR_SEPARATOR.
Note we start at the end with the final package dot. */
for (; i >= 0; i--)
{
if (buf[i] == '.')
buf[i] = DIR_SEPARATOR;
char c = class_name[i];
if (c == '.')
c = DIR_SEPARATOR;
buf[i] = c;
}
sfname_id = get_identifier (buf);
free (buf);
sfname = IDENTIFIER_POINTER (sfname_id);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment