mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Improve error and warning output
Improve error messages generated by `errx()`, `warnx()` and similar. Set `progname` to a static string with the name of the program so that the path of the binary isn't included in error messages. Signed-off-by: AntonioND <antonio_nd@outlook.com>
This commit is contained in:
@@ -298,7 +298,7 @@ main(int argc, char *argv[])
|
|||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
progname = argv[0];
|
progname = "rgbasm";
|
||||||
|
|
||||||
/* yydebug=1; */
|
/* yydebug=1; */
|
||||||
|
|
||||||
|
|||||||
26
src/extern/err.c
vendored
26
src/extern/err.c
vendored
@@ -30,30 +30,44 @@ extern char *progname;
|
|||||||
|
|
||||||
void rgbds_vwarn(const char *fmt, va_list ap)
|
void rgbds_vwarn(const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: ", progname);
|
fprintf (stderr, "%s:warning", progname);
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
|
fputs (":", stderr);
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
fputs (": ", stderr);
|
|
||||||
}
|
}
|
||||||
|
putc('\n', stderr);
|
||||||
perror(0);
|
perror(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rgbds_vwarnx(const char *fmt, va_list ap)
|
void rgbds_vwarnx(const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: ", progname);
|
fprintf (stderr, "%s:warning", progname);
|
||||||
if (fmt) vfprintf(stderr, fmt, ap);
|
if (fmt) {
|
||||||
|
fputs (":", stderr);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
}
|
||||||
putc('\n', stderr);
|
putc('\n', stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
noreturn void rgbds_verr(int status, const char *fmt, va_list ap)
|
noreturn void rgbds_verr(int status, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
vwarn(fmt, ap);
|
fprintf (stderr, "%s:error", progname);
|
||||||
|
if (fmt) {
|
||||||
|
fputs (":", stderr);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
}
|
||||||
|
putc('\n', stderr);
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
noreturn void rgbds_verrx(int status, const char *fmt, va_list ap)
|
noreturn void rgbds_verrx(int status, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
vwarnx(fmt, ap);
|
fprintf (stderr, "%s:error", progname);
|
||||||
|
if (fmt) {
|
||||||
|
fputs (":", stderr);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
}
|
||||||
|
putc('\n', stderr);
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ main(int argc, char *argv[])
|
|||||||
int version; /* mask ROM version number */
|
int version; /* mask ROM version number */
|
||||||
int padvalue; /* to pad the rom with if it changes size */
|
int padvalue; /* to pad the rom with if it changes size */
|
||||||
|
|
||||||
progname = argv[0];
|
progname = "rgbfix";
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "Cci:jk:l:m:n:p:sr:t:v")) != -1) {
|
while ((ch = getopt(argc, argv, "Cci:jk:l:m:n:p:sr:t:v")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ main(int argc, char *argv[])
|
|||||||
char *ext;
|
char *ext;
|
||||||
const char *errmsg = "Warning: The PNG's %s setting is not the same as the setting defined on the command line.";
|
const char *errmsg = "Warning: The PNG's %s setting is not the same as the setting defined on the command line.";
|
||||||
|
|
||||||
progname = argv[0];
|
progname = "rgbgfx";
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
usage();
|
usage();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ main(int argc, char *argv[])
|
|||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
progname = argv[0];
|
progname = "rgblink";
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "l:m:n:o:O:p:s:tw")) != -1) {
|
while ((ch = getopt(argc, argv, "l:m:n:o:O:p:s:tw")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
|||||||
Reference in New Issue
Block a user