From 84df52f9ea78e2d71bde648a16b69d80404c6421 Mon Sep 17 00:00:00 2001 From: zwelch Date: Tue, 23 Jun 2009 22:42:54 +0000 Subject: - 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 --- src/helper/binarybuffer.h | 4 ++-- src/helper/command.c | 40 ++++++++++++++++++++-------------------- src/helper/configuration.c | 4 ++-- src/helper/ioutil.c | 4 ++-- src/helper/jim.c | 46 +++++++++++++++++++++++----------------------- src/helper/jim.h | 8 ++++---- src/helper/log.c | 26 +++++++++++++------------- src/helper/options.c | 6 +++--- src/helper/time_support.c | 4 ++-- 9 files changed, 71 insertions(+), 71 deletions(-) (limited to 'src/helper') diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index d07a15a1..a49d5d53 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -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> (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>(i%8))&1) == 1) result |= 1 << (i-first); diff --git a/src/helper/command.c b/src/helper/command.c index e8391054..231c2999 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -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) { diff --git a/src/helper/configuration.c b/src/helper/configuration.c index 95b4c7e0..9485a7eb 100644 --- a/src/helper/configuration.c +++ b/src/helper/configuration.c @@ -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++; diff --git a/src/helper/ioutil.c b/src/helper/ioutil.c index 8f02e2eb..390d50e9 100644 --- a/src/helper/ioutil.c +++ b/src/helper/ioutil.c @@ -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); } diff --git a/src/helper/jim.c b/src/helper/jim.c index 8e063608..7c459d57 100644 --- a/src/helper/jim.c +++ b/src/helper/jim.c @@ -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; iinternalRep.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)) { diff --git a/src/helper/jim.h b/src/helper/jim.h index 3d3346c2..97846f14 100644 --- a/src/helper/jim.h +++ b/src/helper/jim.h @@ -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; * } diff --git a/src/helper/log.c b/src/helper/log.c index 0e04af6f..68b29a20 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -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; inapTime) { - 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)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; -- cgit v1.2.3