strtoq.c (58f0484fa251c266ede97b591b499fe3dd4f578e) strtoq.c (e7241b8ffe2856c43aa6f2a539534aa99a43e194)
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 42 unchanged lines hidden (view full) ---

51quad_t
52strtoq(nptr, endptr, base)
53 const char *nptr;
54 char **endptr;
55 register int base;
56{
57 register const char *s;
58 register u_quad_t acc;
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 42 unchanged lines hidden (view full) ---

51quad_t
52strtoq(nptr, endptr, base)
53 const char *nptr;
54 char **endptr;
55 register int base;
56{
57 register const char *s;
58 register u_quad_t acc;
59 register int c;
59 register unsigned char c;
60 register u_quad_t qbase, cutoff;
61 register int neg, any, cutlim;
62
63 /*
64 * Skip white space and pick up leading +/- sign if any.
65 * If base is 0, allow 0x for hex and 0 for octal, else
66 * assume decimal; if base is already 16, allow 0x.
67 */

--- 36 unchanged lines hidden (view full) ---

104 * Set any if any `digits' consumed; make it negative to indicate
105 * overflow.
106 */
107 qbase = (unsigned)base;
108 cutoff = neg ? -(u_quad_t)QUAD_MIN : QUAD_MAX;
109 cutlim = cutoff % qbase;
110 cutoff /= qbase;
111 for (acc = 0, any = 0;; c = *s++) {
60 register u_quad_t qbase, cutoff;
61 register int neg, any, cutlim;
62
63 /*
64 * Skip white space and pick up leading +/- sign if any.
65 * If base is 0, allow 0x for hex and 0 for octal, else
66 * assume decimal; if base is already 16, allow 0x.
67 */

--- 36 unchanged lines hidden (view full) ---

104 * Set any if any `digits' consumed; make it negative to indicate
105 * overflow.
106 */
107 qbase = (unsigned)base;
108 cutoff = neg ? -(u_quad_t)QUAD_MIN : QUAD_MAX;
109 cutlim = cutoff % qbase;
110 cutoff /= qbase;
111 for (acc = 0, any = 0;; c = *s++) {
112 if (!isascii(c))
113 break;
112 if (isdigit(c))
113 c -= '0';
114 else if (isalpha(c))
115 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
116 else
117 break;
118 if (c >= base)
119 break;

--- 17 unchanged lines hidden ---
114 if (isdigit(c))
115 c -= '0';
116 else if (isalpha(c))
117 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
118 else
119 break;
120 if (c >= base)
121 break;

--- 17 unchanged lines hidden ---