Skip to content

Commit 5e096fa

Browse files
authored
Fix floating point exception (#54)
1 parent e4ae71c commit 5e096fa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/catimg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
8181
while ((c = getopt (argc, argv, "H:w:l:r:hct")) != -1)
8282
switch (c) {
8383
case 'H':
84-
rows = strtol(optarg, &num, 0) >> 1;
84+
rows = strtol(optarg, &num, 0);
8585
if (adjust_to_width) {
8686
// only either adjust to width or adjust to height is allowed, but not both.
8787
printf(ERR_WIDTH_OR_HEIGHT);
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
138138

139139
// if precision is 2 we can use the terminal full width/height. Otherwise we can only use half
140140
max_cols = terminal_columns() / (2 / precision);
141-
max_rows = terminal_rows() * 2 / (2 / precision);
141+
max_rows = terminal_rows() * precision;
142142

143143
if (strcmp(file, "-") == 0) {
144144
img_load_from_stdin(&img);
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
157157
scale_cols = cols / (float)img.width;
158158
img_resize(&img, scale_cols, scale_cols);
159159
} else if (rows > 0 && rows < img.height) {
160-
scale_rows = (float)(rows * 2) / (float)img.height;
160+
scale_rows = rows / (float)img.height;
161161
img_resize(&img, scale_rows, scale_rows);
162162
}
163163

0 commit comments

Comments
 (0)