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

@@ -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

@@ -100,7 +100,6 @@ Output(void)
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) {
f_overlay = fopen(tzOverlayname, "rb"); f_overlay = fopen(tzOverlayname, "rb");

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);
} }