diff --git a/src/common.cpp b/src/common.cpp index 0fa22b310..bdf327018 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -196,15 +196,14 @@ static wcstring str2wcs_internal(const char *in, const size_t in_len) { // Protect against broken mbrtowc() implementations which attempt to encode UTF-8 // sequences longer than four bytes (e.g., OS X Snow Leopard). use_encode_direct = true; - } else if (sizeof(wchar_t) == 2 && (in[in_pos] & 0xF8) == 0xF0) { + } else if (sizeof(wchar_t) == 2 && //!OCLINT(constant if expression) + (in[in_pos] & 0xF8) == 0xF0) { // Assume we are in a UTF-16 environment (e.g., Cygwin) using a UTF-8 encoding. // The bits set check will be true for a four byte UTF-8 sequence that requires // two UTF-16 chars. Something that doesn't work with our simple use of mbrtowc(). use_encode_direct = true; } else { ret = mbrtowc(&wc, &in[in_pos], in_len - in_pos, &state); - // fprintf(stderr, "WTF in_pos %d ret %d\n", in_pos, ret); - // Determine whether to encode this character with our crazy scheme. if (wc >= ENCODE_DIRECT_BASE && wc < ENCODE_DIRECT_BASE + 256) { use_encode_direct = true; @@ -219,7 +218,8 @@ static wcstring str2wcs_internal(const char *in, const size_t in_len) { } else if (ret > in_len - in_pos) { // Other error codes? Terrifying, should never happen. use_encode_direct = true; - } else if (sizeof(wchar_t) == 2 && wc >= 0xD800 && wc <= 0xDFFF) { + } else if (sizeof(wchar_t) == 2 && wc >= 0xD800 && //!OCLINT(constant if expression) + wc <= 0xDFFF) { // If we get a surrogate pair char on a UTF-16 system (e.g., Cygwin) then // it's guaranteed the UTF-8 decoding is wrong so use direct encoding. use_encode_direct = true; @@ -227,24 +227,20 @@ static wcstring str2wcs_internal(const char *in, const size_t in_len) { } if (use_encode_direct) { - // fprintf(stderr, "WTF use_encode_direct\n"); wc = ENCODE_DIRECT_BASE + (unsigned char)in[in_pos]; result.push_back(wc); in_pos++; memset(&state, 0, sizeof state); - } else if (ret == 0) { - // fprintf(stderr, "WTF null byte\n"); - // Embedded null byte! + } else if (ret == 0) { // embedded null byte! result.push_back(L'\0'); in_pos++; memset(&state, 0, sizeof state); - } else { - // fprintf(stderr, "WTF null byte\n"); - // Normal case. + } else { // normal case result.push_back(wc); in_pos += ret; } } + return result; } diff --git a/src/iothread.cpp b/src/iothread.cpp index bc7da0cb5..ca9e50a41 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -30,8 +30,6 @@ #define IO_SERVICE_MAIN_THREAD_REQUEST_QUEUE 99 #define IO_SERVICE_RESULT_QUEUE 100 -#define IOTHREAD_LOG if (0) - static void iothread_service_main_thread_requests(void); static void iothread_service_result_queue(); @@ -120,7 +118,7 @@ static void *iothread_worker(void *unused) { scoped_lock locker(s_spawn_queue_lock); struct SpawnRequest_t *req; while ((req = dequeue_spawn_request()) != NULL) { - IOTHREAD_LOG fprintf(stderr, "pthread %p dequeued %p\n", this_thread(), req); + debug(5, "pthread %p dequeued %p\n", this_thread(), req); // Unlock the queue while we execute the request. locker.unlock(); @@ -153,7 +151,7 @@ static void *iothread_worker(void *unused) { assert(s_active_thread_count > 0); s_active_thread_count -= 1; - IOTHREAD_LOG fprintf(stderr, "pthread %p exiting\n", this_thread()); + debug(5, "pthread %p exiting\n", this_thread()); // We're done. return NULL; } @@ -175,7 +173,7 @@ static void iothread_spawn() { // We will never join this thread. VOMIT_ON_FAILURE(pthread_detach(thread)); - IOTHREAD_LOG fprintf(stderr, "pthread %p spawned\n", (void *)(intptr_t)thread); + debug(5, "pthread %p spawned\n", (void *)(intptr_t)thread); // Restore our sigmask. VOMIT_ON_FAILURE(pthread_sigmask(SIG_SETMASK, &saved_set, NULL)); } diff --git a/src/parse_productions.cpp b/src/parse_productions.cpp index 0455b50fa..1b577d6ed 100644 --- a/src/parse_productions.cpp +++ b/src/parse_productions.cpp @@ -432,11 +432,8 @@ const production_t *parse_productions::production_for_token(parse_token_type_t n const parse_token_t &input1, const parse_token_t &input2, parse_node_tag_t *out_tag) { - const bool log_it = false; - if (log_it) { - fprintf(stderr, "Resolving production for %ls with input token <%ls>\n", - token_type_description(node_type), input1.describe().c_str()); - } + debug(5, "Resolving production for %ls with input token <%ls>\n", + token_type_description(node_type), input1.describe().c_str()); // Fetch the function to resolve the list of productions. const production_t *(*resolver)(const parse_token_t &input1, const parse_token_t &input2, @@ -500,9 +497,9 @@ const production_t *parse_productions::production_for_token(parse_token_type_t n PARSE_ASSERT(resolver != NULL); const production_t *result = resolver(input1, input2, out_tag); - if (result == NULL && log_it) { - fprintf(stderr, "Node type '%ls' has no production for input '%ls' (in %s)\n", - token_type_description(node_type), input1.describe().c_str(), __FUNCTION__); + if (result == NULL) { + debug(5, "Node type '%ls' has no production for input '%ls' (in %s)\n", + token_type_description(node_type), input1.describe().c_str(), __FUNCTION__); } return result; diff --git a/src/utf8.cpp b/src/utf8.cpp index 53d994852..55d404fe8 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -82,7 +82,7 @@ size_t utf8_to_wchar(const char *in, size_t insize, std::wstring *out, int flags } size_t result; - if (sizeof(wchar_t) == sizeof(utf8_wchar_t)) { + if (sizeof(wchar_t) == sizeof(utf8_wchar_t)) { //!OCLINT(constant if expression) result = utf8_to_wchar_internal(in, insize, reinterpret_cast(out), flags); } else if (out == NULL) { result = utf8_to_wchar_internal(in, insize, NULL, flags); @@ -102,7 +102,7 @@ size_t wchar_to_utf8(const wchar_t *in, size_t insize, char *out, size_t outsize } size_t result; - if (sizeof(wchar_t) == sizeof(utf8_wchar_t)) { + if (sizeof(wchar_t) == sizeof(utf8_wchar_t)) { //!OCLINT(constant if expression) result = wchar_to_utf8_internal(reinterpret_cast(in), insize, out, outsize, flags); } else {