1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Extract integer from string. Start reading after the colon, if
18
(1) Integer read from string, on success.
19
(2) Zero if there are no digits.
21
========includes:============================================================*/
27
/*======extract integer from a string:=======================================*/
29
int ExtractInteger_ (char *sP)
34
/* Colon should be separator: */
35
if ((P0 = strstr (sP, ":")) == NULL) P0 = sP;
37
/* Replace each non-numeric character except minus sign with space: */
39
while ((n = *P1++) != '\0') if (!isdigit (n) && (n != '-')) *(P1 - 1) = ' ';
41
/* Try to read one integer: */
42
if (sscanf (P0, "%d", &n) != 1) return 0;
44
/* If everything worked fine, return the extracted integer: */
48
/*===========================================================================*/