Minor tweaks
Sigbjorn Finne
sigbjorn_finne@hotmail.com
Tue, 6 Mar 2001 10:51:25 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_00AA_01C0A62B.6471D480
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Attached is a patch to Feb2001 which does the following
* flushes stderr when :set -h<size> and :set {+,-}98 is used.
As is, the informational messages that's printed on stderr may
not appear until later with some terminal & CRT combos.
* allows the use of "~/" in :cd commands. ~/ is substituted with
whatever the environment variable HOME contains. It doesn't
do other forms of tilde expansion, but if there's interest I could
always add support for ~login/
i.e., first tweak is a bugfix, the second is a feature tweak.
BTW, is there a technical reason why toggling between Haskell98
and Hugs mode can only be done at startup time?
--sigbjorn
------=_NextPart_000_00AA_01C0A62B.6471D480
Content-Type: application/octet-stream;
name="misc-patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="misc-patch"
*** hugs.c.~1~ Tue Feb 29 02:29:00 2000
--- hugs.c Sun Mar 4 15:39:24 2001
***************
*** 672,675 ****
--- 672,676 ----
(!state && haskell98))) {
FPrintf(stderr,"Haskell 98 compatibility cannot be changed =
while the interpreter is running\n");
+ FFlush(stderr);
} else {
haskell98 =3D state;
***************
*** 696,707 ****
hpSize =3D MAXIMUMHEAP;
if (heapBuilt() && hpSize !=3D heapSize) {
#if HUGS_FOR_WINDOWS
! MessageBox(hWndMain, "Change to heap size will not take =
effect until you rerun Hugs", appName, MB_ICONHAND | MB_OK); =20
#endif =20
#if USE_REGISTRY
! FPrintf(stderr,"Change to heap size will not take effect until =
you rerun Hugs\n");
#else
FPrintf(stderr,"Cannot change heap size\n");
#endif
} else {
heapSize =3D hpSize;
--- 697,711 ----
hpSize =3D MAXIMUMHEAP;
if (heapBuilt() && hpSize !=3D heapSize) {
+ #define HEAP_RESIZE_MSG "Change to heap size will not take effect =
until you rerun Hugs"
#if HUGS_FOR_WINDOWS
! MessageBox(hWndMain, HEAP_RESIZE_MSG, appName, MB_ICONHAND =
| MB_OK);
#endif =20
#if USE_REGISTRY
! FPrintf(stderr,HEAP_RESIZE_MSG "\n");
#else
FPrintf(stderr,"Cannot change heap size\n");
#endif
+ #undef HEAP_RESIZE_MSG
+ FFlush(stderr);
} else {
heapSize =3D hpSize;
***************
*** 984,991 ****
* =
------------------------------------------------------------------------*=
/
=20
static Void local changeDir() { /* change directory =
*/
! String s =3D readFilename();
! if (s && chdir(s)) {
! ERRMSG(0) "Unable to change to directory \"%s\"", s
EEND;
}
--- 988,1027 ----
* =
------------------------------------------------------------------------*=
/
=20
+ /*
+ * Poor man's path expansion: expand out ~/=20
+ */
+ static Void local expandPath(origPath,expandedPath,maxLen)
+ String origPath;
+ String expandedPath;
+ unsigned int maxLen;
+ {
+=20
+ if (!origPath) {
+ return;
+ }
+=20
+ /* If the original path starts with "~/", expand it. */
+ if (*origPath =3D=3D '~' && *(origPath+1) =3D=3D '/') {
+ unsigned int origLen;
+ String home =3D getenv("HOME");
+ origLen =3D (origPath ? strlen(origPath) : 0);
+ /* The expansion of $HOME will fit in iff
+ * (maxLength - length(unexpanded) - length("~")) >=3D =
length("$HOME")
+ */
+ if ( (maxLen - origLen - 1) >=3D strlen(home) ) {
+ strcpy(expandedPath, home);
+ strcat(expandedPath, origPath+1);
+ return;
+ }
+ }
+ strcpy(expandedPath, origPath);
+ }
+=20
static Void local changeDir() { /* change directory =
*/
! String path =3D readFilename();
! char expandedPath[FILENAME_MAX+1];
! expandPath(path, expandedPath,FILENAME_MAX);
! if (path && chdir(expandedPath)) {
! ERRMSG(0) "Unable to change to directory \"%s\"", path
EEND;
}
------=_NextPart_000_00AA_01C0A62B.6471D480--