Annotation of researchv10no/cmd/basic/bite/src/left.c, revision 1.1.1.1

1.1       root        1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
                      2: 
                      3:  *     /////////////////////////////////////
                      4:  *     /////////////////////////////////////
                      5:  *     ////////////// left.c ///////////////
                      6:  *     /// J. P. Hawkins WH X4610 8C-001 ///
                      7:  *     ///// Thu Mar  5 06:15:32 1981 //////
                      8:  *     /////////////////////////////////////
                      9:  *     /////////////////////////////////////
                     10:  *     @(#) left.c: V1.1 3/5/81
                     11: 
                     12:  * function left$(string,n)
                     13:  *     where the first n chars of the string are returned
                     14:  *             n is a number or numerical expression
                     15:  */
                     16: 
                     17: extern char    scratch[];
                     18: 
                     19: char   *
                     20: left(args)
                     21: char   args[];
                     22: {
                     23:        double  evalx();
                     24:        char    *prncpy();
                     25:        char    *holdptr;
                     26:        char    num[20];
                     27:        int     number;
                     28:        char    result[80];
                     29: 
                     30:        holdptr = args;
                     31:        holdptr = prncpy(result,args)+1; /* point to string field */
                     32:        prncpy(num,holdptr);    /* get number of chars */
                     33:        evals(result,scratch);
                     34:        number=(int)evalx(num); /* convert expr to integer */
                     35:        strncpy(result,scratch,number); /* get the beginning seg of string*/
                     36:        result[number] = '\0';
                     37:        return(result);
                     38: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.