From 65b9c17942f3b85ba956becf26d3fe9a8a538ed0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonathan=20Sch=C3=B6bel?= <jonathan@xn--schbel-yxa.info>
Date: Fri, 6 Jan 2023 12:56:26 +0100
Subject: [PATCH] added splint annotations (text)

---
 sefht.geany          |  6 ++--
 src/lib/sefht/text.c | 44 ++++++++++++++++++++++++++--
 src/lib/sefht/text.h | 68 ++++++++++++++++++++++++++++++++++----------
 3 files changed, 97 insertions(+), 21 deletions(-)

diff --git a/sefht.geany b/sefht.geany
index 3bca782..56ba616 100644
--- a/sefht.geany
+++ b/sefht.geany
@@ -28,7 +28,7 @@ long_line_behaviour=1
 long_line_column=72
 
 [files]
-current_page=12
+current_page=14
 FILE_NAME_0=923;Sh;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fconfigure.ac;0;8
 FILE_NAME_1=73;Make;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2FMakefile.am;0;8
 FILE_NAME_2=1143;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Fmain.c;0;8
@@ -43,8 +43,8 @@ FILE_NAME_10=1923;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fp
 FILE_NAME_11=1701;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ffragment_class.c;0;8
 FILE_NAME_12=8225;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fnode_fragment.c;0;8
 FILE_NAME_13=1892;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fnode_fragment.h;0;8
-FILE_NAME_14=1384;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext.c;0;8
-FILE_NAME_15=2692;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext.h;0;8
+FILE_NAME_14=25820;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext.c;0;8
+FILE_NAME_15=3637;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Ftext.h;0;8
 FILE_NAME_16=1212;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator.c;0;8
 FILE_NAME_17=1260;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator.h;0;8
 FILE_NAME_18=1466;C;0;EUTF-8;1;1;0;%2Fhome%2Fjonathan%2FDokumente%2Fprojekte%2Fprgm%2Finternet%2Fweb%2FSeFHT%2Fsrc%2Flib%2Fsefht%2Fvalidator_tag.c;0;8
diff --git a/src/lib/sefht/text.c b/src/lib/sefht/text.c
index 9ffda54..b071c50 100644
--- a/src/lib/sefht/text.c
+++ b/src/lib/sefht/text.c
@@ -44,7 +44,6 @@
 #error "CHUNK_SIZE can't be 0."
 #endif /* CHUNK_SIZE == 0 */
 
-/*@abstract@*/
 struct text_segment;
 struct text_segment
 {
@@ -54,7 +53,6 @@ struct text_segment
 	/*@relnull@*/ struct text_segment * next;
 };
 
-/*@abstract@*/
 struct SH_Text
 {
 	/*@notnull@*/ struct text_segment * data;
@@ -65,6 +63,9 @@ struct SH_Text
 /*@only@*/
 struct SH_Text *
 SH_Text_new (/*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	struct SH_Text * text;
 	text = malloc (sizeof (struct SH_Text));
@@ -104,7 +105,7 @@ SH_Text_new (/*@null@*/ /*@out@*/ struct SH_Status * status)
 	}
 
 	text->data->text[0] = (char) 0;
-	text->data->size = CHUNK_SIZE;
+	text->data->size = (size_t) CHUNK_SIZE;
 	text->data->next = NULL;
 
 	set_success (status);
@@ -117,6 +118,9 @@ SH_Text_new (/*@null@*/ /*@out@*/ struct SH_Status * status)
 struct SH_Text *
 SH_Text_new_from_string (const char * string,
                          /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	struct SH_Text * text;
 	text = malloc (sizeof (struct SH_Text));
@@ -177,6 +181,8 @@ SH_Text_new_from_string (const char * string,
 
 void
 SH_Text_free (/*@only@*/ struct SH_Text * text)
+	/*@modifies text@*/
+	/*@releases text@*/
 {
 	struct text_segment * next;
 
@@ -198,6 +204,9 @@ SH_Text_free (/*@only@*/ struct SH_Text * text)
 struct SH_Text *
 SH_Text_copy (const struct SH_Text * text,
               /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	const struct text_segment * start;
 	const struct text_segment * end;
@@ -294,6 +303,8 @@ SH_Text_copy (const struct SH_Text * text,
 			else
 			{
 				end = end->next;
+
+				/*@innerbreak@*/
 				break;
 			}
 		}
@@ -390,6 +401,9 @@ SH_Text_copy (const struct SH_Text * text,
 size_t
 SH_Text_get_length (const struct SH_Text * text,
                     /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	size_t length;
 	const struct text_segment * seg;
@@ -421,6 +435,9 @@ char *
 SH_Text_get_char (const struct SH_Text * text,
                   size_t index,
                   /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	char * character;
 	const struct text_segment * seg;
@@ -463,6 +480,10 @@ SH_Text_get_string (const struct SH_Text * text,
                     size_t index, size_t offset,
                     /*@null@*/ /*@out@*/ size_t * length,
                     /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@modifies length@*/
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	size_t len;
 	char * string;
@@ -645,6 +666,10 @@ SH_Text_get_range (const struct SH_Text * text,
                    size_t start, size_t end,
                    /*@null@*/ /*@out@*/ size_t * length,
                    /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@modifies length@*/
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	size_t len;
 	char * string;
@@ -836,6 +861,10 @@ SH_Text_get_range (const struct SH_Text * text,
 bool
 SH_Text_append_string (struct SH_Text * text, const char * string,
                        /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@modifies text->data@*/
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	size_t length;
 	size_t size;
@@ -962,6 +991,10 @@ bool
 SH_Text_append_text (struct SH_Text * text,
                      const struct SH_Text * text2,
                      /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@modifies text->data@*/
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/
 {
 	struct SH_Text * copy;
 	struct text_segment * seg;
@@ -987,6 +1020,9 @@ SH_Text_append_text (struct SH_Text * text,
 void
 SH_Text_join (struct SH_Text * text,
               /*@only@*/ struct SH_Text * text2)
+	/*@modifies text->data@*/
+	/*@modifies text2@*/
+	/*@releases text2@*/
 {
 	struct text_segment * seg;
 
@@ -1004,6 +1040,8 @@ SH_Text_join (struct SH_Text * text,
 
 void
 SH_Text_print (const struct SH_Text * text)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
 {
 	const struct text_segment * seg;
 
diff --git a/src/lib/sefht/text.h b/src/lib/sefht/text.h
index 63775fe..7b90514 100644
--- a/src/lib/sefht/text.h
+++ b/src/lib/sefht/text.h
@@ -40,33 +40,50 @@ typedef /*@abstract@*/ struct SH_Text SH_Text;
 /*@null@*/
 /*@only@*/
 SH_Text *
-SH_Text_new (/*@null@*/ /*@out@*/ struct SH_Status * status);
+SH_Text_new (/*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 /*@null@*/
 /*@only@*/
 SH_Text *
 SH_Text_new_from_string (const char * string,
-                         /*@null@*/ /*@out@*/ struct SH_Status * status);
+                         /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 void
-SH_Text_free (/*@only@*/ SH_Text * text);
+SH_Text_free (/*@only@*/ SH_Text * text)
+	/*@modifies text@*/
+	/*@releases text@*/;
 
 /*@null@*/
 /*@only@*/
 SH_Text *
 SH_Text_copy (const SH_Text * text,
-              /*@null@*/ /*@out@*/ struct SH_Status * status);
+              /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 size_t
-SH_Text_get_length (const SH_Text * text,
-                    /*@null@*/ /*@out@*/ struct SH_Status * status);
+SH_Text_get_length (const struct SH_Text * text,
+                    /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 /*@null@*/
 /*@only@*/
 char *
 SH_Text_get_char (const SH_Text * text,
                   size_t index,
-                  /*@null@*/ /*@out@*/ struct SH_Status * status);
+                  /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 /*@null@*/
 /*@only@*/
@@ -74,7 +91,11 @@ char *
 SH_Text_get_string (const SH_Text * text,
                     size_t index, size_t offset,
                     /*@null@*/ /*@out@*/ size_t * length,
-                    /*@null@*/ /*@out@*/ struct SH_Status * status);
+                    /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@modifies length@*/
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 /*@null@*/
 /*@only@*/
@@ -82,22 +103,39 @@ char *
 SH_Text_get_range (const SH_Text * text,
                    size_t start, size_t end,
                    /*@null@*/ /*@out@*/ size_t * length,
-                   /*@null@*/ /*@out@*/ struct SH_Status * status);
+                   /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@modifies length@*/
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 bool
-SH_Text_append_string (SH_Text * text,
-                       const char * string,
-                       /*@null@*/ /*@out@*/ struct SH_Status * status);
+SH_Text_append_string (SH_Text * text, const char * string,
+                       /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@modifies text@*/
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 bool
 SH_Text_append_text (SH_Text * text,
                      const SH_Text * text2,
-                     /*@null@*/ /*@out@*/ struct SH_Status * status);
+                     /*@null@*/ /*@out@*/ struct SH_Status * status)
+	/*@modifies text@*/
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/
+	/*@modifies status@*/;
 
 void
-SH_Text_join (SH_Text * text, /*@only@*/ SH_Text * text2);
+SH_Text_join (SH_Text * text,
+              /*@only@*/ SH_Text * text2)
+	/*@modifies text@*/
+	/*@modifies text2@*/
+	/*@releases text2@*/;
 
 void
-SH_Text_print (const SH_Text * text);
+SH_Text_print (const SH_Text * text)
+	/*@globals fileSystem@*/
+	/*@modifies fileSystem@*/;
 
 #endif /* __TEXT_H__ */
-- 
GitLab