From fb9bd89b1f1dafb6cac060a87806291126230c84 Mon Sep 17 00:00:00 2001
From: vignesh <vignesh@localhost.localdomain>
Date: Sat, 26 Oct 2019 13:54:57 +0530
Subject: [PATCH] Cleanup, removal of function present in #if 0.

Removal of unused function apply_typmod present in #if 0, this function has
been present within #if 0 from many years. This function can be removed safely.
---
 src/interfaces/ecpg/pgtypeslib/numeric.c | 83 --------------------------------
 1 file changed, 83 deletions(-)

diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c
index b6ca2d3..ab65e14 100644
--- a/src/interfaces/ecpg/pgtypeslib/numeric.c
+++ b/src/interfaces/ecpg/pgtypeslib/numeric.c
@@ -22,89 +22,6 @@
 						  free(buf); \
 		  } while (0)
 
-
-#if 0
-/* ----------
- * apply_typmod() -
- *
- *	Do bounds checking and rounding according to the attributes
- *	typmod field.
- * ----------
- */
-static int
-apply_typmod(numeric *var, long typmod)
-{
-	int			precision;
-	int			scale;
-	int			maxweight;
-	int			i;
-
-	/* Do nothing if we have a default typmod (-1) */
-	if (typmod < (long) (VARHDRSZ))
-		return 0;
-
-	typmod -= VARHDRSZ;
-	precision = (typmod >> 16) & 0xffff;
-	scale = typmod & 0xffff;
-	maxweight = precision - scale;
-
-	/* Round to target scale */
-	i = scale + var->weight + 1;
-	if (i >= 0 && var->ndigits > i)
-	{
-		int			carry = (var->digits[i] > 4) ? 1 : 0;
-
-		var->ndigits = i;
-
-		while (carry)
-		{
-			carry += var->digits[--i];
-			var->digits[i] = carry % 10;
-			carry /= 10;
-		}
-
-		if (i < 0)
-		{
-			var->digits--;
-			var->ndigits++;
-			var->weight++;
-		}
-	}
-	else
-		var->ndigits = Max(0, Min(i, var->ndigits));
-
-	/*
-	 * Check for overflow - note we can't do this before rounding, because
-	 * rounding could raise the weight.  Also note that the var's weight could
-	 * be inflated by leading zeroes, which will be stripped before storage
-	 * but perhaps might not have been yet. In any case, we must recognize a
-	 * true zero, whose weight doesn't mean anything.
-	 */
-	if (var->weight >= maxweight)
-	{
-		/* Determine true weight; and check for all-zero result */
-		int			tweight = var->weight;
-
-		for (i = 0; i < var->ndigits; i++)
-		{
-			if (var->digits[i])
-				break;
-			tweight--;
-		}
-
-		if (tweight >= maxweight && i < var->ndigits)
-		{
-			errno = PGTYPES_NUM_OVERFLOW;
-			return -1;
-		}
-	}
-
-	var->rscale = scale;
-	var->dscale = scale;
-	return 0;
-}
-#endif
-
 /* ----------
  *	alloc_var() -
  *
-- 
1.8.3.1

