Przeglądaj źródła

fmt_str was broken. It did not check for out==NULL

master
Felix von Leitner 20 lat temu
rodzic
commit
5d07297e8c
  1. 3
      CHANGES
  2. 10
      fmt/fmt_str.c
  3. 5
      t.c

3
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.

10
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;
}

5
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");

Ładowanie…
Anuluj
Zapisz