📄 strtol.c
字号:
/*************************************************************************
*
* Copyright Mentor Graphics Corporation 2002
* All Rights Reserved.
*
* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
* SUBJECT TO LICENSE TERMS.
*
*************************************************************************/
/*************************************************************************
* FILE NAME VERSION
*
* strtol.c Nucleus Common Library 1.1
*
* DESCRIPTION
*
* This file contains the implementation of NCL_strol.
*
* DATA STRUCTURES
*
* None.
*
* FUNCTIONS
*
* NCL_strol
*
* DEPENDENCIES
*
* ncl.h
* convert.h
* ctype.h
* nucleus.h
*
************************************************************************/
#define NU_NCL_SOURCE_FILE
#include "ncl\inc\ncl.h"
#include "ncl\inc\convert.h"
#include "ncl\inc\ctype.h"
#include "plus\nucleus.h" /* MMU Support */
/*************************************************************************
*
* FUNCTION
*
* NCL_strtol
*
* DESCRIPTION
*
* This routine scans a string for a long integer. The integer may
* be preceeded by optional whitespace characters, and by a single '+'
* or '-' sign. The integer is in the base specified (from 2 to 36).
* If "base" is 0, then the integer is octal or hexadecimal if
* preceeded by a '0' or a '0x', otherwise, it defaults to decimal.
* A hexadecimal number may optionally be preceeded by "0x".
* If "endptr" is non-zero, it is set to point to the first invalid
* character found after the integer, or to nptr if a valid integer
* can't be scanned from the string.
*
* INPUTS
*
* nptr The start of the string to be processed
* base The number system to use (binary, hex, etc...)
*
* OUTPUTS
*
* endptr The first valid character after the integer
* (passed by reference)
* long The unsigned long number represented by the
* string
*
*************************************************************************/
long NCL_strtol (const char *nptr, char **endptr, int base)
{
register const uchar *ptr = (const uchar *)nptr;
long value;
while (NCL_isspace(*ptr))
++ptr; /* skip over whitespace */
value = NCL__strtol((const char*)ptr, endptr, base, -1);
if (endptr != (char**)0) /* indicate error if needed */
if (*endptr == (char*)ptr)
*endptr = (char *)nptr;
return (value);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -