PERFORCE change 144268 for review

Gabor Kovesdan gabor at FreeBSD.org
Sun Jun 29 12:39:15 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=144268

Change 144268 by gabor at gabor_server on 2008/06/29 12:39:07

	- Allow wider contexts with unsigned long long

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/diff/diff.c#4 edit
.. //depot/projects/soc2008/gabor_textproc/diff/diff.h#3 edit

Differences ...

==== //depot/projects/soc2008/gabor_textproc/diff/diff.c#4 (text+ko) ====

@@ -46,7 +46,8 @@
 
 int	 aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
 int	 sflag, tflag, Tflag, wflag;
-int	 format, context, status;
+int	 format, status;
+unsigned long long context;
 char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;
 struct stat stb1, stb2;
 struct excludes *excludes_list;
@@ -122,7 +123,6 @@
 main(int argc, char **argv)
 {
 	char	*ep, **oargv;
-	long	 l;
 	int	 ch, lastch, gotstdin, prevoptind, newarg;
 
 	oargv = argv;
@@ -139,7 +139,7 @@
 				usage();	/* disallow -[0-9]+ */
 			else if (lastch == 'c' || lastch == 'u')
 				context = 0;
-			else if (!isdigit(lastch) || context > INT_MAX / 10)
+			else if (!isdigit(lastch) || context > ULLONG_MAX / 10)
 				usage();
 			context = (context * 10) + (ch - '0');
 			break;
@@ -153,10 +153,9 @@
 		case 'c':
 			format = D_CONTEXT;
 			if (optarg != NULL) {
-				l = strtol(optarg, &ep, 10);
-				if (*ep != '\0' || l < 0 || l >= INT_MAX)
-					usage();
-				context = (int)l;
+				context = strtoull(optarg, &ep, 10);
+				if (*ep != '\0' || context == ULLONG_MAX)
+					err(2, "context out of range\n");
 			} else
 				context = 3;
 			break;
@@ -228,10 +227,9 @@
 		case 'u':
 			format = D_UNIFIED;
 			if (optarg != NULL) {
-				l = strtol(optarg, &ep, 10);
-				if (*ep != '\0' || l < 0 || l >= INT_MAX)
-					usage();
-				context = (int)l;
+				context = strtoull(optarg, &ep, 10);
+				if (*ep != '\0' || context == ULLONG_MAX)
+					err(2, "context out of range\n");
 			} else
 				context = 3;
 			break;

==== //depot/projects/soc2008/gabor_textproc/diff/diff.h#3 (text+ko) ====

@@ -77,7 +77,8 @@
 
 extern int	 aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
 		 sflag, tflag, Tflag, wflag;
-extern int	 format, context, status;
+extern int	 format, status;
+extern unsigned long long context;
 extern char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;
 extern struct	 stat stb1, stb2;
 extern struct	 excludes *excludes_list;


More information about the p4-projects mailing list