From 6b5525edbb6797e29bb3f3d022837ddde6949712 Mon Sep 17 00:00:00 2001 From: Stewart Brodie <sbrodie@gitlab.riscosopen.org> Date: Tue, 17 Apr 2001 13:23:50 +0000 Subject: [PATCH] Tidied up the strcmp() fix to remove an unused variable. Initialised so_far in stdio.c to remove compiler warning. Admin: Built. strcmptest() still indicates that strcmp() is working OK! Version 5.32. Tagged as 'RISC_OSLib-5_32' --- VersionASM | 14 +++++++------- VersionNum | 20 ++++++++++---------- c/stdio | 31 ++++++++++++++++++++----------- c/string | 11 +++++------ 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/VersionASM b/VersionASM index 262eab6..448b6ea 100644 --- a/VersionASM +++ b/VersionASM @@ -11,14 +11,14 @@ GBLS Module_HelpVersion GBLS Module_ComponentName GBLS Module_ComponentPath -Module_MajorVersion SETS "5.31" -Module_Version SETA 531 +Module_MajorVersion SETS "5.32" +Module_Version SETA 532 Module_MinorVersion SETS "" -Module_Date SETS "11 Apr 2001" -Module_ApplicationDate2 SETS "11-Apr-01" -Module_ApplicationDate4 SETS "11-Apr-2001" +Module_Date SETS "17 Apr 2001" +Module_ApplicationDate2 SETS "17-Apr-01" +Module_ApplicationDate4 SETS "17-Apr-2001" Module_ComponentName SETS "RISC_OSLib" Module_ComponentPath SETS "RiscOS/Sources/Lib/RISC_OSLib" -Module_FullVersion SETS "5.31" -Module_HelpVersion SETS "5.31 (11 Apr 2001)" +Module_FullVersion SETS "5.32" +Module_HelpVersion SETS "5.32 (17 Apr 2001)" END diff --git a/VersionNum b/VersionNum index 9e12d2e..4cf6900 100644 --- a/VersionNum +++ b/VersionNum @@ -1,22 +1,22 @@ -/* (5.31) +/* (5.32) * * This file is automatically maintained by srccommit, do not edit manually. * */ -#define Module_MajorVersion_CMHG 5.31 +#define Module_MajorVersion_CMHG 5.32 #define Module_MinorVersion_CMHG -#define Module_Date_CMHG 11 Apr 2001 +#define Module_Date_CMHG 17 Apr 2001 -#define Module_MajorVersion "5.31" -#define Module_Version 531 +#define Module_MajorVersion "5.32" +#define Module_Version 532 #define Module_MinorVersion "" -#define Module_Date "11 Apr 2001" +#define Module_Date "17 Apr 2001" -#define Module_ApplicationDate2 "11-Apr-01" -#define Module_ApplicationDate4 "11-Apr-2001" +#define Module_ApplicationDate2 "17-Apr-01" +#define Module_ApplicationDate4 "17-Apr-2001" #define Module_ComponentName "RISC_OSLib" #define Module_ComponentPath "RiscOS/Sources/Lib/RISC_OSLib" -#define Module_FullVersion "5.31" -#define Module_HelpVersion "5.31 (11 Apr 2001)" +#define Module_FullVersion "5.32" +#define Module_HelpVersion "5.32 (17 Apr 2001)" diff --git a/c/stdio b/c/stdio index cd0824e..bad330c 100644 --- a/c/stdio +++ b/c/stdio @@ -161,11 +161,11 @@ int (feof)(FILE *stream) { return feof(stream); } int (ferror)(FILE *stream) { return ferror(stream); } #define STDOUT stderr #ifdef DEBUG -#define dbmsg(m, m2) if (stream > STDOUT || stream == stdin) {int last ;int iw; char v[128]; \ +#define dbmsg(m, m2) if (stream > STDOUT || stream == stdin) {int last=0 ;int iw; char v[128]; \ sprintf(v, m, m2); \ for(iw=0;v[iw];_kernel_oswrch(last=v[iw++])); \ - if (last = 10)_kernel_oswrch(13);} -#define dbmsg_noNL(m, m2) if (stream > STDOUT || stream == stdin) {int last ;int iw; char v[128]; \ + if (last == 10)_kernel_oswrch(13);} +#define dbmsg_noNL(m, m2) if (stream > STDOUT || stream == stdin) {int last=0 ;int iw; char v[128]; \ sprintf(v, m, m2); \ for(iw=0;v[iw];_kernel_oswrch(last=v[iw++]));} #else @@ -329,7 +329,9 @@ else dbmsg("%s\n", ".....already there"); extern int __flsbuf(int ch, FILE *stream) { int flag; dbmsg_noNL("%s ", "__flsbuf"); -dbmsg("%c\n", ch); +dbmsg_noNL("%c ",ch<32?' ':ch); +dbmsg_noNL("(%d/", ch); +dbmsg("&%02x)\n", ch); stream->__flag = (stream->__flag & ~_IOUNGET) | _IOACTIVE; if (stream->__flag & _IOLAZY) _deferredlazyseek(stream); @@ -818,15 +820,22 @@ static int _write(const char *ptr, int nbytes, FILE *stream) /* H&S say 0 on error */ } else if (nbytes > 0) { - if (stream->__ocnt >= nbytes) { + int so_far = 0; + + if (stream->__ocnt < 0) { + /* Not ready for writes, so do one putc to force it into a nice state. */ + if (putc(*ptr++, stream) == EOF) return 0; + ++so_far; + } + + if (stream->__ocnt >= (nbytes - so_far)) { /* output will fit completely into our output buffer */ - memcpy(stream->__ptr, ptr, nbytes); - stream->__ptr += nbytes; - stream->__ocnt -= nbytes; - ptr += nbytes; + memcpy(stream->__ptr, ptr, nbytes - so_far); + stream->__ptr += nbytes - so_far; + stream->__ocnt -= nbytes - so_far; + ptr += nbytes - so_far; } else { - int so_far = 0; /* Fill the existing buffer */ if (stream->__ocnt > 0) { /* Space exists - write the data to the buffer en bloc */ @@ -907,7 +916,7 @@ size_t fwrite(const void *ptr, size_t itemsize, size_t count, FILE *stream) { /* The comments made about fread apply here too */ dbmsg_noNL("fwrite %d ", count); -dbmsg("itemsize %d\n", itemsize); +dbmsg("itemsize %d (decimal)\n", itemsize); return itemsize == 0 ? count : _write(ptr, itemsize*count, stream) / itemsize; } diff --git a/c/string b/c/string index 1a324a5..383c1c9 100644 --- a/c/string +++ b/c/string @@ -262,15 +262,14 @@ strcmp_checkbytes: * on the subtraction. Right-shift on signed integers implementation defined, * but because we mask w1 and w2 with res, whether ASL or LSL is used is irrelevant. */ - rc = res & -res; - res = 0xFF; + rc = 0xFF; for (;;) { - if (((w1 | w2) & res) == 0) return 0; - if (rc & res) return (w1 & res) - (w2 & res); + if (((w1 | w2) & rc) == 0) return 0; + if (rc & res) return (w1 & rc) - (w2 & rc); w1 >>= 1; w2 >>= 1; - rc >>= 1; - res <<= 7; + res >>= 1; + rc <<= 7; } # endif /* WANT_ARMS_BROKEN_STRCMP_FOR_TOP_BIT_SET_CHARACTERS */ #else -- GitLab