From f7233b5bf705b3eae5e290155acb907d9b2704f5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 16 Oct 2020 17:28:25 -0700 Subject: [PATCH] remove unused _sfstrtod() --- lib/sfio/Makefile.am | 2 +- lib/sfio/sfhdr.h | 1 - lib/sfio/sfio.vcxproj | 1 - lib/sfio/sfio.vcxproj.filters | 3 - lib/sfio/sfstrtod.c | 135 ---------------------------------- 5 files changed, 1 insertion(+), 141 deletions(-) delete mode 100644 lib/sfio/sfstrtod.c diff --git a/lib/sfio/Makefile.am b/lib/sfio/Makefile.am index 708b8b371..ad7f65bcb 100644 --- a/lib/sfio/Makefile.am +++ b/lib/sfio/Makefile.am @@ -16,7 +16,7 @@ libsfio_C_la_SOURCES = sfclose.c sfcvt.c sfdisc.c \ sfprintf.c \ sfputr.c sfraise.c sfrd.c sfread.c \ sfresize.c sfscanf.c sfseek.c sfsetbuf.c sfsetfd.c \ - sfsk.c sfstack.c sfstrtod.c sfswap.c sfsync.c \ + sfsk.c sfstack.c sfswap.c sfsync.c \ sftable.c sftell.c sftmp.c sfungetc.c sfvprintf.c \ sfvscanf.c sfwr.c sfwrite.c diff --git a/lib/sfio/sfhdr.h b/lib/sfio/sfhdr.h index 48f4b786f..179de33f6 100644 --- a/lib/sfio/sfhdr.h +++ b/lib/sfio/sfhdr.h @@ -681,7 +681,6 @@ extern "C" { extern int _sfsetpool(Sfio_t *); extern char *_sfcvt(void *, int, int *, int *, int); extern char **_sfgetpath(char *); - extern Sfdouble_t _sfstrtod(const char *, char **); #ifndef errno extern int errno; diff --git a/lib/sfio/sfio.vcxproj b/lib/sfio/sfio.vcxproj index 2d8e2da28..7cc7dc806 100644 --- a/lib/sfio/sfio.vcxproj +++ b/lib/sfio/sfio.vcxproj @@ -111,7 +111,6 @@ - diff --git a/lib/sfio/sfio.vcxproj.filters b/lib/sfio/sfio.vcxproj.filters index 366224108..628eade43 100644 --- a/lib/sfio/sfio.vcxproj.filters +++ b/lib/sfio/sfio.vcxproj.filters @@ -116,9 +116,6 @@ Source Files - - Source Files - Source Files diff --git a/lib/sfio/sfstrtod.c b/lib/sfio/sfstrtod.c deleted file mode 100644 index e5b6fa915..000000000 --- a/lib/sfio/sfstrtod.c +++ /dev/null @@ -1,135 +0,0 @@ -/* $Id$ $Revision$ */ -/* vim:set shiftwidth=4 ts=8: */ - -/************************************************************************* - * Copyright (c) 2011 AT&T Intellectual Property - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: See CVS logs. Details at http://www.graphviz.org/ - *************************************************************************/ - -#include - -/* Convert a Sfdouble_t value represented in an ASCII format into -** the internal Sfdouble_t representation. -** -** Written by Kiem-Phong Vo. -*/ - -#define BATCH (2*sizeof(int)) /* accumulate this many digits at a time */ -#define IPART 0 /* doing integer part */ -#define FPART 1 /* doing fractional part */ -#define EPART 2 /* doing exponent part */ - -static Sfdouble_t sfpow10(int n) -{ - Sfdouble_t dval; - - switch (n) { - case -3: - return .001; - case -2: - return .01; - case -1: - return .1; - case 0: - return 1.; - case 1: - return 10.; - case 2: - return 100.; - case 3: - return 1000.; - } - - if (n < 0) { - dval = .0001; - for (n += 4; n < 0; n += 1) - dval /= 10.; - } else { - dval = 10000.; - for (n -= 4; n > 0; n -= 1) - dval *= 10.; - } - - return dval; -} - -/** - * @param s string to convert - * @param retp to return the remainder of string - */ -Sfdouble_t _sfstrtod(const char *s, char **retp) -{ - int n, c, m; - int mode, fexp, sign, expsign; - Sfdouble_t dval; - char decpoint = 0, thousand; - SFSETLOCALE(decpoint, thousand); - - /* skip initial blanks */ - while (isspace(*s)) - ++s; - - /* get the sign */ - if ((sign = (*s == '-')) || *s == '+') - s += 1; - - mode = IPART; - fexp = expsign = 0; - dval = 0.; - while (*s) { /* accumulate a handful of the digits */ - for (m = BATCH, n = 0; m > 0; --m, ++s) { /* get and process a char */ - c = *s; - if (isdigit(c)) - n = 10 * n + (c - '0'); - else - break; - } - - /* number of digits accumulated */ - m = BATCH - m; - - if (mode == IPART) { /* doing the integer part */ - if (dval == 0.) - dval = (Sfdouble_t) n; - else - dval = dval * sfpow10(m) + (Sfdouble_t) n; - } else if (mode == FPART) { /* doing the fractional part */ - fexp -= m; - if (n > 0) - dval += n * sfpow10(fexp); - } else if (n) { /* doing the exponent part */ - if (expsign) - n = -n; - dval *= sfpow10(n); - } - - if (!c) - break; - - if (m < BATCH) { /* detected a non-digit */ - if (c == decpoint) { /* start the fractional part or no match */ - if (mode != IPART) - break; - mode = FPART; - s += 1; - } else if (c == 'e' || c == 'E') { - if (mode == EPART) - break; - mode = EPART; - c = *++s; - if ((expsign = (c == '-')) || c == '+') - s += 1; - } else - break; - } - } - - if (retp) - *retp = (char *) s; - return sign ? -dval : dval; -} -- 2.40.0