Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/blenkernel/intern/suggestions.c
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/blenkernel/intern/suggestions.c')
-rw-r--r--source/blender/blenkernel/intern/suggestions.c277
1 files changed, 140 insertions, 137 deletions
diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c
index f3f919d0048..7631afaa680 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -21,7 +21,6 @@
* \ingroup bke
*/
-
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
@@ -44,23 +43,23 @@ static char *documentation = NULL;
static void txttl_free_suggest(void)
{
- SuggItem *item, *prev;
- for (item = suggestions.last; item; item = prev) {
- prev = item->prev;
- MEM_freeN(item);
- }
- suggestions.first = suggestions.last = NULL;
- suggestions.firstmatch = suggestions.lastmatch = NULL;
- suggestions.selected = NULL;
- suggestions.top = 0;
+ SuggItem *item, *prev;
+ for (item = suggestions.last; item; item = prev) {
+ prev = item->prev;
+ MEM_freeN(item);
+ }
+ suggestions.first = suggestions.last = NULL;
+ suggestions.firstmatch = suggestions.lastmatch = NULL;
+ suggestions.selected = NULL;
+ suggestions.top = 0;
}
static void txttl_free_docs(void)
{
- if (documentation) {
- MEM_freeN(documentation);
- documentation = NULL;
- }
+ if (documentation) {
+ MEM_freeN(documentation);
+ documentation = NULL;
+ }
}
/**************************/
@@ -69,26 +68,27 @@ static void txttl_free_docs(void)
void free_texttools(void)
{
- txttl_free_suggest();
- txttl_free_docs();
+ txttl_free_suggest();
+ txttl_free_docs();
}
void texttool_text_set_active(Text *text)
{
- if (activeToolText == text) return;
- texttool_text_clear();
- activeToolText = text;
+ if (activeToolText == text)
+ return;
+ texttool_text_clear();
+ activeToolText = text;
}
void texttool_text_clear(void)
{
- free_texttools();
- activeToolText = NULL;
+ free_texttools();
+ activeToolText = NULL;
}
short texttool_text_is_active(Text *text)
{
- return activeToolText == text ? 1 : 0;
+ return activeToolText == text ? 1 : 0;
}
/***************************/
@@ -97,125 +97,127 @@ short texttool_text_is_active(Text *text)
void texttool_suggest_add(const char *name, char type)
{
- const int len = strlen(name);
- int cmp;
- SuggItem *newitem, *item;
-
- newitem = MEM_mallocN(sizeof(SuggItem) + len + 1, "SuggItem");
- if (!newitem) {
- printf("Failed to allocate memory for suggestion.\n");
- return;
- }
-
- memcpy(newitem->name, name, len + 1);
- newitem->type = type;
- newitem->prev = newitem->next = NULL;
-
- /* Perform simple linear search for ordered storage */
- if (!suggestions.first || !suggestions.last) {
- suggestions.first = suggestions.last = newitem;
- }
- else {
- cmp = -1;
- for (item = suggestions.last; item; item = item->prev) {
- cmp = BLI_strncasecmp(name, item->name, len);
-
- /* Newitem comes after this item, insert here */
- if (cmp >= 0) {
- newitem->prev = item;
- if (item->next)
- item->next->prev = newitem;
- newitem->next = item->next;
- item->next = newitem;
-
- /* At last item, set last pointer here */
- if (item == suggestions.last)
- suggestions.last = newitem;
- break;
- }
- }
- /* Reached beginning of list, insert before first */
- if (cmp < 0) {
- newitem->next = suggestions.first;
- suggestions.first->prev = newitem;
- suggestions.first = newitem;
- }
- }
- suggestions.firstmatch = suggestions.lastmatch = suggestions.selected = NULL;
- suggestions.top = 0;
+ const int len = strlen(name);
+ int cmp;
+ SuggItem *newitem, *item;
+
+ newitem = MEM_mallocN(sizeof(SuggItem) + len + 1, "SuggItem");
+ if (!newitem) {
+ printf("Failed to allocate memory for suggestion.\n");
+ return;
+ }
+
+ memcpy(newitem->name, name, len + 1);
+ newitem->type = type;
+ newitem->prev = newitem->next = NULL;
+
+ /* Perform simple linear search for ordered storage */
+ if (!suggestions.first || !suggestions.last) {
+ suggestions.first = suggestions.last = newitem;
+ }
+ else {
+ cmp = -1;
+ for (item = suggestions.last; item; item = item->prev) {
+ cmp = BLI_strncasecmp(name, item->name, len);
+
+ /* Newitem comes after this item, insert here */
+ if (cmp >= 0) {
+ newitem->prev = item;
+ if (item->next)
+ item->next->prev = newitem;
+ newitem->next = item->next;
+ item->next = newitem;
+
+ /* At last item, set last pointer here */
+ if (item == suggestions.last)
+ suggestions.last = newitem;
+ break;
+ }
+ }
+ /* Reached beginning of list, insert before first */
+ if (cmp < 0) {
+ newitem->next = suggestions.first;
+ suggestions.first->prev = newitem;
+ suggestions.first = newitem;
+ }
+ }
+ suggestions.firstmatch = suggestions.lastmatch = suggestions.selected = NULL;
+ suggestions.top = 0;
}
void texttool_suggest_prefix(const char *prefix, const int prefix_len)
{
- SuggItem *match, *first, *last;
- int cmp, top = 0;
-
- if (!suggestions.first) return;
- if (prefix_len == 0) {
- suggestions.selected = suggestions.firstmatch = suggestions.first;
- suggestions.lastmatch = suggestions.last;
- return;
- }
-
- first = last = NULL;
- for (match = suggestions.first; match; match = match->next) {
- cmp = BLI_strncasecmp(prefix, match->name, prefix_len);
- if (cmp == 0) {
- if (!first) {
- first = match;
- suggestions.top = top;
- }
- }
- else if (cmp < 0) {
- if (!last) {
- last = match->prev;
- break;
- }
- }
- top++;
- }
- if (first) {
- if (!last) last = suggestions.last;
- suggestions.firstmatch = first;
- suggestions.lastmatch = last;
- suggestions.selected = first;
- }
- else {
- suggestions.firstmatch = NULL;
- suggestions.lastmatch = NULL;
- suggestions.selected = NULL;
- suggestions.top = 0;
- }
+ SuggItem *match, *first, *last;
+ int cmp, top = 0;
+
+ if (!suggestions.first)
+ return;
+ if (prefix_len == 0) {
+ suggestions.selected = suggestions.firstmatch = suggestions.first;
+ suggestions.lastmatch = suggestions.last;
+ return;
+ }
+
+ first = last = NULL;
+ for (match = suggestions.first; match; match = match->next) {
+ cmp = BLI_strncasecmp(prefix, match->name, prefix_len);
+ if (cmp == 0) {
+ if (!first) {
+ first = match;
+ suggestions.top = top;
+ }
+ }
+ else if (cmp < 0) {
+ if (!last) {
+ last = match->prev;
+ break;
+ }
+ }
+ top++;
+ }
+ if (first) {
+ if (!last)
+ last = suggestions.last;
+ suggestions.firstmatch = first;
+ suggestions.lastmatch = last;
+ suggestions.selected = first;
+ }
+ else {
+ suggestions.firstmatch = NULL;
+ suggestions.lastmatch = NULL;
+ suggestions.selected = NULL;
+ suggestions.top = 0;
+ }
}
void texttool_suggest_clear(void)
{
- txttl_free_suggest();
+ txttl_free_suggest();
}
SuggItem *texttool_suggest_first(void)
{
- return suggestions.firstmatch;
+ return suggestions.firstmatch;
}
SuggItem *texttool_suggest_last(void)
{
- return suggestions.lastmatch;
+ return suggestions.lastmatch;
}
void texttool_suggest_select(SuggItem *sel)
{
- suggestions.selected = sel;
+ suggestions.selected = sel;
}
SuggItem *texttool_suggest_selected(void)
{
- return suggestions.selected;
+ return suggestions.selected;
}
int *texttool_suggest_top(void)
{
- return &suggestions.top;
+ return &suggestions.top;
}
/*************************/
@@ -224,36 +226,37 @@ int *texttool_suggest_top(void)
void texttool_docs_show(const char *docs)
{
- int len;
-
- if (!docs) return;
-
- len = strlen(docs);
-
- if (documentation) {
- MEM_freeN(documentation);
- documentation = NULL;
- }
-
- /* Ensure documentation ends with a '\n' */
- if (docs[len - 1] != '\n') {
- documentation = MEM_mallocN(len + 2, "Documentation");
- memcpy(documentation, docs, len);
- documentation[len++] = '\n';
- }
- else {
- documentation = MEM_mallocN(len + 1, "Documentation");
- memcpy(documentation, docs, len);
- }
- documentation[len] = '\0';
+ int len;
+
+ if (!docs)
+ return;
+
+ len = strlen(docs);
+
+ if (documentation) {
+ MEM_freeN(documentation);
+ documentation = NULL;
+ }
+
+ /* Ensure documentation ends with a '\n' */
+ if (docs[len - 1] != '\n') {
+ documentation = MEM_mallocN(len + 2, "Documentation");
+ memcpy(documentation, docs, len);
+ documentation[len++] = '\n';
+ }
+ else {
+ documentation = MEM_mallocN(len + 1, "Documentation");
+ memcpy(documentation, docs, len);
+ }
+ documentation[len] = '\0';
}
char *texttool_docs_get(void)
{
- return documentation;
+ return documentation;
}
void texttool_docs_clear(void)
{
- txttl_free_docs();
+ txttl_free_docs();
}