- Replace 'if(' with 'if ('.
[openocd.git] / src / helper / jim.c
index 5da0aa114b34d7bb29db1cab69b884c88d898dac..d62346c1a3e5968fa9659bd5876373d0d573fefc 100644 (file)
  * are those of the authors and should not be interpreted as representing
  * official policies, either expressed or implied, of the Jim Tcl Project.
  **/
  * are those of the authors and should not be interpreted as representing
  * official policies, either expressed or implied, of the Jim Tcl Project.
  **/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #define __JIM_CORE__
 #define JIM_OPTIMIZATION /* comment to avoid optimizations and reduce size */
 
 #ifdef __ECOS
 #include <pkgconf/jimtcl.h>
 #define __JIM_CORE__
 #define JIM_OPTIMIZATION /* comment to avoid optimizations and reduce size */
 
 #ifdef __ECOS
 #include <pkgconf/jimtcl.h>
-#endif
-#ifndef JIM_ANSIC
-#define JIM_DYNLIB      /* Dynamic library support for UNIX and WIN32 */
-#endif /* JIM_ANSIC */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE    /* for vasprintf() */
-#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 #include <errno.h>
 #include <time.h>
 #include <assert.h>
 #include <errno.h>
 #include <time.h>
-#if defined(WIN32)
-/* sys/time - need is different */
-#else
-#include <sys/time.h> // for gettimeofday()
 #endif
 #endif
+#ifndef JIM_ANSIC
+#define JIM_DYNLIB      /* Dynamic library support for UNIX and WIN32 */
+#endif /* JIM_ANSIC */
 
 
-#include "replacements.h"
+#include <stdarg.h>
+#include <limits.h>
 
 /* Include the platform dependent libraries for
  * dynamic loading of libraries. */
 
 /* Include the platform dependent libraries for
  * dynamic loading of libraries. */
 #endif /* WIN32 */
 #endif /* JIM_DYNLIB */
 
 #endif /* WIN32 */
 #endif /* JIM_DYNLIB */
 
-#ifndef WIN32
-#include <unistd.h>
-#endif
-
 #ifdef __ECOS
 #include <cyg/jimtcl/jim.h>
 #else
 #ifdef __ECOS
 #include <cyg/jimtcl/jim.h>
 #else
@@ -118,7 +110,7 @@ static void JimChangeCallFrameId(Jim_Interp *interp, Jim_CallFrame *cf);
 static void JimFreeCallFrame(Jim_Interp *interp, Jim_CallFrame *cf, int flags);
 static void JimRegisterCoreApi(Jim_Interp *interp);
 
 static void JimFreeCallFrame(Jim_Interp *interp, Jim_CallFrame *cf, int flags);
 static void JimRegisterCoreApi(Jim_Interp *interp);
 
-static Jim_HashTableType JimVariablesHashTableType;
+static Jim_HashTableType *getJimVariablesHashTableType(void);
 
 /* -----------------------------------------------------------------------------
  * Utility functions
 
 /* -----------------------------------------------------------------------------
  * Utility functions
@@ -160,7 +152,7 @@ jim_vasprintf_done( void *buf )
  * Ignores `locale' stuff.  Assumes that the upper and lower case
  * alphabets and digits are each contiguous.
  */
  * Ignores `locale' stuff.  Assumes that the upper and lower case
  * alphabets and digits are each contiguous.
  */
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 #define JimIsAscii(c) (((c) & ~0x7f) == 0)
 static jim_wide JimStrtoll(const char *nptr, char **endptr, register int base)
 {
 #define JimIsAscii(c) (((c) & ~0x7f) == 0)
 static jim_wide JimStrtoll(const char *nptr, char **endptr, register int base)
 {
@@ -424,7 +416,7 @@ int Jim_StringToWide(const char *str, jim_wide *widePtr, int base)
 {
     char *endptr;
 
 {
     char *endptr;
 
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
     *widePtr = JimStrtoll(str, &endptr, base);
 #else
     *widePtr = strtol(str, &endptr, base);
     *widePtr = JimStrtoll(str, &endptr, base);
 #else
     *widePtr = strtol(str, &endptr, base);
@@ -552,7 +544,7 @@ void Jim_Panic(Jim_Interp *interp, const char *fmt, ...)
 #endif
        
        /* This may actually crash... we do it last */
 #endif
        
        /* This may actually crash... we do it last */
-       if( interp && interp->cookie_stderr ){
+       if ( interp && interp->cookie_stderr ){
                Jim_fprintf(  interp, interp->cookie_stderr, JIM_NL "JIM INTERPRETER PANIC: ");
                Jim_vfprintf( interp, interp->cookie_stderr, fmt, ap );
                Jim_fprintf(  interp, interp->cookie_stderr, JIM_NL JIM_NL );
                Jim_fprintf(  interp, interp->cookie_stderr, JIM_NL "JIM INTERPRETER PANIC: ");
                Jim_vfprintf( interp, interp->cookie_stderr, fmt, ap );
                Jim_fprintf(  interp, interp->cookie_stderr, JIM_NL JIM_NL );
@@ -2072,7 +2064,7 @@ void Jim_AppendString_sprintf( Jim_Interp *interp, Jim_Obj *objPtr, const char *
        buf = jim_vasprintf( fmt, ap );
        va_end(ap);
 
        buf = jim_vasprintf( fmt, ap );
        va_end(ap);
 
-       if( buf ){
+       if ( buf ){
                Jim_AppendString( interp, objPtr, buf, -1 );
                jim_vasprintf_done(buf);
        }
                Jim_AppendString( interp, objPtr, buf, -1 );
                jim_vasprintf_done(buf);
        }
@@ -2291,7 +2283,7 @@ static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
                haveprec = 0;
                prec = -1; /* not found yet */
     next_fmt:
                haveprec = 0;
                prec = -1; /* not found yet */
     next_fmt:
-               if( fmtLen <= 0 ){
+               if ( fmtLen <= 0 ){
                        break;
                }
                switch( *fmt ){
                        break;
                }
                switch( *fmt ){
@@ -2353,7 +2345,7 @@ static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
                                accum = (accum * 10) + (*fmt - '0');
                                fmt++;  fmtLen--;
                        }
                                accum = (accum * 10) + (*fmt - '0');
                                fmt++;  fmtLen--;
                        }
-                       if( inprec ){
+                       if ( inprec ){
                                haveprec = 1;
                                prec = accum;
                        } else {
                                haveprec = 1;
                                prec = accum;
                        } else {
@@ -2364,24 +2356,24 @@ static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
                        /* suck up the next item as an integer */
                        fmt++;  fmtLen--;
                        objc--;
                        /* suck up the next item as an integer */
                        fmt++;  fmtLen--;
                        objc--;
-                       if( objc <= 0 ){
+                       if ( objc <= 0 ){
                                goto not_enough_args;
                        }
                                goto not_enough_args;
                        }
-                       if( Jim_GetWide(interp,objv[0],&wideValue )== JIM_ERR ){
+                       if ( Jim_GetWide(interp,objv[0],&wideValue )== JIM_ERR ){
                                Jim_FreeNewObj(interp, resObjPtr );
                                return NULL;
                        }
                                Jim_FreeNewObj(interp, resObjPtr );
                                return NULL;
                        }
-                       if( inprec ){
+                       if ( inprec ){
                                haveprec = 1;
                                prec = wideValue;
                                haveprec = 1;
                                prec = wideValue;
-                               if( prec < 0 ){
+                               if ( prec < 0 ){
                                        /* man 3 printf says */
                                        /* if prec is negative, it is zero */
                                        prec = 0;
                                }
                        } else {
                        width = wideValue;
                                        /* man 3 printf says */
                                        /* if prec is negative, it is zero */
                                        prec = 0;
                                }
                        } else {
                        width = wideValue;
-                       if( width < 0 ){
+                       if ( width < 0 ){
                                ljust = 1;
                                width = -width;
                        }
                                ljust = 1;
                                width = -width;
                        }
@@ -2410,32 +2402,32 @@ static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
                 */
                cp = fmt_str;
                *cp++ = '%';
                 */
                cp = fmt_str;
                *cp++ = '%';
-               if( altfm ){
+               if ( altfm ){
                        *cp++ = '#';
                }
                        *cp++ = '#';
                }
-               if( forceplus ){
+               if ( forceplus ){
                        *cp++ = '+';
                        *cp++ = '+';
-               } else if( spad ){
+               } else if ( spad ){
                        /* PLUS overrides */
                        *cp++ = ' ';
                }
                        /* PLUS overrides */
                        *cp++ = ' ';
                }
-               if( ljust ){
+               if ( ljust ){
                        *cp++ = '-';
                }
                        *cp++ = '-';
                }
-               if( zpad  ){
+               if ( zpad  ){
                        *cp++ = '0';
                }
                        *cp++ = '0';
                }
-               if( width > 0 ){
+               if ( width > 0 ){
                        sprintf( cp, "%d", width );
                        /* skip ahead */
                        cp = strchr(cp,0);
                }
                /* did we find a period? */
                        sprintf( cp, "%d", width );
                        /* skip ahead */
                        cp = strchr(cp,0);
                }
                /* did we find a period? */
-               if( inprec ){
+               if ( inprec ){
                        /* then add it */
                        *cp++ = '.';
                        /* did something occur after the period? */
                        /* then add it */
                        *cp++ = '.';
                        /* did something occur after the period? */
-                       if( haveprec ){
+                       if ( haveprec ){
                                sprintf( cp, "%d", prec );
                        }
                        cp = strchr(cp,0);
                                sprintf( cp, "%d", prec );
                        }
                        cp = strchr(cp,0);
@@ -2469,7 +2461,7 @@ static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
                case 'E':
                        *cp++ = *fmt;
                        *cp   = 0;
                case 'E':
                        *cp++ = *fmt;
                        *cp   = 0;
-                       if( Jim_GetDouble( interp, objv[0], &doubleValue ) == JIM_ERR ){
+                       if ( Jim_GetDouble( interp, objv[0], &doubleValue ) == JIM_ERR ){
                                Jim_FreeNewObj( interp, resObjPtr );
                                return NULL;
                        }
                                Jim_FreeNewObj( interp, resObjPtr );
                                return NULL;
                        }
@@ -2483,7 +2475,7 @@ static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
                case 'x':
                case 'X':
                        /* jim widevaluse are 64bit */
                case 'x':
                case 'X':
                        /* jim widevaluse are 64bit */
-                       if( sizeof(jim_wide) == sizeof(long long) ){
+                       if ( sizeof(jim_wide) == sizeof(long long) ){
                                *cp++ = 'l'; 
                                *cp++ = 'l';
                        } else {
                                *cp++ = 'l'; 
                                *cp++ = 'l';
                        } else {
@@ -2635,12 +2627,12 @@ int Jim_GetNvp(Jim_Interp *interp,
        int e;
 
        e = Jim_Nvp_name2value_obj( interp, nvp_table, objPtr, &n );
        int e;
 
        e = Jim_Nvp_name2value_obj( interp, nvp_table, objPtr, &n );
-       if( e == JIM_ERR ){
+       if ( e == JIM_ERR ){
                return e;
        }
 
        /* Success? found? */
                return e;
        }
 
        /* Success? found? */
-       if( n->name ){
+       if ( n->name ){
                /* remove const */
                *result = (Jim_Nvp *)n;
                return JIM_OK;
                /* remove const */
                *result = (Jim_Nvp *)n;
                return JIM_OK;
@@ -3237,7 +3229,7 @@ int Jim_CreateProcedure(Jim_Interp *interp, const char *cmdName,
         Jim_ListLength(interp, staticsListObjPtr, &len);
         if (len != 0) {
             cmdPtr->staticVars = Jim_Alloc(sizeof(Jim_HashTable));
         Jim_ListLength(interp, staticsListObjPtr, &len);
         if (len != 0) {
             cmdPtr->staticVars = Jim_Alloc(sizeof(Jim_HashTable));
-            Jim_InitHashTable(cmdPtr->staticVars, &JimVariablesHashTableType,
+            Jim_InitHashTable(cmdPtr->staticVars, getJimVariablesHashTableType(),
                     interp);
             for (i = 0; i < len; i++) {
                 Jim_Obj *objPtr, *initObjPtr, *nameObjPtr;
                     interp);
             for (i = 0; i < len; i++) {
                 Jim_Obj *objPtr, *initObjPtr, *nameObjPtr;
@@ -3440,6 +3432,11 @@ static Jim_HashTableType JimVariablesHashTableType = {
     JimVariablesHTValDestructor       /* val destructor */
 };
 
     JimVariablesHTValDestructor       /* val destructor */
 };
 
+static Jim_HashTableType *getJimVariablesHashTableType(void)
+{
+       return &JimVariablesHashTableType;
+}
+
 /* -----------------------------------------------------------------------------
  * Variable object
  * ---------------------------------------------------------------------------*/
 /* -----------------------------------------------------------------------------
  * Variable object
  * ---------------------------------------------------------------------------*/
@@ -5922,7 +5919,7 @@ int Jim_DictKey(Jim_Interp *interp, Jim_Obj *dictPtr, Jim_Obj *keyPtr,
 int Jim_DictKeysVector(Jim_Interp *interp, Jim_Obj *dictPtr,
         Jim_Obj *const *keyv, int keyc, Jim_Obj **objPtrPtr, int flags)
 {
 int Jim_DictKeysVector(Jim_Interp *interp, Jim_Obj *dictPtr,
         Jim_Obj *const *keyv, int keyc, Jim_Obj **objPtrPtr, int flags)
 {
-    Jim_Obj *objPtr;
+    Jim_Obj *objPtr = NULL;
     int i;
 
     if (keyc == 0) {
     int i;
 
     if (keyc == 0) {
@@ -7645,6 +7642,8 @@ static int ScanOneEntry(Jim_Interp *interp, const char *str, long pos,
                 scanned += 1;
                 break;
             case 'd': case 'o': case 'x': case 'u': case 'i': {
                 scanned += 1;
                 break;
             case 'd': case 'o': case 'x': case 'u': case 'i': {
+                jim_wide jwvalue = 0;
+                long lvalue = 0;
                 char *endp;  /* Position where the number finished */
                 int base = descr->type == 'o' ? 8
                     : descr->type == 'x' ? 16
                 char *endp;  /* Position where the number finished */
                 int base = descr->type == 'o' ? 8
                     : descr->type == 'x' ? 16
@@ -7654,16 +7653,22 @@ static int ScanOneEntry(Jim_Interp *interp, const char *str, long pos,
                 do {
                     /* Try to scan a number with the given base */
                     if (descr->modifier == 'l')
                 do {
                     /* Try to scan a number with the given base */
                     if (descr->modifier == 'l')
-#ifdef HAVE_LONG_LONG
-                      *(jim_wide*)value = JimStrtoll(tok, &endp, base);
+                    {
+#ifdef HAVE_LONG_LONG_INT
+                        jwvalue = JimStrtoll(tok, &endp, base),
 #else
 #else
-                      *(jim_wide*)value = strtol(tok, &endp, base);
+                        jwvalue = strtol(tok, &endp, base),
 #endif
 #endif
+                        memcpy(value, &jwvalue, sizeof(jim_wide));
+                    }
                     else
                     else
+                    {
                       if (descr->type == 'u')
                       if (descr->type == 'u')
-                        *(long*)value = strtoul(tok, &endp, base);
+                        lvalue = strtoul(tok, &endp, base);
                       else
                       else
-                        *(long*)value = strtol(tok, &endp, base);
+                        lvalue = strtol(tok, &endp, base);
+                      memcpy(value, &lvalue, sizeof(lvalue));
+                    }
                     /* If scanning failed, and base was undetermined, simply
                      * put it to 10 and try once more. This should catch the
                      * case where %i begin to parse a number prefix (e.g. 
                     /* If scanning failed, and base was undetermined, simply
                      * put it to 10 and try once more. This should catch the
                      * case where %i begin to parse a number prefix (e.g. 
@@ -7675,9 +7680,9 @@ static int ScanOneEntry(Jim_Interp *interp, const char *str, long pos,
                 if (endp != tok) {
                     /* There was some number sucessfully scanned! */
                     if (descr->modifier == 'l')
                 if (endp != tok) {
                     /* There was some number sucessfully scanned! */
                     if (descr->modifier == 'l')
-                        *valObjPtr = Jim_NewIntObj(interp, *(jim_wide*)value);
+                        *valObjPtr = Jim_NewIntObj(interp, jwvalue);
                     else
                     else
-                        *valObjPtr = Jim_NewIntObj(interp, *(long*)value);
+                        *valObjPtr = Jim_NewIntObj(interp, lvalue);
                     /* Adjust the number-of-chars scanned so far */
                     scanned += endp - tok;
                 } else {
                     /* Adjust the number-of-chars scanned so far */
                     scanned += endp - tok;
                 } else {
@@ -7696,10 +7701,11 @@ static int ScanOneEntry(Jim_Interp *interp, const char *str, long pos,
             case 'e': case 'f': case 'g': {
                 char *endp;
 
             case 'e': case 'f': case 'g': {
                 char *endp;
 
-                *(double*)value = strtod(tok, &endp);
+                double dvalue = strtod(tok, &endp);
+                memcpy(value, &dvalue, sizeof(double));
                 if (endp != tok) {
                     /* There was some number sucessfully scanned! */
                 if (endp != tok) {
                     /* There was some number sucessfully scanned! */
-                    *valObjPtr = Jim_NewDoubleObj(interp, *(double*)value);
+                    *valObjPtr = Jim_NewDoubleObj(interp, dvalue);
                     /* Adjust the number-of-chars scanned so far */
                     scanned += endp - tok;
                 } else {
                     /* Adjust the number-of-chars scanned so far */
                     scanned += endp - tok;
                 } else {
@@ -8098,17 +8104,17 @@ DIR *opendir(const char *name)
 {
     DIR *dir = 0;
 
 {
     DIR *dir = 0;
 
-    if(name && name[0]) {
+    if (name && name[0]) {
         size_t base_length = strlen(name);
         const char *all = /* search pattern must end with suitable wildcard */
             strchr("/\\", name[base_length - 1]) ? "*" : "/*";
 
         size_t base_length = strlen(name);
         const char *all = /* search pattern must end with suitable wildcard */
             strchr("/\\", name[base_length - 1]) ? "*" : "/*";
 
-        if((dir = (DIR *) Jim_Alloc(sizeof *dir)) != 0 &&
+        if ((dir = (DIR *) Jim_Alloc(sizeof *dir)) != 0 &&
            (dir->name = (char *) Jim_Alloc(base_length + strlen(all) + 1)) != 0)
         {
             strcat(strcpy(dir->name, name), all);
 
            (dir->name = (char *) Jim_Alloc(base_length + strlen(all) + 1)) != 0)
         {
             strcat(strcpy(dir->name, name), all);
 
-            if((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1)
+            if ((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1)
                 dir->result.d_name = 0;
             else { /* rollback */
                 Jim_Free(dir->name);
                 dir->result.d_name = 0;
             else { /* rollback */
                 Jim_Free(dir->name);
@@ -8130,13 +8136,13 @@ int closedir(DIR *dir)
 {
     int result = -1;
 
 {
     int result = -1;
 
-    if(dir) {
-        if(dir->handle != -1)
+    if (dir) {
+        if (dir->handle != -1)
             result = _findclose(dir->handle);
         Jim_Free(dir->name);
         Jim_Free(dir);
     }
             result = _findclose(dir->handle);
         Jim_Free(dir->name);
         Jim_Free(dir);
     }
-    if(result == -1) /* map all errors to EBADF */
+    if (result == -1) /* map all errors to EBADF */
         errno = EBADF;
     return result;
 }
         errno = EBADF;
     return result;
 }
@@ -8145,8 +8151,8 @@ struct dirent *readdir(DIR *dir)
 {
     struct dirent *result = 0;
 
 {
     struct dirent *result = 0;
 
-    if(dir && dir->handle != -1) {
-        if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) {
+    if (dir && dir->handle != -1) {
+        if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) {
             result         = &dir->result;
             result->d_name = dir->info.name;
         }
             result         = &dir->result;
             result->d_name = dir->info.name;
         }
@@ -8888,7 +8894,7 @@ int Jim_Eval_Named(Jim_Interp *interp, const char *script, const char *filename,
     Jim_IncrRefCount(scriptObjPtr);
 
 
     Jim_IncrRefCount(scriptObjPtr);
 
 
-       if( filename ){
+       if ( filename ){
                JimSetSourceInfo( interp, scriptObjPtr, filename, lineno );
        }
 
                JimSetSourceInfo( interp, scriptObjPtr, filename, lineno );
        }
 
@@ -11979,7 +11985,7 @@ static int Jim_EnvCoreCommand(Jim_Interp *interp, int argc,
 
     if (argc == 1) {
 
 
     if (argc == 1) {
 
-#ifndef HAVE_UNISTD_H
+#ifdef NEED_ENVIRON_EXTERN
         extern char **environ;
 #endif
 
         extern char **environ;
 #endif
 
@@ -12406,7 +12412,7 @@ int Jim_fprintf( Jim_Interp *interp, void *cookie, const char *fmt, ... )
 
 int Jim_vfprintf( Jim_Interp *interp, void *cookie, const char *fmt, va_list ap )
 {
 
 int Jim_vfprintf( Jim_Interp *interp, void *cookie, const char *fmt, va_list ap )
 {
-       if( (interp == NULL) || (interp->cb_vfprintf == NULL) ){
+       if ( (interp == NULL) || (interp->cb_vfprintf == NULL) ){
                errno = ENOTSUP;
                return -1;
        }
                errno = ENOTSUP;
                return -1;
        }
@@ -12415,7 +12421,7 @@ int Jim_vfprintf( Jim_Interp *interp, void *cookie, const char *fmt, va_list ap
 
 size_t Jim_fwrite( Jim_Interp *interp, const void *ptr, size_t size, size_t n, void *cookie )
 {
 
 size_t Jim_fwrite( Jim_Interp *interp, const void *ptr, size_t size, size_t n, void *cookie )
 {
-       if( (interp == NULL) || (interp->cb_fwrite == NULL) ){
+       if ( (interp == NULL) || (interp->cb_fwrite == NULL) ){
                errno = ENOTSUP;
                return 0;
        }
                errno = ENOTSUP;
                return 0;
        }
@@ -12424,7 +12430,7 @@ size_t Jim_fwrite( Jim_Interp *interp, const void *ptr, size_t size, size_t n, v
 
 size_t Jim_fread( Jim_Interp *interp, void *ptr, size_t size, size_t n, void *cookie )
 {
 
 size_t Jim_fread( Jim_Interp *interp, void *ptr, size_t size, size_t n, void *cookie )
 {
-       if( (interp == NULL) || (interp->cb_fread == NULL) ){
+       if ( (interp == NULL) || (interp->cb_fread == NULL) ){
                errno = ENOTSUP;
                return 0;
        }
                errno = ENOTSUP;
                return 0;
        }
@@ -12433,7 +12439,7 @@ size_t Jim_fread( Jim_Interp *interp, void *ptr, size_t size, size_t n, void *co
 
 int Jim_fflush( Jim_Interp *interp, void *cookie )
 {
 
 int Jim_fflush( Jim_Interp *interp, void *cookie )
 {
-       if( (interp == NULL) || (interp->cb_fflush == NULL) ){
+       if ( (interp == NULL) || (interp->cb_fflush == NULL) ){
                /* pretend all is well */
                return 0;
        }
                /* pretend all is well */
                return 0;
        }
@@ -12442,7 +12448,7 @@ int Jim_fflush( Jim_Interp *interp, void *cookie )
 
 char* Jim_fgets( Jim_Interp *interp, char *s, int size, void *cookie )
 {
 
 char* Jim_fgets( Jim_Interp *interp, char *s, int size, void *cookie )
 {
-       if( (interp == NULL) || (interp->cb_fgets == NULL) ){
+       if ( (interp == NULL) || (interp->cb_fgets == NULL) ){
                errno = ENOTSUP;
                return NULL;
        }
                errno = ENOTSUP;
                return NULL;
        }
@@ -12452,7 +12458,7 @@ Jim_Nvp *
 Jim_Nvp_name2value_simple( const Jim_Nvp *p, const char *name )
 {
        while( p->name ){
 Jim_Nvp_name2value_simple( const Jim_Nvp *p, const char *name )
 {
        while( p->name ){
-               if( 0 == strcmp( name, p->name ) ){
+               if ( 0 == strcmp( name, p->name ) ){
                        break;
                }
                p++;
                        break;
                }
                p++;
@@ -12464,7 +12470,7 @@ Jim_Nvp *
 Jim_Nvp_name2value_nocase_simple( const Jim_Nvp *p, const char *name )
 {
        while( p->name ){
 Jim_Nvp_name2value_nocase_simple( const Jim_Nvp *p, const char *name )
 {
        while( p->name ){
-               if( 0 == strcasecmp( name, p->name ) ){
+               if ( 0 == strcasecmp( name, p->name ) ){
                        break;
                }
                p++;
                        break;
                }
                p++;
@@ -12493,12 +12499,12 @@ Jim_Nvp_name2value( Jim_Interp *interp,
        p = Jim_Nvp_name2value_simple( _p, name );
 
        /* result */
        p = Jim_Nvp_name2value_simple( _p, name );
 
        /* result */
-       if( result ){
+       if ( result ){
                *result = (Jim_Nvp *)(p);
        }
        
        /* found? */
                *result = (Jim_Nvp *)(p);
        }
        
        /* found? */
-       if( p->name ){
+       if ( p->name ){
                return JIM_OK;
        } else {
                return JIM_ERR;
                return JIM_OK;
        } else {
                return JIM_ERR;
@@ -12518,11 +12524,11 @@ Jim_Nvp_name2value_nocase( Jim_Interp *interp, const Jim_Nvp *_p, const char *na
 
        p = Jim_Nvp_name2value_nocase_simple( _p, name );
 
 
        p = Jim_Nvp_name2value_nocase_simple( _p, name );
 
-       if( puthere ){
+       if ( puthere ){
                *puthere = (Jim_Nvp *)(p);
        }
        /* found */
                *puthere = (Jim_Nvp *)(p);
        }
        /* found */
-       if( p->name ){
+       if ( p->name ){
                return JIM_OK;
        } else {
                return JIM_ERR;
                return JIM_OK;
        } else {
                return JIM_ERR;
@@ -12537,7 +12543,7 @@ Jim_Nvp_value2name_obj( Jim_Interp *interp, const Jim_Nvp *p, Jim_Obj *o, Jim_Nv
        jim_wide w;
 
        e = Jim_GetWide( interp, o, &w );
        jim_wide w;
 
        e = Jim_GetWide( interp, o, &w );
-       if( e != JIM_OK ){
+       if ( e != JIM_OK ){
                return e;
        }
 
                return e;
        }
 
@@ -12548,7 +12554,7 @@ Jim_Nvp *
 Jim_Nvp_value2name_simple( const Jim_Nvp *p, int value )
 {
        while( p->name ){
 Jim_Nvp_value2name_simple( const Jim_Nvp *p, int value )
 {
        while( p->name ){
-               if( value == p->value ){
+               if ( value == p->value ){
                        break;
                }
                p++;
                        break;
                }
                p++;
@@ -12564,11 +12570,11 @@ Jim_Nvp_value2name( Jim_Interp *interp, const Jim_Nvp *_p, int value, Jim_Nvp **
 
        p = Jim_Nvp_value2name_simple( _p, value );
 
 
        p = Jim_Nvp_value2name_simple( _p, value );
 
-       if( result ){
+       if ( result ){
                *result = (Jim_Nvp *)(p);
        }
 
                *result = (Jim_Nvp *)(p);
        }
 
-       if( p->name ){
+       if ( p->name ){
                return JIM_OK;
        } else {
                return JIM_ERR;
                return JIM_OK;
        } else {
                return JIM_ERR;
@@ -12609,16 +12615,16 @@ Jim_GetOpt_Obj( Jim_GetOptInfo *goi, Jim_Obj **puthere )
        Jim_Obj *o;
        
        o = NULL; // failure 
        Jim_Obj *o;
        
        o = NULL; // failure 
-       if( goi->argc ){
+       if ( goi->argc ){
                // success 
                o = goi->argv[0];
                goi->argc -= 1;
                goi->argv += 1;
        }
                // success 
                o = goi->argv[0];
                goi->argc -= 1;
                goi->argv += 1;
        }
-       if( puthere ){
+       if ( puthere ){
                *puthere = o;
        }
                *puthere = o;
        }
-       if( o != NULL ){
+       if ( o != NULL ){
                return JIM_OK;
        } else {
                return JIM_ERR;
                return JIM_OK;
        } else {
                return JIM_ERR;
@@ -12634,9 +12640,9 @@ Jim_GetOpt_String( Jim_GetOptInfo *goi, char **puthere, int *len )
 
 
        r = Jim_GetOpt_Obj( goi, &o );
 
 
        r = Jim_GetOpt_Obj( goi, &o );
-       if( r == JIM_OK ){
+       if ( r == JIM_OK ){
                cp = Jim_GetString( o, len );
                cp = Jim_GetString( o, len );
-               if( puthere ){
+               if ( puthere ){
                        /* remove const */
                        *puthere = (char *)(cp);
                }
                        /* remove const */
                        *puthere = (char *)(cp);
                }
@@ -12651,14 +12657,14 @@ Jim_GetOpt_Double( Jim_GetOptInfo *goi, double *puthere )
        Jim_Obj *o;
        double _safe;
        
        Jim_Obj *o;
        double _safe;
        
-       if( puthere == NULL ){
+       if ( puthere == NULL ){
                puthere = &_safe;
        }
 
        r = Jim_GetOpt_Obj( goi, &o );
                puthere = &_safe;
        }
 
        r = Jim_GetOpt_Obj( goi, &o );
-       if( r == JIM_OK ){
+       if ( r == JIM_OK ){
                r = Jim_GetDouble( goi->interp, o, puthere );
                r = Jim_GetDouble( goi->interp, o, puthere );
-               if( r != JIM_OK ){
+               if ( r != JIM_OK ){
                        Jim_SetResult_sprintf( goi->interp,
                                                                   "not a number: %s", 
                                                                   Jim_GetString( o, NULL ) );
                        Jim_SetResult_sprintf( goi->interp,
                                                                   "not a number: %s", 
                                                                   Jim_GetString( o, NULL ) );
@@ -12674,12 +12680,12 @@ Jim_GetOpt_Wide( Jim_GetOptInfo *goi, jim_wide *puthere )
        Jim_Obj *o;
        jim_wide _safe;
 
        Jim_Obj *o;
        jim_wide _safe;
 
-       if( puthere == NULL ){
+       if ( puthere == NULL ){
                puthere = &_safe;
        }
 
        r = Jim_GetOpt_Obj( goi, &o );
                puthere = &_safe;
        }
 
        r = Jim_GetOpt_Obj( goi, &o );
-       if( r == JIM_OK ){
+       if ( r == JIM_OK ){
                r = Jim_GetWide( goi->interp, o, puthere );
        }
        return r;
                r = Jim_GetWide( goi->interp, o, puthere );
        }
        return r;
@@ -12693,12 +12699,12 @@ int Jim_GetOpt_Nvp( Jim_GetOptInfo *goi,
        Jim_Obj *o;
        int e;
 
        Jim_Obj *o;
        int e;
 
-       if( puthere == NULL ){
+       if ( puthere == NULL ){
                puthere = &_safe;
        }
 
        e = Jim_GetOpt_Obj( goi, &o );
                puthere = &_safe;
        }
 
        e = Jim_GetOpt_Obj( goi, &o );
-       if( e == JIM_OK ){
+       if ( e == JIM_OK ){
                e = Jim_Nvp_name2value_obj( goi->interp,
                                                                        nvp, 
                                                                        o,
                e = Jim_Nvp_name2value_obj( goi->interp,
                                                                        nvp, 
                                                                        o,
@@ -12713,7 +12719,7 @@ Jim_GetOpt_NvpUnknown( Jim_GetOptInfo *goi,
                                           const Jim_Nvp *nvptable,
                                           int hadprefix )
 {
                                           const Jim_Nvp *nvptable,
                                           int hadprefix )
 {
-       if( hadprefix ){
+       if ( hadprefix ){
                Jim_SetResult_NvpUnknown( goi->interp,
                                                                  goi->argv[-2],
                                                                  goi->argv[-1],
                Jim_SetResult_NvpUnknown( goi->interp,
                                                                  goi->argv[-2],
                                                                  goi->argv[-1],
@@ -12736,11 +12742,11 @@ Jim_GetOpt_Enum( Jim_GetOptInfo *goi,
        Jim_Obj *o;
        int e;
 
        Jim_Obj *o;
        int e;
 
-       if( puthere == NULL ){
+       if ( puthere == NULL ){
                puthere = &_safe;
        }
        e = Jim_GetOpt_Obj( goi, &o );
                puthere = &_safe;
        }
        e = Jim_GetOpt_Obj( goi, &o );
-       if( e == JIM_OK ){
+       if ( e == JIM_OK ){
                e = Jim_GetEnum( goi->interp,
                                                 o,
                                                 lookup,
                e = Jim_GetEnum( goi->interp,
                                                 o,
                                                 lookup,
@@ -12762,7 +12768,7 @@ Jim_SetResult_sprintf( Jim_Interp *interp, const char *fmt,... )
        va_start(ap,fmt);
        buf = jim_vasprintf( fmt, ap );
        va_end(ap);
        va_start(ap,fmt);
        buf = jim_vasprintf( fmt, ap );
        va_end(ap);
-       if( buf ){
+       if ( buf ){
                Jim_SetResultString( interp, buf, -1 );
                jim_vasprintf_done(buf);
        }
                Jim_SetResultString( interp, buf, -1 );
                jim_vasprintf_done(buf);
        }
@@ -12776,7 +12782,7 @@ Jim_SetResult_NvpUnknown( Jim_Interp *interp,
                                                  Jim_Obj *param_value,
                                                  const Jim_Nvp *nvp )
 {
                                                  Jim_Obj *param_value,
                                                  const Jim_Nvp *nvp )
 {
-       if( param_name ){
+       if ( param_name ){
                Jim_SetResult_sprintf( interp,
                                                           "%s: Unknown: %s, try one of: ",
                                                           Jim_GetString( param_name, NULL ),
                Jim_SetResult_sprintf( interp,
                                                           "%s: Unknown: %s, try one of: ",
                                                           Jim_GetString( param_name, NULL ),
@@ -12790,7 +12796,7 @@ Jim_SetResult_NvpUnknown( Jim_Interp *interp,
                const char *a;
                const char *b;
 
                const char *a;
                const char *b;
 
-               if( (nvp+1)->name ){
+               if ( (nvp+1)->name ){
                        a = nvp->name;
                        b = ", ";
                } else {
                        a = nvp->name;
                        b = ", ";
                } else {
@@ -12812,7 +12818,7 @@ Jim_Debug_ArgvString( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
 {
        int x;
 
 {
        int x;
 
-       if( debug_string_obj ){
+       if ( debug_string_obj ){
                Jim_FreeObj( interp, debug_string_obj );
        }
 
                Jim_FreeObj( interp, debug_string_obj );
        }
 
@@ -12827,12 +12833,3 @@ Jim_Debug_ArgvString( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
 
        return Jim_GetString( debug_string_obj, NULL );
 }
 
        return Jim_GetString( debug_string_obj, NULL );
 }
-
-       
-
-/*
- * Local Variables: ***
- * c-basic-offset: 4 ***
- * tab-width: 4 ***
- * End: ***
- */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)