| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/relpath.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | static int | - | ||||||||||||||||||||||||
| 8 | __attribute__ ((__pure__)) | - | ||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | path_common_prefix (const char *path1, const char *path2) | - | ||||||||||||||||||||||||
| 11 | { | - | ||||||||||||||||||||||||
| 12 | int i = 0; | - | ||||||||||||||||||||||||
| 13 | int ret = 0; | - | ||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||
| 18 | if ((
| 0-26 | ||||||||||||||||||||||||
| 19 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | while (*
| 2-702 | ||||||||||||||||||||||||
| 22 | { | - | ||||||||||||||||||||||||
| 23 | if (*
| 3-697 | ||||||||||||||||||||||||
| 24 | break; executed 3 times by 2 tests: break;Executed by:
| 3 | ||||||||||||||||||||||||
| 25 | if (*
| 83-614 | ||||||||||||||||||||||||
| 26 | ret = i + 1; executed 83 times by 2 tests: ret = i + 1;Executed by:
| 83 | ||||||||||||||||||||||||
| 27 | path1++; | - | ||||||||||||||||||||||||
| 28 | path2++; | - | ||||||||||||||||||||||||
| 29 | i++; | - | ||||||||||||||||||||||||
| 30 | } executed 697 times by 2 tests: end of blockExecuted by:
| 697 | ||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||
| 32 | if ((!*path1
| 5-21 | ||||||||||||||||||||||||
| 33 | || (!*path1
| 3-11 | ||||||||||||||||||||||||
| 34 | || (!*path2
| 1-11 | ||||||||||||||||||||||||
| 35 | ret = i; executed 14 times by 2 tests: ret = i;Executed by:
| 14 | ||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||
| 37 | return executed 26 times by 2 tests: ret;return ret;Executed by:
executed 26 times by 2 tests: return ret;Executed by:
| 26 | ||||||||||||||||||||||||
| 38 | } | - | ||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | static | - | ||||||||||||||||||||||||
| 46 | _Bool | - | ||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | buffer_or_output (const char* str, char **pbuf, size_t *plen) | - | ||||||||||||||||||||||||
| 49 | { | - | ||||||||||||||||||||||||
| 50 | if (*
| 8-26 | ||||||||||||||||||||||||
| 51 | { | - | ||||||||||||||||||||||||
| 52 | size_t slen = strlen (str); | - | ||||||||||||||||||||||||
| 53 | if (slen >= *plen
| 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 blockExecuted by:
| 8 | ||||||||||||||||||||||||
| 61 | else | - | ||||||||||||||||||||||||
| 62 | { | - | ||||||||||||||||||||||||
| 63 | fputs_unlocked (str, | - | ||||||||||||||||||||||||
| 64 | stdout | - | ||||||||||||||||||||||||
| 65 | ); | - | ||||||||||||||||||||||||
| 66 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | return executed 34 times by 2 tests: return 0 ;Executed by:
executed 34 times by 2 tests: return 0 ;Executed by:
| 34 | ||||||||||||||||||||||||
| 69 | 0 executed 34 times by 2 tests: return 0 ;Executed by:
| 34 | ||||||||||||||||||||||||
| 70 | ; executed 34 times by 2 tests: return 0 ;Executed by:
| 34 | ||||||||||||||||||||||||
| 71 | } | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||
| 76 | _Bool | - | ||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||
| 78 | relpath (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
| 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 (*
| 1-25 | ||||||||||||||||||||||||
| 98 | relto_suffix++; executed 1 time by 1 test: relto_suffix++;Executed by:
| 1 | ||||||||||||||||||||||||
| 99 | if (*
| 3-23 | ||||||||||||||||||||||||
| 100 | fname_suffix++; executed 3 times by 2 tests: fname_suffix++;Executed by:
| 3 | ||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | if (*
| 6-20 | ||||||||||||||||||||||||
| 105 | { | - | ||||||||||||||||||||||||
| 106 | buf_err |= buffer_or_output ("..", &buf, &len); | - | ||||||||||||||||||||||||
| 107 | for (; *
| 6-27 | ||||||||||||||||||||||||
| 108 | { | - | ||||||||||||||||||||||||
| 109 | if (*
| 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 blockExecuted by:
| 27 | ||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | if (*
| 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 blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 118 | } executed 6 times by 2 tests: end of blockExecuted by:
| 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 blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | if (buf_err
| 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: !buf_err;return !buf_err;Executed by:
executed 26 times by 2 tests: return !buf_err;Executed by:
| 26 | ||||||||||||||||||||||||
| 135 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |