aboutsummaryrefslogtreecommitdiffstats
path: root/core/format.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-03-14 20:37:19 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-04-09 11:29:43 -0700
commit5afe1a53d8c662f26de048c8d954be323b96026b (patch)
tree0a45d68019e94160f2d402c34334a73c1bafcd5f /core/format.h
parent36249f27802540e541bae132a7b644b4a8a2f148 (diff)
downloadsubsurface-5afe1a53d8c662f26de048c8d954be323b96026b.tar.gz
Cleanup: Move *_loc formatting functions into new format.cpp file
qthelper.cpp is already quite voluminous. Move the recently introduced localized versions of (v)snprintf() and put_format() into their own translation unit. Moreover, adopt C-style semantics for asprintf_loc(). This function will be used to remove fixed-size buffers in core/plannernotes.c. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/format.h')
-rw-r--r--core/format.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/format.h b/core/format.h
new file mode 100644
index 000000000..0498fe2be
--- /dev/null
+++ b/core/format.h
@@ -0,0 +1,29 @@
+#ifndef FORMAT_H
+#define FORMAT_H
+
+#ifdef __GNUC__
+#define __printf(x, y) __attribute__((__format__(__printf__, x, y)))
+#else
+#define __printf(x, y)
+#endif
+
+#ifdef __cplusplus
+#include <QString>
+__printf(1, 2) QString qasprintf_loc(const char *cformat, ...);
+__printf(1, 0) QString vqasprintf_loc(const char *cformat, va_list ap);
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+__printf(3, 4) int snprintf_loc(char *dst, size_t size, const char *cformat, ...);
+__printf(3, 0) int vsnprintf_loc(char *dst, size_t size, const char *cformat, va_list ap);
+__printf(2, 3) int asprintf_loc(char **dst, const char *cformat, ...);
+__printf(2, 0) int vasprintf_loc(char **dst, const char *cformat, va_list ap);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif