Date: Tue, 17 Jun 2008 12:38:08 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 143639 for review Message-ID: <200806171238.m5HCc8qO030333@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=143639 Change 143639 by gabor@gabor_server on 2008/06/17 12:37:14 - Clean up allocations - Improve --color compatibility Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/grep.c#20 edit .. //depot/projects/soc2008/gabor_textproc/grep/util.c#21 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#20 (text+ko) ==== @@ -455,14 +455,14 @@ case COLOR_OPT: if (optarg == NULL) optarg = "auto"; - if (strcmp("always", optarg) == 0) { + if (strcmp("auto", optarg) == 0 || strcmp("always", optarg) == 0 ) { color = getenv("GREP_COLOR"); if (color == NULL) color = "01;31"; - } else if ((strcmp("auto", optarg) == 0)) - color = getenv("GREP_COLOR"); - else if (strcmp("never", optarg) == 0) + } else if (strcmp("never", optarg) == 0) color = NULL; + else + usage(); break; case LABEL_OPT: label = optarg; ==== //depot/projects/soc2008/gabor_textproc/grep/util.c#21 (text+ko) ==== @@ -227,11 +227,11 @@ if ((r == 0) && (color != NULL) && !oflag && !nottext) { char *tmp, *begin, *matched, *end; - if ((begin = malloc(strlen(l->dat) - pmatch.rm_so + 20)) == NULL) + if ((begin = malloc(strlen(l->dat) - pmatch.rm_so + 1)) == NULL) errx(2, NULL); - if ((matched = malloc((pmatch.rm_eo - pmatch.rm_so + 20) * sizeof(char))) == NULL) + if ((matched = malloc((pmatch.rm_eo - pmatch.rm_so + 1) * sizeof(char))) == NULL) errx(2, NULL); - if ((end = malloc(strlen(l->dat) - pmatch.rm_eo + 20)) == NULL) + if ((end = malloc(strlen(l->dat) - pmatch.rm_eo + 1)) == NULL) errx(2, NULL); strlcpy(begin, l->dat, pmatch.rm_so + 1);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806171238.m5HCc8qO030333>