/[cvs]/ccvs/src/parseinfo.c
ViewVC logotype

Diff of /ccvs/src/parseinfo.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.81 by scjones, Fri Sep 2 21:03:40 2005 UTC revision 1.82 by dprice, Sun Sep 4 23:00:00 2005 UTC
# Line 379  parse_config (const char *cvsroot, const Line 379  parse_config (const char *cvsroot, const
379      FILE *fp_info;      FILE *fp_info;
380      char *line = NULL;      char *line = NULL;
381      unsigned int ln;            /* Input file line counter.  */      unsigned int ln;            /* Input file line counter.  */
382      size_t line_allocated = 0;      char *buf = NULL;
383        size_t buf_allocated = 0;
384      size_t len;      size_t len;
385      char *p;      char *p;
386      struct config *retval;      struct config *retval;
387        /* PROCESSING       Whether config keys are currently being processed for
388         *                  this root.
389         * PROCESSED        Whether any keys have been processed for this root.
390         *                  This is initialized to true so that any initial keys
391         *                  may be processed as global defaults.
392         */
393        bool processing = true;
394        bool processed = true;
395    
396      TRACE (TRACE_FUNCTION, "parse_config (%s)", cvsroot);      TRACE (TRACE_FUNCTION, "parse_config (%s)", cvsroot);
397    
# Line 435  parse_config (const char *cvsroot, const Line 444  parse_config (const char *cvsroot, const
444      }      }
445    
446      ln = 0;  /* Have not read any lines yet.  */      ln = 0;  /* Have not read any lines yet.  */
447      while (getline (&line, &line_allocated, fp_info) >= 0)      while (getline (&buf, &buf_allocated, fp_info) >= 0)
448      {      {
449          ln++; /* Keep track of input file line number for error messages.  */          ln++; /* Keep track of input file line number for error messages.  */
450    
451            line = buf;
452    
453            /* Skip leading white space.  */
454            while (isspace (*line)) line++;
455    
456          /* Skip comments.  */          /* Skip comments.  */
457          if (line[0] == '#')          if (line[0] == '#')
458              continue;              continue;
459    
460          /* At least for the moment we don't skip whitespace at the start          /* Is there any kind of written standard for the syntax of this
            of the line.  Too picky?  Maybe.  But being insufficiently  
            picky leads to all sorts of confusion, and it is a lot easier  
            to start out picky and relax it than the other way around.  
   
            Is there any kind of written standard for the syntax of this  
461             sort of config file?  Anywhere in POSIX for example (I guess             sort of config file?  Anywhere in POSIX for example (I guess
462             makefiles are sort of close)?  Red Hat Linux has a bunch of             makefiles are sort of close)?  Red Hat Linux has a bunch of
463             these too (with some GUI tools which edit them)...             these too (with some GUI tools which edit them)...
# Line 464  parse_config (const char *cvsroot, const Line 473  parse_config (const char *cvsroot, const
473    
474          len = strlen (line) - 1;          len = strlen (line) - 1;
475          if (line[len] == '\n')          if (line[len] == '\n')
476              line[len] = '\0';              line[len--] = '\0';
477    
478          /* Skip blank lines.  */          /* Skip blank lines.  */
479          if (line[0] == '\0')          if (line[0] == '\0')
# Line 472  parse_config (const char *cvsroot, const Line 481  parse_config (const char *cvsroot, const
481    
482          TRACE (TRACE_DATA, "parse_info() examining line: `%s'", line);          TRACE (TRACE_DATA, "parse_info() examining line: `%s'", line);
483    
484            /* Check for a root specification.  */
485            if (line[0] == '[' && line[len] == ']')
486            {
487                cvsroot_t *tmproot;
488    
489                line++[len] = '\0';
490                tmproot = parse_cvsroot (line);
491    
492                /* Ignoring method.  */
493                if (!tmproot
494                    /* FIXME: Check isThisHost (tmproot->hostname).  */
495                    || (tmproot->method != local_method
496                        && (!tmproot->hostname || !isThisHost (tmproot->hostname)))
497                    || !isSamePath (tmproot->directory, cvsroot))
498                {
499                    if (processed) processing = false;
500                }
501                else
502                {
503                    TRACE (TRACE_FLOW, "Matched root section`%s'", line);
504                    processing = true;
505                    processed = false;
506                }
507    
508                continue;
509            }
510    
511            /* There is data on this line.  */
512    
513            /* Even if the data is bad or ignored, consider data processed for
514             * this root.
515             */
516            processed = true;
517    
518            if (!processing)
519                /* ...but it is for a different root.  */
520                 continue;
521    
522          /* The first '=' separates keyword from value.  */          /* The first '=' separates keyword from value.  */
523          p = strchr (line, '=');          p = strchr (line, '=');
524          if (!p)          if (!p)
# Line 659  parse_config (const char *cvsroot, const Line 706  parse_config (const char *cvsroot, const
706      if (fclose (fp_info) < 0)      if (fclose (fp_info) < 0)
707          error (0, errno, "cannot close %s", infopath);          error (0, errno, "cannot close %s", infopath);
708      if (freeinfopath) free (freeinfopath);      if (freeinfopath) free (freeinfopath);
709      if (line) free (line);      if (buf) free (buf);
710    
711      return retval;      return retval;
712  }  }

Legend:
Removed from v.1.81  
changed lines
  Added in v.1.82

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26