*BSD News Article 8526


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!uwm.edu!caen!uunet!mcsun!fuug!kiae!demos!newsserv
From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su>
Newsgroups: comp.unix.bsd
Subject: [386bsd] Patch glob() from libc, error function
Date: Thu, 03 Dec 92 21:11:38 +0300
Distribution: world
Organization: Ha-oh-lahm Yetzirah
Message-ID: <AGQta7hGh2@astral.msk.su>
Sender: news-service@newcom.kiae.su
Reply-To: ache@astral.msk.su
Lines: 72

When glob() call errfunc, it doesn't convert extended char*
(u_short *) to char*, so errfunc print only first pathbuf letter
(second char from u_short is '\0').
When I test it, I uncomment DEBUG define and got compilation error.
This patch fix both bugs:

*** glob.c.was	Mon Jun 24 18:35:42 1991
--- glob.c	Mon Nov 30 03:54:27 1992
***************
*** 332,341 ****
  	    
  	if (!(dirp = g_opendir(pathbuf)))
  		/* TODO: don't call for ENOENT or ENOTDIR? */
! 		if (pglob->gl_errfunc &&
! 		    (*pglob->gl_errfunc)(pathbuf, errno) ||
! 		    (pglob->gl_flags & GLOB_ERR))
  			return(GLOB_ABEND);
  		else
  			return(0);
  
--- 332,347 ----
  	    
  	if (!(dirp = g_opendir(pathbuf)))
  		/* TODO: don't call for ENOENT or ENOTDIR? */
! 		if (pglob->gl_errfunc) {
! 		    char buf[MAXPATHLEN];
! 
! 		    g_Ctoc(pathbuf, buf);
! 		    if ((*pglob->gl_errfunc)(buf, errno) ||
! 			(pglob->gl_flags & GLOB_ERR))
  			return(GLOB_ABEND);
+ 		    else
+ 			return(0);
+ 		}
  		else
  			return(0);
  
***************
*** 544,556 ****
  	register Char *p;
  
  	for (p = s; *p; p++)
! 		(void)printf("%c", *p & 0xff);
  	(void)printf("\n");
  	for (p = s; *p; p++)
  		(void)printf("%c", *p & M_PROTECT ? '"' : ' ');
  	(void)printf("\n");
  	for (p = s; *p; p++)
! 		(void)printf("%c", *p & M_META ? '_' : ' ');
  	(void)printf("\n");
  }
  #endif
--- 550,562 ----
  	register Char *p;
  
  	for (p = s; *p; p++)
! 		(void)printf("%c", CHAR(*p));
  	(void)printf("\n");
  	for (p = s; *p; p++)
  		(void)printf("%c", *p & M_PROTECT ? '"' : ' ');
  	(void)printf("\n");
  	for (p = s; *p; p++)
! 		(void)printf("%c", ismeta(*p) ? '_' : ' ');
  	(void)printf("\n");
  }
  #endif
-- 
In-This-Life:  Andrew A. Chernov    |  "Hay mas dicha, mas contento
Internet:      ache@astral.msk.su   |  "Que adorar una hermosura
Organization:  The RELCOM Corp.,    |  "Brujuleada entre los lejos
               Moscow, Russia       |  "De lo imposible?!"  (Calderon)