OpenCoverage

relpath.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/relpath.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7static int -
8 __attribute__ ((__pure__))-
9-
10path_common_prefix (const char *path1, const char *path2)-
11{-
12 int i = 0;-
13 int ret = 0;-
14-
15-
16-
17-
18 if ((
(path1[1] == '...th2[1] == '/')Description
TRUEnever evaluated
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • ln
  • realpath
path1[1] == '/') != (path2[1] == '/')
(path1[1] == '...th2[1] == '/')Description
TRUEnever evaluated
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
0-26
19 return
never executed: return 0;
0;
never executed: return 0;
0
20-
21 while (*
*path1Description
TRUEevaluated 702 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 21 times by 2 tests
Evaluated by:
  • ln
  • realpath
path1
*path1Description
TRUEevaluated 702 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 21 times by 2 tests
Evaluated by:
  • ln
  • realpath
&& *
*path2Description
TRUEevaluated 700 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 2 times by 1 test
Evaluated by:
  • realpath
path2
*path2Description
TRUEevaluated 700 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 2 times by 1 test
Evaluated by:
  • realpath
)
2-702
22 {-
23 if (*
*path1 != *path2Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 697 times by 2 tests
Evaluated by:
  • ln
  • realpath
path1 != *path2
*path1 != *path2Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 697 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
3-697
24 break;
executed 3 times by 2 tests: break;
Executed by:
  • ln
  • realpath
3
25 if (*
*path1 == '/'Description
TRUEevaluated 83 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 614 times by 2 tests
Evaluated by:
  • ln
  • realpath
path1 == '/'
*path1 == '/'Description
TRUEevaluated 83 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 614 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
83-614
26 ret = i + 1;
executed 83 times by 2 tests: ret = i + 1;
Executed by:
  • ln
  • realpath
83
27 path1++;-
28 path2++;-
29 i++;-
30 }
executed 697 times by 2 tests: end of block
Executed by:
  • ln
  • realpath
697
31-
32 if ((!*path1
!*path1Description
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • ln
  • realpath
&& !*path2
!*path2Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • realpath
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
5-21
33 || (!*path1
!*path1Description
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 5 times by 2 tests
Evaluated by:
  • ln
  • realpath
&& *
*path2 == '/'Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 8 times by 1 test
Evaluated by:
  • realpath
path2 == '/'
*path2 == '/'Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 8 times by 1 test
Evaluated by:
  • realpath
)
3-11
34 || (!*path2
!*path2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • realpath
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • ln
  • realpath
&& *
*path1 == '/'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • realpath
FALSEevaluated 1 time by 1 test
Evaluated by:
  • realpath
path1 == '/'
*path1 == '/'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • realpath
FALSEevaluated 1 time by 1 test
Evaluated by:
  • realpath
))
1-11
35 ret = i;
executed 14 times by 2 tests: ret = i;
Executed by:
  • ln
  • realpath
14
36-
37 return
executed 26 times by 2 tests: return ret;
Executed by:
  • ln
  • realpath
ret;
executed 26 times by 2 tests: return ret;
Executed by:
  • ln
  • realpath
26
38}-
39-
40-
41-
42-
43-
44-
45static -
46 _Bool-
47-
48buffer_or_output (const char* str, char **pbuf, size_t *plen)-
49{-
50 if (*
*pbufDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • ln
FALSEevaluated 26 times by 1 test
Evaluated by:
  • realpath
pbuf
*pbufDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • ln
FALSEevaluated 26 times by 1 test
Evaluated by:
  • realpath
)
8-26
51 {-
52 size_t slen = strlen (str);-
53 if (slen >= *plen
slen >= *plenDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • ln
)
0-8
54 return
never executed: return 1 ;
never executed: return 1 ;
0
55 1
never executed: return 1 ;
0
56 ;
never executed: return 1 ;
0
57 memcpy (*pbuf, str, slen + 1);-
58 *pbuf += slen;-
59 *plen -= slen;-
60 }
executed 8 times by 1 test: end of block
Executed by:
  • ln
8
61 else-
62 {-
63 fputs_unlocked (str,-
64 stdout-
65 );-
66 }
executed 26 times by 1 test: end of block
Executed by:
  • realpath
26
67-
68 return
executed 34 times by 2 tests: return 0 ;
Executed by:
  • ln
  • realpath
executed 34 times by 2 tests: return 0 ;
Executed by:
  • ln
  • realpath
34
69 0
executed 34 times by 2 tests: return 0 ;
Executed by:
  • ln
  • realpath
34
70 ;
executed 34 times by 2 tests: return 0 ;
Executed by:
  • ln
  • realpath
34
71}-
72-
73-
74-
75-
76_Bool-
77-
78relpath (const char *can_fname, const char *can_reldir, char *buf, size_t len)-
79{-
80 -
81 _Bool -
82 buf_err = -
83 0-
84 ;-
85-
86-
87 int common_index = path_common_prefix (can_reldir, can_fname);-
88 if (!common_index
!common_indexDescription
TRUEnever evaluated
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
0-26
89 return
never executed: return 0 ;
never executed: return 0 ;
0
90 0
never executed: return 0 ;
0
91 ;
never executed: return 0 ;
0
92-
93 const char *relto_suffix = can_reldir + common_index;-
94 const char *fname_suffix = can_fname + common_index;-
95-
96-
97 if (*
*relto_suffix == '/'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • realpath
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • ln
  • realpath
relto_suffix == '/'
*relto_suffix == '/'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • realpath
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
1-25
98 relto_suffix++;
executed 1 time by 1 test: relto_suffix++;
Executed by:
  • realpath
1
99 if (*
*fname_suffix == '/'Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 23 times by 2 tests
Evaluated by:
  • ln
  • realpath
fname_suffix == '/'
*fname_suffix == '/'Description
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 23 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
3-23
100 fname_suffix++;
executed 3 times by 2 tests: fname_suffix++;
Executed by:
  • ln
  • realpath
3
101-
102-
103-
104 if (*
*relto_suffixDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 20 times by 2 tests
Evaluated by:
  • ln
  • realpath
relto_suffix
*relto_suffixDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 20 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
6-20
105 {-
106 buf_err |= buffer_or_output ("..", &buf, &len);-
107 for (; *
*relto_suffixDescription
TRUEevaluated 27 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • ln
  • realpath
relto_suffix
*relto_suffixDescription
TRUEevaluated 27 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • ln
  • realpath
; ++relto_suffix)
6-27
108 {-
109 if (*
*relto_suffix == '/'Description
TRUEnever evaluated
FALSEevaluated 27 times by 2 tests
Evaluated by:
  • ln
  • realpath
relto_suffix == '/'
*relto_suffix == '/'Description
TRUEnever evaluated
FALSEevaluated 27 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
0-27
110 buf_err |= buffer_or_output ("/..", &buf, &len);
never executed: buf_err |= buffer_or_output ("/..", &buf, &len);
0
111 }
executed 27 times by 2 tests: end of block
Executed by:
  • ln
  • realpath
27
112-
113 if (*
*fname_suffixDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 2 times by 1 test
Evaluated by:
  • realpath
fname_suffix
*fname_suffixDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • ln
  • realpath
FALSEevaluated 2 times by 1 test
Evaluated by:
  • realpath
)
2-4
114 {-
115 buf_err |= buffer_or_output ("/", &buf, &len);-
116 buf_err |= buffer_or_output (fname_suffix, &buf, &len);-
117 }
executed 4 times by 2 tests: end of block
Executed by:
  • ln
  • realpath
4
118 }
executed 6 times by 2 tests: end of block
Executed by:
  • ln
  • realpath
6
119 else-
120 {-
121 buf_err |= buffer_or_output (*fname_suffix ? fname_suffix : ".",-
122 &buf, &len);-
123 }
executed 20 times by 2 tests: end of block
Executed by:
  • ln
  • realpath
20
124-
125 if (buf_err
buf_errDescription
TRUEnever evaluated
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • ln
  • realpath
)
0-26
126 error (0,
never executed: error (0, 36 , "%s", dcgettext (((void *)0), "generating relative path" , 5) );
0
127 36
never executed: error (0, 36 , "%s", dcgettext (((void *)0), "generating relative path" , 5) );
0
128 , "%s",
never executed: error (0, 36 , "%s", dcgettext (((void *)0), "generating relative path" , 5) );
0
129 dcgettext (((void *)0),
never executed: error (0, 36 , "%s", dcgettext (((void *)0), "generating relative path" , 5) );
0
130 "generating relative path"
never executed: error (0, 36 , "%s", dcgettext (((void *)0), "generating relative path" , 5) );
0
131 , 5)
never executed: error (0, 36 , "%s", dcgettext (((void *)0), "generating relative path" , 5) );
0
132 );
never executed: error (0, 36 , "%s", dcgettext (((void *)0), "generating relative path" , 5) );
0
133-
134 return
executed 26 times by 2 tests: return !buf_err;
Executed by:
  • ln
  • realpath
!buf_err;
executed 26 times by 2 tests: return !buf_err;
Executed by:
  • ln
  • realpath
26
135}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2