diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2024-04-11 10:54:13 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2024-04-11 10:54:13 (GMT) |
commit | e0977e799934f1579c1eaf677439a2a1d20c4adb (patch) | |
tree | 07ae6c41179dd4b3e33fb39b7820bf37818a0b56 | |
parent | 6d5bb92136f89aa1d36b71aab42657a073ec5058 (diff) | |
download | tcl-e0977e799934f1579c1eaf677439a2a1d20c4adb.zip tcl-e0977e799934f1579c1eaf677439a2a1d20c4adb.tar.gz tcl-e0977e799934f1579c1eaf677439a2a1d20c4adb.tar.bz2 |
Style cleanup
-rw-r--r-- | generic/tclStrIdxTree.h | 127 |
1 files changed, 65 insertions, 62 deletions
diff --git a/generic/tclStrIdxTree.h b/generic/tclStrIdxTree.h index 5052823..28e0710 100644 --- a/generic/tclStrIdxTree.h +++ b/generic/tclStrIdxTree.h @@ -13,26 +13,26 @@ #ifndef _TCLSTRIDXTREE_H #define _TCLSTRIDXTREE_H - /* * Main structures declarations of index tree and entry */ +typedef struct TclStrIdx TclStrIdx; + typedef struct TclStrIdxTree { - struct TclStrIdx *firstPtr; - struct TclStrIdx *lastPtr; + TclStrIdx *firstPtr; + TclStrIdx *lastPtr; } TclStrIdxTree; -typedef struct TclStrIdx { - struct TclStrIdxTree childTree; - struct TclStrIdx *nextPtr; - struct TclStrIdx *prevPtr; - Tcl_Obj *key; +struct TclStrIdx { + TclStrIdxTree childTree; + TclStrIdx *nextPtr; + TclStrIdx *prevPtr; + Tcl_Obj *key; Tcl_Size length; - void *value; -} TclStrIdx; - - + void *value; +}; + /* *---------------------------------------------------------------------- * @@ -51,38 +51,44 @@ typedef struct TclStrIdx { static inline const char * TclUtfFindEqual( - const char *cs, /* UTF string to find in cin. */ - const char *cse, /* End of cs */ - const char *cin, /* UTF string will be browsed. */ - const char *cine) /* End of cin */ + const char *cs, /* UTF string to find in cin. */ + const char *cse, /* End of cs */ + const char *cin, /* UTF string will be browsed. */ + const char *cine) /* End of cin */ { const char *ret = cs; Tcl_UniChar ch1, ch2; + do { cs += TclUtfToUniChar(cs, &ch1); cin += TclUtfToUniChar(cin, &ch2); - if (ch1 != ch2) break; + if (ch1 != ch2) { + break; + } } while ((ret = cs) < cse && cin < cine); return ret; } static inline const char * TclUtfFindEqualNC( - const char *cs, /* UTF string to find in cin. */ - const char *cse, /* End of cs */ - const char *cin, /* UTF string will be browsed. */ - const char *cine, /* End of cin */ - const char **cinfnd) /* Return position in cin */ + const char *cs, /* UTF string to find in cin. */ + const char *cse, /* End of cs */ + const char *cin, /* UTF string will be browsed. */ + const char *cine, /* End of cin */ + const char **cinfnd) /* Return position in cin */ { const char *ret = cs; Tcl_UniChar ch1, ch2; + do { cs += TclUtfToUniChar(cs, &ch1); cin += TclUtfToUniChar(cin, &ch2); if (ch1 != ch2) { ch1 = Tcl_UniCharToLower(ch1); ch2 = Tcl_UniCharToLower(ch2); - if (ch1 != ch2) break; + if (ch1 != ch2) { + break; + } } *cinfnd = cin; } while ((ret = cs) < cse && cin < cine); @@ -91,20 +97,23 @@ TclUtfFindEqualNC( static inline const char * TclUtfFindEqualNCInLwr( - const char *cs, /* UTF string (in anycase) to find in cin. */ - const char *cse, /* End of cs */ - const char *cin, /* UTF string (in lowercase) will be browsed. */ - const char *cine, /* End of cin */ - const char **cinfnd) /* Return position in cin */ + const char *cs, /* UTF string (in anycase) to find in cin. */ + const char *cse, /* End of cs */ + const char *cin, /* UTF string (in lowercase) will be browsed. */ + const char *cine, /* End of cin */ + const char **cinfnd) /* Return position in cin */ { const char *ret = cs; Tcl_UniChar ch1, ch2; + do { cs += TclUtfToUniChar(cs, &ch1); cin += TclUtfToUniChar(cin, &ch2); if (ch1 != ch2) { ch1 = Tcl_UniCharToLower(ch1); - if (ch1 != ch2) break; + if (ch1 != ch2) { + break; + } } *cinfnd = cin; } while ((ret = cs) < cse && cin < cine); @@ -116,48 +125,42 @@ TclUtfFindEqualNCInLwr( */ #define TclUnsetObjRef(obj) \ - do { \ - if (obj != NULL) { \ - Tcl_DecrRefCount(obj); \ - obj = NULL; \ - } \ + do { \ + if (obj != NULL) { \ + Tcl_DecrRefCount(obj); \ + obj = NULL; \ + } \ } while (0) #define TclInitObjRef(obj, val) \ - do { \ - obj = val; \ - if (obj) { \ - Tcl_IncrRefCount(obj); \ - } \ + do { \ + obj = val; \ + if (obj) { \ + Tcl_IncrRefCount(obj); \ + } \ } while (0) #define TclSetObjRef(obj, val) \ - do { \ - Tcl_Obj *nval = val; \ - if (obj != nval) { \ - Tcl_Obj *prev = obj; \ - TclInitObjRef(obj, nval); \ - if (prev != NULL) { \ - Tcl_DecrRefCount(prev); \ - }; \ - } \ + do { \ + Tcl_Obj *nval = val; \ + if (obj != nval) { \ + Tcl_Obj *prev = obj; \ + TclInitObjRef(obj, nval); \ + if (prev != NULL) { \ + Tcl_DecrRefCount(prev); \ + } \ + } \ } while (0) - + /* * Prototypes of module functions. */ -MODULE_SCOPE const char* - TclStrIdxTreeSearch(TclStrIdxTree **foundParent, - TclStrIdx **foundItem, TclStrIdxTree *tree, - const char *start, const char *end); - -MODULE_SCOPE int TclStrIdxTreeBuildFromList(TclStrIdxTree *idxTree, - Tcl_Size lstc, Tcl_Obj **lstv, void **values); - -MODULE_SCOPE Tcl_Obj* - TclStrIdxTreeNewObj(); - -MODULE_SCOPE TclStrIdxTree* - TclStrIdxTreeGetFromObj(Tcl_Obj *objPtr); +MODULE_SCOPE const char*TclStrIdxTreeSearch(TclStrIdxTree **foundParent, + TclStrIdx **foundItem, TclStrIdxTree *tree, + const char *start, const char *end); +MODULE_SCOPE int TclStrIdxTreeBuildFromList(TclStrIdxTree *idxTree, + Tcl_Size lstc, Tcl_Obj **lstv, void **values); +MODULE_SCOPE Tcl_Obj * TclStrIdxTreeNewObj(); +MODULE_SCOPE TclStrIdxTree*TclStrIdxTreeGetFromObj(Tcl_Obj *objPtr); #if 0 /* currently unused, debug resp. test purposes only */ |