atoi.c revision 1.9
15756Siignatyev/* $NetBSD: atoi.c,v 1.9 1999/09/16 11:45:33 lukem Exp $ */ 28344Sgoetz 35756Siignatyev/* 45756Siignatyev * Copyright (c) 1988, 1993 55756Siignatyev * The Regents of the University of California. All rights reserved. 65756Siignatyev * 75756Siignatyev * Redistribution and use in source and binary forms, with or without 85756Siignatyev * modification, are permitted provided that the following conditions 95756Siignatyev * are met: 105756Siignatyev * 1. Redistributions of source code must retain the above copyright 115756Siignatyev * notice, this list of conditions and the following disclaimer. 125756Siignatyev * 2. Redistributions in binary form must reproduce the above copyright 135756Siignatyev * notice, this list of conditions and the following disclaimer in the 145756Siignatyev * documentation and/or other materials provided with the distribution. 155756Siignatyev * 3. All advertising materials mentioning features or use of this software 165756Siignatyev * must display the following acknowledgement: 175756Siignatyev * This product includes software developed by the University of 185756Siignatyev * California, Berkeley and its contributors. 195756Siignatyev * 4. Neither the name of the University nor the names of its contributors 205756Siignatyev * may be used to endorse or promote products derived from this software 215756Siignatyev * without specific prior written permission. 225756Siignatyev * 235756Siignatyev * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2411707Stpivovarova * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2511707Stpivovarova * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2611707Stpivovarova * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2711707Stpivovarova * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 288359Sykantser * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 295756Siignatyev * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 305756Siignatyev * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 315756Siignatyev * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 325756Siignatyev * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3311534Siignatyev * SUCH DAMAGE. 345756Siignatyev */ 355756Siignatyev 365756Siignatyev#include <sys/cdefs.h> 375756Siignatyev#if defined(LIBC_SCCS) && !defined(lint) 385756Siignatyev#if 0 395756Siignatyevstatic char sccsid[] = "@(#)atoi.c 8.1 (Berkeley) 6/4/93"; 405756Siignatyev#else 415756Siignatyev__RCSID("$NetBSD: atoi.c,v 1.9 1999/09/16 11:45:33 lukem Exp $"); 425756Siignatyev#endif 435756Siignatyev#endif /* LIBC_SCCS and not lint */ 445756Siignatyev 455756Siignatyev#include <assert.h> 465756Siignatyev#include <stdlib.h> 4711715Stpivovarova 4811715Stpivovarovaint 4911715Stpivovarovaatoi(str) 505756Siignatyev const char *str; 515756Siignatyev{ 525756Siignatyev _DIAGASSERT(str != NULL); 5312547Sjcm#ifdef _DIAGNOSTIC 5411715Stpivovarova if (str == NULL) 5511715Stpivovarova return (0); 5611715Stpivovarova#endif 5712408Skvn 585756Siignatyev return((int)strtol(str, (char **)NULL, 10)); 5911715Stpivovarova} 605756Siignatyev