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<<=8;
r|=(UBYTE)(s[i]); r|=(UBYTE)(s[i]);
i++; i++;
} }
return( r ); return( r );
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,48 +28,48 @@
%% %%
\"([^\\\"]|\\.)*\" { \"([^\\\"]|\\.)*\" {
if (strlen(yytext) > sizeof(yylval.s) - 1) if (strlen(yytext) > sizeof(yylval.s) - 1)
errx(1, "String is too long: \"%s\"\n.", yytext); errx(1, "String is too long: \"%s\"\n.", yytext);
if (strlen(yytext) < 3) /* 2 quotes + 1 character */ if (strlen(yytext) < 3) /* 2 quotes + 1 character */
errx(1, "String \"%s\" is invalid\n.", yytext); errx(1, "String \"%s\" is invalid\n.", yytext);
yytext++; /* ignore first quote */ yytext++; /* ignore first quote */
strcpy(yylval.s, yytext); strcpy(yylval.s, yytext);
yylval.s[strlen(yylval.s)-1] = '\0'; /* remove end quote */ yylval.s[strlen(yylval.s)-1] = '\0'; /* remove end quote */
return STRING; return STRING;
} }
\$[a-fA-F0-9]+ { \$[a-fA-F0-9]+ {
yytext++; /* Skip prefix */ yytext++; /* Skip prefix */
yylval.i = strtol(yytext, NULL, 16); yylval.i = strtol(yytext, NULL, 16);
return INTEGER; return INTEGER;
} }
[0-9]+ { [0-9]+ {
yylval.i = strtol(yytext, NULL, 10); yylval.i = strtol(yytext, NULL, 10);
return INTEGER; return INTEGER;
} }
(?i:ROM0) { strcpy(yylval.s, "ROM0"); return SECTION_NONBANKED; } (?i:ROM0) { strcpy(yylval.s, "ROM0"); return SECTION_NONBANKED; }
(?i:ROMX) { strcpy(yylval.s, "ROMX"); return SECTION_BANKED; } (?i:ROMX) { strcpy(yylval.s, "ROMX"); return SECTION_BANKED; }
(?i:VRAM) { strcpy(yylval.s, "VRAM"); return SECTION_BANKED; } (?i:VRAM) { strcpy(yylval.s, "VRAM"); return SECTION_BANKED; }
(?i:WRAM0) { strcpy(yylval.s, "WRAM0"); return SECTION_NONBANKED; } (?i:WRAM0) { strcpy(yylval.s, "WRAM0"); return SECTION_NONBANKED; }
(?i:WRAMX) { strcpy(yylval.s, "WRAMX"); return SECTION_BANKED; } (?i:WRAMX) { strcpy(yylval.s, "WRAMX"); return SECTION_BANKED; }
(?i:SRAM) { strcpy(yylval.s, "SRAM"); return SECTION_BANKED; } (?i:SRAM) { strcpy(yylval.s, "SRAM"); return SECTION_BANKED; }
(?i:OAM) { strcpy(yylval.s, "OAM"); return SECTION_NONBANKED; } (?i:OAM) { strcpy(yylval.s, "OAM"); return SECTION_NONBANKED; }
(?i:HRAM) { strcpy(yylval.s, "HRAM"); return SECTION_NONBANKED; } (?i:HRAM) { strcpy(yylval.s, "HRAM"); return SECTION_NONBANKED; }
(?i:ALIGN) { return COMMAND_ALIGN; } (?i:ALIGN) { return COMMAND_ALIGN; }
(?i:ORG) { return COMMAND_ORG; } (?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) readasciiz(char **dest, FILE *f)
{ {
size_t r = 0; size_t r = 0;
size_t bufferLength = 16; size_t bufferLength = 16;
char *start = malloc(bufferLength); char *start = malloc(bufferLength);
char *s = start; char *s = start;
if (!s) { if (!s) {
err(1, NULL); err(1, NULL);
} }
while (((*s++) = fgetc(f)) != 0) { while (((*s++) = fgetc(f)) != 0) {
r += 1; r += 1;
if (r >= bufferLength) { if (r >= bufferLength) {
bufferLength *= 2; bufferLength *= 2;
start = realloc(start, bufferLength); start = realloc(start, bufferLength);
@@ -82,7 +82,7 @@ readasciiz(char **dest, FILE *f)
s = start + r; s = start + r;
} }
} }
*dest = start; *dest = start;
return (r + 1); return (r + 1);
} }

View File

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

View File

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