strtoul.c (58f0484fa251c266ede97b591b499fe3dd4f578e) strtoul.c (e7241b8ffe2856c43aa6f2a539534aa99a43e194)
1/*
2 * Copyright (c) 1990, 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

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

49unsigned long
50strtoul(nptr, endptr, base)
51 const char *nptr;
52 char **endptr;
53 register int base;
54{
55 register const char *s = nptr;
56 register unsigned long acc;
1/*
2 * Copyright (c) 1990, 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

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

49unsigned long
50strtoul(nptr, endptr, base)
51 const char *nptr;
52 char **endptr;
53 register int base;
54{
55 register const char *s = nptr;
56 register unsigned long acc;
57 register int c;
57 register unsigned char c;
58 register unsigned long cutoff;
59 register int neg = 0, any, cutlim;
60
61 /*
62 * See strtol for comments as to the logic used.
63 */
64 do {
65 c = *s++;

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

75 s += 2;
76 base = 16;
77 }
78 if (base == 0)
79 base = c == '0' ? 8 : 10;
80 cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
81 cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
82 for (acc = 0, any = 0;; c = *s++) {
58 register unsigned long cutoff;
59 register int neg = 0, any, cutlim;
60
61 /*
62 * See strtol for comments as to the logic used.
63 */
64 do {
65 c = *s++;

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

75 s += 2;
76 base = 16;
77 }
78 if (base == 0)
79 base = c == '0' ? 8 : 10;
80 cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
81 cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
82 for (acc = 0, any = 0;; c = *s++) {
83 if (!isascii(c))
84 break;
83 if (isdigit(c))
84 c -= '0';
85 else if (isalpha(c))
86 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
87 else
88 break;
89 if (c >= base)
90 break;

--- 17 unchanged lines hidden ---
85 if (isdigit(c))
86 c -= '0';
87 else if (isalpha(c))
88 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
89 else
90 break;
91 if (c >= base)
92 break;

--- 17 unchanged lines hidden ---