| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | #include <config.h> | - |
| 22 | | - |
| 23 | #if defined (HAVE_UNISTD_H) | - |
| 24 | # ifdef _MINIX | - |
| 25 | # include <sys/types.h> | - |
| 26 | # endif | - |
| 27 | # include <unistd.h> | - |
| 28 | #endif | - |
| 29 | | - |
| 30 | #include <bashansi.h> | - |
| 31 | #include "shell.h" | - |
| 32 | | - |
| 33 | #include <tilde/tilde.h> | - |
| 34 | | - |
| 35 | #ifndef NULL | - |
| 36 | # define NULL 0 | - |
| 37 | #endif | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | #ifndef MP_DOTILDE | - |
| 42 | # define MP_DOTILDE 0x01 | - |
| 43 | # define MP_DOCWD 0x02 | - |
| 44 | # define MP_RMDOT 0x04 | - |
| 45 | # define MP_IGNDOT 0x08 | - |
| 46 | #endif | - |
| 47 | | - |
| 48 | extern char *get_working_directory __P((char *)); | - |
| 49 | | - |
| 50 | static char *nullpath = ""; | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | | - |
| 55 | | - |
| 56 | | - |
| 57 | | - |
| 58 | | - |
| 59 | | - |
| 60 | | - |
| 61 | #define MAKEDOT() \ | - |
| 62 | do { \ | - |
| 63 | xpath = (char *)xmalloc (2); \ | - |
| 64 | xpath[0] = '.'; \ | - |
| 65 | xpath[1] = '\0'; \ | - |
| 66 | pathlen = 1; \ | - |
| 67 | } while (0) | - |
| 68 | | - |
| 69 | char * | - |
| 70 | sh_makepath (path, dir, flags) | - |
| 71 | const char *path, *dir; | - |
| 72 | int flags; | - |
| 73 | { | - |
| 74 | int dirlen, pathlen; | - |
| 75 | char *ret, *xpath, *xdir, *r, *s; | - |
| 76 | | - |
| 77 | if (path == 0 || *path == '\0')| TRUE | never evaluated | | FALSE | evaluated 31544 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 31544 times by 1 test |
| 0-31544 |
| 78 | { | - |
| 79 | if (flags & MP_DOCWD)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 80 | { | - |
| 81 | xpath = get_working_directory ("sh_makepath"); | - |
| 82 | if (xpath == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 83 | { | - |
| 84 | ret = get_string_value ("PWD"); | - |
| 85 | if (ret)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 86 | xpath = savestring (ret); never executed: xpath = (char *)strcpy (sh_xmalloc((1 + strlen (ret)), "makepath.c", 86), (ret)); | 0 |
| 87 | } never executed: end of block | 0 |
| 88 | if (xpath == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 89 | MAKEDOT(); never executed: end of block | 0 |
| 90 | else | - |
| 91 | pathlen = strlen (xpath); never executed: pathlen = strlen (xpath); | 0 |
| 92 | } | - |
| 93 | else | - |
| 94 | MAKEDOT(); never executed: end of block | 0 |
| 95 | } | - |
| 96 | else if ((flags & MP_IGNDOT) && path[0] == '.' && (path[1] == '\0' ||| TRUE | evaluated 579 times by 1 test | | FALSE | evaluated 30965 times by 1 test |
| TRUE | evaluated 94 times by 1 test | | FALSE | evaluated 485 times by 1 test |
| TRUE | evaluated 94 times by 1 test | | FALSE | never evaluated |
| 0-30965 |
| 97 | (path[1] == '/' && path[2] == '\0')))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 98 | { | - |
| 99 | xpath = nullpath; | - |
| 100 | pathlen = 0; | - |
| 101 | }executed 94 times by 1 test: end of block | 94 |
| 102 | else | - |
| 103 | { | - |
| 104 | xpath = ((flags & MP_DOTILDE) && *path == '~') ? bash_tilde_expand (path, 0) : (char *)path;| TRUE | evaluated 2 times by 1 test | | FALSE | evaluated 31448 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 2 times by 1 test |
| 0-31448 |
| 105 | pathlen = strlen (xpath); | - |
| 106 | }executed 31450 times by 1 test: end of block | 31450 |
| 107 | | - |
| 108 | xdir = (char *)dir; | - |
| 109 | dirlen = strlen (xdir); | - |
| 110 | if ((flags & MP_RMDOT) && dir[0] == '.' && dir[1] == '/')| TRUE | evaluated 817 times by 1 test | | FALSE | evaluated 30727 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 817 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-30727 |
| 111 | { | - |
| 112 | xdir += 2; | - |
| 113 | dirlen -= 2; | - |
| 114 | } never executed: end of block | 0 |
| 115 | | - |
| 116 | r = ret = (char *)xmalloc (2 + dirlen + pathlen); | - |
| 117 | s = xpath; | - |
| 118 | while (*s)| TRUE | evaluated 502903 times by 1 test | | FALSE | evaluated 31544 times by 1 test |
| 31544-502903 |
| 119 | *r++ = *s++;executed 502903 times by 1 test: *r++ = *s++; | 502903 |
| 120 | if (s > xpath && s[-1] != '/')| TRUE | evaluated 31450 times by 1 test | | FALSE | evaluated 94 times by 1 test |
| TRUE | evaluated 31442 times by 1 test | | FALSE | evaluated 8 times by 1 test |
| 8-31450 |
| 121 | *r++ = '/'; executed 31442 times by 1 test: *r++ = '/'; | 31442 |
| 122 | s = xdir; | - |
| 123 | while (*r++ = *s++)| TRUE | evaluated 91049 times by 1 test | | FALSE | evaluated 31544 times by 1 test |
| 31544-91049 |
| 124 | ;executed 91049 times by 1 test: ; | 91049 |
| 125 | if (xpath != path && xpath != nullpath)| TRUE | evaluated 94 times by 1 test | | FALSE | evaluated 31450 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 94 times by 1 test |
| 0-31450 |
| 126 | free (xpath); never executed: sh_xfree((xpath), "makepath.c", 126); | 0 |
| 127 | return (ret);executed 31544 times by 1 test: return (ret); | 31544 |
| 128 | } | - |
| | |