* Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de *
* *
- * Copyright (C) 2007,2008 Øyvind Harboe *
+ * Copyright (C) 2007,2008 Øyvind Harboe *
* oyvind.harboe@zylin.com *
* *
* Copyright (C) 2008, Duane Ellis *
/* 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);
- Jim_Eval_Named(interp, override_name, __THIS__FILE__, __LINE__ );
+ Jim_Eval_Named(interp, override_name, __THIS__FILE__, __LINE__);
free((void *)override_name);
/* accumulate help text in Tcl helptext list. */
void command_output_text(command_context_t *context, const char *data)
{
- if ( context && context->output_handler && data ){
- context->output_handler( context, data );
+ if (context && context->output_handler && data) {
+ context->output_handler(context, data);
}
}
int run_command(command_context_t *context, command_t *c, char *words[], int num_words)
{
int start_word = 0;
- if (!((context->mode == COMMAND_CONFIG) || (c->mode == COMMAND_ANY) || (c->mode == context->mode) ))
+ if (!((context->mode == COMMAND_CONFIG) || (c->mode == COMMAND_ANY) || (c->mode == context->mode)))
{
/* Config commands can not run after the config stage */
LOG_ERROR("Command '%s' only runs during configuration stage", c->name);
retcode = Jim_SetAssocData(interp, "retval", NULL, &retval);
if (retcode == JIM_OK)
{
- retcode = Jim_Eval_Named(interp, line, __THIS__FILE__, __LINE__ );
+ retcode = Jim_Eval_Named(interp, line, __THIS__FILE__, __LINE__);
Jim_DeleteAssocData(interp, "retval");
}
int reslen;
result = Jim_GetString(Jim_GetResult(interp), &reslen);
- if (reslen>0)
+ if (reslen > 0)
{
int i;
char buff[256 + 1];
log_add_callback(tcl_output, tclOutput);
- retcode = Jim_Eval_Named(interp, str, __THIS__FILE__, __LINE__ );
+ retcode = Jim_Eval_Named(interp, str, __THIS__FILE__, __LINE__);
log_remove_callback(tcl_output, tclOutput);
Jim_RegisterCoreCommands(interp);
#endif
-#if defined( _MSC_VER )
+#if defined(_MSC_VER)
/* WinXX - is generic, the forward
* looking problem is this:
*
* "winxx" is generic.
*/
HostOs = "winxx";
-#elif defined( __LINUX__)
+#elif defined(__LINUX__)
HostOs = "linux";
-#elif defined( __DARWIN__ )
+#elif defined(__DARWIN__)
HostOs = "darwin";
-#elif defined( __CYGWIN__ )
+#elif defined(__CYGWIN__)
HostOs = "cygwin";
-#elif defined( __MINGW32__ )
+#elif defined(__MINGW32__)
HostOs = "mingw32";
#else
HostOs = "other";
#endif
- Jim_SetGlobalVariableStr( interp, "ocd_HOSTOS", Jim_NewStringObj( interp, HostOs , strlen(HostOs)) );
+ Jim_SetGlobalVariableStr(interp, "ocd_HOSTOS", Jim_NewStringObj(interp, HostOs , strlen(HostOs)));
Jim_CreateCommand(interp, "ocd_find", jim_find, NULL, NULL);
Jim_CreateCommand(interp, "echo", jim_echo, NULL, NULL);
if (!recursion)
{
recursion++;
- Jim_ProcessEvents (interp, JIM_ALL_EVENTS|JIM_DONT_WAIT);
+ Jim_ProcessEvents (interp, JIM_ALL_EVENTS | JIM_DONT_WAIT);
recursion--;
}
#endif
int parse##name(const char *str, type *ul) \
{ \
if (!*str) \
+ { \
+ LOG_ERROR("Invalid command argument"); \
return ERROR_COMMAND_ARGUMENT_INVALID; \
+ } \
char *end; \
*ul = func(str, &end, 0); \
if (*end) \
+ { \
+ LOG_ERROR("Invalid command argument"); \
return ERROR_COMMAND_ARGUMENT_INVALID; \
+ } \
if ((max == *ul) && (ERANGE == errno)) \
+ { \
+ LOG_ERROR("Argument overflow"); \
return ERROR_COMMAND_ARGUMENT_OVERFLOW; \
+ } \
if (min && (min == *ul) && (ERANGE == errno)) \
+ { \
+ LOG_ERROR("Argument underflow"); \
return ERROR_COMMAND_ARGUMENT_UNDERFLOW; \
+ } \
return ERROR_OK; \
}
DEFINE_PARSE_NUM_TYPE(_ulong, unsigned long , strtoul, 0, ULONG_MAX)
return ERROR_COMMAND_ARGUMENT_UNDERFLOW; \
*ul = n; \
return ERROR_OK; \
- }
+ }
#define DEFINE_PARSE_ULONG(name, type, min, max) \
DEFINE_PARSE_WRAPPER(name, type, min, max, unsigned long, _ulong)