* Return a quoted string with the full pathname of the indicated filename. * The string " (in MODNAME)" may also be appended. The returned pointer * remains valid until the next time full_fname() is called. **/
| 1271 | * remains valid until the next time full_fname() is called. |
| 1272 | **/ |
| 1273 | char *full_fname(const char *fn) |
| 1274 | { |
| 1275 | static char *result = NULL; |
| 1276 | char *m1, *m2, *m3; |
| 1277 | char *p1, *p2; |
| 1278 | |
| 1279 | if (result) |
| 1280 | free(result); |
| 1281 | |
| 1282 | if (*fn == '/') |
| 1283 | p1 = p2 = ""; |
| 1284 | else { |
| 1285 | p1 = curr_dir + module_dirlen; |
| 1286 | for (p2 = p1; *p2 == '/'; p2++) {} |
| 1287 | if (*p2) |
| 1288 | p2 = "/"; |
| 1289 | } |
| 1290 | if (module_id >= 0) { |
| 1291 | m1 = " (in "; |
| 1292 | m2 = lp_name(module_id); |
| 1293 | m3 = ")"; |
| 1294 | } else |
| 1295 | m1 = m2 = m3 = ""; |
| 1296 | |
| 1297 | if (asprintf(&result, "\"%s%s%s\"%s%s%s", p1, p2, fn, m1, m2, m3) < 0) |
| 1298 | out_of_memory("full_fname"); |
| 1299 | |
| 1300 | return result; |
| 1301 | } |
| 1302 | |
| 1303 | static char partial_fname[MAXPATHLEN]; |
| 1304 |
no test coverage detected