]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/StdLib/strtoumax.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / LibC / StdLib / strtoumax.c
diff --git a/StdLib/LibC/StdLib/strtoumax.c b/StdLib/LibC/StdLib/strtoumax.c
deleted file mode 100644 (file)
index 1565800..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*  $NetBSD: strtoumax.c,v 1.1 2006/04/22 15:33:33 thorpej Exp $  */\r
-\r
-/*\r
- * Copyright (c) 1990, 1993\r
- *  The Regents of the University of California.  All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- *    notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- *    notice, this list of conditions and the following disclaimer in the\r
- *    documentation and/or other materials provided with the distribution.\r
- * 3. Neither the name of the University nor the names of its contributors\r
- *    may be used to endorse or promote products derived from this software\r
- *    without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- * SUCH DAMAGE.\r
- */\r
-#include  <LibConfig.h>\r
-#include <sys/EfiCdefs.h>\r
-\r
-#if !defined(_KERNEL) && !defined(_STANDALONE)\r
-#if defined(LIBC_SCCS) && !defined(lint)\r
-#if 0\r
-static char sccsid[] = "from: @(#)strtoul.c 8.1 (Berkeley) 6/4/93";\r
-#else\r
-__RCSID("$NetBSD: strtoumax.c,v 1.1 2006/04/22 15:33:33 thorpej Exp $");\r
-#endif\r
-#endif /* LIBC_SCCS and not lint */\r
-\r
-#include "namespace.h"\r
-\r
-#include <assert.h>\r
-#include <ctype.h>\r
-#include <errno.h>\r
-#include <inttypes.h>\r
-#include <stddef.h>\r
-\r
-#include <Library/BaseLib.h>\r
-\r
-#ifdef __weak_alias\r
-__weak_alias(strtoumax, _strtoumax)\r
-#endif\r
-\r
-#else /* !_KERNEL && !_STANDALONE */\r
-#include <sys/param.h>\r
-#include <lib/libkern/libkern.h>\r
-#endif /* !_KERNEL && !_STANDALONE */\r
-\r
-/*\r
- * Convert a string to an uintmax_t.\r
- *\r
- * Ignores `locale' stuff.  Assumes that the upper and lower case\r
- * alphabets and digits are each contiguous.\r
- */\r
-uintmax_t\r
-strtoumax(const char *nptr, char **endptr, int base)\r
-{\r
-  const char *s;\r
-  uintmax_t acc, cutoff;\r
-  int c;\r
-  int neg, any, cutlim;\r
-\r
-  _DIAGASSERT(nptr != NULL);\r
-  /* endptr may be NULL */\r
-\r
-  /*\r
-   * See strtol for comments as to the logic used.\r
-   */\r
-  s = nptr;\r
-  do {\r
-    c = (unsigned char) *s++;\r
-  } while (isspace(c));\r
-  if (c == '-') {\r
-    neg = 1;\r
-    c = *s++;\r
-  } else {\r
-    neg = 0;\r
-    if (c == '+')\r
-      c = *s++;\r
-  }\r
-  if ((base == 0 || base == 16) &&\r
-      c == '0' && (*s == 'x' || *s == 'X')) {\r
-    c = s[1];\r
-    s += 2;\r
-    base = 16;\r
-  }\r
-  if (base == 0)\r
-    base = c == '0' ? 8 : 10;\r
-\r
-  cutoff = DivU64x32 ((UINT64) UINTMAX_MAX, (UINT32) base);\r
-  cutlim = (int) ModU64x32 ((UINT64) UINTMAX_MAX, (UINT32) base);\r
-  for (acc = 0, any = 0;; c = (unsigned char) *s++) {\r
-    if (isdigit(c))\r
-      c -= '0';\r
-    else if (isalpha(c)) {\r
-#if defined(_KERNEL) || defined(_STANDALONE)\r
-      c = toupper(c) - 'A' + 10;\r
-#else\r
-      c -= isupper(c) ? 'A' - 10 : 'a' - 10;\r
-#endif\r
-    } else\r
-      break;\r
-    if (c >= base)\r
-      break;\r
-    if (any < 0)\r
-      continue;\r
-    if (acc > cutoff || (acc == cutoff && c > cutlim)) {\r
-#if defined(_KERNEL) || defined(_STANDALONE)\r
-      if (endptr)\r
-        *endptr = __UNCONST(nptr);\r
-      return UINTMAX_MAX;\r
-#else\r
-      any = -1;\r
-      acc = UINTMAX_MAX;\r
-      errno = ERANGE;\r
-#endif\r
-    } else {\r
-      any = 1;\r
-      acc *= (uintmax_t)base;\r
-      acc += c;\r
-    }\r
-  }\r
-  if (neg && any > 0)\r
-    acc = (uintmax_t)(-((intmax_t)acc));\r
-  if (endptr != 0)\r
-    *endptr = __UNCONST(any ? s - 1 : nptr);\r
-  return (acc);\r
-}\r