Skip to content

Commit 56f9387

Browse files
committed
tldr.c: fix indentation, update code; gitignore: add vscode directory
Signed-off-by: K.B.Dharun Krishna <[email protected]>
1 parent a7cc5e5 commit 56f9387

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ infer-out
3333
*.i*86
3434
*.x86_64
3535
*.hex
36+
37+
# VSCode
38+
.vscode

src/tldr.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
#include <stdio.h>
1313
#include <string.h>
1414
#include <time.h>
15+
#include <unistd.h> //for isatty
1516

1617
#define VERSION_TAG "v1.6.0"
1718
#ifndef VERSION
18-
#define VERSION_PRETTY ""
19+
#define VERSION_PRETTY ""
1920
#else
20-
#define VERSION_PRETTY VERSION
21+
#define VERSION_PRETTY VERSION
2122
#endif
2223

2324
/* Help and usage */
24-
void print_version (char const *arg);
25-
void print_usage (char const *arg);
25+
void print_version(char const *arg);
26+
void print_usage(char const *arg);
2627

2728
/* getopt */
2829
static int help_flag;
@@ -47,11 +48,10 @@ static struct option long_options[] = {
4748
{"sunos", no_argument, 0, 'p'},
4849
{"list", no_argument, &list_flag, 'l'},
4950
{"render", required_argument, 0, 'r'},
50-
{"color", no_argument, &color_flag, 'C'}, {0, 0, 0, 0}};
51+
{"color", no_argument, &color_flag, 'C'},
52+
{0, 0, 0, 0}};
5153

52-
int
53-
main(int argc, char **argv)
54-
{
54+
int main(int argc, char **argv) {
5555
int c;
5656
int missing_arg;
5757
int option_index;
@@ -79,12 +79,12 @@ main(int argc, char **argv)
7979
break;
8080

8181
case '?':
82-
/* do not set help flag, only show getopt error */
82+
/* do not set the help flag, only show getopt error */
8383
/* help_flag = 1; */
8484
break;
8585

8686
case 'p': {
87-
const char* platform_name = long_options[option_index].name;
87+
const char *platform_name = long_options[option_index].name;
8888
if (strcmp(platform_name, "platform") == 0) {
8989
size_t len = strlen(optarg);
9090
if (len > STRBUFSIZ)
@@ -121,7 +121,7 @@ main(int argc, char **argv)
121121
check_localdate();
122122
}
123123

124-
/* show help, if platform was supplied, but no further argument */
124+
/* show help, if the platform was supplied, but no further argument */
125125
missing_arg = (platform_flag && !list_flag && (optind == argc));
126126
if (help_flag || missing_arg) {
127127
print_usage(argv[0]);
@@ -166,7 +166,7 @@ main(int argc, char **argv)
166166
sum = 0;
167167
while (optind < argc) {
168168
len = strlen(argv[optind]);
169-
if (sum+len >= 4096)
169+
if (sum + len >= 4096)
170170
exit(EXIT_FAILURE);
171171
memcpy(buf + sum, argv[optind], len);
172172
memcpy(buf + sum + len, "-", 1);
@@ -192,22 +192,18 @@ main(int argc, char **argv)
192192
return EXIT_SUCCESS;
193193
}
194194

195-
void
196-
print_version(char const *arg)
197-
{
195+
void print_version(char const *arg) {
198196
/* *INDENT-OFF* */
199197
if (strcmp("", VERSION_PRETTY) == 0)
200-
fprintf(stdout, "%s %s\n", arg, VERSION_TAG);
198+
fprintf(stdout, "%s %s\n", arg, VERSION_TAG);
201199
else
202-
fprintf(stdout, "%s %s (%s)\n", arg, VERSION_TAG, VERSION_PRETTY);;
200+
fprintf(stdout, "%s %s (%s)\n", arg, VERSION_TAG, VERSION_PRETTY);;
203201
fprintf(stdout, "Copyright (C) 2016 Arvid Gerstmann\n");
204202
fprintf(stdout, "Source available at https://github.com/tldr-pages/tldr-c-client\n");
205203
/* *INDENT-ON* */
206204
}
207205

208-
void
209-
print_usage(char const *arg)
210-
{
206+
void print_usage(char const *arg) {
211207
char const *out = "usage: %s [-v] [OPTION]... SEARCH\n\n";
212208

213209
/* *INDENT-OFF* */
@@ -229,4 +225,3 @@ print_usage(char const *arg)
229225
fprintf(stdout, " %-20s %-30s\n", "-C, --color", "force color display");
230226
/* *INDENT-ON* */
231227
}
232-

0 commit comments

Comments
 (0)