From: Peter Johnson Date: Sat, 11 Feb 2006 21:33:51 +0000 (-0000) Subject: * linemgr.h (yasm_linemap_traverse_filenames): New function to go through all X-Git-Tag: v0.5.0rc1~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb15d52a37a97decedaff7b73cfe8d37cb8f753e;p=yasm * linemgr.h (yasm_linemap_traverse_filenames): New function to go through all filenames used by linemgr. * linemgr.c (yasm_linemap_traverse_filenames): Implement. svn path=/trunk/yasm/; revision=1373 --- diff --git a/libyasm/linemgr.c b/libyasm/linemgr.c index e7ca9c48..01b10743 100644 --- a/libyasm/linemgr.c +++ b/libyasm/linemgr.c @@ -240,6 +240,13 @@ yasm_linemap_lookup(yasm_linemap *linemap, unsigned long line, *file_line = mapping->file_line + mapping->line_inc*(line-mapping->line); } +int +yasm_linemap_traverse_filenames(yasm_linemap *linemap, /*@null@*/ void *d, + int (*func) (const char *filename, void *d)) +{ + return HAMT_traverse(linemap->filenames, d, (int (*) (void *, void *))func); +} + int yasm_linemap_get_source(yasm_linemap *linemap, unsigned long line, yasm_bytecode **bcp, const char **sourcep) diff --git a/libyasm/linemgr.h b/libyasm/linemgr.h index f1507493..fecf621a 100644 --- a/libyasm/linemgr.h +++ b/libyasm/linemgr.h @@ -101,4 +101,17 @@ void yasm_linemap_set(yasm_linemap *linemap, /*@null@*/ const char *filename, void yasm_linemap_lookup(yasm_linemap *linemap, unsigned long line, /*@out@*/ const char **filename, /*@out@*/ unsigned long *file_line); + +/** Traverses all filenames used in a linemap, calling a function on each + * filename. + * \param linemap line mapping repository + * \param d data pointer passed to func on each call + * \param func function + * \return Stops early (and returns func's return value) if func returns a + * nonzero value; otherwise 0. + */ +int yasm_linemap_traverse_filenames + (yasm_linemap *linemap, /*@null@*/ void *d, + int (*func) (const char *filename, void *d)); + #endif