diff --git a/CHANGES b/CHANGES index 366d527..18bb8e9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +0.9: + fmt_str did not check for out==NULL! Thanks, Uwe Ohse. + 0.8: BSD compatibility. fix mmap_shared. diff --git a/fmt/fmt_str.c b/fmt/fmt_str.c index 221c33c..0130f19 100644 --- a/fmt/fmt_str.c +++ b/fmt/fmt_str.c @@ -4,10 +4,10 @@ unsigned int fmt_str(char *out,const char *in) { register char* s=out; register const char* t=in; for (;;) { - if (!*t) break; *s=*t; ++s; ++t; - if (!*t) break; *s=*t; ++s; ++t; - if (!*t) break; *s=*t; ++s; ++t; - if (!*t) break; *s=*t; ++s; ++t; + if (!*t) break; if (s) { *s=*t; ++s; } ++t; + if (!*t) break; if (s) { *s=*t; ++s; } ++t; + if (!*t) break; if (s) { *s=*t; ++s; } ++t; + if (!*t) break; if (s) { *s=*t; ++s; } ++t; } - return s-out; + return t-in; } diff --git a/t.c b/t.c index a37bfb7..632a47a 100644 --- a/t.c +++ b/t.c @@ -14,7 +14,10 @@ __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") int main(int argc,char* argv[]) { -#if 1 + char buf[100]; + printf("%d\n",fmt_str(buf,"fnord")); + printf("%d\n",fmt_str(0,"fnord")); +#if 0 buffer_putulong(buffer_1,23); // buffer_putspace(buffer_1); buffer_putsflush(buffer_1,"\n");