diff options
Diffstat (limited to 'usr.bin/encrypt/encrypt.c')
-rw-r--r-- | usr.bin/encrypt/encrypt.c | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/usr.bin/encrypt/encrypt.c b/usr.bin/encrypt/encrypt.c index e243d34441d..08d97c373fe 100644 --- a/usr.bin/encrypt/encrypt.c +++ b/usr.bin/encrypt/encrypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: encrypt.c,v 1.27 2007/05/01 01:26:25 jdixon Exp $ */ +/* $OpenBSD: encrypt.c,v 1.28 2007/07/14 21:26:38 krw Exp $ */ /* * Copyright (c) 1996, Jason Downs. All rights reserved. @@ -51,7 +51,6 @@ extern char *__progname; char buffer[_PASSWORD_LEN]; void usage(void); -char *trim(char *); void print_passwd(char *, int, void *); void @@ -64,26 +63,6 @@ usage(void) exit(1); } -char * -trim(char *line) -{ - char *ptr; - - if (line[0] == '\0') - return (line); - - for (ptr = &line[strlen(line)-1]; ptr > line; ptr--) { - if (!isspace(*ptr)) - break; - } - ptr[1] = '\0'; - - for (ptr = line; isspace(*ptr); ptr++) - ; - - return(ptr); -} - void print_passwd(char *string, int operation, void *extra) { @@ -206,15 +185,17 @@ main(int argc, char **argv) print_passwd(string, operation, extra); (void)fputc('\n', stdout); } else { + size_t len; /* Encrypt stdin to stdout. */ while (!feof(stdin) && (fgets(line, sizeof(line), stdin) != NULL)) { - /* Kill the whitesapce. */ - string = trim(line); - if (*string == '\0') + len = strlen(line); + if (len == 0 || line[0] == '\n') continue; - - print_passwd(string, operation, extra); + if (line[len - 1] == '\n') + line[len - 1] = '\0'; + + print_passwd(line, operation, extra); if (operation == DO_MAKEKEY) { fflush(stdout); |