PERFORCE change 140947 for review
Gabor Kovesdan
gabor at FreeBSD.org
Wed Apr 30 22:00:16 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=140947
Change 140947 by gabor at gabor_server on 2008/04/30 21:59:49
- style(9)
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/diff/diff.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/diff/diff.h#2 edit
.. //depot/projects/soc2008/gabor_textproc/diff/diffdir.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/diff/diffreg.c#2 edit
.. //depot/projects/soc2008/gabor_textproc/diff/pathnames.h#2 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/diff/diff.c#2 (text+ko) ====
@@ -1,4 +1,4 @@
-/*
+/*-
* Copyright (c) 2003 Todd C. Miller <Todd.Miller at courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -36,9 +36,9 @@
#include <errno.h>
#include <getopt.h>
#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
#include <string.h>
#include <unistd.h>
@@ -87,26 +87,26 @@
{ "forward-ed", no_argument, NULL, 'f' },
{ "ignore-matching-lines", required_argument, NULL, 'I' },
{ "ignore-case", no_argument, NULL, 'i' },
+ { "label", required_argument, NULL, 'L' },
{ "paginate", no_argument, NULL, 'l' },
- { "label", required_argument, NULL, 'L' },
{ "new-file", no_argument, NULL, 'N' },
{ "rcs", no_argument, NULL, 'n' },
{ "unidirectional-new-file", no_argument, NULL, 'P' },
{ "show-c-function", no_argument, NULL, 'p' },
{ "brief", no_argument, NULL, 'q' },
{ "recursive", no_argument, NULL, 'r' },
+ { "starting-file", required_argument, NULL, 'S' },
{ "report-identical-files", no_argument, NULL, 's' },
- { "starting-file", required_argument, NULL, 'S' },
+ { "initial-tab", no_argument, NULL, 'T' },
{ "expand-tabs", no_argument, NULL, 't' },
- { "initial-tab", no_argument, NULL, 'T' },
/* XXX: -u is incompatible with GNU version */
{ "unified", optional_argument, NULL, 'U' },
{ "version", no_argument, NULL, 'v' },
/* XXX: UNIMPLEMENTED
{ "width", optional_argument, NULL, 'W' }, */
{ "ignore-all-space", no_argument, NULL, 'w' },
+ { "exclude-from", required_argument, NULL, 'X' },
{ "exclude", required_argument, NULL, 'x' },
- { "exclude-from", required_argument, NULL, 'X' },
/* XXX: UNIMPLEMENTED
{ "side-by-side", no_argument, NULL, 'y' }, */
{ NULL, 0, NULL, '\0'}
@@ -115,15 +115,15 @@
void usage(void);
void push_excludes(char *);
void push_ignore_pats(char *);
-void read_excludes_file(char *file);
+void read_excludes_file(char *);
void set_argstr(char **, char **);
int
main(int argc, char **argv)
{
- char *ep, **oargv;
- long l;
- int ch, lastch, gotstdin, prevoptind, newarg;
+ char *ep, **oargv;
+ long l;
+ int ch, lastch, gotstdin, prevoptind, newarg;
oargv = argv;
gotstdin = 0;
@@ -160,13 +160,13 @@
} else
context = 3;
break;
- case 'd':
- dflag = 1;
- break;
case 'D':
format = D_IFDEF;
ifdefname = optarg;
break;
+ case 'd':
+ dflag = 1;
+ break;
case 'e':
format = D_EDIT;
break;
@@ -200,12 +200,12 @@
case 'n':
format = D_NREVERSE;
break;
+ case 'P':
+ Pflag = 1;
+ break;
case 'p':
pflag = 1;
break;
- case 'P':
- Pflag = 1;
- break;
case 'r':
rflag = 1;
break;
@@ -269,7 +269,7 @@
int error;
if ((error = regcomp(&ignore_re, ignore_pats,
- REG_NEWLINE | REG_EXTENDED)) != 0) {
+ REG_NEWLINE | REG_EXTENDED)) != 0) {
regerror(error, &ignore_re, buf, sizeof(buf));
if (*ignore_pats != '\0')
errx(2, "%s: %s", ignore_pats, buf);
@@ -314,7 +314,7 @@
void *
emalloc(size_t n)
{
- void *p;
+ void *p;
if (p == 0)
errx(2, NULL);
@@ -327,7 +327,7 @@
void *
erealloc(void *p, size_t n)
{
- void *q;
+ void *q;
if (n == 0)
errx(2, NULL);
@@ -343,8 +343,8 @@
int
easprintf(char **ret, const char *fmt, ...)
{
- int len;
- va_list ap;
+ int len;
+ va_list ap;
va_start(ap, fmt);
len = vasprintf(ret, fmt, ap);
@@ -358,20 +358,20 @@
char *
estrdup(const char *str)
{
- size_t len;
- char *cp;
+ size_t len;
+ char *cp;
len = strlen(str) + 1;
cp = emalloc(len);
strlcpy(cp, str, len);
- return cp;
+ return (cp);
}
void
set_argstr(char **av, char **ave)
{
- size_t argsize;
- char **ap;
+ size_t argsize;
+ char **ap;
argsize = 4 + *ave - *av + 1;
diffargs = emalloc(argsize);
@@ -390,9 +390,9 @@
void
read_excludes_file(char *file)
{
- FILE *fp;
- char *buf, *pattern;
- size_t len;
+ FILE *fp;
+ char *buf, *pattern;
+ size_t len;
if (strcmp(file, "-") == 0)
fp = stdin;
@@ -416,7 +416,7 @@
void
push_excludes(char *pattern)
{
- struct excludes *entry;
+ struct excludes *entry;
entry = emalloc(sizeof(*entry));
entry->pattern = pattern;
@@ -427,7 +427,7 @@
void
push_ignore_pats(char *pattern)
{
- size_t len;
+ size_t len;
if (ignore_pats == NULL)
ignore_pats = estrdup(pattern);
==== //depot/projects/soc2008/gabor_textproc/diff/diff.h#2 (text+ko) ====
@@ -1,5 +1,6 @@
/* $FreeBSD$ */
/* $OpenBSD: diff.h,v 1.29 2004/12/09 18:56:10 millert Exp $ */
+
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,6 +33,7 @@
*/
#include <sys/types.h>
+
#include <regex.h>
/*
@@ -69,17 +71,17 @@
#define D_SKIPPED2 9 /* path2 was a special file */
struct excludes {
- char *pattern;
- struct excludes *next;
+ char *pattern;
+ struct excludes *next;
};
-extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
- sflag, tflag, Tflag, wflag;
-extern int format, context, status;
+extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
+ sflag, tflag, Tflag, wflag;
+extern int format, context, status;
extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
-extern struct stat stb1, stb2;
-extern struct excludes *excludes_list;
-extern regex_t ignore_re;
+extern struct stat stb1, stb2;
+extern struct excludes *excludes_list;
+extern regex_t ignore_re;
char *splice(char *, char *);
int diffreg(char *, char *, int);
==== //depot/projects/soc2008/gabor_textproc/diff/diffdir.c#2 (text+ko) ====
@@ -1,4 +1,4 @@
-/*
+/*-
* Copyright (c) 2003 Todd C. Miller <Todd.Miller at courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -44,10 +44,10 @@
#include "diff.h"
-static int dircompare(const void *, const void *);
-static int excluded(const char *);
-static struct dirent **slurpdir(char *, char **, int);
-static void diffit(struct dirent *, char *, size_t, char *, size_t);
+static int dircompare(const void *, const void *);
+static int excluded(const char *);
+static structdirent **slurpdir(char *, char **, int);
+static void diffit(struct dirent *, char *, size_t, char *, size_t);
#define d_status d_type /* we need to store status for -l */
@@ -57,12 +57,12 @@
void
diffdir(char *p1, char *p2)
{
- struct dirent **dirp1, **dirp2, **dp1, **dp2;
- struct dirent *dent1, *dent2;
- size_t dirlen1, dirlen2;
- char path1[MAXPATHLEN], path2[MAXPATHLEN];
- char *dirbuf1, *dirbuf2;
- int pos;
+ struct dirent **dirp1, **dirp2, **dp1, **dp2;
+ struct dirent *dent1, *dent2;
+ size_t dirlen1, dirlen2;
+ char path1[MAXPATHLEN], path2[MAXPATHLEN];
+ char *dirbuf1, *dirbuf2;
+ int pos;
dirlen1 = strlcpy(path1, *p1 ? p1 : ".", sizeof(path1));
if (dirlen1 >= sizeof(path1) - 1) {
@@ -168,12 +168,12 @@
static struct dirent **
slurpdir(char *path, char **bufp, int enoentok)
{
- char *buf, *ebuf, *cp;
- size_t bufsize, have, need;
- long base;
- int fd, nbytes, entries;
- struct stat sb;
- struct dirent **dirlist, *dp;
+ char *buf, *ebuf, *cp;
+ size_t bufsize, have, need;
+ long base;
+ int fd, nbytes, entries;
+ struct stat sb;
+ struct dirent **dirlist, *dp;
*bufp = NULL;
if ((fd = open(path, O_RDONLY, 0644)) == -1) {
@@ -254,8 +254,8 @@
static int
dircompare(const void *vp1, const void *vp2)
{
- struct dirent *dp1 = *((struct dirent **) vp1);
- struct dirent *dp2 = *((struct dirent **) vp2);
+ struct dirent *dp1 = *((struct dirent **) vp1);
+ struct dirent *dp2 = *((struct dirent **) vp2);
return (strcmp(dp1->d_name, dp2->d_name));
}
@@ -266,7 +266,7 @@
static void
diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2)
{
- int flags = D_HEADER;
+ int flags = D_HEADER;
strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1);
if (stat(path1, &stb1) != 0) {
@@ -317,7 +317,7 @@
static int
excluded(const char *entry)
{
- struct excludes *excl;
+ struct excludes *excl;
/* always skip "." and ".." */
if (entry[0] == '.' &&
==== //depot/projects/soc2008/gabor_textproc/diff/diffreg.c#2 (text+ko) ====
@@ -158,14 +158,14 @@
*/
struct cand {
- int x;
- int y;
- int pred;
+ int x;
+ int y;
+ int pred;
};
struct line {
- int serial;
- int value;
+ int serial;
+ int value;
} *file[2];
/*
@@ -174,10 +174,10 @@
* understand the highly mnemonic field names)
*/
struct context_vec {
- int a; /* start line in old file */
- int b; /* end line in old file */
- int c; /* start line in new file */
- int d; /* end line in new file */
+ int a; /* start line in old file */
+ int b; /* end line in old file */
+ int c; /* start line in new file */
+ int d; /* end line in new file */
};
static FILE *opentemp(const char *);
@@ -229,9 +229,9 @@
static struct context_vec *context_vec_ptr;
#define FUNCTION_CONTEXT_SIZE 55
-static char lastbuf[FUNCTION_CONTEXT_SIZE];
-static int lastline;
-static int lastmatchline;
+static char lastbuf[FUNCTION_CONTEXT_SIZE];
+static int lastline;
+static int lastmatchline;
/*
* chrtran points to one of 2 translation tables: cup2low if folding upper to
@@ -294,13 +294,13 @@
int
diffreg(char *ofile1, char *ofile2, int flags)
{
- char *file1 = ofile1;
- char *file2 = ofile2;
- FILE *f1 = NULL;
- FILE *f2 = NULL;
- int rval = D_SAME;
- int i, ostdout = -1;
- pid_t pid = -1;
+ char *file1 = ofile1;
+ char *file2 = ofile2;
+ FILE *f1 = NULL;
+ FILE *f2 = NULL;
+ int rval = D_SAME;
+ int i, ostdout = -1;
+ pid_t pid = -1;
anychange = 0;
lastline = 0;
@@ -372,9 +372,9 @@
}
if (lflag) {
/* redirect stdout to pr */
- int pfd[2];
- char *header;
- char *prargv[] = { "pr", "-h", NULL, "-f", NULL };
+ int pfd[2];
+ char *header;
+ char *prargv[] = { "pr", "-h", NULL, "-f", NULL };
easprintf(&header, "%s %s %s", diffargs, file1, file2);
prargv[2] = header;
@@ -477,8 +477,8 @@
static int
files_differ(FILE *f1, FILE *f2, int flags)
{
- char buf1[BUFSIZ], buf2[BUFSIZ];
- size_t i, j;
+ char buf1[BUFSIZ], buf2[BUFSIZ];
+ size_t i, j;
if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != stb2.st_size ||
(stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT))
@@ -501,9 +501,9 @@
static FILE *
opentemp(const char *file)
{
- char buf[BUFSIZ], *tempdir, tempfile[MAXPATHLEN];
- ssize_t nread;
- int ifd, ofd;
+ char buf[BUFSIZ], *tempdir, tempfile[MAXPATHLEN];
+ ssize_t nread;
+ int ifd, ofd;
if (strcmp(file, "-") == 0)
ifd = STDIN_FILENO;
@@ -539,7 +539,7 @@
char *
splice(char *dir, char *file)
{
- char *tail, *buf;
+ char *tail, *buf;
if ((tail = strrchr(file, '/')) == NULL)
tail = file;
@@ -552,9 +552,9 @@
static void
prepare(int i, FILE *fd, off_t filesize)
{
- struct line *p;
- int j, h;
- size_t sz;
+ struct line *p;
+ int j, h;
+ size_t sz;
rewind(fd);
@@ -577,7 +577,7 @@
static void
prune(void)
{
- int i, j;
+ int i, j;
for (pref = 0; pref < len[0] && pref < len[1] &&
file[0][pref + 1].value == file[1][pref + 1].value;
@@ -598,7 +598,7 @@
static void
equiv(struct line *a, int n, struct line *b, int m, int *c)
{
- int i, j;
+ int i, j;
i = j = 1;
while (i <= n && j <= m) {
@@ -627,10 +627,10 @@
static int
isqrt(int n)
{
- int y, x = 1;
+ int y, x = 1;
if (n == 0)
- return(0);
+ return (0);
do { /* newton was a stinker */
y = x;
@@ -645,10 +645,9 @@
static int
stone(int *a, int n, int *b, int *c)
{
- int i, k, y, j, l;
- int oldc, tc, oldl;
- u_int numtries;
-
+ int i, k, y, j, l;
+ int oldc, tc, oldl;
+ u_int numtries;
const u_int bound = dflag ? UINT_MAX : MAX(256, isqrt(n));
k = 0;
@@ -688,7 +687,7 @@
static int
newcand(int x, int y, int pred)
{
- struct cand *q;
+ struct cand *q;
if (clen == clistlen) {
clistlen = clistlen * 11 / 10;
@@ -704,13 +703,13 @@
static int
search(int *c, int k, int y)
{
- int i, j, l, t;
+ int i, j, l, t;
if (clist[c[k]].y < y) /* quick look for typical case */
return (k + 1);
i = 0;
j = k + 1;
- while (1) {
+ for(;;) {
l = i + j;
if ((l >>= 1) <= i)
break;
@@ -728,8 +727,8 @@
static void
unravel(int p)
{
- struct cand *q;
- int i;
+ struct cand *q;
+ int i;
for (i = 0; i <= len[0]; i++)
J[i] = i <= pref ? i :
@@ -747,8 +746,8 @@
static void
check(char *file1, FILE *f1, char *file2, FILE *f2)
{
- int i, j, jackpot, c, d;
- long ctold, ctnew;
+ int i, j, jackpot, c, d;
+ long ctold, ctnew;
rewind(f1);
rewind(f2);
@@ -846,8 +845,8 @@
static void
sort(struct line *a, int n)
{
- struct line *ai, *aim, w;
- int j, m = 0, k;
+ struct line *ai, *aim, w;
+ int j, m = 0, k;
if (n == 0)
return;
@@ -878,7 +877,7 @@
static void
unsort(struct line *f, int l, int *b)
{
- int *a, i;
+ int *a, i;
a = emalloc((l + 1) * sizeof(int));
for (i = 1; i <= l; i++)
@@ -891,7 +890,7 @@
static int
skipline(FILE *f)
{
- int i, c;
+ int i, c;
for (i = 1; (c = getc(f)) != '\n' && c != EOF; i++)
continue;
@@ -901,7 +900,7 @@
static void
output(char *file1, FILE *f1, char *file2, FILE *f2, int flags)
{
- int m, i0, i1, j0, j1;
+ int m, i0, i1, j0, j1;
rewind(f1);
rewind(f2);
@@ -974,8 +973,8 @@
static char *
preadline(int fd, size_t len, off_t off)
{
- char *line;
- ssize_t nr;
+ char *line;
+ ssize_t nr;
line = emalloc(len + 1);
if ((nr = pread(fd, line, len, off)) < 0)
@@ -989,7 +988,7 @@
static int
ignoreline(char *line)
{
- int ret;
+ int ret;
ret = regexec(&ignore_re, line, 0, NULL, 0);
free(line);
@@ -1007,8 +1006,8 @@
change(char *file1, FILE *f1, char *file2, FILE *f2, int a, int b, int c, int d,
int *pflags)
{
- static size_t max_context = 64;
- int i;
+ static size_t max_context = 64;
+ int i;
restart:
if (format != D_IFDEF && a > b && c > d)
@@ -1140,7 +1139,7 @@
static int
fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile)
{
- int i, j, c, lastc, col, nc;
+ int i, j, c, lastc, col, nc;
/*
* When doing #ifdef's, copy down to current line
@@ -1219,8 +1218,8 @@
static int
readhash(FILE *f)
{
- int i, t, space;
- int sum;
+ int i, t, space;
+ int sum;
sum = 1;
space = 0;
@@ -1281,8 +1280,8 @@
static int
asciifile(FILE *f)
{
- unsigned char buf[BUFSIZ];
- int i, cnt;
+ unsigned char buf[BUFSIZ];
+ int i, cnt;
if (aflag || f == NULL)
return (1);
@@ -1300,10 +1299,10 @@
static char *
match_function(const long *f, int pos, FILE *file)
{
- unsigned char buf[FUNCTION_CONTEXT_SIZE];
- size_t nc;
- int last = lastline;
- char *state = NULL;
+ unsigned char buf[FUNCTION_CONTEXT_SIZE];
+ size_t nc;
+ int last = lastline;
+ char *state = NULL;
lastline = pos;
while (pos > last) {
@@ -1332,13 +1331,13 @@
strlcat(lastbuf, state,
sizeof lastbuf);
lastmatchline = pos;
- return lastbuf;
+ return (lastbuf);
}
}
}
pos--;
}
- return lastmatchline > 0 ? lastbuf : NULL;
+ return (lastmatchline > 0 ? lastbuf : NULL);
}
/* dump accumulated "context" diff changes */
@@ -1346,9 +1345,9 @@
dump_context_vec(FILE *f1, FILE *f2)
{
struct context_vec *cvp = context_vec_start;
- int lowa, upb, lowc, upd, do_output;
- int a, b, c, d;
- char ch, *f;
+ int lowa, upb, lowc, upd, do_output;
+ int a, b, c, d;
+ char ch, *f;
if (context_vec_start > context_vec_ptr)
return;
@@ -1451,9 +1450,9 @@
dump_unified_vec(FILE *f1, FILE *f2)
{
struct context_vec *cvp = context_vec_start;
- int lowa, upb, lowc, upd;
- int a, b, c, d;
- char ch, *f;
+ int lowa, upb, lowc, upd;
+ int a, b, c, d;
+ char ch, *f;
if (context_vec_start > context_vec_ptr)
return;
==== //depot/projects/soc2008/gabor_textproc/diff/pathnames.h#2 (text+ko) ====
@@ -1,6 +1,6 @@
/* $FreeBSD$ */
/* $OpenBSD: pathnames.h,v 1.10 2003/07/09 00:07:44 millert Exp $ */
-/*
+/*-
* Copyright (c) 2003 Todd C. Miller <Todd.Miller at courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
More information about the p4-projects
mailing list