On Sat, Jun 16, 2001 at 11:40:30AM -0400, Cris Jacobin came up with this idea:
>> Daniel A. Koepke wrote...
>> since you're providing an unsigned value for a signed conversion. What
>> compiler are you using? Are all the warnings turned on?
side note: I didn't get them with gcc 2.95.2 complaining about the
signedness of %Lu or %Ld that I can remember, although I did get the
errors at comparisons on a few scattered lines. Did that switch long
time ago though so I might be forgetting too.
> One other thing for the archives, in case anyone decides to take this
> route. It's actually fairly easy to implement. Took me around a half
> hour from start to finish. The trick is, if you only want affects don't
Even with roomflags it's not too horrific.
> make everything a wide bitvector. There was no need to play with
> roomflags and such, which eliminated the need to play around with the
> ascii conversion routines.
tested, retested, beat on, fed bogus data, you name it; it works fine.
(suppose I coulda used digits too, just didn't)
void sprintbits(bitvector_t vektor, char *outstring)
{
int i;
char flags[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#$%&'()*+,-.";
strcpy(outstring, "");
for (i = 0; i < 64; i++) {
if (vektor & 1) {
*outstring = flags[i];
outstring++;
};
vektor >>= 1;
};
*outstring = 0;
};
bitvector_t asciiflag_conv(char *flag)
{
bitvector_t flags = 0;
int is_number = 1;
register char *p;
for (p = flag; *p; p++) {
if (islower(*p))
flags |= 1 << (*p - 'a');
else if (isupper(*p))
flags |= 1 << (26 + (*p - 'A'));
else if (ispunct(*p))
flags |= 1 << (52 + (*p - '#'));
if (!isdigit(*p))
is_number = 0;
}
if (is_number)
sscanf(flag, "%Lu", &flags);
/* I prefer that method to strtoul, suppose it could work though,
* but I did have problems with it a few other places.
* Since I control the input to it, format isn't a problem.
*/
//flags = strtoul(flag);
return (flags);
}
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/05/01 PST