| 110 | this function. */ |
| 111 | |
| 112 | static char * |
| 113 | create_fullname (char const *gecos_name, char const *user_name) |
| 114 | { |
| 115 | idx_t rsize = strlen (gecos_name) + 1; |
| 116 | idx_t ampersands = count_ampersands (gecos_name); |
| 117 | |
| 118 | if (ampersands != 0) |
| 119 | { |
| 120 | idx_t ulen = strlen (user_name); |
| 121 | ptrdiff_t product; |
| 122 | if (ckd_mul (&product, ulen - 1, ampersands) |
| 123 | || ckd_add (&rsize, rsize, product)) |
| 124 | xalloc_die (); |
| 125 | } |
| 126 | |
| 127 | char *result = xmalloc (rsize); |
| 128 | char *r = result; |
| 129 | |
| 130 | while (*gecos_name) |
| 131 | { |
| 132 | if (*gecos_name == '&') |
| 133 | { |
| 134 | char const *uname = user_name; |
| 135 | if (islower (to_uchar (*uname))) |
| 136 | *r++ = toupper (to_uchar (*uname++)); |
| 137 | while (*uname) |
| 138 | *r++ = *uname++; |
| 139 | } |
| 140 | else |
| 141 | { |
| 142 | *r++ = *gecos_name; |
| 143 | } |
| 144 | |
| 145 | gecos_name++; |
| 146 | } |
| 147 | *r = 0; |
| 148 | |
| 149 | return result; |
| 150 | } |
| 151 | |
| 152 | /* Return a string representing the time between WHEN and the time |
| 153 | that this function is first run. */ |
no test coverage detected