Explicitly enable printing of warnings
This commit is contained in:
parent
e2d9463375
commit
03bfe1015e
|
@ -35,6 +35,7 @@ sxiv supports the following command-line options:
|
||||||
-p pixelize, i.e. turn off image anti-aliasing
|
-p pixelize, i.e. turn off image anti-aliasing
|
||||||
-s scale all images to fit into window
|
-s scale all images to fit into window
|
||||||
-v print version information and exit
|
-v print version information and exit
|
||||||
|
-W enable printing of warnings
|
||||||
-w WIDTHxHEIGHT
|
-w WIDTHxHEIGHT
|
||||||
set window width to WIDTH and height to HEIGHT
|
set window width to WIDTH and height to HEIGHT
|
||||||
(if HEIGHT is omitted, height is also set to WIDTH)
|
(if HEIGHT is omitted, height is also set to WIDTH)
|
||||||
|
|
1
image.c
1
image.c
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include "sxiv.h"
|
#include "sxiv.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "options.h"
|
|
||||||
|
|
||||||
int zl_cnt;
|
int zl_cnt;
|
||||||
float zoom_min;
|
float zoom_min;
|
||||||
|
|
1
main.c
1
main.c
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
#include "sxiv.h"
|
#include "sxiv.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "options.h"
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
void on_keypress(XEvent*);
|
void on_keypress(XEvent*);
|
||||||
|
|
|
@ -29,7 +29,7 @@ options_t _options;
|
||||||
const options_t *options = (const options_t*) &_options;
|
const options_t *options = (const options_t*) &_options;
|
||||||
|
|
||||||
void print_usage() {
|
void print_usage() {
|
||||||
printf("usage: sxiv [-dfhpsvZ] [-w WIDTH[xHEIGHT]] [-z ZOOM] FILES...\n");
|
printf("usage: sxiv [-dfhpsvWZ] [-w WIDTH[xHEIGHT]] [-z ZOOM] FILES...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_version() {
|
void print_version() {
|
||||||
|
@ -50,7 +50,9 @@ void parse_options(int argc, char **argv) {
|
||||||
_options.winh = h = 0;
|
_options.winh = h = 0;
|
||||||
_options.fullscreen = 0;
|
_options.fullscreen = 0;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "dfhpsvw:Zz:")) != -1) {
|
_options.warn = 0;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "dfhpsvWw:Zz:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case '?':
|
case '?':
|
||||||
print_usage();
|
print_usage();
|
||||||
|
@ -73,6 +75,9 @@ void parse_options(int argc, char **argv) {
|
||||||
case 'v':
|
case 'v':
|
||||||
print_version();
|
print_version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
case 'W':
|
||||||
|
_options.warn = 1;
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
if (!sscanf(optarg, "%hux%hu", &w, &h)) {
|
if (!sscanf(optarg, "%hux%hu", &w, &h)) {
|
||||||
fprintf(stderr, "sxiv: invalid argument for option -w: %s\n",
|
fprintf(stderr, "sxiv: invalid argument for option -w: %s\n",
|
||||||
|
|
|
@ -32,6 +32,8 @@ typedef struct options_s {
|
||||||
int winw;
|
int winw;
|
||||||
int winh;
|
int winh;
|
||||||
unsigned char fullscreen;
|
unsigned char fullscreen;
|
||||||
|
|
||||||
|
unsigned char warn;
|
||||||
} options_t;
|
} options_t;
|
||||||
|
|
||||||
extern const options_t *options;
|
extern const options_t *options;
|
||||||
|
|
5
sxiv.1
5
sxiv.1
|
@ -3,7 +3,7 @@
|
||||||
sxiv \- Simple (or small or suckless) X Image Viewer
|
sxiv \- Simple (or small or suckless) X Image Viewer
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B sxiv
|
.B sxiv
|
||||||
.RB [ \-dfhpsvZ ]
|
.RB [ \-dfhpsvWZ ]
|
||||||
.RB [ \-w
|
.RB [ \-w
|
||||||
.IB WIDTH x HEIGHT
|
.IB WIDTH x HEIGHT
|
||||||
]
|
]
|
||||||
|
@ -36,6 +36,9 @@ Scale all images to fit into window.
|
||||||
.B \-v
|
.B \-v
|
||||||
Print version information to standard output and exit.
|
Print version information to standard output and exit.
|
||||||
.TP
|
.TP
|
||||||
|
.B \-W
|
||||||
|
Enable printing of warnings to standard error stream.
|
||||||
|
.TP
|
||||||
.BI "\-w " WIDTH x HEIGHT
|
.BI "\-w " WIDTH x HEIGHT
|
||||||
Set window width to
|
Set window width to
|
||||||
.I WIDTH
|
.I WIDTH
|
||||||
|
|
31
sxiv.h
31
sxiv.h
|
@ -20,26 +20,29 @@
|
||||||
#define SXIV_H
|
#define SXIV_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
#define ABS(a) ((a) < 0 ? (-(a)) : (a))
|
#define ABS(a) ((a) < 0 ? (-(a)) : (a))
|
||||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
|
|
||||||
#define WARN(...) \
|
#define WARN(...) \
|
||||||
do { \
|
do { \
|
||||||
fprintf(stderr, "sxiv: %s:%d: warning: ", __FILE__, __LINE__); \
|
if (options->warn) { \
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, "sxiv: %s:%d: warning: ", __FILE__, __LINE__); \
|
||||||
fprintf(stderr, "\n"); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
} while (0)
|
fprintf(stderr, "\n"); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define DIE(...) \
|
#define DIE(...) \
|
||||||
do { \
|
do { \
|
||||||
fprintf(stderr, "sxiv: %s:%d: error: ", __FILE__, __LINE__); \
|
fprintf(stderr, "sxiv: %s:%d: error: ", __FILE__, __LINE__); \
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
fprintf(stderr, "\n"); \
|
fprintf(stderr, "\n"); \
|
||||||
cleanup(); \
|
cleanup(); \
|
||||||
exit(1); \
|
exit(1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue