Skip to content

Commit

Permalink
Fix floating point exception (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
boretom committed Jul 31, 2020
1 parent e4ae71c commit 5e096fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/catimg.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int main(int argc, char *argv[])
while ((c = getopt (argc, argv, "H:w:l:r:hct")) != -1)
switch (c) {
case 'H':
rows = strtol(optarg, &num, 0) >> 1;
rows = strtol(optarg, &num, 0);
if (adjust_to_width) {
// only either adjust to width or adjust to height is allowed, but not both.
printf(ERR_WIDTH_OR_HEIGHT);
Expand Down Expand Up @@ -138,7 +138,7 @@ int main(int argc, char *argv[])

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

if (strcmp(file, "-") == 0) {
img_load_from_stdin(&img);
Expand All @@ -157,7 +157,7 @@ int main(int argc, char *argv[])
scale_cols = cols / (float)img.width;
img_resize(&img, scale_cols, scale_cols);
} else if (rows > 0 && rows < img.height) {
scale_rows = (float)(rows * 2) / (float)img.height;
scale_rows = rows / (float)img.height;
img_resize(&img, scale_rows, scale_rows);
}

Expand Down

0 comments on commit 5e096fa

Please sign in to comment.