| 140 | | if (!help || !*help) help = "(no help available)"; |
|---|
| | 140 | if (!help || !*help) { |
|---|
| | 141 | int j, len = 0; |
|---|
| | 142 | |
|---|
| | 143 | for (j = 0; j < cmd->nargs; ++j) |
|---|
| | 144 | len += strlen(cmd->args[j]) + 1; |
|---|
| | 145 | help = (char*)malloc(len); |
|---|
| | 146 | strcpy(help, cmd->args[0]); |
|---|
| | 147 | for (j = 1; j < cmd->nargs; ++j) { |
|---|
| | 148 | strcat(help, " "); |
|---|
| | 149 | if (strchr(cmd->args[j], ' ') || strchr(cmd->args[j], '\t')) { |
|---|
| | 150 | strcat(help, "'"); |
|---|
| | 151 | strcat(help, cmd->args[j]); |
|---|
| | 152 | strcat(help, "'"); |
|---|
| | 153 | } else |
|---|
| | 154 | strcat(help, cmd->args[j]); |
|---|
| | 155 | } |
|---|
| | 156 | } |
|---|
| 142 | | while (*help) { |
|---|
| 143 | | int j; |
|---|
| 144 | | |
|---|
| 145 | | printf("%-*.*s\n", 77 - length, 77 - length, help); |
|---|
| 146 | | for (j = 0; j < 77 - length && *help; ++j, ++help) ; |
|---|
| 147 | | if (j == 77 - length) |
|---|
| 148 | | printf("%-*s", length + 2, ""); |
|---|
| 149 | | } |
|---|
| | 158 | printf("%-*.*s", 77 - length, 77 - length, help); |
|---|
| | 159 | if (strlen(help) > 77 - length) |
|---|
| | 160 | printf("...\n"); |
|---|
| | 161 | else |
|---|
| | 162 | printf("\n"); |
|---|