delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2012/11/18/10:52:10

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
X-Mailer: exmh version 2.7.2 01/07/2005 (debian 1:2.7.2-18) with nmh-1.3
X-Exmh-Isig-CompType: repl
X-Exmh-Isig-Folder: inbox
To: geda-user AT delorie DOT com
Subject: Re: [geda-user] Bug #903129 Translations don't work on Windows
In-reply-to: <CAPYb0EFmbs-xqhgCfwbPuB-gMc+CTO1fv2ESZkUX5u_5WgSnNA@mail.gmail.com>
References: <20121113211401 DOT 20747813A49B AT turkos DOT aspodata DOT se> <CAOuGh89nhtaPkKZ+0CJGn9V_XnZyi6YD-NndT53FHoAyYD0LFw AT mail DOT gmail DOT com> <20121115210903 DOT 90A4881345E3 AT turkos DOT aspodata DOT se> <CAPYb0EE-xqA681-iq9AwnL7Wq1j9NL7AP383X5qe5QeCZZW0Ug AT mail DOT gmail DOT com> <20121116135510 DOT 6D56B81345EB AT turkos DOT aspodata DOT se> <CAOuGh8_tCu_CM=RCRPDAoJMObszqWpjG29-37rAUAHyBN18uSw AT mail DOT gmail DOT com> <20121116204345 DOT 9377B81345F9 AT turkos DOT aspodata DOT se> <CAOuGh88CA2c+HNu+9QqGZZ2oLSeNHq5bsgvcWDqhQ+5nB_aAbg AT mail DOT gmail DOT com> <20121116222416 DOT 4B63C81345FC AT turkos DOT aspodata DOT se> <20121118123027 DOT 272B08134615 AT turkos DOT aspodata DOT se> <CAPYb0EFmbs-xqhgCfwbPuB-gMc+CTO1fv2ESZkUX5u_5WgSnNA AT mail DOT gmail DOT com>
Comments: In-reply-to Bob Paddock <bob DOT paddock AT gmail DOT com>
message dated "Sun, 18 Nov 2012 09:10:32 -0500."
Mime-Version: 1.0
Message-Id: <20121118155051.F0E4B813BDA2@turkos.aspodata.se>
Date: Sun, 18 Nov 2012 16:50:51 +0100 (CET)
From: karl AT aspodata DOT se (Karl Hammar)
X-Virus-Scanned: ClamAV using ClamSMTP
Reply-To: geda-user AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-user AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Bob Paddock:
> > And tomorrow became today.
> > Bob, or anyone, could you test the attached program.
> 
> Can't say I understand this:
> 
> #ifdef __linux__
> #define MAX_PATH 400
> struct HINSTANCE_t {
>   const char *filename;
> };
> ....
> 
> Why would __linux__ defined and care about:
> 
> HINSTANCE GetModuleHandle(void *handle) {
>   (void) handle;
>   gg.filename = "c:\\gEDA\\bin\\gschem";
>   return &gg;
> }

This just about so that I can test it in *some* way on my box.
I didn't want to send you something that didn't compile.
You can remove it, it is solely for testing.

> > I don't know how to compile it for MS-Windows.
> 
> If you have Windows the easiest way is:
> 
> http://nuwen.net/mingw.html gets you most of what you need.
> There will still be a few missing libraries.
> 
> The other way to do it on Windows is with Cygwin,
> where it has the libraries but is a lot slower.
> http://www.cygwin.com/

Sorry, don't have MS-Windows.

> If you don't have Windows then the minipack cross compiler setup is
> part of the current distribution.
> Someone was working on making a mxe.cc cross compiler version but not
> have heard anymore about it (Anyone know its status?).
> http://mxe.cc/

I found

 mingw32 (contains i586-mingw32msvc-gcc)
 gcc-mingw-w64-i686 (contains i686-w64-mingw32-gcc)

on debian. But I don't have any crosscompiled glib, so both fails.

> > Which version of get_locale() do you like, should we use?

Maybe it should be called get_localedir() instead.

> I'll have to run this code and see what it does, for example:
>  strncpy(cc, "\\share\\locale", sz - len);
> should that be strncat()?

No, cc is at end of path, though you could use

 strncat(path, "..", sz - strlen(path) -1)

might be more obvious.

> Both strncpy and strncat will result in buffer overflows if all of
> MAX_PATH is used; sz -(len -1) would fix.

Not strncpy(), but it might not '\0' terminate the string.
If strncpy() I have to add path[sz-1] = '\0' to fix that.
So these two do the same job:

$ cat Tsz.c
#include <string.h>
#include <stdio.h>

#define SZ 20

int main(void) {
  char path[SZ] = "c:\\gEDA\\bin\\gschem";
  size_t len = strlen(path);

  strncat(path, "\\share\\locale", SZ-len-1);
  printf("path <%s>\nlen: %d\n", path, strlen(path));

  strncpy(path+len, "\\share\\locale", SZ-len);
  path[SZ-1] = '\0';
  printf("path <%s>\nlen: %d\n", path, strlen(path));

  return 0;
}

$ ./Tsz
path <c:\gEDA\bin\gschem\>
len: 19
path <c:\gEDA\bin\gschem\>
len: 19

I also forgot:
    g_free(localedir);
in alt2.

> I like your Alt2 better as it is shorter.
> As you already said there is already a dependency on glib.

I don't really care as long as it does its job and runs on all
MS-Windows versions that libgeda targets (even in the future
hopefully).

Which one of:

1,
 GetModuleHandle()
 GetModuleFileName()

2,
 g_win32_get_package_installation_directory_of_module()

will be deprecated first, what do you think?

Regards,
/Karl Hammar

-----------------------------------------------------------------------
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019