File: fmt_strn.c

package info (click to toggle)
libowfat 0.22-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,148 kB
  • ctags: 976
  • sloc: ansic: 10,424; makefile: 42
file content (14 lines) | stat: -rw-r--r-- 471 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "fmt.h"

unsigned long fmt_strn(char *out,const char *in,unsigned long limit) {
  register char* s=out;
  register const char* t=in;
  register const char* u=in+limit;
  for (;;) {
    if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t;
    if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t;
    if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t;
    if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t;
  }
  return t-in;
}