ref: 5f299bfe6c79b1805ceccf3427a0ec43d5d868d5
parent: 07cc4fb8fd95fe33954958667ebe9ce186d2d1da
author: AntonioND <[email protected]>
date: Tue Apr 4 18:09:01 EDT 2017
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 <[email protected]>
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -118,7 +118,6 @@
r<<=8;
r|=(UBYTE)(s[i]);
i++;
-
}
return( r );
}
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -438,7 +438,7 @@
size_t i;
char *s;
int argNum;
-
+
switch (c) {
case '1':
case '2':
@@ -724,7 +724,7 @@
index += length;
else
fatalerror("Illegal character escape '%c'", ch);
-
+
ch = 0;
break;
}
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -258,13 +258,13 @@
{
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);
}
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -766,7 +766,7 @@
sym_AddEqu("_NARG", 0);
p_NARGSymbol = findsymbol("_NARG", NULL);
p_NARGSymbol->Callback = Callback_NARG;
-
+
math_DefinePI();
}
--- a/src/gfx/makepng.c
+++ b/src/gfx/makepng.c
@@ -316,7 +316,7 @@
png_init_io(img, f);
png_write_info(img, png->info);
-
+
png_write_image(img, png->data);
png_write_end(img, NULL);
--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -103,7 +103,7 @@
pNewArea->nOrg = org + size;
pNewArea->nSize -= size + pArea->nSize;
return org;
-
+
} else {
err(1, NULL);
}
@@ -110,7 +110,7 @@
}
}
}
-
+
return -1;
}
@@ -125,7 +125,7 @@
if (result != -1) {
return result;
}
-
+
ppArea = &(pArea->pNext);
pArea = *ppArea;
}
@@ -140,7 +140,7 @@
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 @@
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 @@
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 @@
}
pSection = pSection->pNext;
}
-
+
return r;
}
@@ -294,7 +294,7 @@
&& 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 @@
AssignFloatingBankSections(enum eSectionType type)
{
ensureSectionTypeIsValid(type);
-
+
struct sSection *pSection;
while ((pSection = FindLargestSection(type, false))) {
@@ -347,7 +347,7 @@
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 @@
pSection->pzName, SECT_ATTRIBUTES[type].name, locality, pSection->nAlign);
}
}
- }
+ }
}
char *tzLinkerscriptName = NULL;
@@ -429,7 +429,7 @@
} else {
errx(1, "(INTERNAL) Unknown bank type!");
}
-
+
MaxAvail[i] = BankFree[i]->nSize;
BankFree[i]->pPrev = NULL;
BankFree[i]->pNext = NULL;
@@ -523,7 +523,7 @@
pSection->oAssigned = 1;
DOMAXBANK(pSection->Type, pSection->nBank);
break;
-
+
default: // Handle other sections later
break;
}
--- a/src/link/lexer.l
+++ b/src/link/lexer.l
@@ -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); }
%%
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -61,18 +61,18 @@
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 @@
s = start + r;
}
}
-
+
*dest = start;
return (r + 1);
}
--- a/src/link/output.c
+++ b/src/link/output.c
@@ -21,7 +21,7 @@
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 @@
SLONG i;
FILE *f;
FILE *f_overlay = NULL;
-
if ((f = fopen(tzOutname, "wb"))) {
if (tzOverlayname) {
@@ -122,13 +121,13 @@
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);
}
--- a/src/link/parser.y
+++ b/src/link/parser.y
@@ -44,52 +44,52 @@
%%
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 @@
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);
}