File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 3
3
set -euo pipefail
4
4
5
5
DAY=" $1 "
6
- INPUT=" $2 "
6
+
7
+ if [[ -z ${2-} ]]; then
8
+ INPUT=" ${1: 0:- 1} .input"
9
+ else
10
+ INPUT=$2
11
+ fi
12
+
13
+ FLAGS=" -Ofast \
14
+ -Wunused-but-set-variable \
15
+ -Wunused-parameter \
16
+ -Wunused-macros"
17
+
18
+ if [[ -v D ]]; then
19
+ FLAGS=" -O0 \
20
+ -Wno-unused-function \
21
+ -Wno-unused-variable"
22
+ fi
7
23
8
24
mkdir -p build
9
25
@@ -19,10 +35,7 @@ clang \
19
35
-Wsign-compare \
20
36
-Wswitch-enum \
21
37
-Wno-gnu-binary-literal \
22
- -Wunused-variable \
23
- -Wunused-function \
24
- -Wunused-but-set-variable \
25
- -Wunused-parameter \
38
+ ${=FLAGS} \
26
39
-std=c17 \
27
40
--debug \
28
41
-o " ./build/$DAY " \
Original file line number Diff line number Diff line change 5
5
int main (void ) {
6
6
char * line = NULL ;
7
7
size_t ngetline = 0 ;
8
+
8
9
int nchars = 0 ;
9
10
10
11
while ((nchars = (int )getline (& line , & ngetline , stdin )) > 0 ) {
11
- if (line [nchars - 1 ] == '\n' ) line [-- nchars ] = '\0' ;
12
+ if (line [nchars - 1 ] == '\n' ) line [-- nchars ] = 0 ;
12
13
13
14
printf ("line: %s\n" , line );
14
15
}
You can’t perform that action at this time.
0 commit comments