From 5b21e94bebed90180d8ff63dad03b8b948361089 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 21 Jul 2022 09:23:58 -0700 Subject: Expand tabs [ci skip] [Misc #18891] --- dln.c | 154 +++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 77 insertions(+), 77 deletions(-) (limited to 'dln.c') diff --git a/dln.c b/dln.c index b9cfe7dc94..b14ba63c44 100644 --- a/dln.c +++ b/dln.c @@ -110,8 +110,8 @@ init_funcname_len(const char **file) /* Load the file as an object one */ for (base = p; *p; p++) { /* Find position of last '/' */ - if (*p == '.' && !dot) dot = p; - if (isdirsep(*p)) base = p+1, dot = NULL; + if (*p == '.' && !dot) dot = p; + if (isdirsep(*p)) base = p+1, dot = NULL; } *file = base; /* Delete suffix if it exists */ @@ -126,7 +126,7 @@ static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX const size_t plen = sizeof(funcname_prefix);\ char *const tmp = ALLOCA_N(char, plen+flen+1);\ if (!tmp) {\ - dln_memerror();\ + dln_memerror();\ }\ memcpy(tmp, funcname_prefix, plen);\ memcpy(tmp+plen, base, flen);\ @@ -170,14 +170,14 @@ dln_strerror(char *message, size_t size) size_t len = snprintf(message, size, "%d: ", error); #define format_message(sublang) FormatMessage(\ - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, \ - NULL, error, MAKELANGID(LANG_NEUTRAL, (sublang)), \ - message + len, size - len, NULL) + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, \ + NULL, error, MAKELANGID(LANG_NEUTRAL, (sublang)), \ + message + len, size - len, NULL) if (format_message(SUBLANG_ENGLISH_US) == 0) - format_message(SUBLANG_DEFAULT); + format_message(SUBLANG_DEFAULT); for (p = message + len; *p; p++) { - if (*p == '\n' || *p == '\r') - *p = ' '; + if (*p == '\n' || *p == '\r') + *p = ' '; } return message; } @@ -200,18 +200,18 @@ aix_loaderror(const char *pathname) snprintf(errbuf, sizeof(errbuf), "load failed - %s. ", pathname); if (loadquery(L_GETMESSAGES, &message[0], sizeof(message)) != -1) { - ERRBUF_APPEND("Please issue below command for detailed reasons:\n\t"); - ERRBUF_APPEND("/usr/sbin/execerror ruby "); - for (i=0; message[i]; i++) { - ERRBUF_APPEND("\""); - ERRBUF_APPEND(message[i]); - ERRBUF_APPEND("\" "); - } - ERRBUF_APPEND("\n"); + ERRBUF_APPEND("Please issue below command for detailed reasons:\n\t"); + ERRBUF_APPEND("/usr/sbin/execerror ruby "); + for (i=0; message[i]; i++) { + ERRBUF_APPEND("\""); + ERRBUF_APPEND(message[i]); + ERRBUF_APPEND("\" "); + } + ERRBUF_APPEND("\n"); } else { - ERRBUF_APPEND(strerror(errno)); - ERRBUF_APPEND("[loadquery failed]"); + ERRBUF_APPEND(strerror(errno)); + ERRBUF_APPEND("[loadquery failed]"); } dln_loaderror("%s", errbuf); } @@ -229,22 +229,22 @@ rb_w32_check_imported(HMODULE ext, HMODULE mine) desc = ImageDirectoryEntryToData(ext, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &size); if (!desc) return 0; while (desc->Name) { - PIMAGE_THUNK_DATA pint = (PIMAGE_THUNK_DATA)((char *)ext + desc->Characteristics); - PIMAGE_THUNK_DATA piat = (PIMAGE_THUNK_DATA)((char *)ext + desc->FirstThunk); - for (; piat->u1.Function; piat++, pint++) { - static const char prefix[] = "rb_"; - PIMAGE_IMPORT_BY_NAME pii; - const char *name; - - if (IMAGE_SNAP_BY_ORDINAL(pint->u1.Ordinal)) continue; - pii = (PIMAGE_IMPORT_BY_NAME)((char *)ext + (size_t)pint->u1.AddressOfData); - name = (const char *)pii->Name; - if (strncmp(name, prefix, sizeof(prefix) - 1) == 0) { - FARPROC addr = GetProcAddress(mine, name); - if (addr) return (FARPROC)piat->u1.Function == addr; - } - } - desc++; + PIMAGE_THUNK_DATA pint = (PIMAGE_THUNK_DATA)((char *)ext + desc->Characteristics); + PIMAGE_THUNK_DATA piat = (PIMAGE_THUNK_DATA)((char *)ext + desc->FirstThunk); + for (; piat->u1.Function; piat++, pint++) { + static const char prefix[] = "rb_"; + PIMAGE_IMPORT_BY_NAME pii; + const char *name; + + if (IMAGE_SNAP_BY_ORDINAL(pint->u1.Ordinal)) continue; + pii = (PIMAGE_IMPORT_BY_NAME)((char *)ext + (size_t)pint->u1.AddressOfData); + name = (const char *)pii->Name; + if (strncmp(name, prefix, sizeof(prefix) - 1) == 0) { + FARPROC addr = GetProcAddress(mine, name); + if (addr) return (FARPROC)piat->u1.Function == addr; + } + } + desc++; } return 1; } @@ -252,11 +252,11 @@ rb_w32_check_imported(HMODULE ext, HMODULE mine) #if defined(DLN_NEEDS_ALT_SEPARATOR) && DLN_NEEDS_ALT_SEPARATOR #define translit_separator(src) do { \ - char *tmp = ALLOCA_N(char, strlen(src) + 1), *p = tmp, c; \ - do { \ - *p++ = ((c = *file++) == '/') ? DLN_NEEDS_ALT_SEPARATOR : c; \ - } while (c); \ - (src) = tmp; \ + char *tmp = ALLOCA_N(char, strlen(src) + 1), *p = tmp, c; \ + do { \ + *p++ = ((c = *file++) == '/') ? DLN_NEEDS_ALT_SEPARATOR : c; \ + } while (c); \ + (src) = tmp; \ } while (0) #else #define translit_separator(str) (void)(str) @@ -273,7 +273,7 @@ dln_incompatible_func(void *handle, const char *funcname, void *const fp, const if (!ex) return false; if (ex == fp) return false; if (dladdr(ex, &dli)) { - *libname = dli.dli_fname; + *libname = dli.dli_fname; } return true; } @@ -287,7 +287,7 @@ dln_incompatible_library_p(void *handle, const char **libname) { #define check_func(func) \ if (dln_incompatible_func(handle, EXTERNAL_PREFIX #func, (void *)&func, libname)) \ - return true + return true check_func(ruby_xmalloc); return false; } @@ -337,7 +337,7 @@ dln_open(const char *file) /* Convert the file path to wide char */ WCHAR *winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL); if (!winfile) { - dln_memerror(); + dln_memerror(); } /* Load file */ @@ -345,15 +345,15 @@ dln_open(const char *file) free(winfile); if (!handle) { - error = dln_strerror(); - goto failed; + error = dln_strerror(); + goto failed; } # if defined(RUBY_EXPORT) if (!rb_w32_check_imported(handle, rb_libruby_handle())) { - FreeLibrary(handle); - error = incompatible; - goto failed; + FreeLibrary(handle); + error = incompatible; + goto failed; } # endif @@ -378,24 +378,24 @@ dln_open(const char *file) # if defined(RUBY_EXPORT) { - const char *libruby_name = NULL; - if (dln_incompatible_library_p(handle, &libruby_name)) { - if (dln_disable_dlclose()) { - /* dlclose() segfaults */ - if (libruby_name) { - dln_fatalerror("linked to incompatible %s - %s", libruby_name, file); - } - dln_fatalerror("%s - %s", incompatible, file); - } - else { - dlclose(handle); - if (libruby_name) { - dln_loaderror("linked to incompatible %s - %s", libruby_name, file); - } - error = incompatible; - goto failed; - } - } + const char *libruby_name = NULL; + if (dln_incompatible_library_p(handle, &libruby_name)) { + if (dln_disable_dlclose()) { + /* dlclose() segfaults */ + if (libruby_name) { + dln_fatalerror("linked to incompatible %s - %s", libruby_name, file); + } + dln_fatalerror("%s - %s", incompatible, file); + } + else { + dlclose(handle); + if (libruby_name) { + dln_loaderror("linked to incompatible %s - %s", libruby_name, file); + } + error = incompatible; + goto failed; + } + } } # endif #endif @@ -471,17 +471,17 @@ dln_load(const char *file) #elif defined(_AIX) { - void (*init_fct)(void); - - init_fct = (void(*)(void))load((char*)file, 1, 0); - if (init_fct == NULL) { - aix_loaderror(file); - } - if (loadbind(0, (void*)dln_load, (void*)init_fct) == -1) { - aix_loaderror(file); - } - (*init_fct)(); - return (void*)init_fct; + void (*init_fct)(void); + + init_fct = (void(*)(void))load((char*)file, 1, 0); + if (init_fct == NULL) { + aix_loaderror(file); + } + if (loadbind(0, (void*)dln_load, (void*)init_fct) == -1) { + aix_loaderror(file); + } + (*init_fct)(); + return (void*)init_fct; } #else dln_notimplement(); -- cgit v1.2.3