=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/encrypt/encrypt.c,v retrieving revision 1.27 retrieving revision 1.28 diff -c -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 **** ! /* $OpenBSD: encrypt.c,v 1.27 2007/05/01 01:26:25 jdixon Exp $ */ /* * Copyright (c) 1996, Jason Downs. All rights reserved. --- 1,4 ---- ! /* $OpenBSD: encrypt.c,v 1.28 2007/07/14 21:26:38 krw Exp $ */ /* * Copyright (c) 1996, Jason Downs. All rights reserved. *************** *** 51,57 **** char buffer[_PASSWORD_LEN]; void usage(void); - char *trim(char *); void print_passwd(char *, int, void *); void --- 51,56 ---- *************** *** 64,89 **** 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) { --- 63,68 ---- *************** *** 206,220 **** print_passwd(string, operation, extra); (void)fputc('\n', stdout); } else { /* Encrypt stdin to stdout. */ while (!feof(stdin) && (fgets(line, sizeof(line), stdin) != NULL)) { ! /* Kill the whitesapce. */ ! string = trim(line); ! if (*string == '\0') continue; ! ! print_passwd(string, operation, extra); if (operation == DO_MAKEKEY) { fflush(stdout); --- 185,201 ---- 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)) { ! len = strlen(line); ! if (len == 0 || line[0] == '\n') continue; ! if (line[len - 1] == '\n') ! line[len - 1] = '\0'; ! ! print_passwd(line, operation, extra); if (operation == DO_MAKEKEY) { fflush(stdout);