MCPcopy Create free account
hub / github.com/coreutils/coreutils / incr_grows

Function incr_grows

src/seq.c:415–432  ·  view source on GitHub ↗

The nonempty char array P represents a valid non-negative decimal integer. ENDP points just after the last char in P. Adjust the array to describe the next-larger integer and return whether this grows the array by one on the left. */

Source from the content-addressed store, hash-verified

413 Adjust the array to describe the next-larger integer and return
414 whether this grows the array by one on the left. */
415static bool
416incr_grows (char *p, char *endp)
417{
418 do
419 {
420 endp--;
421 if (*endp < '9')
422 {
423 (*endp)++;
424 return false;
425 }
426 *endp = '0';
427 }
428 while (p < endp);
429
430 p[-1] = '1';
431 return true;
432}
433
434/* Compare A and B with lengths A_LEN and B_LEN. A and B are integers
435 represented by nonempty arrays of digits without redundant leading '0'.

Callers 1

seq_fastFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected