Skip to content

Commit

Permalink
Merge pull request #25 from Ruun/branch-new
Browse files Browse the repository at this point in the history
fixed some errors
  • Loading branch information
Ruun authored Jun 14, 2024
2 parents 759817a + 543489f commit 38a3c07
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 23 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/RuanScript/v17/.wsuo
Binary file not shown.
Binary file modified .vs/RuanScript/v17/Browse.VC.db
Binary file not shown.
Binary file modified .vs/RuanScript/v17/Browse.VC.db-shm
Binary file not shown.
Binary file modified .vs/RuanScript/v17/Browse.VC.db-wal
Binary file not shown.
2 changes: 1 addition & 1 deletion .vs/RuanScript/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"RelativeDocumentMoniker": "code\\Reader.c",
"ToolTip": "C:\\Mac\\Home\\Downloads\\RuanScript\\code\\Reader.c",
"RelativeToolTip": "code\\Reader.c",
"ViewState": "AQIAANMAAAAAAAAAAAAWwOkAAAAAAAAA",
"ViewState": "AQIAAO4CAAAAwMzMzMwXwPEAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|",
"WhenOpened": "2024-06-13T16:55:18.632Z",
"EditorCaption": ""
Expand Down
Binary file modified .vs/slnx.sqlite
Binary file not shown.
4 changes: 2 additions & 2 deletions code/MainReader.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# ECHO " @@ @ @@ /@/ @@@ @ @@ �
# ECHO " @@ @@@@@@@@@@@@@@@ @@ �
# ECHO " @@ @@ �
# ECHO " @@ S O F I A @@ �
# ECHO " @@ RuanScript @@ �
# ECHO " @@ @@ �
# ECHO " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ �
# ECHO " "
Expand Down Expand Up @@ -158,7 +158,7 @@ Rs_intg mainReader(Rs_intg argc, Rs_string* argv) {
************************************************************
* Buffer starting method
* Params:
* - Program: Name of the program
* - Program: RuanScript
* - Input: Filename
* - Mode: Operational mode
* - Size: Buffer capacity
Expand Down
40 changes: 20 additions & 20 deletions code/Reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@
*/

BufferPointer readerCreate(Rs_intg size, Rs_intg increment, Rs_intg mode) {
BufferPointer readerPointer;
//BufferPointer readerPointer;
/* Defensive programming: Check for invalid size or increment */
if (size < 0 || increment < 0 || mode < 0) {
return NULL;
}
/* TO_DO: Adjust the values according to parameters */
readerPointer = (BufferPointer)calloc(1, sizeof(Buffer));
BufferPointer readerPointer = (BufferPointer)calloc(1, sizeof(Buffer));
if (!readerPointer)
return NULL;
if (size != 0)
Expand All @@ -103,21 +103,21 @@ BufferPointer readerCreate(Rs_intg size, Rs_intg increment, Rs_intg mode) {
readerPointer->mode = mode;
else
readerPointer->mode = MODE_FIXED;
readerPointer->content = (Rs_string)malloc(size);

// readerPointer->content = (Rs_string)malloc(size);
readerPointer->content = (Rs_string)malloc(readerPointer->size * sizeof(Rs_char));
/* TO_DO: Defensive programming */
if (!readerPointer->content) {
free(readerPointer);
return NULL;
}
} //come back to this
/* TO_DO: Initialize the histogram */
for(int i =0; i < NCHAR; i++)
readerPointer->histogram[i] = 0;

/* TO_DO: Initialize flags */
readerPointer->flags = READER_DEFAULT_FLAG;
readerPointer->flags = READER_DEFAULT_FLAG | EMP_FLAG;;
/* TO_DO: The created flag must be signalized as EMP */
readerPointer->flags |= EMP_FLAG;
// readerPointer->flags |= EMP_FLAG;
/* NEW: Cleaning the content */
if (readerPointer->content)
readerPointer->content[0] = READER_TERMINATOR;
Expand Down Expand Up @@ -176,17 +176,18 @@ BufferPointer readerAddChar(BufferPointer const readerPointer, Rs_char ch) {
return NULL;
}
/* TO_DO: New reader allocation */
tempReader = (Rs_string)realloc(readerPointer->content, newSize);
tempReader = (Rs_string)realloc(readerPointer->content, newSize * sizeof(Rs_char));
/* TO_DO: Defensive programming */
if (!tempReader) {
return NULL;
}
/* TO_DO: Check Relocation */
readerPointer->content = tempReader;
readerPointer->size = newSize;
/* TO_DO: Add the char */
readerPointer->content[readerPointer->position.wrte++] = ch;
}
/* TO_DO: Add the char */
readerPointer->content[readerPointer->position.wrte++] = ch;

/* TO_DO: Updates histogram */
readerPointer->histogram[(int)ch]++;
return readerPointer;
Expand Down Expand Up @@ -239,7 +240,6 @@ Rs_boln readerFree(BufferPointer const readerPointer) {
/* TO_DO: Free pointers */
free(readerPointer->content);
free(readerPointer);
//readerPointer = NULL;
return TRUE;
}

Expand Down Expand Up @@ -337,7 +337,9 @@ Rs_intg readerPrint(BufferPointer const readerPointer) {
if (!readerPointer) {
return -1;
}
c = readerGetChar(readerPointer);
Rs_intg cont = 0;
Rs_char c = readerGetChar(readerPointer);
// c = readerGetChar(readerPointer);
/* TO_DO: Check flag if buffer EOB has achieved */
while (cont < readerPointer->position.wrte) {
cont++;
Expand All @@ -364,19 +366,18 @@ Rs_intg readerPrint(BufferPointer const readerPointer) {
*************************************************************
*/
Rs_intg readerLoad(BufferPointer const readerPointer, FILE* const fileDescriptor) {
Rs_intg size = 0;
Rs_char c;
/* TO_DO: Defensive programming */
if (!readerPointer || !fileDescriptor) {
return READER_ERROR; //-1
}
c = (Rs_char)fgetc(fileDescriptor);
Rs_intg size = 0;
Rs_char c = (Rs_char)fgetc(fileDescriptor);
while (!feof(fileDescriptor)) {
if (!readerAddChar(readerPointer, c)) {
ungetc(c, fileDescriptor);
return READER_ERROR;
}
c = (char)fgetc(fileDescriptor);
c = (Rs_char)fgetc(fileDescriptor);
size++;
}
/* TO_DO: Defensive programming */
Expand Down Expand Up @@ -681,8 +682,6 @@ Rs_byte readerGetFlags(BufferPointer const readerPointer) {
return readerPointer->flags;
}



/*
***********************************************************
* Function name: readerPrintStat
Expand Down Expand Up @@ -735,7 +734,7 @@ Rs_intg readerNumErrors(BufferPointer const readerPointer) {
}
/* TO_DO: Returns the number of errors */
//return readerPointer->errors;
return NULL;
return 0;
}

/*
Expand All @@ -759,5 +758,6 @@ Rs_void readerChecksum(BufferPointer readerPointer) {
return;
}
/* TO_DO: Adjust the checksum to flags */
readerPointer->flags; // |= CHECKSUM_FLAG;
//readerPointer->flags; |= CHECKSUM_FLAG;
readerPointer->flags;
}
Binary file modified code/out/build/x64-Debug/.ninja_deps
Binary file not shown.
8 changes: 8 additions & 0 deletions code/out/build/x64-Debug/.ninja_log
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
14 379 7400256337424523 build.ninja 10add4a6052b72f8
153 520 7400044609840306 Compiler.exe 60774a4753864fbb
14 41 0 clean 3807ae1e948da024
20 476 7400257133865449 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
479 991 7400257137340089 Compiler.exe 60774a4753864fbb
19 157 7400261844559788 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
161 535 7400261847623436 Compiler.exe 60774a4753864fbb
28 190 7400263491772083 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
193 610 7400263495124599 Compiler.exe 60774a4753864fbb
19 442 7400281131362751 CMakeFiles/Compiler.dir/Reader.c.obj a4c8113ae2b0e945
446 803 7400281134183904 Compiler.exe 60774a4753864fbb
Binary file modified code/out/build/x64-Debug/CMakeFiles/Compiler.dir/Reader.c.obj
Binary file not shown.
Binary file modified code/out/build/x64-Debug/CMakeFiles/Compiler.dir/vc140.pdb
Binary file not shown.
Binary file modified code/out/build/x64-Debug/Compiler.exe
Binary file not shown.
Binary file modified code/out/build/x64-Debug/Compiler.ilk
Binary file not shown.
Binary file modified code/out/build/x64-Debug/Compiler.pdb
Binary file not shown.

0 comments on commit 38a3c07

Please sign in to comment.