Fix whitespace

Replace spaces by tabs for consistency. The rest of the codebase uses
tabs, so the linkerscript parser has to change.

Removed trailing tabs in all codebase.

Signed-off-by: AntonioND <antonio_nd@outlook.com>
This commit is contained in:
AntonioND
2017-04-04 22:09:01 +01:00
parent 07cc4fb8fd
commit 5f299bfe6c
10 changed files with 111 additions and 113 deletions

View File

@@ -118,7 +118,6 @@ ULONG str2int2( char *s, int length )
r<<=8;
r|=(UBYTE)(s[i]);
i++;
}
return( r );
}

View File

@@ -438,7 +438,7 @@ CopyMacroArg(char *dest, size_t maxLength, char c)
size_t i;
char *s;
int argNum;
switch (c) {
case '1':
case '2':
@@ -724,7 +724,7 @@ yylex_MACROARGS()
index += length;
else
fatalerror("Illegal character escape '%c'", ch);
ch = 0;
break;
}

View File

@@ -258,13 +258,13 @@ warning(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
fprintf(stderr, "warning: ");
fstk_Dump();
fprintf(stderr, ":\n\t");
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
}

View File

@@ -766,7 +766,7 @@ sym_PrepPass2(void)
sym_AddEqu("_NARG", 0);
p_NARGSymbol = findsymbol("_NARG", NULL);
p_NARGSymbol->Callback = Callback_NARG;
math_DefinePI();
}

View File

@@ -316,7 +316,7 @@ output_png_file(struct Options opts, struct PNGImage *png)
png_init_io(img, f);
png_write_info(img, png->info);
png_write_image(img, png->data);
png_write_end(img, NULL);

View File

@@ -103,14 +103,14 @@ area_doAlloc(struct sFreeArea *pArea, SLONG org, SLONG size)
pNewArea->nOrg = org + size;
pNewArea->nSize -= size + pArea->nSize;
return org;
} else {
err(1, NULL);
}
}
}
}
return -1;
}
@@ -125,7 +125,7 @@ area_AllocAbs(struct sFreeArea ** ppArea, SLONG org, SLONG size)
if (result != -1) {
return result;
}
ppArea = &(pArea->pNext);
pArea = *ppArea;
}
@@ -140,7 +140,7 @@ area_AllocAbsAnyBank(SLONG org, SLONG size, enum eSectionType type)
SLONG startBank = SECT_ATTRIBUTES[type].bank;
SLONG bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) {
if (area_AllocAbs(&BankFree[startBank + i], org, size) != -1) {
return startBank + i;
@@ -156,20 +156,20 @@ area_Alloc(struct sFreeArea ** ppArea, SLONG size, SLONG alignment) {
if (alignment < 1) {
alignment = 1;
}
pArea = *ppArea;
while (pArea) {
SLONG org = pArea->nOrg;
SLONG org = pArea->nOrg;
if (org % alignment) {
org += alignment;
}
org -= org % alignment;
SLONG result = area_doAlloc(pArea, org, size);
if (result != -1) {
return result;
}
ppArea = &(pArea->pNext);
pArea = *ppArea;
}
@@ -183,7 +183,7 @@ area_AllocAnyBank(SLONG size, SLONG alignment, enum eSectionType type) {
SLONG startBank = SECT_ATTRIBUTES[type].bank;
SLONG bankCount = SECT_ATTRIBUTES[type].bankCount;
for (int i = 0; i < bankCount; i++) {
SLONG org = area_Alloc(&BankFree[startBank + i], size, alignment);
if (org != -1) {
@@ -212,7 +212,7 @@ FindLargestSection(enum eSectionType type, bool bankFixed)
}
pSection = pSection->pNext;
}
return r;
}
@@ -294,7 +294,7 @@ VerifyAndSetBank(struct sSection *pSection)
&& pSection->nBank < SECT_ATTRIBUTES[pSection->Type].minBank + SECT_ATTRIBUTES[pSection->Type].bankCount) {
pSection->nBank += SECT_ATTRIBUTES[pSection->Type].bank + SECT_ATTRIBUTES[pSection->Type].offset;
return true;
} else {
return false;
}
@@ -328,7 +328,7 @@ void
AssignFloatingBankSections(enum eSectionType type)
{
ensureSectionTypeIsValid(type);
struct sSection *pSection;
while ((pSection = FindLargestSection(type, false))) {
@@ -347,7 +347,7 @@ AssignFloatingBankSections(enum eSectionType type)
if (SECT_ATTRIBUTES[pSection->Type].bankCount > 1) {
locality = "in any bank";
}
if (pSection->nAlign <= 1) {
errx(1, "Unable to place '%s' (%s section) %s",
pSection->pzName, SECT_ATTRIBUTES[type].name, locality);
@@ -356,7 +356,7 @@ AssignFloatingBankSections(enum eSectionType type)
pSection->pzName, SECT_ATTRIBUTES[type].name, locality, pSection->nAlign);
}
}
}
}
}
char *tzLinkerscriptName = NULL;
@@ -429,7 +429,7 @@ AssignSections(void)
} else {
errx(1, "(INTERNAL) Unknown bank type!");
}
MaxAvail[i] = BankFree[i]->nSize;
BankFree[i]->pPrev = NULL;
BankFree[i]->pNext = NULL;
@@ -523,7 +523,7 @@ AssignSections(void)
pSection->oAssigned = 1;
DOMAXBANK(pSection->Type, pSection->nBank);
break;
default: // Handle other sections later
break;
}

View File

@@ -28,48 +28,48 @@
%%
\"([^\\\"]|\\.)*\" {
if (strlen(yytext) > sizeof(yylval.s) - 1)
errx(1, "String is too long: \"%s\"\n.", yytext);
if (strlen(yytext) < 3) /* 2 quotes + 1 character */
errx(1, "String \"%s\" is invalid\n.", yytext);
\"([^\\\"]|\\.)*\" {
if (strlen(yytext) > sizeof(yylval.s) - 1)
errx(1, "String is too long: \"%s\"\n.", yytext);
if (strlen(yytext) < 3) /* 2 quotes + 1 character */
errx(1, "String \"%s\" is invalid\n.", yytext);
yytext++; /* ignore first quote */
strcpy(yylval.s, yytext);
yylval.s[strlen(yylval.s)-1] = '\0'; /* remove end quote */
yytext++; /* ignore first quote */
strcpy(yylval.s, yytext);
yylval.s[strlen(yylval.s)-1] = '\0'; /* remove end quote */
return STRING;
}
return STRING;
}
\$[a-fA-F0-9]+ {
yytext++; /* Skip prefix */
yylval.i = strtol(yytext, NULL, 16);
return INTEGER;
}
[0-9]+ {
yylval.i = strtol(yytext, NULL, 10);
return INTEGER;
}
\$[a-fA-F0-9]+ {
yytext++; /* Skip prefix */
yylval.i = strtol(yytext, NULL, 16);
return INTEGER;
}
[0-9]+ {
yylval.i = strtol(yytext, NULL, 10);
return INTEGER;
}
(?i:ROM0) { strcpy(yylval.s, "ROM0"); return SECTION_NONBANKED; }
(?i:ROMX) { strcpy(yylval.s, "ROMX"); return SECTION_BANKED; }
(?i:VRAM) { strcpy(yylval.s, "VRAM"); return SECTION_BANKED; }
(?i:WRAM0) { strcpy(yylval.s, "WRAM0"); return SECTION_NONBANKED; }
(?i:WRAMX) { strcpy(yylval.s, "WRAMX"); return SECTION_BANKED; }
(?i:SRAM) { strcpy(yylval.s, "SRAM"); return SECTION_BANKED; }
(?i:OAM) { strcpy(yylval.s, "OAM"); return SECTION_NONBANKED; }
(?i:HRAM) { strcpy(yylval.s, "HRAM"); return SECTION_NONBANKED; }
(?i:ROM0) { strcpy(yylval.s, "ROM0"); return SECTION_NONBANKED; }
(?i:ROMX) { strcpy(yylval.s, "ROMX"); return SECTION_BANKED; }
(?i:VRAM) { strcpy(yylval.s, "VRAM"); return SECTION_BANKED; }
(?i:WRAM0) { strcpy(yylval.s, "WRAM0"); return SECTION_NONBANKED; }
(?i:WRAMX) { strcpy(yylval.s, "WRAMX"); return SECTION_BANKED; }
(?i:SRAM) { strcpy(yylval.s, "SRAM"); return SECTION_BANKED; }
(?i:OAM) { strcpy(yylval.s, "OAM"); return SECTION_NONBANKED; }
(?i:HRAM) { strcpy(yylval.s, "HRAM"); return SECTION_NONBANKED; }
(?i:ALIGN) { return COMMAND_ALIGN; }
(?i:ORG) { return COMMAND_ORG; }
(?i:ALIGN) { return COMMAND_ALIGN; }
(?i:ORG) { return COMMAND_ORG; }
"\n" { return NEWLINE; }
"\n" { return NEWLINE; }
;.* { /* Ignore comments. A dot doesn't match newline. */ }
;.* { /* Ignore comments. A dot doesn't match newline. */ }
[[:space:]] { /* Ignore whitespace. */ }
[[:space:]] { /* Ignore whitespace. */ }
. { errx(1, "Invalid character [%s]\n.", yytext); }
. { errx(1, "Invalid character [%s]\n.", yytext); }
%%

View File

@@ -61,18 +61,18 @@ SLONG
readasciiz(char **dest, FILE *f)
{
size_t r = 0;
size_t bufferLength = 16;
char *start = malloc(bufferLength);
char *s = start;
if (!s) {
err(1, NULL);
}
while (((*s++) = fgetc(f)) != 0) {
r += 1;
if (r >= bufferLength) {
bufferLength *= 2;
start = realloc(start, bufferLength);
@@ -82,7 +82,7 @@ readasciiz(char **dest, FILE *f)
s = start + r;
}
}
*dest = start;
return (r + 1);
}

View File

@@ -21,7 +21,7 @@ writehome(FILE * f, FILE * f_overlay)
mem = malloc(MaxAvail[BANK_ROM0]);
if (!mem)
return;
if (f_overlay != NULL) {
fseek(f_overlay, 0L, SEEK_SET);
fread(mem, 1, MaxAvail[BANK_ROM0], f_overlay);
@@ -99,7 +99,6 @@ Output(void)
SLONG i;
FILE *f;
FILE *f_overlay = NULL;
if ((f = fopen(tzOutname, "wb"))) {
if (tzOverlayname) {
@@ -122,13 +121,13 @@ Output(void)
MaxBankUsed = MaxOverlayBank;
}
}
writehome(f, f_overlay);
for (i = 1; i <= MaxBankUsed; i += 1)
writebank(f, f_overlay, i);
fclose(f);
if (tzOverlayname) {
fclose(f_overlay);
}

View File

@@ -44,52 +44,52 @@ static int nline = 1;
%%
lines:
/* empty */
| lines line NEWLINE
;
/* empty */
| lines line NEWLINE
;
line:
/* empty */ { nline++; }
| statement { nline++; }
;
/* empty */ { nline++; }
| statement { nline++; }
;
statement:
/* Statements to set the current section */
SECTION_NONBANKED {
script_SetCurrentSectionType($1, 0);
}
| SECTION_NONBANKED INTEGER {
errx(1, "%d:Trying to assign a bank to a non-banked section.\n", nline);
}
/* Statements to set the current section */
SECTION_NONBANKED {
script_SetCurrentSectionType($1, 0);
}
| SECTION_NONBANKED INTEGER {
errx(1, "%d:Trying to assign a bank to a non-banked section.\n", nline);
}
| SECTION_BANKED {
errx(1, "%d:Banked section without assigned bank.\n", nline);
}
| SECTION_BANKED INTEGER {
script_SetCurrentSectionType($1, $2);
}
| SECTION_BANKED {
errx(1, "%d:Banked section without assigned bank.\n", nline);
}
| SECTION_BANKED INTEGER {
script_SetCurrentSectionType($1, $2);
}
/* Commands to adjust the address inside the current section */
| COMMAND_ALIGN INTEGER {
script_SetAlignment($2);
}
| COMMAND_ALIGN {
errx(1, "%d:ALIGN keyword needs an argument.\n", nline);
}
| COMMAND_ORG INTEGER {
script_SetAddress($2);
}
| COMMAND_ORG {
errx(1, "%d:ORG keyword needs an argument.\n", nline);
}
/* Commands to adjust the address inside the current section */
| COMMAND_ALIGN INTEGER {
script_SetAlignment($2);
}
| COMMAND_ALIGN {
errx(1, "%d:ALIGN keyword needs an argument.\n", nline);
}
| COMMAND_ORG INTEGER {
script_SetAddress($2);
}
| COMMAND_ORG {
errx(1, "%d:ORG keyword needs an argument.\n", nline);
}
/* Section name */
| STRING {
script_OutputSection($1);
}
/* Section name */
| STRING {
script_OutputSection($1);
}
/* End */
;
/* End */
;
%%
@@ -100,24 +100,24 @@ extern FILE *yyin;
void yyerror(char *s)
{
errx(1, "%d:Linkerscript parse error: \"%s\"\n", nline, s);
errx(1, "%d:Linkerscript parse error: \"%s\"\n", nline, s);
}
void script_Parse(const char *path)
{
script_InitSections();
script_InitSections();
FILE *f = fopen(path, "r");
FILE *f = fopen(path, "r");
if (!f)
errx(1, "Error opening file! \"%s\"\n", path);
if (!f)
errx(1, "Error opening file! \"%s\"\n", path);
yyin = f;
yyin = f;
do {
yyparse();
} while (!feof(yyin));
do {
yyparse();
} while (!feof(yyin));
fclose(f);
fclose(f);
}