mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 06:02:48 +02:00
eeshow/: convert "perror" to diagnostic functions
This commit is contained in:
parent
d1fdcaeab4
commit
5a7ddc8b95
@ -23,6 +23,7 @@
|
|||||||
#include <cairo/cairo-pdf.h>
|
#include <cairo/cairo-pdf.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "diag.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
@ -344,7 +345,7 @@ static cairo_status_t stream_to_stdout(void *closure,
|
|||||||
wrote = write(1, data, length);
|
wrote = write(1, data, length);
|
||||||
if (wrote == (ssize_t) length)
|
if (wrote == (ssize_t) length)
|
||||||
return CAIRO_STATUS_SUCCESS;
|
return CAIRO_STATUS_SUCCESS;
|
||||||
perror("stdout");
|
diag_perror("stdout");
|
||||||
return CAIRO_STATUS_WRITE_ERROR;
|
return CAIRO_STATUS_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,10 +374,8 @@ static void cr_pdf_new_sheet(void *ctx)
|
|||||||
|
|
||||||
cc->n_sheets++;
|
cc->n_sheets++;
|
||||||
cc->sheets = realloc(cc->sheets, sizeof(struct record) * cc->n_sheets);
|
cc->sheets = realloc(cc->sheets, sizeof(struct record) * cc->n_sheets);
|
||||||
if (!cc->sheets) {
|
if (!cc->sheets)
|
||||||
perror("realloc");
|
diag_pfatal("realloc");
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
cc->sheets[cc->n_sheets - 1] = cc->record;
|
cc->sheets[cc->n_sheets - 1] = cc->record;
|
||||||
record_wipe(&cc->record);
|
record_wipe(&cc->record);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
#include "diag.h"
|
#include "diag.h"
|
||||||
@ -22,6 +24,23 @@
|
|||||||
unsigned verbose = 0;
|
unsigned verbose = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- Specialized diagnostic functions ---------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
void diag_pfatal(const char *s)
|
||||||
|
{
|
||||||
|
fatal("%s: %s\n", s, strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void diag_perror(const char *s)
|
||||||
|
{
|
||||||
|
error("%s: %s\n", s, strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- General diagnostic functions -------------------------------------- */
|
||||||
|
|
||||||
void fatal(const char *fmt, ...)
|
void fatal(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -23,6 +23,18 @@
|
|||||||
extern unsigned verbose;
|
extern unsigned verbose;
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- Specialized diagnostic functions ---------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
/* perror, based on "fatal" or "error" */
|
||||||
|
|
||||||
|
void diag_pfatal(const char *s);
|
||||||
|
void diag_perror(const char *s);
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- General diagnostic functions -------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Terminate immediately. Further execution makes no sense.
|
* Terminate immediately. Further execution makes no sense.
|
||||||
* E.g., out of memory.
|
* E.g., out of memory.
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "diag.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -269,10 +270,8 @@ static void *fig_init(int argc, char *const *argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(template, "r");
|
file = fopen(template, "r");
|
||||||
if (!file) {
|
if (!file)
|
||||||
perror(template);
|
diag_pfatal(template);
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
while (fgets(buf, sizeof(buf), file)) {
|
while (fgets(buf, sizeof(buf), file)) {
|
||||||
while (apply_vars(buf, n_vars, vars));
|
while (apply_vars(buf, n_vars, vars));
|
||||||
printf("%s", buf);
|
printf("%s", buf);
|
||||||
|
@ -182,11 +182,11 @@ bool file_open(struct file *file, const char *name, const struct file *related)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
perror(name); /* @@@ may need changing later */
|
diag_perror(name);
|
||||||
|
|
||||||
if (!strchr(name, ':')) {
|
if (!strchr(name, ':')) {
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
perror(name);
|
diag_perror(name);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,10 +125,8 @@ static char *canonical_path_into_repo(const char *repo_dir, const char *path)
|
|||||||
|
|
||||||
/* identify inode of repo root */
|
/* identify inode of repo root */
|
||||||
|
|
||||||
if (stat(repo_dir, &repo_st) < 0) {
|
if (stat(repo_dir, &repo_st) < 0)
|
||||||
perror(repo_dir);
|
diag_pfatal(repo_dir);
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (!S_ISDIR(repo_st.st_mode))
|
if (!S_ISDIR(repo_st.st_mode))
|
||||||
fatal("%s: not a directory\n", repo_dir);
|
fatal("%s: not a directory\n", repo_dir);
|
||||||
|
|
||||||
|
@ -49,10 +49,8 @@ static void uplink(struct hist *down, struct hist *up)
|
|||||||
{
|
{
|
||||||
down->newer = realloc(down->newer,
|
down->newer = realloc(down->newer,
|
||||||
sizeof(struct hist *) * (down->n_newer + 1));
|
sizeof(struct hist *) * (down->n_newer + 1));
|
||||||
if (!down->newer) {
|
if (!down->newer)
|
||||||
perror("realloc");
|
diag_pfatal("realloc");
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
down->newer[down->n_newer++] = up;
|
down->newer[down->n_newer++] = up;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,10 +124,8 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
|
|||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = realloc((void *) txt->s, len + 3);
|
s = realloc((void *) txt->s, len + 3);
|
||||||
if (!s) {
|
if (!s)
|
||||||
perror("realloc");
|
diag_pfatal("realloc");
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (comp->unit <= 26)
|
if (comp->unit <= 26)
|
||||||
sprintf(s + len, "%c", 'A' + comp->unit - 1);
|
sprintf(s + len, "%c", 'A' + comp->unit - 1);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user