CCL Home Page
Up Directory CCL pfield
#include "utility.h"

char *pfield(line,field_start,field)
/*============================================================================*/
/* PURPOSE: PUT A FIELD INTO A LINE.  A FIELD IS A CONTIGUOUS SPAN OF
/*	CHARACTERS STARTING AT AN ARBITRARY POINT.  THE SUPPLIED FIELD IS
/*	OVERLAYED ONTO THE SUPPLIED LINE, OVERWRITING PREVIOUS CHARACTERS THAT
/*	OCCUPY FIELD POSITIONS.  THE TRAILING NULL OF THE FIELD IS *NOT*
/*	TRANSFERRED TO THE LINE.  IF THE FIELD IS TO BE INSERTED BEFORE THE
/*	START OF THE LINE, NO ACTION IS TAKEN.  IF THE FIELD WOULD EXTEND
/*	BEYOND THE END OF THE LINE, ONLY AS MUCH OF THE FIELD AS WILL FIT IN
/*	THE ORIGINAL LINE IS INSERTED (EXTRA CHARACTERS ARE TRUNCATED).
/*	THE NEW LINE IS RETURNED (ALWAYS THE SAME LENGTH AS THE ORIGINAL LINE).
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 22 JUNE 1993 MVG
*/
   char line[];		/* ORIGINAL LINE. */
   int field_start;	/* STARTING CHARACTER POSITION OF FIELD. */
   char field[];	/* FIELD TO BE INSERTED, NULL TERMINATED. */
   {
   char *line_pos;	/* CHARACTER POSITION IN LINE. */
   char *field_pos;	/* CHARACTER POSITION IN FIELD. */
   int line_length;	/* ORIGINAL LENGTH OF LINE. */

   if (field_start>=0)
      {
      line_pos= &line[field_start];
      line_length=strlen(line);

      for (field_pos=field; *field_pos!='\0' && (line_pos-line+1)<=line_length; field_pos++)
         {
         *line_pos++ = *field_pos;
         }
      }

   return(line);
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 5114 times since Sat Apr 17 21:59:01 1999 GMT