A pair of editor related changes
Sigbjorn Finne
sigbjorn_finne@hotmail.com
Mon, 5 Feb 2001 15:56:07 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_0007_01C08F8C.26CC98F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hi,
great to see that Hugs98 isn't withering, but that new
releases keep coming out. Attached are some diffs that
might be of interest - they fix the following:
* when invoking the editor, cope with filenames containing
spaces (and other icky characters) by escaping them
in double-quotes.
* don't hardwire the location of notepad.exe as the
default editor (and make notepad.exe the default
editor on Win32 platforms, not just with Hugs for
Windows.)
The changes have only been tested on Win2k using MSVC;
the diffs are wrt the Jan 2001 sources.
--sigbjorn
------=_NextPart_000_0007_01C08F8C.26CC98F0
Content-Type: application/octet-stream;
name="editor-patches"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="editor-patches"
*** hugs.c.~1~ Wed Jan 31 07:39:30 2001
--- hugs.c Mon Feb 5 14:39:30 2001
***************
*** 24,27 ****
--- 24,31 ----
#include <stdio.h>
=20
+ #if HAVE_WINDOWS_H
+ #include <windows.h>
+ #endif
+=20
#if HUGS_FOR_WINDOWS
#include "winhugs\WinHugs.h"
***************
*** 258,263 ****
namesUpto =3D 1;
=20
! #if HUGS_FOR_WINDOWS
! hugsEdit =3D =
strCopy(fromEnv("EDITOR","c:\\windows\\notepad.exe"));
#elif SYMANTEC_C
hugsEdit =3D "";
--- 262,289 ----
namesUpto =3D 1;
=20
! #if HUGS_FOR_WINDOWS || HAVE_WINDOWS_H
! #define DEFAULT_EDITOR "\\notepad.exe"
! /*
! * Check first to see if the user has explicitly defined
! * an editor via the environment variable EDITOR..
! */
! hugsEdit =3D strCopy(fromEnv("EDITOR",NULL));
! if (hugsEdit =3D=3D NULL) {
! UINT rc;
! int notePadLen =3D strlen(DEFAULT_EDITOR);
! char* notePadLoc;
! /*
! * Nope, the default editor is used instead. In our case
! * this is 'notepad', which we assume is always residing
! * in the windows directory, so locate it first..
! */
! =20
! notePadLoc =3D _alloca(sizeof(char)*(MAX_PATH + notePadLen + =
1));
! rc =3D GetWindowsDirectory(notePadLoc, MAX_PATH);
! if ( !(rc =3D=3D 0 || rc > MAX_PATH) ) {
! strcat(notePadLoc, DEFAULT_EDITOR);
! hugsEdit =3D strCopy(notePadLoc);
! }
! }
#elif SYMANTEC_C
hugsEdit =3D "";
*** machdep.c.~1~ Wed Jan 31 22:10:38 2001
--- machdep.c Mon Feb 5 15:29:58 2001
***************
*** 1122,1127 ****
he++;
}
! else if (*he=3D=3D's' && (size_t)n>strlen(nm)) {
! strcpy(ec,nm);
rd =3D NULL;
he++;
--- 1122,1131 ----
he++;
}
! else if (*he=3D=3D's' && (size_t)n>(strlen(nm)+2)) {
! /* Protect the filename by putting quotes around it =
*/
! *ec++=3D'\"';
! strcpy(ec,nm); ec +=3D strlen(nm);
! *ec++=3D'\"';
! *ec=3D'\0';
rd =3D NULL;
he++;
***************
*** 1151,1157 ****
=20
if (nm && line=3D=3D0 && n>1) { /* Name, but no line ... =
*/
! *ec++ =3D ' ';
! for (; n>0 && *nm; n--) /* ... just copy file name */
! *ec++ =3D *nm++;
}
=20
--- 1155,1169 ----
=20
if (nm && line=3D=3D0 && n>1) { /* Name, but no line ... =
*/
! *ec++ =3D ' ';=20
! /* Protect the filename by putting quotes around it */
! if (n>0) {
! *ec++ =3D '\"'; n--;
! }
! for (; n>0 && *nm; n--) /* ... just copy file name */
! *ec++ =3D *nm++;
! if (n>0) {
! *ec++ =3D '\"';
! n--;
! }
}
=20
------=_NextPart_000_0007_01C08F8C.26CC98F0--