Re: strange cygstart bug with current Cygwin versions

2006-02-08 Thread Christopher Faylor
On Tue, Feb 07, 2006 at 01:25:12PM -0600, Brian Ford wrote:
On Tue, 7 Feb 2006, Christopher Faylor wrote:

 I believe that Brian Ford is looking into modifying the new CW_SETUP_WINENV
 code to perform the proper conversion of POSIX style to Windows style.

We're still debating aproaches for solving our problem, so it is possible
I won't get to it.  If someone else wants to try, feel free.

Well, that's disappointing.  I'm not aware of any debates.  I thought
just this once we could rely on someone else fixing a problem.

I guess I'll look into this when I get a chance.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-08 Thread Michael Schaap
On 8-Feb-2006 16:41, Christopher Faylor wrote:
 On Tue, Feb 07, 2006 at 01:25:12PM -0600, Brian Ford wrote:
   
 On Tue, 7 Feb 2006, Christopher Faylor wrote:

 
 I believe that Brian Ford is looking into modifying the new CW_SETUP_WINENV
 code to perform the proper conversion of POSIX style to Windows style.
   
 We're still debating aproaches for solving our problem, so it is possible
 I won't get to it.  If someone else wants to try, feel free.
 

 Well, that's disappointing.  I'm not aware of any debates.  I thought
 just this once we could rely on someone else fixing a problem.

 I guess I'll look into this when I get a chance.

   
Well, the below code works for cygstart, and does the right thing for
the variables Cygwin converts from POSIX - Win32.
Feel free to adapt this to CW_SETUP_WINENV. (Although it might be more
elegant to use conv_envvars[] from environ.cc there.)

If I hear no objections, I'm going to submit this as a path for
cygutils, and ask Chuck to release it. If and when this gets fixed in
CW_SETUP_WINENV, and released, I'll change it to use that instead.

– Michael


/* Copy cygwin environment variables to the Windows environment if
they're not
* already there. */
static void setup_win_environ(void)
{
char **envp = environ;
char *var, *val;
char curval[2];
char *winpathlist;
char winpath[MAX_PATH+1];

while (envp  *envp) {
var = strdup(*envp++);
val = strchr(var, '=');
*val++ = '\0';

if (GetEnvironmentVariable(var, curval, 2) == 0
 GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
/* Convert POSIX to Win32 where necessary */
if (!strcmp(var, PATH) ||
!strcmp(var, LD_LIBRARY_PATH)) {
winpathlist = (char *)
malloc(cygwin_posix_to_win32_path_list_buf_size(val));
if (winpathlist) {
cygwin_posix_to_win32_path_list(val, winpathlist);
SetEnvironmentVariable(var, winpathlist);
free(winpathlist);
}
} else if (!strcmp(var, HOME) ||
!strcmp(var, TMPDIR) ||
!strcmp(var, TMP) ||
!strcmp(var, TEMP)) {
cygwin_conv_to_win32_path(val, winpath);
SetEnvironmentVariable(var, winpath);
} else {
SetEnvironmentVariable(var, val);
}
}

free(var);
}
}

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-08 Thread Michael Schaap
On 8-Feb-2006 18:49, Michael Schaap wrote:
 On 8-Feb-2006 16:41, Christopher Faylor wrote:
   
 On Tue, Feb 07, 2006 at 01:25:12PM -0600, Brian Ford wrote:
   
 
 On Tue, 7 Feb 2006, Christopher Faylor wrote:

 
   
 I believe that Brian Ford is looking into modifying the new CW_SETUP_WINENV
 code to perform the proper conversion of POSIX style to Windows style.
   
 
 We're still debating aproaches for solving our problem, so it is possible
 I won't get to it.  If someone else wants to try, feel free.
 
   
 Well, that's disappointing.  I'm not aware of any debates.  I thought
 just this once we could rely on someone else fixing a problem.

 I guess I'll look into this when I get a chance.

   
 
 Well, the below code works for cygstart, and does the right thing for
 the variables Cygwin converts from POSIX - Win32.
 Feel free to adapt this to CW_SETUP_WINENV. (Although it might be more
 elegant to use conv_envvars[] from environ.cc there.)

 If I hear no objections, I'm going to submit this as a path for
 cygutils, and ask Chuck to release it. If and when this gets fixed in
 CW_SETUP_WINENV, and released, I'll change it to use that instead.
   
No idea why Thunderbird decided to strip the indentation...  Anyway,
I'll just attach cygstart.c instead.

 - Michael
/*
 * cygstart - Let Windows start a program, or open a file or URL
 *
 * (c) 2002 Michael Schaap cygstart(at)mscha.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * See the COPYING file for license information.
 */

#if HAVE_CONFIG_H
#include config.h
#endif
#include common.h

/* The official name of this program (e.g., no `g' prefix).  */
#define PROGRAM_NAME cygstart
#define AUTHORS Michael Schaap

/* Predefined actions */
#define ACTION_OPEN open
#define ACTION_EXPLORE explore
#define ACTION_EDIT edit
#define ACTION_FIND find
#define ACTION_PRINT print

/* MSDN reference URL */
#define MSDN_URL http://msdn.microsoft.com/library/en-us/shellcc/platform/; \
 Shell/reference/functions/shellexecute.asp

static const char versionID[] = 1.2;
/* for future CVS */
static const char revID[] =
$Id: cygstart.c,v 1.4 2005/05/16 20:18:52 cwilson Exp $;
static const char copyrightID[] =
Copyright (c) 2002,...\n
Michael Schaap. All rights reserved.\n
Licensed under GPL v2.0\n;

/* The name this program was run with. */
static char *program_name;

static int cygStart(const char *aPath, const char *action, const char *args,
const char *workDir, int show);
static int winStart(const char *aPath, const char *action, const char *args,
const char *workDir, int show);
static char *startError(int err);
static const char *getVersion(void);
static void printTopDescription(FILE *f, char *name);
static void printBottomDescription(FILE *f, char *name);
static void usage(poptContext optCon, FILE *f, char *name);
static void help(poptContext optCon, FILE *f, char *name);
static void version(poptContext optCon, FILE *f, char *name);
static void license(poptContext optCon, FILE *f, char *name);
static void setup_win_environ(void);

int main(int argc, const char **argv)
{
poptContext optCon;
const char *arg;
const char **rest;
int rc;
int ret;
char *action = NULL;
char *file = NULL;
size_t argLength;
const char **tmp;
char *args = NULL;
char *workDir = NULL;
int show = SW_SHOWNORMAL;

/* Action options */
struct poptOption actionOptionsTable[] = {
{ action,  'a',  POPT_ARG_STRING, NULL, 'a', \
  Use specified action instead of default, NULL},
{ open,  'o',  POPT_ARG_NONE, NULL, 'o', \
  Short for: --action open, NULL},
{ explore,  'x',  POPT_ARG_NONE, NULL, 'x', \
  Short for: --action explore, NULL},
{ edit,  'e',  POPT_ARG_NONE, NULL, 'e', \
  Short for: --action edit, NULL},
{ find,  'f',  POPT_ARG_NONE, NULL, 'f', \
  Short for: --action find, NULL},
{ print,  'p',  POPT_ARG_NONE, NULL, 'p', \
  Short for: --action print, NULL},
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
};

/* Directory options */
struct poptOption directoryOptionsTable[] = {
{ directory,  'd',  POPT_ARG_STRING, NULL, 'd', \
  Set working 

Re: strange cygstart bug with current Cygwin versions

2006-02-08 Thread Michael Schaap
On 8-Feb-2006 18:54, Michael Schaap wrote:
 winpathlist = (char *)
 malloc(cygwin_posix_to_win32_path_list_buf_size(val));
To correct myself before anyone else does so: This needs a  + 1, of
course.  :-[

 - Michael

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-08 Thread Brian Ford
On Wed, 8 Feb 2006, Christopher Faylor wrote:
 On Tue, Feb 07, 2006 at 01:25:12PM -0600, Brian Ford wrote:
 On Tue, 7 Feb 2006, Christopher Faylor wrote:
  I believe that Brian Ford is looking into modifying the new CW_SETUP_WINENV
  code to perform the proper conversion of POSIX style to Windows style.
 
 We're still debating aproaches for solving our problem, so it is possible
 I won't get to it.  If someone else wants to try, feel free.

 Well, that's disappointing.  I'm not aware of any debates.  I thought
 just this once we could rely on someone else fixing a problem.

I didn't mean to disappoint, but I work on Cygwin only at work.  I don't
currently have the free time or resources at home to do it.  As such, I
have to work only on the problems that face our products.

We only needed that functionality because of missing vfork behavior.  We
decided to use spawn and a helper executable to solve the problem instead
of going outside the Cygwin box with CreateProcess.

Occasionally, I try to use free work time (lunch, after hours, etc.) to do
otherwise.  But lately that's been in very short supply (as in taken up
by work itself).

:-(.

-- 
Brian Ford
Lead Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-07 Thread David Picton
On 2/3/06, Igor Peshansky [EMAIL PROTECTED] wrote:
 On Fri, 3 Feb 2006, David Picton wrote:

  I have encountered a strange bug when starting Microsoft Word when it is
  started by the cygstart command, e.g. cygstart Index.doc, with the
  current version of the Cygwin dll.
 
  The symptoms are as follows:

[snip]

  3.  Attempting to save the file gets no response.  The only way to close
  the window is to exit without saving!

I have now tested 'cygstart cmd' on the three computers I use, and in
every case I see the same problem with the TEMP and TMP environment
variables - they retain the Cygwin pathname (regardless of whether
this actually causes a problem with Word).  For now, I've caused TEMP
and TMP to be set to a Windows pathname within Cygwin.

I don't see the bug if I run an older version of Cygwin (pre-2006
versions of the Cygwin DLL).  TEMP and TMP used to be translated
correctly in processes invoked by cygstart.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-07 Thread Michael Schaap
On 7-Feb-2006 3:31, Yitzchak Scott-Thoennes wrote:
 On Mon, Feb 06, 2006 at 11:40:22PM +0100, Michael Schaap wrote:
   
 What we basically need to do, is copy the Cygwin environment to the
 Windows environment, taking care of path conversion for all the
 appropriate variables.
 

 Maybe start with:

 http://www.cygwin.com/ml/cygwin-patches/2005-q4/msg9.html
   

Not really, I think, especially since that code didn't make it into
Cygwin.  ;-)
(Also, Corinna suggested in that thread that an application should
simply convert the necessary variables itself.)

I did notice, though, that a new version, setup_winenv(), externally
callable as cygwin_internal(CW_SETUP_WINENV), was made available ...
last Thursday.  (Looks like the code was adapted from the cygstart code,
actually. :-) )
So, ideally, that function would be fixed to do POSIX to Windows
conversion on the necessary variables, and cygstart can then be changed
to call it, instead of its own setup_win_environ() function.

That would mean that the bug won't be fixed until 1.5.20 is released,
though ...
So, I guess I'll just add some path conversion handling to the cygstart
code itself, for now.  Then if at some point the Cygwin setup_winenv()
function is fixed in a similar way, and released, I might take it out
and call cygwin_internal(CW_SETUP_WINENV) instead.

If I don't see any other suggestions or objections, watch this space for
a patch.

 - Michael

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-07 Thread Christopher Faylor
On Tue, Feb 07, 2006 at 06:59:43PM +0100, Michael Schaap wrote:
On 7-Feb-2006 3:31, Yitzchak Scott-Thoennes wrote:
 On Mon, Feb 06, 2006 at 11:40:22PM +0100, Michael Schaap wrote:
   
 What we basically need to do, is copy the Cygwin environment to the
 Windows environment, taking care of path conversion for all the
 appropriate variables.
 

 Maybe start with:

 http://www.cygwin.com/ml/cygwin-patches/2005-q4/msg9.html
   

Not really, I think, especially since that code didn't make it into
Cygwin.  ;-)
(Also, Corinna suggested in that thread that an application should
simply convert the necessary variables itself.)

I did notice, though, that a new version, setup_winenv(), externally
callable as cygwin_internal(CW_SETUP_WINENV), was made available ...
last Thursday.  (Looks like the code was adapted from the cygstart code,
actually. :-) )
So, ideally, that function would be fixed to do POSIX to Windows
conversion on the necessary variables, and cygstart can then be changed
to call it, instead of its own setup_win_environ() function.

That would mean that the bug won't be fixed until 1.5.20 is released,
though ...
So, I guess I'll just add some path conversion handling to the cygstart
code itself, for now.  Then if at some point the Cygwin setup_winenv()
function is fixed in a similar way, and released, I might take it out
and call cygwin_internal(CW_SETUP_WINENV) instead.

I believe that Brian Ford is looking into modifying the new CW_SETUP_WINENV
code to perform the proper conversion of POSIX style to Windows style.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-06 Thread David Picton
On 2/3/06, Igor Peshansky [EMAIL PROTECTED] wrote:
 On Fri, 3 Feb 2006, David Picton wrote:

  I have encountered a strange bug when starting Microsoft Word when it is
  started by the cygstart command, e.g. cygstart Index.doc, with the
  current version of the Cygwin dll.
 
  The symptoms are as follows:
 
  1.  Word appears to start normally, and the file can be edited on screen.

[snip]

  3.  Attempting to save the file gets no response.  The only way to close
  the window is to exit without saving!

[snip]


 Sounds like an instance of
 http://cygwin.com/ml/cygwin/2005-05/msg00587.html...  Does it work if
 you cygstart cmd and then start word from that cmd shell?  If you get
 the same symptoms, please run set in that cmd window and compare the
 output with the same in a cmd started via Start-Run...

I get the same symptoms, and now I can see what the problem is.  The 
CMD window shows that TEMP and TMP have retained Cygwin-style
pathnames:

TEMP=/cygdrive/c/DOCUME~1/dave/LOCALS~1/Temp
TMP=/cygdrive/c/DOCUME~1/dave/LOCALS~1/Temp

Word works OK if I set TMP to a proper Windows pathname e.g. D:\cygwin\tmp


 Do you get the same problem if you use run winword.exe filename?  Which
 version of Word are you trying to use?

No.  Everything worked normally when I did the following:

export PATH='/cygdrive/c/program files/microsoft office/office11':$PATH
run winword paper1.doc

The problem seems to be specific to commands started by cygstart (with
the current
Cygwin dll) but isn't specific to one version of Word - I've seen it
with both Word 2003
and Word 2000.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-06 Thread Yitzchak Scott-Thoennes
On Mon, Feb 06, 2006 at 11:40:22PM +0100, Michael Schaap wrote:
 What we basically need to do, is copy the Cygwin environment to the
 Windows environment, taking care of path conversion for all the
 appropriate variables.

Maybe start with:

http://www.cygwin.com/ml/cygwin-patches/2005-q4/msg9.html

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: strange cygstart bug with current Cygwin versions

2006-02-03 Thread Igor Peshansky
On Fri, 3 Feb 2006, David Picton wrote:

 I have encountered a strange bug when starting Microsoft Word when it is
 started by the cygstart command, e.g. cygstart Index.doc, with the
 current version of the Cygwin dll.

 The symptoms are as follows:

 1.  Word appears to start normally, and the file can be edited on screen.

 2.  However, when Word should be autosaving, a message appears to the
 effect that the auto-recovery save has been postponed.

 3.  Attempting to save the file gets no response.  The only way to close
 the window is to exit without saving!

 To attempt to reproduce the bug, you need to open a Word document using
 cygstart, change the document, then try to save it.

 I have seen this bug on two of the three computers which I use - all
 with the latest release of Cygwin.  Reverting to the previous version
 doesn't help, but the bug goes away if I restore a pre-January version
 of Cygwin.  It also goes away if I invoke the Word binary (winword.exe)
 directly from the command line or a shell script.

Sounds like an instance of
http://cygwin.com/ml/cygwin/2005-05/msg00587.html...  Does it work if
you cygstart cmd and then start word from that cmd shell?  If you get
the same symptoms, please run set in that cmd window and compare the
output with the same in a cmd started via Start-Run...

Do you get the same problem if you use run winword.exe filename?  Which
version of Word are you trying to use?

I know that Word uses /tmp for temporary files when started via Cygwin.
Check permissions on your /tmp.  Otherwise, we'll need more details, as I,
for one, can't reproduce your problem.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte.
But no -- you are no fool; you call yourself a fool, there's proof enough in
that! -- Rostand, Cyrano de Bergerac

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/