Merge branch 'assembler-s' into 'assembler-e'
Assembler s See merge request lab2324_summer/armv8_43!14
This commit is contained in:
commit
5221189304
@ -35,11 +35,13 @@ int countLines(char *filename) {
|
||||
|
||||
int count = 0;
|
||||
char c;
|
||||
char prevC = '\n';
|
||||
|
||||
while ((c = fgetc(file)) != EOF) {
|
||||
if (c == '\n') {
|
||||
if (c == '\n' && prevC != '\n') {
|
||||
count++;
|
||||
}
|
||||
prevC = c;
|
||||
}
|
||||
|
||||
return count;
|
||||
@ -71,6 +73,11 @@ char **readAssemblyFile(char filename[], int lineCount) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (*buffer == '\n') {
|
||||
// Skip empty lines.
|
||||
continue;
|
||||
}
|
||||
|
||||
lines[currentLine] = malloc(strlen(buffer) + 1);
|
||||
if (lines[currentLine] == NULL) {
|
||||
fprintf(stderr, "Error: Could not allocate memory to store the assembly line");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user