utility
|
cmd_head.c,
count_tokens.c,
cp_file.c,
errmsg.c,
file_opened.c,
find_line.c,
find_string.c,
fn_base.c,
fn_dir.c,
fn_ext.c,
fn_root.c,
gchoice.c,
gdata_line.c,
gdouble.c,
gfield.c,
gint.c,
gntoken.c,
graphics_ok.c,
gstring.c,
lock.c,
lower.c,
mat_multiply.c,
mat_transform.c,
mat_transpose.c,
mv_file.c,
new_extension.c,
nolead.c,
notrail.c,
ordinal.c,
pfield.c,
squish_blanks.c,
test.c,
unlock.c,
upper.c,
utility.h,
utility.make,
valchars.c,
vec_angle.c,
vec_crossprod.c,
vec_diff.c,
vec_dotprod.c,
vec_length.c,
vec_norm.c,
|
|
|
#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);
}
|