1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Introduce test library in util/test.h containing the die() function

Fix the die() function to exit with EXIT_FAILURE value as pointed
out by Kalle on elinks-dev in <87tzqkxhlp.fsf@Astalo.kon.iki.fi>.
This commit is contained in:
Jonas Fonseca 2007-08-28 20:09:37 +02:00
parent 40afaae7d6
commit 0f53941fef
6 changed files with 30 additions and 74 deletions

View File

@ -15,21 +15,7 @@
#include "dom/select.h"
#include "dom/sgml/parser.h"
#include "dom/stack.h"
void die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(!!NULL);
}
#include "util/test.h"
int
main(int argc, char *argv[])

View File

@ -16,6 +16,7 @@
#include "dom/sgml/dump.h"
#include "dom/sgml/parser.h"
#include "dom/stack.h"
#include "util/test.h"
unsigned int number_of_lines = 0;
@ -242,21 +243,6 @@ sgml_error_function(struct sgml_parser *parser, struct dom_string *string,
return DOM_CODE_OK;
}
static void
die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(!!NULL);
}
static int
get_opt(char **argref, const char *name, int *argi, int argc, char *argv[],
const char *expect_msg)

View File

@ -678,6 +678,9 @@ struct module mailcap_mime_module = struct_module(
);
#ifdef TEST_MAILCAP
#include "util/test.h"
/* Some ugly shortcuts for getting defined symbols to work. */
int default_mime_backend,
install_signal_handler,
@ -685,20 +688,6 @@ int default_mime_backend,
program;
LIST_OF(struct terminal) terminals;
void die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(1);
}
int
main(int argc, char *argv[])
{

View File

@ -13,21 +13,7 @@
#include "osdep/stat.h"
#include "protocol/ftp/parse.h"
void die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(!!NULL);
}
#include "util/test.h"
int
main(int argc, char *argv[])

View File

@ -13,6 +13,7 @@
#include "main/module.h"
#include "protocol/user.h"
#include "session/session.h"
#include "util/test.h"
#define STUB_MODULE(name) \
struct module name = struct_module( \
@ -38,21 +39,6 @@ STUB_MODULE(smb_protocol_module);
STUB_MODULE(uri_rewrite_module);
STUB_MODULE(user_protocol_module);
static void
die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(!!NULL);
}
static void
stub_called(const unsigned char *fun)
{

23
src/util/test.h Normal file
View File

@ -0,0 +1,23 @@
/* Test library */
#ifndef EL__UTIL_TEST_H
#define EL__UTIL_TEST_H
#include <stdlib.h>
static inline void
die(const char *msg, ...)
{
va_list args;
if (msg) {
va_start(args, msg);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
exit(EXIT_FAILURE);
}
#endif