Browse Source

use llabs instead of the home-grown version; and some comment changes

ok ian@, millert@
OPENBSD_4_6
martynas 15 years ago
parent
commit
b263bc8a8a
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      src/lib/libutil/fmt_scaled.c

+ 4
- 4
src/lib/libutil/fmt_scaled.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: fmt_scaled.c,v 1.9 2007/03/20 03:42:52 tedu Exp $ */
/* $OpenBSD: fmt_scaled.c,v 1.10 2009/06/20 15:00:04 martynas Exp $ */
/* /*
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved. * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@ -65,7 +65,7 @@ static long long scale_factors[] = {
#define MAX_DIGITS (SCALE_LENGTH * 3) /* XXX strlen(sprintf("%lld", -1)? */ #define MAX_DIGITS (SCALE_LENGTH * 3) /* XXX strlen(sprintf("%lld", -1)? */
/** Convert the given input string "scaled" into numeric in "result".
/* Convert the given input string "scaled" into numeric in "result".
* Return 0 on success, -1 and errno set on error. * Return 0 on success, -1 and errno set on error.
*/ */
int int
@ -146,7 +146,7 @@ scan_scaled(char *scaled, long long *result)
/* Validate scale factor, and scale whole and fraction by it. */ /* Validate scale factor, and scale whole and fraction by it. */
for (i = 0; i < SCALE_LENGTH; i++) { for (i = 0; i < SCALE_LENGTH; i++) {
/** Are we there yet? */
/* Are we there yet? */
if (*p == scale_chars[i] || if (*p == scale_chars[i] ||
*p == tolower(scale_chars[i])) { *p == tolower(scale_chars[i])) {
@ -192,7 +192,7 @@ fmt_scaled(long long number, char *result)
unsigned int i; unsigned int i;
unit_type unit = NONE; unit_type unit = NONE;
abval = (number < 0LL) ? -number : number; /* no long long_abs yet */
abval = llabs(number);
/* Not every negative long long has a positive representation. /* Not every negative long long has a positive representation.
* Also check for numbers that are just too darned big to format * Also check for numbers that are just too darned big to format


Loading…
Cancel
Save