diff options
| -rw-r--r-- | docs/csview_api.md | 20 | ||||
| -rw-r--r-- | examples/regex2.c | 2 | ||||
| -rw-r--r-- | examples/regex_match.c | 2 | ||||
| -rw-r--r-- | examples/splitstr.c | 2 | ||||
| -rw-r--r-- | examples/sso_substr.c | 2 | ||||
| -rw-r--r-- | examples/sview_split.c | 2 | ||||
| -rw-r--r-- | examples/utf8replace_c.c | 2 | ||||
| -rw-r--r-- | include/stc/csview.h | 2 | ||||
| -rw-r--r-- | include/stc/utf8.h | 2 |
9 files changed, 18 insertions, 18 deletions
diff --git a/docs/csview_api.md b/docs/csview_api.md index 0a071278..cb524590 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -111,12 +111,12 @@ uint64_t csview_hash(const csview* x); ## Constants and macros -| Name | Value | Usage | -|:---------------|:---------------------|:----------------------------------------------| -| `csview_null` | same as `c_sv("")` | `sview = csview_null;` | -| `csview_npos` | same as `cstr_npos` | | -| `c_PRIsv` | printf format csview | | -| `c_ARGsv(sv)` | printf argument | `printf("view: " c_PRIsv "\n", c_ARGsv(sv));` | +| Name | Value | Usage | +|:---------------|:---------------------|:---------------------------------------------| +| `csview_null` | same as `c_sv("")` | `sview = csview_null;` | +| `csview_npos` | same as `cstr_npos` | | +| `c_PRIsv` | printf format | | +| `c_ARGsv(sv)` | printf argument | `printf("sv: %" c_PRIsv "\n", c_ARGsv(sv));` | ## Example ```c @@ -132,8 +132,8 @@ int main () size_t pos = cstr_find(str1, "live"); // position of "live" in str1 csview sv2 = cstr_substr(&str1, pos, 4); // get "live" csview sv3 = cstr_slice(&str1, -8, -1); // get "details" - printf(c_PRIsv c_PRIsv c_PRIsv "\n", c_ARGsv(sv1), c_ARGsv(sv2), c_ARGsv(sv3)); - + printf("%" c_PRIsv "%" c_PRIsv "%" c_PRIsv "\n", + c_ARGsv(sv1), c_ARGsv(sv2), c_ARGsv(sv3)); cstr s1 = cstr_new("Apples are red"); cstr s2 = cstr_from_sv(cstr_substr(&s1, -3, 3)); // "red" cstr s3 = cstr_from_sv(cstr_substr(&s1, 0, 6)); // "Apples" @@ -162,7 +162,7 @@ int main() csview sv = csview_from_s(&s1); c_foreach (i, csview, sv) - printf(c_PRIsv ",", c_ARGsv(i.codep)); + printf("%" c_PRIsv ",", c_ARGsv(i.codep)); } } ``` @@ -184,7 +184,7 @@ void print_split(csview str, csview sep) while (pos != str.size) { csview tok = csview_token(str, sep, &pos); // print non-null-terminated csview - printf("[" c_PRIsv "]\n", c_ARGsv(tok)); + printf("[%" c_PRIsv "]\n", c_ARGsv(tok)); } } diff --git a/examples/regex2.c b/examples/regex2.c index 09eaecd3..750638c4 100644 --- a/examples/regex2.c +++ b/examples/regex2.c @@ -24,7 +24,7 @@ int main() { c_forrange (j, cregex_captures(re)) { - printf(" submatch %" PRIuMAX ": " c_PRIsv "\n", j, c_ARGsv(m[j])); + printf(" submatch %" PRIuMAX ": %" c_PRIsv "\n", j, c_ARGsv(m[j])); } puts(""); } diff --git a/examples/regex_match.c b/examples/regex_match.c index 7f02f892..3747b319 100644 --- a/examples/regex_match.c +++ b/examples/regex_match.c @@ -26,7 +26,7 @@ int main() } while (cregex_find(&re, s, 10, m, creg_next) > 0) { - printf(c_PRIsv " ; ", c_ARGsv(m[0])); + printf("%" c_PRIsv " ; ", c_ARGsv(m[0])); } puts(""); } diff --git a/examples/splitstr.c b/examples/splitstr.c index 427c61c8..d0aefa85 100644 --- a/examples/splitstr.c +++ b/examples/splitstr.c @@ -8,7 +8,7 @@ void print_split(csview str, csview sep) while (pos != str.size) {
csview tok = csview_token(str, sep, &pos);
// print non-null-terminated csview
- printf("[" c_PRIsv "]\n", c_ARGsv(tok));
+ printf("[%" c_PRIsv "]\n", c_ARGsv(tok));
}
}
diff --git a/examples/sso_substr.c b/examples/sso_substr.c index f8382f16..8e21b7fe 100644 --- a/examples/sso_substr.c +++ b/examples/sso_substr.c @@ -8,7 +8,7 @@ int main () size_t pos = cstr_find(str, "live"); // position of "live" csview sv2 = cstr_substr(&str, pos, 4); // "live" csview sv3 = cstr_slice(&str, -8, -1); // "details" - printf(c_PRIsv ", " c_PRIsv ", " c_PRIsv "\n", + printf("%" c_PRIsv ", %" c_PRIsv ", %" c_PRIsv "\n", c_ARGsv(sv1), c_ARGsv(sv2), c_ARGsv(sv3)); cstr_assign(&str, "apples are green or red"); diff --git a/examples/sview_split.c b/examples/sview_split.c index 3e3c584b..3594a599 100644 --- a/examples/sview_split.c +++ b/examples/sview_split.c @@ -10,7 +10,7 @@ int main() const csview month = csview_token(date, c_sv("/"), &pos);
const csview day = csview_token(date, c_sv("/"), &pos);
- printf(c_PRIsv ", " c_PRIsv ", " c_PRIsv "\n",
+ printf("%" c_PRIsv ", %" c_PRIsv ", %" c_PRIsv "\n",
c_ARGsv(year), c_ARGsv(month), c_ARGsv(day));
c_auto (cstr, y, m, d) {
diff --git a/examples/utf8replace_c.c b/examples/utf8replace_c.c index 5ca51d22..6b3fcebe 100644 --- a/examples/utf8replace_c.c +++ b/examples/utf8replace_c.c @@ -16,6 +16,6 @@ int main() { csview sv = csview_from_s(&hello); c_foreach (c, csview, sv) - printf(c_PRIsv ",", c_ARGsv(c.codep)); + printf("%" c_PRIsv ",", c_ARGsv(c.codep)); } } diff --git a/include/stc/csview.h b/include/stc/csview.h index 4cbe1ee2..5bc25215 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -30,7 +30,7 @@ #define csview_null c_sv("")
#define csview_new(literal) c_sv(literal)
#define csview_npos (SIZE_MAX >> 1)
-#define c_PRIsv "%.*s"
+#define c_PRIsv ".*s"
#define c_ARGsv(sv) (int)(sv).size, (sv).str
STC_API csview csview_substr(csview sv, intptr_t pos, size_t n);
diff --git a/include/stc/utf8.h b/include/stc/utf8.h index 9a1493b6..50fbefc7 100644 --- a/include/stc/utf8.h +++ b/include/stc/utf8.h @@ -15,7 +15,7 @@ int main() csview sv = csview_from_s(s1);
c_foreach (i, csview, sv)
- printf(c_PRIsv ",", c_ARGsv(i.codep));
+ printf("%" c_PRIsv ",", c_ARGsv(i.codep));
}
}
// Output:
|
