From: Peter Johnson Date: Wed, 2 Nov 2005 08:14:01 +0000 (-0000) Subject: * libyasm.h (yasm_linemap_set): Allow NULL filename to indicate unchanged. X-Git-Tag: v0.5.0rc1~73 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81a6ef76d87f10d07af7971e609d58d7c8df3db5;p=yasm * libyasm.h (yasm_linemap_set): Allow NULL filename to indicate unchanged. * libyasm.c (yasm_linemap_set): Implement. svn path=/trunk/yasm/; revision=1305 --- diff --git a/libyasm/linemgr.c b/libyasm/linemgr.c index 6cccd598..e7ca9c48 100644 --- a/libyasm/linemgr.c +++ b/libyasm/linemgr.c @@ -105,12 +105,21 @@ yasm_linemap_set(yasm_linemap *linemap, const char *filename, /* Fill it */ - /* Copy the filename (via shared storage) */ - copy = yasm__xstrdup(filename); - /*@-aliasunique@*/ - mapping->filename = HAMT_insert(linemap->filenames, copy, copy, &replace, - filename_delete_one); - /*@=aliasunique@*/ + if (!filename) { + if (linemap->map->size >= 2) + mapping->filename = + linemap->map->vector[linemap->map->size-2].filename; + else + filename = "unknown"; + } + if (filename) { + /* Copy the filename (via shared storage) */ + copy = yasm__xstrdup(filename); + /*@-aliasunique@*/ + mapping->filename = HAMT_insert(linemap->filenames, copy, copy, + &replace, filename_delete_one); + /*@=aliasunique@*/ + } mapping->line = linemap->current; mapping->file_line = file_line; diff --git a/libyasm/linemgr.h b/libyasm/linemgr.h index 1beffc0e..b1e838b8 100644 --- a/libyasm/linemgr.h +++ b/libyasm/linemgr.h @@ -85,11 +85,11 @@ unsigned long yasm_linemap_goto_next(yasm_linemap *linemap); * virtual line. line_inc indicates how much the "real" line is incremented * by for each virtual line increment (0 is perfectly legal). * \param linemap line mapping repository - * \param filename physical file name + * \param filename physical file name (if NULL, not changed) * \param file_line physical line number * \param line_inc line increment */ -void yasm_linemap_set(yasm_linemap *linemap, const char *filename, +void yasm_linemap_set(yasm_linemap *linemap, /*@null@*/ const char *filename, unsigned long file_line, unsigned long line_inc); /** Look up the associated physical file and line for a virtual line.