# HG changeset patch # User Mike Becker # Date 1744915663 -7200 # Node ID 0597f1f20ea9385eb2783974aa57f4e513b0d911 # Parent 0811fb9a8dbab3f1764b6a313e8f5f6fea20bc63 use new string formatting macros in documentation diff -r 0811fb9a8dba -r 0597f1f20ea9 docs/Writerside/topics/buffer.h.md --- 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 ); } diff -r 0811fb9a8dba -r 0597f1f20ea9 docs/Writerside/topics/map.h.md --- 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; diff -r 0811fb9a8dba -r 0597f1f20ea9 docs/Writerside/topics/mempool.h.md --- 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) ); } diff -r 0811fb9a8dba -r 0597f1f20ea9 docs/Writerside/topics/properties.h.md --- 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