CVS update: /ccvs/src/

[email protected] 8 Jun 2005 14:02:35 -0000
Newsgroups gmane.comp.version-control.cvs.cvs
Message-ID <[email protected]>
User: dprice  
Date: 05/06/08 07:02:35

Modified:
 /ccvs/src/
  ChangeLog, parseinfo.c

Log:
 * parseinfo.c: Restore comparison to NULL in assignment within
 conditional to placate non-GNU compilers.  Eliminate assignments in
 conditionals where possible by GNU coding standards.  Eliminate other
 comparisons to NULL where possible.
 (Parse_Info): Make int a true bool.

File Changes:

Directory: /ccvs/src/
=====================

File [changed]: ChangeLog
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/ChangeLog?r1=1.3211&r2=1.3212
Delta lines:  +8 -0
-------------------
--- ChangeLog	3 Jun 2005 18:26:08 -0000	1.3211
+++ ChangeLog	8 Jun 2005 14:02:33 -0000	1.3212
@@ -1,3 +1,11 @@
+2005-06-08  Derek Price  <[email protected]>
+
+	* parseinfo.c: Restore comparison to NULL in assignment within
+	conditional to placate non-GNU compilers.  Eliminate assignments in
+	conditionals where possible by GNU coding standards.  Eliminate other
+	comparisons to NULL where possible.
+	(Parse_Info): Make int a true bool.
+
 2005-06-03  Derek Price  <[email protected]>
 
 	* client.c (force_gzip): New static global.

File [changed]: parseinfo.c
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/parseinfo.c?r1=1.78&r2=1.79
Delta lines:  +25 -23
---------------------
--- parseinfo.c	3 Jun 2005 18:26:09 -0000	1.78
+++ parseinfo.c	8 Jun 2005 14:02:33 -0000	1.79
@@ -37,14 +37,15 @@
     char *default_value = NULL;
     int default_line = 0;
     char *expanded_value;
-    int callback_done, line_number;
+    bool callback_done;
+    int line_number;
     char *cp, *exp, *value;
     const char *srepos;
     const char *regex_err;
 
     assert (repository);
 
-    if (current_parsed_root == NULL)
+    if (!current_parsed_root)
     {
 	/* XXX - should be error maybe? */
 	error (0, 0, "CVSROOT variable not set");
@@ -55,7 +56,7 @@
     infopath = Xasprintf ("%s/%s/%s", current_parsed_root->directory,
 			  CVSROOTADM, infofile);
     fp_info = CVS_FOPEN (infopath, "r");
-    if (fp_info == NULL)
+    if (!fp_info)
     {
 	/* If no file, don't do anything special.  */
 	if (!existence_error (errno))
@@ -71,7 +72,8 @@
 	   infopath, srepos,  (opt & PIOPT_ALL) ? "ALL" : "not ALL");
 
     /* search the info file for lines that match */
-    callback_done = line_number = 0;
+    callback_done = false;
+    line_number = 0;
     while (getline (&line, &line_allocated, fp_info) >= 0)
     {
 	line_number++;
@@ -108,8 +110,8 @@
 	value = cp;
 
 	/* strip the newline off the end of the value */
-	if ((cp = strrchr (value, '\n')) != NULL)
-	    *cp = '\0';
+	cp = strrchr (value, '\n');
+	if (cp) *cp = '\0';
 
 	/*
 	 * At this point, exp points to the regular expression, and value
@@ -121,7 +123,7 @@
 	/* save the default value so we have it later if we need it */
 	if (strcmp (exp, "DEFAULT") == 0)
 	{
-	    if (default_value != NULL)
+	    if (default_value)
 	    {
 		error (0, 0, "Multiple `DEFAULT' lines (%d and %d) in %s file",
 		       default_line, line_number, infofile);
@@ -143,7 +145,7 @@
 		error (0, 0, "Keyword `ALL' is ignored at line %d in %s file",
 		       line_number, infofile);
 	    else if ((expanded_value = expand_path (value, true, infofile,
-	                                            line_number)))
+	                                            line_number)) != NULL)
 	    {
 		err += callproc (repository, expanded_value, closure);
 		free (expanded_value);
@@ -158,7 +160,8 @@
 	    continue;
 
 	/* see if the repository matched this regular expression */
-	if ((regex_err = re_comp (exp)) != NULL)
+	regex_err = re_comp (exp);
+	if (regex_err)
 	{
 	    error (0, 0, "bad regular expression at line %d file %s: %s",
 		   line_number, infofile, regex_err);
@@ -168,14 +171,15 @@
 	    continue;				/* no match */
 
 	/* it did, so do the callback and note that we did one */
-	if ((expanded_value = expand_path (value, true, infofile, line_number)))
+	expanded_value = expand_path (value, true, infofile, line_number);
+	if (expanded_value)
 	{
 	    err += callproc (repository, expanded_value, closure);
 	    free (expanded_value);
 	}
 	else
 	    err++;
-	callback_done = 1;
+	callback_done = true;
     }
     if (ferror (fp_info))
 	error (0, errno, "cannot read %s", infopath);
@@ -183,10 +187,11 @@
 	error (0, errno, "cannot close %s", infopath);
 
     /* if we fell through and didn't callback at all, do the default */
-    if (callback_done == 0 && default_value != NULL)
+    if (!callback_done && default_value)
     {
-	if ((expanded_value = expand_path (default_value, true, infofile,
-	                                   line_number)))
+	expanded_value = expand_path (default_value, true, infofile,
+	                              line_number);
+	if (expanded_value)
 	{
 	    err += callproc (repository, expanded_value, closure);
 	    free (expanded_value);
@@ -196,11 +201,9 @@
     }
 
     /* free up space if necessary */
-    if (default_value != NULL)
-	free (default_value);
+    if (default_value) free (default_value);
     free (infopath);
-    if (line != NULL)
-	free (line);
+    if (line) free (line);
 
     return err;
 }
@@ -380,7 +383,7 @@
     infopath = Xasprintf ("%s/%s/%s", cvsroot, CVSROOTADM, CVSROOTADM_CONFIG);
 
     fp_info = CVS_FOPEN (infopath, "r");
-    if (fp_info == NULL)
+    if (!fp_info)
     {
 	/* If no file, don't do anything special.  */
 	if (!existence_error (errno))
@@ -433,7 +436,7 @@
 
 	/* The first '=' separates keyword from value.  */
 	p = strchr (line, '=');
-	if (p == NULL)
+	if (!p)
 	{
 	    if (!parse_error (infopath, ln))
 		error (0, 0,
@@ -484,7 +487,7 @@
 	    readBool (infopath, "TopLevelAdmin", p, &retval->top_level_admin);
 	else if (strcmp (line, "LockDir") == 0)
 	{
-	    if (retval->lock_dir != NULL)
+	    if (retval->lock_dir)
 		free (retval->lock_dir);
 	    retval->lock_dir = xstrdup (p);
 	    /* Could try some validity checking, like whether we can
@@ -616,7 +619,6 @@
     if (fclose (fp_info) < 0)
 	error (0, errno, "cannot close %s", infopath);
     free (infopath);
-    if (line != NULL)
-	free (line);
+    if (line) free (line);
     return retval;
 }