1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

VarParseLong: Move the initialisation of dynamic up which saves

an else clause. Move the assignment to the lengthPtr down to
just before the return statements.

Patch:		7.81

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
This commit is contained in:
Hartmut Brandt 2005-02-28 17:23:17 +00:00
parent d525de835f
commit 4866acd4de
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=142809

View File

@ -1006,6 +1006,8 @@ VarParseLong(char foo[], GNode *ctxt, Boolean err, size_t *lengthPtr,
}
}
dynamic = FALSE;
if (v == NULL) {
if (((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) &&
((vlen == 1) ||
@ -1079,8 +1081,6 @@ VarParseLong(char foo[], GNode *ctxt, Boolean err, size_t *lengthPtr,
return (err ? var_Error : varNoError);
}
}
} else {
dynamic = FALSE;
}
Buf_Destroy(buf, TRUE);
@ -1634,7 +1634,6 @@ VarParseLong(char foo[], GNode *ctxt, Boolean err, size_t *lengthPtr,
tstr = cp;
}
}
*lengthPtr = tstr - input + 1;
if (v->flags & VAR_FROM_ENV) {
if (rw_str == (char *)Buf_GetAll(v->val, (size_t *)NULL)) {
@ -1643,9 +1642,11 @@ VarParseLong(char foo[], GNode *ctxt, Boolean err, size_t *lengthPtr,
* the thing.
*/
*freePtr = TRUE;
*lengthPtr = tstr - input + 1;
VarDestroy(v, FALSE);
return (rw_str);
} else {
*lengthPtr = tstr - input + 1;
VarDestroy(v, TRUE);
return (rw_str);
}
@ -1659,6 +1660,7 @@ VarParseLong(char foo[], GNode *ctxt, Boolean err, size_t *lengthPtr,
}
if (dynamic) {
*freePtr = FALSE;
*lengthPtr = tstr - input + 1;
VarDestroy(v, TRUE);
rw_str = emalloc(*lengthPtr + 1);
strncpy(rw_str, input, *lengthPtr);
@ -1667,10 +1669,12 @@ VarParseLong(char foo[], GNode *ctxt, Boolean err, size_t *lengthPtr,
return (rw_str);
} else {
*freePtr = FALSE;
*lengthPtr = tstr - input + 1;
VarDestroy(v, TRUE);
return (err ? var_Error : varNoError);
}
} else {
*lengthPtr = tstr - input + 1;
return (rw_str);
}
}