--- .zfs/snapshot/2008-07-25/sys/libkern/gets.c 2006-01-14 21:45:02.000000000 +0100 +++ sys/libkern/gets.c 2008-07-25 16:45:59.854716504 +0200 @@ -32,12 +32,33 @@ #include #include +static void ditch_duplicates(char *buf) { + char *p; + int duplicates; + + p = buf; + duplicates = 0; + + while (*p) { + if (*p == *(p+1)) { + bcopy(p+1, p, strlen(p)); + duplicates++; + } else + p++; + } + + if (duplicates) + printf("Ditched %d duplicates.\n", duplicates); +} + void gets(char *cp, size_t size, int visible) { char *lp, *end; int c; + char *buf; + buf = cp; lp = cp; end = cp + size - 1; for (;;) { @@ -47,12 +68,12 @@ case '\r': printf("%c", c); *lp = '\0'; + ditch_duplicates(buf); return; case '\b': case '\177': if (lp > cp) { - if (visible) - printf("%c \b", c); + printf("%c \b", c); lp--; } continue; @@ -60,8 +81,7 @@ continue; default: if (lp < end) { - if (visible) - printf("%c", c); + printf("%c", visible ? c : '*'); *lp++ = c; } }