summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2023-11-19 16:57:23 +0100
committerOskar <[email protected]>2023-11-19 16:57:23 +0100
commitc79c2b6b2aa7b8d259044bc9f90c0eee16a9bc0a (patch)
tree3d7c2cc8b93e8583e1faea14b510166ec52d1fe6
parent6a6a4adf561d4a3a35df2fc5517dc4d253006809 (diff)
may or may not have fixed a bug with GET_LINE(), i did some confirmation testing after i fixed the bug and it seems to work now but i may just be coping. Ill have to do additional tests to confirm that nothing else broke or if i might have missed anything. Its entirely possible i may have missed something
-rw-r--r--Makefile2
-rw-r--r--editmode.c2
-rw-r--r--functions.c6
-rw-r--r--test/testgetline.c2
4 files changed, 6 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 6746525..07442d1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
all: 7ed
7ed:
- gcc -Wfatal-errors -Wall -Werror -Wextra -g 7ed.c functions.c startmode.c editmode.c -o 7ed
+ gcc -Wfatal-errors -Wall -Werror -Wextra -g -fsanitize=address 7ed.c functions.c startmode.c editmode.c -o 7ed
cp 7ed test
mv test/7ed test/7ed-test
clean:
diff --git a/editmode.c b/editmode.c
index b010383..97afbe8 100644
--- a/editmode.c
+++ b/editmode.c
@@ -74,7 +74,7 @@ return 0;
}
-int NEW_LINE(char filename[]) {
+int NEW_LINE(char filename[]) { // testing this now with -fsanitize=address !! Please work!
long new_line_pos;
long new_line_pos_temp;
diff --git a/functions.c b/functions.c
index e5837b7..edba69b 100644
--- a/functions.c
+++ b/functions.c
@@ -156,7 +156,7 @@ int GET_LINE(char filename[], long focus, char **line, size_t *start) { // Makin
c1_count++;
}
} // checks how many characters are in the first line
- char c1buf[c1_count];
+ char c1buf[c1_count+1];
fseek(file, 0, SEEK_SET);
int i = 0;
@@ -207,7 +207,7 @@ int GET_LINE(char filename[], long focus, char **line, size_t *start) { // Makin
}
fseek(file, save_i+1, SEEK_SET);
- char c2buf[c2_count];
+ char c2buf[c2_count+1];
int i = 0;
for (; i < c2_count ; i++) {
c2buf[i] = fgetc(file);
@@ -223,4 +223,4 @@ int GET_LINE(char filename[], long focus, char **line, size_t *start) { // Makin
fclose(file);
return 0;
-} \ No newline at end of file
+}
diff --git a/test/testgetline.c b/test/testgetline.c
index dfbab4b..d186439 100644
--- a/test/testgetline.c
+++ b/test/testgetline.c
@@ -41,4 +41,4 @@ while ((opt = getopt(argc, argv, "i:")) != -1) {
return EXIT_SUCCESS;
// TEST!
-} // LINE 44 YOYOYOYOOYOYOOYOYOYOYOYYO
+// LINE 44 YOOOOOOOOOOOOOOO!!