diff options
author | Campbell Barton <campbell@blender.org> | 2022-06-17 10:14:04 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-06-17 10:15:06 +0300 |
commit | 5cda99ff526449e3d4b564b6d10e552a1703b96f (patch) | |
tree | 6582883a5bb0834870780df32743e9ccfc862172 /intern | |
parent | c756d08b4a5349362af09c78974b3ca310ab5037 (diff) |
Cleanup: clang-tidy for GHOST
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/GHOST_Rect.h | 36 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_DropTargetX11.cpp | 19 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventPrinter.cpp | 17 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_NDOFManager.cpp | 11 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_NDOFManagerUnix.cpp | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_System.cpp | 16 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemX11.cpp | 144 |
7 files changed, 149 insertions, 100 deletions
diff --git a/intern/ghost/GHOST_Rect.h b/intern/ghost/GHOST_Rect.h index 0a5561b7d68..a8082bf015a 100644 --- a/intern/ghost/GHOST_Rect.h +++ b/intern/ghost/GHOST_Rect.h @@ -190,26 +190,34 @@ inline bool GHOST_Rect::isValid() const inline void GHOST_Rect::unionRect(const GHOST_Rect &r) { - if (r.m_l < m_l) + if (r.m_l < m_l) { m_l = r.m_l; - if (r.m_r > m_r) + } + if (r.m_r > m_r) { m_r = r.m_r; - if (r.m_t < m_t) + } + if (r.m_t < m_t) { m_t = r.m_t; - if (r.m_b > m_b) + } + if (r.m_b > m_b) { m_b = r.m_b; + } } inline void GHOST_Rect::unionPoint(int32_t x, int32_t y) { - if (x < m_l) + if (x < m_l) { m_l = x; - if (x > m_r) + } + if (x > m_r) { m_r = x; - if (y < m_t) + } + if (y < m_t) { m_t = y; - if (y > m_b) + } + if (y > m_b) { m_b = y; + } } inline void GHOST_Rect::wrapPoint(int32_t &x, int32_t &y, int32_t ofs, GHOST_TAxisFlag axis) @@ -223,16 +231,20 @@ inline void GHOST_Rect::wrapPoint(int32_t &x, int32_t &y, int32_t ofs, GHOST_TAx } if (axis & GHOST_kAxisX) { - while (x - ofs < m_l) + while (x - ofs < m_l) { x += w - (ofs * 2); - while (x + ofs > m_r) + } + while (x + ofs > m_r) { x -= w - (ofs * 2); + } } if (axis & GHOST_kGrabAxisY) { - while (y - ofs < m_t) + while (y - ofs < m_t) { y += h - (ofs * 2); - while (y + ofs > m_b) + } + while (y + ofs > m_b) { y -= h - (ofs * 2); + } } } diff --git a/intern/ghost/intern/GHOST_DropTargetX11.cpp b/intern/ghost/intern/GHOST_DropTargetX11.cpp index 70c2eb8c29e..900e46c3732 100644 --- a/intern/ghost/intern/GHOST_DropTargetX11.cpp +++ b/intern/ghost/intern/GHOST_DropTargetX11.cpp @@ -31,7 +31,7 @@ int GHOST_DropTargetX11::m_refCounter = 0; #define dndTypePlainText m_dndTypes[dndTypePlainTextID] #define dndTypeOctetStream m_dndTypes[dndTypeOctetStreamID] -void GHOST_DropTargetX11::Initialize(void) +void GHOST_DropTargetX11::Initialize() { Display *display = m_system->getXDisplay(); int dndTypesCount = sizeof(m_dndMimeTypes) / sizeof(char *); @@ -60,7 +60,7 @@ void GHOST_DropTargetX11::Initialize(void) m_dndActions[counter++] = 0; } -void GHOST_DropTargetX11::Uninitialize(void) +void GHOST_DropTargetX11::Uninitialize() { xdnd_shut(&m_dndClass); @@ -98,12 +98,12 @@ GHOST_DropTargetX11::~GHOST_DropTargetX11() /* Based on: https://stackoverflow.com/a/2766963/432509 */ -typedef enum DecodeState_e { +using DecodeState_e = enum DecodeState_e { /** Searching for an ampersand to convert. */ STATE_SEARCH = 0, /** Convert the two proceeding characters from hex. */ STATE_CONVERTING -} DecodeState_e; +}; void GHOST_DropTargetX11::UrlDecode(char *decodedOut, int bufferSize, const char *encodedIn) { @@ -122,7 +122,7 @@ void GHOST_DropTargetX11::UrlDecode(char *decodedOut, int bufferSize, const char case STATE_SEARCH: if (encodedIn[i] != '%') { strncat(decodedOut, &encodedIn[i], 1); - assert(strlen(decodedOut) < bufferSize); + assert((int)strlen(decodedOut) < bufferSize); break; } @@ -145,18 +145,19 @@ void GHOST_DropTargetX11::UrlDecode(char *decodedOut, int bufferSize, const char /* Ensure both characters are hexadecimal */ for (j = 0; j < 2; ++j) { - if (!isxdigit(tempNumBuf[j])) + if (!isxdigit(tempNumBuf[j])) { bothDigits = false; + } } - if (!bothDigits) + if (!bothDigits) { break; - + } /* Convert two hexadecimal characters into one character */ sscanf(tempNumBuf, "%x", &asciiCharacter); /* Ensure we aren't going to overflow */ - assert(strlen(decodedOut) < bufferSize); + assert((int)strlen(decodedOut) < bufferSize); /* Concatenate this character onto the output */ strncat(decodedOut, (char *)&asciiCharacter, 1); diff --git a/intern/ghost/intern/GHOST_EventPrinter.cpp b/intern/ghost/intern/GHOST_EventPrinter.cpp index 758938e879e..2620bcc075d 100644 --- a/intern/ghost/intern/GHOST_EventPrinter.cpp +++ b/intern/ghost/intern/GHOST_EventPrinter.cpp @@ -12,7 +12,7 @@ #include "GHOST_EventKey.h" #include <iostream> -#include <stdio.h> +#include <cstdio> bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event) { @@ -20,9 +20,9 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event) GHOST_ASSERT(event, "event==0"); - if (event->getType() == GHOST_kEventWindowUpdate) + if (event->getType() == GHOST_kEventWindowUpdate) { return false; - + } std::cout << "GHOST_EventPrinter::processEvent, time: " << (int32_t)event->getTime() << ", type: "; switch (event->getType()) { @@ -106,8 +106,9 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event) std::cout << " type : GHOST_kDragnDropTypeFilenames,"; std::cout << "\n Received " << strArray->count << " filename" << (strArray->count > 1 ? "s:" : ":"); - for (i = 0; i < strArray->count; i++) + for (i = 0; i < strArray->count; i++) { std::cout << "\n File[" << i << "] : " << strArray->strings[i]; + } } break; default: break; @@ -117,10 +118,12 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent *event) case GHOST_kEventOpenMainFile: { GHOST_TEventDataPtr eventData = ((GHOST_IEvent *)event)->getData(); - if (eventData) + if (eventData) { std::cout << "GHOST_kEventOpenMainFile for path : " << (char *)eventData; - else + } + else { std::cout << "GHOST_kEventOpenMainFile with no path specified!!"; + } } break; case GHOST_kEventQuitRequest: @@ -167,7 +170,7 @@ void GHOST_EventPrinter::getKeyString(GHOST_TKey key, char str[32]) const sprintf(str, "F%d", key - GHOST_kKeyF1 + 1); } else { - const char *tstr = NULL; + const char *tstr = nullptr; switch (key) { case GHOST_kKeyBackSpace: tstr = "BackSpace"; diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp index 7f6b5f53316..2298ba86521 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.cpp +++ b/intern/ghost/intern/GHOST_NDOFManager.cpp @@ -6,10 +6,10 @@ #include "GHOST_EventNDOF.h" #include "GHOST_WindowManager.h" -#include <limits.h> -#include <math.h> -#include <stdio.h> /* For error/info reporting. */ -#include <string.h> /* For memory functions. */ +#include <climits> +#include <cmath> +#include <cstdio> /* For error/info reporting. */ +#include <cstring> /* For memory functions. */ #ifdef DEBUG_NDOF_MOTION /* Printable version of each GHOST_TProgress value. */ @@ -255,8 +255,9 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ printf("ndof: unknown device %04hx:%04hx\n", vendor_id, product_id); } - if (m_buttonMask == 0) + if (m_buttonMask == 0) { m_buttonMask = (int)~(UINT_MAX << m_buttonCount); + } #ifdef DEBUG_NDOF_BUTTONS printf("ndof: %d buttons -> hex:%X\n", m_buttonCount, m_buttonMask); diff --git a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp index 7e53ce45f70..7770f5f39ce 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerUnix.cpp @@ -32,10 +32,11 @@ GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System &sys) char line[MAX_LINE_LENGTH] = {0}; while (fgets(line, MAX_LINE_LENGTH, command_output)) { unsigned short vendor_id = 0, product_id = 0; - if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2) + if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2) { if (setDevice(vendor_id, product_id)) { break; /* stop looking once the first 3D mouse is found */ } + } } pclose(command_output); } @@ -44,8 +45,9 @@ GHOST_NDOFManagerUnix::GHOST_NDOFManagerUnix(GHOST_System &sys) GHOST_NDOFManagerUnix::~GHOST_NDOFManagerUnix() { - if (m_available) + if (m_available) { spnav_close(); + } } bool GHOST_NDOFManagerUnix::available() diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index c8308b3586b..cc8d0915c5a 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -158,7 +158,7 @@ GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting &settin return success; } -GHOST_TSuccess GHOST_System::endFullScreen(void) +GHOST_TSuccess GHOST_System::endFullScreen() { GHOST_TSuccess success = GHOST_kFailure; GHOST_ASSERT(m_windowManager, "GHOST_System::endFullScreen(): invalid window manager"); @@ -177,7 +177,7 @@ GHOST_TSuccess GHOST_System::endFullScreen(void) return success; } -bool GHOST_System::getFullScreen(void) +bool GHOST_System::getFullScreen() { bool fullScreen; if (m_windowManager) { @@ -289,7 +289,7 @@ void GHOST_System::setTabletAPI(GHOST_TTabletAPI api) m_tabletAPI = api; } -GHOST_TTabletAPI GHOST_System::getTabletAPI(void) +GHOST_TTabletAPI GHOST_System::getTabletAPI() { return m_tabletAPI; } @@ -319,9 +319,7 @@ GHOST_TSuccess GHOST_System::init() if (m_timerManager && m_windowManager && m_eventManager) { return GHOST_kSuccess; } - else { - return GHOST_kFailure; - } + return GHOST_kFailure; } GHOST_TSuccess GHOST_System::exit() @@ -357,10 +355,12 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window, { GHOST_GLSettings glSettings = {0}; - if (stereoVisual) + if (stereoVisual) { glSettings.flags |= GHOST_glStereoVisual; - if (alphaBackground) + } + if (alphaBackground) { glSettings.flags |= GHOST_glAlphaBackground; + } /* NOTE: don't use #getCurrentDisplaySetting() because on X11 we may * be zoomed in and the desktop may be bigger than the viewport. */ diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index e93a56cc8d4..bed9cd6c784 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -506,8 +506,9 @@ static void destroyIMCallback(XIM /*xim*/, XPointer ptr, XPointer /*data*/) { GHOST_PRINT("XIM server died\n"); - if (ptr) + if (ptr) { *(XIM *)ptr = nullptr; + } } bool GHOST_SystemX11::openX11_IM() @@ -519,8 +520,9 @@ bool GHOST_SystemX11::openX11_IM() XSetLocaleModifiers(""); m_xim = XOpenIM(m_display, nullptr, (char *)GHOST_X11_RES_NAME, (char *)GHOST_X11_RES_CLASS); - if (!m_xim) + if (!m_xim) { return false; + } XIMCallback destroy; destroy.callback = (XIMProc)destroyIMCallback; @@ -641,10 +643,11 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent) SleepTillEvent(m_display, -1); } else { - int64_t maxSleep = next - getMilliSeconds(); + const int64_t maxSleep = next - getMilliSeconds(); - if (maxSleep >= 0) + if (maxSleep >= 0) { SleepTillEvent(m_display, next - getMilliSeconds()); + } } } @@ -692,8 +695,9 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent) } else if (xevent.type == KeyPress) { if ((xevent.xkey.keycode == m_last_release_keycode) && - ((xevent.xkey.time <= m_last_release_time))) + ((xevent.xkey.time <= m_last_release_time))) { continue; + } } processEvent(&xevent); @@ -733,7 +737,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent) XK_Super_R, }; - for (int i = 0; i < (sizeof(modifiers) / sizeof(*modifiers)); i++) { + for (int i = 0; i < (int)(sizeof(modifiers) / sizeof(*modifiers)); i++) { KeyCode kc = XKeysymToKeycode(m_display, modifiers[i]); if (kc != 0 && ((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) { pushEvent(new GHOST_EventKey(getMilliSeconds(), @@ -1233,36 +1237,46 @@ void GHOST_SystemX11::processEvent(XEvent *xe) /* process wheel mouse events and break, only pass on press events */ if (xbe.button == Button4) { - if (xbe.type == ButtonPress) + if (xbe.type == ButtonPress) { g_event = new GHOST_EventWheel(getMilliSeconds(), window, 1); + } break; } - else if (xbe.button == Button5) { - if (xbe.type == ButtonPress) + if (xbe.button == Button5) { + if (xbe.type == ButtonPress) { g_event = new GHOST_EventWheel(getMilliSeconds(), window, -1); + } break; } /* process rest of normal mouse buttons */ - if (xbe.button == Button1) + if (xbe.button == Button1) { gbmask = GHOST_kButtonMaskLeft; - else if (xbe.button == Button2) + } + else if (xbe.button == Button2) { gbmask = GHOST_kButtonMaskMiddle; - else if (xbe.button == Button3) + } + else if (xbe.button == Button3) { gbmask = GHOST_kButtonMaskRight; - /* It seems events 6 and 7 are for horizontal scrolling. - * you can re-order button mapping like this... (swaps 6,7 with 8,9) - * `xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"` */ - else if (xbe.button == 6) + /* It seems events 6 and 7 are for horizontal scrolling. + * you can re-order button mapping like this... (swaps 6,7 with 8,9) + * `xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"` */ + } + else if (xbe.button == 6) { gbmask = GHOST_kButtonMaskButton6; - else if (xbe.button == 7) + } + else if (xbe.button == 7) { gbmask = GHOST_kButtonMaskButton7; - else if (xbe.button == 8) + } + else if (xbe.button == 8) { gbmask = GHOST_kButtonMaskButton4; - else if (xbe.button == 9) + } + else if (xbe.button == 9) { gbmask = GHOST_kButtonMaskButton5; - else + } + else { break; + } g_event = new GHOST_EventButton( getMilliSeconds(), type, window, gbmask, window->GetTabletData()); @@ -1326,8 +1340,9 @@ void GHOST_SystemX11::processEvent(XEvent *xe) if (XGetWindowAttributes(m_display, xcme.window, &attr) == True) { if (XGetInputFocus(m_display, &fwin, &revert_to) == True) { if (attr.map_state == IsViewable) { - if (fwin != xcme.window) + if (fwin != xcme.window) { XSetInputFocus(m_display, xcme.window, RevertToParent, xcme.data.l[1]); + } } } } @@ -1376,10 +1391,12 @@ void GHOST_SystemX11::processEvent(XEvent *xe) // printf("X: %s window %d\n", // xce.type == EnterNotify ? "entering" : "leaving", (int) xce.window); - if (xce.type == EnterNotify) + if (xce.type == EnterNotify) { m_windowManager->setActiveWindow(window); - else + } + else { m_windowManager->setWindowInactive(window); + } break; } @@ -1645,10 +1662,10 @@ static GHOST_TSuccess getCursorPosition_impl(Display *display, &mask_return) == False) { return GHOST_kFailure; } - else { - x = rx; - y = ry; - } + + x = rx; + y = ry; + return GHOST_kSuccess; } @@ -1955,18 +1972,19 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt, return; case XCLIB_XCOUT_SENTCONVSEL: - if (evt->type != SelectionNotify) + if (evt->type != SelectionNotify) { return; + } if (target == m_atom.UTF8_STRING && evt->xselection.property == None) { *context = XCLIB_XCOUT_FALLBACK_UTF8; return; } - else if (target == m_atom.COMPOUND_TEXT && evt->xselection.property == None) { + if (target == m_atom.COMPOUND_TEXT && evt->xselection.property == None) { *context = XCLIB_XCOUT_FALLBACK_COMP; return; } - else if (target == m_atom.TEXT && evt->xselection.property == None) { + if (target == m_atom.TEXT && evt->xselection.property == None) { *context = XCLIB_XCOUT_FALLBACK_TEXT; return; } @@ -2042,12 +2060,14 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt, * then read it, delete it, etc. */ /* make sure that the event is relevant */ - if (evt->type != PropertyNotify) + if (evt->type != PropertyNotify) { return; + } /* skip unless the property has a new value */ - if (evt->xproperty.state != PropertyNewValue) + if (evt->xproperty.state != PropertyNewValue) { return; + } /* check size and format of the property */ XGetWindowProperty(m_display, @@ -2121,7 +2141,6 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt, XFlush(m_display); return; } - return; } char *GHOST_SystemX11::getClipboard(bool selection) const @@ -2136,10 +2155,12 @@ char *GHOST_SystemX11::getClipboard(bool selection) const XEvent evt; unsigned int context = XCLIB_XCOUT_NONE; - if (selection == True) + if (selection == True) { sseln = m_atom.PRIMARY; - else + } + else { sseln = m_atom.CLIPBOARD; + } const vector<GHOST_IWindow *> &win_vec = m_windowManager->getWindows(); vector<GHOST_IWindow *>::const_iterator win_it = win_vec.begin(); @@ -2154,20 +2175,18 @@ char *GHOST_SystemX11::getClipboard(bool selection) const strcpy(sel_buf, txt_cut_buffer); return sel_buf; } - else { - sel_buf = (char *)malloc(strlen(txt_select_buffer) + 1); - strcpy(sel_buf, txt_select_buffer); - return sel_buf; - } + sel_buf = (char *)malloc(strlen(txt_select_buffer) + 1); + strcpy(sel_buf, txt_select_buffer); + return sel_buf; } - else if (owner == None) { + if (owner == None) { return nullptr; } /* Restore events so copy doesn't swallow other event types (keyboard/mouse). */ vector<XEvent> restore_events; - while (1) { + while (true) { /* only get an event if xcout() is doing something */ bool restore_this_event = false; if (context != XCLIB_XCOUT_NONE) { @@ -2188,26 +2207,27 @@ char *GHOST_SystemX11::getClipboard(bool selection) const target = m_atom.STRING; continue; } - else if (context == XCLIB_XCOUT_FALLBACK_UTF8) { + if (context == XCLIB_XCOUT_FALLBACK_UTF8) { /* utf8 fail, move to compound text. */ context = XCLIB_XCOUT_NONE; target = m_atom.COMPOUND_TEXT; continue; } - else if (context == XCLIB_XCOUT_FALLBACK_COMP) { + if (context == XCLIB_XCOUT_FALLBACK_COMP) { /* Compound text fail, move to text. */ context = XCLIB_XCOUT_NONE; target = m_atom.TEXT; continue; } - else if (context == XCLIB_XCOUT_FALLBACK_TEXT) { + if (context == XCLIB_XCOUT_FALLBACK_TEXT) { /* Text fail, nothing else to try, break. */ context = XCLIB_XCOUT_NONE; } /* Only continue if #xcout() is doing something. */ - if (context == XCLIB_XCOUT_NONE) + if (context == XCLIB_XCOUT_NONE) { break; + } } while (!restore_events.empty()) { @@ -2221,10 +2241,12 @@ char *GHOST_SystemX11::getClipboard(bool selection) const memcpy(tmp_data, (char *)sel_buf, sel_len); tmp_data[sel_len] = '\0'; - if (sseln == m_atom.STRING) + if (sseln == m_atom.STRING) { XFree(sel_buf); - else + } + else { free(sel_buf); + } return tmp_data; } @@ -2244,8 +2266,9 @@ void GHOST_SystemX11::putClipboard(const char *buffer, bool selection) const if (selection == False) { XSetSelectionOwner(m_display, m_atom.CLIPBOARD, m_window, CurrentTime); owner = XGetSelectionOwner(m_display, m_atom.CLIPBOARD); - if (txt_cut_buffer) + if (txt_cut_buffer) { free((void *)txt_cut_buffer); + } txt_cut_buffer = (char *)malloc(strlen(buffer) + 1); strcpy(txt_cut_buffer, buffer); @@ -2253,15 +2276,17 @@ void GHOST_SystemX11::putClipboard(const char *buffer, bool selection) const else { XSetSelectionOwner(m_display, m_atom.PRIMARY, m_window, CurrentTime); owner = XGetSelectionOwner(m_display, m_atom.PRIMARY); - if (txt_select_buffer) + if (txt_select_buffer) { free((void *)txt_select_buffer); + } txt_select_buffer = (char *)malloc(strlen(buffer) + 1); strcpy(txt_select_buffer, buffer); } - if (owner != m_window) + if (owner != m_window) { fprintf(stderr, "failed to own primary\n"); + } } } @@ -2374,7 +2399,7 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title, const char *help_label, const char *continue_label, const char *link, - GHOST_DialogOptions) const + GHOST_DialogOptions /*dialog_options*/) const { char **text_splitted = nullptr; int textLines = 0; @@ -2557,18 +2582,23 @@ static bool match_token(const char *haystack, const char *needle) { const char *h, *n; for (h = haystack; *h;) { - while (*h && is_filler_char(*h)) + while (*h && is_filler_char(*h)) { h++; - if (!*h) + } + if (!*h) { break; + } - for (n = needle; *n && *h && tolower(*h) == tolower(*n); n++) + for (n = needle; *n && *h && tolower(*h) == tolower(*n); n++) { h++; - if (!*n && (is_filler_char(*h) || !*h)) + } + if (!*n && (is_filler_char(*h) || !*h)) { return true; + } - while (*h && !is_filler_char(*h)) + while (*h && !is_filler_char(*h)) { h++; + } } return false; } |