Lines Matching +full:i +full:- +full:leak +full:- +full:current
1 // SPDX-License-Identifier: GPL-2.0-or-later
33 int len = slash - path; in get_dirname()
51 int i, len = strlen(fname); in set_initial_path() local
55 for (i = 0; i != len; i++) in set_initial_path()
56 if (initial_path[i] == '/') in set_initial_path()
75 int diff = initial_pathlen - slashes, i, j; in shorten_to_initial_path() local
76 int restlen = strlen(fname) - (p1 - fname); in shorten_to_initial_path()
80 for (i = 0, j = 0; i != diff; i++) { in shorten_to_initial_path()
135 /* Try current directory first */ in fopen_any_on_path()
138 cur_dir = current_srcfile->dir; in fopen_any_on_path()
142 for (node = search_path_head; !*fp && node; node = node->next) in fopen_any_on_path()
143 fullname = try_open(node->dirname, fname, fp); in fopen_any_on_path()
153 if (streq(fname, "-")) { in srcfile_relative_open()
183 srcfile->f = srcfile_relative_open(fname, &srcfile->name); in srcfile_push()
184 srcfile->dir = get_dirname(srcfile->name); in srcfile_push()
185 srcfile->prev = current_srcfile; in srcfile_push()
187 srcfile->lineno = 1; in srcfile_push()
188 srcfile->colno = 1; in srcfile_push()
193 set_initial_path(srcfile->name); in srcfile_push()
202 current_srcfile = srcfile->prev; in srcfile_pop()
204 if (fclose(srcfile->f)) in srcfile_pop()
205 die("Error closing \"%s\": %s\n", srcfile->name, in srcfile_pop()
208 /* FIXME: We allow the srcfile_state structure to leak, in srcfile_pop()
223 node->next = NULL; in srcfile_add_search_path()
224 node->dirname = xstrdup(dirname); in srcfile_add_search_path()
231 search_path_tail = &node->next; in srcfile_add_search_path()
236 int i; in srcpos_update() local
238 pos->file = current_srcfile; in srcpos_update()
240 pos->first_line = current_srcfile->lineno; in srcpos_update()
241 pos->first_column = current_srcfile->colno; in srcpos_update()
243 for (i = 0; i < len; i++) in srcpos_update()
244 if (text[i] == '\n') { in srcpos_update()
245 current_srcfile->lineno++; in srcpos_update()
246 current_srcfile->colno = 1; in srcpos_update()
248 current_srcfile->colno++; in srcpos_update()
251 pos->last_line = current_srcfile->lineno; in srcpos_update()
252 pos->last_column = current_srcfile->colno; in srcpos_update()
265 assert(pos->next == NULL); in srcpos_copy()
270 memcpy(srcfile_state, pos->file, sizeof(struct srcfile_state)); in srcpos_copy()
271 pos_new->file = srcfile_state; in srcpos_copy()
283 for (p = pos; p->next != NULL; p = p->next); in srcpos_extend()
284 p->next = newtail; in srcpos_extend()
291 const char *fname = "<no-file>"; in srcpos_string()
294 if (pos->file && pos->file->name) in srcpos_string()
295 fname = pos->file->name; in srcpos_string()
298 if (pos->first_line != pos->last_line) in srcpos_string()
299 xasprintf(&pos_str, "%s:%d.%d-%d.%d", fname, in srcpos_string()
300 pos->first_line, pos->first_column, in srcpos_string()
301 pos->last_line, pos->last_column); in srcpos_string()
302 else if (pos->first_column != pos->last_column) in srcpos_string()
303 xasprintf(&pos_str, "%s:%d.%d-%d", fname, in srcpos_string()
304 pos->first_line, pos->first_column, in srcpos_string()
305 pos->last_column); in srcpos_string()
308 pos->first_line, pos->first_column); in srcpos_string()
321 xasprintf(&pos_str, "<no-file>:<no-line>"); in srcpos_string_comment()
328 if (!pos->file) in srcpos_string_comment()
329 fname = "<no-file>"; in srcpos_string_comment()
330 else if (!pos->file->name) in srcpos_string_comment()
331 fname = "<no-filename>"; in srcpos_string_comment()
333 fname = pos->file->name; in srcpos_string_comment()
335 fresh_fname = shorten_to_initial_path(pos->file->name); in srcpos_string_comment()
339 fname = pos->file->name; in srcpos_string_comment()
343 xasprintf(&first, "%s:%d:%d-%d:%d", fname, in srcpos_string_comment()
344 pos->first_line, pos->first_column, in srcpos_string_comment()
345 pos->last_line, pos->last_column); in srcpos_string_comment()
348 first_line ? pos->first_line : pos->last_line); in srcpos_string_comment()
353 if (pos->next != NULL) { in srcpos_string_comment()
354 rest = srcpos_string_comment(pos->next, first_line, level); in srcpos_string_comment()
401 current_srcfile->name = f; in srcpos_set_line()
402 current_srcfile->lineno = l; in srcpos_set_line()