# 2.11BSD#431 - /usr/ingres/source/equel/runtime/IIatoi.c

##### Functions

    IIatoi            X

       1: /*
       2: **  IIatoi()
       3: **  ASCII CHARACTER STRING TO 16-BIT INTEGER CONVERSION
       4: **
       5: **	`a' is a pointer to the character string, `i' is a
       6: **	pointer to the word which is to contain the result.
       7: **
       8: **	The return value of the function is:
       9: **		zero:	succesful conversion; `i' contains the integer
      10: **		+1:	numeric overflow; `i' is unchanged
      11: **		-1:	syntax error; `i' is unchanged
      12: **
      13: **	A valid string is of the form:
      14: **		<space>* [+-] <space>* <digit>* <space>*
      15: **
      16: **		Eric's utility routine.
      17: **
      18: */
      19:
      20: IIatoi(a1, i)
      21: char    *a1;
      22: int *i;
      23: {
      24:     int     sign;       /* flag to indicate the sign */
      25:     register int    x;      /* holds the integer being formed */
      26:     register char   c;
      27:     register char   *a;
      28:
      29:     a = a1;
      30:     sign = 0;
      31:     /* skip leading blanks */
      32:     while (*a == ' ')
      33:         a++;
      34:     /* check for sign */
      35:     switch (*a)
      36:     {
      37:
      38:       case '-':
      39:         sign = -1;
      40:
      41:       case '+':
      42:         while (*++a == ' ');
      43:     }
      44:
      45:     /* at this point everything had better be numeric */
      46:     x = 0;
      47:     while ((c = *a) <= '9' && c >= '0')
      48:     {
      49:         if (x > 3276 || (x == 3276 && c > '7'))
      50:             return (1);     /* overflow */
      51:         x = x * 10 + c - '0';
      52:         a++;
      53:     }
      54:
      55:     /* eaten all the numerics; better be all blanks */
      56:     while (c = *a++)
      57:         if(c != ' ')            /* syntax error */
      58:             return (-1);
      59:     *i = sign ? -x : x;
      60:     return (0);     /* successful termination */
      61: }

#### Defined functions

IIatoi defined in line 20; used 1 times

- in /usr/ingres/source/equel/runtime/IIp_err.c line 66

Last modified: 1980-12-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 357 |