(writeHex): When given several bytes, don't write the first one many times.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@18024 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-11-02 02:11:33 +00:00
parent baa14f193b
commit dbe4650406
2 changed files with 25 additions and 17 deletions

View file

@ -1,3 +1,11 @@
2003-11-02 02:58 Alexander Malmberg <alexander@malmberg.org>
* Source/gsc/GSStreamContext.m Whitespace cleanups.
(writeHex): Use index properly; don't always write the first byte.
Use fputc() instead of fprintf() (was doing the hex conversion
manually anyway, might as well make it efficient).
2003-11-02 02:27 Alexander Malmberg <alexander@malmberg.org>
* Source/gsc/GSStreamContext.m (fpfloat, writeHex): Make static.

View file

@ -795,16 +795,16 @@ fpfloat(FILE *stream, float f)
@end
static char *hexdigits = "0123456789abcdef";
static void
writeHex(FILE *gstream, const unsigned char *data, int count)
{
static const char *hexdigits = "0123456789abcdef";
int i;
for (i = 0; i < count; i++)
{
fprintf(gstream, "%c%c", hexdigits[(int)(data[0]/16)],
hexdigits[(data[0] % 16)]);
fputc(hexdigits[(int)(data[i] / 16)], gstream);
fputc(hexdigits[(int)(data[i] % 16)], gstream);
if (i && i % 40 == 0)
fprintf(gstream, "\n");
}