diff options
author | Alexander Smirnov <alex@ydb.tech> | 2025-05-14 00:51:55 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2025-05-14 00:51:55 +0000 |
commit | b2d03716ee053cd32dccb8dd189d0b4bc3540d90 (patch) | |
tree | d329b3f92d5f80b8a76cac17d9e30bd1c8dc4b06 /contrib/python/matplotlib/py3/extern/ttconv/ttutil.cpp | |
parent | 645c59acc8ced6d89eb8559e26a7405d42ae9fb4 (diff) | |
parent | 0bf9db6399352012396e7791bcfd762e944b33c2 (diff) | |
download | ydb-b2d03716ee053cd32dccb8dd189d0b4bc3540d90.tar.gz |
Merge branch 'rightlib' into merge-libs-250514-0050
Diffstat (limited to 'contrib/python/matplotlib/py3/extern/ttconv/ttutil.cpp')
-rw-r--r-- | contrib/python/matplotlib/py3/extern/ttconv/ttutil.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/contrib/python/matplotlib/py3/extern/ttconv/ttutil.cpp b/contrib/python/matplotlib/py3/extern/ttconv/ttutil.cpp new file mode 100644 index 00000000000..6028e1d45d4 --- /dev/null +++ b/contrib/python/matplotlib/py3/extern/ttconv/ttutil.cpp @@ -0,0 +1,71 @@ +/* -*- mode: c++; c-basic-offset: 4 -*- */ + +/* + * Modified for use within matplotlib + * 5 July 2007 + * Michael Droettboom + */ + +/* Very simple interface to the ppr TT routines */ +/* (c) Frank Siegert 1996 */ + +#include <cstdio> +#include <cstdarg> +#include <cstdlib> +#include "pprdrv.h" + +#define PRINTF_BUFFER_SIZE 512 +void TTStreamWriter::printf(const char* format, ...) +{ + va_list arg_list; + va_start(arg_list, format); + char buffer[PRINTF_BUFFER_SIZE]; + +#if defined(WIN32) || defined(_MSC_VER) + int size = _vsnprintf(buffer, PRINTF_BUFFER_SIZE, format, arg_list); +#else + int size = vsnprintf(buffer, PRINTF_BUFFER_SIZE, format, arg_list); +#endif + if (size >= PRINTF_BUFFER_SIZE) { + char* buffer2 = (char*)malloc(size); +#if defined(WIN32) || defined(_MSC_VER) + _vsnprintf(buffer2, size, format, arg_list); +#else + vsnprintf(buffer2, size, format, arg_list); +#endif + this->write(buffer2); + free(buffer2); + } else { + this->write(buffer); + } + + va_end(arg_list); +} + +void TTStreamWriter::put_char(int val) +{ + char c[2]; + c[0] = (char)val; + c[1] = 0; + this->write(c); +} + +void TTStreamWriter::puts(const char *a) +{ + this->write(a); +} + +void TTStreamWriter::putline(const char *a) +{ + this->write(a); + this->write("\n"); +} + +void replace_newlines_with_spaces(char *a) { + char* i = a; + while (*i != 0) { + if (*i == '\r' || *i == '\n') + *i = ' '; + i++; + } +} |