Graphviz 2.47.0.
- Error on more than 128 cluster subgraphs #2080
- `dot2gxl` no longer crashes on input `<node id="">` #2092
+- remove itos #2229
### Removed
#pragma once
-#include <stdio.h>
-
// maximum number of bytes needed to print a NUL-terminated int
enum { CHARS_FOR_NUL_TERM_INT = 12 };
-
-// return type of itos below
-struct itos_ {
- char str[CHARS_FOR_NUL_TERM_INT];
-};
-
-/** convert an integer to a string
- *
- * Intended usage is something like:
- * agattr(g, AGEDGE, "hello", itos(42).str)
- *
- * @param i Integer to convert
- * @return Stringized conversion wrapped in a struct
- */
-static inline struct itos_ itos(int i) {
- struct itos_ s;
- (void)snprintf(s.str, sizeof(s.str), "%d", i);
- return s;
-}
+++ /dev/null
-// basic unit tester for itos
-
-#ifdef NDEBUG
-#error this is not intended to be compiled with assertions off
-#endif
-
-#include <assert.h>
-#include <cgraph/itos.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void test_0(void) { assert(strcmp(itos(0).str, "0") == 0); }
-
-static void test_1(void) { assert(strcmp(itos(1).str, "1") == 0); }
-
-static void test_neg_1(void) { assert(strcmp(itos(-1).str, "-1") == 0); }
-
-static void test_min(void) {
-
- int r = snprintf(NULL, 0, "%d", INT_MIN);
- assert(r > 0);
-
- char *buffer = malloc(sizeof(char) * ((size_t)r + 1));
- assert(buffer != NULL);
-
- (void)sprintf(buffer, "%d", INT_MIN);
-
- assert(strcmp(itos(INT_MIN).str, buffer) == 0);
-
- free(buffer);
-}
-
-static void test_max(void) {
-
- int r = snprintf(NULL, 0, "%d", INT_MAX);
- assert(r > 0);
-
- char *buffer = malloc(sizeof(char) * ((size_t)r + 1));
- assert(buffer != NULL);
-
- (void)sprintf(buffer, "%d", INT_MAX);
-
- assert(strcmp(itos(INT_MAX).str, buffer) == 0);
-
- free(buffer);
-}
-
-int main(void) {
-
-#define RUN(t) \
- do { \
- printf("running test_%s... ", #t); \
- fflush(stdout); \
- test_##t(); \
- printf("OK\n"); \
- } while (0)
-
- RUN(0);
- RUN(1);
- RUN(neg_1);
- RUN(min);
- RUN(max);
-
-#undef RUN
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-"""test ../lib/cgraph/itos.h"""
-
-import os
-from pathlib import Path
-import sys
-
-sys.path.append(os.path.dirname(__file__))
-from gvtest import run_c # pylint: disable=wrong-import-position
-
-def test_itos():
- """run the itos unit tests"""
-
- # locate the itos unit tests
- src = Path(__file__).parent.resolve() / "../lib/cgraph/test_itos.c"
- assert src.exists()
-
- # locate lib directory that needs to be in the include path
- lib = Path(__file__).parent.resolve() / "../lib"
-
- # extra C flags this compilation needs
- cflags = ['-I', lib]
-
- _, _ = run_c(src, cflags=cflags)