Re: 2.5.6pre1 bombs on Sunos4 in popthelp.c on use of sprintf

2003-01-14 Thread Dave Dykstra
On Tue, Jan 14, 2003 at 10:24:04AM -0600, Dave Dykstra wrote:
 2.5.6pre1 bombs on Sunos4 gcc with these errors
 popt/popthelp.c: In function `singleOptionDefaultValue':
 popt/popthelp.c:137: invalid operands to binary +
 popt/popthelp.c:141: invalid operands to binary +
 popt/popthelp.c:145: invalid operands to binary +
 popt/popthelp.c:149: invalid operands to binary +
 because it's depending on sprintf to return the number of bytes written
 and that doesn't happen on Sunos4.

If nobody objects to the following patch, I'll put it in.  It's a little
slower but this is definitely not time-critical code.

- Dave


--- popt/popthelp.c.O   Tue Jan 14 13:02:47 2003
+++ popt/popthelp.c Tue Jan 14 13:04:45 2003
@@ -134,19 +134,23 @@
 case POPT_ARG_VAL:
 case POPT_ARG_INT:
 {  long aLong = *((int *)opt-arg);
-   le += sprintf(le, %ld, aLong);
+   sprintf(le, %ld, aLong);
+   le += strlen(le);
 }  break;
 case POPT_ARG_LONG:
 {  long aLong = *((long *)opt-arg);
-   le += sprintf(le, %ld, aLong);
+   sprintf(le, %ld, aLong);
+   le += strlen(le);
 }  break;
 case POPT_ARG_FLOAT:
 {  double aDouble = *((float *)opt-arg);
-   le += sprintf(le, %g, aDouble);
+   sprintf(le, %g, aDouble);
+   le += strlen(le);
 }  break;
 case POPT_ARG_DOUBLE:
 {  double aDouble = *((double *)opt-arg);
-   le += sprintf(le, %g, aDouble);
+   sprintf(le, %g, aDouble);
+   le += strlen(le);
 }  break;
 case POPT_ARG_STRING:
 {  const char * s = *(const char **)opt-arg;
@@ -271,7 +275,8 @@
*le++ = '=';
if (negate) *le++ = '~';
/*@-formatconst@*/
-   le += sprintf(le, (ops ? 0x%lx : %ld), aLong);
+   sprintf(le, (ops ? 0x%lx : %ld), aLong);
+   le += strlen(le);
/*@=formatconst@*/
*le++ = ']';
}   break;
-- 
To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html



Re: 2.5.6pre1 bombs on Sunos4 in popthelp.c on use of sprintf

2003-01-14 Thread jw schultz
On Tue, Jan 14, 2003 at 11:20:43AM -0600, Dave Dykstra wrote:
 On Tue, Jan 14, 2003 at 10:24:04AM -0600, Dave Dykstra wrote:
  2.5.6pre1 bombs on Sunos4 gcc with these errors
  popt/popthelp.c: In function `singleOptionDefaultValue':
  popt/popthelp.c:137: invalid operands to binary +
  popt/popthelp.c:141: invalid operands to binary +
  popt/popthelp.c:145: invalid operands to binary +
  popt/popthelp.c:149: invalid operands to binary +
  because it's depending on sprintf to return the number of bytes written
  and that doesn't happen on Sunos4.
 
 If nobody objects to the following patch, I'll put it in.  It's a little
 slower but this is definitely not time-critical code.

It is a bit ugly but i don't have a problem with the
performance here.

I'd be concerned about someone not knowing about the Sunos4
limitation messing with this though.  At a minimum this
needs comments.  Even better would be if we can manage a way
to conditionally have our own sprintf.  I've a vague nagging
that it can be done but can't recall how.

 
 --- popt/popthelp.c.O Tue Jan 14 13:02:47 2003
 +++ popt/popthelp.c   Tue Jan 14 13:04:45 2003
 @@ -134,19 +134,23 @@
  case POPT_ARG_VAL:
  case POPT_ARG_INT:
  {long aLong = *((int *)opt-arg);
 - le += sprintf(le, %ld, aLong);
 + sprintf(le, %ld, aLong);
 + le += strlen(le);
  }break;
  case POPT_ARG_LONG:
  {long aLong = *((long *)opt-arg);
 - le += sprintf(le, %ld, aLong);
 + sprintf(le, %ld, aLong);
 + le += strlen(le);
  }break;
  case POPT_ARG_FLOAT:
  {double aDouble = *((float *)opt-arg);
 - le += sprintf(le, %g, aDouble);
 + sprintf(le, %g, aDouble);
 + le += strlen(le);
  }break;
  case POPT_ARG_DOUBLE:
  {double aDouble = *((double *)opt-arg);
 - le += sprintf(le, %g, aDouble);
 + sprintf(le, %g, aDouble);
 + le += strlen(le);
  }break;
  case POPT_ARG_STRING:
  {const char * s = *(const char **)opt-arg;
 @@ -271,7 +275,8 @@
   *le++ = '=';
   if (negate) *le++ = '~';
   /*@-formatconst@*/
 - le += sprintf(le, (ops ? 0x%lx : %ld), aLong);
 + sprintf(le, (ops ? 0x%lx : %ld), aLong);
 + le += strlen(le);
   /*@=formatconst@*/
   *le++ = ']';
   }   break;
 -- 
 To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
 Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html

-- 

J.W. SchultzPegasystems Technologies
email address:  [EMAIL PROTECTED]

Remember Cernan and Schmitt
-- 
To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html