View Issue Details

IDProjectCategoryView StatusLast Update
0002050libextractorportabilitypublic2012-09-25 17:18
ReporterLRN Assigned ToChristian Grothoff  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.6.3 
Target Version1.0.0Fixed in Version1.0.0 
Summary0002050: UTF8ization patch for libextractor
DescriptionLE requires adaptation after UTF8ization of plibc.
TagsNo tags attached.
Attached Files
0001-UTF8ize-libextractor.patch (2,895 bytes)   
From 9fdeacca44ece464456d6a8cc7237404c95be845 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1?=
 =?UTF-8?q?=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
Date: Fri, 30 Dec 2011 20:24:49 +0400
Subject: [PATCH] UTF8ize libextractor

---
 src/main/extractor.c |   37 +++++++++++++++++++++++++++++++------
 1 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/src/main/extractor.c b/src/main/extractor.c
index 3a0e960..9789f3f 100644
--- a/src/main/extractor.c
+++ b/src/main/extractor.c
@@ -184,7 +184,7 @@ get_path_from_proc_exe() {
 	   sizeof (fn),
 	   "/proc/%u/maps",
 	   getpid());
-  f = fopen(fn, "r");
+  f = FOPEN(fn, "r");
   if (f != NULL) {
     while (NULL != fgets(line, 1024, f)) {
       if ( (1 == sscanf(line,
@@ -514,10 +514,10 @@ find_plugin_in_path (void *cls,
 
   if (sc->path != NULL)
     return;
-  dir = opendir (path);
+  dir = OPENDIR (path);
   if (NULL == dir)
     return;
-  while (NULL != (ent = readdir (dir)))
+  while (NULL != (ent = READDIR (dir)))
     {
       if (ent->d_name[0] == '.')
 	continue;
@@ -531,7 +531,7 @@ find_plugin_in_path (void *cls,
       sym = strdup (sym_name);
       if (sym == NULL)
 	{
-	  closedir (dir);
+	  CLOSEDIR (dir);
 	  return;
 	}
       dot = strstr (sym, ".");
@@ -552,7 +552,7 @@ find_plugin_in_path (void *cls,
 	     sc->short_name,
 	     path);
 #endif
-  closedir (dir);
+  CLOSEDIR (dir);
 }
 
 
@@ -766,6 +766,10 @@ get_symbol_with_prefix(void *lib_handle,
 static int
 plugin_load (struct EXTRACTOR_PluginList *plugin)
 {
+#if WINDOWS
+  wchar_t wlibname[4097];
+  char llibname[4097];
+#endif
   lt_dladvise advise;
 
   if (plugin->libname == NULL)
@@ -783,8 +787,29 @@ plugin_load (struct EXTRACTOR_PluginList *plugin)
   lt_dladvise_init (&advise);
   lt_dladvise_ext (&advise);
   lt_dladvise_local (&advise);
+#if WINDOWS
+  wlibname[0] = L'\0';
+  llibname[0] = '\0';
+  if (MultiByteToWideChar (CP_UTF8, 0, plugin->libname, -1, wlibname, 4097) <= 0
+      || WideCharToMultiByte (CP_ACP, 0, wlibname, -1, llibname, 4097, NULL, NULL) < 0)
+  {
+#if DEBUG
+      fprintf (stderr,
+	       "Loading `%s' plugin failed: %s\n",
+	       plugin->short_libname,
+	       "can't convert plugin name to local encoding");
+      free (plugin->libname);
+      plugin->libname = NULL;
+      plugin->flags = EXTRACTOR_OPTION_DISABLED;
+      return -1;
+#endif
+  }
+  plugin->libraryHandle = lt_dlopenadvise (llibname,
+				       advise);
+#else
   plugin->libraryHandle = lt_dlopenadvise (plugin->libname, 
 				       advise);
+#endif
   lt_dladvise_destroy(&advise);
   if (plugin->libraryHandle == NULL)
     {
@@ -2333,7 +2358,7 @@ static int file_open(const char *filename, int oflag, ...)
   /* Set binary mode */
   mode |= O_BINARY;
 #endif
-  return open(fn, oflag, mode);
+  return OPEN(fn, oflag, mode);
 }
 
 
-- 
1.7.4

Activities

Christian Grothoff

2011-12-31 19:40

manager   ~0005230

Applied in SVN 18867, plibc.h updated in SVN 18868.

Issue History

Date Modified Username Field Change
2011-12-30 16:25 LRN New Issue
2011-12-30 16:25 LRN File Added: 0001-UTF8ize-libextractor.patch
2011-12-31 19:40 Christian Grothoff Note Added: 0005230
2011-12-31 19:40 Christian Grothoff Status new => resolved
2011-12-31 19:40 Christian Grothoff Fixed in Version => Git master
2011-12-31 19:40 Christian Grothoff Resolution open => fixed
2011-12-31 19:40 Christian Grothoff Assigned To => Christian Grothoff
2012-09-09 02:35 Christian Grothoff Fixed in Version Git master => 1.0.0
2012-09-09 02:35 Christian Grothoff Target Version => 1.0.0
2012-09-25 17:18 Christian Grothoff Status resolved => closed