atobytes(): restore postfix before return
This commit is contained in:
committed by
Masamichi Takagi
parent
0e50eb44a9
commit
9d6e0319f7
@ -1674,6 +1674,8 @@ static void destroy_local_environ(char **local_env)
|
|||||||
unsigned long atobytes(char *string)
|
unsigned long atobytes(char *string)
|
||||||
{
|
{
|
||||||
unsigned long mult = 1;
|
unsigned long mult = 1;
|
||||||
|
unsigned long ret;
|
||||||
|
char orig_postfix = 0;
|
||||||
char *postfix;
|
char *postfix;
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
|
|
||||||
@ -1685,19 +1687,26 @@ unsigned long atobytes(char *string)
|
|||||||
|
|
||||||
if (*postfix == 'k' || *postfix == 'K') {
|
if (*postfix == 'k' || *postfix == 'K') {
|
||||||
mult = 1024;
|
mult = 1024;
|
||||||
|
orig_postfix = *postfix;
|
||||||
*postfix = 0;
|
*postfix = 0;
|
||||||
}
|
}
|
||||||
else if (*postfix == 'm' || *postfix == 'M') {
|
else if (*postfix == 'm' || *postfix == 'M') {
|
||||||
mult = 1024 * 1024;
|
mult = 1024 * 1024;
|
||||||
|
orig_postfix = *postfix;
|
||||||
*postfix = 0;
|
*postfix = 0;
|
||||||
}
|
}
|
||||||
else if (*postfix == 'g' || *postfix == 'G') {
|
else if (*postfix == 'g' || *postfix == 'G') {
|
||||||
mult = 1024 * 1024 * 1024;
|
mult = 1024 * 1024 * 1024;
|
||||||
|
orig_postfix = *postfix;
|
||||||
*postfix = 0;
|
*postfix = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = atol(string) * mult;
|
||||||
|
if (orig_postfix)
|
||||||
|
*postfix = orig_postfix;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return atol(string) * mult;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct option mcexec_options[] = {
|
static struct option mcexec_options[] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user