Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/, src/, po/: get[u]long(): Move functions to lib/atoi/str2i.h
And make them inline. Signed-off-by: Alejandro Colomar <[email protected]>
- Loading branch information
1 parent
dc12e87
commit 27e236c
Showing
24 changed files
with
105 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-FileCopyrightText: 2007-2009, Nicolas François | ||
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <[email protected]> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#include <config.h> | ||
|
||
#include "atoi/str2i.h" | ||
|
||
|
||
extern inline int getlong(const char *restrict s, long *restrict n); | ||
extern inline int getulong(const char *restrict s, unsigned long *restrict n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-FileCopyrightText: 2007-2009, Nicolas François | ||
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <[email protected]> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#ifndef SHADOW_INCLUDE_LIB_ATOI_STR2I_H_ | ||
#define SHADOW_INCLUDE_LIB_ATOI_STR2I_H_ | ||
|
||
|
||
#include <config.h> | ||
|
||
#include <stdlib.h> | ||
#include <errno.h> | ||
|
||
#include "atoi/str2i.h" | ||
#include "atoi/strtou_noneg.h" | ||
#include "attr.h" | ||
|
||
|
||
ATTR_ACCESS(write_only, 2) | ||
inline int getlong(const char *restrict s, long *restrict n); | ||
ATTR_ACCESS(write_only, 2) | ||
inline int getulong(const char *restrict s, unsigned long *restrict n); | ||
|
||
|
||
inline int | ||
getlong(const char *restrict s, long *restrict n) | ||
{ | ||
char *endp; | ||
long val; | ||
|
||
errno = 0; | ||
val = strtol(s, &endp, 0); | ||
if (('\0' == *s) || ('\0' != *endp) || (0 != errno)) | ||
return -1; | ||
|
||
*n = val; | ||
return 0; | ||
} | ||
|
||
|
||
inline int | ||
getulong(const char *restrict s, unsigned long *restrict n) | ||
{ | ||
char *endp; | ||
unsigned long val; | ||
|
||
errno = 0; | ||
val = strtoul_noneg(s, &endp, 0); | ||
if (('\0' == *s) || ('\0' != *endp) || (0 != errno)) | ||
return -1; | ||
|
||
*n = val; | ||
return 0; | ||
} | ||
|
||
|
||
#endif // include guard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
#include "defines.h" | ||
#include <stdio.h> | ||
|
||
#include "atoi/str2i.h" | ||
|
||
|
||
static FILE *shadow; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
#include <string.h> | ||
|
||
#include "alloc.h" | ||
#include "atoi/str2i.h" | ||
#include "string/sprintf.h" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.