Restore proper handling of errors
This commit is contained in:
parent
3ef2ba8fca
commit
9a60f176e3
|
@ -84,9 +84,10 @@ static int _editor_filter(EditorPrefs * prefs)
|
|||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, template);
|
||||
#endif
|
||||
/* write to and from the temporary file */
|
||||
if((ret = filter_read(fd, template)) == 0
|
||||
&& (ret = _editor(prefs, template)) == 0)
|
||||
ret = filter_write(template);
|
||||
if((ret = filter_read(fd, template)) != 0
|
||||
|| (ret = _editor(prefs, template)) != 0
|
||||
|| (ret = filter_write(template)) != 0)
|
||||
error_print(PROGNAME);
|
||||
/* remove the temporary file */
|
||||
if(unlink(template) != 0)
|
||||
/* we can otherwise ignore this error */
|
||||
|
|
|
@ -6,9 +6,9 @@ SBINDIR = $(PREFIX)/sbin
|
|||
CC = cc
|
||||
CPPFLAGSF=
|
||||
CPPFLAGS=
|
||||
CFLAGSF = -W
|
||||
CFLAGSF = -W `pkg-config --cflags libSystem`
|
||||
CFLAGS = -Wall -g -O2 -pedantic
|
||||
LDFLAGSF= -lintl
|
||||
LDFLAGSF= `pkg-config --libs libSystem` -lintl
|
||||
LDFLAGS =
|
||||
RM = rm -f
|
||||
LN = ln -f
|
||||
|
@ -20,7 +20,7 @@ all: $(TARGETS)
|
|||
|
||||
filter_OBJS = filter.o
|
||||
filter_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||
filter_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) `pkg-config --libs libSystem` ../src/filter.o
|
||||
filter_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) ../src/filter.o
|
||||
|
||||
filter: $(filter_OBJS)
|
||||
$(CC) -o filter $(filter_OBJS) $(filter_LDFLAGS)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <System.h>
|
||||
#include "../src/filter.h"
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
|
@ -69,9 +70,12 @@ static int _filter(int argc, char const * argv[])
|
|||
fprintf(stderr, "DEBUG: %s() \"%s\"\n", __func__, template);
|
||||
#endif
|
||||
/* write to and from the temporary file */
|
||||
if((ret = filter_read(fd, template)) == 0
|
||||
&& (ret = _filter_exec(template, argc, argv)) == 0)
|
||||
ret = filter_write(template);
|
||||
if((ret = filter_read(fd, template)) != 0)
|
||||
error_print(PROGNAME);
|
||||
else if((ret = _filter_exec(template, argc, argv)) != 0)
|
||||
error_print(PROGNAME);
|
||||
else if((ret = filter_write(template)) != 0)
|
||||
error_print(PROGNAME);
|
||||
/* remove the temporary file */
|
||||
if(unlink(template) != 0)
|
||||
/* we can otherwise ignore this error */
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
targets=filter
|
||||
cflags_force=-W
|
||||
cflags_force=-W `pkg-config --cflags libSystem`
|
||||
cflags=-Wall -g -O2 -pedantic
|
||||
ldflags_force=-lintl
|
||||
ldflags_force=`pkg-config --libs libSystem` -lintl
|
||||
ldflags=
|
||||
dist=Makefile
|
||||
|
||||
[filter]
|
||||
type=binary
|
||||
sources=filter.c
|
||||
ldflags=`pkg-config --libs libSystem` ../src/filter.o
|
||||
ldflags=../src/filter.o
|
||||
|
|
Loading…
Reference in New Issue
Block a user