From 43d1dfdcce3eccf054c55924a8cdc13750a0d59c Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 6 Jul 2021 18:49:03 -0700 Subject: [PATCH] remove sfio versioning mechanism MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The sfio library versioned its format structure, _sffmt_s. This allowed multiple format structures of differing versions to exist in memory at once,¹ with sfio able to distinguish between a structure created by itself vs a structure created by a different version of sfio. In theory, this allows multiple versions of the sfio library to be loaded at once. In practice, Graphviz does not take advantage of any of this. In fact, it is not possible to do this within Graphviz as SFIO_VERSION has not been bumped when lib/sfio is changed. It still claims to be compatible with a version developed in 2001. This commit removes the versioning mechanism entirely, in order to both reduce maintenance overhead as well as remove the runtime cost associated with managing this data. The latter is trivial in terms of runtime, but it is also work that has no purpose. ¹ This kind of design often also allows you to serialize a structure to disk or network to later be read back in by a potentially differing version of the library. In the case of sfio however, this use case was not possible because the structure contains function pointers. --- lib/expr/exeval.c | 2 -- lib/sfio/sfio.h | 5 ----- lib/sfio/sftable.c | 1 - 3 files changed, 8 deletions(-) diff --git a/lib/expr/exeval.c b/lib/expr/exeval.c index 03742110f..448ce6c35 100644 --- a/lib/expr/exeval.c +++ b/lib/expr/exeval.c @@ -403,7 +403,6 @@ print(Expr_t* ex, Exnode_t* expr, void* env, Sfio_t* sp) } } memset(&fmt, 0, sizeof(fmt)); - fmt.fmt.version = SFIO_VERSION; fmt.fmt.extf = prformat; fmt.expr = ex; fmt.env = env; @@ -530,7 +529,6 @@ scan(Expr_t* ex, Exnode_t* expr, void* env, Sfio_t* sp) } get: memset(&fmt, 0, sizeof(fmt)); - fmt.fmt.version = SFIO_VERSION; fmt.fmt.extf = scformat; fmt.expr = ex; fmt.env = env; diff --git a/lib/sfio/sfio.h b/lib/sfio/sfio.h index 0a11d0a6e..5decb1e37 100644 --- a/lib/sfio/sfio.h +++ b/lib/sfio/sfio.h @@ -15,8 +15,6 @@ extern "C" { #ifndef _SFIO_H #define _SFIO_H 1 -#define SFIO_VERSION 20010201L - /* Public header file for the sfio library ** ** Written by Kiem-Phong Vo @@ -80,7 +78,6 @@ extern "C" { typedef int (*Sffmtext_f)(Sfio_t *, void *, Sffmt_t *); typedef int (*Sffmtevent_f)(Sfio_t *, int, void *, Sffmt_t *); struct _sffmt_s { - long version; /* version of this structure */ Sffmtext_f extf; /* function to process arguments */ Sffmtevent_f eventf; /* process events */ @@ -97,8 +94,6 @@ extern "C" { char *t_str; /* type string */ ssize_t n_str; /* length of t_str */ }; -#define sffmtversion(fe,type) \ - (type ? ((fe)->version = SFIO_VERSION) : (fe)->version) #define SFFMT_SSHORT 00000010 /* 'hh' flag, char */ #define SFFMT_TFLAG 00000020 /* 't' flag, ptrdiff_t */ diff --git a/lib/sfio/sftable.c b/lib/sfio/sftable.c index 0b0b39b7e..2e68af083 100644 --- a/lib/sfio/sftable.c +++ b/lib/sfio/sftable.c @@ -303,7 +303,6 @@ static Fmtpos_t *sffmtpos(Sfio_t * f, const char *form, va_list args, } if (ft && ft->extf) { - fp[n].ft.version = ft->version; fp[n].ft.extf = ft->extf; fp[n].ft.eventf = ft->eventf; if ((v = fp[n].need[FP_WIDTH]) >= 0 && v < n) -- 2.40.0