OpenCoverage

makepath.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/lib/sh/makepath.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9extern char *get_working_directory (char *);-
10-
11static char *nullpath = "";-
12char *-
13sh_makepath (path, dir, flags)-
14 const char *path, *dir;-
15 int flags;-
16{-
17 int dirlen, pathlen;-
18 char *ret, *xpath, *xdir, *r, *s;-
19-
20 if (path == 0
path == 0Description
TRUEnever evaluated
FALSEevaluated 31544 times by 1 test
Evaluated by:
  • Self test
|| *
*path == '\0'Description
TRUEnever evaluated
FALSEevaluated 31544 times by 1 test
Evaluated by:
  • Self test
path == '\0'
*path == '\0'Description
TRUEnever evaluated
FALSEevaluated 31544 times by 1 test
Evaluated by:
  • Self test
)
0-31544
21 {-
22 if (flags & 0x02
flags & 0x02Description
TRUEnever evaluated
FALSEnever evaluated
)
0
23 {-
24 xpath = get_working_directory ("sh_makepath");-
25 if (xpath == 0
xpath == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
26 {-
27 ret = get_string_value ("PWD");-
28 if (ret
retDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
29 xpath = (char *)strcpy (sh_xmalloc((1 + strlen (ret)), "makepath.c", 86), (ret));
never executed: xpath = (char *)strcpy (sh_xmalloc((1 + strlen (ret)), "makepath.c", 86), (ret));
0
30 }
never executed: end of block
0
31 if (xpath == 0
xpath == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
32 do { xpath = (char *)sh_xmalloc((2), "makepath.c", 89); xpath[0] = '.'; xpath[1] = '\0'; pathlen = 1; }
never executed: end of block
while (0);
0
33 else-
34 pathlen = strlen (xpath);
never executed: pathlen = strlen (xpath);
0
35 }-
36 else-
37 do { xpath = (char *)sh_xmalloc((2), "makepath.c", 94); xpath[0] = '.'; xpath[1] = '\0'; pathlen = 1; }
never executed: end of block
while (0);
0
38 }-
39 else if ((
(flags & 0x08)Description
TRUEevaluated 579 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30965 times by 1 test
Evaluated by:
  • Self test
flags & 0x08)
(flags & 0x08)Description
TRUEevaluated 579 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30965 times by 1 test
Evaluated by:
  • Self test
&& path[0] == '.'
path[0] == '.'Description
TRUEevaluated 94 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 485 times by 1 test
Evaluated by:
  • Self test
&& (path[1] == '\0'
path[1] == '\0'Description
TRUEevaluated 94 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
||
0-30965
40 (path[1] == '/'
path[1] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
&& path[2] == '\0'
path[2] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
)))
0
41 {-
42 xpath = nullpath;-
43 pathlen = 0;-
44 }
executed 94 times by 1 test: end of block
Executed by:
  • Self test
94
45 else-
46 {-
47 xpath = ((
(flags & 0x01)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31448 times by 1 test
Evaluated by:
  • Self test
flags & 0x01)
(flags & 0x01)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31448 times by 1 test
Evaluated by:
  • Self test
&& *
*path == '~'Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
path == '~'
*path == '~'Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
) ? bash_tilde_expand (path, 0) : (char *)path;
0-31448
48 pathlen = strlen (xpath);-
49 }
executed 31450 times by 1 test: end of block
Executed by:
  • Self test
31450
50-
51 xdir = (char *)dir;-
52 dirlen = strlen (xdir);-
53 if ((
(flags & 0x04)Description
TRUEevaluated 817 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30727 times by 1 test
Evaluated by:
  • Self test
flags & 0x04)
(flags & 0x04)Description
TRUEevaluated 817 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30727 times by 1 test
Evaluated by:
  • Self test
&& dir[0] == '.'
dir[0] == '.'Description
TRUEnever evaluated
FALSEevaluated 817 times by 1 test
Evaluated by:
  • Self test
&& dir[1] == '/'
dir[1] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
)
0-30727
54 {-
55 xdir += 2;-
56 dirlen -= 2;-
57 }
never executed: end of block
0
58-
59 r = ret = (char *)sh_xmalloc((2 + dirlen + pathlen), "makepath.c", 116);-
60 s = xpath;-
61 while (*
*sDescription
TRUEevaluated 502903 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31544 times by 1 test
Evaluated by:
  • Self test
s
*sDescription
TRUEevaluated 502903 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31544 times by 1 test
Evaluated by:
  • Self test
)
31544-502903
62 *
executed 502903 times by 1 test: *r++ = *s++;
Executed by:
  • Self test
r++ = *s++;
executed 502903 times by 1 test: *r++ = *s++;
Executed by:
  • Self test
502903
63 if (s > xpath
s > xpathDescription
TRUEevaluated 31450 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 94 times by 1 test
Evaluated by:
  • Self test
&& s[-1] != '/'
s[-1] != '/'Description
TRUEevaluated 31442 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
)
8-31450
64 *
executed 31442 times by 1 test: *r++ = '/';
Executed by:
  • Self test
r++ = '/';
executed 31442 times by 1 test: *r++ = '/';
Executed by:
  • Self test
31442
65 s = xdir;-
66 while (*
*r++ = *s++Description
TRUEevaluated 91049 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31544 times by 1 test
Evaluated by:
  • Self test
r++ = *s++
*r++ = *s++Description
TRUEevaluated 91049 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31544 times by 1 test
Evaluated by:
  • Self test
)
31544-91049
67 ;
executed 91049 times by 1 test: ;
Executed by:
  • Self test
91049
68 if (xpath != path
xpath != pathDescription
TRUEevaluated 94 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31450 times by 1 test
Evaluated by:
  • Self test
&& xpath != nullpath
xpath != nullpathDescription
TRUEnever evaluated
FALSEevaluated 94 times by 1 test
Evaluated by:
  • Self test
)
0-31450
69 sh_xfree((xpath), "makepath.c", 126);
never executed: sh_xfree((xpath), "makepath.c", 126);
0
70 return
executed 31544 times by 1 test: return (ret);
Executed by:
  • Self test
(ret);
executed 31544 times by 1 test: return (ret);
Executed by:
  • Self test
31544
71}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2