delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/10/08/22:57:34

Date: Thu, 09 Oct 1997 15:57:25 +1100
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: gethostname
To: djgpp-workers AT delorie DOT com
Message-id: <199710090254.PAA01999@teleng1.tait.co.nz gatekeeper.tait.co.nz>
Organization: Tait Electronics Limited
MIME-version: 1.0
Comments: Authenticated sender is <billc AT blackmagic DOT tait DOT co DOT nz>

--Message-Boundary-1114
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

gethostname() in 2.01 under w95 returns (for example) 
"currieb        ", which I beleive is not really any good. Can host 
names have any spaces in them at all? Trailing spaces certainly don't 
make any sence.

Here's a patch to cause gethostname() to strip trailing spaces from 
the machine name when int 0x21, ax=0x5e00 succeeds (does not affect 
HOSTNAME from the environment).


Bill
--
Leave others their otherness.


--Message-Boundary-1114
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'gethostn.patch'

*** gethostn.c~	Thu Oct  9 15:25:00 1997
--- gethostn.c	Thu Oct  9 15:33:04 1997
***************
*** 31,38 ****
    }
    else
    {
!     dosmemget (__tb, sizeof (dosbuf), dosbuf);
!     h = dosbuf;
    }
  
    len = strlen (h);
--- 31,41 ----
    }
    else
    {
! 	dosmemget (__tb, sizeof (dosbuf), dosbuf);
! 	h = dosbuf + strlen (dosbuf);
! 	while (h > dosbuf && h[-1] == ' ') h--;
! 	*h = 0;
! 	h = dosbuf;
    }
  
    len = strlen (h);

--Message-Boundary-1114--

- Raw text -


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