home *** CD-ROM | disk | FTP | other *** search
- /*
- * centers.c
- * contains: centers()
- *
- */
-
- #include <stdio.h>
- #include <string.h>
- #include "gfuncts.h"
-
- /*
- * void
- * centers(dest,source,cols)
- *
- * ARGUMENT
- * (int) dest = destination for centered string
- * (int) source = source string to be centered
- * (int) cols = Number of columns to center on
- *
- * DESCRIPTION
- * The source string is centered on a width which is the lesser of "cols"
- * or global variable gmaxcol, and is transferred to the destination string
- * with leading blanks as required to center correctly.
- *
- * AUTHOR
- * Copyright (C)1987-1990 Greenleaf Software Inc.
- *
- * MODIFICATIONS
- *
- */
- void GF_CONV centers(outstr,instr,cols)
- int cols;
- char *outstr,*instr;
- {
- int i,left,icols;
- char *pi,*po;
-
- icols=xmin(cols,gmaxcol);
- if(icols<=1)
- return;
- left=(icols-strlen(instr))/2;
- pi=instr;
- po=outstr;
- for(i=1;i<=left;i++)
- *po++=' ';
- while((*po++ = *pi++)!=0)
- ;
- *po='\0';
- }