summaryrefslogtreecommitdiff
path: root/gprof/source.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2001-03-14 03:14:56 +0000
committerAlan Modra <amodra@bigpond.net.au>2001-03-14 03:14:56 +0000
commit2f03d8ae4f701cf7710d14a47e0a6cc539077861 (patch)
treed55ce5b6020729eb103cb1fee509dc03149e4a3a /gprof/source.c
parent912f7270cfdb64add96caa3e380fefbd14963e05 (diff)
downloadbinutils-redhat-2f03d8ae4f701cf7710d14a47e0a6cc539077861.tar.gz
David Mosberger's fixes for cross compiling gprof.
Diffstat (limited to 'gprof/source.c')
-rw-r--r--gprof/source.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/gprof/source.c b/gprof/source.c
index 30b8278d99..7b9401f60a 100644
--- a/gprof/source.c
+++ b/gprof/source.c
@@ -1,6 +1,6 @@
/* source.c - Keep track of source files.
- Copyright 2000 Free Software Foundation, Inc.
+ Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -44,19 +44,19 @@ DEFUN (source_file_lookup_path, (path), const char *path)
if (FILENAME_CMP (path, sf->name) == 0)
break;
}
-
+
if (!sf)
{
/* Create a new source file descriptor. */
sf = (Source_File *) xmalloc (sizeof (*sf));
-
+
memset (sf, 0, sizeof (*sf));
-
+
sf->name = xstrdup (path);
sf->next = first_src_file;
first_src_file = sf;
}
-
+
return sf;
}
@@ -66,7 +66,7 @@ DEFUN (source_file_lookup_name, (filename), const char *filename)
{
const char *fname;
Source_File *sf;
-
+
/* The user cannot know exactly how a filename will be stored in
the debugging info (e.g., ../include/foo.h
vs. /usr/include/foo.h). So we simply compare the filename
@@ -74,7 +74,7 @@ DEFUN (source_file_lookup_name, (filename), const char *filename)
for (sf = first_src_file; sf; sf = sf->next)
{
fname = strrchr (sf->name, '/');
-
+
if (fname)
++fname;
else
@@ -83,7 +83,7 @@ DEFUN (source_file_lookup_name, (filename), const char *filename)
if (FILENAME_CMP (filename, fname) == 0)
break;
}
-
+
return sf;
}
@@ -106,7 +106,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
/* Open input file. If open fails, walk along search-list until
open succeeds or reaching end of list. */
strcpy (fname, sf->name);
-
+
if (IS_ABSOLUTE_PATH (sf->name))
sle = 0; /* Don't use search list for absolute paths. */
@@ -115,7 +115,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
{
DBG (SRCDEBUG, printf ("[annotate_source]: looking for %s, trying %s\n",
sf->name, fname));
-
+
ifp = fopen (fname, FOPEN_RB);
if (ifp)
break;
@@ -139,7 +139,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
sle = src_search_list.head;
}
}
-
+
if (sle)
{
strcpy (fname, sle->path);
@@ -149,7 +149,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
strcat (fname, ".");
#endif
strcat (fname, "/");
-
+
if (name_only)
strcat (fname, name_only);
else
@@ -170,7 +170,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
}
ofp = stdout;
-
+
if (create_annotation_files)
{
/* Try to create annotated source file. */
@@ -213,7 +213,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
}
#endif
ofp = fopen (fname, "w");
-
+
if (!ofp)
{
perror (fname);
@@ -241,7 +241,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
annotation = xmalloc (max_width + 1);
line_num = 1;
new_line = TRUE;
-
+
while ((nread = fread (buf, 1, sizeof (buf), ifp)) > 0)
{
for (i = 0; i < nread; ++i)
@@ -253,12 +253,12 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
++line_num;
new_line = FALSE;
}
-
+
new_line = (buf[i] == '\n');
fputc (buf[i], ofp);
}
}
-
+
free (annotation);
return ofp;
}