use new string formatting macros in documentation

Thu, 17 Apr 2025 20:47:43 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 17 Apr 2025 20:47:43 +0200
changeset 1298
0597f1f20ea9
parent 1297
0811fb9a8dba
child 1299
5dfce68057ce

use new string formatting macros in documentation

docs/Writerside/topics/buffer.h.md file | annotate | diff | comparison | revisions
docs/Writerside/topics/map.h.md file | annotate | diff | comparison | revisions
docs/Writerside/topics/mempool.h.md file | annotate | diff | comparison | revisions
docs/Writerside/topics/properties.h.md file | annotate | diff | comparison | revisions
--- a/docs/Writerside/topics/buffer.h.md	Wed Apr 16 20:35:34 2025 +0200
+++ b/docs/Writerside/topics/buffer.h.md	Thu Apr 17 20:47:43 2025 +0200
@@ -47,8 +47,8 @@
 	CxMapIterator iter = cxMapIterator(header);
 	cx_foreach(CxMapEntry*, entry, iter) {
 		cxstring name = cx_strn(entry->key->data, entry->key->len);
-		cx_bprintf(&buf, "%.*s: %s\r\n",
-			(int) name.length, name.ptr, entry->value
+		cx_bprintf(&buf, "%" CX_PRIstr ": %s\r\n",
+			CX_SFMT(name), entry->value
 		);
 	}
 	
--- a/docs/Writerside/topics/map.h.md	Wed Apr 16 20:35:34 2025 +0200
+++ b/docs/Writerside/topics/map.h.md	Thu Apr 17 20:47:43 2025 +0200
@@ -67,7 +67,7 @@
     cx_foreach(CxMapEntry *, entry, iter) {
         cxstring name = cx_strn(entry->key->data, entry->key->len);
         const char *phone = entry->value;
-        printf("%.*s: %s\n", (int) name.length, name.ptr, phone);
+        printf("%" CX_PRIstr ": %s\n", CX_SFMT(name), phone);
     }
 
     cxMapFree(contacts);
@@ -82,7 +82,7 @@
 Then the example shows retrieval, updating, and removal of information.
 The last part shows how to iterate over the pairs of the map and how to recover the string from the key.
 
-In real world situations, however, it is quite unlikely that you will use a map to store string literals.
+In real-world situations, however, it is quite unlikely that you will use a map to store string literals.
 The next example shows a more realistic program, where it is necessary to store strings based on user input.
 
 ```C
@@ -142,8 +142,8 @@
                     if (phone == NULL) {
                         puts("No record.");
                     } else {
-                        printf("Result: %.*s\n",
-                            (int) phone->length, phone->ptr);
+                        printf("Result: %" CX_PRIstr "\n",
+                                CX_SFMT(*phone));
                     }
                 }
             } else if (input[0] == '3') {
@@ -167,9 +167,8 @@
                                             entry->key->len);
                     // ... except that here we get cxmutstr*
                     cxmutstr *phone = entry->value;
-                    printf("%.*s: %.*s\n",
-                        (int) name.length, name.ptr,
-                        (int) phone->length, phone->ptr);
+                    printf("%" CX_PRIstr ": %" CX_PRIstr "\n",
+                        CX_SFMT(name), CX_SFMT(*phone));
                 }
             } else if (input[0] == '0') {
                 running = false;
--- a/docs/Writerside/topics/mempool.h.md	Wed Apr 16 20:35:34 2025 +0200
+++ b/docs/Writerside/topics/mempool.h.md	Thu Apr 17 20:47:43 2025 +0200
@@ -155,12 +155,12 @@
     // iterate through the list and output the data
     CxIterator iter = cxListIterator(datalist);
     cx_foreach(CSVData*, data, iter) {
-        printf("Column A: %.*s | "
-               "Column B: %.*s | "
-               "Column C: %.*s\n",
-               (int)data->column_a.length, data->column_a.ptr,
-               (int)data->column_b.length, data->column_b.ptr,
-               (int)data->column_c.length, data->column_c.ptr
+        printf("Column A: %" CX_PRIstr " | "
+               "Column B: %" CX_PRIstr " | "
+               "Column C: %" CX_PRIstr "\n",
+               CX_SFMT(data->column_a),
+               CX_SFMT(data->column_b),
+               CX_SFMT(data->column_c)
         );
     }
 
--- a/docs/Writerside/topics/properties.h.md	Wed Apr 16 20:35:34 2025 +0200
+++ b/docs/Writerside/topics/properties.h.md	Thu Apr 17 20:47:43 2025 +0200
@@ -307,8 +307,8 @@
     cx_foreach(CxMapEntry *, entry, iter) {
         cxstring k = cx_strn(entry->key->data, entry->key->len);
         cxmutstr *v = entry->value;
-        printf("%.*s = %.*s\n",
-            (int) k.length, k.ptr, (int) v->length, v->ptr);
+        printf("%" CX_PRIstr " = %" CX_PRIstr "\n",
+            CX_SFMT(k), CX_SFMT(*v));
     }
 
     // freeing the map also frees the strings

mercurial