=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/encrypt/encrypt.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- src/usr.bin/encrypt/encrypt.c 2007/05/01 01:26:25 1.27 +++ src/usr.bin/encrypt/encrypt.c 2007/07/14 21:26:38 1.28 @@ -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 @@ char buffer[_PASSWORD_LEN]; void usage(void); -char *trim(char *); void print_passwd(char *, int, void *); void @@ -64,26 +63,6 @@ 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 @@ 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);