* digit. For instance, if the range for quads is
* [-9223372036854775808..9223372036854775807] and the input base
* is 10, cutoff will be set to 922337203685477580 and cutlim to
- * either 7 (neg==0) or 8 (neg==1), meaning that if we have
+ * either 7 (neg == 0) or 8 (neg == 1), meaning that if we have
* accumulated a value > 922337203685477580, or equal but the
* next digit is > 7 (or 8), the number is too big, and we will
* return a range error.
static jim_wide JimPowWide(jim_wide b, jim_wide e)
{
jim_wide i, res = 1;
- if ((b==0 && e != 0) || (e<0)) return 0;
- for (i=0; i<e; i++) {res *= b;}
+ if ((b == 0 && e != 0) || (e<0)) return 0;
+ for (i = 0; i<e; i++) {res *= b;}
return res;
}
void *Jim_Alloc(int size)
{
/* We allocate zero length arrayes, etc. to use a single orthogonal codepath */
- if (size==0)
- size=1;
+ if (size == 0)
+ size = 1;
void *p = malloc(size);
if (p == NULL)
Jim_Panic(NULL,"malloc: Out of memory");
void *Jim_Realloc(void *ptr, int size)
{
/* We allocate zero length arrayes, etc. to use a single orthogonal codepath */
- if (size==0)
- size=1;
+ if (size == 0)
+ size = 1;
void *p = realloc(ptr, size);
if (p == NULL)
Jim_Panic(NULL,"realloc: Out of memory");
Jim_Obj *Jim_FormatString(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
int objc, Jim_Obj *const *objv)
{
- char *sprintf_buf=malloc(JIM_MAX_FMT);
- Jim_Obj *t=Jim_FormatString_Inner(interp, fmtObjPtr, objc, objv, sprintf_buf);
+ char *sprintf_buf = malloc(JIM_MAX_FMT);
+ Jim_Obj *t = Jim_FormatString_Inner(interp, fmtObjPtr, objc, objv, sprintf_buf);
free(sprintf_buf);
return t;
}
}
point = listPtr->internalRep.listValue.ele + index;
memmove(point+elemc, point, (currentLen-index) * sizeof(Jim_Obj*));
- for (i=0; i < elemc; ++i) {
+ for (i = 0; i < elemc; ++i) {
point[i] = elemVec[i];
Jim_IncrRefCount(point[i]);
}
case JIM_EXPROP_GTE: wC = wA >= wB; break;
case JIM_EXPROP_LSHIFT: wC = wA << wB; break;
case JIM_EXPROP_RSHIFT: wC = wA >> wB; break;
- case JIM_EXPROP_NUMEQ: wC = wA==wB; break;
+ case JIM_EXPROP_NUMEQ: wC = wA == wB; break;
case JIM_EXPROP_NUMNE: wC = wA != wB; break;
case JIM_EXPROP_BITAND: wC = wA&wB; break;
case JIM_EXPROP_BITXOR: wC = wA^wB; break;
case JIM_EXPROP_GT: dC = dA>dB; break;
case JIM_EXPROP_LTE: dC = dA <= dB; break;
case JIM_EXPROP_GTE: dC = dA >= dB; break;
- case JIM_EXPROP_NUMEQ: dC = dA==dB; break;
+ case JIM_EXPROP_NUMEQ: dC = dA == dB; break;
case JIM_EXPROP_NUMNE: dC = dA != dB; break;
case JIM_EXPROP_LOGICAND_LEFT:
if (dA == 0) {
Jim_FreeIntRep(interp, objPtr);
/* Count how many conversions could take place maximally */
- for (i=0, maxCount=0; i < maxFmtLen; ++i)
+ for (i = 0, maxCount = 0; i < maxFmtLen; ++i)
if (fmt[i] == '%')
++maxCount;
/* Calculate an approximation of the memory necessary */
buffer = fmtObj->stringRep + maxFmtLen + 1;
objPtr->internalRep.ptr = fmtObj;
objPtr->typePtr = &scanFmtStringObjType;
- for (i=0, curr=0; fmt < fmtEnd; ++fmt) {
- int width=0, skip;
+ for (i = 0, curr = 0; fmt < fmtEnd; ++fmt) {
+ int width = 0, skip;
ScanFmtPartDescr *descr = &fmtObj->descr[curr];
fmtObj->count++;
descr->width = 0; /* Assume width unspecified */
return JIM_ERR;
}
/* Look if this position was already used */
- for (prev=0; prev < curr; ++prev) {
+ for (prev = 0; prev < curr; ++prev) {
if (fmtObj->descr[prev].pos == -1) continue;
if (fmtObj->descr[prev].pos == descr->pos) {
fmtObj->error = "same \"%n$\" conversion specifier "
/* In case a range fence was given "backwards", swap it */
while (swapped) {
swapped = 0;
- for (j=beg+1; j < end-1; ++j) {
+ for (j = beg+1; j < end-1; ++j) {
if (buffer[j] == '-' && buffer[j-1] > buffer[j+1]) {
char tmp = buffer[j-1];
buffer[j-1] = buffer[j+1];
if (sdescr[1] == '-' && sdescr[2] != 0) {
/* Handle range definitions */
int i;
- for (i=sdescr[0]; i <= sdescr[2]; ++i)
+ for (i = sdescr[0]; i <= sdescr[2]; ++i)
JimSetBit(charset, (char)i);
sdescr += 3;
} else {
}
}
/* Negate the charset if there was a NOT given */
- for (i=0; notFlag && i < sizeof(charset); ++i)
+ for (i = 0; notFlag && i < sizeof(charset); ++i)
charset[i] = ~charset[i];
}
/* And after all the mess above, the real work begin ... */
if (descr->prefix) {
/* There was a prefix given before the conversion, skip it and adjust
* the string-to-be-parsed accordingly */
- for (i=0; str[pos] && descr->prefix[i]; ++i) {
+ for (i = 0; str[pos] && descr->prefix[i]; ++i) {
/* If prefix require, skip WS */
if (isspace((int)descr->prefix[i]))
while (str[pos] && isspace((int)str[pos])) ++pos;
/* Create a list and fill it with empty strings up to max specified XPG3 */
resultList = Jim_NewListObj(interp, 0, 0);
if (fmtObj->maxPos > 0) {
- for (i=0; i < fmtObj->maxPos; ++i)
+ for (i = 0; i < fmtObj->maxPos; ++i)
Jim_ListAppendElement(interp, resultList, emptyStr);
JimListGetElements(interp, resultList, &resultc, &resultVec);
}
/* Now handle every partial format description */
- for (i=0, pos=0; i < fmtObj->count; ++i) {
+ for (i = 0, pos = 0; i < fmtObj->count; ++i) {
ScanFmtPartDescr *descr = &(fmtObj->descr[i]);
Jim_Obj *value = 0;
/* Only last type may be "literal" w/o conversion - skip it! */
Jim_Obj *scriptObjPtr;
if ((fp = fopen(filename, "r")) == NULL) {
- const int cwd_len=2048;
- char *cwd=malloc(cwd_len);
+ const int cwd_len = 2048;
+ char *cwd = malloc(cwd_len);
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
if (!getcwd( cwd, cwd_len )) strcpy(cwd, "unknown");
Jim_AppendStrings(interp, Jim_GetResult(interp),
/* Initialize iterators and remember max nbr elements each list */
memset(listsIdx, 0, nbrOfLists * sizeof(int));
/* Remember lengths of all lists and calculate how much rounds to loop */
- for (i=0; i < nbrOfLists*2; i += 2) {
+ for (i = 0; i < nbrOfLists*2; i += 2) {
div_t cnt;
int count;
Jim_ListLength(interp, argv[i+1], &listsEnd[i]);
nbrOfLoops = count;
}
for (; nbrOfLoops-- > 0; ) {
- for (i=0; i < nbrOfLists; ++i) {
+ for (i = 0; i < nbrOfLists; ++i) {
int varIdx = 0, var = i * 2;
while (varIdx < listsEnd[var]) {
Jim_Obj *varName, *ele;
static int Jim_SwitchCoreCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
- int retcode = JIM_ERR, matchOpt = SWITCH_EXACT, opt=1, patCount, i;
+ int retcode = JIM_ERR, matchOpt = SWITCH_EXACT, opt = 1, patCount, i;
Jim_Obj *command = 0, *const *caseList = 0, *strObj;
Jim_Obj *script = 0;
if (argc < 3) goto wrongnumargs;
- for (opt=1; opt < argc; ++opt) {
+ for (opt = 1; opt < argc; ++opt) {
const char *option = Jim_GetString(argv[opt], 0);
if (*option != '-') break;
else if (strncmp(option, "--", 2) == 0) { ++opt; break; }
} else
caseList = &argv[opt];
if (patCount == 0 || patCount % 2 != 0) goto wrongnumargs;
- for (i=0; script == 0 && i < patCount; i += 2) {
+ for (i = 0; script == 0 && i < patCount; i += 2) {
Jim_Obj *patObj = caseList[i];
if (!Jim_CompareStringImmediate(interp, patObj, "default")
|| i < (patCount-2)) {