1 -: 0:Source:misc.c 2 -: 1:/* misc.c -- functions that do not fit in any other file */ 3 -: 2: 4 -: 3:/* 5 -: 4: * This file is part of CliFM 6 -: 5: * 7 -: 6: * Copyright (C) 2016-2021, L. Abramovich <johndoe.arch@outlook.com> 8 -: 7: * All rights reserved. 9 -: 8: 10 -: 9: * CliFM is free software; you can redistribute it and/or modify 11 -: 10: * it under the terms of the GNU General Public License as published by 12 -: 11: * the Free Software Foundation; either version 2 of the License, or 13 -: 12: * (at your option) any later version. 14 -: 13: * 15 -: 14: * CliFM is distributed in the hope that it will be useful, 16 -: 15: * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 -: 16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 -: 17: * GNU General Public License for more details. 19 -: 18: * 20 -: 19: * You should have received a copy of the GNU General Public License 21 -: 20: * along with this program; if not, write to the Free Software 22 -: 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 -: 22: * MA 02110-1301, USA. 24 -: 23:*/ 25 -: 24: 26 -: 25:#include "helpers.h" 27 -: 26: 28 -: 27:#include <errno.h> 29 -: 28:#include <fcntl.h> 30 -: 29:#include <signal.h> 31 -: 30:#include <stdarg.h> 32 -: 31:#include <stdio.h> 33 -: 32:#include <string.h> 34 -: 33:#include <sys/stat.h> 35 -: 34:#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 36 -: 35:#include <sys/mount.h> 37 -: 36:#include <sys/sysctl.h> 38 -: 37:#endif 39 -: 38:/* 40 -: 39:#if defined(__HAIKU__) 41 -: 40:#include <private/libs/compat/freebsd_network/compat/sys/mount.h> 42 -: 41:#include <private/libs/compat/freebsd_network/compat/sys/sysctl.h> 43 -: 42:#endif */ 44 -: 43:#include <time.h> 45 -: 44:#include <unistd.h> 46 -: 45:#include <readline/readline.h> 47 -: 46:#ifdef LINUX_INOTIFY 48 -: 47:#include <sys/inotify.h> 49 -: 48:#endif 50 -: 49: 51 -: 50:#include "aux.h" 52 -: 51:#include "bookmarks.h" 53 -: 52:#include "checks.h" 54 -: 53:#include "exec.h" 55 -: 54:#include "history.h" 56 -: 55:#include "init.h" 57 -: 56:#include "jump.h" 58 -: 57:#include "listing.h" 59 -: 58:#include "navigation.h" 60 -: 59:#include "readline.h" 61 -: 60:#include "strings.h" 62 -: 61:#include "remotes.h" 63 -: 62:#include "messages.h" 64 -: 63: 65 -: 64:#ifdef LINUX_INOTIFY 66 -: 65:void 67function read_inotify called 48 returned 100% blocks executed 93% 68 48: 66:read_inotify(void) 69 -: 67:{ 70 -: 68: int i; 71 -: 69: struct inotify_event *event; 72 -: 70: char inotify_buf[EVENT_BUF_LEN]; 73 -: 71: 74 48: 72: memset((void *)inotify_buf, '\0', EVENT_BUF_LEN); 75 48: 73: i = (int)read(inotify_fd, inotify_buf, EVENT_BUF_LEN); 76 48: 73-block 0 77call 0 returned 48 78 -: 74: 79 48: 75: if (i <= 0) 80branch 0 taken 3 (fallthrough) 81branch 1 taken 45 82 3: 76: return; 83 3: 76-block 0 84unconditional 0 taken 3 85 -: 77: 86 45: 78: int ignore_event = 0, refresh = 0; 87 45: 79: for (char *ptr = inotify_buf; 88 45: 79-block 0 89unconditional 0 taken 45 90 409: 80: ptr + ((struct inotify_event *)ptr)->len < inotify_buf + i; 91 409: 80-block 0 92branch 0 taken 364 93branch 1 taken 45 (fallthrough) 94 364: 81: ptr += sizeof(struct inotify_event) + event->len) { 95 364: 81-block 0 96unconditional 0 taken 364 97 364: 82: event = (struct inotify_event *)ptr; 98 364: 83: if (!event->wd) 99 364: 83-block 0 100branch 0 taken 0 (fallthrough) 101branch 1 taken 364 102 #####: 84: break; 103 %%%%%: 84-block 0 104unconditional 0 never executed 105 -: 85: 106 364: 86: if (event->mask & IN_CREATE) { 107 364: 86-block 0 108branch 0 taken 25 (fallthrough) 109branch 1 taken 339 110 -: 87:/* puts("IN_CREATE"); */ 111 -: 88: struct stat a; 112 25: 89: if (stat(event->name, &a) != 0) 113 25: 89-block 0 114call 0 returned 25 115branch 1 taken 5 (fallthrough) 116branch 2 taken 20 117 -: 90: /* The file was created, but doesn't exist anymore */ 118 5: 91: ignore_event = 1; 119 5: 91-block 0 120unconditional 0 taken 5 121 -: 92: } 122 364: 93: if (event->mask & IN_DELETE) { 123 364: 93-block 0 124branch 0 taken 17 (fallthrough) 125branch 1 taken 347 126 -: 94:/* puts("IN_DELETE"); */ 127 -: 95: struct stat a; 128 17: 96: if (stat(event->name, &a) == 0) 129 17: 96-block 0 130call 0 returned 17 131branch 1 taken 0 (fallthrough) 132branch 2 taken 17 133 -: 97: /* The file was removed, but is still there */ 134 #####: 98: ignore_event = 1; 135 %%%%%: 98-block 0 136unconditional 0 never executed 137 -: 99: } 138 -: 100:/* if (event->mask & IN_DELETE_SELF) 139 -: 101: puts("IN_DELETE_SELF"); 140 -: 102: if (event->mask & IN_MOVE_SELF) 141 -: 103: puts("IN_MOVE_SELF"); 142 -: 104: if (event->mask & IN_MOVED_FROM) 143 -: 105: puts("IN_MOVED_FROM"); 144 -: 106: if (event->mask & IN_MOVED_TO) 145 -: 107: puts("IN_MOVED_TO"); 146 -: 108: if (event->mask & IN_IGNORED) { 147 -: 109: puts("IN_IGNORED"); 148 -: 110: } */ 149 -: 111: 150 364: 112: if (!ignore_event && (event->mask & INOTIFY_MASK)) 151 364: 112-block 0 152branch 0 taken 342 (fallthrough) 153branch 1 taken 22 154 342: 112-block 1 155branch 2 taken 57 (fallthrough) 156branch 3 taken 285 157 57: 113: refresh = 1; 158 57: 113-block 0 159unconditional 0 taken 57 160 -: 114: } 161 -: 115: 162 45: 116: if (refresh) { 163 45: 116-block 0 164branch 0 taken 26 (fallthrough) 165branch 1 taken 19 166 26: 117: free_dirlist(); 167 26: 117-block 0 168call 0 returned 26 169 26: 118: list_dir(); 170call 0 returned 26 171unconditional 1 taken 26 172 -: 119: } 173 -: 120: 174 45: 121: return; 175 45: 121-block 0 176unconditional 0 taken 45 177 -: 122:} 178 -: 123:#elif defined(BSD_KQUEUE) 179 -: 124:void 180 -: 125:read_kqueue(void) 181 -: 126:{ 182 -: 127: struct kevent event_data[NUM_EVENT_SLOTS]; 183 -: 128: memset((void *)event_data, '\0', sizeof(struct kevent) 184 -: 129: * NUM_EVENT_SLOTS); 185 -: 130: int i, refresh = 0; 186 -: 131: 187 -: 132: int count = kevent(kq, NULL, 0, event_data, 4096, &timeout); 188 -: 133: 189 -: 134: for (i = 0; i < count; i++) { 190 -: 135:/* if (event_data[i].fflags & NOTE_DELETE) 191 -: 136: puts("NOTE_DELETE"); 192 -: 137: if (event_data[i].fflags & NOTE_WRITE) 193 -: 138: puts("NOTE_WRITE"); 194 -: 139: if (event_data[i].fflags & NOTE_EXTEND) 195 -: 140: puts("NOTE_EXTEND"); 196 -: 141: if (event_data[i].fflags & NOTE_ATTRIB) 197 -: 142: puts("NOTE_ATTRIB"); 198 -: 143: if (event_data[i].fflags & NOTE_LINK) 199 -: 144: puts("NOTE_LINK"); 200 -: 145: if (event_data[i].fflags & NOTE_RENAME) 201 -: 146: puts("NOTE_RENAME"); 202 -: 147: if (event_data[i].fflags & NOTE_REVOKE) 203 -: 148: puts("NOTE_REVOKE"); */ 204 -: 149: 205 -: 150: if (event_data[i].fflags & KQUEUE_FFLAGS) { 206 -: 151: refresh = 1; 207 -: 152: break; 208 -: 153: } 209 -: 154: } 210 -: 155: 211 -: 156: if (refresh) { 212 -: 157: free_dirlist(); 213 -: 158: if (list_dir() != EXIT_SUCCESS) 214 -: 159: exit_code = EXIT_FAILURE; 215 -: 160: return; 216 -: 161: } 217 -: 162: 218 -: 163: if (event_fd >= 0) { 219 -: 164: close(event_fd); 220 -: 165: event_fd = -1; 221 -: 166: watch = 0; 222 -: 167: } 223 -: 168:} 224 -: 169:#endif 225 -: 170: 226 -: 171:void 227function set_term_title called 613 returned 100% blocks executed 89% 228 613: 172:set_term_title(const char *str) 229 -: 173:{ 230 613: 174: char *tmp = (char *)NULL; 231 613: 175: tmp = home_tilde(str); 232 613: 175-block 0 233call 0 returned 613 234 -: 176: 235 613*: 177: printf("\033]2;%s - %s\007", PROGRAM_NAME, tmp ? tmp : str); 236branch 0 taken 613 (fallthrough) 237branch 1 taken 0 238 613: 177-block 0 239unconditional 2 taken 613 240 %%%%%: 177-block 1 241unconditional 3 never executed 242 613: 177-block 2 243call 4 returned 613 244 613: 178: fflush(stdout); 245call 0 returned 613 246 -: 179: 247 613: 180: if (tmp) 248branch 0 taken 613 (fallthrough) 249branch 1 taken 0 250 613: 181: free(tmp); 251 613: 181-block 0 252unconditional 0 taken 613 253 613: 182:} 254 -: 183: 255 -: 184:int 256function filter_function called 7 returned 100% blocks executed 85% 257 7: 185:filter_function(const char *arg) 258 -: 186:{ 259 7: 187: if (!arg) { 260 7: 187-block 0 261branch 0 taken 2 (fallthrough) 262branch 1 taken 5 263 2*: 188: printf(_("Current filter: %c%s\n"), filter_rev ? '!' : 0, 264 1: 188-block 0 265unconditional 0 taken 1 266 1: 188-block 1 267unconditional 1 taken 1 268 2: 188-block 2 269branch 2 taken 0 (fallthrough) 270branch 3 taken 2 271 %%%%%: 188-block 3 272unconditional 4 never executed 273 2: 188-block 4 274unconditional 5 taken 2 275 2: 188-block 5 276call 6 returned 2 277call 7 returned 2 278 2: 189: filter ? filter : "none"); 279 2: 189-block 0 280branch 0 taken 1 (fallthrough) 281branch 1 taken 1 282 2: 190: return EXIT_SUCCESS; 283unconditional 0 taken 2 284 -: 191: } 285 -: 192: 286 5: 193: if (*arg == '-' && strcmp(arg, "--help") == 0) { 287 5: 193-block 0 288branch 0 taken 1 (fallthrough) 289branch 1 taken 4 290 1: 193-block 1 291branch 2 taken 1 (fallthrough) 292branch 3 taken 0 293 1: 194: puts(_(FILTER_USAGE)); 294 1: 194-block 0 295call 0 returned 1 296call 1 returned 1 297 1: 195: return EXIT_SUCCESS; 298unconditional 0 taken 1 299 -: 196: } 300 -: 197: 301 4: 198: if (*arg == 'u' && strcmp(arg, "unset") == 0) { 302 4: 198-block 0 303branch 0 taken 1 (fallthrough) 304branch 1 taken 3 305 1: 198-block 1 306branch 2 taken 1 (fallthrough) 307branch 3 taken 0 308 1: 199: if (filter) { 309 1: 199-block 0 310branch 0 taken 1 (fallthrough) 311branch 1 taken 0 312 1: 200: free(filter); 313 1: 201: filter = (char *)NULL; 314 1: 202: regfree(®ex_exp); 315 1: 202-block 0 316call 0 returned 1 317 1: 203: puts(_("Filter unset")); 318call 0 returned 1 319call 1 returned 1 320 1: 204: filter_rev = 0; 321unconditional 0 taken 1 322 -: 205: } else { 323 #####: 206: puts(_("No filter set")); 324 %%%%%: 206-block 0 325call 0 never executed 326call 1 never executed 327unconditional 2 never executed 328 -: 207: } 329 -: 208: 330 1: 209: return EXIT_SUCCESS; 331 1: 209-block 0 332unconditional 0 taken 1 333 -: 210: } 334 -: 211: 335 3: 212: if (filter) 336 3: 212-block 0 337branch 0 taken 2 (fallthrough) 338branch 1 taken 1 339 2: 213: free(filter); 340 2: 213-block 0 341unconditional 0 taken 2 342 -: 214: 343 3: 215: regfree(®ex_exp); 344 3: 215-block 0 345call 0 returned 3 346 -: 216: 347 3: 217: if (*arg == '!') { 348branch 0 taken 1 (fallthrough) 349branch 1 taken 2 350 1: 218: filter_rev = 1; 351 1: 219: arg++; 352 1: 219-block 0 353unconditional 0 taken 1 354 -: 220: } else { 355 2: 221: filter_rev = 0; 356 2: 221-block 0 357unconditional 0 taken 2 358 -: 222: } 359 -: 223: 360 3: 224: filter = savestring(arg, strlen(arg)); 361 3: 224-block 0 362call 0 returned 3 363 -: 225: 364 3: 226: if (regcomp(®ex_exp, filter, REG_NOSUB | REG_EXTENDED) != EXIT_SUCCESS) { 365call 0 returned 3 366branch 1 taken 0 (fallthrough) 367branch 2 taken 3 368 #####: 227: fprintf(stderr, _("%s: '%s': Invalid regular expression\n"), 369 %%%%%: 227-block 0 370call 0 never executed 371call 1 never executed 372 -: 228: PROGRAM_NAME, filter); 373 #####: 229: free(filter); 374 #####: 230: filter = (char *)NULL; 375 #####: 231: regfree(®ex_exp); 376call 0 never executed 377unconditional 1 never executed 378 -: 232: } else { 379 3: 233: puts(_("New filter successfully set")); 380 3: 233-block 0 381call 0 returned 3 382call 1 returned 3 383unconditional 2 taken 3 384 -: 234: } 385 -: 235: 386 3: 236: return EXIT_SUCCESS; 387 3: 236-block 0 388unconditional 0 taken 3 389 -: 237:} 390 -: 238: 391 -: 239:/* Print either all tips (if ALL == 1) or just a random one (ALL == 0) */ 392 -: 240:void 393function print_tips called 5 returned 100% blocks executed 100% 394 5: 241:print_tips(int all) 395 -: 242:{ 396 5: 243: const char *TIPS[] = { 397 -: 244: "Try the autocd and auto-open functions: run 'FILE' instead " 398 -: 245: "of 'open FILE' or 'cd FILE'", 399 -: 246: "Add a new entry to the mimelist file with 'mm edit' or F6", 400 -: 247: "Do not forget to take a look at the manpage", 401 -: 248: "Need more speed? Try the light mode (Alt-y)", 402 -: 249: "The Selection Box is shared among different instances of CliFM", 403 -: 250: "Select files here and there with the 's' command", 404 -: 251: "Use wildcards and regular expressions with the 's' command: " 405 -: 252: "'s *.c' or 's .*\\.c$'", 406 -: 253: "ELN's and the 'sel' keyword work for shell commands as well: " 407 -: 254: "'file 1 sel'", 408 -: 255: "Press TAB to automatically expand an ELN: 's 2' -> TAB -> " 409 -: 256: "'s FILENAME'", 410 -: 257: "Easily copy everything in CWD into another directory: 's * " 411 -: 258: "&& c sel ELN/DIR'", 412 -: 259: "Use ranges (ELN-ELN) to easily move multiple files: 'm 3-12 " 413 -: 260: "ELN/DIR'", 414 -: 261: "Trash files with a simple 't ELN'", 415 -: 262: "Get mime information for a file: 'mm info ELN'", 416 -: 263: "If too many files are listed, try enabling the pager ('pg on')", 417 -: 264: "Once in the pager, go backwards pressing the keyboard shortcut " 418 -: 265: "provided by your terminal emulator", 419 -: 266: "Once in the pager, press 'q' to stop it", 420 -: 267: "Press 'Alt-l' to switch to long view mode", 421 -: 268: "Search for files using the slash command: '/*.png'", 422 -: 269: "The search function allows regular expressions: '/^c'", 423 -: 270: "Add a new bookmark by just entering 'bm a ELN/FILE'", 424 -: 271: "Use c, l, m, md, and r instead of cp, ln, mv, mkdir, and rm", 425 -: 272: "Access a remote file system using the 'net' command", 426 -: 273: "Manage default associated applications with the 'mime' command", 427 -: 274: "Go back and forth in the directory history with 'Alt-j' and 'Alt-k' " 428 -: 275: "or Shift-Left and Shift-Right", 429 -: 276: "Open a new instance of CliFM with the 'x' command: 'x ELN/DIR'", 430 -: 277: "Send a command directly to the system shell with ';CMD'", 431 -: 278: "Run the last executed command by just running '!!'", 432 -: 279: "Import aliases from file using 'alias import FILE'", 433 -: 280: "List available aliases by running 'alias'", 434 -: 281: "Create aliases to easily run your preferred commands", 435 -: 282: "Open and edit the configuration file with 'edit'", 436 -: 283: "Find a description for each CliFM command by running 'cmd'", 437 -: 284: "Print the currently used color codes list by entering 'cc'", 438 -: 285: "Press 'Alt-i' or 'Alt-.' to toggle hidden files on/off", 439 -: 286: "List mountpoints by pressing 'Alt-m'", 440 -: 287: "Disallow the use of shell commands with the -x option: 'clifm -x'", 441 -: 288: "Go to the root directory by just pressing 'Alt-r'", 442 -: 289: "Go to the home directory by just pressing 'Alt-e'", 443 -: 290: "Press 'F8' to open and edit current color scheme", 444 -: 291: "Press 'F9' to open and edit the keybindings file", 445 -: 292: "Press 'F10' to open and edit the configuration file", 446 -: 293: "Press 'F11' to open and edit the bookmarks file", 447 -: 294: "Set the starting path: 'clifm PATH'", 448 -: 295: "Use the 'o' command to open files and directories: '12'", 449 -: 296: "Bypass the resource opener specifying an application: '12 " 450 -: 297: "leafpad'", 451 -: 298: "Open a file and send it to the background running '24&'", 452 -: 299: "Create a custom prompt editing the configuration file", 453 -: 300: "Customize color codes via 'cs edit' command (F6)", 454 -: 301: "Open the bookmarks manager by just pressing 'Alt-b'", 455 -: 302: "Chain commands using ; and &&: 's 2 7-10; r sel'", 456 -: 303: "Add emojis to the prompt by copying them to the Prompt line " 457 -: 304: "in the configuration file", 458 -: 305: "Create a new profile running 'pf add PROFILE' or 'clifm -P " 459 -: 306: "PROFILE'", 460 -: 307: "Switch profiles using 'pf set PROFILE'", 461 -: 308: "Delete a profile using 'pf del PROFILE'", 462 -: 309: "Copy selected files into CWD by just running 'v sel' or " 463 -: 310: "pressing Ctrl-Alt-v", 464 -: 311: "Use 'p ELN' to print file properties for ELN", 465 -: 312: "Deselect all selected files by pressing 'Alt-d'", 466 -: 313: "Select all files in CWD by pressing 'Alt-a'", 467 -: 314: "Jump to the Selection Box by pressing 'Alt-s'", 468 -: 315: "Restore trashed files using the 'u' command", 469 -: 316: "Empty the trash bin running 't clear'", 470 -: 317: "Press Alt-f to toggle list-folders-first on/off", 471 -: 318: "Use the 'fc' command to disable the files counter", 472 -: 319: "Take a look at the splash screen with the 'splash' command", 473 -: 320: "Have some fun trying the 'bonus' command", 474 -: 321: "Launch the default system shell in CWD using ':' or ';'", 475 -: 322: "Use 'Alt-z' and 'Alt-x' to switch sorting methods", 476 -: 323: "Reverse sorting order using the 'rev' option: 'st rev'", 477 -: 324: "Compress and decompress files using the 'ac' and 'ad' " 478 -: 325: "commands respectivelly", 479 -: 326: "Rename multiple files at once with the bulk rename function: " 480 -: 327: "'br *.txt'", 481 -: 328: "Need no more tips? Disable this feature in the configuration " 482 -: 329: "file", 483 -: 330: "Need root privileges? Launch a new instance of CLifM as root " 484 -: 331: "running the 'X' command", 485 -: 332: "Create custom commands and features using the 'actions' command", 486 -: 333: "Create a fresh configuration file by running 'edit gen'", 487 -: 334: "Use 'ln edit' (or 'le') to edit symbolic links", 488 -: 335: "Change default keyboard shortcuts by editing the keybindings file (F9)", 489 -: 336: "Keep in sight previous and next visited directories enabling the " 490 -: 337: "DirhistMap option in the configuration file", 491 -: 338: "Leave no traces at all running in stealth mode (-S)", 492 -: 339: "Pin a file via the 'pin' command and then use it with the " 493 -: 340: "period keyword (,). Ex: 'pin DIR' and then 'cd ,'", 494 -: 341: "Switch between color schemes using the 'cs' command", 495 -: 342: "Try the 'j' command to quickly navigate through visited " 496 -: 343: "directories", 497 -: 344: "Switch workspaces by pressing Alt-[1-4]", 498 -: 345: "Use the 'ws' command to list available workspaces", 499 -: 346: "Take a look at available plugins using the 'actions' command", 500 -: 347: "Space is not needed: enter 'p12' instead of 'p 12'", 501 -: 348: "When searching or selecting files, use the exclamation mark " 502 -: 349: "to reverse the meaning of a pattern", 503 -: 350: "Enable the TrashAsRm option to prevent accidental deletions", 504 -: 351: "Don't like ELN's? Disable them using the -e option", 505 -: 352: "Use the 'n' command to create multiple files and/or directories", 506 -: 353: "Customize your prompt by adding prompt commands via the 'edit' " 507 -: 354: "command (F10)", 508 -: 355: "Need git integration? Consult the manpage", 509 -: 356: "Accept a given suggestion by pressing the Right arrow key", 510 -: 357: "Accept only the first suggested word by pressing Alt-f or Alt-Right", 511 -: 358: "Enter 'c sel' to copy selected files into the current directory", 512 -: 359: "Take a look at available plugins via the 'actions' command", 513 -: 360: NULL}; 514 -: 361: 515 5: 362: size_t tipsn = (sizeof(TIPS) / sizeof(TIPS[0])) - 1; 516 -: 363: 517 5: 364: if (all) { 518 5: 364-block 0 519branch 0 taken 1 (fallthrough) 520branch 1 taken 4 521 -: 365: size_t i; 522 96: 366: for (i = 0; i < tipsn; i++) 523 1: 366-block 0 524unconditional 0 taken 1 525unconditional 1 taken 95 526 96: 366-block 1 527branch 2 taken 95 528branch 3 taken 1 (fallthrough) 529 95: 367: printf("%sTIP %zu%s: %s\n", BOLD, i, df_c, TIPS[i]); 530 95: 367-block 0 531call 0 returned 95 532 -: 368: 533 1: 369: return; 534 1: 369-block 0 535unconditional 0 taken 1 536 -: 370: } 537 -: 371: 538 4: 372: srand((unsigned int)time(NULL)); 539 4: 372-block 0 540call 0 returned 4 541call 1 returned 4 542 4: 373: printf("%sTIP%s: %s\n", BOLD, df_c, TIPS[rand() % (int)tipsn]); 543call 0 returned 4 544call 1 returned 4 545 -: 374:} 546 -: 375: 547 -: 376:/* Open DIR in a new instance of the program (using TERM, set in the config 548 -: 377: * file, as terminal emulator) */ 549 -: 378:int 550function new_instance called 3 returned 100% blocks executed 60% 551 3: 379:new_instance(char *dir, int sudo) 552 -: 380:{ 553 -: 381:#if defined(__HAIKU__) 554 -: 382: UNUSED(dir); UNUSED(sudo); 555 -: 383: fprintf(stderr, _("%s: This function is not available on Haiku\n"), 556 -: 384: PROGRAM_NAME); 557 -: 385: return EXIT_FAILURE; 558 -: 386:#elif defined(__OpenBSD__) 559 -: 387: UNUSED(dir); UNUSED(sudo); 560 -: 388: fprintf(stderr, _("%s: This function is not available on OpenBSD\n"), 561 -: 389: PROGRAM_NAME); 562 -: 390: return EXIT_FAILURE; 563 -: 391:#else 564 3: 392: if (!term) { 565 3: 392-block 0 566branch 0 taken 0 (fallthrough) 567branch 1 taken 3 568 #####: 393: fprintf(stderr, _("%s: Default terminal not set. Use the " 569 %%%%%: 393-block 0 570call 0 never executed 571call 1 never executed 572 -: 394: "configuration file to set one\n"), PROGRAM_NAME); 573 #####: 395: return EXIT_FAILURE; 574unconditional 0 never executed 575 -: 396: } 576 -: 397: 577 3: 398: if (!(flags & GUI)) { 578 3: 398-block 0 579branch 0 taken 0 (fallthrough) 580branch 1 taken 3 581 #####: 399: fprintf(stderr, _("%s: Function only available for graphical " 582 %%%%%: 399-block 0 583call 0 never executed 584call 1 never executed 585 -: 400: "environments\n"), PROGRAM_NAME); 586 #####: 401: return EXIT_FAILURE; 587unconditional 0 never executed 588 -: 402: } 589 -: 403: 590 -: 404: /* Get absolute path of executable name of itself */ 591 -: 405:#if defined(__linux__) 592 3: 406: char *self = realpath("/proc/self/exe", NULL); 593 3: 406-block 0 594call 0 returned 3 595 -: 407: 596 3: 408: if (!self) { 597branch 0 taken 0 (fallthrough) 598branch 1 taken 3 599 -: 409:#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 600 -: 410: const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; 601 -: 411: char *self = malloc(PATH_MAX); 602 -: 412: size_t len = PATH_MAX; 603 -: 413: 604 -: 414: if (!self || sysctl(mib, 4, self, &len, NULL, 0) == -1) { 605 -: 415:#endif 606 #####: 416: fprintf(stderr, "%s: %s\n", PROGRAM_NAME, strerror(errno)); 607 %%%%%: 416-block 0 608call 0 never executed 609call 1 never executed 610 #####: 417: return EXIT_FAILURE; 611unconditional 0 never executed 612 -: 418: } 613 -: 419: 614 3: 420: if (!dir) { 615 3: 420-block 0 616branch 0 taken 0 (fallthrough) 617branch 1 taken 3 618 #####: 421: free(self); 619 #####: 422: return EXIT_FAILURE; 620 %%%%%: 422-block 0 621unconditional 0 never executed 622 -: 423: } 623 -: 424: 624 3: 425: char *_sudo = (char *)NULL; 625 3: 426: if (sudo) { 626 3: 426-block 0 627branch 0 taken 1 (fallthrough) 628branch 1 taken 2 629 1: 427: _sudo = get_sudo_path(); 630 1: 427-block 0 631call 0 returned 1 632 1: 428: if (!_sudo) { 633branch 0 taken 0 (fallthrough) 634branch 1 taken 1 635 #####: 429: free(self); 636 #####: 430: return EXIT_FAILURE; 637 %%%%%: 430-block 0 638unconditional 0 never executed 639 -: 431: } 640 -: 432: } 641 -: 433: 642 3: 434: char *deq_dir = dequote_str(dir, 0); 643 3: 434-block 0 644call 0 returned 3 645 -: 435: 646 3: 436: if (!deq_dir) { 647branch 0 taken 0 (fallthrough) 648branch 1 taken 3 649 #####: 437: fprintf(stderr, _("%s: %s: Error dequoting file name\n"), 650 %%%%%: 437-block 0 651call 0 never executed 652call 1 never executed 653 -: 438: PROGRAM_NAME, dir); 654 #####: 439: free(self); 655 #####: 440: return EXIT_FAILURE; 656unconditional 0 never executed 657 -: 441: } 658 -: 442: 659 -: 443: struct stat file_attrib; 660 -: 444: 661 3: 445: if (stat(deq_dir, &file_attrib) == -1) { 662 3: 445-block 0 663call 0 returned 3 664branch 1 taken 0 (fallthrough) 665branch 2 taken 3 666 #####: 446: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, deq_dir, 667call 0 never executed 668 #####: 447: strerror(errno)); 669 %%%%%: 447-block 0 670call 0 never executed 671 #####: 448: free(self); 672 #####: 449: free(deq_dir); 673 #####: 450: return EXIT_FAILURE; 674unconditional 0 never executed 675 -: 451: } 676 -: 452: 677 3: 453: if ((file_attrib.st_mode & S_IFMT) != S_IFDIR) { 678 3: 453-block 0 679branch 0 taken 0 (fallthrough) 680branch 1 taken 3 681 #####: 454: fprintf(stderr, _("%s: %s: Not a directory\n"), PROGRAM_NAME, deq_dir); 682 %%%%%: 454-block 0 683call 0 never executed 684call 1 never executed 685 #####: 455: free(self); 686 #####: 456: free(deq_dir); 687 #####: 457: return EXIT_FAILURE; 688unconditional 0 never executed 689 -: 458: } 690 -: 459: 691 3: 460: char *path_dir = (char *)NULL; 692 -: 461: 693 3: 462: if (*deq_dir != '/') { 694 3: 462-block 0 695branch 0 taken 0 (fallthrough) 696branch 1 taken 3 697 #####: 463: path_dir = (char *)xnmalloc(strlen(ws[cur_ws].path) 698 #####: 464: + strlen(deq_dir) + 2, sizeof(char)); 699 %%%%%: 464-block 0 700call 0 never executed 701 #####: 465: sprintf(path_dir, "%s/%s", ws[cur_ws].path, deq_dir); 702 #####: 466: free(deq_dir); 703unconditional 0 never executed 704 -: 467: } else { 705 3: 468: path_dir = deq_dir; 706 3: 468-block 0 707unconditional 0 taken 3 708 -: 469: } 709 -: 470: 710 3: 471: char **tmp_term = (char **)NULL, 711 3: 472: **tmp_cmd = (char **)NULL; 712 -: 473: 713 3: 474: if (strcntchr(term, ' ') != -1) { 714 3: 474-block 0 715call 0 returned 3 716branch 1 taken 3 (fallthrough) 717branch 2 taken 0 718 3: 475: tmp_term = get_substr(term, ' '); 719 3: 475-block 0 720call 0 returned 3 721 -: 476: 722 3: 477: if (tmp_term) { 723branch 0 taken 3 (fallthrough) 724branch 1 taken 0 725 -: 478: int i; 726 9: 479: for (i = 0; tmp_term[i]; i++); 727 3: 479-block 0 728unconditional 0 taken 3 729 6: 479-block 1 730unconditional 1 taken 6 731 9: 479-block 2 732branch 2 taken 6 733branch 3 taken 3 (fallthrough) 734 -: 480: 735 3: 481: int num = i; 736 3: 482: tmp_cmd = (char **)xrealloc(tmp_cmd, ((size_t)i + (sudo ? 4 : 3)) 737 3: 482-block 0 738branch 0 taken 1 (fallthrough) 739branch 1 taken 2 740 1: 482-block 1 741unconditional 2 taken 1 742 2: 482-block 2 743unconditional 3 taken 2 744 3: 482-block 3 745call 4 returned 3 746 -: 483: * sizeof(char *)); 747 9: 484: for (i = 0; tmp_term[i]; i++) { 748unconditional 0 taken 3 749 9: 484-block 0 750branch 1 taken 6 751branch 2 taken 3 (fallthrough) 752 6: 485: tmp_cmd[i] = savestring(tmp_term[i], strlen(tmp_term[i])); 753 6: 485-block 0 754call 0 returned 6 755 6: 486: free(tmp_term[i]); 756unconditional 0 taken 6 757 -: 487: } 758 3: 488: free(tmp_term); 759 -: 489: 760 3: 490: i = num - 1; 761 3: 491: int plus = 1; 762 -: 492: 763 3: 493: if (sudo) { 764 3: 493-block 0 765branch 0 taken 1 (fallthrough) 766branch 1 taken 2 767 1: 494: tmp_cmd[i + plus] = (char *)xnmalloc(strlen(self) + 1, 768 1: 494-block 0 769call 0 returned 1 770 -: 495: sizeof(char)); 771 1: 496: strcpy(tmp_cmd[i + plus], _sudo); 772 1: 497: plus++; 773unconditional 0 taken 1 774 -: 498: } 775 -: 499: 776 3: 500: tmp_cmd[i + plus] = (char *)xnmalloc(strlen(self) + 1, sizeof(char)); 777 3: 500-block 0 778call 0 returned 3 779 3: 501: strcpy(tmp_cmd[i + plus++], self); 780 3: 502: tmp_cmd[i + plus] = (char *)xnmalloc(strlen(path_dir) + 1, sizeof(char)); 781call 0 returned 3 782 3: 503: strcpy(tmp_cmd[i + plus++], path_dir); 783 3: 504: tmp_cmd[i + plus] = (char *)NULL; 784unconditional 0 taken 3 785 -: 505: } 786 -: 506: } 787 -: 507: 788 3: 508: int ret = -1; 789 -: 509: 790 3: 510: if (tmp_cmd) { 791 3: 510-block 0 792branch 0 taken 3 (fallthrough) 793branch 1 taken 0 794 3: 511: ret = launch_execve(tmp_cmd, BACKGROUND, E_NOFLAG); 795 3: 511-block 0 796call 0 returned 3 797 -: 512: size_t i; 798 16: 513: for (i = 0; tmp_cmd[i]; i++) 799unconditional 0 taken 3 800 16: 513-block 0 801branch 1 taken 13 802branch 2 taken 3 (fallthrough) 803 13: 514: free(tmp_cmd[i]); 804 13: 514-block 0 805unconditional 0 taken 13 806 3: 515: free(tmp_cmd); 807 3: 515-block 0 808unconditional 0 taken 3 809 -: 516: } else { 810 #####: 517: fprintf(stderr, _("%s: No option specified for '%s'\n" 811call 0 never executed 812 -: 518: "Trying '%s -e %s %s'\n"), PROGRAM_NAME, term, 813 #####: 519: term, self, ws[cur_ws].path); 814 %%%%%: 519-block 0 815call 0 never executed 816 #####: 520: if (sudo) { 817branch 0 never executed 818branch 1 never executed 819 #####: 521: char *cmd[] = {term, "-e", _sudo, self, path_dir, NULL}; 820 #####: 522: ret = launch_execve(cmd, BACKGROUND, E_NOFLAG); 821 %%%%%: 522-block 0 822call 0 never executed 823 -: 523: } else { 824 #####: 524: char *cmd[] = {term, "-e", self, path_dir, NULL}; 825 #####: 525: ret = launch_execve(cmd, BACKGROUND, E_NOFLAG); 826 %%%%%: 525-block 0 827call 0 never executed 828 -: 526: } 829 -: 527: } 830 -: 528: 831 3: 529: free(_sudo); 832 3: 530: free(path_dir); 833 3: 531: free(self); 834 -: 532: 835 3: 533: if (ret != EXIT_SUCCESS) 836 3: 533-block 0 837branch 0 taken 0 (fallthrough) 838branch 1 taken 3 839 #####: 534: fprintf(stderr, _("%s: Error lauching new instance\n"), PROGRAM_NAME); 840 %%%%%: 534-block 0 841call 0 never executed 842call 1 never executed 843unconditional 2 never executed 844 -: 535: 845 3: 536: return ret; 846 3: 536-block 0 847unconditional 0 taken 3 848 -: 537:#endif /* !__HAIKU__ */ 849 -: 538:// cppcheck-suppress syntaxError 850 -: 539:} 851 -: 540: 852 -: 541:int 853function alias_import called 0 returned 0% blocks executed 0% 854 #####: 542:alias_import(char *file) 855 -: 543:{ 856 #####: 544: if (xargs.stealth_mode == 1) { 857 %%%%%: 544-block 0 858branch 0 never executed 859branch 1 never executed 860 #####: 545: printf("%s: The alias function is disabled in stealth mode\n", 861 %%%%%: 545-block 0 862call 0 never executed 863 -: 546: PROGRAM_NAME); 864 #####: 547: return EXIT_SUCCESS; 865unconditional 0 never executed 866 -: 548: } 867 -: 549: 868 #####: 550: if (!file) 869 %%%%%: 550-block 0 870branch 0 never executed 871branch 1 never executed 872 #####: 551: return EXIT_FAILURE; 873 %%%%%: 551-block 0 874unconditional 0 never executed 875 -: 552: 876 #####: 553: char rfile[PATH_MAX] = ""; 877 #####: 554: rfile[0] = '\0'; 878 -: 555: 879 -: 556: /* if (*file == '~' && *(file + 1) == '/') { */ 880 -: 557: 881 #####: 558: if (*file == '~') { 882 %%%%%: 558-block 0 883branch 0 never executed 884branch 1 never executed 885 #####: 559: char *file_exp = tilde_expand(file); 886 %%%%%: 559-block 0 887call 0 never executed 888 #####: 560: if (!file_exp) { 889branch 0 never executed 890branch 1 never executed 891 #####: 561: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, file, strerror(errno)); 892 %%%%%: 561-block 0 893call 0 never executed 894call 1 never executed 895 #####: 562: return EXIT_FAILURE; 896unconditional 0 never executed 897 -: 563: } 898 -: 564: 899 #####: 565: if (realpath(file_exp, rfile) == NULL) { 900 %%%%%: 565-block 0 901call 0 never executed 902branch 1 never executed 903branch 2 never executed 904 #####: 566: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, file_exp, 905call 0 never executed 906 #####: 567: strerror(errno)); 907 %%%%%: 567-block 0 908call 0 never executed 909 #####: 568: free(file_exp); 910 #####: 569: return EXIT_FAILURE; 911unconditional 0 never executed 912 -: 570: } 913 #####: 571: free(file_exp); 914 %%%%%: 571-block 0 915unconditional 0 never executed 916 -: 572: } else { 917 #####: 573: if (realpath(file, rfile) == NULL) { 918 %%%%%: 573-block 0 919call 0 never executed 920branch 1 never executed 921branch 2 never executed 922 #####: 574: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, file, strerror(errno)); 923 %%%%%: 574-block 0 924call 0 never executed 925call 1 never executed 926 #####: 575: return EXIT_FAILURE; 927unconditional 0 never executed 928 -: 576: } 929 -: 577: } 930 -: 578: 931 #####: 579: if (rfile[0] == '\0') { 932 %%%%%: 579-block 0 933branch 0 never executed 934branch 1 never executed 935 #####: 580: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, file, strerror(errno)); 936 %%%%%: 580-block 0 937call 0 never executed 938call 1 never executed 939 #####: 581: return EXIT_FAILURE; 940unconditional 0 never executed 941 -: 582: } 942 -: 583: 943 -: 584: /* Open the file to import aliases from */ 944 -: 585: int fd; 945 #####: 586: FILE *fp = open_fstream_r(rfile, &fd); 946 %%%%%: 586-block 0 947call 0 never executed 948 #####: 587: if (!fp) { 949branch 0 never executed 950branch 1 never executed 951 #####: 588: fprintf(stderr, "b%s: '%s': %s\n", PROGRAM_NAME, rfile, strerror(errno)); 952 %%%%%: 588-block 0 953call 0 never executed 954call 1 never executed 955 #####: 589: return EXIT_FAILURE; 956unconditional 0 never executed 957 -: 590: } 958 -: 591: 959 -: 592: /* Open CliFM's config file as well */ 960 #####: 593: FILE *config_fp = fopen(config_file, "a"); 961 %%%%%: 593-block 0 962call 0 never executed 963 #####: 594: if (!config_fp) { 964branch 0 never executed 965branch 1 never executed 966 #####: 595: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, config_file, 967call 0 never executed 968 #####: 596: strerror(errno)); 969 %%%%%: 596-block 0 970call 0 never executed 971 #####: 597: close_fstream(fp, fd); 972call 0 never executed 973 #####: 598: return EXIT_FAILURE; 974unconditional 0 never executed 975 -: 599: } 976 -: 600: 977 #####: 601: size_t line_size = 0, i; 978 #####: 602: char *line = (char *)NULL; 979 #####: 603: size_t alias_found = 0, alias_imported = 0; 980 #####: 604: int first = 1; 981 -: 605: 982 #####: 606: while (getline(&line, &line_size, fp) > 0) { 983 %%%%%: 606-block 0 984unconditional 0 never executed 985 %%%%%: 606-block 1 986call 1 never executed 987branch 2 never executed 988branch 3 never executed 989 #####: 607: if (*line == 'a' && strncmp(line, "alias ", 6) == 0) { 990 %%%%%: 607-block 0 991branch 0 never executed 992branch 1 never executed 993 %%%%%: 607-block 1 994branch 2 never executed 995branch 3 never executed 996 #####: 608: alias_found++; 997 -: 609: 998 -: 610: /* If alias name conflicts with some internal command, 999 -: 611: * skip it */ 1000 #####: 612: char *alias_name = strbtw(line, ' ', '='); 1001 %%%%%: 612-block 0 1002call 0 never executed 1003 #####: 613: if (!alias_name) 1004branch 0 never executed 1005branch 1 never executed 1006 #####: 614: continue; 1007 %%%%%: 614-block 0 1008unconditional 0 never executed 1009 -: 615: 1010 #####: 616: if (is_internal_c(alias_name)) { 1011 %%%%%: 616-block 0 1012call 0 never executed 1013branch 1 never executed 1014branch 2 never executed 1015 #####: 617: fprintf(stderr, _("%s: Alias conflicts with " 1016 %%%%%: 617-block 0 1017call 0 never executed 1018call 1 never executed 1019 -: 618: "internal command\n"), alias_name); 1020 #####: 619: free(alias_name); 1021 #####: 620: continue; 1022unconditional 0 never executed 1023 -: 621: } 1024 -: 622: 1025 #####: 623: char *p = line + 6; /* p points now to the beginning of the 1026 -: 624: alias name (because "alias " == 6) */ 1027 -: 625: 1028 -: 626: /* Only accept single quoted aliases commands */ 1029 #####: 627: char *tmp = strchr(p, '='); 1030 #####: 628: if (!tmp) 1031 %%%%%: 628-block 0 1032branch 0 never executed 1033branch 1 never executed 1034 #####: 629: continue; 1035 %%%%%: 629-block 0 1036unconditional 0 never executed 1037 #####: 630: if (*(++tmp) != '\'') { 1038 %%%%%: 630-block 0 1039branch 0 never executed 1040branch 1 never executed 1041 #####: 631: free(alias_name); 1042 #####: 632: continue; 1043 %%%%%: 632-block 0 1044unconditional 0 never executed 1045 -: 633: } 1046 -: 634: 1047 -: 635: /* If alias already exists, skip it too */ 1048 #####: 636: int exists = 0; 1049 -: 637: 1050 #####: 638: for (i = 0; i < aliases_n; i++) { 1051 %%%%%: 638-block 0 1052unconditional 0 never executed 1053 %%%%%: 638-block 1 1054unconditional 1 never executed 1055 %%%%%: 638-block 2 1056branch 2 never executed 1057branch 3 never executed 1058 #####: 639: int alias_len = strcntchr(aliases[i], '='); 1059 %%%%%: 639-block 0 1060call 0 never executed 1061 #####: 640: if (alias_len != -1 && strncmp(aliases[i], p, 1062branch 0 never executed 1063branch 1 never executed 1064 #####: 641: (size_t)alias_len + 1) == 0) { 1065 %%%%%: 641-block 0 1066branch 0 never executed 1067branch 1 never executed 1068 #####: 642: exists = 1; 1069 #####: 643: break; 1070 %%%%%: 643-block 0 1071unconditional 0 never executed 1072 -: 644: } 1073 -: 645: } 1074 -: 646: 1075 #####: 647: if (!exists) { 1076 %%%%%: 647-block 0 1077branch 0 never executed 1078branch 1 never executed 1079 #####: 648: if (first) { 1080 %%%%%: 648-block 0 1081branch 0 never executed 1082branch 1 never executed 1083 #####: 649: first = 0; 1084 #####: 650: fputs("\n\n", config_fp); 1085 %%%%%: 650-block 0 1086call 0 never executed 1087unconditional 1 never executed 1088 -: 651: } 1089 -: 652: 1090 #####: 653: alias_imported++; 1091 -: 654: 1092 -: 655: /* Write the new alias into CLiFM config file */ 1093 #####: 656: fputs(line, config_fp); 1094 %%%%%: 656-block 0 1095call 0 never executed 1096unconditional 1 never executed 1097 -: 657: } else { 1098 #####: 658: fprintf(stderr, _("%s: Alias already exists\n"), 1099 %%%%%: 658-block 0 1100call 0 never executed 1101call 1 never executed 1102unconditional 2 never executed 1103 -: 659: alias_name); 1104 -: 660: } 1105 -: 661: 1106 #####: 662: free(alias_name); 1107 %%%%%: 662-block 0 1108unconditional 0 never executed 1109 -: 663: } 1110 -: 664: } 1111 -: 665: 1112 #####: 666: free(line); 1113 #####: 667: close_fstream(fp, fd); 1114 %%%%%: 667-block 0 1115call 0 never executed 1116 #####: 668: fclose(config_fp); 1117call 0 never executed 1118 -: 669: 1119 -: 670: /* No alias was found in FILE */ 1120 #####: 671: if (alias_found == 0) { 1121branch 0 never executed 1122branch 1 never executed 1123 #####: 672: fprintf(stderr, _("%s: %s: No alias found\n"), PROGRAM_NAME, 1124 %%%%%: 672-block 0 1125call 0 never executed 1126call 1 never executed 1127 -: 673: rfile); 1128 #####: 674: return EXIT_FAILURE; 1129unconditional 0 never executed 1130 -: 675: } 1131 -: 676: 1132 -: 677: /* Aliases were found in FILE, but none was imported (either because 1133 -: 678: * they conflicted with internal commands or the alias already 1134 -: 679: * existed) */ 1135 #####: 680: else if (alias_imported == 0) { 1136 %%%%%: 680-block 0 1137branch 0 never executed 1138branch 1 never executed 1139 #####: 681: fprintf(stderr, _("%s: No alias imported\n"), PROGRAM_NAME); 1140 %%%%%: 681-block 0 1141call 0 never executed 1142call 1 never executed 1143 #####: 682: return EXIT_FAILURE; 1144unconditional 0 never executed 1145 -: 683: } 1146 -: 684: 1147 -: 685: /* If some alias was found and imported, print the corresponding 1148 -: 686: * message and update the aliases array */ 1149 #####: 687: if (alias_imported > 1) { 1150 %%%%%: 687-block 0 1151branch 0 never executed 1152branch 1 never executed 1153 #####: 688: printf(_("%s: %zu aliases were successfully imported\n"), 1154 %%%%%: 688-block 0 1155call 0 never executed 1156call 1 never executed 1157unconditional 2 never executed 1158 -: 689: PROGRAM_NAME, alias_imported); 1159 -: 690: } else { 1160 #####: 691: printf(_("%s: 1 alias was successfully imported\n"), PROGRAM_NAME); 1161 %%%%%: 691-block 0 1162call 0 never executed 1163call 1 never executed 1164unconditional 2 never executed 1165 -: 692: } 1166 -: 693: 1167 -: 694: /* Add new aliases to the internal list of aliases */ 1168 #####: 695: get_aliases(); 1169 %%%%%: 695-block 0 1170call 0 never executed 1171 -: 696: 1172 -: 697: /* Add new aliases to the commands list for TAB completion */ 1173 #####: 698: if (bin_commands) { 1174branch 0 never executed 1175branch 1 never executed 1176 #####: 699: for (i = 0; bin_commands[i]; i++) 1177 %%%%%: 699-block 0 1178unconditional 0 never executed 1179 %%%%%: 699-block 1 1180branch 1 never executed 1181branch 2 never executed 1182 #####: 700: free(bin_commands[i]); 1183 %%%%%: 700-block 0 1184unconditional 0 never executed 1185 #####: 701: free(bin_commands); 1186 #####: 702: bin_commands = (char **)NULL; 1187 %%%%%: 702-block 0 1188unconditional 0 never executed 1189 -: 703: } 1190 -: 704: 1191 #####: 705: get_path_programs(); 1192 %%%%%: 705-block 0 1193call 0 never executed 1194 #####: 706: return EXIT_SUCCESS; 1195unconditional 0 never executed 1196 -: 707:} 1197 -: 708: 1198 -: 709:/* Store last visited directory for the restore last path and the 1199 -: 710: * cd on quit functions */ 1200 -: 711:void 1201function save_last_path called 8 returned 100% blocks executed 76% 1202 8: 712:save_last_path(void) 1203 -: 713:{ 1204 8: 714: if (!config_ok || !config_dir) 1205 8: 714-block 0 1206branch 0 taken 8 (fallthrough) 1207branch 1 taken 0 1208 8: 714-block 1 1209branch 2 taken 0 (fallthrough) 1210branch 3 taken 8 1211 #####: 715: return; 1212 %%%%%: 715-block 0 1213unconditional 0 never executed 1214 -: 716: 1215 8: 717: char *last_dir = (char *)xnmalloc(strlen(config_dir) + 7, sizeof(char)); 1216 8: 717-block 0 1217call 0 returned 8 1218 8: 718: sprintf(last_dir, "%s/.last", config_dir); 1219 -: 719: 1220 -: 720: FILE *last_fp; 1221 8: 721: last_fp = fopen(last_dir, "w"); 1222call 0 returned 8 1223 8: 722: if (!last_fp) { 1224branch 0 taken 0 (fallthrough) 1225branch 1 taken 8 1226 #####: 723: fprintf(stderr, _("%s: Error saving last visited " 1227 %%%%%: 723-block 0 1228call 0 never executed 1229call 1 never executed 1230 -: 724: "directory\n"), 1231 -: 725: PROGRAM_NAME); 1232 #####: 726: free(last_dir); 1233 #####: 727: return; 1234unconditional 0 never executed 1235 -: 728: } 1236 -: 729: 1237 -: 730: size_t i; 1238 72: 731: for (i = 0; i < MAX_WS; i++) { 1239 8: 731-block 0 1240unconditional 0 taken 8 1241 64: 731-block 1 1242unconditional 1 taken 64 1243 72: 731-block 2 1244branch 2 taken 64 1245branch 3 taken 8 (fallthrough) 1246 64: 732: if (ws[i].path) { 1247 64: 732-block 0 1248branch 0 taken 29 (fallthrough) 1249branch 1 taken 35 1250 -: 733: /* Mark current workspace with an asterisk. It will 1251 -: 734: * be read at startup by get_last_path */ 1252 29: 735: if ((size_t)cur_ws == i) 1253 29: 735-block 0 1254branch 0 taken 8 (fallthrough) 1255branch 1 taken 21 1256 8: 736: fprintf(last_fp, "*%zu:%s\n", i, ws[i].path); 1257 8: 736-block 0 1258call 0 returned 8 1259unconditional 1 taken 8 1260 -: 737: else 1261 21: 738: fprintf(last_fp, "%zu:%s\n", i, ws[i].path); 1262 21: 738-block 0 1263call 0 returned 21 1264unconditional 1 taken 21 1265 -: 739: } 1266 -: 740: } 1267 -: 741: 1268 8: 742: fclose(last_fp); 1269 8: 742-block 0 1270call 0 returned 8 1271 -: 743: 1272 8: 744: char *last_dir_tmp = xnmalloc(strlen(config_dir_gral) + 7, sizeof(char *)); 1273call 0 returned 8 1274 8: 745: sprintf(last_dir_tmp, "%s/.last", config_dir_gral); 1275 -: 746: 1276 8: 747: if (cd_on_quit) { 1277branch 0 taken 0 (fallthrough) 1278branch 1 taken 8 1279 #####: 748: char *cmd[] = {"cp", "-p", last_dir, last_dir_tmp, 1280 -: 749: NULL}; 1281 -: 750: 1282 #####: 751: launch_execve(cmd, FOREGROUND, E_NOFLAG); 1283 %%%%%: 751-block 0 1284call 0 never executed 1285 -: 752: } else { 1286 -: 753: /* If not cd on quit, remove the file */ 1287 8: 754: char *cmd[] = {"rm", "-f", last_dir_tmp, NULL}; 1288 8: 755: launch_execve(cmd, FOREGROUND, E_NOFLAG); 1289 8: 755-block 0 1290call 0 returned 8 1291 -: 756: } 1292 -: 757: 1293 8: 758: free(last_dir_tmp); 1294 8: 759: free(last_dir); 1295 8: 760: return; 1296 8: 760-block 0 1297unconditional 0 taken 8 1298 -: 761:} 1299 -: 762: 1300 -: 763:char * 1301function parse_usrvar_value called 0 returned 0% blocks executed 0% 1302 #####: 764:parse_usrvar_value(const char *str, const char c) 1303 -: 765:{ 1304 #####: 766: if (c == '\0' || !str) 1305 %%%%%: 766-block 0 1306branch 0 never executed 1307branch 1 never executed 1308 %%%%%: 766-block 1 1309branch 2 never executed 1310branch 3 never executed 1311 #####: 767: return (char *)NULL; 1312 %%%%%: 767-block 0 1313unconditional 0 never executed 1314 -: 768: 1315 -: 769: /* Get whatever comes after c */ 1316 #####: 770: char *tmp = (char *)NULL; 1317 #####: 771: tmp = strchr(str, c); 1318 -: 772: 1319 -: 773: /* If no C or there's nothing after C */ 1320 #####: 774: if (!tmp || !*(++tmp)) 1321 %%%%%: 774-block 0 1322branch 0 never executed 1323branch 1 never executed 1324 %%%%%: 774-block 1 1325branch 2 never executed 1326branch 3 never executed 1327 #####: 775: return (char *)NULL; 1328 %%%%%: 775-block 0 1329unconditional 0 never executed 1330 -: 776: 1331 -: 777: /* Remove leading quotes */ 1332 #####: 778: if (*tmp == '"' || *tmp == '\'') 1333 %%%%%: 778-block 0 1334branch 0 never executed 1335branch 1 never executed 1336 %%%%%: 778-block 1 1337branch 2 never executed 1338branch 3 never executed 1339 #####: 779: tmp++; 1340 %%%%%: 779-block 0 1341unconditional 0 never executed 1342 -: 780: 1343 -: 781: /* Remove trailing spaces, tabs, new line chars, and quotes */ 1344 #####: 782: size_t tmp_len = strlen(tmp), 1345 -: 783: i; 1346 -: 784: 1347 #####: 785: for (i = tmp_len - 1; tmp[i] && i > 0; i--) { 1348 %%%%%: 785-block 0 1349unconditional 0 never executed 1350 %%%%%: 785-block 1 1351branch 1 never executed 1352branch 2 never executed 1353 %%%%%: 785-block 2 1354branch 3 never executed 1355branch 4 never executed 1356 #####: 786: if (tmp[i] != ' ' && tmp[i] != '\t' && tmp[i] != '"' && tmp[i] != '\'' 1357 %%%%%: 786-block 0 1358branch 0 never executed 1359branch 1 never executed 1360 %%%%%: 786-block 1 1361branch 2 never executed 1362branch 3 never executed 1363 %%%%%: 786-block 2 1364branch 4 never executed 1365branch 5 never executed 1366 %%%%%: 786-block 3 1367branch 6 never executed 1368branch 7 never executed 1369 #####: 787: && tmp[i] != '\n') 1370 %%%%%: 787-block 0 1371branch 0 never executed 1372branch 1 never executed 1373 -: 788: break; 1374 -: 789: else 1375 #####: 790: tmp[i] = '\0'; 1376 %%%%%: 790-block 0 1377unconditional 0 never executed 1378 -: 791: } 1379 -: 792: 1380 #####: 793: if (!*tmp) 1381 %%%%%: 793-block 0 1382branch 0 never executed 1383branch 1 never executed 1384 #####: 794: return (char *)NULL; 1385 %%%%%: 794-block 0 1386unconditional 0 never executed 1387 -: 795: 1388 -: 796: /* Copy the result string into a buffer and return it */ 1389 #####: 797: char *buf = (char *)NULL; 1390 #####: 798: buf = savestring(tmp, strlen(tmp)); 1391 %%%%%: 798-block 0 1392call 0 never executed 1393 #####: 799: tmp = (char *)NULL; 1394 -: 800: 1395 #####: 801: if (buf) 1396branch 0 never executed 1397branch 1 never executed 1398 #####: 802: return buf; 1399 %%%%%: 802-block 0 1400unconditional 0 never executed 1401 #####: 803: return (char *)NULL; 1402 %%%%%: 803-block 0 1403unconditional 0 never executed 1404 -: 804:} 1405 -: 805: 1406 -: 806:int 1407function create_usr_var called 0 returned 0% blocks executed 0% 1408 #####: 807:create_usr_var(char *str) 1409 -: 808:{ 1410 #####: 809: char *name = strbfr(str, '='); 1411 %%%%%: 809-block 0 1412call 0 never executed 1413 #####: 810: char *value = parse_usrvar_value(str, '='); 1414call 0 never executed 1415 -: 811: 1416 #####: 812: if (!name) { 1417branch 0 never executed 1418branch 1 never executed 1419 #####: 813: if (value) 1420 %%%%%: 813-block 0 1421branch 0 never executed 1422branch 1 never executed 1423 #####: 814: free(value); 1424 %%%%%: 814-block 0 1425unconditional 0 never executed 1426 #####: 815: fprintf(stderr, _("%s: Error getting variable name\n"), 1427 %%%%%: 815-block 0 1428call 0 never executed 1429call 1 never executed 1430 -: 816: PROGRAM_NAME); 1431 #####: 817: return EXIT_FAILURE; 1432unconditional 0 never executed 1433 -: 818: } 1434 -: 819: 1435 #####: 820: if (!value) { 1436 %%%%%: 820-block 0 1437branch 0 never executed 1438branch 1 never executed 1439 #####: 821: free(name); 1440 #####: 822: fprintf(stderr, _("%s: Error getting variable value\n"), 1441 %%%%%: 822-block 0 1442call 0 never executed 1443call 1 never executed 1444 -: 823: PROGRAM_NAME); 1445 #####: 824: return EXIT_FAILURE; 1446unconditional 0 never executed 1447 -: 825: } 1448 -: 826: 1449 #####: 827: usr_var = xrealloc(usr_var, (size_t)(usrvar_n + 1) * sizeof(struct usrvar_t)); 1450 %%%%%: 827-block 0 1451call 0 never executed 1452 #####: 828: usr_var[usrvar_n].name = savestring(name, strlen(name)); 1453call 0 never executed 1454 #####: 829: usr_var[usrvar_n++].value = savestring(value, strlen(value)); 1455call 0 never executed 1456 -: 830: 1457 #####: 831: free(name); 1458 #####: 832: free(value); 1459 #####: 833: return EXIT_SUCCESS; 1460unconditional 0 never executed 1461 -: 834:} 1462 -: 835: 1463 -: 836:/* Custom POSIX implementation of GNU asprintf() modified to log program 1464 -: 837: * messages. MSG_TYPE is one of: 'e', 'w', 'n', or zero (meaning this 1465 -: 838: * latter that no message mark (E, W, or N) will be added to the prompt). 1466 -: 839: * PROMPT tells whether to print the message immediately before the 1467 -: 840: * prompt or rather in place. Based on littlstar's xasprintf 1468 -: 841: * implementation: 1469 -: 842: * https://github.com/littlstar/asprintf.c/blob/master/asprintf.c*/ 1470 -: 843:__attribute__((__format__(__printf__, 3, 0))) 1471 -: 844:/* We use __attribute__ here to silence clang warning: "format string is 1472 -: 845: * not a string literal" */ 1473 -: 846:int 1474function _err called 3 returned 100% blocks executed 72% 1475 3: 847:_err(int msg_type, int prompt, const char *format, ...) 1476 -: 848:{ 1477 -: 849: va_list arglist, tmp_list; 1478 3: 850: int size = 0; 1479 -: 851: 1480 3: 852: va_start(arglist, format); 1481 3: 853: va_copy(tmp_list, arglist); 1482 3: 854: size = vsnprintf((char *)NULL, 0, format, tmp_list); 1483 3: 855: va_end(tmp_list); 1484 -: 856: 1485 3: 857: if (size < 0) { 1486 3: 857-block 0 1487branch 0 taken 0 (fallthrough) 1488branch 1 taken 3 1489 #####: 858: va_end(arglist); 1490 #####: 859: return EXIT_FAILURE; 1491 %%%%%: 859-block 0 1492unconditional 0 never executed 1493 -: 860: } 1494 -: 861: 1495 3: 862: char *buf = (char *)xcalloc((size_t)size + 1, sizeof(char)); 1496 3: 862-block 0 1497call 0 returned 3 1498 -: 863: 1499 3: 864: vsprintf(buf, format, arglist); 1500 3: 865: va_end(arglist); 1501 -: 866: 1502 -: 867: /* If the new message is the same as the last message, skip it */ 1503 3: 868: if (msgs_n && strcmp(messages[msgs_n - 1], buf) == 0) { 1504branch 0 taken 1 (fallthrough) 1505branch 1 taken 2 1506 1: 868-block 0 1507branch 2 taken 0 (fallthrough) 1508branch 3 taken 1 1509 #####: 869: free(buf); 1510 #####: 870: return EXIT_SUCCESS; 1511 %%%%%: 870-block 0 1512unconditional 0 never executed 1513 -: 871: } 1514 -: 872: 1515 3: 873: if (buf) { 1516 3: 873-block 0 1517branch 0 taken 3 (fallthrough) 1518branch 1 taken 0 1519 3: 874: if (msg_type) { 1520 3: 874-block 0 1521branch 0 taken 2 (fallthrough) 1522branch 1 taken 1 1523 2: 875: switch (msg_type) { 1524 2: 875-block 0 1525branch 0 taken 0 1526branch 1 taken 1 1527branch 2 taken 1 1528branch 3 taken 0 1529 #####: 876: case 'e': pmsg = ERROR; break; 1530 %%%%%: 876-block 0 1531unconditional 0 never executed 1532 1: 877: case 'w': pmsg = WARNING; break; 1533 1: 877-block 0 1534unconditional 0 taken 1 1535 1: 878: case 'n': pmsg = NOTICE; break; 1536 1: 878-block 0 1537unconditional 0 taken 1 1538 #####: 879: default: pmsg = NOMSG; 1539 %%%%%: 879-block 0 1540unconditional 0 never executed 1541 -: 880: } 1542 -: 881: } 1543 -: 882: 1544 3: 883: log_msg(buf, (prompt) ? PRINT_PROMPT : NOPRINT_PROMPT); 1545 3: 883-block 0 1546call 0 returned 3 1547 3: 884: free(buf); 1548 3: 885: return EXIT_SUCCESS; 1549unconditional 0 taken 3 1550 -: 886: } 1551 -: 887: 1552 #####: 888: return EXIT_FAILURE; 1553 %%%%%: 888-block 0 1554unconditional 0 never executed 1555 -: 889:} 1556 -: 890: 1557 -: 891:/* Set STR as the program current shell */ 1558 -: 892:int 1559function set_shell called 2 returned 100% blocks executed 70% 1560 2: 893:set_shell(char *str) 1561 -: 894:{ 1562 2: 895: if (!str || !*str) 1563 2: 895-block 0 1564branch 0 taken 2 (fallthrough) 1565branch 1 taken 0 1566 2: 895-block 1 1567branch 2 taken 0 (fallthrough) 1568branch 3 taken 2 1569 #####: 896: return EXIT_FAILURE; 1570 %%%%%: 896-block 0 1571unconditional 0 never executed 1572 -: 897: 1573 -: 898: /* IF no slash in STR, check PATH env variable for a file named STR 1574 -: 899: * and get its full path*/ 1575 2: 900: char *full_path = (char *)NULL; 1576 -: 901: 1577 2: 902: if (strcntchr(str, '/') == -1) 1578 2: 902-block 0 1579call 0 returned 2 1580branch 1 taken 0 (fallthrough) 1581branch 2 taken 2 1582 #####: 903: full_path = get_cmd_path(str); 1583 %%%%%: 903-block 0 1584call 0 never executed 1585unconditional 1 never executed 1586 -: 904: 1587 2: 905: char *tmp = (char *)NULL; 1588 -: 906: 1589 2: 907: if (full_path) 1590 2: 907-block 0 1591branch 0 taken 0 (fallthrough) 1592branch 1 taken 2 1593 #####: 908: tmp = full_path; 1594 %%%%%: 908-block 0 1595unconditional 0 never executed 1596 -: 909: else 1597 2: 910: tmp = str; 1598 2: 910-block 0 1599unconditional 0 taken 2 1600 -: 911: 1601 2: 912: if (access(tmp, X_OK) == -1) { 1602 2: 912-block 0 1603call 0 returned 2 1604branch 1 taken 0 (fallthrough) 1605branch 2 taken 2 1606 #####: 913: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, tmp, strerror(errno)); 1607 %%%%%: 913-block 0 1608call 0 never executed 1609call 1 never executed 1610 #####: 914: return EXIT_FAILURE; 1611unconditional 0 never executed 1612 -: 915: } 1613 -: 916: 1614 2: 917: if (user.shell) 1615 2: 917-block 0 1616branch 0 taken 2 (fallthrough) 1617branch 1 taken 0 1618 2: 918: free(user.shell); 1619 2: 918-block 0 1620unconditional 0 taken 2 1621 -: 919: 1622 2: 920: user.shell = savestring(tmp, strlen(tmp)); 1623 2: 920-block 0 1624call 0 returned 2 1625 2: 921: printf(_("Successfully set '%s' as %s default shell\n"), user.shell, 1626call 0 returned 2 1627call 1 returned 2 1628 -: 922: PROGRAM_NAME); 1629 -: 923: 1630 2: 924: if (full_path) 1631branch 0 taken 0 (fallthrough) 1632branch 1 taken 2 1633 #####: 925: free(full_path); 1634 %%%%%: 925-block 0 1635unconditional 0 never executed 1636 2: 926: return EXIT_SUCCESS; 1637 2: 926-block 0 1638unconditional 0 taken 2 1639 -: 927:} 1640 -: 928: 1641 -: 929:/* List available mountpoints and chdir into one of them */ 1642 -: 930:int 1643function list_mountpoints called 1 returned 100% blocks executed 77% 1644 1: 931:list_mountpoints(void) 1645 -: 932:{ 1646 -: 933:#if defined(__HAIKU__) 1647 -: 934: fprintf(stderr, "%s: Mountpoints: This feature is not available on Haiku\n", 1648 -: 935: PROGRAM_NAME); 1649 -: 936: return EXIT_FAILURE; 1650 -: 937:#endif 1651 -: 938: 1652 -: 939:#if defined(__linux__) 1653 1: 940: FILE *mp_fp = fopen("/proc/mounts", "r"); 1654 1: 940-block 0 1655call 0 returned 1 1656 1: 941: if (!mp_fp) { 1657branch 0 taken 0 (fallthrough) 1658branch 1 taken 1 1659 #####: 942: fprintf(stderr, "%s: mp: fopen: /proc/mounts: %s\n", 1660call 0 never executed 1661 #####: 943: PROGRAM_NAME, strerror(errno)); 1662 %%%%%: 943-block 0 1663call 0 never executed 1664 #####: 944: return EXIT_FAILURE; 1665unconditional 0 never executed 1666 -: 945: } 1667 -: 946:#endif 1668 -: 947: 1669 1: 948: printf(_("%sMountpoints%s\n\n"), BOLD, df_c); 1670 1: 948-block 0 1671call 0 returned 1 1672call 1 returned 1 1673 -: 949: 1674 1: 950: char **mountpoints = (char **)NULL; 1675 1: 951: size_t mp_n = 0; 1676 1: 952: int i, exit_status = EXIT_SUCCESS; 1677 -: 953: 1678 -: 954:#if defined(__linux__) 1679 1: 955: size_t line_size = 0; 1680 1: 956: char *line = (char *)NULL; 1681 -: 957: 1682 37: 958: while (getline(&line, &line_size, mp_fp) > 0) { 1683unconditional 0 taken 1 1684 37: 958-block 0 1685call 1 returned 37 1686branch 2 taken 36 1687branch 3 taken 1 (fallthrough) 1688 -: 959: /* Do not list all mountpoints, but only those corresponding 1689 -: 960: * to a block device (/dev) */ 1690 36: 961: if (strncmp(line, "/dev/", 5) == 0) { 1691 36: 961-block 0 1692branch 0 taken 5 (fallthrough) 1693branch 1 taken 31 1694 5: 962: char *str = (char *)NULL; 1695 5: 963: size_t counter = 0; 1696 -: 964: 1697 -: 965: /* use strtok() to split LINE into tokens using space as 1698 -: 966: * IFS */ 1699 5: 967: str = strtok(line, " "); 1700 5: 967-block 0 1701call 0 returned 5 1702 5: 968: size_t dev_len = strlen(str); 1703 -: 969: 1704 5: 970: char *device = savestring(str, dev_len); 1705call 0 returned 5 1706 -: 971: /* Print only the first two fileds of each /proc/mounts 1707 -: 972: * line */ 1708 15: 973: while (str && counter < 2) { 1709unconditional 0 taken 5 1710 15: 973-block 0 1711branch 1 taken 15 (fallthrough) 1712branch 2 taken 0 1713 15: 973-block 1 1714branch 3 taken 10 1715branch 4 taken 5 (fallthrough) 1716 10: 974: if (counter == 1) { /* 1 == second field */ 1717 10: 974-block 0 1718branch 0 taken 5 (fallthrough) 1719branch 1 taken 5 1720 5*: 975: printf("%s%zu%s %s%s%s (%s)\n", el_c, mp_n + 1, 1721branch 0 taken 5 (fallthrough) 1722branch 1 taken 0 1723 5: 975-block 0 1724unconditional 2 taken 5 1725 %%%%%: 975-block 1 1726unconditional 3 never executed 1727 5: 975-block 2 1728call 4 returned 5 1729 5: 976: df_c, (access(str, R_OK | X_OK) == 0) ? di_c : nd_c, 1730 5: 976-block 0 1731call 0 returned 5 1732 -: 977: str, df_c, device); 1733 -: 978: /* Store the second field (mountpoint) into an 1734 -: 979: * array */ 1735 5: 980: mountpoints = (char **)xrealloc(mountpoints, 1736 5: 981: (mp_n + 1) * sizeof(char *)); 1737call 0 returned 5 1738 5: 982: mountpoints[mp_n++] = savestring(str, strlen(str)); 1739call 0 returned 5 1740unconditional 1 taken 5 1741 -: 983: } 1742 -: 984: 1743 10: 985: str = strtok(NULL, " ,"); 1744 10: 985-block 0 1745call 0 returned 10 1746 10: 986: counter++; 1747unconditional 0 taken 10 1748 -: 987: } 1749 -: 988: 1750 5: 989: free(device); 1751 5: 989-block 0 1752unconditional 0 taken 5 1753 -: 990: } 1754 -: 991: } 1755 -: 992: 1756 1: 993: free(line); 1757 1: 994: line = (char *)NULL; 1758 1: 995: fclose(mp_fp); 1759 1: 995-block 0 1760call 0 returned 1 1761 -: 996: 1762 -: 997:#elif defined(__FreeBSD__) || defined(__OpenBSD__) 1763 -: 998: struct statfs *fslist; 1764 -: 999: mp_n = (size_t)getmntinfo(&fslist, MNT_NOWAIT); 1765 -: 1000:#elif defined(__NetBSD__) 1766 -: 1001: struct statvfs *fslist; 1767 -: 1002: mp_n = (size_t)getmntinfo(&fslist, MNT_NOWAIT); 1768 -: 1003:#endif 1769 -: 1004: 1770 -: 1005: /* This should never happen: There should always be a mountpoint, 1771 -: 1006: * at least "/" */ 1772 -: 1007: // cppcheck-suppress knownConditionTrueFalse 1773 1: 1008: if (mp_n == 0) { 1774branch 0 taken 0 (fallthrough) 1775branch 1 taken 1 1776 #####: 1009: fputs(_("mp: There are no available mountpoints\n"), stdout); 1777 %%%%%: 1009-block 0 1778call 0 never executed 1779call 1 never executed 1780 #####: 1010: return EXIT_SUCCESS; 1781unconditional 0 never executed 1782 -: 1011: } 1783 -: 1012:#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 1784 -: 1013: int j; 1785 -: 1014: for (i = j = 0; i < (int)mp_n; i++) { 1786 -: 1015: /* Do not list all mountpoints, but only those corresponding 1787 -: 1016: * to a block device (/dev) */ 1788 -: 1017: if (strncmp(fslist[i].f_mntfromname, "/dev/", 5) == 0) { 1789 -: 1018: printf("%s%d%s %s%s%s (%s)\n", el_c, j + 1, df_c, 1790 -: 1019: (access(fslist[i].f_mntonname, R_OK | X_OK) == 0) 1791 -: 1020: ? di_c : nd_c, fslist[i].f_mntonname, 1792 -: 1021: df_c, fslist[i].f_mntfromname); 1793 -: 1022: /* Store the mountpoint into an array */ 1794 -: 1023: mountpoints = (char **)xrealloc(mountpoints, 1795 -: 1024: (size_t)(j + 1) * sizeof(char *)); 1796 -: 1025: mountpoints[j++] = savestring(fslist[i].f_mntonname, 1797 -: 1026: strlen(fslist[i].f_mntonname)); 1798 -: 1027: } 1799 -: 1028: } 1800 -: 1029: /* Update filesystem counter as it would be used to free() the 1801 -: 1030: * mountpoints entries later (below) */ 1802 -: 1031: mp_n = (size_t)j; 1803 -: 1032:#endif 1804 -: 1033: 1805 1: 1034: putchar('\n'); 1806 1: 1034-block 0 1807call 0 returned 1 1808 -: 1035: /* Ask the user and chdir into the selected mountpoint */ 1809 1: 1036: char *input = (char *)NULL; 1810 2: 1037: while (!input) 1811unconditional 0 taken 1 1812 2: 1037-block 0 1813branch 1 taken 1 1814branch 2 taken 1 (fallthrough) 1815 1: 1038: input = rl_no_hist(_("Choose a mountpoint ('q' to quit): ")); 1816 1: 1038-block 0 1817call 0 returned 1 1818call 1 returned 1 1819unconditional 2 taken 1 1820 -: 1039: 1821 1*: 1040: if (!(*input == 'q' && *(input + 1) == '\0')) { 1822 1: 1040-block 0 1823branch 0 taken 0 (fallthrough) 1824branch 1 taken 1 1825 %%%%%: 1040-block 1 1826branch 2 never executed 1827branch 3 never executed 1828 1: 1041: int atoi_num = atoi(input); 1829 1: 1042: if (atoi_num > 0 && atoi_num <= (int)mp_n) { 1830 1: 1042-block 0 1831branch 0 taken 1 (fallthrough) 1832branch 1 taken 0 1833 1: 1042-block 1 1834branch 2 taken 1 (fallthrough) 1835branch 3 taken 0 1836 1: 1043: if (xchdir(mountpoints[atoi_num - 1], SET_TITLE) == EXIT_SUCCESS) { 1837 1: 1043-block 0 1838call 0 returned 1 1839branch 1 taken 1 (fallthrough) 1840branch 2 taken 0 1841 1: 1044: free(ws[cur_ws].path); 1842 2: 1045: ws[cur_ws].path = savestring(mountpoints[atoi_num - 1], 1843 1: 1046: strlen(mountpoints[atoi_num - 1])); 1844 1: 1046-block 0 1845call 0 returned 1 1846 -: 1047: 1847 1: 1048: if (cd_lists_on_the_fly) { 1848branch 0 taken 1 (fallthrough) 1849branch 1 taken 0 1850 1: 1049: free_dirlist(); 1851 1: 1049-block 0 1852call 0 returned 1 1853 1: 1050: if (list_dir() != EXIT_SUCCESS) 1854call 0 returned 1 1855branch 1 taken 0 (fallthrough) 1856branch 2 taken 1 1857 #####: 1051: exit_status = EXIT_FAILURE; 1858 %%%%%: 1051-block 0 1859unconditional 0 never executed 1860 -: 1052: } 1861 -: 1053: 1862 1: 1054: add_to_dirhist(ws[cur_ws].path); 1863 1: 1054-block 0 1864call 0 returned 1 1865 1: 1055: add_to_jumpdb(ws[cur_ws].path); 1866call 0 returned 1 1867unconditional 1 taken 1 1868 -: 1056: } else { 1869 #####: 1057: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, 1870 #####: 1058: mountpoints[atoi_num - 1], strerror(errno)); 1871 %%%%%: 1058-block 0 1872call 0 never executed 1873call 1 never executed 1874 #####: 1059: exit_status = EXIT_FAILURE; 1875unconditional 0 never executed 1876 -: 1060: } 1877 -: 1061: } else { 1878 #####: 1062: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, 1879 #####: 1063: mountpoints[atoi_num - 1], strerror(errno)); 1880 %%%%%: 1063-block 0 1881call 0 never executed 1882call 1 never executed 1883 #####: 1064: exit_status = EXIT_FAILURE; 1884unconditional 0 never executed 1885 -: 1065: } 1886 -: 1066: } 1887 -: 1067: 1888 -: 1068: /* Free stuff and exit */ 1889 1: 1069: free(input); 1890 -: 1070: 1891 1: 1071: i = (int)mp_n; 1892 6: 1072: while (--i >= 0) 1893 1: 1072-block 0 1894unconditional 0 taken 1 1895 6: 1072-block 1 1896branch 1 taken 5 1897branch 2 taken 1 (fallthrough) 1898 5: 1073: free(mountpoints[i]); 1899 5: 1073-block 0 1900unconditional 0 taken 5 1901 1: 1074: free(mountpoints); 1902 -: 1075: 1903 1: 1076: return exit_status; 1904 1: 1076-block 0 1905unconditional 0 taken 1 1906 -: 1077:} 1907 -: 1078: 1908 -: 1079:/* Store pinned directory for the next session */ 1909 -: 1080:void 1910function save_pinned_dir called 4 returned 100% blocks executed 83% 1911 4: 1081:save_pinned_dir(void) 1912 -: 1082:{ 1913 4: 1083: if (pinned_dir && config_ok) { 1914 4: 1083-block 0 1915branch 0 taken 1 (fallthrough) 1916branch 1 taken 3 1917 1: 1083-block 1 1918branch 2 taken 1 (fallthrough) 1919branch 3 taken 0 1920 -: 1084: 1921 1: 1085: char *pin_file = (char *)xnmalloc(strlen(config_dir) + 7, 1922 1: 1085-block 0 1923call 0 returned 1 1924 -: 1086: sizeof(char)); 1925 1: 1087: sprintf(pin_file, "%s/.pin", config_dir); 1926 -: 1088: 1927 1: 1089: FILE *fp = fopen(pin_file, "w"); 1928call 0 returned 1 1929 1: 1090: if (!fp) { 1930branch 0 taken 0 (fallthrough) 1931branch 1 taken 1 1932 #####: 1091: fprintf(stderr, _("%s: Error storing pinned " 1933 %%%%%: 1091-block 0 1934call 0 never executed 1935call 1 never executed 1936unconditional 2 never executed 1937 -: 1092: "directory\n"), PROGRAM_NAME); 1938 -: 1093: } else { 1939 1: 1094: fprintf(fp, "%s", pinned_dir); 1940 1: 1094-block 0 1941call 0 returned 1 1942 1: 1095: fclose(fp); 1943call 0 returned 1 1944unconditional 1 taken 1 1945 -: 1096: } 1946 -: 1097: 1947 1: 1098: free(pin_file); 1948 1: 1098-block 0 1949unconditional 0 taken 1 1950 -: 1099: } 1951 -: 1100: 1952 4: 1101: return; 1953 4: 1101-block 0 1954unconditional 0 taken 4 1955 -: 1102:} 1956 -: 1103: 1957 -: 1104:int 1958function free_remotes called 26 returned 100% blocks executed 100% 1959 26: 1105:free_remotes(int exit) 1960 -: 1106:{ 1961 26: 1107: if (exit) 1962 26: 1107-block 0 1963branch 0 taken 4 (fallthrough) 1964branch 1 taken 22 1965 4: 1108: autounmount_remotes(); 1966 4: 1108-block 0 1967call 0 returned 4 1968unconditional 1 taken 4 1969 -: 1109: 1970 -: 1110: size_t i; 1971 64: 1111: for (i = 0; i < remotes_n; i++) { 1972 26: 1111-block 0 1973unconditional 0 taken 26 1974 64: 1111-block 1 1975branch 1 taken 38 1976branch 2 taken 26 (fallthrough) 1977 38: 1112: free(remotes[i].name); 1978 38: 1113: free(remotes[i].desc); 1979 38: 1114: free(remotes[i].mountpoint); 1980 38: 1115: free(remotes[i].mount_cmd); 1981 38: 1116: free(remotes[i].unmount_cmd); 1982 38: 1116-block 0 1983unconditional 0 taken 38 1984 -: 1117: } 1985 26: 1118: free(remotes); 1986 26: 1119: remotes_n = 0; 1987 -: 1120: 1988 26: 1121: return EXIT_SUCCESS; 1989 26: 1121-block 0 1990unconditional 0 taken 26 1991 -: 1122:} 1992 -: 1123: 1993 -: 1124:/* This function is called by atexit() to clear whatever is there at exit 1994 -: 1125: * time and avoid thus memory leaks */ 1995 -: 1126:void 1996function free_stuff called 4 returned 100% blocks executed 91% 1997 4: 1127:free_stuff(void) 1998 -: 1128:{ 1999 4: 1129: int i = 0; 2000 -: 1130: 2001 -: 1131:#ifdef LINUX_INOTIFY 2002 -: 1132: /* Shutdown inotify */ 2003 4: 1133: if (inotify_wd >= 0) 2004 4: 1133-block 0 2005branch 0 taken 4 (fallthrough) 2006branch 1 taken 0 2007 4: 1134: inotify_rm_watch(inotify_fd, inotify_wd); 2008 4: 1134-block 0 2009call 0 returned 4 2010unconditional 1 taken 4 2011 4: 1135: close(inotify_fd); 2012 4: 1135-block 0 2013call 0 returned 4 2014 -: 1136:#elif defined(BSD_KQUEUE) 2015 -: 1137: if (event_fd >= 0) 2016 -: 1138: close(event_fd); 2017 -: 1139: close(kq); 2018 -: 1140:#endif 2019 -: 1141: 2020 4: 1142: if (xargs.stealth_mode != 1) { 2021branch 0 taken 4 (fallthrough) 2022branch 1 taken 0 2023 4: 1143: save_pinned_dir(); 2024 4: 1143-block 0 2025call 0 returned 4 2026 4: 1144: save_jumpdb(); 2027call 0 returned 4 2028unconditional 1 taken 4 2029 -: 1145: } 2030 -: 1146: 2031 4: 1147: save_dirhist(); 2032 4: 1147-block 0 2033call 0 returned 4 2034 -: 1148: 2035 4: 1149: if (restore_last_path || cd_on_quit) 2036branch 0 taken 1 (fallthrough) 2037branch 1 taken 3 2038 1: 1149-block 0 2039branch 2 taken 0 (fallthrough) 2040branch 3 taken 1 2041 3: 1150: save_last_path(); 2042 3: 1150-block 0 2043call 0 returned 3 2044unconditional 1 taken 3 2045 -: 1151: 2046 4: 1152: free(alt_profile); 2047 4: 1153: free_bookmarks(); 2048 4: 1153-block 0 2049call 0 returned 4 2050 4: 1154: free(encoded_prompt); 2051 4: 1155: free_dirlist(); 2052call 0 returned 4 2053 4: 1156: free(opener); 2054 -: 1157: 2055 4: 1158: if (stdin_tmp_dir) { 2056branch 0 taken 0 (fallthrough) 2057branch 1 taken 4 2058 #####: 1159: char *rm_cmd[] = {"rm", "-rd", "--", stdin_tmp_dir, NULL}; 2059 #####: 1160: launch_execve(rm_cmd, FOREGROUND, E_NOFLAG); 2060 %%%%%: 1160-block 0 2061call 0 never executed 2062 #####: 1161: free(stdin_tmp_dir); 2063unconditional 0 never executed 2064 -: 1162: } 2065 -: 1163: 2066 4: 1164: if (color_schemes) { 2067 4: 1164-block 0 2068branch 0 taken 4 (fallthrough) 2069branch 1 taken 0 2070 65: 1165: for (i = 0; color_schemes[i]; i++) 2071 4: 1165-block 0 2072unconditional 0 taken 4 2073 65: 1165-block 1 2074branch 1 taken 61 2075branch 2 taken 4 (fallthrough) 2076 61: 1166: free(color_schemes[i]); 2077 61: 1166-block 0 2078unconditional 0 taken 61 2079 4: 1167: free(color_schemes); 2080 4: 1167-block 0 2081unconditional 0 taken 4 2082 -: 1168: } 2083 -: 1169: 2084 4: 1170: if (jump_db) { 2085 4: 1170-block 0 2086branch 0 taken 4 (fallthrough) 2087branch 1 taken 0 2088 4: 1171: i = (int)jump_n; 2089 147: 1172: while (--i >= 0) 2090 4: 1172-block 0 2091unconditional 0 taken 4 2092 147: 1172-block 1 2093branch 1 taken 143 2094branch 2 taken 4 (fallthrough) 2095 143: 1173: free(jump_db[i].path); 2096 143: 1173-block 0 2097unconditional 0 taken 143 2098 4: 1174: free(jump_db); 2099 4: 1174-block 0 2100unconditional 0 taken 4 2101 -: 1175: } 2102 -: 1176: 2103 4: 1177: if (pinned_dir) 2104 4: 1177-block 0 2105branch 0 taken 1 (fallthrough) 2106branch 1 taken 3 2107 1: 1178: free(pinned_dir); 2108 1: 1178-block 0 2109unconditional 0 taken 1 2110 -: 1179: 2111 4: 1180: if (filter) { 2112 4: 1180-block 0 2113branch 0 taken 0 (fallthrough) 2114branch 1 taken 4 2115 #####: 1181: regfree(®ex_exp); 2116 %%%%%: 1181-block 0 2117call 0 never executed 2118 #####: 1182: free(filter); 2119unconditional 0 never executed 2120 -: 1183: } 2121 -: 1184: 2122 4: 1185: if (eln_as_file_n) 2123 4: 1185-block 0 2124branch 0 taken 0 (fallthrough) 2125branch 1 taken 4 2126 #####: 1186: free(eln_as_file); 2127 %%%%%: 1186-block 0 2128unconditional 0 never executed 2129 -: 1187: 2130 4: 1188: if (ext_colors_n) 2131 4: 1188-block 0 2132branch 0 taken 4 (fallthrough) 2133branch 1 taken 0 2134 4: 1189: free(ext_colors_len); 2135 4: 1189-block 0 2136unconditional 0 taken 4 2137 -: 1190: 2138 -: 1191: 2139 4: 1192: if (profile_names) { 2140 4: 1192-block 0 2141branch 0 taken 4 (fallthrough) 2142branch 1 taken 0 2143 20: 1193: for (i = 0; profile_names[i]; i++) 2144 4: 1193-block 0 2145unconditional 0 taken 4 2146 20: 1193-block 1 2147branch 1 taken 16 2148branch 2 taken 4 (fallthrough) 2149 16: 1194: free(profile_names[i]); 2150 16: 1194-block 0 2151unconditional 0 taken 16 2152 4: 1195: free(profile_names); 2153 4: 1195-block 0 2154unconditional 0 taken 4 2155 -: 1196: } 2156 -: 1197: 2157 4: 1198: if (sel_n > 0) { 2158 4: 1198-block 0 2159branch 0 taken 0 (fallthrough) 2160branch 1 taken 4 2161 #####: 1199: i = (int)sel_n; 2162 #####: 1200: while (--i >= 0) 2163 %%%%%: 1200-block 0 2164unconditional 0 never executed 2165 %%%%%: 1200-block 1 2166branch 1 never executed 2167branch 2 never executed 2168 #####: 1201: free(sel_elements[i]); 2169 %%%%%: 1201-block 0 2170unconditional 0 never executed 2171 #####: 1202: free(sel_elements); 2172 %%%%%: 1202-block 0 2173unconditional 0 never executed 2174 -: 1203: } 2175 -: 1204: 2176 4: 1205: if (bin_commands) { 2177 4: 1205-block 0 2178branch 0 taken 4 (fallthrough) 2179branch 1 taken 0 2180 4: 1206: i = (int)path_progsn; 2181 14975: 1207: while (--i >= 0) 2182 4: 1207-block 0 2183unconditional 0 taken 4 2184 14975: 1207-block 1 2185branch 1 taken 14971 2186branch 2 taken 4 (fallthrough) 2187 14971: 1208: free(bin_commands[i]); 2188 14971: 1208-block 0 2189unconditional 0 taken 14971 2190 4: 1209: free(bin_commands); 2191 4: 1209-block 0 2192unconditional 0 taken 4 2193 -: 1210: } 2194 -: 1211: 2195 4: 1212: if (paths) { 2196 4: 1212-block 0 2197branch 0 taken 4 (fallthrough) 2198branch 1 taken 0 2199 4: 1213: i = (int)path_n; 2200 28: 1214: while (--i >= 0) 2201 4: 1214-block 0 2202unconditional 0 taken 4 2203 28: 1214-block 1 2204branch 1 taken 24 2205branch 2 taken 4 (fallthrough) 2206 24: 1215: free(paths[i]); 2207 24: 1215-block 0 2208unconditional 0 taken 24 2209 4: 1216: free(paths); 2210 4: 1216-block 0 2211unconditional 0 taken 4 2212 -: 1217: } 2213 -: 1218: 2214 4: 1219: if (cdpaths) { 2215 4: 1219-block 0 2216branch 0 taken 3 (fallthrough) 2217branch 1 taken 1 2218 3: 1220: i = (int)cdpath_n; 2219 9: 1221: while (--i >= 0) 2220 3: 1221-block 0 2221unconditional 0 taken 3 2222 9: 1221-block 1 2223branch 1 taken 6 2224branch 2 taken 3 (fallthrough) 2225 6: 1222: free(cdpaths[i]); 2226 6: 1222-block 0 2227unconditional 0 taken 6 2228 3: 1223: free(cdpaths); 2229 3: 1223-block 0 2230unconditional 0 taken 3 2231 -: 1224: } 2232 -: 1225: 2233 4: 1226: if (history) { 2234 4: 1226-block 0 2235branch 0 taken 4 (fallthrough) 2236branch 1 taken 0 2237 4: 1227: i = (int)current_hist_n; 2238 3146: 1228: while (--i >= 0) 2239 4: 1228-block 0 2240unconditional 0 taken 4 2241 3146: 1228-block 1 2242branch 1 taken 3142 2243branch 2 taken 4 (fallthrough) 2244 3142: 1229: free(history[i]); 2245 3142: 1229-block 0 2246unconditional 0 taken 3142 2247 4: 1230: free(history); 2248 4: 1230-block 0 2249unconditional 0 taken 4 2250 -: 1231: } 2251 -: 1232: 2252 4: 1233: if (argv_bk) { 2253 4: 1233-block 0 2254branch 0 taken 4 (fallthrough) 2255branch 1 taken 0 2256 4: 1234: i = argc_bk; 2257 12: 1235: while (--i >= 0) 2258 4: 1235-block 0 2259unconditional 0 taken 4 2260 12: 1235-block 1 2261branch 1 taken 8 2262branch 2 taken 4 (fallthrough) 2263 8: 1236: free(argv_bk[i]); 2264 8: 1236-block 0 2265unconditional 0 taken 8 2266 4: 1237: free(argv_bk); 2267 4: 1237-block 0 2268unconditional 0 taken 4 2269 -: 1238: } 2270 -: 1239: 2271 4: 1240: if (dirhist_total_index) { 2272 4: 1240-block 0 2273branch 0 taken 4 (fallthrough) 2274branch 1 taken 0 2275 4: 1241: i = (int)dirhist_total_index; 2276 482: 1242: while (--i >= 0) 2277 4: 1242-block 0 2278unconditional 0 taken 4 2279 482: 1242-block 1 2280branch 1 taken 478 2281branch 2 taken 4 (fallthrough) 2282 478: 1243: free(old_pwd[i]); 2283 478: 1243-block 0 2284unconditional 0 taken 478 2285 4: 1244: free(old_pwd); 2286 4: 1244-block 0 2287unconditional 0 taken 4 2288 -: 1245: } 2289 -: 1246: 2290 4: 1247: i = (int)kbinds_n; 2291 211: 1248: while (--i >= 0) { 2292 4: 1248-block 0 2293unconditional 0 taken 4 2294 211: 1248-block 1 2295branch 1 taken 207 2296branch 2 taken 4 (fallthrough) 2297 207: 1249: free(kbinds[i].function); 2298 207: 1250: free(kbinds[i].key); 2299 207: 1250-block 0 2300unconditional 0 taken 207 2301 -: 1251: } 2302 4: 1252: free(kbinds); 2303 -: 1253: 2304 4: 1254: i = (int)usrvar_n; 2305 4: 1255: while (--i >= 0) { 2306 4: 1255-block 0 2307unconditional 0 taken 4 2308 4: 1255-block 1 2309branch 1 taken 0 2310branch 2 taken 4 (fallthrough) 2311 #####: 1256: free(usr_var[i].name); 2312 #####: 1257: free(usr_var[i].value); 2313 %%%%%: 1257-block 0 2314unconditional 0 never executed 2315 -: 1258: } 2316 4: 1259: free(usr_var); 2317 -: 1260: 2318 4: 1261: i = (int)actions_n; 2319 89: 1262: while (--i >= 0) { 2320 4: 1262-block 0 2321unconditional 0 taken 4 2322 89: 1262-block 1 2323branch 1 taken 85 2324branch 2 taken 4 (fallthrough) 2325 85: 1263: free(usr_actions[i].name); 2326 85: 1264: free(usr_actions[i].value); 2327 85: 1264-block 0 2328unconditional 0 taken 85 2329 -: 1265: } 2330 4: 1266: free(usr_actions); 2331 -: 1267: 2332 4: 1268: i = (int)aliases_n; 2333 19: 1269: while (--i >= 0) 2334 4: 1269-block 0 2335unconditional 0 taken 4 2336 19: 1269-block 1 2337branch 1 taken 15 2338branch 2 taken 4 (fallthrough) 2339 15: 1270: free(aliases[i]); 2340 15: 1270-block 0 2341unconditional 0 taken 15 2342 4: 1271: free(aliases); 2343 -: 1272: 2344 4: 1273: i = (int)prompt_cmds_n; 2345 15: 1274: while (--i >= 0) 2346 4: 1274-block 0 2347unconditional 0 taken 4 2348 15: 1274-block 1 2349branch 1 taken 11 2350branch 2 taken 4 (fallthrough) 2351 11: 1275: free(prompt_cmds[i]); 2352 11: 1275-block 0 2353unconditional 0 taken 11 2354 4: 1276: free(prompt_cmds); 2355 -: 1277: 2356 -: 1278:/* if (flags & FILE_CMD_OK) 2357 -: 1279: free(file_cmd_path); */ 2358 -: 1280: 2359 4: 1281: if (msgs_n) { 2360 4: 1281-block 0 2361branch 0 taken 1 (fallthrough) 2362branch 1 taken 3 2363 1: 1282: i = (int)msgs_n; 2364 2: 1283: while (--i >= 0) 2365 1: 1283-block 0 2366unconditional 0 taken 1 2367 2: 1283-block 1 2368branch 1 taken 1 2369branch 2 taken 1 (fallthrough) 2370 1: 1284: free(messages[i]); 2371 1: 1284-block 0 2372unconditional 0 taken 1 2373 1: 1285: free(messages); 2374 1: 1285-block 0 2375unconditional 0 taken 1 2376 -: 1286: } 2377 -: 1287: 2378 4: 1288: if (ext_colors_n) { 2379 4: 1288-block 0 2380branch 0 taken 4 (fallthrough) 2381branch 1 taken 0 2382 4: 1289: i = (int)ext_colors_n; 2383 318: 1290: while (--i >= 0) 2384 4: 1290-block 0 2385unconditional 0 taken 4 2386 318: 1290-block 1 2387branch 1 taken 314 2388branch 2 taken 4 (fallthrough) 2389 314: 1291: free(ext_colors[i]); 2390 314: 1291-block 0 2391unconditional 0 taken 314 2392 4: 1292: free(ext_colors); 2393 4: 1292-block 0 2394unconditional 0 taken 4 2395 -: 1293: } 2396 -: 1294: 2397 4: 1295: if (ws && ws[0].path) { 2398 4: 1295-block 0 2399branch 0 taken 4 (fallthrough) 2400branch 1 taken 0 2401 4: 1295-block 1 2402branch 2 taken 4 (fallthrough) 2403branch 3 taken 0 2404 4: 1296: i = MAX_WS; 2405 36: 1297: while (--i >= 0) 2406 4: 1297-block 0 2407unconditional 0 taken 4 2408 36: 1297-block 1 2409branch 1 taken 32 2410branch 2 taken 4 (fallthrough) 2411 32: 1298: if (ws[i].path) 2412 32: 1298-block 0 2413branch 0 taken 13 (fallthrough) 2414branch 1 taken 19 2415 13: 1299: free(ws[i].path); 2416 13: 1299-block 0 2417unconditional 0 taken 13 2418 4: 1300: free(ws); 2419 4: 1300-block 0 2420unconditional 0 taken 4 2421 -: 1301: } 2422 -: 1302: 2423 4: 1303: free(actions_file); 2424 4: 1304: free(bm_file); 2425 4: 1305: free(data_dir); 2426 4: 1306: free(colors_dir); 2427 4: 1307: free(config_dir_gral); 2428 4: 1308: free(config_dir); 2429 4: 1309: free(config_file); 2430 4: 1310: free(dirhist_file); 2431 4: 1311: free(hist_file); 2432 4: 1312: free(kbinds_file); 2433 4: 1313: free(log_file); 2434 4: 1314: free(mime_file); 2435 4: 1315: free(msg_log_file); 2436 4: 1316: free(plugins_dir); 2437 4: 1317: free(profile_file); 2438 4: 1318: free(remotes_file); 2439 -: 1319: 2440 4: 1320: free_remotes(1); 2441 4: 1320-block 0 2442call 0 returned 4 2443 -: 1321: 2444 -: 1322:#ifndef _NO_SUGGESTIONS 2445 4: 1323: free(suggestion_buf); 2446 4: 1324: free(suggestion_strategy); 2447 -: 1325:#endif 2448 -: 1326: 2449 4: 1327: free(sel_file); 2450 4: 1328: free(tmp_dir); 2451 4: 1329: free(user.name); 2452 4: 1330: free(user.home); 2453 4: 1331: free(user.shell); 2454 -: 1332:#ifndef _NO_TRASH 2455 4: 1333: free(trash_dir); 2456 4: 1334: free(trash_files_dir); 2457 4: 1335: free(trash_info_dir); 2458 -: 1336:#endif 2459 -: 1337: 2460 -: 1338: /* Restore the color of the running terminal */ 2461 4: 1339: fputs("\x1b[0;39;49m", stdout); 2462call 0 returned 4 2463 4: 1340:} 2464 -: 1341: 2465 -: 1342:void 2466function set_signals_to_ignore called 4 returned 100% blocks executed 100% 2467 4: 1343:set_signals_to_ignore(void) 2468 -: 1344:{ 2469 -: 1345: /* signal(SIGINT, signal_handler); C-c */ 2470 4: 1346: signal(SIGINT, SIG_IGN); /* C-c */ 2471 4: 1346-block 0 2472call 0 returned 4 2473 4: 1347: signal(SIGQUIT, SIG_IGN); /* C-\ */ 2474call 0 returned 4 2475 4: 1348: signal(SIGTSTP, SIG_IGN); /* C-z */ 2476call 0 returned 4 2477 -: 1349: /* signal(SIGTERM, SIG_IGN); 2478 -: 1350: signal(SIGTTIN, SIG_IGN); 2479 -: 1351: signal(SIGTTOU, SIG_IGN); */ 2480 4: 1352:} 2481 -: 1353: 2482 -: 1354:void 2483function handle_stdin called 0 returned 0% blocks executed 0% 2484 #####: 1355:handle_stdin() 2485 -: 1356:{ 2486 -: 1357: /* If files are passed via stdin, we need to disable restore 2487 -: 1358: * last path in order to correctly understand relative paths */ 2488 #####: 1359: restore_last_path = 0; 2489 -: 1360: 2490 -: 1361: /* Max input size: 512 * (512 * 1024) 2491 -: 1362: * 512 chunks of 524288 bytes (512KiB) each 2492 -: 1363: * == (65535 * PATH_MAX) 2493 -: 1364: * == 262MiB of data ((65535 * PATH_MAX) / 1024) */ 2494 -: 1365: 2495 #####: 1366: size_t chunk = 512 * 1024, 2496 #####: 1367: chunks_n = 1, 2497 #####: 1368: total_len = 0, 2498 #####: 1369: max_chunks = 512; 2499 -: 1370: 2500 #####: 1371: ssize_t input_len = 0; 2501 -: 1372: 2502 -: 1373: /* Initial buffer allocation == 1 chunk */ 2503 #####: 1374: char *buf = (char *)xnmalloc(chunk, sizeof(char)); 2504 %%%%%: 1374-block 0 2505call 0 never executed 2506 -: 1375: 2507 #####: 1376: while (chunks_n < max_chunks) { 2508unconditional 0 never executed 2509 %%%%%: 1376-block 0 2510branch 1 never executed 2511branch 2 never executed 2512 #####: 1377: input_len = read(STDIN_FILENO, buf + total_len, chunk); 2513 %%%%%: 1377-block 0 2514call 0 never executed 2515 -: 1378: 2516 -: 1379: /* Error */ 2517 #####: 1380: if (input_len < 0) { 2518branch 0 never executed 2519branch 1 never executed 2520 #####: 1381: free(buf); 2521 #####: 1382: return; 2522 %%%%%: 1382-block 0 2523unconditional 0 never executed 2524 -: 1383: } 2525 -: 1384: 2526 -: 1385: /* Nothing else to be read */ 2527 #####: 1386: if (input_len == 0) 2528 %%%%%: 1386-block 0 2529branch 0 never executed 2530branch 1 never executed 2531 #####: 1387: break; 2532 %%%%%: 1387-block 0 2533unconditional 0 never executed 2534 -: 1388: 2535 #####: 1389: total_len += (size_t)input_len; 2536 #####: 1390: chunks_n++; 2537 -: 1391: 2538 -: 1392: /* Append a new chunk of memory to the buffer */ 2539 #####: 1393: buf = (char *)xrealloc(buf, (chunks_n + 1) * chunk); 2540 %%%%%: 1393-block 0 2541call 0 never executed 2542unconditional 1 never executed 2543 -: 1394: } 2544 -: 1395: 2545 #####: 1396: if (total_len == 0) 2546 %%%%%: 1396-block 0 2547branch 0 never executed 2548branch 1 never executed 2549 #####: 1397: goto FREE_N_EXIT; 2550 %%%%%: 1397-block 0 2551unconditional 0 never executed 2552 -: 1398: 2553 -: 1399: /* Null terminate the input buffer */ 2554 #####: 1400: buf[total_len] = '\0'; 2555 -: 1401: 2556 -: 1402: /* Create tmp dir to store links to files */ 2557 #####: 1403: char *rand_ext = gen_rand_str(6); 2558 %%%%%: 1403-block 0 2559call 0 never executed 2560 #####: 1404: if (!rand_ext) 2561branch 0 never executed 2562branch 1 never executed 2563 #####: 1405: goto FREE_N_EXIT; 2564 %%%%%: 1405-block 0 2565unconditional 0 never executed 2566 -: 1406: 2567 #####: 1407: if (tmp_dir) { 2568 %%%%%: 1407-block 0 2569branch 0 never executed 2570branch 1 never executed 2571 #####: 1408: stdin_tmp_dir = (char *)xnmalloc(strlen(tmp_dir) + 14, sizeof(char)); 2572 %%%%%: 1408-block 0 2573call 0 never executed 2574 #####: 1409: sprintf(stdin_tmp_dir, "%s/clifm.%s", tmp_dir, rand_ext); 2575unconditional 0 never executed 2576 -: 1410: } else { 2577 #####: 1411: stdin_tmp_dir = (char *)xnmalloc(18, sizeof(char)); 2578 %%%%%: 1411-block 0 2579call 0 never executed 2580 #####: 1412: sprintf(stdin_tmp_dir, "/tmp/clifm.%s", rand_ext); 2581unconditional 0 never executed 2582 -: 1413: } 2583 -: 1414: 2584 #####: 1415: free(rand_ext); 2585 -: 1416: 2586 #####: 1417: char *cmd[] = {"mkdir", "-p", stdin_tmp_dir, NULL}; 2587 #####: 1418: if (launch_execve(cmd, FOREGROUND, E_NOFLAG) != EXIT_SUCCESS) 2588 %%%%%: 1418-block 0 2589call 0 never executed 2590branch 1 never executed 2591branch 2 never executed 2592 #####: 1419: goto FREE_N_EXIT; 2593 %%%%%: 1419-block 0 2594unconditional 0 never executed 2595 -: 1420: 2596 -: 1421: /* Get CWD: we need it to prepend it to relative paths */ 2597 #####: 1422: char *cwd = (char *)NULL; 2598 #####: 1423: cwd = getcwd(NULL, 0); 2599 %%%%%: 1423-block 0 2600call 0 never executed 2601 #####: 1424: if (!cwd) 2602branch 0 never executed 2603branch 1 never executed 2604 #####: 1425: goto FREE_N_EXIT; 2605 %%%%%: 1425-block 0 2606unconditional 0 never executed 2607 -: 1426: 2608 -: 1427: /* Get substrings from buf */ 2609 #####: 1428: char *p = buf, *q = buf; 2610 -: 1429: 2611 #####: 1430: while (*p) { 2612 %%%%%: 1430-block 0 2613unconditional 0 never executed 2614 %%%%%: 1430-block 1 2615branch 1 never executed 2616branch 2 never executed 2617 #####: 1431: if (!*p || *p == '\n') { 2618 %%%%%: 1431-block 0 2619branch 0 never executed 2620branch 1 never executed 2621 %%%%%: 1431-block 1 2622branch 2 never executed 2623branch 3 never executed 2624 #####: 1432: *p = '\0'; 2625 -: 1433: 2626 -: 1434: /* Create symlinks (in tmp dir) to each valid file in 2627 -: 1435: * the buffer */ 2628 -: 1436: 2629 -: 1437: /* If file does not exist */ 2630 -: 1438: struct stat attr; 2631 #####: 1439: if (lstat(q, &attr) == -1) 2632 %%%%%: 1439-block 0 2633call 0 never executed 2634branch 1 never executed 2635branch 2 never executed 2636 #####: 1440: continue; 2637 %%%%%: 1440-block 0 2638unconditional 0 never executed 2639 -: 1441: 2640 -: 1442: /* Construct source and destiny files */ 2641 #####: 1443: char *tmp_file = strrchr(q, '/'); 2642 #####: 1444: if (!tmp_file || !*(++tmp_file)) 2643 %%%%%: 1444-block 0 2644branch 0 never executed 2645branch 1 never executed 2646 %%%%%: 1444-block 1 2647branch 2 never executed 2648branch 3 never executed 2649 #####: 1445: tmp_file = q; 2650 %%%%%: 1445-block 0 2651unconditional 0 never executed 2652 -: 1446: 2653 -: 1447: char source[PATH_MAX]; 2654 #####: 1448: if (*q != '/' || !q[1]) 2655 %%%%%: 1448-block 0 2656branch 0 never executed 2657branch 1 never executed 2658 %%%%%: 1448-block 1 2659branch 2 never executed 2660branch 3 never executed 2661 #####: 1449: snprintf(source, PATH_MAX, "%s/%s", cwd, q); 2662 %%%%%: 1449-block 0 2663unconditional 0 never executed 2664 -: 1450: else 2665 #####: 1451: xstrsncpy(source, q, PATH_MAX); 2666 %%%%%: 1451-block 0 2667call 0 never executed 2668unconditional 1 never executed 2669 -: 1452: 2670 -: 1453: char dest[PATH_MAX + 1]; 2671 #####: 1454: snprintf(dest, PATH_MAX, "%s/%s", stdin_tmp_dir, tmp_file); 2672 -: 1455: 2673 #####: 1456: if (symlink(source, dest) == -1) 2674 %%%%%: 1456-block 0 2675call 0 never executed 2676branch 1 never executed 2677branch 2 never executed 2678 #####: 1457: _err('w', PRINT_PROMPT, "ln: '%s': %s\n", q, strerror(errno)); 2679 %%%%%: 1457-block 0 2680call 0 never executed 2681call 1 never executed 2682unconditional 2 never executed 2683 -: 1458: 2684 #####: 1459: q = p + 1; 2685 %%%%%: 1459-block 0 2686unconditional 0 never executed 2687 -: 1460: } 2688 -: 1461: 2689 #####: 1462: p++; 2690 %%%%%: 1462-block 0 2691unconditional 0 never executed 2692 -: 1463: } 2693 -: 1464: 2694 -: 1465: /* chdir to tmp dir and update path var */ 2695 #####: 1466: if (xchdir(stdin_tmp_dir, SET_TITLE) == -1) { 2696 %%%%%: 1466-block 0 2697call 0 never executed 2698branch 1 never executed 2699branch 2 never executed 2700 #####: 1467: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, stdin_tmp_dir, 2701call 0 never executed 2702 #####: 1468: strerror(errno)); 2703 %%%%%: 1468-block 0 2704call 0 never executed 2705 -: 1469: 2706 #####: 1470: char *rm_cmd[] = {"rm", "-drf", stdin_tmp_dir, NULL}; 2707 #####: 1471: launch_execve(rm_cmd, FOREGROUND, E_NOFLAG); 2708call 0 never executed 2709 -: 1472: 2710 #####: 1473: free(cwd); 2711 #####: 1474: goto FREE_N_EXIT; 2712unconditional 0 never executed 2713 -: 1475: } 2714 -: 1476: 2715 #####: 1477: free(cwd); 2716 -: 1478: 2717 #####: 1479: if (ws[cur_ws].path) 2718 %%%%%: 1479-block 0 2719branch 0 never executed 2720branch 1 never executed 2721 #####: 1480: free(ws[cur_ws].path); 2722 %%%%%: 1480-block 0 2723unconditional 0 never executed 2724 -: 1481: 2725 #####: 1482: ws[cur_ws].path = savestring(stdin_tmp_dir, strlen(stdin_tmp_dir)); 2726 %%%%%: 1482-block 0 2727call 0 never executed 2728 #####: 1483: goto FREE_N_EXIT; 2729unconditional 0 never executed 2730 -: 1484: 2731 #####: 1485:FREE_N_EXIT: 2732 #####: 1486: free(buf); 2733 -: 1487: 2734 -: 1488: /* Go back to tty */ 2735 #####: 1489: dup2(STDOUT_FILENO, STDIN_FILENO); 2736 %%%%%: 1489-block 0 2737call 0 never executed 2738 -: 1490: 2739 #####: 1491: if (cd_lists_on_the_fly) { 2740branch 0 never executed 2741branch 1 never executed 2742 #####: 1492: free_dirlist(); 2743 %%%%%: 1492-block 0 2744call 0 never executed 2745 #####: 1493: list_dir(); 2746call 0 never executed 2747 #####: 1494: add_to_dirhist(ws[cur_ws].path); 2748call 0 never executed 2749unconditional 1 never executed 2750 -: 1495: } 2751 -: 1496: 2752 #####: 1497: return; 2753 %%%%%: 1497-block 0 2754unconditional 0 never executed 2755 -: 1498:} 2756 -: 1499: 2757 -: 1500:int 2758function pin_directory called 1 returned 100% blocks executed 61% 2759 1: 1501:pin_directory(char *dir) 2760 -: 1502:{ 2761 1: 1503: if (!dir || !*dir) 2762 1: 1503-block 0 2763branch 0 taken 1 (fallthrough) 2764branch 1 taken 0 2765 1: 1503-block 1 2766branch 2 taken 0 (fallthrough) 2767branch 3 taken 1 2768 #####: 1504: return EXIT_FAILURE; 2769 %%%%%: 1504-block 0 2770unconditional 0 never executed 2771 -: 1505: 2772 -: 1506: struct stat attr; 2773 1: 1507: if (lstat(dir, &attr) == -1) { 2774 1: 1507-block 0 2775call 0 returned 1 2776branch 1 taken 0 (fallthrough) 2777branch 2 taken 1 2778 #####: 1508: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, dir, strerror(errno)); 2779 %%%%%: 1508-block 0 2780call 0 never executed 2781call 1 never executed 2782 #####: 1509: return EXIT_FAILURE; 2783unconditional 0 never executed 2784 -: 1510: } 2785 -: 1511: 2786 1: 1512: if (pinned_dir) { 2787 1: 1512-block 0 2788branch 0 taken 0 (fallthrough) 2789branch 1 taken 1 2790 #####: 1513: free(pinned_dir); 2791 #####: 1514: pinned_dir = (char *)NULL; 2792 %%%%%: 1514-block 0 2793unconditional 0 never executed 2794 -: 1515: } 2795 -: 1516: 2796 -: 1517: /* If absolute path */ 2797 1: 1518: if (*dir == '/') { 2798 1: 1518-block 0 2799branch 0 taken 0 (fallthrough) 2800branch 1 taken 1 2801 #####: 1519: pinned_dir = savestring(dir, strlen(dir)); 2802 %%%%%: 1519-block 0 2803call 0 never executed 2804unconditional 1 never executed 2805 -: 1520: } else { /* If relative path */ 2806 -: 1521: 2807 1: 1522: if (strcmp(ws[cur_ws].path, "/") == 0) { 2808 1: 1522-block 0 2809branch 0 taken 0 (fallthrough) 2810branch 1 taken 1 2811 #####: 1523: pinned_dir = (char *)xnmalloc(strlen(dir) + 2, sizeof(char)); 2812 %%%%%: 1523-block 0 2813call 0 never executed 2814 #####: 1524: sprintf(pinned_dir, "/%s", dir); 2815unconditional 0 never executed 2816 -: 1525: } else { 2817 2: 1526: pinned_dir = (char *)xnmalloc(strlen(dir) 2818 1: 1527: + strlen(ws[cur_ws].path) + 2, sizeof(char)); 2819 1: 1527-block 0 2820call 0 returned 1 2821 1: 1528: sprintf(pinned_dir, "%s/%s", ws[cur_ws].path, dir); 2822unconditional 0 taken 1 2823 -: 1529: } 2824 -: 1530: } 2825 -: 1531: 2826 1: 1532: printf(_("%s: Succesfully pinned '%s'\n"), PROGRAM_NAME, dir); 2827 1: 1532-block 0 2828call 0 returned 1 2829call 1 returned 1 2830 1: 1533: return EXIT_SUCCESS; 2831unconditional 0 taken 1 2832 -: 1534:} 2833 -: 1535: 2834 -: 1536:int 2835function unpin_dir called 2 returned 100% blocks executed 67% 2836 2: 1537:unpin_dir(void) 2837 -: 1538:{ 2838 2: 1539: if (!pinned_dir) { 2839 2: 1539-block 0 2840branch 0 taken 0 (fallthrough) 2841branch 1 taken 2 2842 #####: 1540: printf(_("%s: No pinned file\n"), PROGRAM_NAME); 2843 %%%%%: 1540-block 0 2844call 0 never executed 2845call 1 never executed 2846 #####: 1541: return EXIT_SUCCESS; 2847unconditional 0 never executed 2848 -: 1542: } 2849 -: 1543: 2850 2: 1544: if (config_dir && xargs.stealth_mode != 1) { 2851 2: 1544-block 0 2852branch 0 taken 2 (fallthrough) 2853branch 1 taken 0 2854 2: 1544-block 1 2855branch 2 taken 2 (fallthrough) 2856branch 3 taken 0 2857 2: 1545: int cmd_error = 0; 2858 2: 1546: char *pin_file = (char *)xnmalloc(strlen(config_dir) + 7, sizeof(char)); 2859 2: 1546-block 0 2860call 0 returned 2 2861 2: 1547: sprintf(pin_file, "%s/.pin", config_dir); 2862 -: 1548: 2863 2: 1549: if (unlink(pin_file) == -1) { 2864call 0 returned 2 2865branch 1 taken 2 (fallthrough) 2866branch 2 taken 0 2867 2: 1550: fprintf(stderr, "%s: %s: %s\n", PROGRAM_NAME, pin_file, 2868call 0 returned 2 2869 2: 1551: strerror(errno)); 2870 2: 1551-block 0 2871call 0 returned 2 2872 2: 1552: cmd_error = 1; 2873unconditional 0 taken 2 2874 -: 1553: } 2875 -: 1554: 2876 2: 1555: free(pin_file); 2877 2: 1556: if (cmd_error) 2878 2: 1556-block 0 2879branch 0 taken 2 (fallthrough) 2880branch 1 taken 0 2881 2: 1557: return EXIT_FAILURE; 2882 2: 1557-block 0 2883unconditional 0 taken 2 2884 -: 1558: } 2885 -: 1559: 2886 #####: 1560: printf(_("Succesfully unpinned %s\n"), pinned_dir); 2887 %%%%%: 1560-block 0 2888call 0 never executed 2889call 1 never executed 2890 -: 1561: 2891 #####: 1562: free(pinned_dir); 2892 #####: 1563: pinned_dir = (char *)NULL; 2893 #####: 1564: return EXIT_SUCCESS; 2894unconditional 0 never executed 2895 -: 1565:} 2896 -: 1566: 2897 -: 1567:int 2898function hidden_function called 3 returned 100% blocks executed 85% 2899 3: 1568:hidden_function(char **comm) 2900 -: 1569:{ 2901 3: 1570: int exit_status = EXIT_SUCCESS; 2902 -: 1571: 2903 3: 1572: if (strcmp(comm[1], "status") == 0) { 2904 3: 1572-block 0 2905branch 0 taken 1 (fallthrough) 2906branch 1 taken 2 2907 1: 1573: printf(_("%s: Hidden files %s\n"), PROGRAM_NAME, 2908 1: 1573-block 0 2909call 0 returned 1 2910call 1 returned 1 2911unconditional 2 taken 1 2912 1*: 1574: (show_hidden) ? _("enabled") : _("disabled")); 2913 1: 1574-block 0 2914branch 0 taken 1 (fallthrough) 2915branch 1 taken 0 2916 1: 1574-block 1 2917call 2 returned 1 2918unconditional 3 taken 1 2919 %%%%%: 1574-block 2 2920call 4 never executed 2921unconditional 5 never executed 2922 2: 1575: } else if (strcmp(comm[1], "off") == 0) { 2923 2: 1575-block 0 2924branch 0 taken 1 (fallthrough) 2925branch 1 taken 1 2926 1: 1576: if (show_hidden == 1) { 2927 1: 1576-block 0 2928branch 0 taken 1 (fallthrough) 2929branch 1 taken 0 2930 1: 1577: show_hidden = 0; 2931 -: 1578: 2932 1: 1579: if (cd_lists_on_the_fly) { 2933 1: 1579-block 0 2934branch 0 taken 1 (fallthrough) 2935branch 1 taken 0 2936 1: 1580: free_dirlist(); 2937 1: 1580-block 0 2938call 0 returned 1 2939 1: 1581: exit_status = list_dir(); 2940call 0 returned 1 2941unconditional 1 taken 1 2942 -: 1582: } 2943 -: 1583: } 2944 1: 1584: } else if (strcmp(comm[1], "on") == 0) { 2945 1: 1584-block 0 2946branch 0 taken 1 (fallthrough) 2947branch 1 taken 0 2948 1: 1585: if (show_hidden == 0) { 2949 1: 1585-block 0 2950branch 0 taken 1 (fallthrough) 2951branch 1 taken 0 2952 1: 1586: show_hidden = 1; 2953 -: 1587: 2954 1: 1588: if (cd_lists_on_the_fly) { 2955 1: 1588-block 0 2956branch 0 taken 1 (fallthrough) 2957branch 1 taken 0 2958 1: 1589: free_dirlist(); 2959 1: 1589-block 0 2960call 0 returned 1 2961 1: 1590: exit_status = list_dir(); 2962call 0 returned 1 2963unconditional 1 taken 1 2964 -: 1591: } 2965 -: 1592: } 2966 -: 1593: } else { 2967 #####: 1594: fprintf(stderr, "%s\n", _(HF_USAGE)); 2968 %%%%%: 1594-block 0 2969call 0 never executed 2970call 1 never executed 2971unconditional 2 never executed 2972 -: 1595: } 2973 -: 1596: 2974 3: 1597: return exit_status; 2975 3: 1597-block 0 2976unconditional 0 taken 3 2977 -: 1598:} 2978 -: 1599: 2979 -: 1600:/* Instead of recreating here the commands description, just jump to the 2980 -: 1601: * corresponding section in the manpage */ 2981 -: 1602:int 2982function list_commands called 1 returned 100% blocks executed 83% 2983 1: 1603:list_commands(void) 2984 -: 1604:{ 2985 -: 1605: char cmd[PATH_MAX]; 2986 1: 1606: snprintf(cmd, PATH_MAX - 1, "export PAGER=\"less -p '^[0-9]+\\.[[:space:]]COMMANDS'\"; man %s\n", 2987 -: 1607: PNL); 2988 1: 1608: if (launch_execle(cmd) != EXIT_SUCCESS) 2989 1: 1608-block 0 2990call 0 returned 1 2991branch 1 taken 0 (fallthrough) 2992branch 2 taken 1 2993 #####: 1609: return EXIT_FAILURE; 2994 %%%%%: 1609-block 0 2995unconditional 0 never executed 2996 -: 1610: 2997 1: 1611: return EXIT_SUCCESS; 2998 1: 1611-block 0 2999unconditional 0 taken 1 3000 -: 1612:} 3001 -: 1613: 3002 -: 1614:void 3003function help_function called 38 returned 100% blocks executed 95% 3004 38: 1615:help_function(void) 3005 -: 1616:{ 3006 38: 1617: fputs("\x1b[0m", stdout); 3007 38: 1617-block 0 3008call 0 returned 38 3009 38*: 1618: printf(_("%s%s %s (%s), by %s\n"), (flags & EXT_HELP) ? "" : df_c, 3010branch 0 taken 0 (fallthrough) 3011branch 1 taken 38 3012 %%%%%: 1618-block 0 3013unconditional 2 never executed 3014 38: 1618-block 1 3015unconditional 3 taken 38 3016 38: 1618-block 2 3017call 4 returned 38 3018call 5 returned 38 3019 -: 1619: PROGRAM_NAME, VERSION, DATE, AUTHOR); 3020 -: 1620: 3021 38: 1621: printf(_("\nUSAGE: %s %s\n\ 3022call 0 returned 38 3023call 1 returned 38 3024 -: 1622:\n -a, --no-hidden\t\t do not show hidden files (default)\ 3025 -: 1623:\n -A, --show-hidden\t\t show hidden files\ 3026 -: 1624:\n -b, --bookmarks-file=FILE\t specify an alternative bookmarks file\ 3027 -: 1625:\n -c, --config-file=FILE\t\t specify an alternative configuration file\ 3028 -: 1626:\n -D, --config-dir=DIR\t\t specify an alternative configuration directory\ 3029 -: 1627:\n -e, --no-eln\t\t\t do not print ELN (entry list number) at \ 3030 -: 1628:\n the left of each file name \ 3031 -: 1629:\n -f, --no-folders-first\t\t do not list folders first\ 3032 -: 1630:\n -F, --folders-first\t\t list folders first (default)\ 3033 -: 1631:\n -g, --pager\t\t\t enable the pager\ 3034 -: 1632:\n -G, --no-pager\t\t\t disable the pager (default)\ 3035 -: 1633:\n -h, --help\t\t\t show this help and exit\ 3036 -: 1634:\n -i, --no-case-sensitive\t no case-sensitive files listing (default)\ 3037 -: 1635:\n -I, --case-sensitive\t\t case-sensitive files listing\ 3038 -: 1636:\n -k, --keybindings-file=FILE\t specify an alternative keybindings file\ 3039 -: 1637:\n -l, --no-long-view\t\t disable long view mode (default)\ 3040 -: 1638:\n -L, --long-view\t\t enable long view mode\ 3041 -: 1639:\n -m, --dihist-map\t\t enable the directory history map\ 3042 -: 1640:\n -o, --no-list-on-the-fly\t 'cd' works as the shell 'cd' command\ 3043 -: 1641:\n -O, --list-on-the-fly\t\t 'cd' lists files on the fly (default)\ 3044 -: 1642:\n -p, --path=PATH\t\t (Deprecated: use positional parameters instead)\ 3045 -: 1643:\n use PATH as %s starting path\ 3046 -: 1644:\n -P, --profile=PROFILE\t\t use (or create) PROFILE as profile\ 3047 -: 1645:\n -s, --splash \t\t\t enable the splash screen\ 3048 -: 1646:\n -S, --stealth-mode \t\t leave no trace on the host system.\ 3049 -: 1647:\n Nothing is read from any file nor any file \ 3050 -: 1648:\n is created: all settings are set to the \ 3051 -: 1649:\n default value. However, most settings can \ 3052 -: 1650:\n be controlled via command line options\ 3053 -: 1651:\n -u, --no-unicode \t\t disable unicode\ 3054 -: 1652:\n -U, --unicode \t\t\t enable unicode to correctly list file names \ 3055 -: 1653:\n containing accents, tildes, umlauts, \ 3056 -: 1654:\n non-latin letters, etc. This option is \ 3057 -: 1655:\n enabled by default\ 3058 -: 1656:\n -v, --version\t\t\t show version details and exit\ 3059 -: 1657:\n -w, --workspace=NUM\t\t start in workspace NUM\ 3060 -: 1658:\n -x, --no-ext-cmds\t\t disallow the use of external commands\ 3061 -: 1659:\n -y, --light-mode\t\t enable the light mode\ 3062 -: 1660:\n -z, --sort=METHOD\t\t sort files by METHOD, where METHOD \ 3063 -: 1661:\n could be: 0 = none, 1 = name, 2 = size, \ 3064 -: 1662:\n 3 = atime, 4 = btime, 5 = ctime, \ 3065 -: 1663:\n 6 = mtime, 7 = version, 8 = extension, \ 3066 -: 1664:\n 9 = inode, 10 = owner, 11 = group"), 3067 -: 1665: PNL, GRAL_USAGE, PROGRAM_NAME); 3068 -: 1666: 3069 38: 1667: printf("\ 3070call 0 returned 38 3071 -: 1668:\n --autojump\t enable the autojump function (run the directory \ 3072 -: 1669:\n jumper omitting the j command: 'STR...' == 'j STR...')\ 3073 -: 1670:\n --case-sens-dirjump\t do not ignore case when consulting the \ 3074 -: 1671:\n jump database (via the 'j' command)\ 3075 -: 1672:\n --case-sens-path-comp\t enable case sensitive path completion\ 3076 -: 1673:\n --cd-on-quit\t\t write last visited path to \ 3077 -: 1674:\n $XDG_CONFIG_HOME/clifm/.last to be accessed\ 3078 -: 1675:\n later by a shell funtion. See the manpage\ 3079 -: 1676:\n --color-scheme=NAME\t use color scheme NAME\ 3080 -: 1677:\n --cwd-in-title\t\t print current directory in terminal \ 3081 -: 1678:\n window title\ 3082 -: 1679:\n --disk-usage\t\t show disk usage (free/total) for the\ 3083 -: 1680:\n filesystem to which the current directory \ 3084 -: 1681:\n belongs\ 3085 -: 1682:\n --enable-logs\t\t enable program logs\ 3086 -: 1683:\n --expand-bookmarks\t\t expand bookmark names into the \ 3087 -: 1684:\n corresponding bookmark paths. TAB \ 3088 -: 1685:\n completion for bookmark names is also \ 3089 -: 1686:\n available\ 3090 -: 1687:\n --icons\t\t\t enable icons\ 3091 -: 1688:\n --icons-use-file-color\t icons color follows file color\ 3092 -: 1689:\n --list-and-quit\t\t list files and quit. It may be used\ 3093 -: 1690:\n in conjunction with -p\ 3094 -: 1691:\n --max-dirhist\t\t maximum number of visited directories to \ 3095 -: 1692:\n remember\ 3096 -: 1693:\n --max-files=NUM\t\t list only up to NUM files\ 3097 -: 1694:\n --max-path=NUM\t\t set the maximun number of characters \ 3098 -: 1695:\n after which the current directory in the \ 3099 -: 1696:\n prompt line will be abreviated to the \ 3100 -: 1697:\n directory base name (if \\z is used in \ 3101 -: 1698:\n the prompt\ 3102 -: 1699:\n --no-dir-jumper\t\t disable the directory jumper function\ 3103 -: 1700:\n --no-cd-auto\t\t by default, %s changes to directories \ 3104 -: 1701:\n\t\t\t\tby just specifying the corresponding ELN \ 3105 -: 1702:\n (e.g. '12' instead of 'cd 12'). This \ 3106 -: 1703:\n option forces the use of 'cd'\ 3107 -: 1704:\n --no-classify\t\t do not append file type indicators\ 3108 -: 1705:\n --no-clear-screen\t\t do not clear the screen when listing \ 3109 -: 1706:\n directories\ 3110 -: 1707:\n --no-colors\t\t disable file type colors for files listing \ 3111 -: 1708:\n --no-columns\t\t disable columned files listing\ 3112 -: 1709:\n --no-file-cap\t\t do not check files capabilities when\ 3113 -: 1710:\n listing files\ 3114 -: 1711:\n --no-file-ext\t\t do not check files extension when\ 3115 -: 1712:\n listing files\ 3116 -: 1713:\n --no-files-counter\t\t disable the files counter for \ 3117 -: 1714:\n directories. This option is especially \ 3118 -: 1715:\n useful to speed up the listing process; \ 3119 -: 1716:\n counting files in directories is expensive\ 3120 -: 1717:\n --no-follow-symlink\t do not follow symbolic links when\ 3121 -: 1718:\n listing files\ 3122 -: 1719:\n --no-open-auto\t\t same as no-cd-auto, but for files\ 3123 -: 1720:\n --no-tips\t\t\t disable startup tips\ 3124 -: 1721:\n --no-restore-last-path\t save last visited directory to be \ 3125 -: 1722:\n restored in the next session\ 3126 -: 1723:\n --no-suggestions\t\t disable auto-suggestions\ 3127 -: 1724:\n --no-welcome-message\t disable the welcome message\ 3128 -: 1725:\n --only-dirs\t\t list only directories and symbolic links\ 3129 -: 1726:\n to directories\ 3130 -: 1727:\n --open=FILE\t run as a stand-alone resource opener: open\ 3131 -: 1728:\n FILE and exit\ 3132 -: 1729:\n --opener=APPLICATION\t resource opener to use instead of 'lira',\ 3133 -: 1730:\n %s built-in opener\ 3134 -: 1731:\n --print-sel\t\t keep the list of selected files in sight\ 3135 -: 1732:\n --rl-vi-mode\t\t set readline to vi editing mode (defaults \ 3136 -: 1733:\n to emacs editing mode)\ 3137 -: 1734:\n --share-selbox\t\t make the Selection Box common to \ 3138 -: 1735:\n different profiles\ 3139 -: 1736:\n --sort-reverse\t\t sort in reverse order, for example: z-a \ 3140 -: 1737:\n instead of a-z, which is the default order)\ 3141 -: 1738:\n --trash-as-rm\t\t the 'r' command executes 'trash' instead of \ 3142 -: 1739: 'rm' to prevent accidental deletions\n", 3143 -: 1740: PROGRAM_NAME, PROGRAM_NAME); 3144 -: 1741: 3145 38: 1742: printf(_("\nBUILT-IN COMMANDS:\n\nThe following is just a brief list of " 3146call 0 returned 38 3147call 1 returned 38 3148 -: 1743: "available commands and possible parameters.\n\nFor a complete " 3149 -: 1744: "description of each of these commands run 'cmd' (or press " 3150 -: 1745: "F2) or consult the manpage (F1).\n\nYou can also try " 3151 -: 1746: "the 'ih' action to run the interactive help plugin (it " 3152 -: 1747: "depends on FZF). Just enter 'ih', that's it.\n\nIt is also " 3153 -: 1748: "recommended to consult the project's wiki " 3154 -: 1749: "(https://github.com/leo-arch/clifm/wiki)\n\n")); 3155 -: 1750: 3156 38: 1751: puts(_("ELN/FILE/DIR (auto-open and autocd functions)\n\ 3157call 0 returned 38 3158call 1 returned 38 3159 -: 1752: /PATTERN [DIR] [-filetype] [-x] (quick search)\n\ 3160 -: 1753: ;[CMD], :[CMD] (run CMD via the system shell)\n\ 3161 -: 1754: ac, ad ELN/FILE ... (archiving functions)\n\ 3162 -: 1755: acd, autocd [on, off, status]\n\ 3163 -: 1756: actions [edit]\n\ 3164 -: 1757: alias [import FILE]\n\ 3165 -: 1758: ao, auto-open [on, off, status]\n\ 3166 -: 1759: b, back [h, hist] [clear] [!ELN]\n\ 3167 -: 1760: bl ELN/FILE ... (batch links)\n\ 3168 -: 1761: bm, bookmarks [a, add PATH] [d, del] [edit] [SHORTCUT or NAME]\n\ 3169 -: 1762: br, bulk ELN/FILE ...\n\ 3170 -: 1763: c, l [e, edit], m, md, r (copy, link, move, makedir, and remove)\n\ 3171 -: 1764: cc, colors\n\ 3172 -: 1765: cd [ELN/DIR]\n\ 3173 -: 1766: cl, columns [on, off]\n\ 3174 -: 1767: cmd, commands\n\ 3175 -: 1768: cs, colorscheme [edit] [COLORSCHEME]\n\ 3176 -: 1769: d, dup SOURCE [DEST]\n\ 3177 -: 1770: ds, desel [*, a, all]\n\ 3178 -: 1771: edit [APPLICATION] [reset]\n\ 3179 -: 1772: exp, export [ELN/FILE ...]\n\ 3180 -: 1773: ext [on, off, status]\n\ 3181 -: 1774: f, forth [h, hist] [clear] [!ELN]\n\ 3182 -: 1775: fc, filescounter [on, off, status]\n\ 3183 -: 1776: ff, folders-first [on, off, status]\n\ 3184 -: 1777: fs\n\ 3185 -: 1778: ft, filter [unset] [REGEX]\n\ 3186 -: 1779: hf, hidden [on, off, status]\n\ 3187 -: 1780: history [clear] [-n]\n\ 3188 -: 1781: icons [on, off]\n\ 3189 -: 1782: j, jc, jp, jl [STRING ...] jo [NUM], je (directory jumper function)\n\ 3190 -: 1783: kb, keybinds [edit] [reset] [readline]\n\ 3191 -: 1784: lm [on, off] (lightmode)\n\ 3192 -: 1785: log [clear]\n\ 3193 -: 1786: mf NUM (List up to NUM files)\n\ 3194 -: 1787: mm, mime [info ELN/FILE] [edit] [import] (resource opener)\n\ 3195 -: 1788: mp, mountpoints\n\ 3196 -: 1789: msg, messages [clear]\n\ 3197 -: 1790: n, new FILE DIR/ ...n\n\ 3198 -: 1791: net [NAME] [edit] [m, mount NAME] [u, unmount NAME]\n\ 3199 -: 1792: o, open [ELN/FILE] [APPLICATION]\n\ 3200 -: 1793: opener [default] [APPLICATION]\n\ 3201 -: 1794: p, pr, pp, prop [ELN/FILE ... n]\n\ 3202 -: 1795: path, cwd\n\ 3203 -: 1796: pf, prof, profile [ls, list] [set, add, del PROFILE]\n\ 3204 -: 1797: pg, pager [on, off, status]\n\ 3205 -: 1798: pin [FILE/DIR]\n\ 3206 -: 1799: q, quit, exit\n\ 3207 -: 1800: Q\n\ 3208 -: 1801: rf, refresh\n\ 3209 -: 1802: rl, reload\n\ 3210 -: 1803: s, sel ELN/FILE... [[!]PATTERN] [-FILETYPE] [:PATH]\n\ 3211 -: 1804: sb, selbox\n\ 3212 -: 1805: shell [SHELL]\n\ 3213 -: 1806: splash\n\ 3214 -: 1807: st, sort [METHOD] [rev]\n\ 3215 -: 1808: t, tr, trash [ELN/FILE ... n] [ls, list] [clear] [del, rm]\n\ 3216 -: 1809: te [FILE(s)]\n\ 3217 -: 1810: tips\n\ 3218 -: 1811: u, undel, untrash [*, a, all]\n\ 3219 -: 1812: uc, unicode [on, off, status]\n\ 3220 -: 1813: unpin\n\ 3221 -: 1814: v, vv, paste sel [DESTINY]\n\ 3222 -: 1815: ver, version\n\ 3223 -: 1816: ws [NUM, +, -] (workspaces)\n\ 3224 -: 1817: x, X [ELN/DIR] (new instance)\n")); 3225 -: 1818: 3226 38: 1819: printf(_("DEFAULT KEYBOARD SHORTCUTS:\n\n" 3227call 0 returned 38 3228call 1 returned 38 3229 -: 1820: " Right, C-f: Accept the entire suggestion\n\ 3230 -: 1821: M-Right, M-f: Accept the first suggested word\n\ 3231 -: 1822: M-c: Clear the current command line buffer\n\ 3232 -: 1823: M-g: Toggle list-folders-first on/off\n\ 3233 -: 1824: C-r: Refresh the screen\n\ 3234 -: 1825: M-l: Toggle long view mode on/off\n\ 3235 -: 1826: M-m: List mountpoints\n\ 3236 -: 1827: M-t: Clear messages\n\ 3237 -: 1828: M-h: Show directory history\n\ 3238 -: 1829: M-i, M-.: Toggle hidden files on/off\n\ 3239 -: 1830: M-s: Open the Selection Box\n\ 3240 -: 1831: M-a: Select all files in the current working directory\n\ 3241 -: 1832: M-d: Deselect all selected files\n\ 3242 -: 1833: M-r: Change to the root directory\n\ 3243 -: 1834: M-e, Home: Change to the home directory\n\ 3244 -: 1835: M-u, S-Up: Change to the parent directory\n\ 3245 -: 1836: M-j, S-Left: Change to previous visited directory\n\ 3246 -: 1837: M-k, S-Right: Change to next visited directory\n\ 3247 -: 1838: M-o: Lock terminal\n\ 3248 -: 1839: M-p: Change to pinned directory\n\ 3249 -: 1840: M-1: Switch to workspace 1\n\ 3250 -: 1841: M-2: Switch to workspace 2\n\ 3251 -: 1842: M-3: Switch to workspace 3\n\ 3252 -: 1843: M-4: Switch to workspace 4\n\ 3253 -: 1844: C-M-j: Change to first visited directory\n\ 3254 -: 1845: C-M-k: Change to last visited directory\n\ 3255 -: 1846: C-M-o: Switch to previous profile\n\ 3256 -: 1847: C-M-p: Switch to next profile\n\ 3257 -: 1848: C-M-a: Archive selected files\n\ 3258 -: 1849: C-M-e: Export selected files\n\ 3259 -: 1850: C-M-r: Rename selected files\n\ 3260 -: 1851: C-M-d: Remove selected files\n\ 3261 -: 1852: C-M-t: Trash selected files\n\ 3262 -: 1853: C-M-u: Restore trashed files\n\ 3263 -: 1854: C-M-b: Bookmark last selected file or directory\n\ 3264 -: 1855: C-M-g: Open/change-into last selected file/directory\n\ 3265 -: 1856: C-M-n: Move selected files into the current working directory\n\ 3266 -: 1857: C-M-v: Copy selected files into the current working directory\n\ 3267 -: 1858: M-y: Toggle light mode on/off\n\ 3268 -: 1859: M-z: Switch to previous sorting method\n\ 3269 -: 1860: M-x: Switch to next sorting method\n\ 3270 -: 1861: C-x: Launch a new instance\n\ 3271 -: 1862: F1: Manual page\n\ 3272 -: 1863: F2: Commands help\n\ 3273 -: 1864: F3: Keybindings help\n\ 3274 -: 1865: F6: Open the MIME list file\n\ 3275 -: 1866: F7: Open the jump database file\n\ 3276 -: 1867: F8: Open the current color scheme file\n\ 3277 -: 1868: F9: Open the keybindings file\n\ 3278 -: 1869: F10: Open the configuration file\n\ 3279 -: 1870: F11: Open the bookmarks file\n\ 3280 -: 1871: F12: Quit\n\n" 3281 -: 1872: "NOTE: C stands for Ctrl, S for Shift, and M for Meta (Alt key in " 3282 -: 1873: "most keyboards)\n\n")); 3283 -: 1874: 3284 38: 1875: puts(_("Run the 'colors' or 'cc' command to see the list " 3285call 0 returned 38 3286call 1 returned 38 3287 -: 1876: "of currently used color codes.\n")); 3288 -: 1877: 3289 38: 1878: puts(_("The configuration and profile files allow you to customize " 3290call 0 returned 38 3291call 1 returned 38 3292 -: 1879: "colors, define some prompt commands and aliases, and more. " 3293 -: 1880: "For a full description consult the manpage.")); 3294 38: 1881:} 3295 -: 1882: 3296 -: 1883:void 3297function free_software called 1 returned 100% blocks executed 100% 3298 1: 1884:free_software(void) 3299 -: 1885:{ 3300 1: 1886: puts(_("Excerpt from 'What is Free Software?', by Richard Stallman. \ 3301 1: 1886-block 0 3302call 0 returned 1 3303call 1 returned 1 3304 -: 1887:Source: https://www.gnu.org/philosophy/free-sw.html\n \ 3305 -: 1888:\n\"'Free software' means software that respects users' freedom and \ 3306 -: 1889:community. Roughly, it means that the users have the freedom to run, \ 3307 -: 1890:copy, distribute, study, change and improve the software. Thus, 'free \ 3308 -: 1891:software' is a matter of liberty, not price. To understand the concept, \ 3309 -: 1892:you should think of 'free' as in 'free speech', not as in 'free beer'. \ 3310 -: 1893:We sometimes call it 'libre software', borrowing the French or Spanish \ 3311 -: 1894:word for 'free' as in freedom, to show we do not mean the software is \ 3312 -: 1895:gratis.\n\ 3313 -: 1896:\nWe campaign for these freedoms because everyone deserves them. With \ 3314 -: 1897:these freedoms, the users (both individually and collectively) control \ 3315 -: 1898:the program and what it does for them. When users don't control the \ 3316 -: 1899:program, we call it a 'nonfree' or proprietary program. The nonfree \ 3317 -: 1900:program controls the users, and the developer controls the program; \ 3318 -: 1901:this makes the program an instrument of unjust power. \n\ 3319 -: 1902:\nA program is free software if the program's users have the four \ 3320 -: 1903:essential freedoms:\n\n\ 3321 -: 1904:- The freedom to run the program as you wish, for any purpose \ 3322 -: 1905:(freedom 0).\n\ 3323 -: 1906:- The freedom to study how the program works, and change it so it does \ 3324 -: 1907:your computing as you wish (freedom 1). Access to the source code is a \ 3325 -: 1908:precondition for this.\n\ 3326 -: 1909:- The freedom to redistribute copies so you can help your neighbor \ 3327 -: 1910:(freedom 2).\n\ 3328 -: 1911:- The freedom to distribute copies of your modified versions to others \ 3329 -: 1912:(freedom 3). By doing this you can give the whole community a chance to \ 3330 -: 1913:benefit from your changes. Access to the source code is a precondition \ 3331 -: 1914:for this. \n\ 3332 -: 1915:\nA program is free software if it gives users adequately all of these \ 3333 -: 1916:freedoms. Otherwise, it is nonfree. While we can distinguish various \ 3334 -: 1917:nonfree distribution schemes in terms of how far they fall short of \ 3335 -: 1918:being free, we consider them all equally unethical (...)\"")); 3336 1: 1919:} 3337 -: 1920: 3338 -: 1921:void 3339function version_function called 1 returned 100% blocks executed 100% 3340 1: 1922:version_function(void) 3341 -: 1923:{ 3342 1: 1924: printf(_("%s %s (%s), by %s\nContact: %s\nWebsite: " 3343 1: 1924-block 0 3344call 0 returned 1 3345call 1 returned 1 3346 -: 1925: "%s\nLicense: %s\n"), PROGRAM_NAME, VERSION, DATE, 3347 -: 1926: AUTHOR, CONTACT, WEBSITE, LICENSE); 3348 1: 1927:} 3349 -: 1928: 3350 -: 1929:void 3351function splash called 1 returned 100% blocks executed 60% 3352 1: 1930:splash(void) 3353 -: 1931:{ 3354 1: 1932: printf("\n%s" 3355 1: 1932-block 0 3356call 0 returned 1 3357 -: 1933:" .okkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkd. \n" 3358 -: 1934:" 'kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkc\n" 3359 -: 1935:" xkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\n" 3360 -: 1936:" xkkkkkc::::::::::::::::::dkkkkkkc:::::kkkkkk\n" 3361 -: 1937:" xkkkkk'..................okkkkkk'.....kkkkkk\n" 3362 -: 1938:" xkkkkk'..................okkkkkk'.....kkkkkk\n" 3363 -: 1939:" xkkkkk'.....okkkkkk,.....okkkkkk'.....kkkkkk\n" 3364 -: 1940:" xkkkkk'.....dkkkkkk;.....okkkkkk'.....kkkkkk\n" 3365 -: 1941:" xkkkkk'.....dkkkkkk;.....okkkkkk'.....kkkkkk\n" 3366 -: 1942:" xkkkkk'.....dkkkkkk;.....okkkkkk'.....kkkkkk\n" 3367 -: 1943:" xkkkkk'.....dkkkkkk;.....okkkkkk'.....kkkkkk\n" 3368 -: 1944:" xkkkkk'.....dkkkkkk;.....okkkkkk'.....kkkkkk\n" 3369 -: 1945:" xkkkkk'.....dkkkkkk;.....okkkkkk'.....kkkkkk\n" 3370 -: 1946:" xkkkkk'.....dkkkkkk;.....okkkkkk'.....kkkkkk\n" 3371 -: 1947:" xkkkkk'.....dkkkkkk;.....okkkkkk'.....kkkkkk\n" 3372 -: 1948:" xkkkkk'.....coooooo'.....:llllll......kkkkkk\n" 3373 -: 1949:" xkkkkk'...............................kkkkkk\n" 3374 -: 1950:" xkkkkk'...............................kkkkkk\n" 3375 -: 1951:" xkkkkklccccccccccccccccccccccccccccccckkkkkk\n" 3376 -: 1952:" lkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkx\n" 3377 -: 1953:" ;kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkc \n" 3378 -: 1954:" :c::::::::::::::::::::::::::::::::::.", 3379 -: 1955: D_CYAN); 3380 -: 1956: 3381 1: 1957: printf(_("\n\n%s%s\t\t CliFM%s\n\tThe KISS/non-curses file manager\n"), 3382call 0 returned 1 3383call 1 returned 1 3384 -: 1958: df_c, BOLD, df_c); 3385 -: 1959: 3386 1: 1960: if (splash_screen) { 3387branch 0 taken 0 (fallthrough) 3388branch 1 taken 1 3389 #####: 1961: printf(_("\n\t\t\tPress any key to continue... ")); 3390 %%%%%: 1961-block 0 3391call 0 never executed 3392call 1 never executed 3393 #####: 1962: xgetchar(); 3394call 0 never executed 3395 #####: 1963: putchar('\n'); 3396call 0 never executed 3397unconditional 1 never executed 3398 -: 1964: } else { 3399 1: 1965: putchar('\n'); 3400 1: 1965-block 0 3401call 0 returned 1 3402unconditional 1 taken 1 3403 -: 1966: } 3404 1: 1967:} 3405 -: 1968: 3406 -: 1969:void 3407function bonus_function called 0 returned 0% blocks executed 0% 3408 #####: 1970:bonus_function(void) 3409 -: 1971:{ 3410 #####: 1972: char *phrases[] = { 3411 -: 1973: "\"Vamos Boca Juniors Carajo!\" (La mitad + 1)", 3412 -: 1974: "\"Hey! Look behind you! A three-headed monkey! (G. Threepweed)", 3413 -: 1975: "\"Free as in free speech, not as in free beer\" (R. M. S)", 3414 -: 1976: "\"Nothing great has been made in the world without passion\" (G. W. F. Hegel)", 3415 -: 1977: "\"Simplicity is the ultimate sophistication\" (Leo Da Vinci)", 3416 -: 1978: "\"Yo vendí semillas de alambre de púa, al contado, y me lo agradecieron\" (Marquitos, 9 Reinas)", 3417 -: 1979: "\"I'm so happy, because today I've found my friends, they're in my head\" (K. D. Cobain)", 3418 -: 1980: "\"The best code is written with the delete key (Someone, somewhere, sometime)", 3419 -: 1981: "\"I'm selling these fine leather jackets (Indy)", 3420 -: 1982: "\"I pray to God to make me free of God\" (Meister Eckhart)", 3421 -: 1983: "¡Truco y quiero retruco mierda!", 3422 -: 1984: "The only truth is that there is no truth", 3423 -: 1985: "\"This is a lie\" (The liar paradox)", 3424 -: 1986: "\"There are two ways to write error-free programs; only the third one works\" (Alan J. Perlis)", 3425 -: 1987: "The man who sold the world was later sold by the big G", 3426 -: 1988: "A programmer is always one year older than herself", 3427 -: 1989: "A smartphone is anything but smart", 3428 -: 1990: "And he did it: he killed the one who killed him", 3429 -: 1991: ">++('>", 3430 -: 1992: ":(){:|:&};:", 3431 -: 1993: "Keep it simple, stupid", 3432 -: 1994: "If ain't broken, brake it", 3433 -: 1995: "An Archer knows her target like the back of her hands", 3434 -: 1996: "\"I only know that I know nothing\" (Socrates)", 3435 -: 1997: "(Learned) Ignorance is the true outcome of wisdom (Nicholas " 3436 -: 1998: "of Cusa)", 3437 -: 1999: "True intelligence is about questions, not about answers", 3438 -: 2000: "Humanity is just an arrow released towards God", 3439 -: 2001: "Buzz is right: infinity is our only and ultimate goal", 3440 -: 2002: "That stain will never ever be erased (La 12)", 3441 -: 2003: "\"A work of art is never finished, but adandoned\" (J. L. Guerrero)", 3442 -: 2004: "At the beginning, software was hardware; but today hardware is " 3443 -: 2005: "being absorbed by software", 3444 -: 2006: NULL}; 3445 -: 2007: 3446 #####: 2008: size_t num = (sizeof(phrases) / sizeof(phrases[0])) - 1; 3447 #####: 2009: srand((unsigned int)time(NULL)); 3448 %%%%%: 2009-block 0 3449call 0 never executed 3450call 1 never executed 3451 #####: 2010: puts(phrases[rand() % (int)num]); 3452call 0 never executed 3453call 1 never executed 3454 #####: 2011:} 3455