Lines Matching +full:i +full:- +full:leak +full:- +full:current

1 // SPDX-License-Identifier: GPL-2.0-or-later
31 int len = slash - path; in get_dirname()
49 int i, len = strlen(fname); in set_initial_path() local
53 for (i = 0; i != len; i++) in set_initial_path()
54 if (initial_path[i] == '/') in set_initial_path()
73 int diff = initial_pathlen - slashes, i, j; in shorten_to_initial_path() local
74 int restlen = strlen(fname) - (p1 - fname); in shorten_to_initial_path()
78 for (i = 0, j = 0; i != diff; i++) { in shorten_to_initial_path()
133 /* Try current directory first */ in fopen_any_on_path()
136 cur_dir = current_srcfile->dir; in fopen_any_on_path()
140 for (node = search_path_head; !*fp && node; node = node->next) in fopen_any_on_path()
141 fullname = try_open(node->dirname, fname, fp); in fopen_any_on_path()
151 if (streq(fname, "-")) { in srcfile_relative_open()
181 srcfile->f = srcfile_relative_open(fname, &srcfile->name); in srcfile_push()
182 srcfile->dir = get_dirname(srcfile->name); in srcfile_push()
183 srcfile->prev = current_srcfile; in srcfile_push()
185 srcfile->lineno = 1; in srcfile_push()
186 srcfile->colno = 1; in srcfile_push()
191 set_initial_path(srcfile->name); in srcfile_push()
200 current_srcfile = srcfile->prev; in srcfile_pop()
202 if (fclose(srcfile->f)) in srcfile_pop()
203 die("Error closing \"%s\": %s\n", srcfile->name, in srcfile_pop()
206 /* FIXME: We allow the srcfile_state structure to leak, in srcfile_pop()
221 node->next = NULL; in srcfile_add_search_path()
222 node->dirname = xstrdup(dirname); in srcfile_add_search_path()
229 search_path_tail = &node->next; in srcfile_add_search_path()
234 int i; in srcpos_update() local
236 pos->file = current_srcfile; in srcpos_update()
238 pos->first_line = current_srcfile->lineno; in srcpos_update()
239 pos->first_column = current_srcfile->colno; in srcpos_update()
241 for (i = 0; i < len; i++) in srcpos_update()
242 if (text[i] == '\n') { in srcpos_update()
243 current_srcfile->lineno++; in srcpos_update()
244 current_srcfile->colno = 1; in srcpos_update()
246 current_srcfile->colno++; in srcpos_update()
249 pos->last_line = current_srcfile->lineno; in srcpos_update()
250 pos->last_column = current_srcfile->colno; in srcpos_update()
263 assert(pos->next == NULL); in srcpos_copy()
268 memcpy(srcfile_state, pos->file, sizeof(struct srcfile_state)); in srcpos_copy()
269 pos_new->file = srcfile_state; in srcpos_copy()
281 for (p = pos; p->next != NULL; p = p->next); in srcpos_extend()
282 p->next = newtail; in srcpos_extend()
289 const char *fname = "<no-file>"; in srcpos_string()
292 if (pos->file && pos->file->name) in srcpos_string()
293 fname = pos->file->name; in srcpos_string()
296 if (pos->first_line != pos->last_line) in srcpos_string()
297 xasprintf(&pos_str, "%s:%d.%d-%d.%d", fname, in srcpos_string()
298 pos->first_line, pos->first_column, in srcpos_string()
299 pos->last_line, pos->last_column); in srcpos_string()
300 else if (pos->first_column != pos->last_column) in srcpos_string()
301 xasprintf(&pos_str, "%s:%d.%d-%d", fname, in srcpos_string()
302 pos->first_line, pos->first_column, in srcpos_string()
303 pos->last_column); in srcpos_string()
306 pos->first_line, pos->first_column); in srcpos_string()
319 xasprintf(&pos_str, "<no-file>:<no-line>"); in srcpos_string_comment()
326 if (!pos->file) in srcpos_string_comment()
327 fname = "<no-file>"; in srcpos_string_comment()
328 else if (!pos->file->name) in srcpos_string_comment()
329 fname = "<no-filename>"; in srcpos_string_comment()
331 fname = pos->file->name; in srcpos_string_comment()
333 fname = shorten_to_initial_path(pos->file->name); in srcpos_string_comment()
337 fname = pos->file->name; in srcpos_string_comment()
341 xasprintf(&first, "%s:%d:%d-%d:%d", fname, in srcpos_string_comment()
342 pos->first_line, pos->first_column, in srcpos_string_comment()
343 pos->last_line, pos->last_column); in srcpos_string_comment()
346 first_line ? pos->first_line : pos->last_line); in srcpos_string_comment()
351 if (pos->next != NULL) { in srcpos_string_comment()
352 rest = srcpos_string_comment(pos->next, first_line, level); in srcpos_string_comment()
399 current_srcfile->name = f; in srcpos_set_line()
400 current_srcfile->lineno = l; in srcpos_set_line()