mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-22 19:22:05 +00:00
Now that we replace missing libc functions, switch back to err().
This commit is contained in:
@@ -11,18 +11,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef STRL_IN_LIBC
|
||||
#define strlcpy rgbds_strlcpy
|
||||
#define strlcat rgbds_strlcat
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
size_t strlcat(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#include "asm/symbol.h"
|
||||
#include "asm/fstack.h"
|
||||
#include "asm/types.h"
|
||||
#include "asm/main.h"
|
||||
#include "asm/lexer.h"
|
||||
#include "extern/err.h"
|
||||
#include "extern/strl.h"
|
||||
|
||||
/*
|
||||
* RGBAsm - FSTACK.C (FileStack routines)
|
||||
@@ -245,10 +240,8 @@ fstk_RunInclude(char *tzFileName)
|
||||
f = fstk_FindFile(tzFileName);
|
||||
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "Unable to open included file '%s': ",
|
||||
err(1, "Unable to open included file '%s'",
|
||||
tzFileName);
|
||||
perror(NULL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pushcontext();
|
||||
@@ -357,10 +350,7 @@ fstk_Init(char *s)
|
||||
pFileStack = NULL;
|
||||
pCurrentFile = fopen(tzFileName, "rb");
|
||||
if (pCurrentFile == NULL) {
|
||||
fprintf(stderr, "Unable to open file '%s': ",
|
||||
tzFileName);
|
||||
perror(NULL);
|
||||
exit(1);
|
||||
err(1, "Unable to open file '%s'", tzFileName);
|
||||
}
|
||||
|
||||
nMacroCount = 0;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "asm/main.h"
|
||||
#include "asm/rpn.h"
|
||||
#include "asm/fstack.h"
|
||||
#include "extern/err.h"
|
||||
|
||||
#include "asmy.h"
|
||||
|
||||
@@ -213,9 +214,8 @@ void
|
||||
lex_CheckCharacterRange(UWORD start, UWORD end)
|
||||
{
|
||||
if (start > end || start < 1 || end > 127) {
|
||||
fprintf(stderr, "Invalid character range (start: %u, end: %u)\n",
|
||||
errx(1, "Invalid character range (start: %u, end: %u)",
|
||||
start, end);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,8 +344,6 @@ lex_AddStrings(struct sLexInitString * lex)
|
||||
while (*ppHash)
|
||||
ppHash = &((*ppHash)->pNext);
|
||||
|
||||
//printf("%s has hashvalue %d\n", lex->tzName, hash);
|
||||
|
||||
if (((*ppHash) =
|
||||
(struct sLexString *) malloc(sizeof(struct sLexString))) !=
|
||||
NULL) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "asm/fstack.h"
|
||||
#include "asm/output.h"
|
||||
#include "asm/main.h"
|
||||
#include "extern/err.h"
|
||||
|
||||
int yyparse(void);
|
||||
void setuplex(void);
|
||||
@@ -133,9 +134,8 @@ opt_Parse(char *s)
|
||||
newopt.gbgfx[2] = s[3];
|
||||
newopt.gbgfx[3] = s[4];
|
||||
} else {
|
||||
fprintf(stderr, "Must specify exactly 4 characters "
|
||||
"for option 'g'\n");
|
||||
exit(1);
|
||||
errx(1, "Must specify exactly 4 characters for "
|
||||
"option 'g'");
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
@@ -143,9 +143,8 @@ opt_Parse(char *s)
|
||||
newopt.binary[0] = s[1];
|
||||
newopt.binary[1] = s[2];
|
||||
} else {
|
||||
fprintf(stderr, "Must specify exactly 2 characters "
|
||||
"for option 'b'\n");
|
||||
exit(1);
|
||||
errx(1, "Must specify exactly 2 characters for option "
|
||||
"'b'");
|
||||
}
|
||||
break;
|
||||
case 'z':
|
||||
@@ -154,12 +153,10 @@ opt_Parse(char *s)
|
||||
|
||||
result = sscanf(&s[1], "%lx", &newopt.fillchar);
|
||||
if (!((result == EOF) || (result == 1))) {
|
||||
fprintf(stderr,
|
||||
"Invalid argument for option 'z'\n");
|
||||
exit(1);
|
||||
errx(1, "Invalid argument for option 'z'");
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Invalid argument for option 'z'\n");
|
||||
errx(1, "Invalid argument for option 'z'");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
@@ -295,9 +292,8 @@ main(int argc, char *argv[])
|
||||
newopt.binary[0] = optarg[1];
|
||||
newopt.binary[1] = optarg[2];
|
||||
} else {
|
||||
fprintf(stderr, "Must specify exactly "
|
||||
"2 characters for option 'b'\n");
|
||||
exit(1);
|
||||
errx(1, "Must specify exactly 2 characters for "
|
||||
"option 'b'");
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
@@ -307,9 +303,8 @@ main(int argc, char *argv[])
|
||||
newopt.gbgfx[2] = optarg[3];
|
||||
newopt.gbgfx[3] = optarg[4];
|
||||
} else {
|
||||
fprintf(stderr, "Must specify exactly "
|
||||
"4 characters for option 'g'\n");
|
||||
exit(1);
|
||||
errx(1, "Must specify exactly 4 characters for "
|
||||
"option 'g'");
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
@@ -324,14 +319,11 @@ main(int argc, char *argv[])
|
||||
case 'p':
|
||||
newopt.fillchar = strtoul(optarg, &ep, 0);
|
||||
if (optarg[0] == '\0' || *ep != '\0') {
|
||||
fprintf(stderr,
|
||||
"Invalid argument for option 'p'\n");
|
||||
exit(1);
|
||||
errx(1, "Invalid argument for option 'p'");
|
||||
}
|
||||
if (newopt.fillchar < 0 || newopt.fillchar > 0xFF) {
|
||||
fprintf(stderr, "Argument for option 'p' "
|
||||
"must be between 0 and 0xFF\n");
|
||||
exit(1);
|
||||
errx(1, "Argument for option 'p' must be "
|
||||
"between 0 and 0xFF");
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
@@ -420,16 +412,12 @@ main(int argc, char *argv[])
|
||||
exit(5);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unterminated IF construct (%ld levels)!\n",
|
||||
errx(1, "Unterminated IF construct (%ld levels)!",
|
||||
nIFDepth);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Assembly aborted in pass 1 (%ld errors)!\n",
|
||||
errx(1, "Assembly aborted in pass 1 (%ld errors)!",
|
||||
nErrors);
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "asm/main.h"
|
||||
#include "asm/rpn.h"
|
||||
#include "asm/fstack.h"
|
||||
#include "extern/err.h"
|
||||
|
||||
#define SECTIONCHUNK 0x4000
|
||||
|
||||
@@ -909,10 +910,7 @@ out_BinaryFile(char *s)
|
||||
|
||||
f = fstk_FindFile(s);
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "Unable to open incbin file '%s': ",
|
||||
s);
|
||||
perror(NULL);
|
||||
exit(1);
|
||||
err(1, "Unable to open incbin file '%s'", s);
|
||||
}
|
||||
|
||||
SLONG fsize;
|
||||
@@ -949,10 +947,7 @@ out_BinaryFileSlice(char *s, SLONG start_pos, SLONG length)
|
||||
|
||||
f = fstk_FindFile(s);
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "Unable to open included file '%s': ",
|
||||
s);
|
||||
perror(NULL);
|
||||
exit(1);
|
||||
err(1, "Unable to open included file '%s'", s);
|
||||
}
|
||||
|
||||
SLONG fsize;
|
||||
|
||||
Reference in New Issue
Block a user