Skip to content

Commit 7fdea3a

Browse files
authored
Merge pull request #3 from mojotx/2022_simplify
2022 simplify
2 parents 86d9b86 + afe09ee commit 7fdea3a

File tree

4 files changed

+35
-25
lines changed

4 files changed

+35
-25
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
12+
# 4 space indentation
13+
[*.c]
14+
indent_style = space
15+
indent_size = 4
16+
17+
# Tab indentation (no size specified)
18+
[Makefile]
19+
indent_style = tab

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xttitle

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

22
#CC=gcc
33
CC=clang
4-
CFLAGS+=-Os -Wall -Wextra -pedantic -fstack-protector -fstack-protector-all -pipe
5-
RM=rm -rvf
4+
CFLAGS+=-Os -Wall -Wextra -pedantic -fstack-protector -pipe
5+
RM=rm -vf
66

7+
all: xttitle
78

89
xttitle: src/xttitle.c
910
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<

src/xttitle.c

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,33 @@ along with this program. If not, see <htp://www.gnu.org/licenses/>.
2828

2929
#define FORMAT "\033]2;%s\007\033\\\033[1A\n\033]1;%s\007\033\\\033[1A\n\033]21;%s\033\\\033[1A\n\033]2L;%s\033\\\033[1A\n"
3030

31-
static void usage( const char *prog );
32-
33-
int main( int argc, char *argv[] )
34-
{
31+
int main(int argc, char *argv[]) {
32+
int rc = EXIT_SUCCESS;
3533
char *title = NULL; /* Used to set the title of the window */
36-
char *icon = NULL; /* Used to set the icon name */
34+
char *icon = NULL; /* Used to set the icon name */
3735

38-
switch ( argc ) {
39-
case 1:
40-
usage(argv[0]);
41-
exit(1);
42-
break; /* Never reached */
4336

37+
switch (argc) {
4438
case 2:
4539
/* If there was just one parameter, set icon to same as title. */
4640
title = argv[1];
47-
icon = argv[1];
41+
icon = argv[1];
4842
break;
4943

5044
case 3:
5145
/* They passed both window title AND icon name */
5246
title = argv[1];
53-
icon = argv[2];
47+
icon = argv[2];
5448
break;
5549

5650
default:
57-
usage(argv[0]);
58-
exit(1);
59-
break; /* Never reached */
51+
printf("Usage: %s <window title> [ <icon title> ]\n", argv[0]);
52+
rc = EXIT_FAILURE;
53+
break;
6054
}
6155

62-
printf( FORMAT, title, icon, title, icon );
56+
if (rc == EXIT_SUCCESS)
57+
printf(FORMAT, title, icon, title, icon);
6358

64-
exit(0);
59+
return rc;
6560
}
66-
67-
static void usage( const char *prog )
68-
{
69-
printf("Usage: %s <window title> [ <icon title> ]\n", prog );
70-
}
71-

0 commit comments

Comments
 (0)