vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, here is a patch for 'from'. With this patch, from is able to handle long lines and able to parse for long strings given via -s [name]. PS. Here is a code part i didn't touched because I'm not sure, what this sould do: #if MAXPATHLEN > BUFSIZ char buf[MAXPATHLEN]; #else char buf[BUFSIZ]; #endif I wonder about these lines because there is no MAXPATHLEN defined... -- steffen Here is the patch: [root@eygo /usr/src/usr.bin/from] ==> cvs diff -up from.c Makefile Index: from.c ================================================== ================= RCS file: /cvs/src/usr.bin/from/from.c,v retrieving revision 1.12 diff -u -p -r1.12 from.c --- from.c 14 Mar 2006 19:39:49 -0000 1.12 +++ from.c 16 Aug 2006 12:43:50 -0000 @@ -52,6 +52,8 @@ static char rcsid[] = "$OpenBSD: from.c, #include <paths.h> #include <string.h> #include <err.h> +#include <readline/readline.h> +#include <readline/history.h> int match(char *, char *); @@ -66,8 +68,9 @@ main(int argc, char *argv[]) #else char buf[BUFSIZ]; #endif + char *content; - file = sender = NULL; + file = sender = content = NULL; while ((ch = getopt(argc, argv, "f:s:")) != -1) switch((char)ch) { case 'f': @@ -79,7 +82,6 @@ main(int argc, char *argv[]) if (isupper(*p)) *p = tolower(*p); break; - case '?': default: fprintf(stderr, "usage: from [-f file] [-s sender] [user]\n"); exit(1); @@ -115,14 +117,14 @@ main(int argc, char *argv[]) } if (!freopen(file, "r", stdin)) err(1, "%s", file); - for (newline = 1; fgets(buf, sizeof(buf), stdin) - if (*buf == '\n') { + for (newline = 1; content = readline(NULL); free(content)) { + if (*content == '\n') { newline = 1; continue; } - if (newline && !strncmp(buf, "From ", 5) && - (!sender || match(buf + 5, sender))) - printf("%s", buf); + if (newline && !strncmp(content, "From ", 5) && + (!sender || match(content + 5, sender))) + printf("%s", content); newline = 0; } exit(0); Index: Makefile ================================================== ================= RCS file: /cvs/src/usr.bin/from/Makefile,v retrieving revision 1.3 diff -u -p -r1.3 Makefile --- Makefile 21 Sep 1997 11:49:06 -0000 1.3 +++ Makefile 16 Aug 2006 12:43:50 -0000 @@ -1,5 +1,6 @@ # $OpenBSD: Makefile,v 1.3 1997/09/21 11:49:06 deraadt Exp $ PROG= from +LDADD = -lreadline -lcurses .include <bsd.prog.mk> -- http://cdp.doomed-reality.org |