RPM Community Forums

Mailing List Message of <popt-devel>

Re: popt isspace use

From: Jeff Johnson <n3npq@mac.com>
Date: Sat 03 Nov 2007 - 23:50:58 CET
Message-Id: <ED42F125-F6A3-4043-953B-B6209C346694@mac.com>
Added. Thanks for the patch.

73 de Jeff

On Nov 3, 2007, at 12:21 PM, Emanuele Giaquinta wrote:

> Index: poptconfig.c
> ===================================================================
> RCS file: /v/rpm/cvs/popt/poptconfig.c,v
> retrieving revision 1.31
> diff -u -r1.31 poptconfig.c
> --- poptconfig.c	6 Oct 2007 02:14:42 -0000	1.31
> +++ poptconfig.c	3 Nov 2007 16:14:42 -0000
> @@ -33,20 +33,20 @@
>      if (strncmp(line, con->appName, nameLength)) return;
>
>      line += nameLength;
> -    if (*line == '\0' || !isspace(*line)) return;
> +    if (*line == '\0' || !_isspaceptr(line)) return;
>
> -    while (*line != '\0' && isspace(*line)) line++;
> +    while (*line != '\0' && _isspaceptr(line)) line++;
>      entryType = line;
> -    while (*line == '\0' || !isspace(*line)) line++;
> +    while (*line == '\0' || !_isspaceptr(line)) line++;
>      *line++ = '\0';
>
> -    while (*line != '\0' && isspace(*line)) line++;
> +    while (*line != '\0' && _isspaceptr(line)) line++;
>      if (*line == '\0') return;
>      opt = line;
> -    while (*line == '\0' || !isspace(*line)) line++;
> +    while (*line == '\0' || !_isspaceptr(line)) line++;
>      *line++ = '\0';
>
> -    while (*line != '\0' && isspace(*line)) line++;
> +    while (*line != '\0' && _isspaceptr(line)) line++;
>      if (*line == '\0') return;
>
>  /*@-temptrans@*/ /* FIX: line alias is saved */
> @@ -139,7 +139,7 @@
>  	  case '\n':
>  	    *dst = '\0';
>  	    dst = buf;
> -	    while (*dst && isspace(*dst)) dst++;
> +	    while (*dst && _isspaceptr(dst)) dst++;
>  	    if (*dst && *dst != '#')
>  		configLine(con, dst);
>  	    chptr++;
> Index: popthelp.c
> ===================================================================
> RCS file: /v/rpm/cvs/popt/popthelp.c,v
> retrieving revision 1.64
> diff -u -r1.64 popthelp.c
> --- popthelp.c	25 Aug 2007 00:54:57 -0000	1.64
> +++ popthelp.c	3 Nov 2007 16:14:42 -0000
> @@ -24,9 +24,6 @@
>
>  /*@access poptContext@*/
>
> -/* XXX isspace(3) has i18n encoding signednesss issues on Solaris. */
> -#define	_isspaceptr(_chp)	isspace((int)(*(unsigned char *)(_chp)))
> -
>  /**
>   * Display arguments.
>   * @param con		context
> Index: poptparse.c
> ===================================================================
> RCS file: /v/rpm/cvs/popt/poptparse.c,v
> retrieving revision 1.25
> diff -u -r1.25 poptparse.c
> --- poptparse.c	13 Jul 2007 12:24:00 -0000	1.25
> +++ poptparse.c	3 Nov 2007 16:14:42 -0000
> @@ -86,7 +86,7 @@
>  		if (*src != quote) *buf++ = '\\';
>  	    }
>  	    *buf++ = *src;
> -	} else if (isspace(*src)) {
> +	} else if (_isspaceptr(src)) {
>  	    if (*argv[argc] != '\0') {
>  		buf++, argc++;
>  		if (argc == argvAlloced) {
> @@ -161,7 +161,7 @@
>  	p = line;
>
>  	/* loop until first non-space char or EOL */
> -	while( *p != '\0' && isspace(*p) )
> +	while( *p != '\0' && _isspaceptr(p) )
>  	    p++;
>
>  	linelen = strlen(p);
> @@ -175,13 +175,13 @@
>
>  	q = p;
>
> -	while (*q != '\0' && (!isspace(*q)) && *q != '=')
> +	while (*q != '\0' && (!_isspaceptr(q)) && *q != '=')
>  	    q++;
>
> -	if (isspace(*q)) {
> +	if (_isspaceptr(q)) {
>  	    /* a space after the name, find next non space */
>  	    *q++='\0';
> -	    while( *q != '\0' && isspace((int)*q) ) q++;
> +	    while( *q != '\0' && _isspaceptr(q) ) q++;
>  	}
>  	if (*q == '\0') {
>  	    /* single command line option (ie, no name=val, just name) */
> @@ -203,14 +203,14 @@
>  	*q++ = '\0';
>
>  	/* find next non-space letter of value */
> -	while (*q != '\0' && isspace(*q))
> +	while (*q != '\0' && _isspaceptr(q))
>  	    q++;
>  	if (*q == '\0')
>  	    continue;	/* XXX silently ignore missing value */
>
>  	/* now, loop and strip all ending whitespace */
>  	x = p + linelen;
> -	while (isspace(*--x))
> +	while (_isspaceptr(--x))
>  	    *x = '\0';	/* null out last char if space (including fgets()  
> NL) */
>
>  	/* rest of line accept */
> Index: system.h
> ===================================================================
> RCS file: /v/rpm/cvs/popt/system.h,v
> retrieving revision 1.10
> diff -u -r1.10 system.h
> --- system.h	14 Jun 2007 13:31:10 -0000	1.10
> +++ system.h	3 Nov 2007 16:14:42 -0000
> @@ -17,6 +17,9 @@
>
>  #include <ctype.h>
>
> +/* XXX isspace(3) has i18n encoding signednesss issues on Solaris. */
> +#define	_isspaceptr(_chp)	isspace((int)(*(unsigned char *)(_chp)))
> +
>  #include <errno.h>
>  #include <fcntl.h>
>  #include <limits.h>
Received on Sat Nov 3 23:53:31 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.