| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/argv-iter.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | struct argv_iterator | - | ||||||||||||
| 5 | { | - | ||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | FILE *fp; | - | ||||||||||||
| 9 | size_t item_idx; | - | ||||||||||||
| 10 | char *tok; | - | ||||||||||||
| 11 | size_t buf_len; | - | ||||||||||||
| 12 | - | |||||||||||||
| 13 | - | |||||||||||||
| 14 | char **arg_list; | - | ||||||||||||
| 15 | char **p; | - | ||||||||||||
| 16 | }; | - | ||||||||||||
| 17 | - | |||||||||||||
| 18 | struct argv_iterator * | - | ||||||||||||
| 19 | argv_iter_init_argv (char **argv) | - | ||||||||||||
| 20 | { | - | ||||||||||||
| 21 | struct argv_iterator *ai = malloc (sizeof *ai); | - | ||||||||||||
| 22 | if (!ai
| 0-2145 | ||||||||||||
| 23 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||
| 24 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
| 25 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 26 | ai->fp = | - | ||||||||||||
| 27 | ((void *)0) | - | ||||||||||||
| 28 | ; | - | ||||||||||||
| 29 | ai->arg_list = argv; | - | ||||||||||||
| 30 | ai->p = argv; | - | ||||||||||||
| 31 | return executed 2145 times by 2 tests: ai;return ai;Executed by:
executed 2145 times by 2 tests: return ai;Executed by:
| 2145 | ||||||||||||
| 32 | } | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | - | |||||||||||||
| 35 | - | |||||||||||||
| 36 | struct argv_iterator * | - | ||||||||||||
| 37 | argv_iter_init_stream (FILE *fp) | - | ||||||||||||
| 38 | { | - | ||||||||||||
| 39 | struct argv_iterator *ai = malloc (sizeof *ai); | - | ||||||||||||
| 40 | if (!ai
| 0-15 | ||||||||||||
| 41 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||
| 42 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
| 43 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 44 | ai->fp = fp; | - | ||||||||||||
| 45 | ai->tok = | - | ||||||||||||
| 46 | ((void *)0) | - | ||||||||||||
| 47 | ; | - | ||||||||||||
| 48 | ai->buf_len = 0; | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | ai->item_idx = 0; | - | ||||||||||||
| 51 | ai->arg_list = | - | ||||||||||||
| 52 | ((void *)0) | - | ||||||||||||
| 53 | ; | - | ||||||||||||
| 54 | return executed 15 times by 2 tests: ai;return ai;Executed by:
executed 15 times by 2 tests: return ai;Executed by:
| 15 | ||||||||||||
| 55 | } | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | char * | - | ||||||||||||
| 58 | argv_iter (struct argv_iterator *ai, enum argv_iter_err *err) | - | ||||||||||||
| 59 | { | - | ||||||||||||
| 60 | if (ai->fp
| 30-9737 | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | ssize_t len = getdelim (&ai->tok, &ai->buf_len, '\0', ai->fp); | - | ||||||||||||
| 63 | if (len < 0
| 15 | ||||||||||||
| 64 | { | - | ||||||||||||
| 65 | *err = feof (ai->fp)
| 2-13 | ||||||||||||
| 66 | return executed 15 times by 2 tests: return ((void *)0) ;Executed by:
executed 15 times by 2 tests: return ((void *)0) ;Executed by:
| 15 | ||||||||||||
| 67 | ((void *)0) executed 15 times by 2 tests: return ((void *)0) ;Executed by:
| 15 | ||||||||||||
| 68 | ; executed 15 times by 2 tests: return ((void *)0) ;Executed by:
| 15 | ||||||||||||
| 69 | } | - | ||||||||||||
| 70 | - | |||||||||||||
| 71 | *err = AI_ERR_OK; | - | ||||||||||||
| 72 | ai->item_idx++; | - | ||||||||||||
| 73 | return executed 15 times by 2 tests: ai->tok;return ai->tok;Executed by:
executed 15 times by 2 tests: return ai->tok;Executed by:
| 15 | ||||||||||||
| 74 | } | - | ||||||||||||
| 75 | else | - | ||||||||||||
| 76 | { | - | ||||||||||||
| 77 | if (*(
| 2145-7592 | ||||||||||||
| 78 | ((void *)0)
| 2145-7592 | ||||||||||||
| 79 | ) | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | *err = AI_ERR_EOF; | - | ||||||||||||
| 82 | return executed 2145 times by 2 tests: return ((void *)0) ;Executed by:
executed 2145 times by 2 tests: return ((void *)0) ;Executed by:
| 2145 | ||||||||||||
| 83 | ((void *)0) executed 2145 times by 2 tests: return ((void *)0) ;Executed by:
| 2145 | ||||||||||||
| 84 | ; executed 2145 times by 2 tests: return ((void *)0) ;Executed by:
| 2145 | ||||||||||||
| 85 | } | - | ||||||||||||
| 86 | else | - | ||||||||||||
| 87 | { | - | ||||||||||||
| 88 | *err = AI_ERR_OK; | - | ||||||||||||
| 89 | return executed 7592 times by 2 tests: *(ai->p++);return *(ai->p++);Executed by:
executed 7592 times by 2 tests: return *(ai->p++);Executed by:
| 7592 | ||||||||||||
| 90 | } | - | ||||||||||||
| 91 | } | - | ||||||||||||
| 92 | } | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | size_t | - | ||||||||||||
| 95 | argv_iter_n_args (struct argv_iterator const *ai) | - | ||||||||||||
| 96 | { | - | ||||||||||||
| 97 | return executed 3751 times by 2 tests: ai->fp ? ai->item_idx : ai->p - ai->arg_list;return ai->fp ? ai->item_idx : ai->p - ai->arg_list;Executed by:
executed 3751 times by 2 tests: return ai->fp ? ai->item_idx : ai->p - ai->arg_list;Executed by:
| 3751 | ||||||||||||
| 98 | } | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | void | - | ||||||||||||
| 101 | argv_iter_free (struct argv_iterator *ai) | - | ||||||||||||
| 102 | { | - | ||||||||||||
| 103 | if (ai->fp
| 15-2145 | ||||||||||||
| 104 | free (ai->tok); executed 15 times by 2 tests: free (ai->tok);Executed by:
| 15 | ||||||||||||
| 105 | free (ai); | - | ||||||||||||
| 106 | } executed 2160 times by 2 tests: end of blockExecuted by:
| 2160 | ||||||||||||
| Switch to Source code | Preprocessed file |