]> granicus.if.org Git - yasm/commitdiff
* libyasm.h (yasm_linemap_set): Allow NULL filename to indicate unchanged.
authorPeter Johnson <peter@tortall.net>
Wed, 2 Nov 2005 08:14:01 +0000 (08:14 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 2 Nov 2005 08:14:01 +0000 (08:14 -0000)
* libyasm.c (yasm_linemap_set): Implement.

svn path=/trunk/yasm/; revision=1305

libyasm/linemgr.c
libyasm/linemgr.h

index 6cccd598c186d83dcfe3356fed776597cd5ca359..e7ca9c485adb942f18138726464baf75f8a4804b 100644 (file)
@@ -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;
index 1beffc0e3fbf7f9429c5f5bc24c1a77dc63c6f46..b1e838b8d1c4232d615ee16164e2ba2f221c9b17 100644 (file)
@@ -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.