- Fixes '=' whitespace
- Replace ')\(=\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\(=\)(' with '\1 \2 ('.
- Replace '\(\w\)\(=\)\(\w\)' with '\1 \2 \3'.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2372 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
@@ -42,7 +42,7 @@ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i=first; i<first+num; i++)
|
||||
for (i = first; i<first+num; i++)
|
||||
{
|
||||
if (((value >> (i-first))&1) == 1)
|
||||
buffer[i/8] |= 1 << (i%8);
|
||||
@@ -61,7 +61,7 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, un
|
||||
uint32_t result = 0;
|
||||
unsigned int i;
|
||||
|
||||
for (i=first; i<first+num; i++)
|
||||
for (i = first; i<first+num; i++)
|
||||
{
|
||||
if (((buffer[i/8]>>(i%8))&1) == 1)
|
||||
result |= 1 << (i-first);
|
||||
|
||||
@@ -54,7 +54,7 @@ int run_command(command_context_t *context, command_t *c, char *words[], int num
|
||||
|
||||
static void tcl_output(void *privData, const char *file, int line, const char *function, const char *string)
|
||||
{
|
||||
Jim_Obj *tclOutput=(Jim_Obj *)privData;
|
||||
Jim_Obj *tclOutput = (Jim_Obj *)privData;
|
||||
|
||||
Jim_AppendString(interp, tclOutput, string, strlen(string));
|
||||
}
|
||||
@@ -108,7 +108,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
int len;
|
||||
const char *w=Jim_GetString(argv[i], &len);
|
||||
const char *w = Jim_GetString(argv[i], &len);
|
||||
if (*w=='#')
|
||||
{
|
||||
/* hit an end of line comment */
|
||||
@@ -228,26 +228,26 @@ command_t* register_command(command_context_t *context, command_t *parent, char
|
||||
/* maximum of two levels :-) */
|
||||
if (c->parent != NULL)
|
||||
{
|
||||
t1=c->parent->name;
|
||||
t1 = c->parent->name;
|
||||
t2="_";
|
||||
}
|
||||
t3=c->name;
|
||||
const char *full_name=alloc_printf("ocd_%s%s%s", t1, t2, t3);
|
||||
t3 = c->name;
|
||||
const char *full_name = alloc_printf("ocd_%s%s%s", t1, t2, t3);
|
||||
Jim_CreateCommand(interp, full_name, script_command, c, NULL);
|
||||
free((void *)full_name);
|
||||
|
||||
/* we now need to add an overrideable proc */
|
||||
const char *override_name=alloc_printf("proc %s%s%s {args} {if {[catch {eval ocd_%s%s%s $args}]==0} {return \"\"} else { return -code error }", t1, t2, t3, t1, t2, t3);
|
||||
const char *override_name = alloc_printf("proc %s%s%s {args} {if {[catch {eval ocd_%s%s%s $args}]==0} {return \"\"} else { return -code error }", t1, t2, t3, t1, t2, t3);
|
||||
Jim_Eval_Named(interp, override_name, __THIS__FILE__, __LINE__ );
|
||||
free((void *)override_name);
|
||||
|
||||
/* accumulate help text in Tcl helptext list. */
|
||||
Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG);
|
||||
Jim_Obj *helptext = Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG);
|
||||
if (Jim_IsShared(helptext))
|
||||
helptext = Jim_DuplicateObj(interp, helptext);
|
||||
Jim_Obj *cmd_entry=Jim_NewListObj(interp, NULL, 0);
|
||||
Jim_Obj *cmd_entry = Jim_NewListObj(interp, NULL, 0);
|
||||
|
||||
Jim_Obj *cmd_list=Jim_NewListObj(interp, NULL, 0);
|
||||
Jim_Obj *cmd_list = Jim_NewListObj(interp, NULL, 0);
|
||||
|
||||
/* maximum of two levels :-) */
|
||||
if (c->parent != NULL)
|
||||
@@ -404,7 +404,7 @@ void command_print(command_context_t *context, const char *format, ...)
|
||||
|
||||
int run_command(command_context_t *context, command_t *c, char *words[], int num_words)
|
||||
{
|
||||
int start_word=0;
|
||||
int start_word = 0;
|
||||
if (!((context->mode == COMMAND_CONFIG) || (c->mode == COMMAND_ANY) || (c->mode == context->mode) ))
|
||||
{
|
||||
/* Config commands can not run after the config stage */
|
||||
@@ -422,10 +422,10 @@ int run_command(command_context_t *context, command_t *c, char *words[], int num
|
||||
/* maximum of two levels :-) */
|
||||
if (c->parent != NULL)
|
||||
{
|
||||
t1=c->parent->name;
|
||||
t1 = c->parent->name;
|
||||
t2=" ";
|
||||
}
|
||||
t3=c->name;
|
||||
t3 = c->name;
|
||||
command_run_linef(context, "help {%s%s%s}", t1, t2, t3);
|
||||
}
|
||||
else if (retval == ERROR_COMMAND_CLOSE_CONNECTION)
|
||||
@@ -450,7 +450,7 @@ int command_run_line(command_context_t *context, char *line)
|
||||
* results
|
||||
*/
|
||||
/* run the line thru a script engine */
|
||||
int retval=ERROR_FAIL;
|
||||
int retval = ERROR_FAIL;
|
||||
int retcode;
|
||||
/* Beware! This code needs to be reentrant. It is also possible
|
||||
* for OpenOCD commands to be invoked directly from Tcl. This would
|
||||
@@ -508,21 +508,21 @@ int command_run_line(command_context_t *context, char *line)
|
||||
}
|
||||
LOG_USER_N("%s", "\n");
|
||||
}
|
||||
retval=ERROR_OK;
|
||||
retval = ERROR_OK;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int command_run_linef(command_context_t *context, const char *format, ...)
|
||||
{
|
||||
int retval=ERROR_FAIL;
|
||||
int retval = ERROR_FAIL;
|
||||
char *string;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
string = alloc_vprintf(format, ap);
|
||||
if (string != NULL)
|
||||
{
|
||||
retval=command_run_line(context, string);
|
||||
retval = command_run_line(context, string);
|
||||
}
|
||||
va_end(ap);
|
||||
return retval;
|
||||
@@ -837,13 +837,13 @@ void register_jim(struct command_context_s *cmd_ctx, const char *name, int (*cmd
|
||||
|
||||
/* FIX!!! it would be prettier to invoke add_help_text...
|
||||
* accumulate help text in Tcl helptext list. */
|
||||
Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG);
|
||||
Jim_Obj *helptext = Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG);
|
||||
if (Jim_IsShared(helptext))
|
||||
helptext = Jim_DuplicateObj(interp, helptext);
|
||||
|
||||
Jim_Obj *cmd_entry=Jim_NewListObj(interp, NULL, 0);
|
||||
Jim_Obj *cmd_entry = Jim_NewListObj(interp, NULL, 0);
|
||||
|
||||
Jim_Obj *cmd_list=Jim_NewListObj(interp, NULL, 0);
|
||||
Jim_Obj *cmd_list = Jim_NewListObj(interp, NULL, 0);
|
||||
Jim_ListAppendElement(interp, cmd_list, Jim_NewStringObj(interp, name, -1));
|
||||
|
||||
Jim_ListAppendElement(interp, cmd_entry, cmd_list);
|
||||
@@ -854,7 +854,7 @@ void register_jim(struct command_context_s *cmd_ctx, const char *name, int (*cmd
|
||||
/* return global variable long value or 0 upon failure */
|
||||
long jim_global_long(const char *variable)
|
||||
{
|
||||
Jim_Obj *objPtr=Jim_GetGlobalVariableStr(interp, variable, JIM_ERRMSG);
|
||||
Jim_Obj *objPtr = Jim_GetGlobalVariableStr(interp, variable, JIM_ERRMSG);
|
||||
long t;
|
||||
if (Jim_GetLong(interp, objPtr, &t) == JIM_OK)
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ FILE *open_file_from_path (char *file, char *mode)
|
||||
return fopen(file, mode);
|
||||
} else
|
||||
{
|
||||
char *full_path=find_file(file);
|
||||
char *full_path = find_file(file);
|
||||
if (full_path == NULL)
|
||||
return NULL;
|
||||
FILE *fp = NULL;
|
||||
@@ -115,7 +115,7 @@ int parse_config_file(struct command_context_s *cmd_ctx)
|
||||
|
||||
while (*cfg)
|
||||
{
|
||||
retval=command_run_line(cmd_ctx, *cfg);
|
||||
retval = command_run_line(cmd_ctx, *cfg);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
cfg++;
|
||||
|
||||
@@ -215,7 +215,7 @@ int handle_append_command(struct command_context_s *cmd_ctx, char *cmd,
|
||||
return ERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
int retval=ERROR_FAIL;
|
||||
int retval = ERROR_FAIL;
|
||||
FILE *config_file = NULL;
|
||||
config_file = fopen(args[0], "a");
|
||||
if (config_file != NULL)
|
||||
@@ -235,7 +235,7 @@ int handle_append_command(struct command_context_s *cmd_ctx, char *cmd,
|
||||
}
|
||||
if ((i == argc) && (fwrite("\n", 1, 1, config_file) == 1))
|
||||
{
|
||||
retval=ERROR_OK;
|
||||
retval = ERROR_OK;
|
||||
}
|
||||
fclose(config_file);
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ 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;}
|
||||
for (i = 0; i<e; i++) {res *= b;}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ void *Jim_Alloc(int size)
|
||||
{
|
||||
/* We allocate zero length arrayes, etc. to use a single orthogonal codepath */
|
||||
if (size == 0)
|
||||
size=1;
|
||||
size = 1;
|
||||
void *p = malloc(size);
|
||||
if (p == NULL)
|
||||
Jim_Panic(NULL,"malloc: Out of memory");
|
||||
@@ -584,7 +584,7 @@ void *Jim_Realloc(void *ptr, int size)
|
||||
{
|
||||
/* We allocate zero length arrayes, etc. to use a single orthogonal codepath */
|
||||
if (size == 0)
|
||||
size=1;
|
||||
size = 1;
|
||||
void *p = realloc(ptr, size);
|
||||
if (p == NULL)
|
||||
Jim_Panic(NULL,"realloc: Out of memory");
|
||||
@@ -2521,8 +2521,8 @@ static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
|
||||
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;
|
||||
}
|
||||
@@ -5366,7 +5366,7 @@ void ListInsertElements(Jim_Obj *listPtr, int index, int elemc,
|
||||
}
|
||||
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]);
|
||||
}
|
||||
@@ -7335,7 +7335,7 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
|
||||
|
||||
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 */
|
||||
@@ -7356,8 +7356,8 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
|
||||
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 */
|
||||
@@ -7401,7 +7401,7 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
|
||||
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 "
|
||||
@@ -7442,7 +7442,7 @@ static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
|
||||
/* 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];
|
||||
@@ -7550,7 +7550,7 @@ JimScanAString(Jim_Interp *interp, const char *sdescr, const char *str)
|
||||
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 {
|
||||
@@ -7559,7 +7559,7 @@ JimScanAString(Jim_Interp *interp, const char *sdescr, const char *str)
|
||||
}
|
||||
}
|
||||
/* 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 ... */
|
||||
@@ -7600,7 +7600,7 @@ static int ScanOneEntry(Jim_Interp *interp, const char *str, long pos,
|
||||
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;
|
||||
@@ -7757,12 +7757,12 @@ Jim_Obj *Jim_ScanString(Jim_Interp *interp, Jim_Obj *strObjPtr,
|
||||
/* 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! */
|
||||
@@ -8960,8 +8960,8 @@ int Jim_EvalFile(Jim_Interp *interp, const char *filename)
|
||||
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),
|
||||
@@ -10203,7 +10203,7 @@ static int JimForeachMapHelper(Jim_Interp *interp, int argc,
|
||||
/* 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]);
|
||||
@@ -10218,7 +10218,7 @@ static int JimForeachMapHelper(Jim_Interp *interp, int argc,
|
||||
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;
|
||||
@@ -10340,11 +10340,11 @@ enum {SWITCH_EXACT, SWITCH_GLOB, SWITCH_RE, SWITCH_CMD, SWITCH_UNKNOWN};
|
||||
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; }
|
||||
@@ -10372,7 +10372,7 @@ static int Jim_SwitchCoreCommand(Jim_Interp *interp, int argc,
|
||||
} 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)) {
|
||||
|
||||
@@ -575,7 +575,7 @@ typedef struct Jim_Reference {
|
||||
* known string, or there may be multiple strings (aliases) that mean then same
|
||||
* thing.
|
||||
*
|
||||
* An NVP Table is terminated with ".name=NULL".
|
||||
* An NVP Table is terminated with ".name = NULL".
|
||||
*
|
||||
* During the 'name2value' operation, if no matching string is found
|
||||
* the pointer to the terminal element (with p->name == NULL) is returned.
|
||||
@@ -966,7 +966,7 @@ JIM_STATIC const char *JIM_API( Jim_Debug_ArgvString )( Jim_Interp *interp, int
|
||||
* Usefull when dealing with command options.
|
||||
* that may come in any order...
|
||||
*
|
||||
* Does not support "-foo=123" type options.
|
||||
* Does not support "-foo = 123" type options.
|
||||
* Only supports tcl type options, like "-foo 123"
|
||||
*/
|
||||
|
||||
@@ -1097,7 +1097,7 @@ JIM_STATIC int JIM_API( Jim_GetOpt_Nvp)( Jim_GetOptInfo *goi, const Jim_Nvp *loo
|
||||
*
|
||||
* This function assumes the previous option argv[-1] is the unknown string.
|
||||
*
|
||||
* If this option had some prefix, then pass "hadprefix=1" else pass "hadprefix=0"
|
||||
* If this option had some prefix, then pass "hadprefix = 1" else pass "hadprefix = 0"
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
@@ -1107,7 +1107,7 @@ JIM_STATIC int JIM_API( Jim_GetOpt_Nvp)( Jim_GetOptInfo *goi, const Jim_Nvp *loo
|
||||
* e = Jim_GetOpt_Nvp( &goi, cmd_options, &n );
|
||||
* if ( e != JIM_OK ){
|
||||
* // option was not recognized
|
||||
* // pass 'hadprefix=0' because there is no prefix
|
||||
* // pass 'hadprefix = 0' because there is no prefix
|
||||
* Jim_GetOpt_NvpUnknown( &goi, cmd_options, 0 );
|
||||
* return e;
|
||||
* }
|
||||
|
||||
@@ -94,7 +94,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
|
||||
if (debug_level >= LOG_LVL_DEBUG)
|
||||
{
|
||||
/* print with count and time information */
|
||||
int t=(int)(timeval_ms()-start);
|
||||
int t = (int)(timeval_ms()-start);
|
||||
#ifdef _DEBUG_FREE_SPACE_
|
||||
struct mallinfo info;
|
||||
info = mallinfo();
|
||||
@@ -136,9 +136,9 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
|
||||
/* DANGER!!!! the log callback can remove itself!!!! */
|
||||
while (cb)
|
||||
{
|
||||
next=cb->next;
|
||||
next = cb->next;
|
||||
cb->fn(cb->priv, file, line, function, string);
|
||||
cb=next;
|
||||
cb = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ int log_init(struct command_context_s *cmd_ctx)
|
||||
log_output = stderr;
|
||||
}
|
||||
|
||||
start=last_time=timeval_ms();
|
||||
start = last_time = timeval_ms();
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ char *alloc_printf(const char *format, ...)
|
||||
*/
|
||||
void keep_alive()
|
||||
{
|
||||
current_time=timeval_ms();
|
||||
current_time = timeval_ms();
|
||||
if (current_time-last_time>1000)
|
||||
{
|
||||
extern int gdb_actual_connections;
|
||||
@@ -413,28 +413,28 @@ void keep_alive()
|
||||
* These functions should be invoked at a well defined spot in server.c
|
||||
*/
|
||||
|
||||
last_time=current_time;
|
||||
last_time = current_time;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset keep alive timer without sending message */
|
||||
void kept_alive()
|
||||
{
|
||||
current_time=timeval_ms();
|
||||
last_time=current_time;
|
||||
current_time = timeval_ms();
|
||||
last_time = current_time;
|
||||
}
|
||||
|
||||
/* if we sleep for extended periods of time, we must invoke keep_alive() intermittantly */
|
||||
void alive_sleep(int ms)
|
||||
{
|
||||
int i;
|
||||
int napTime=10;
|
||||
for (i=0; i<ms; i += napTime)
|
||||
int napTime = 10;
|
||||
for (i = 0; i<ms; i += napTime)
|
||||
{
|
||||
int sleep_a_bit=ms-i;
|
||||
int sleep_a_bit = ms-i;
|
||||
if (sleep_a_bit>napTime)
|
||||
{
|
||||
sleep_a_bit=napTime;
|
||||
sleep_a_bit = napTime;
|
||||
}
|
||||
usleep(sleep_a_bit*1000);
|
||||
keep_alive();
|
||||
@@ -444,7 +444,7 @@ void alive_sleep(int ms)
|
||||
void busy_sleep(int ms)
|
||||
{
|
||||
long long then;
|
||||
then=timeval_ms();
|
||||
then = timeval_ms();
|
||||
while ((timeval_ms()-then)<ms)
|
||||
{
|
||||
/* busy wait */
|
||||
|
||||
@@ -70,7 +70,7 @@ int add_default_dirs(void)
|
||||
/* Either this code will *always* work or it will SEGFAULT giving
|
||||
* excellent information on the culprit.
|
||||
*/
|
||||
*strrchr(strExePath, '\\')=0;
|
||||
*strrchr(strExePath, '\\') = 0;
|
||||
strcat(strExePath, "\\..");
|
||||
add_script_search_dir(strExePath);
|
||||
}
|
||||
@@ -88,9 +88,9 @@ int add_default_dirs(void)
|
||||
char strExePath [MAX_PATH];
|
||||
char *p;
|
||||
GetModuleFileName (NULL, strExePath, MAX_PATH);
|
||||
*strrchr(strExePath, '\\')=0;
|
||||
*strrchr(strExePath, '\\') = 0;
|
||||
strcat(strExePath, "/../lib/"PACKAGE);
|
||||
for (p=strExePath; *p; p++) {
|
||||
for (p = strExePath; *p; p++) {
|
||||
if (*p == '\\')
|
||||
*p = '/';
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ int duration_stop_measure(duration_t *duration, char **text)
|
||||
if (text)
|
||||
{
|
||||
float t;
|
||||
t=duration->duration.tv_sec;
|
||||
t = duration->duration.tv_sec;
|
||||
t += (float)duration->duration.tv_usec/1000000.0;
|
||||
*text = malloc(100);
|
||||
snprintf(*text, 100, "%fs", t);
|
||||
@@ -111,7 +111,7 @@ int duration_stop_measure(duration_t *duration, char **text)
|
||||
long long timeval_ms()
|
||||
{
|
||||
struct timeval now;
|
||||
long long t=0;
|
||||
long long t = 0;
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
t += now.tv_usec/1000;
|
||||
|
||||
Reference in New Issue
Block a user